refactor: blacklist and about page

This commit is contained in:
Kingkor Roy Tirtho 2025-01-11 20:08:04 +06:00
parent b25ae332b8
commit a8694a7a8b
5 changed files with 79 additions and 63 deletions

View File

@ -55,6 +55,7 @@ class HomeGenresSection extends HookConsumerWidget {
return () { return () {
timer.cancel(); timer.cancel();
controller.dispose();
}; };
}, []); }, []);

View File

@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/assets.gen.dart';
import 'package:spotube/collections/env.dart'; import 'package:spotube/collections/env.dart';
import 'package:spotube/components/button/back_button.dart';
import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/components/image/universal_image.dart';
import 'package:spotube/components/links/hyper_link.dart'; import 'package:spotube/components/links/hyper_link.dart';
import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/components/titlebar/titlebar.dart';
@ -26,14 +27,16 @@ class AboutSpotube extends HookConsumerWidget {
final license = ref.watch(_licenseProvider); final license = ref.watch(_licenseProvider);
final theme = Theme.of(context); final theme = Theme.of(context);
const colon = Text(":"); const colon = TableCell(child: Text(":"));
return Scaffold( return Scaffold(
appBar: TitleBar( headers: [
TitleBar(
leading: const [BackButton()], leading: const [BackButton()],
title: Text(context.l10n.about_spotube), title: Text(context.l10n.about_spotube),
), )
body: SingleChildScrollView( ],
child: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column( child: Column(
@ -45,77 +48,86 @@ class AboutSpotube extends HookConsumerWidget {
Center( Center(
child: Column( child: Column(
children: [ children: [
Text( Text(context.l10n.spotube_description).semiBold().large(),
context.l10n.spotube_description,
style: theme.textTheme.titleLarge,
),
const SizedBox(height: 20), const SizedBox(height: 20),
Table( Table(
columnWidths: const { columnWidths: const {
0: FixedColumnWidth(95), 0: FixedTableSize(95),
1: FixedColumnWidth(10), 1: FixedTableSize(10),
2: IntrinsicColumnWidth(), 2: IntrinsicTableSize(),
}, },
children: [ defaultRowHeight: const FixedTableSize(40),
rows: [
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.founder), TableCell(child: Text(context.l10n.founder)),
colon, colon,
Hyperlink( TableCell(
child: Hyperlink(
context.l10n.kingkor_roy_tirtho, context.l10n.kingkor_roy_tirtho,
"https://github.com/KRTirtho", "https://github.com/KRTirtho",
),
) )
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.version), TableCell(child: Text(context.l10n.version)),
colon, colon,
Text("v${packageInfo.version}") TableCell(child: Text("v${packageInfo.version}"))
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.channel), TableCell(child: Text(context.l10n.channel)),
colon, colon,
Text(Env.releaseChannel.name) TableCell(child: Text(Env.releaseChannel.name))
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.build_number), TableCell(child: Text(context.l10n.build_number)),
colon, colon,
Text(packageInfo.buildNumber.replaceAll(".", " ")) TableCell(
child: Text(
packageInfo.buildNumber.replaceAll(".", " ")),
)
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.repository), TableCell(child: Text(context.l10n.repository)),
colon, colon,
const Hyperlink( const TableCell(
child: Hyperlink(
"github.com/KRTirtho/spotube", "github.com/KRTirtho/spotube",
"https://github.com/KRTirtho/spotube", "https://github.com/KRTirtho/spotube",
), ),
),
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.license), TableCell(child: Text(context.l10n.license)),
colon, colon,
const Hyperlink( const TableCell(
child: Hyperlink(
"BSD-4-Clause", "BSD-4-Clause",
"https://raw.githubusercontent.com/KRTirtho/spotube/master/LICENSE", "https://raw.githubusercontent.com/KRTirtho/spotube/master/LICENSE",
), ),
),
], ],
), ),
TableRow( TableRow(
children: [ cells: [
Text(context.l10n.bug_issues), TableCell(child: Text(context.l10n.bug_issues)),
colon, colon,
const Hyperlink( const TableCell(
child: Hyperlink(
"github.com/KRTirtho/spotube/issues", "github.com/KRTirtho/spotube/issues",
"https://github.com/KRTirtho/spotube/issues", "https://github.com/KRTirtho/spotube/issues",
), ),
),
], ],
), ),
], ],
@ -141,12 +153,12 @@ class AboutSpotube extends HookConsumerWidget {
Text( Text(
context.l10n.made_with, context.l10n.made_with,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: theme.textTheme.bodySmall, style: theme.typography.small,
), ),
Text( Text(
context.l10n.copyright(DateTime.now().year), context.l10n.copyright(DateTime.now().year),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: theme.textTheme.bodySmall, style: theme.typography.small,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
ConstrainedBox( ConstrainedBox(
@ -156,7 +168,7 @@ class AboutSpotube extends HookConsumerWidget {
data: (data) { data: (data) {
return Text( return Text(
data, data,
style: theme.textTheme.bodySmall, style: theme.typography.small,
); );
}, },
loading: () { loading: () {
@ -167,7 +179,7 @@ class AboutSpotube extends HookConsumerWidget {
error: (e, s) { error: (e, s) {
return Text( return Text(
e.toString(), e.toString(),
style: theme.textTheme.bodySmall, style: theme.typography.small,
); );
}, },
), ),

View File

@ -1,12 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:fuzzywuzzy/fuzzywuzzy.dart'; import 'package:fuzzywuzzy/fuzzywuzzy.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/button/back_button.dart';
import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart';
import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/components/titlebar/titlebar.dart';
import 'package:spotube/components/ui/button_tile.dart';
import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/context.dart';
import 'package:spotube/provider/blacklist_provider.dart'; import 'package:spotube/provider/blacklist_provider.dart';
@ -44,21 +46,21 @@ class BlackListPage extends HookConsumerWidget {
); );
return Scaffold( return Scaffold(
appBar: TitleBar( headers: [
TitleBar(
title: Text(context.l10n.blacklist), title: Text(context.l10n.blacklist),
leading: const [BackButton()], leading: const [BackButton()],
), )
body: Column( ],
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: TextField( child: TextField(
onChanged: (value) => searchText.value = value, onChanged: (value) => searchText.value = value,
decoration: InputDecoration( placeholder: Text(context.l10n.search),
hintText: context.l10n.search, leading: const Icon(SpotubeIcons.search),
prefixIcon: const Icon(SpotubeIcons.search),
),
), ),
), ),
InterScrollbar( InterScrollbar(
@ -69,11 +71,12 @@ class BlackListPage extends HookConsumerWidget {
itemCount: filteredBlacklist.length, itemCount: filteredBlacklist.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = filteredBlacklist.elementAt(index); final item = filteredBlacklist.elementAt(index);
return ListTile( return ButtonTile(
style: ButtonVariance.ghost,
leading: Text("${index + 1}."), leading: Text("${index + 1}."),
title: Text("${item.name} (${item.elementType.name})"), title: Text("${item.name} (${item.elementType.name})"),
subtitle: Text(item.elementId), subtitle: Text(item.elementId),
trailing: IconButton( trailing: IconButton.ghost(
icon: Icon(SpotubeIcons.trash, color: Colors.red[400]), icon: Icon(SpotubeIcons.trash, color: Colors.red[400]),
onPressed: () { onPressed: () {
ref ref

View File

@ -1971,8 +1971,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: fix-scaffold-footer-safearea ref: d928e73cd734582046c63a3bed99cc42aeab6085
resolved-ref: "8ede34e1e3270ec3839192a7a6453e19cd00f9ab" resolved-ref: d928e73cd734582046c63a3bed99cc42aeab6085
url: "https://github.com/KRTirtho/shadcn_flutter.git" url: "https://github.com/KRTirtho/shadcn_flutter.git"
source: git source: git
version: "0.0.24" version: "0.0.24"

View File

@ -105,7 +105,7 @@ dependencies:
shadcn_flutter: shadcn_flutter:
git: git:
url: https://github.com/KRTirtho/shadcn_flutter.git url: https://github.com/KRTirtho/shadcn_flutter.git
ref: fix-scaffold-footer-safearea ref: d928e73cd734582046c63a3bed99cc42aeab6085
shared_preferences: ^2.2.3 shared_preferences: ^2.2.3
shelf: ^1.4.1 shelf: ^1.4.1
shelf_router: ^1.1.4 shelf_router: ^1.1.4