2021-06-11 10:12:26 +00:00
|
|
|
import 'dart:io';
|
2021-06-02 13:54:31 +00:00
|
|
|
import 'dart:typed_data';
|
2021-09-25 08:30:51 +00:00
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
import 'package:extended_image/extended_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:image_editor/image_editor.dart';
|
2021-06-02 16:45:35 +00:00
|
|
|
import 'package:logging/logging.dart';
|
2021-10-30 05:43:56 +00:00
|
|
|
import 'package:path/path.dart' as path;
|
2021-06-02 16:45:35 +00:00
|
|
|
import 'package:photo_manager/photo_manager.dart';
|
2021-06-02 21:46:38 +00:00
|
|
|
import 'package:photos/core/event_bus.dart';
|
|
|
|
import 'package:photos/db/files_db.dart';
|
|
|
|
import 'package:photos/events/local_photos_updated_event.dart';
|
2021-10-30 05:43:56 +00:00
|
|
|
import 'package:photos/models/file.dart' as ente;
|
|
|
|
import 'package:photos/models/location.dart';
|
2021-06-14 14:58:36 +00:00
|
|
|
import 'package:photos/services/local_sync_service.dart';
|
2021-06-02 22:00:03 +00:00
|
|
|
import 'package:photos/services/sync_service.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/common/loading_widget.dart';
|
2021-10-11 12:11:31 +00:00
|
|
|
import 'package:photos/ui/editor/filtered_image.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/viewer/file/detail_page.dart';
|
2021-06-02 16:45:35 +00:00
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
2021-06-09 13:38:27 +00:00
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
2021-06-02 16:45:35 +00:00
|
|
|
import 'package:photos/utils/toast_util.dart';
|
2021-06-10 15:55:12 +00:00
|
|
|
import 'package:syncfusion_flutter_core/theme.dart';
|
|
|
|
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
2021-06-02 13:54:31 +00:00
|
|
|
|
|
|
|
class ImageEditorPage extends StatefulWidget {
|
|
|
|
final ImageProvider imageProvider;
|
2021-06-09 13:38:27 +00:00
|
|
|
final DetailPageConfiguration detailPageConfig;
|
2021-06-02 16:45:35 +00:00
|
|
|
final ente.File originalFile;
|
2021-06-02 13:54:31 +00:00
|
|
|
|
2021-06-09 13:38:27 +00:00
|
|
|
const ImageEditorPage(
|
|
|
|
this.imageProvider,
|
|
|
|
this.originalFile,
|
|
|
|
this.detailPageConfig, {
|
|
|
|
Key key,
|
|
|
|
}) : super(key: key);
|
2021-06-02 13:54:31 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
_ImageEditorPageState createState() => _ImageEditorPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ImageEditorPageState extends State<ImageEditorPage> {
|
2021-09-25 08:30:09 +00:00
|
|
|
static const double kBrightnessDefault = 1;
|
|
|
|
static const double kBrightnessMin = 0;
|
|
|
|
static const double kBrightnessMax = 2;
|
|
|
|
static const double kSaturationDefault = 1;
|
|
|
|
static const double kSaturationMin = 0;
|
|
|
|
static const double kSaturationMax = 2;
|
|
|
|
|
2021-06-02 16:45:35 +00:00
|
|
|
final _logger = Logger("ImageEditor");
|
2021-06-02 13:54:31 +00:00
|
|
|
final GlobalKey<ExtendedImageEditorState> editorKey =
|
|
|
|
GlobalKey<ExtendedImageEditorState>();
|
|
|
|
|
2021-09-25 08:30:09 +00:00
|
|
|
double _brightness = kBrightnessDefault;
|
|
|
|
double _saturation = kSaturationDefault;
|
2021-06-10 18:52:45 +00:00
|
|
|
bool _hasEdited = false;
|
2021-06-10 18:28:09 +00:00
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-06-04 18:57:07 +00:00
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () async {
|
2021-06-10 18:52:45 +00:00
|
|
|
if (_hasBeenEdited()) {
|
|
|
|
await _showExitConfirmationDialog();
|
|
|
|
} else {
|
|
|
|
replacePage(context, DetailPage(widget.detailPageConfig));
|
|
|
|
}
|
2021-06-04 18:57:07 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Color(0x00000000),
|
|
|
|
elevation: 0,
|
2021-06-10 18:52:45 +00:00
|
|
|
actions: _hasBeenEdited()
|
|
|
|
? [
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.only(right: 16, left: 16),
|
|
|
|
onPressed: () {
|
|
|
|
editorKey.currentState.reset();
|
|
|
|
setState(() {
|
2021-09-25 08:30:09 +00:00
|
|
|
_brightness = kBrightnessDefault;
|
|
|
|
_saturation = kSaturationDefault;
|
2021-06-10 18:52:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: Icon(Icons.history),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
: [],
|
2021-06-04 18:57:07 +00:00
|
|
|
),
|
2021-09-25 08:30:51 +00:00
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(child: _buildImage()),
|
|
|
|
Padding(padding: EdgeInsets.all(4)),
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
_buildBrightness(),
|
|
|
|
_buildSat(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.all(8)),
|
|
|
|
_buildBottomBar(),
|
|
|
|
Padding(padding: EdgeInsets.all(Platform.isIOS ? 16 : 6)),
|
|
|
|
],
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:52:45 +00:00
|
|
|
bool _hasBeenEdited() {
|
2021-09-25 08:30:09 +00:00
|
|
|
return _hasEdited ||
|
|
|
|
_saturation != kSaturationDefault ||
|
|
|
|
_brightness != kBrightnessDefault;
|
2021-06-10 18:52:45 +00:00
|
|
|
}
|
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
Widget _buildImage() {
|
|
|
|
return Hero(
|
2021-06-09 13:38:27 +00:00
|
|
|
tag: widget.detailPageConfig.tagPrefix + widget.originalFile.tag(),
|
2021-06-10 18:22:04 +00:00
|
|
|
child: ExtendedImage(
|
|
|
|
image: widget.imageProvider,
|
|
|
|
extendedImageEditorKey: editorKey,
|
|
|
|
mode: ExtendedImageMode.editor,
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
initEditorConfigHandler: (_) => EditorConfig(
|
|
|
|
maxScale: 8.0,
|
|
|
|
cropRectPadding: const EdgeInsets.all(20.0),
|
|
|
|
hitTestSize: 20.0,
|
2021-06-10 18:25:48 +00:00
|
|
|
cornerColor: Color.fromRGBO(45, 150, 98, 1),
|
2021-06-10 18:52:45 +00:00
|
|
|
editActionDetailsIsChanged: (_) {
|
|
|
|
setState(() {
|
|
|
|
_hasEdited = true;
|
|
|
|
});
|
|
|
|
},
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
2021-10-13 06:14:35 +00:00
|
|
|
loadStateChanged: (state) {
|
|
|
|
if (state.extendedImageLoadState == LoadState.completed) {
|
|
|
|
return FilteredImage(
|
|
|
|
child: state.completedWidget,
|
|
|
|
brightness: _brightness,
|
|
|
|
saturation: _saturation,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return loadWidget;
|
2021-10-11 12:11:31 +00:00
|
|
|
},
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBottomBar() {
|
2021-06-02 16:45:35 +00:00
|
|
|
return Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
children: [
|
|
|
|
_buildFlipButton(),
|
|
|
|
_buildRotateLeftButton(),
|
|
|
|
_buildRotateRightButton(),
|
|
|
|
_buildSaveButton(),
|
|
|
|
],
|
|
|
|
);
|
2021-06-02 13:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildFlipButton() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
return GestureDetector(
|
2021-06-11 10:12:26 +00:00
|
|
|
behavior: HitTestBehavior.translucent,
|
2021-06-02 13:54:31 +00:00
|
|
|
onTap: () {
|
|
|
|
flip();
|
|
|
|
},
|
2021-09-25 08:30:51 +00:00
|
|
|
child: SizedBox(
|
2021-06-02 13:54:31 +00:00
|
|
|
width: 80,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 2),
|
|
|
|
child: Icon(
|
|
|
|
Icons.flip,
|
2022-05-13 09:34:16 +00:00
|
|
|
color: Theme.of(context).iconTheme.color.withOpacity(0.8),
|
2021-06-02 13:54:31 +00:00
|
|
|
size: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.all(2)),
|
|
|
|
Text(
|
2022-06-09 04:59:23 +00:00
|
|
|
"Flip",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildRotateLeftButton() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
return GestureDetector(
|
2021-06-11 10:12:26 +00:00
|
|
|
behavior: HitTestBehavior.translucent,
|
2021-06-02 13:54:31 +00:00
|
|
|
onTap: () {
|
|
|
|
rotate(false);
|
|
|
|
},
|
2021-09-25 08:30:51 +00:00
|
|
|
child: SizedBox(
|
2021-06-02 13:54:31 +00:00
|
|
|
width: 80,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2022-05-13 09:34:16 +00:00
|
|
|
Icon(
|
|
|
|
Icons.rotate_left,
|
|
|
|
color: Theme.of(context).iconTheme.color.withOpacity(0.8),
|
|
|
|
),
|
2021-06-02 13:54:31 +00:00
|
|
|
Padding(padding: EdgeInsets.all(2)),
|
|
|
|
Text(
|
2022-06-09 04:59:23 +00:00
|
|
|
"Rotate left",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildRotateRightButton() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
return GestureDetector(
|
2021-06-11 10:12:26 +00:00
|
|
|
behavior: HitTestBehavior.translucent,
|
2021-06-02 13:54:31 +00:00
|
|
|
onTap: () {
|
|
|
|
rotate(true);
|
|
|
|
},
|
2021-09-25 08:30:51 +00:00
|
|
|
child: SizedBox(
|
2021-06-02 13:54:31 +00:00
|
|
|
width: 80,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2022-05-13 09:34:16 +00:00
|
|
|
Icon(
|
|
|
|
Icons.rotate_right,
|
|
|
|
color: Theme.of(context).iconTheme.color.withOpacity(0.8),
|
|
|
|
),
|
2021-06-02 13:54:31 +00:00
|
|
|
Padding(padding: EdgeInsets.all(2)),
|
|
|
|
Text(
|
2022-06-09 04:59:23 +00:00
|
|
|
"Rotate right",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildSaveButton() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-02 13:54:31 +00:00
|
|
|
return GestureDetector(
|
2021-06-11 10:12:26 +00:00
|
|
|
behavior: HitTestBehavior.translucent,
|
2021-06-02 13:54:31 +00:00
|
|
|
onTap: () {
|
2021-06-02 16:45:35 +00:00
|
|
|
_saveEdits();
|
2021-06-02 13:54:31 +00:00
|
|
|
},
|
2021-09-25 08:30:51 +00:00
|
|
|
child: SizedBox(
|
2021-06-02 13:54:31 +00:00
|
|
|
width: 80,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2022-05-13 09:34:16 +00:00
|
|
|
Icon(
|
|
|
|
Icons.save_alt_outlined,
|
|
|
|
color: Theme.of(context).iconTheme.color.withOpacity(0.8),
|
|
|
|
),
|
2021-06-02 13:54:31 +00:00
|
|
|
Padding(padding: EdgeInsets.all(2)),
|
|
|
|
Text(
|
2022-06-09 04:59:23 +00:00
|
|
|
"Save copy",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-02 13:54:31 +00:00
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-02 16:45:35 +00:00
|
|
|
Future<void> _saveEdits() async {
|
2022-06-09 04:59:23 +00:00
|
|
|
final dialog = createProgressDialog(context, "Saving...");
|
2021-06-02 16:45:35 +00:00
|
|
|
await dialog.show();
|
2021-06-02 13:54:31 +00:00
|
|
|
final ExtendedImageEditorState state = editorKey.currentState;
|
|
|
|
if (state == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final Rect rect = state.getCropRect();
|
|
|
|
if (rect == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final EditActionDetails action = state.editAction;
|
|
|
|
final double radian = action.rotateAngle;
|
|
|
|
|
|
|
|
final bool flipHorizontal = action.flipY;
|
|
|
|
final bool flipVertical = action.flipX;
|
|
|
|
final Uint8List img = state.rawImageData;
|
|
|
|
|
|
|
|
if (img == null) {
|
2021-06-02 16:45:35 +00:00
|
|
|
_logger.severe("null rawImageData");
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Something went wrong");
|
2021-06-02 13:54:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final ImageEditorOption option = ImageEditorOption();
|
|
|
|
|
|
|
|
option.addOption(ClipOption.fromRect(rect));
|
|
|
|
option.addOption(
|
2022-06-11 08:23:52 +00:00
|
|
|
FlipOption(horizontal: flipHorizontal, vertical: flipVertical),
|
|
|
|
);
|
2021-06-02 13:54:31 +00:00
|
|
|
if (action.hasRotateAngle) {
|
|
|
|
option.addOption(RotateOption(radian.toInt()));
|
|
|
|
}
|
|
|
|
|
2021-09-25 08:30:09 +00:00
|
|
|
option.addOption(ColorOption.saturation(_saturation));
|
|
|
|
option.addOption(ColorOption.brightness(_brightness));
|
2021-06-02 13:54:31 +00:00
|
|
|
|
|
|
|
option.outputFormat = const OutputFormat.png(88);
|
|
|
|
|
|
|
|
final DateTime start = DateTime.now();
|
|
|
|
final Uint8List result = await ImageEditor.editImage(
|
|
|
|
image: img,
|
|
|
|
imageEditorOption: option,
|
|
|
|
);
|
2021-06-02 16:45:35 +00:00
|
|
|
_logger.info('result.length = ${result?.length}');
|
2021-06-02 13:54:31 +00:00
|
|
|
final Duration diff = DateTime.now().difference(start);
|
2021-06-02 16:45:35 +00:00
|
|
|
_logger.info('image_editor time : $diff');
|
2021-06-02 13:54:31 +00:00
|
|
|
|
2021-06-02 16:45:35 +00:00
|
|
|
if (result == null) {
|
|
|
|
_logger.severe("null result");
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Something went wrong");
|
2021-06-02 16:45:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
2021-06-02 21:46:38 +00:00
|
|
|
final fileName =
|
|
|
|
path.basenameWithoutExtension(widget.originalFile.title) +
|
|
|
|
"_edited_" +
|
|
|
|
DateTime.now().microsecondsSinceEpoch.toString() +
|
|
|
|
path.extension(widget.originalFile.title);
|
|
|
|
final newAsset = await PhotoManager.editor.saveImage(
|
2021-06-02 16:49:38 +00:00
|
|
|
result,
|
2021-06-02 21:46:38 +00:00
|
|
|
title: fileName,
|
2021-06-02 16:49:38 +00:00
|
|
|
);
|
2021-06-02 22:00:03 +00:00
|
|
|
final newFile =
|
|
|
|
await ente.File.fromAsset(widget.originalFile.deviceFolder, newAsset);
|
2021-06-02 21:46:38 +00:00
|
|
|
newFile.creationTime = widget.originalFile.creationTime;
|
2021-06-09 15:32:30 +00:00
|
|
|
newFile.collectionID = widget.originalFile.collectionID;
|
2021-06-11 10:12:26 +00:00
|
|
|
newFile.location = widget.originalFile.location;
|
2021-07-22 07:25:30 +00:00
|
|
|
if (!newFile.hasLocation() && widget.originalFile.localID != null) {
|
2021-07-24 17:22:46 +00:00
|
|
|
var assetEntity = await widget.originalFile.getAsset();
|
|
|
|
if (assetEntity != null) {
|
|
|
|
final latLong = await assetEntity.latlngAsync();
|
|
|
|
newFile.location = Location(latLong.latitude, latLong.longitude);
|
|
|
|
}
|
2021-06-11 09:02:46 +00:00
|
|
|
}
|
2021-06-09 15:32:30 +00:00
|
|
|
newFile.generatedID = await FilesDB.instance.insert(newFile);
|
2021-06-14 14:58:36 +00:00
|
|
|
await LocalSyncService.instance.trackEditedFile(newFile);
|
2021-06-02 21:46:38 +00:00
|
|
|
Bus.instance.fire(LocalPhotosUpdatedEvent([newFile]));
|
2021-06-02 22:00:03 +00:00
|
|
|
SyncService.instance.sync();
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Edits saved");
|
2021-06-11 10:12:26 +00:00
|
|
|
_logger.info("Original file " + widget.originalFile.toString());
|
|
|
|
_logger.info("Saved edits to file " + newFile.toString());
|
2021-06-09 13:38:27 +00:00
|
|
|
final existingFiles = widget.detailPageConfig.files;
|
2021-06-29 05:13:16 +00:00
|
|
|
final files = (await widget.detailPageConfig.asyncLoader(
|
2022-06-11 08:23:52 +00:00
|
|
|
existingFiles[existingFiles.length - 1].creationTime,
|
|
|
|
existingFiles[0].creationTime,
|
|
|
|
))
|
2021-06-29 05:13:16 +00:00
|
|
|
.files;
|
2021-06-09 13:38:27 +00:00
|
|
|
replacePage(
|
|
|
|
context,
|
|
|
|
DetailPage(
|
|
|
|
widget.detailPageConfig.copyWith(
|
|
|
|
files: files,
|
2021-06-09 15:32:30 +00:00
|
|
|
selectedIndex: files
|
|
|
|
.indexWhere((file) => file.generatedID == newFile.generatedID),
|
2021-06-09 13:38:27 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2021-06-02 16:45:35 +00:00
|
|
|
} catch (e, s) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Oops, could not save edits");
|
2021-06-02 16:45:35 +00:00
|
|
|
_logger.severe(e, s);
|
|
|
|
}
|
|
|
|
await dialog.hide();
|
2021-06-02 13:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flip() {
|
|
|
|
editorKey.currentState?.flip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void rotate(bool right) {
|
|
|
|
editorKey.currentState?.rotate(right: right);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildSat() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-10 15:55:12 +00:00
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2021-09-25 08:30:51 +00:00
|
|
|
SizedBox(
|
2021-06-10 15:55:12 +00:00
|
|
|
width: 40,
|
|
|
|
child: Text(
|
2022-06-18 12:23:51 +00:00
|
|
|
"Color",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-10 15:55:12 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: SfSliderTheme(
|
|
|
|
data: SfSliderThemeData(
|
|
|
|
activeTrackHeight: 4,
|
|
|
|
inactiveTrackHeight: 2,
|
|
|
|
inactiveTrackColor: Colors.grey[900],
|
|
|
|
activeTrackColor: Color.fromRGBO(45, 150, 98, 1),
|
|
|
|
thumbColor: Color.fromRGBO(45, 150, 98, 1),
|
|
|
|
thumbRadius: 10,
|
|
|
|
tooltipBackgroundColor: Colors.grey[900],
|
|
|
|
),
|
|
|
|
child: SfSlider(
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
2021-06-10 18:28:09 +00:00
|
|
|
_saturation = value;
|
2021-06-10 15:55:12 +00:00
|
|
|
});
|
|
|
|
},
|
2021-06-10 18:28:09 +00:00
|
|
|
value: _saturation,
|
2021-06-10 15:55:12 +00:00
|
|
|
enableTooltip: true,
|
|
|
|
stepSize: 0.01,
|
2021-09-25 08:30:09 +00:00
|
|
|
min: kSaturationMin,
|
|
|
|
max: kSaturationMax,
|
2021-06-10 15:55:12 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-06-02 13:54:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBrightness() {
|
2022-05-13 09:34:16 +00:00
|
|
|
TextStyle subtitle2 = Theme.of(context).textTheme.subtitle2;
|
|
|
|
|
2021-06-10 15:55:12 +00:00
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2021-09-25 08:30:51 +00:00
|
|
|
SizedBox(
|
2021-06-10 15:55:12 +00:00
|
|
|
width: 40,
|
|
|
|
child: Text(
|
2022-06-09 04:59:23 +00:00
|
|
|
"Light",
|
2022-05-13 09:34:16 +00:00
|
|
|
style: subtitle2.copyWith(
|
|
|
|
color: subtitle2.color.withOpacity(0.8),
|
2021-06-10 15:55:12 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: SfSliderTheme(
|
|
|
|
data: SfSliderThemeData(
|
|
|
|
activeTrackHeight: 4,
|
|
|
|
inactiveTrackHeight: 2,
|
|
|
|
activeTrackColor: Color.fromRGBO(45, 150, 98, 1),
|
|
|
|
inactiveTrackColor: Colors.grey[900],
|
|
|
|
thumbColor: Color.fromRGBO(45, 150, 98, 1),
|
|
|
|
thumbRadius: 10,
|
|
|
|
tooltipBackgroundColor: Colors.grey[900],
|
|
|
|
),
|
|
|
|
child: SfSlider(
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
2021-06-10 18:28:09 +00:00
|
|
|
_brightness = value;
|
2021-06-10 15:55:12 +00:00
|
|
|
});
|
|
|
|
},
|
2021-06-10 18:28:09 +00:00
|
|
|
value: _brightness,
|
2021-06-10 15:55:12 +00:00
|
|
|
enableTooltip: true,
|
|
|
|
stepSize: 0.01,
|
2021-09-25 08:30:09 +00:00
|
|
|
min: kBrightnessMin,
|
|
|
|
max: kBrightnessMax,
|
2021-06-10 15:55:12 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-06-02 13:54:31 +00:00
|
|
|
);
|
|
|
|
}
|
2021-06-04 18:57:07 +00:00
|
|
|
|
|
|
|
Future<void> _showExitConfirmationDialog() async {
|
|
|
|
AlertDialog alert = AlertDialog(
|
2022-06-09 04:59:23 +00:00
|
|
|
title: Text("Discard edits?"),
|
2021-06-04 18:57:07 +00:00
|
|
|
actions: [
|
|
|
|
TextButton(
|
2022-06-09 04:59:23 +00:00
|
|
|
child: Text("Yes", style: TextStyle(color: Colors.red)),
|
2021-06-04 18:57:07 +00:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop('dialog');
|
2021-06-09 13:38:27 +00:00
|
|
|
replacePage(context, DetailPage(widget.detailPageConfig));
|
2021-06-04 18:57:07 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
TextButton(
|
2022-06-09 04:59:23 +00:00
|
|
|
child: Text("No", style: TextStyle(color: Colors.white)),
|
2021-06-04 18:57:07 +00:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop('dialog');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return alert;
|
|
|
|
},
|
|
|
|
barrierColor: Colors.black87,
|
|
|
|
);
|
|
|
|
}
|
2021-06-02 13:54:31 +00:00
|
|
|
}
|