Skip to content

Commit

Permalink
refactor(blacklist): blacklist page instead of dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jan 6, 2023
1 parent 947c143 commit d495709
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
7 changes: 7 additions & 0 deletions lib/collections/routes.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:spotify/spotify.dart' hide Search;
import 'package:spotube/pages/settings/blacklist.dart';
import 'package:spotube/pages/settings/about.dart';
import 'package:spotube/utils/platform.dart';
import 'package:spotube/components/shared/spotube_page_route.dart';
Expand Down Expand Up @@ -56,6 +57,12 @@ final router = GoRouter(
child: const SettingsPage(),
),
routes: [
GoRoute(
path: "blacklist",
pageBuilder: (context, state) => SpotubePage(
child: const BlackListPage(),
),
),
GoRoute(
path: "about",
pageBuilder: (context, state) => SpotubePage(
Expand Down
2 changes: 0 additions & 2 deletions lib/components/shared/page_window_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:spotube/utils/platform.dart';
class PageWindowTitleBar extends StatefulHookWidget with PreferredSizeWidget {
final Widget? leading;
final bool automaticallyImplyLeading;
final Widget? title;
final List<Widget>? actions;
final Color? backgroundColor;
final Color? foregroundColor;
Expand All @@ -24,7 +23,6 @@ class PageWindowTitleBar extends StatefulHookWidget with PreferredSizeWidget {

PageWindowTitleBar({
Key? key,
this.title,
this.actions,
this.center,
this.toolbarOpacity = 1,
Expand Down
4 changes: 2 additions & 2 deletions lib/components/shared/shimmers/shimmer_track_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class ShimmerTrackTile extends StatelessWidget {
child: CustomPaint(
size: const Size(double.infinity, 50),
painter: ShimmerTrackTilePainter(
background: shimmerTheme?.shimmerBackgroundColor ??
background: shimmerTheme.shimmerBackgroundColor ??
Theme.of(context).scaffoldBackgroundColor,
foreground:
shimmerTheme?.shimmerColor ?? Theme.of(context).cardColor,
shimmerTheme.shimmerColor ?? Theme.of(context).cardColor,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AboutSpotube extends HookConsumerWidget {
return PlatformScaffold(
appBar: PageWindowTitleBar(
leading: const PlatformBackButton(),
title: const PlatformText("About Wives"),
center: const PlatformText("About Spotube"),
),
body: SingleChildScrollView(
child: Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import 'package:collection/collection.dart';
import 'package:fuzzywuzzy/fuzzywuzzy.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/provider/blacklist_provider.dart';
import 'package:tuple/tuple.dart';

class BlackListDialog extends HookConsumerWidget {
const BlackListDialog({Key? key}) : super(key: key);
class BlackListPage extends HookConsumerWidget {
const BlackListPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context, ref) {
Expand All @@ -33,13 +34,19 @@ class BlackListDialog extends HookConsumerWidget {
[blacklist, searchText.value],
);

return PlatformAlertDialog(
title: const PlatformText("Blacklist"),
content: Column(
return PlatformScaffold(
appBar: PageWindowTitleBar(
center: const PlatformText("Blacklist"),
centerTitle: true,
leading: const PlatformBackButton(),
),
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
padding: platform == TargetPlatform.windows
? const EdgeInsets.all(8.0).copyWith(left: 45)
: const EdgeInsets.all(8.0),
child: PlatformTextField(
onChanged: (value) => searchText.value = value,
placeholder: "Search",
Expand All @@ -51,12 +58,11 @@ class BlackListDialog extends HookConsumerWidget {
itemCount: filteredBlacklist.length,
itemBuilder: (context, index) {
final item = filteredBlacklist.elementAt(index);
return ListTile(
return PlatformListTile(
leading: PlatformText("${index + 1}."),
minLeadingWidth: 20,
title: PlatformText("${item.name} (${item.type.name})"),
subtitle: PlatformText.caption(item.id),
trailing: IconButton(
trailing: PlatformIconButton(
icon: Icon(Icons.delete_forever_rounded,
color: Colors.red[400]),
onPressed: () {
Expand Down
16 changes: 5 additions & 11 deletions lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:spotube/components/settings/blacklist_dialog.dart';
import 'package:spotube/components/settings/color_scheme_picker_dialog.dart';
import 'package:spotube/components/shared/adaptive/adaptive_list_tile.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
Expand Down Expand Up @@ -339,19 +338,14 @@ class SettingsPage extends HookConsumerWidget {
),
PlatformListTile(
leading: const Icon(Icons.playlist_remove_rounded),
title: const PlatformText(
"Track/Artist Blacklist",
title: const PlatformText("Blacklist"),
subtitle: const PlatformText(
"Blacklisted tracks and artists",
),
onTap: () {
showPlatformAlertDialog(
context,
barrierDismissible: true,
builder: (context) {
return const BlackListDialog();
},
);
GoRouter.of(context).push("/settings/blacklist");
},
trailing: const Icon(Icons.open_in_new_rounded),
trailing: const Icon(Icons.chevron_right_rounded),
),
PlatformText(
" Search",
Expand Down

0 comments on commit d495709

Please sign in to comment.