Skip to content

Commit

Permalink
Use srgb in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 27, 2024
1 parent 3325a1a commit b005fe4
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 563 deletions.
8 changes: 4 additions & 4 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1026.0)
aws-partitions (1.1029.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand Down Expand Up @@ -155,7 +155,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.9.1)
jwt (2.9.3)
jwt (2.10.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand All @@ -167,7 +167,7 @@ GEM
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
plist (3.7.1)
plist (3.7.2)
public_suffix (6.0.1)
rake (13.2.1)
representable (3.2.0)
Expand Down Expand Up @@ -224,4 +224,4 @@ DEPENDENCIES
screengrab

BUNDLED WITH
2.6.1
2.6.2
15 changes: 9 additions & 6 deletions app/lib/cubits/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class ButterflySettings with _$ButterflySettings, LeapSettings {
@Default(0.5) double imageScale,
@Default(2) double pdfQuality,
@Default(PlatformTheme.system) PlatformTheme platformTheme,
@Default([]) List<int> recentColors,
@Default([]) List<SRGBColor> recentColors,
@Default([]) List<String> flags,
@Default(false) bool spreadPages,
@Default(false) bool highContrast,
Expand Down Expand Up @@ -311,8 +311,11 @@ class ButterflySettings with _$ButterflySettings, LeapSettings {
platformTheme: prefs.containsKey('platform_theme')
? PlatformTheme.values.byName(prefs.getString('platform_theme')!)
: PlatformTheme.system,
recentColors:
prefs.getStringList('recent_colors')?.map(int.parse).toList() ?? [],
recentColors: prefs
.getStringList('recent_colors')
?.map((e) => SRGBColor(int.parse(e)))
.toList() ??
[],
flags: prefs.getStringList('flags') ?? [],
spreadPages: prefs.getBool('spread_pages') ?? false,
highContrast: prefs.getBool('high_contrast') ?? false,
Expand Down Expand Up @@ -399,7 +402,7 @@ class ButterflySettings with _$ButterflySettings, LeapSettings {
await prefs.setDouble('pdf_quality', pdfQuality);
await prefs.setString('platform_theme', platformTheme.name);
await prefs.setStringList(
'recent_colors', recentColors.map((e) => e.toString()).toList());
'recent_colors', recentColors.map((e) => e.value.toString()).toList());
await prefs.setStringList('flags', flags);
await prefs.setBool('spread_pages', spreadPages);
await prefs.setBool('high_contrast', highContrast);
Expand Down Expand Up @@ -834,7 +837,7 @@ class SettingsCubit extends Cubit<ButterflySettings>
Future<void> resetPlatformTheme() =>
changePlatformTheme(PlatformTheme.system);

Future<void> addRecentColors(int color) async {
Future<void> addRecentColors(SRGBColor color) async {
final recentColors = state.recentColors.toList();
recentColors.remove(color);
recentColors.insert(0, color);
Expand All @@ -845,7 +848,7 @@ class SettingsCubit extends Cubit<ButterflySettings>
return save();
}

Future<void> removeRecentColors(int color) async {
Future<void> removeRecentColors(SRGBColor color) async {
final recentColors = state.recentColors.toList();
recentColors.remove(color);
emit(state.copyWith(recentColors: recentColors));
Expand Down
20 changes: 10 additions & 10 deletions app/lib/cubits/settings.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ mixin _$ButterflySettings {
double get imageScale => throw _privateConstructorUsedError;
double get pdfQuality => throw _privateConstructorUsedError;
PlatformTheme get platformTheme => throw _privateConstructorUsedError;
List<int> get recentColors => throw _privateConstructorUsedError;
List<SRGBColor> get recentColors => throw _privateConstructorUsedError;
List<String> get flags => throw _privateConstructorUsedError;
bool get spreadPages => throw _privateConstructorUsedError;
bool get highContrast => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -418,7 +418,7 @@ abstract class $ButterflySettingsCopyWith<$Res> {
double imageScale,
double pdfQuality,
PlatformTheme platformTheme,
List<int> recentColors,
List<SRGBColor> recentColors,
List<String> flags,
bool spreadPages,
bool highContrast,
Expand Down Expand Up @@ -646,7 +646,7 @@ class _$ButterflySettingsCopyWithImpl<$Res, $Val extends ButterflySettings>
recentColors: null == recentColors
? _value.recentColors
: recentColors // ignore: cast_nullable_to_non_nullable
as List<int>,
as List<SRGBColor>,
flags: null == flags
? _value.flags
: flags // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -768,7 +768,7 @@ abstract class _$$ButterflySettingsImplCopyWith<$Res>
double imageScale,
double pdfQuality,
PlatformTheme platformTheme,
List<int> recentColors,
List<SRGBColor> recentColors,
List<String> flags,
bool spreadPages,
bool highContrast,
Expand Down Expand Up @@ -996,7 +996,7 @@ class __$$ButterflySettingsImplCopyWithImpl<$Res>
recentColors: null == recentColors
? _value._recentColors
: recentColors // ignore: cast_nullable_to_non_nullable
as List<int>,
as List<SRGBColor>,
flags: null == flags
? _value._flags
: flags // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -1093,7 +1093,7 @@ class _$ButterflySettingsImpl extends _ButterflySettings
this.imageScale = 0.5,
this.pdfQuality = 2,
this.platformTheme = PlatformTheme.system,
final List<int> recentColors = const [],
final List<SRGBColor> recentColors = const [],
final List<String> flags = const [],
this.spreadPages = false,
this.highContrast = false,
Expand Down Expand Up @@ -1236,10 +1236,10 @@ class _$ButterflySettingsImpl extends _ButterflySettings
@override
@JsonKey()
final PlatformTheme platformTheme;
final List<int> _recentColors;
final List<SRGBColor> _recentColors;
@override
@JsonKey()
List<int> get recentColors {
List<SRGBColor> get recentColors {
if (_recentColors is EqualUnmodifiableListView) return _recentColors;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_recentColors);
Expand Down Expand Up @@ -1552,7 +1552,7 @@ abstract class _ButterflySettings extends ButterflySettings {
final double imageScale,
final double pdfQuality,
final PlatformTheme platformTheme,
final List<int> recentColors,
final List<SRGBColor> recentColors,
final List<String> flags,
final bool spreadPages,
final bool highContrast,
Expand Down Expand Up @@ -1639,7 +1639,7 @@ abstract class _ButterflySettings extends ButterflySettings {
@override
PlatformTheme get platformTheme;
@override
List<int> get recentColors;
List<SRGBColor> get recentColors;
@override
List<String> get flags;
@override
Expand Down
10 changes: 3 additions & 7 deletions app/lib/views/toolbar/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ class _ColorToolbarViewState extends State<ColorToolbarView> {
context: context,
builder: (context) => ColorPicker<ColorPickerToolbarAction>(
value: widget.color,
suggested: settingsCubit.state.recentColors
.map((e) => SRGBColor(e))
.toList(),
suggested: settingsCubit.state.recentColors,
secondaryActions: widget.onEyeDropper == null
? null
: (close) => [
Expand Down Expand Up @@ -108,7 +106,7 @@ class _ColorToolbarViewState extends State<ColorToolbarView> {
return;
}
if (response.action != ColorPickerToolbarAction.pin) {
settingsCubit.addRecentColors(srgb.value);
settingsCubit.addRecentColors(srgb);
return;
}
var currentPalette = pack?.getPalette(colorPalette!.name);
Expand Down Expand Up @@ -150,9 +148,7 @@ class _ColorToolbarViewState extends State<ColorToolbarView> {
context: context,
builder: (context) => ColorPicker<ColorPickerToolbarAction>(
value: value,
suggested: settingsCubit.state.recentColors
.map((e) => SRGBColor(e))
.toList(),
suggested: settingsCubit.state.recentColors,
secondaryActions: (close) => [
OutlinedButton(
onPressed: () =>
Expand Down
8 changes: 4 additions & 4 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ packages:
dependency: transitive
description:
name: camera_android_camerax
sha256: "2985b8e5fca62709ebb2150962b1dae0444ba0a112be888ccf21e8371a1406d9"
sha256: abcfa1ac32bd03116b4cfda7e8223ab391f01966e65823c064afe388550d1b3d
url: "https://pub.dev"
source: hosted
version: "0.6.10+1"
version: "0.6.10+3"
camera_avfoundation:
dependency: transitive
description:
Expand Down Expand Up @@ -841,8 +841,8 @@ packages:
dependency: "direct main"
description:
path: "packages/material_leap"
ref: "65d54d2431633488e0ff76c172fbaf2f705ef8fb"
resolved-ref: "65d54d2431633488e0ff76c172fbaf2f705ef8fb"
ref: "307657c0e0b93de9af1e1aa9bd96900e0bb7d27c"
resolved-ref: "307657c0e0b93de9af1e1aa9bd96900e0bb7d27c"
url: "https://github.com/LinwoodDev/dart_pkgs"
source: git
version: "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies:
material_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 65d54d2431633488e0ff76c172fbaf2f705ef8fb
ref: 307657c0e0b93de9af1e1aa9bd96900e0bb7d27c
path: packages/material_leap
lw_sysapi:
git:
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"sharp": "^0.33.5",
"typescript": "^5.7.2"
},
"packageManager": "[email protected].1",
"packageManager": "[email protected].2",
"devDependencies": {
"sass": "^1.83.0"
}
Expand Down
Loading

0 comments on commit b005fe4

Please sign in to comment.