Skip to content

Commit

Permalink
fix: ios dialog action buttons, local tracks crashing app, shimmer co…
Browse files Browse the repository at this point in the history
…lor and android wrong status bar color
  • Loading branch information
KRTirtho committed Dec 9, 2022
1 parent 359fcee commit 90c1200
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 135 deletions.
3 changes: 2 additions & 1 deletion lib/components/library/user_local_tracks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class UserLocalTracks extends HookConsumerWidget {
),
);
},
loading: () => const ShimmerTrackTile(noSliver: true),
loading: () =>
const Expanded(child: ShimmerTrackTile(noSliver: true)),
error: (error, stackTrace) =>
Text(error.toString() + stackTrace.toString()),
)
Expand Down
59 changes: 46 additions & 13 deletions lib/components/lyrics/lyric_delay_adjust_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -21,25 +22,57 @@ class LyricDelayAdjustDialog extends HookConsumerWidget {
macosAppIcon: Sidebar.brandLogo(),
title: const Center(child: Text("Adjust Lyrics Delay")),
secondaryActions: [
PlatformFilledButton(
isSecondary: true,
onPressed: () {
Navigator.of(context).pop();
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
isSecondary: true,
child: const Text("Cancel"),
onPressed: () {
Navigator.pop(context);
},
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () {
Navigator.pop(context);
},
isDestructiveAction: true,
child: const Text("Cancel"),
);
},
child: const Text("Cancel"),
),
],
primaryActions: [
PlatformFilledButton(
child: const Text("Done"),
onPressed: () {
Navigator.of(context).pop(
Duration(
milliseconds: getValue().toInt(),
),
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
child: const Text("Done"),
onPressed: () {
Navigator.of(context).pop(
Duration(
milliseconds: getValue().toInt(),
),
);
},
);
},
)
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () {
Navigator.of(context).pop(
Duration(
milliseconds: getValue().toInt(),
),
);
},
isDefaultAction: true,
child: const Text("Done"),
);
},
),
],
content: SizedBox(
height: 100,
Expand Down
75 changes: 53 additions & 22 deletions lib/components/playlist/playlist_create_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fl_query/fl_query.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -25,36 +26,66 @@ class PlaylistCreateDialog extends HookConsumerWidget {
final public = useState(false);
final collaborative = useState(false);

onCreate() async {
if (playlistName.text.isEmpty) return;
final me = await spotify.me.get();
await spotify.playlists.createPlaylist(
me.id!,
playlistName.text,
collaborative: collaborative.value,
public: public.value,
description: description.text,
);
await QueryBowl.of(context)
.getQuery(
Queries.playlist.ofMine.queryKey,
)
?.refetch();
Navigator.pop(context);
}

return PlatformAlertDialog(
macosAppIcon: Sidebar.brandLogo(),
title: const Text("Create a Playlist"),
primaryActions: [
PlatformFilledButton(
child: const Text("Create"),
onPressed: () async {
if (playlistName.text.isEmpty) return;
final me = await spotify.me.get();
await spotify.playlists.createPlaylist(
me.id!,
playlistName.text,
collaborative: collaborative.value,
public: public.value,
description: description.text,
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
onPressed: onCreate,
child: const Text("Create"),
);
},
ios: (context, data) {
return CupertinoDialogAction(
isDefaultAction: true,
onPressed: onCreate,
child: const Text("Create"),
);
await QueryBowl.of(context)
.getQuery(
Queries.playlist.ofMine.queryKey,
)
?.refetch();
Navigator.pop(context);
},
)
),
],
secondaryActions: [
PlatformFilledButton(
isSecondary: true,
onPressed: () => Navigator.of(context).pop(),
child: const Text("Cancel"),
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
isSecondary: true,
child: const Text("Cancel"),
onPressed: () {
Navigator.pop(context);
},
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () {
Navigator.pop(context);
},
isDestructiveAction: true,
child: const Text("Cancel"),
);
},
),
],
content: Container(
Expand Down
67 changes: 48 additions & 19 deletions lib/components/settings/color_scheme_picker_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -67,32 +68,60 @@ class ColorSchemePickerDialog extends HookConsumerWidget {
},
).key);

onOk() {
switch (schemeType) {
case ColorSchemeType.accent:
preferences.setAccentColorScheme(colorsMap[active.value]!);
break;
default:
preferences.setBackgroundColorScheme(
colorsMap[active.value]!,
);
}
Navigator.pop(context);
}

return PlatformAlertDialog(
macosAppIcon: Sidebar.brandLogo(),
title: Text("Pick ${schemeType.name} color scheme"),
primaryActions: [
PlatformFilledButton(
child: const Text("Save"),
onPressed: () {
switch (schemeType) {
case ColorSchemeType.accent:
preferences.setAccentColorScheme(colorsMap[active.value]!);
break;
default:
preferences.setBackgroundColorScheme(
colorsMap[active.value]!,
);
}
Navigator.pop(context);
PlatformBuilder(
android: (context, data) {
return PlatformFilledButton(
onPressed: onOk,
child: const Text("Save"),
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: onOk,
isDefaultAction: true,
child: const Text("Save"),
);
},
)
fallback: PlatformBuilderFallback.android,
),
],
secondaryActions: [
PlatformFilledButton(
isSecondary: true,
child: const Text("Cancel"),
onPressed: () {
Navigator.pop(context);
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
isSecondary: true,
child: const Text("Cancel"),
onPressed: () {
Navigator.pop(context);
},
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () {
Navigator.pop(context);
},
isDestructiveAction: true,
child: const Text("Cancel"),
);
},
),
],
Expand Down
49 changes: 38 additions & 11 deletions lib/components/shared/dialogs/confirm_download_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
Expand Down Expand Up @@ -62,20 +63,46 @@ class ConfirmDownloadDialog extends StatelessWidget {
),
),
primaryActions: [
PlatformFilledButton(
style: const ButtonStyle(
foregroundColor: MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(Colors.red),
),
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Accept"),
PlatformBuilder(
android: (context, _) {
return PlatformFilledButton(
style: const ButtonStyle(
foregroundColor: MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(Colors.red),
),
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Accept"),
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () => Navigator.of(context).pop(true),
isDestructiveAction: true,
child: const Text("Accept"),
);
},
)
],
secondaryActions: [
PlatformFilledButton(
isSecondary: true,
child: const Text("Decline"),
onPressed: () => Navigator.of(context).pop(false),
PlatformBuilder(
fallback: PlatformBuilderFallback.android,
android: (context, _) {
return PlatformFilledButton(
child: const Text("Decline"),
onPressed: () {
Navigator.pop(context, false);
},
);
},
ios: (context, data) {
return CupertinoDialogAction(
onPressed: () {
Navigator.pop(context, false);
},
isDefaultAction: true,
child: const Text("Decline"),
);
},
),
],
);
Expand Down
Loading

0 comments on commit 90c1200

Please sign in to comment.