feature(image): Добавлен редактор фото
This commit is contained in:
@@ -213,20 +213,34 @@ class _Collection extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
_buildTitle(),
|
||||
const HSpace(4),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Assets.icons.typeCards.image(
|
||||
height: 18.h,
|
||||
width: 18.w,
|
||||
color: AppColors.disabled,
|
||||
),
|
||||
const WSpace(2),
|
||||
AppTypography(
|
||||
'${collection.likesCount.toString()} ${Utils.declOfNum(collection.likesCount, ['карточек', 'карточки', 'карточек'])}',
|
||||
type: Regular14px(),
|
||||
color: AppColors.disabled,
|
||||
),
|
||||
],
|
||||
FutureBuilder(
|
||||
future: getIt<AppDatabase>().ticketsDao.getTicketsInCollectionCount(
|
||||
collection.id,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return SizedBox.square(
|
||||
dimension: 18.r,
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Assets.icons.typeCards.image(
|
||||
height: 18.h,
|
||||
width: 18.w,
|
||||
color: AppColors.disabled,
|
||||
),
|
||||
const WSpace(2),
|
||||
AppTypography(
|
||||
'${snapshot.data.toString()} ${Utils.declOfNum(snapshot.data ?? 0, ['карточек', 'карточки', 'карточек'])}',
|
||||
type: Regular14px(),
|
||||
color: AppColors.disabled,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const HSpace(6),
|
||||
const CollectionProgressBar(),
|
||||
|
||||
@@ -136,11 +136,12 @@ class CollectionCard extends StatelessWidget {
|
||||
collection.id,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return SizedBox.square(
|
||||
dimension: 18.r,
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return _buildIconWithText(
|
||||
icon: Assets.icons.typeCards,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:remever/common/functions.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
@@ -65,15 +66,33 @@ class _CreateScreenState extends State<CreateScreen> {
|
||||
}
|
||||
|
||||
final String fileName = path.basename(filePath);
|
||||
final String destinationPath = path.join(ticketsDirPath, fileName);
|
||||
|
||||
final copiedFile = await File(filePath).copy(destinationPath);
|
||||
final String destinationPath = path.join(
|
||||
ticketsDirPath,
|
||||
'${DateTime.now()}$fileName',
|
||||
);
|
||||
|
||||
final croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: filePath,
|
||||
aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '',
|
||||
initAspectRatio: CropAspectRatioPreset.square,
|
||||
lockAspectRatio: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (croppedFile == null) return;
|
||||
|
||||
await File(croppedFile.path).copy(destinationPath);
|
||||
|
||||
safeSetState(() {
|
||||
_dto =
|
||||
isQuestion
|
||||
? _dto.copyWith(questionImage: copiedFile.path)
|
||||
: _dto.copyWith(answerImage: copiedFile.path);
|
||||
? _dto.copyWith(questionImage: destinationPath)
|
||||
: _dto.copyWith(answerImage: destinationPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:remever/common/functions.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
@@ -76,9 +77,26 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
|
||||
}
|
||||
|
||||
final String fileName = path.basename(originPath!);
|
||||
final String destinationPath = path.join(collectionsDirPath, fileName);
|
||||
final String destinationPath = path.join(
|
||||
collectionsDirPath,
|
||||
'${DateTime.now()}$fileName',
|
||||
);
|
||||
|
||||
await File(originPath).copy(destinationPath);
|
||||
final croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: originPath,
|
||||
aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '',
|
||||
initAspectRatio: CropAspectRatioPreset.square,
|
||||
lockAspectRatio: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (croppedFile == null) return;
|
||||
|
||||
await File(croppedFile.path).copy(destinationPath);
|
||||
|
||||
_updateCollection(avatar: destinationPath);
|
||||
} catch (e) {
|
||||
|
||||
@@ -184,6 +184,7 @@ class _CrudCollectionFullscreenFieldState
|
||||
|
||||
void _onSubmitTap() {
|
||||
widget.onEditingComplete(_controller.text);
|
||||
|
||||
context.back();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user