feature(image): Добавлен редактор фото

This commit is contained in:
2025-09-08 21:47:51 +03:00
parent 6cb9e82e61
commit 90531e6e4e
14 changed files with 133 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@@ -334,6 +334,18 @@ image
3.0
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image-4.5.4/
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image-4.5.4/lib/
image_cropper
3.3
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper-9.1.0/
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper-9.1.0/lib/
image_cropper_for_web
3.3
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper_for_web-6.1.0/
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper_for_web-6.1.0/lib/
image_cropper_platform_interface
3.3
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper_platform_interface-7.1.0/
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper_platform_interface-7.1.0/lib/
image_size_getter
2.12
file:///Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_size_getter-2.4.0/

View File

@@ -8,6 +8,8 @@ flutter_secure_storage_macos=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/f
flutter_secure_storage_web=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/flutter_secure_storage_web-1.2.1/
flutter_secure_storage_windows=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.1.2/
fluttertoast=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/fluttertoast-8.2.12/
image_cropper=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper-9.1.0/
image_cropper_for_web=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/image_cropper_for_web-6.1.0/
package_info_plus=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/
path_provider=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/path_provider-2.1.5/
path_provider_android=/Users/vitalijnecitajlo/.pub-cache/hosted/pub.dev/path_provider_android-2.2.16/

File diff suppressed because one or more lines are too long

View File

@@ -38,6 +38,11 @@
<meta-data
android:name="io.flutter.embedding.android.EnableImpeller"
android:value="false" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Ucrop.CropTheme" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Ucrop.CropTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
</style>
</resources>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode
setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
@@ -15,4 +16,8 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
<style name="Ucrop.CropTheme" parent="Theme.AppCompat.Light.NoActionBar" /> <!--add
this line-->
</resources>

View File

@@ -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(),

View File

@@ -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,

View File

@@ -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);
});
}

View File

@@ -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) {

View File

@@ -184,6 +184,7 @@ class _CrudCollectionFullscreenFieldState
void _onSubmitTap() {
widget.onEditingComplete(_controller.text);
context.back();
}

View File

@@ -693,6 +693,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.5.4"
image_cropper:
dependency: "direct main"
description:
name: image_cropper
sha256: "4e9c96c029eb5a23798da1b6af39787f964da6ffc78fd8447c140542a9f7c6fc"
url: "https://pub.dev"
source: hosted
version: "9.1.0"
image_cropper_for_web:
dependency: transitive
description:
name: image_cropper_for_web
sha256: fd81ebe36f636576094377aab32673c4e5d1609b32dec16fad98d2b71f1250a9
url: "https://pub.dev"
source: hosted
version: "6.1.0"
image_cropper_platform_interface:
dependency: transitive
description:
name: image_cropper_platform_interface
sha256: "6ca6b81769abff9a4dcc3bbd3d75f5dfa9de6b870ae9613c8cd237333a4283af"
url: "https://pub.dev"
source: hosted
version: "7.1.0"
image_size_getter:
dependency: transitive
description:

View File

@@ -39,6 +39,7 @@ dependencies:
modal_bottom_sheet: ^3.0.0
file_picker: ^10.0.0
path_provider: ^2.1.5
image_cropper: ^9.1.0
# logs