Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Add straighten control to crop editor

r4khul8f74c6cf3007
diff --git a/mobile/apps/photos/changes/straighten-photos.md b/mobile/apps/photos/changes/straighten-photos.md
new file mode 100644
index 0000000000..6eaf44310a
--- /dev/null
+++ b/mobile/apps/photos/changes/straighten-photos.md
@@ -0,0 +1 @@
+- Added a straighten control to the photo crop editor.
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
index 02a415b6e6..32cca1c067 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
@@ -11,6 +11,7 @@ class CircularIconButton extends StatelessWidget {
final IconData? icon;
final Widget? child;
final double size;
+ final double width;
final bool isSelected;
const CircularIconButton({
@@ -22,6 +23,7 @@ class CircularIconButton extends StatelessWidget {
this.icon,
this.child,
this.size = 60,
+ this.width = 90,
this.isSelected = false,
}) : assert(
hugeIcon != null || svgPath != null || icon != null || child != null,
@@ -53,7 +55,7 @@ class CircularIconButton extends StatelessWidget {
}
return SizedBox(
- width: 90,
+ width: width,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_adjust_slider.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_adjust_slider.dart
new file mode 100644
index 0000000000..a633961cbb
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_adjust_slider.dart
@@ -0,0 +1,248 @@
+import "package:ente_components/ente_components.dart";
+import 'package:flutter/material.dart';
+
+class ImageEditorAdjustSlider extends StatelessWidget {
+ const ImageEditorAdjustSlider({
+ super.key,
+ required this.min,
+ required this.max,
+ required this.value,
+ required this.onChanged,
+ this.onChangeEnd,
+ });
+
+ final double min;
+ final double max;
+ final double value;
+ final ValueChanged<double> onChanged;
+ final ValueChanged<double>? onChangeEnd;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return SizedBox(
+ height: 40,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ Positioned.fill(
+ child: Container(
+ margin: const EdgeInsets.symmetric(horizontal: 20),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(25),
+ color: colors.fillLight,
+ ),
+ ),
+ ),
+ Container(
+ margin: const EdgeInsets.symmetric(horizontal: 20),
+ decoration: BoxDecoration(borderRadius: BorderRadius.circular(25)),
+ child: SliderTheme(
+ data: SliderTheme.of(context).copyWith(
+ thumbShape: _ColorPickerThumbShape(color: colors.primary),
+ overlayShape: const RoundSliderOverlayShape(overlayRadius: 0),
+ activeTrackColor: colors.primary,
+ inactiveTrackColor: colors.fillLight,
+ trackShape: _CenterBasedTrackShape(isBipolar: min < 0),
+ trackHeight: 24,
+ ),
+ child: Slider(
+ value: value,
+ onChanged: onChanged,
+ onChangeEnd: onChangeEnd,
+ min: min,
+ max: max,
+ ),
+ ),
+ ),
+ Container(
+ margin: const EdgeInsets.symmetric(horizontal: 38),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Container(
+ width: 6,
+ height: 6,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colors.fillBase.withAlpha(30),
+ ),
+ ),
+ Container(
+ width: 6,
+ height: 6,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colors.fillBase.withAlpha(30),
+ ),
+ ),
+ Container(
+ width: 6,
+ height: 6,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colors.fillBase.withAlpha(30),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class _ColorPickerThumbShape extends SliderComponentShape {
+ const _ColorPickerThumbShape({required this.color});
+
+ final Color color;
+
+ static const double thumbRadius = 15.0;
+
+ @override
+ Size getPreferredSize(bool isEnabled, bool isDiscrete) {
+ return const Size(thumbRadius * 2, thumbRadius * 2);
+ }
+
+ @override
+ void paint(
+ PaintingContext context,
+ Offset center, {
+ required Animation<double> activationAnimation,
+ required Animation<double> enableAnimation,
+ required bool isDiscrete,
+ required TextPainter labelPainter,
+ required RenderBox parentBox,
+ required Size sizeWithOverflow,
+ required SliderThemeData sliderTheme,
+ required TextDirection textDirection,
+ required double textScaleFactor,
+ required double value,
+ }) {
+ final canvas = context.canvas;
+
+ final trackRect = sliderTheme.trackShape!.getPreferredRect(
+ parentBox: parentBox,
+ offset: Offset.zero,
+ sliderTheme: sliderTheme,
+ isEnabled: true,
+ isDiscrete: isDiscrete,
+ );
+
+ final constrainedCenter = Offset(
+ center.dx.clamp(
+ trackRect.left + thumbRadius,
+ trackRect.right - thumbRadius,
+ ),
+ center.dy,
+ );
+
+ final paint = Paint()
+ ..color = Colors.white
+ ..style = PaintingStyle.fill;
+
+ canvas.drawCircle(constrainedCenter, thumbRadius, paint);
+
+ final innerPaint = Paint()
+ ..color = color
+ ..style = PaintingStyle.fill;
+ canvas.drawCircle(constrainedCenter, 12.5, innerPaint);
+ }
+}
+
+class _CenterBasedTrackShape extends SliderTrackShape {
+ const _CenterBasedTrackShape({this.isBipolar = true});
+
+ static const double horizontalPadding = 6.0;
+
+ final bool isBipolar;
+
+ @override
+ Rect getPreferredRect({
+ required RenderBox parentBox,
+ Offset offset = Offset.zero,
+ required SliderThemeData sliderTheme,
+ bool isEnabled = false,
+ bool isDiscrete = false,
+ }) {
+ final double trackHeight = sliderTheme.trackHeight ?? 8;
+ final double trackLeft = offset.dx + horizontalPadding;
+ final double trackTop =
+ offset.dy + (parentBox.size.height - trackHeight) / 2;
+ final double trackWidth = parentBox.size.width - (horizontalPadding * 2);
+ return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
+ }
+
+ @override
+ void paint(
+ PaintingContext context,
+ Offset offset, {
+ required RenderBox parentBox,
+ required SliderThemeData sliderTheme,
+ required Animation<double> enableAnimation,
+ required TextDirection textDirection,
+ required Offset thumbCenter,
+ Offset? secondaryOffset,
+ bool isEnabled = false,
+ bool isDiscrete = false,
+ double? additionalActiveTrackHeight,
+ }) {
+ final Canvas canvas = context.canvas;
+ final Rect trackRect = getPreferredRect(
+ parentBox: parentBox,
+ offset: offset,
+ sliderTheme: sliderTheme,
+ isEnabled: isEnabled,
+ isDiscrete: isDiscrete,
+ );
+
+ final double centerX = trackRect.left + trackRect.width / 2;
+
+ final double clampedThumbDx = thumbCenter.dx.clamp(
+ trackRect.left + _ColorPickerThumbShape.thumbRadius,
+ trackRect.right - _ColorPickerThumbShape.thumbRadius,
+ );
+
+ final double activeStartDx = isBipolar ? centerX : trackRect.left;
+
+ final Paint inactivePaint = Paint()
+ ..color = sliderTheme.inactiveTrackColor!
+ ..style = PaintingStyle.fill;
+
+ final RRect inactiveRRect = RRect.fromRectAndRadius(
+ trackRect,
+ Radius.circular(trackRect.height / 2),
+ );
+
+ canvas.drawRRect(inactiveRRect, inactivePaint);
+
+ if ((clampedThumbDx - activeStartDx).abs() >
+ _ColorPickerThumbShape.thumbRadius) {
+ final Paint activePaint = Paint()
+ ..color = sliderTheme.activeTrackColor!
+ ..style = PaintingStyle.fill;
+
+ final Rect activeRect = clampedThumbDx >= activeStartDx
+ ? Rect.fromLTWH(
+ activeStartDx,
+ trackRect.top,
+ clampedThumbDx - activeStartDx,
+ trackRect.height,
+ )
+ : Rect.fromLTWH(
+ clampedThumbDx,
+ trackRect.top,
+ activeStartDx - clampedThumbDx,
+ trackRect.height,
+ );
+
+ final RRect activeRRect = RRect.fromRectAndRadius(
+ activeRect,
+ Radius.circular(trackRect.height / 2),
+ );
+
+ canvas.drawRRect(activeRRect, activePaint);
+ }
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_crop_rotate.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_crop_rotate.dart
index bbc4d716d8..319008aa4f 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_crop_rotate.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_crop_rotate.dart
@@ -1,12 +1,17 @@
+import 'dart:math';
+
import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
import 'package:flutter/material.dart';
import "package:flutter_svg/svg.dart";
import "package:hugeicons/hugeicons.dart";
import "package:photos/ui/tools/editor/image_editor/circular_icon_button.dart";
+import "package:photos/ui/tools/editor/image_editor/image_editor_adjust_slider.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_configs_mixin.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
+import "package:photos/ui/tools/editor/image_editor/image_editor_tune_bar.dart";
import 'package:pro_image_editor/core/mixins/converted_configs.dart';
+import 'package:pro_image_editor/features/crop_rotate_editor/providers/tilt_provider.dart';
import 'package:pro_image_editor/pro_image_editor.dart';
enum CropAspectRatioType {
@@ -57,6 +62,8 @@ enum CropAspectRatioType {
final double? ratio;
}
+enum _CropControl { none, crop, straighten }
+
class ImageEditorCropRotateBar extends StatefulWidget with SimpleConfigsAccess {
const ImageEditorCropRotateBar({
super.key,
@@ -80,6 +87,61 @@ class ImageEditorCropRotateBar extends StatefulWidget with SimpleConfigsAccess {
class _ImageEditorCropRotateBarState extends State<ImageEditorCropRotateBar>
with ImageEditorConvertedConfigs, SimpleConfigsAccessState {
CropAspectRatioType selectedAspectRatio = CropAspectRatioType.original;
+ _CropControl selectedControl = _CropControl.crop;
+ double? _lastStraightenAngle;
+ double? _cachedBarHeight;
+ double? _cachedActionWidth;
+ TextScaler? _cachedTextScaler;
+ Locale? _cachedLocale;
+
+ double _barHeight(BuildContext context, double actionWidth) {
+ final textScaler = MediaQuery.textScalerOf(context);
+ final locale = Localizations.localeOf(context);
+ if (_cachedBarHeight != null &&
+ _cachedActionWidth == actionWidth &&
+ _cachedTextScaler == textScaler &&
+ _cachedLocale == locale) {
+ return _cachedBarHeight!;
+ }
+
+ var labelHeight = 0.0;
+ for (final label in [
+ context.strings.crop,
+ context.strings.straighten,
+ context.strings.rotate,
+ context.strings.flip,
+ ]) {
+ final painter = TextPainter(
+ text: TextSpan(text: label, style: TextStyles.body),
+ textDirection: Directionality.of(context),
+ textScaler: textScaler,
+ )..layout(maxWidth: actionWidth);
+ labelHeight = max(labelHeight, painter.height);
+ painter.dispose();
+ }
+
+ _cachedActionWidth = actionWidth;
+ _cachedTextScaler = textScaler;
+ _cachedLocale = locale;
+ return _cachedBarHeight = max(
+ editorBottomBarHeight,
+ 60 + 8 + labelHeight + 40 + 24,
+ );
+ }
+
+ void _handleStraightenTap(double angle) {
+ if (selectedControl != _CropControl.straighten) {
+ setState(() => selectedControl = _CropControl.straighten);
+ return;
+ }
+
+ if (angle != 0) {
+ _lastStraightenAngle = angle;
+ widget.editor.tilt(TiltMode.rotate, 0);
+ } else if (_lastStraightenAngle != null) {
+ widget.editor.tilt(TiltMode.rotate, _lastStraightenAngle! * pi / 180);
+ }
+ }
@override
Widget build(BuildContext context) {
@@ -95,10 +157,13 @@ class _ImageEditorCropRotateBarState extends State<ImageEditorCropRotateBar>
Widget _buildFunctions(BoxConstraints constraints) {
final colors = context.componentColors;
+ final tiltConfigs = widget.configs.cropRotateEditor.tiltConfigs;
+ final straightenAngle = TiltProvider.of(context).tiltRotate * 180 / pi;
+ final actionWidth = min(90.0, constraints.maxWidth / 4);
return BottomAppBar(
color: colors.backgroundBase,
padding: EdgeInsets.zero,
- height: editorBottomBarHeight,
+ height: _barHeight(context, actionWidth),
child: Align(
alignment: Alignment.bottomCenter,
child: FadeInUp(
@@ -110,14 +175,57 @@ class _ImageEditorCropRotateBarState extends State<ImageEditorCropRotateBar>
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularIconButton(
- hugeIcon: HugeIcons.strokeRoundedRotateCrop,
+ width: actionWidth,
+ hugeIcon: HugeIcons.strokeRoundedCrop,
+ label: context.strings.crop,
+ isSelected: selectedControl == _CropControl.crop,
+ onTap: () => setState(() {
+ selectedControl = selectedControl == _CropControl.crop
+ ? _CropControl.none
+ : _CropControl.crop;
+ }),
+ ),
+ GestureDetector(
+ onTap: () => _handleStraightenTap(straightenAngle),
+ child: SizedBox(
+ width: actionWidth,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ CircularProgressWithValue(
+ value: straightenAngle,
+ min: tiltConfigs.tiltRotateMin,
+ max: tiltConfigs.tiltRotateMax,
+ icon: Icons.straighten,
+ hugeIcon: HugeIcons.strokeRoundedRuler,
+ progressColor: colors.primary,
+ isSelected:
+ selectedControl == _CropControl.straighten,
+ displayValueBuilder: (value) => value.round(),
+ valueSuffix: "Β°",
+ ),
+ const SizedBox(height: 8),
+ Text(
+ context.strings.straighten,
+ style: TextStyles.body.copyWith(
+ color: colors.textBase,
+ ),
+ textAlign: TextAlign.center,
+ ),
+ ],
+ ),
+ ),
+ ),
+ CircularIconButton(
+ width: actionWidth,
+ hugeIcon: HugeIcons.strokeRoundedRotate02,
label: context.strings.rotate,
onTap: () {
widget.editor.rotate();
},
),
- const SizedBox(width: 6),
CircularIconButton(
+ width: actionWidth,
hugeIcon: HugeIcons.strokeRoundedFlipLeft,
label: context.strings.flip,
onTap: () {
@@ -126,33 +234,54 @@ class _ImageEditorCropRotateBarState extends State<ImageEditorCropRotateBar>
),
],
),
- SizedBox(
- height: 40,
- child: ListView.builder(
- scrollDirection: Axis.horizontal,
- itemCount: CropAspectRatioType.values.length,
- itemBuilder: (context, index) {
- final aspectRatio = CropAspectRatioType.values[index];
- final isSelected = selectedAspectRatio == aspectRatio;
- return Padding(
- padding: const EdgeInsets.only(left: 6.0, right: 6.0),
- child: CropAspectChip(
- label: aspectRatio.label,
- svg: aspectRatio.svg,
- isSelected: isSelected,
- onTap: () {
- setState(() {
- selectedAspectRatio = aspectRatio;
- });
- widget.editor.updateAspectRatio(
- aspectRatio.ratio ?? -1,
- );
- },
- ),
- );
- },
+ if (selectedControl == _CropControl.straighten)
+ RepaintBoundary(
+ child: ImageEditorAdjustSlider(
+ min: tiltConfigs.tiltRotateMin,
+ max: tiltConfigs.tiltRotateMax,
+ value: straightenAngle.clamp(
+ tiltConfigs.tiltRotateMin,
+ tiltConfigs.tiltRotateMax,
+ ),
+ onChanged: (value) => widget.editor.tilt(
+ TiltMode.rotate,
+ value * pi / 180,
+ updateStateHistory: false,
+ ),
+ onChangeEnd: (value) =>
+ widget.editor.tilt(TiltMode.rotate, value * pi / 180),
+ ),
+ )
+ else if (selectedControl == _CropControl.crop)
+ SizedBox(
+ height: 40,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: CropAspectRatioType.values.length,
+ itemBuilder: (context, index) {
+ final aspectRatio = CropAspectRatioType.values[index];
+ final isSelected = selectedAspectRatio == aspectRatio;
+ return Padding(
+ padding: const EdgeInsets.only(left: 6.0, right: 6.0),
+ child: CropAspectChip(
+ label: aspectRatio.label,
+ svg: aspectRatio.svg,
+ isSelected: isSelected,
+ onTap: () {
+ setState(() {
+ selectedAspectRatio = aspectRatio;
+ });
+ widget.editor.updateAspectRatio(
+ aspectRatio.ratio ?? -1,
+ );
+ },
+ ),
+ );
+ },
+ ),
),
- ),
+ if (selectedControl == _CropControl.none)
+ const SizedBox(height: 40),
],
),
),
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
index a825f17572..b979c1efc1 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
@@ -38,6 +38,7 @@ import "package:photos/ui/viewer/file/detail_page.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/image_util.dart";
import "package:photos/utils/lossless_edits.dart";
+import 'package:pro_image_editor/core/models/styles/sub_editor_page_style.dart';
import 'package:pro_image_editor/pro_image_editor.dart';
class ImageEditorPage extends StatefulWidget {
@@ -297,6 +298,12 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
SubEditorMode.emoji,
],
style: MainEditorStyle(
+ subEditorPage: const SubEditorPageStyle(
+ positionTop: 0,
+ positionBottom: 0,
+ positionLeft: 0,
+ positionRight: 0,
+ ),
uiOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarContrastEnforced: true,
systemNavigationBarColor: Colors.transparent,
@@ -490,6 +497,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
),
),
cropRotateEditor: CropRotateEditorConfigs(
+ rotateDirection: RotateDirection.right,
style: CropRotateEditorStyle(
background: colors.backgroundBase,
cropCornerColor: colors.primary,
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart
index 0500e4d2ca..97b38ab343 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import "package:flutter/services.dart";
import "package:flutter_svg/svg.dart";
import "package:hugeicons/hugeicons.dart";
+import "package:photos/ui/tools/editor/image_editor/image_editor_adjust_slider.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_configs_mixin.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
import 'package:pro_image_editor/core/mixins/converted_configs.dart';
@@ -109,7 +110,7 @@ class _ImageEditorTuneBarState extends State<ImageEditorTuneBar>
final activeMatrix =
tuneEditor.tuneAdjustmentMatrix[tuneEditor.selectedIndex];
- return _TuneAdjustWidget(
+ return ImageEditorAdjustSlider(
min: activeOption.min,
max: activeOption.max,
value: activeMatrix.value,
@@ -213,6 +214,8 @@ class CircularProgressWithValue extends StatefulWidget {
final double size;
final Color progressColor;
final String? svgPath;
+ final int Function(double)? displayValueBuilder;
+ final String valueSuffix;
const CircularProgressWithValue({
super.key,
@@ -222,6 +225,8 @@ class CircularProgressWithValue extends StatefulWidget {
required this.icon,
this.hugeIcon,
this.svgPath,
+ this.displayValueBuilder,
+ this.valueSuffix = "",
required this.progressColor,
this.isSelected = false,
this.size = 60,
@@ -300,7 +305,7 @@ class _CircularProgressWithValueState extends State<CircularProgressWithValue>
} else if (min == -0.25 && max == 0.25) {
return (value.abs() / 0.25).clamp(0.0, 1.0);
} else {
- return (value.abs() / 1.0).clamp(0.0, 1.0);
+ return (value.abs() / max.abs()).clamp(0.0, 1.0);
}
}
@@ -315,11 +320,9 @@ class _CircularProgressWithValueState extends State<CircularProgressWithValue>
@override
Widget build(BuildContext context) {
final colors = context.componentColors;
- final displayValue = _normalizeValueForDisplay(
- widget.value,
- widget.min,
- widget.max,
- );
+ final displayValue =
+ widget.displayValueBuilder?.call(widget.value) ??
+ _normalizeValueForDisplay(widget.value, widget.min, widget.max);
final displayText = displayValue.toString();
final prefix = displayValue > 0 ? "+" : "";
final progressColor = widget.progressColor;
@@ -383,7 +386,7 @@ class _CircularProgressWithValueState extends State<CircularProgressWithValue>
alignment: Alignment.center,
child: showValue
? Text(
- "$prefix$displayText",
+ "$prefix$displayText${widget.valueSuffix}",
style: TextStyles.bodyBold.copyWith(color: colors.textBase),
)
: widget.svgPath != null
@@ -411,246 +414,6 @@ class _CircularProgressWithValueState extends State<CircularProgressWithValue>
}
}
-class _TuneAdjustWidget extends StatelessWidget {
- final double min;
- final double max;
- final double value;
- final ValueChanged<double> onChanged;
-
- const _TuneAdjustWidget({
- required this.min,
- required this.max,
- required this.value,
- required this.onChanged,
- });
-
- @override
- Widget build(BuildContext context) {
- final colors = context.componentColors;
- return SizedBox(
- height: 40,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Positioned.fill(
- child: Container(
- margin: const EdgeInsets.symmetric(horizontal: 20),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(25),
- color: colors.fillLight,
- ),
- ),
- ),
- Container(
- margin: const EdgeInsets.symmetric(horizontal: 20),
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(25)),
- child: SliderTheme(
- data: SliderTheme.of(context).copyWith(
- thumbShape: const _ColorPickerThumbShape(),
- overlayShape: const RoundSliderOverlayShape(overlayRadius: 0),
- activeTrackColor: colors.primary,
- inactiveTrackColor: colors.fillLight,
- trackShape: _CenterBasedTrackShape(isBipolar: min < 0),
- trackHeight: 24,
- ),
- child: Slider(
- value: value,
- onChanged: onChanged,
- min: min,
- max: max,
- ),
- ),
- ),
- Container(
- margin: const EdgeInsets.symmetric(horizontal: 38),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- width: 6,
- height: 6,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colors.fillBase.withAlpha(30),
- ),
- ),
- Container(
- width: 6,
- height: 6,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colors.fillBase.withAlpha(30),
- ),
- ),
- Container(
- width: 6,
- height: 6,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colors.fillBase.withAlpha(30),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
-}
-
-class _ColorPickerThumbShape extends SliderComponentShape {
- const _ColorPickerThumbShape();
-
- static const double thumbRadius = 15.0;
-
- @override
- Size getPreferredSize(bool isEnabled, bool isDiscrete) {
- return const Size(thumbRadius * 2, thumbRadius * 2);
- }
-
- @override
- void paint(
- PaintingContext context,
- Offset center, {
- required Animation<double> activationAnimation,
- required Animation<double> enableAnimation,
- required bool isDiscrete,
- required TextPainter labelPainter,
- required RenderBox parentBox,
- required Size sizeWithOverflow,
- required SliderThemeData sliderTheme,
- required TextDirection textDirection,
- required double textScaleFactor,
- required double value,
- }) {
- final canvas = context.canvas;
-
- final trackRect = sliderTheme.trackShape!.getPreferredRect(
- parentBox: parentBox,
- offset: Offset.zero,
- sliderTheme: sliderTheme,
- isEnabled: true,
- isDiscrete: isDiscrete,
- );
-
- final constrainedCenter = Offset(
- center.dx.clamp(
- trackRect.left + thumbRadius,
- trackRect.right - thumbRadius,
- ),
- center.dy,
- );
-
- final paint = Paint()
- ..color = Colors.white
- ..style = PaintingStyle.fill;
-
- canvas.drawCircle(constrainedCenter, thumbRadius, paint);
-
- final innerPaint = Paint()
- ..color = const Color.fromRGBO(8, 194, 37, 1)
- ..style = PaintingStyle.fill;
- canvas.drawCircle(constrainedCenter, 12.5, innerPaint);
- }
-}
-
-class _CenterBasedTrackShape extends SliderTrackShape {
- const _CenterBasedTrackShape({this.isBipolar = true});
-
- static const double horizontalPadding = 6.0;
-
- final bool isBipolar;
-
- @override
- Rect getPreferredRect({
- required RenderBox parentBox,
- Offset offset = Offset.zero,
- required SliderThemeData sliderTheme,
- bool isEnabled = false,
- bool isDiscrete = false,
- }) {
- final double trackHeight = sliderTheme.trackHeight ?? 8;
- final double trackLeft = offset.dx + horizontalPadding;
- final double trackTop =
- offset.dy + (parentBox.size.height - trackHeight) / 2;
- final double trackWidth = parentBox.size.width - (horizontalPadding * 2);
- return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
- }
-
- @override
- void paint(
- PaintingContext context,
- Offset offset, {
- required RenderBox parentBox,
- required SliderThemeData sliderTheme,
- required Animation<double> enableAnimation,
- required TextDirection textDirection,
- required Offset thumbCenter,
- Offset? secondaryOffset,
- bool isEnabled = false,
- bool isDiscrete = false,
- double? additionalActiveTrackHeight,
- }) {
- final Canvas canvas = context.canvas;
- final Rect trackRect = getPreferredRect(
- parentBox: parentBox,
- offset: offset,
- sliderTheme: sliderTheme,
- isEnabled: isEnabled,
- isDiscrete: isDiscrete,
- );
-
- final double centerX = trackRect.left + trackRect.width / 2;
-
- final double clampedThumbDx = thumbCenter.dx.clamp(
- trackRect.left + _ColorPickerThumbShape.thumbRadius,
- trackRect.right - _ColorPickerThumbShape.thumbRadius,
- );
-
- final double activeStartDx = isBipolar ? centerX : trackRect.left;
-
- final Paint inactivePaint = Paint()
- ..color = sliderTheme.inactiveTrackColor!
- ..style = PaintingStyle.fill;
-
- final RRect inactiveRRect = RRect.fromRectAndRadius(
- trackRect,
- Radius.circular(trackRect.height / 2),
- );
-
- canvas.drawRRect(inactiveRRect, inactivePaint);
-
- if ((clampedThumbDx - activeStartDx).abs() >
- _ColorPickerThumbShape.thumbRadius) {
- final Paint activePaint = Paint()
- ..color = sliderTheme.activeTrackColor!
- ..style = PaintingStyle.fill;
-
- final Rect activeRect = clampedThumbDx >= activeStartDx
- ? Rect.fromLTWH(
- activeStartDx,
- trackRect.top,
- clampedThumbDx - activeStartDx,
- trackRect.height,
- )
- : Rect.fromLTWH(
- clampedThumbDx,
- trackRect.top,
- activeStartDx - clampedThumbDx,
- trackRect.height,
- );
-
- final RRect activeRRect = RRect.fromRectAndRadius(
- activeRect,
- Radius.circular(trackRect.height / 2),
- );
-
- canvas.drawRRect(activeRRect, activePaint);
- }
- }
-}
-
class CircularProgressPainter extends CustomPainter {
final double progress;
final bool isClockwise;
diff --git a/mobile/apps/photos/lib/utils/lossless_edits.dart b/mobile/apps/photos/lib/utils/lossless_edits.dart
index 150ba01873..d32aaa7326 100644
--- a/mobile/apps/photos/lib/utils/lossless_edits.dart
+++ b/mobile/apps/photos/lib/utils/lossless_edits.dart
@@ -96,6 +96,7 @@ bool isTransformOnlyLossless(TransformConfigs t) {
t.cropRect.right.isFinite &&
t.cropRect.bottom.isFinite &&
(t.angle != 0 || t.flipX || t.flipY) &&
+ !t.isTilted &&
t.isRectangularCropper &&
_isSameRect(t.cropRect, fullImageRect) &&
_isSameDouble(t.scaleUser, 1) &&
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 88bfd52157..9459cc9a4b 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -4277,6 +4277,7 @@
}
}
},
+ "straighten": "Straighten",
"streamDetails": "Stream details",
"streetArt": "Street art stories",
"streetFood": "Street food bites",