Skip to content

Commit

Permalink
[timetable] push "/timetable/palettes/custom" after adding generated …
Browse files Browse the repository at this point in the history
…palette
  • Loading branch information
liplum committed Sep 24, 2024
1 parent 84c2605 commit 5050020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/timetable/p13n/page/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ class _TimetableBackgroundEditorState extends ConsumerState<TimetableBackgroundE
icon: const Icon(Icons.generating_tokens_outlined),
label: i18n.p13n.background.generatePalette.text(),
onPressed: () async {
await addPaletteFromImageByGenerator(
final added = await addPaletteFromImageByGenerator(
context,
FileImage(renderImageFile),
);
if (added) {
if (!context.mounted) return;
context.push("/timetable/palettes/custom");
context.push("/timetable/palettes/custom");
}
},
),
],
Expand Down
8 changes: 4 additions & 4 deletions lib/timetable/p13n/utils/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Future<TimetablePalette> generatePaletteFromImage(
return palette;
}

Future<void> addPaletteFromImageByGenerator(
Future<bool> addPaletteFromImageByGenerator(
BuildContext context,
ImageProvider img, {
int maxColorCount = 12,
Expand All @@ -47,13 +47,13 @@ Future<void> addPaletteFromImageByGenerator(
img,
maxColorCount: maxColorCount,
);
if (!context.mounted) return;
if (!context.mounted) return false;
final newPalette = await context.showSheet<TimetablePalette>(
(ctx) => TimetablePaletteEditorPage(palette: palette),
dismissible: false,
);
if (newPalette == null) return;
if (newPalette == null) return false;
TimetableInit.storage.palette.add(newPalette);
await HapticFeedback.mediumImpact();
if (!context.mounted) return;
return true;
}

0 comments on commit 5050020

Please sign in to comment.