From b4cba1bb9b1ebd683dd7e0787d8d3a93caa45eeb Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Wed, 1 Apr 2026 22:57:41 -0400 Subject: [PATCH] enum --- mobile/lib/constants/aspect_ratios.dart | 34 ++++++------------- .../presentation/pages/drift_edit.page.dart | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/mobile/lib/constants/aspect_ratios.dart b/mobile/lib/constants/aspect_ratios.dart index 512348e6e4..9159db4ef1 100644 --- a/mobile/lib/constants/aspect_ratios.dart +++ b/mobile/lib/constants/aspect_ratios.dart @@ -1,33 +1,19 @@ import 'package:flutter/material.dart'; -class AspectRatioPreset { +enum AspectRatioPreset { + free(ratio: null, label: 'Free', icon: Icons.crop_free_rounded), + square(ratio: 1.0, label: '1:1', icon: Icons.crop_square_rounded), + ratio16x9(ratio: 16 / 9, label: '16:9', icon: Icons.crop_16_9_rounded), + ratio3x2(ratio: 3 / 2, label: '3:2', icon: Icons.crop_3_2_rounded), + ratio7x5(ratio: 7 / 5, label: '7:5', icon: Icons.crop_7_5_rounded), + ratio9x16(ratio: 9 / 16, label: '9:16', icon: Icons.crop_16_9_rounded, iconRotated: true), + ratio2x3(ratio: 2 / 3, label: '2:3', icon: Icons.crop_3_2_rounded, iconRotated: true), + ratio5x7(ratio: 5 / 7, label: '5:7', icon: Icons.crop_7_5_rounded, iconRotated: true); + final double? ratio; final String label; final IconData icon; final bool iconRotated; const AspectRatioPreset({required this.ratio, required this.label, required this.icon, this.iconRotated = false}); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - if (other is AspectRatioPreset) { - return ratio == other.ratio && label == other.label; - } - return false; - } - - @override - int get hashCode => ratio.hashCode ^ label.hashCode; } - -const aspectRatios = [ - AspectRatioPreset(ratio: null, label: 'Free', icon: Icons.crop_free_rounded), - AspectRatioPreset(ratio: 1.0, label: '1:1', icon: Icons.crop_square_rounded), - AspectRatioPreset(ratio: 16 / 9, label: '16:9', icon: Icons.crop_16_9_rounded), - AspectRatioPreset(ratio: 3 / 2, label: '3:2', icon: Icons.crop_3_2_rounded), - AspectRatioPreset(ratio: 7 / 5, label: '7:5', icon: Icons.crop_7_5_rounded), - AspectRatioPreset(ratio: 9 / 16, label: '9:16', icon: Icons.crop_16_9_rounded, iconRotated: true), - AspectRatioPreset(ratio: 2 / 3, label: '2:3', icon: Icons.crop_3_2_rounded, iconRotated: true), - AspectRatioPreset(ratio: 5 / 7, label: '5:7', icon: Icons.crop_7_5_rounded, iconRotated: true), -]; diff --git a/mobile/lib/presentation/pages/drift_edit.page.dart b/mobile/lib/presentation/pages/drift_edit.page.dart index a50db55f10..6e50b5b1af 100644 --- a/mobile/lib/presentation/pages/drift_edit.page.dart +++ b/mobile/lib/presentation/pages/drift_edit.page.dart @@ -382,7 +382,7 @@ class _AspectRatioSelector extends StatelessWidget { return SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( - children: aspectRatios.map((entry) { + children: AspectRatioPreset.values.map((entry) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: _AspectRatioButton(