Skip to content

Commit

Permalink
feat: make snackbar floating
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingkor Roy Tirtho committed Apr 28, 2023
1 parent 31b9249 commit 9dbb817
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/provider/playlist_queue_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,20 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
state = state!.copyWith(tracks: Set.from(tracks), active: active);
}

Future<void> updatePalette() async {
final palette = await PaletteGenerator.fromImageProvider(
UniversalImage.imageProvider(
TypeConversionUtils.image_X_UrlString(
state?.activeTrack.album?.images,
placeholder: ImagePlaceholder.albumArt,
Future<void> updatePalette() {
return Future.microtask(() async {
final palette = await PaletteGenerator.fromImageProvider(
UniversalImage.imageProvider(
TypeConversionUtils.image_X_UrlString(
state?.activeTrack.album?.images,
placeholder: ImagePlaceholder.albumArt,
),
height: 50,
width: 50,
),
height: 50,
width: 50,
),
);
ref.read(paletteProvider.notifier).state = palette;
);
ref.read(paletteProvider.notifier).state = palette;
});
}

@override
Expand All @@ -555,6 +557,8 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
state != null &&
state.active != this.state?.active) {
updatePalette();
} else if (state == null && ref.read(paletteProvider) != null) {
ref.read(paletteProvider.notifier).state = null;
}
super.state = state;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/themes/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ ThemeData theme(Color seed, Brightness brightness) {
color: scheme.surface,
elevation: 4,
),
snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
backgroundColor: scheme.onSurface,
contentTextStyle: TextStyle(color: scheme.surface),
),
);
}

0 comments on commit 9dbb817

Please sign in to comment.