mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-10 17:07:30 +00:00
refactor: place search in mobile navbar and settings in home appbar
This commit is contained in:
parent
dcb4c0a018
commit
4d5beb19fe
@ -5,7 +5,6 @@ import 'package:spotube/pages/home/home.dart';
|
|||||||
import 'package:spotube/pages/library/library.dart';
|
import 'package:spotube/pages/library/library.dart';
|
||||||
import 'package:spotube/pages/lyrics/lyrics.dart';
|
import 'package:spotube/pages/lyrics/lyrics.dart';
|
||||||
import 'package:spotube/pages/search/search.dart';
|
import 'package:spotube/pages/search/search.dart';
|
||||||
import 'package:spotube/pages/settings/settings.dart';
|
|
||||||
import 'package:spotube/pages/stats/stats.dart';
|
import 'package:spotube/pages/stats/stats.dart';
|
||||||
|
|
||||||
class SideBarTiles {
|
class SideBarTiles {
|
||||||
@ -62,6 +61,12 @@ List<SideBarTiles> getNavbarTileList(AppLocalizations l10n) => [
|
|||||||
icon: SpotubeIcons.home,
|
icon: SpotubeIcons.home,
|
||||||
title: l10n.browse,
|
title: l10n.browse,
|
||||||
),
|
),
|
||||||
|
SideBarTiles(
|
||||||
|
id: "search",
|
||||||
|
name: SearchPage.name,
|
||||||
|
icon: SpotubeIcons.search,
|
||||||
|
title: l10n.search,
|
||||||
|
),
|
||||||
SideBarTiles(
|
SideBarTiles(
|
||||||
id: "library",
|
id: "library",
|
||||||
name: LibraryPage.name,
|
name: LibraryPage.name,
|
||||||
@ -74,10 +79,4 @@ List<SideBarTiles> getNavbarTileList(AppLocalizations l10n) => [
|
|||||||
icon: SpotubeIcons.chart,
|
icon: SpotubeIcons.chart,
|
||||||
title: l10n.stats,
|
title: l10n.stats,
|
||||||
),
|
),
|
||||||
SideBarTiles(
|
|
||||||
id: "settings",
|
|
||||||
name: SettingsPage.name,
|
|
||||||
icon: SpotubeIcons.settings,
|
|
||||||
title: l10n.settings,
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -303,7 +303,7 @@ class SidebarFooter extends HookConsumerWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(SpotubeIcons.settings),
|
icon: const Icon(SpotubeIcons.settings),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ServiceUtils.navigateNamed(context, SettingsPage.name);
|
ServiceUtils.pushNamed(context, SettingsPage.name);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -37,15 +37,21 @@ class SpotubeNavigationBar extends HookConsumerWidget {
|
|||||||
theme.colorScheme.primary.withOpacity(0.2),
|
theme.colorScheme.primary.withOpacity(0.2),
|
||||||
);
|
);
|
||||||
|
|
||||||
final navbarTileList =
|
final navbarTileList = useMemoized(
|
||||||
useMemoized(() => getNavbarTileList(context.l10n), [context.l10n]);
|
() => getNavbarTileList(context.l10n),
|
||||||
|
[context.l10n],
|
||||||
|
);
|
||||||
|
|
||||||
final panelHeight = ref.watch(navigationPanelHeight);
|
final panelHeight = ref.watch(navigationPanelHeight);
|
||||||
|
|
||||||
final selectedIndex = navbarTileList.indexWhere(
|
final selectedIndex = useMemoized(() {
|
||||||
|
final index = navbarTileList.indexWhere(
|
||||||
(e) => routerState.namedLocation(e.name) == routerState.matchedLocation,
|
(e) => routerState.namedLocation(e.name) == routerState.matchedLocation,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return index == -1 ? 0 : index;
|
||||||
|
}, [navbarTileList, routerState.matchedLocation]);
|
||||||
|
|
||||||
if (layoutMode == LayoutMode.extended ||
|
if (layoutMode == LayoutMode.extended ||
|
||||||
(mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive) ||
|
(mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive) ||
|
||||||
panelHeight < 10) {
|
panelHeight < 10) {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class StatsPageSummarySection extends HookConsumerWidget {
|
|||||||
SummaryCard.unformatted(
|
SummaryCard.unformatted(
|
||||||
title: usdFormatter.format(summary.fees.toDouble()),
|
title: usdFormatter.format(summary.fees.toDouble()),
|
||||||
unit: "",
|
unit: "",
|
||||||
description: 'Worth of streams',
|
description: 'Owed to artists\nthis month',
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
),
|
),
|
||||||
SummaryCard(
|
SummaryCard(
|
||||||
|
|||||||
@ -30,6 +30,8 @@ class SummaryCard extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ThemeData(:textTheme, :brightness) = Theme.of(context);
|
final ThemeData(:textTheme, :brightness) = Theme.of(context);
|
||||||
|
|
||||||
|
final descriptionNewLines = description.split("").where((s) => s == "\n");
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
color: brightness == Brightness.dark ? color.shade100 : color.shade50,
|
color: brightness == Brightness.dark ? color.shade100 : color.shade50,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -61,7 +63,9 @@ class SummaryCard extends StatelessWidget {
|
|||||||
const Gap(5),
|
const Gap(5),
|
||||||
AutoSizeText(
|
AutoSizeText(
|
||||||
description,
|
description,
|
||||||
maxLines: 1,
|
maxLines: description.contains("\n")
|
||||||
|
? descriptionNewLines.length + 1
|
||||||
|
: 1,
|
||||||
minFontSize: 9,
|
minFontSize: 9,
|
||||||
style: textTheme.labelMedium!.copyWith(
|
style: textTheme.labelMedium!.copyWith(
|
||||||
color: color.shade900,
|
color: color.shade900,
|
||||||
|
|||||||
@ -12,14 +12,9 @@ import 'package:spotube/components/home/sections/genres.dart';
|
|||||||
import 'package:spotube/components/home/sections/made_for_user.dart';
|
import 'package:spotube/components/home/sections/made_for_user.dart';
|
||||||
import 'package:spotube/components/home/sections/new_releases.dart';
|
import 'package:spotube/components/home/sections/new_releases.dart';
|
||||||
import 'package:spotube/components/home/sections/recent.dart';
|
import 'package:spotube/components/home/sections/recent.dart';
|
||||||
import 'package:spotube/components/shared/image/universal_image.dart';
|
|
||||||
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
import 'package:spotube/extensions/image.dart';
|
import 'package:spotube/pages/settings/settings.dart';
|
||||||
import 'package:spotube/pages/profile/profile.dart';
|
|
||||||
import 'package:spotube/pages/search/search.dart';
|
|
||||||
import 'package:spotube/provider/authentication_provider.dart';
|
|
||||||
import 'package:spotube/provider/spotify/spotify.dart';
|
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:spotube/utils/service_utils.dart';
|
import 'package:spotube/utils/service_utils.dart';
|
||||||
|
|
||||||
@ -39,43 +34,17 @@ class HomePage extends HookConsumerWidget {
|
|||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
slivers: [
|
slivers: [
|
||||||
if (mediaQuery.mdAndDown)
|
if (mediaQuery.smAndDown)
|
||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
floating: true,
|
floating: true,
|
||||||
title: Assets.spotubeLogoPng.image(height: 45),
|
title: Assets.spotubeLogoPng.image(height: 45),
|
||||||
actions: [
|
actions: [
|
||||||
const ConnectDeviceButton(),
|
const ConnectDeviceButton(),
|
||||||
const Gap(10),
|
const Gap(10),
|
||||||
Consumer(builder: (context, ref, _) {
|
|
||||||
final auth = ref.watch(authenticationProvider);
|
|
||||||
final me = ref.watch(meProvider);
|
|
||||||
final meData = me.asData?.value;
|
|
||||||
|
|
||||||
if (auth == null) {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
return IconButton(
|
|
||||||
icon: CircleAvatar(
|
|
||||||
backgroundImage: UniversalImage.imageProvider(
|
|
||||||
(meData?.images).asUrlString(
|
|
||||||
placeholder: ImagePlaceholder.artist,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
ServiceUtils.pushNamed(context, ProfilePage.name);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
const Gap(10),
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(SpotubeIcons.search),
|
icon: const Icon(SpotubeIcons.settings, size: 20),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ServiceUtils.pushNamed(context, SearchPage.name);
|
ServiceUtils.pushNamed(context, SettingsPage.name);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Gap(10),
|
const Gap(10),
|
||||||
|
|||||||
@ -4,10 +4,15 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:spotube/collections/spotube_icons.dart';
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
import 'package:spotube/components/settings/section_card_with_heading.dart';
|
import 'package:spotube/components/settings/section_card_with_heading.dart';
|
||||||
|
import 'package:spotube/components/shared/image/universal_image.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
import 'package:spotube/extensions/context.dart';
|
import 'package:spotube/extensions/context.dart';
|
||||||
|
import 'package:spotube/extensions/image.dart';
|
||||||
|
import 'package:spotube/pages/profile/profile.dart';
|
||||||
import 'package:spotube/provider/authentication_provider.dart';
|
import 'package:spotube/provider/authentication_provider.dart';
|
||||||
import 'package:spotube/provider/scrobbler_provider.dart';
|
import 'package:spotube/provider/scrobbler_provider.dart';
|
||||||
|
import 'package:spotube/provider/spotify/spotify.dart';
|
||||||
|
import 'package:spotube/utils/service_utils.dart';
|
||||||
|
|
||||||
class SettingsAccountSection extends HookConsumerWidget {
|
class SettingsAccountSection extends HookConsumerWidget {
|
||||||
const SettingsAccountSection({super.key});
|
const SettingsAccountSection({super.key});
|
||||||
@ -15,9 +20,12 @@ class SettingsAccountSection extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(context, ref) {
|
Widget build(context, ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
final router = GoRouter.of(context);
|
||||||
|
|
||||||
final auth = ref.watch(authenticationProvider);
|
final auth = ref.watch(authenticationProvider);
|
||||||
final scrobbler = ref.watch(scrobblerProvider);
|
final scrobbler = ref.watch(scrobblerProvider);
|
||||||
final router = GoRouter.of(context);
|
final me = ref.watch(meProvider);
|
||||||
|
final meData = me.asData?.value;
|
||||||
|
|
||||||
final logoutBtnStyle = FilledButton.styleFrom(
|
final logoutBtnStyle = FilledButton.styleFrom(
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
@ -27,6 +35,24 @@ class SettingsAccountSection extends HookConsumerWidget {
|
|||||||
return SectionCardWithHeading(
|
return SectionCardWithHeading(
|
||||||
heading: context.l10n.account,
|
heading: context.l10n.account,
|
||||||
children: [
|
children: [
|
||||||
|
if (auth != null)
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(SpotubeIcons.user),
|
||||||
|
title: const Text("User Profile"),
|
||||||
|
trailing: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: CircleAvatar(
|
||||||
|
backgroundImage: UniversalImage.imageProvider(
|
||||||
|
(meData?.images).asUrlString(
|
||||||
|
placeholder: ImagePlaceholder.artist,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
ServiceUtils.pushNamed(context, ProfilePage.name);
|
||||||
|
},
|
||||||
|
),
|
||||||
if (auth == null)
|
if (auth == null)
|
||||||
LayoutBuilder(builder: (context, constrains) {
|
LayoutBuilder(builder: (context, constrains) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
appBar: PageWindowTitleBar(
|
appBar: PageWindowTitleBar(
|
||||||
title: Text(context.l10n.settings),
|
title: Text(context.l10n.settings),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
|
automaticallyImplyLeading: true,
|
||||||
),
|
),
|
||||||
body: Scrollbar(
|
body: Scrollbar(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
|||||||
0
lib/pages/stats/albums/albums.dart
Normal file
0
lib/pages/stats/albums/albums.dart
Normal file
0
lib/pages/stats/artists/artists.dart
Normal file
0
lib/pages/stats/artists/artists.dart
Normal file
0
lib/pages/stats/fees/fees.dart
Normal file
0
lib/pages/stats/fees/fees.dart
Normal file
0
lib/pages/stats/minutes/minutes.dart
Normal file
0
lib/pages/stats/minutes/minutes.dart
Normal file
0
lib/pages/stats/playlists/playlists.dart
Normal file
0
lib/pages/stats/playlists/playlists.dart
Normal file
0
lib/pages/stats/streams/streams.dart
Normal file
0
lib/pages/stats/streams/streams.dart
Normal file
Loading…
Reference in New Issue
Block a user