Skip to content

Commit

Permalink
feat: use settings as a dedicated page for mobile (#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Nov 26, 2024
1 parent b4adf00 commit a788794
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 174 deletions.
2 changes: 1 addition & 1 deletion lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class _MobileMusicPodAppState extends State<_MobileMusicPodApp> {
navigatorKey: libraryModel.masterNavigatorKey,
navigatorObservers: [libraryModel],
initialRoute:
isMobile ? (libraryModel.selectedPageId ?? kSearchPageId) : null,
isMobile ? (libraryModel.selectedPageId ?? kLocalAudioPageId) : null,
onGenerateRoute: (settings) {
final page = (masterItems.firstWhereOrNull(
(e) => e.pageId == settings.name,
Expand Down
10 changes: 10 additions & 0 deletions lib/app/view/master_items.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../common/data/audio_type.dart';
import '../../common/view/icons.dart';
Expand All @@ -20,6 +21,7 @@ import '../../radio/view/radio_page.dart';
import '../../radio/view/station_page.dart';
import '../../radio/view/station_page_icon.dart';
import '../../search/view/search_page.dart';
import '../../settings/view/settings_page.dart';
import 'main_page_icon.dart';

class MasterItem {
Expand Down Expand Up @@ -73,6 +75,14 @@ List<MasterItem> createMasterItems({required LibraryModel libraryModel}) {
),
pageId: kPodcastsPageId,
),
if (isMobile)
MasterItem(
titleBuilder: (context) => Text(context.l10n.settings),
iconBuilder: (selected) =>
Icon(selected ? Iconz.settingsFilled : Iconz.settings),
pageBuilder: (context) => const SettingsPage(),
pageId: kSettingsPageId,
),
MasterItem(
iconBuilder: (selected) => Icon(Iconz.plus),
titleBuilder: (context) => Text(context.l10n.add),
Expand Down
10 changes: 5 additions & 5 deletions lib/app/view/mobile_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ class MobileNavigationBar extends StatelessWidget with WatchItMixin {
watchPropertyValue((LibraryModel m) => m.selectedPageId);

final destinations = <String, NavigationDestination>{
kSearchPageId: NavigationDestination(
selectedIcon: Icon(Iconz.search),
icon: Icon(Iconz.search),
label: l10n.search,
),
kLocalAudioPageId: NavigationDestination(
selectedIcon:
const MainPageIcon(selected: true, audioType: AudioType.local),
Expand All @@ -73,6 +68,11 @@ class MobileNavigationBar extends StatelessWidget with WatchItMixin {
icon: const MainPageIcon(selected: false, audioType: AudioType.podcast),
label: l10n.podcasts,
),
kSettingsPageId: NavigationDestination(
selectedIcon: Icon(Iconz.settingsFilled),
icon: Icon(Iconz.settings),
label: l10n.settings,
),
};

return NavigationBar(
Expand Down
8 changes: 7 additions & 1 deletion lib/common/view/icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ class Iconz {
? YaruIcons.settings
: appleStyled
? CupertinoIcons.settings
: Icons.settings_rounded;
: Icons.settings_outlined;

static IconData get settingsFilled => yaruStyled
? YaruIcons.settings_filled
: appleStyled
? CupertinoIcons.settings
: Icons.settings;

static IconData get addToLibrary => yaruStyled
? YaruIcons.bell
Expand Down
1 change: 1 addition & 0 deletions lib/library/library_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -543,5 +543,6 @@ class LibraryService {
kLocalAudioPageId,
kPodcastsPageId,
kRadioPageId,
kSettingsPageId,
];
}
4 changes: 1 addition & 3 deletions lib/local_audio/view/local_audio_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:animated_emoji/animated_emoji.dart';
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../app/view/music_pod_scaffold.dart';
import '../../common/data/audio_type.dart';
Expand All @@ -18,10 +17,10 @@ import '../../search/search_model.dart';
import '../../search/search_type.dart';
import '../../settings/view/settings_action.dart';
import '../local_audio_model.dart';
import '../local_audio_view.dart';
import 'failed_imports_content.dart';
import 'local_audio_body.dart';
import 'local_audio_control_panel.dart';
import '../local_audio_view.dart';

class LocalAudioPage extends StatefulWidget with WatchItStatefulWidgetMixin {
const LocalAudioPage({super.key});
Expand Down Expand Up @@ -64,7 +63,6 @@ class _LocalAudioPageState extends State<LocalAudioPage> {
adaptive: true,
titleSpacing: 0,
actions: [
if (isMobile) const SettingsButton.icon(),
Padding(
padding: appBarSingleActionSpacing,
child: SearchButton(
Expand Down
3 changes: 0 additions & 3 deletions lib/podcasts/view/podcasts_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../app/view/music_pod_scaffold.dart';
import '../../common/data/audio_type.dart';
Expand All @@ -12,7 +11,6 @@ import '../../l10n/l10n.dart';
import '../../library/library_model.dart';
import '../../search/search_model.dart';
import '../../search/search_type.dart';
import '../../settings/view/settings_action.dart';
import '../podcast_model.dart';
import 'podcasts_collection_body.dart';

Expand Down Expand Up @@ -41,7 +39,6 @@ class _PodcastsPageState extends State<PodcastsPage> {
titleSpacing: 0,
adaptive: true,
actions: [
if (isMobile) const SettingsButton.icon(),
Padding(
padding: appBarSingleActionSpacing,
child: SearchButton(
Expand Down
3 changes: 0 additions & 3 deletions lib/radio/view/radio_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../app/connectivity_model.dart';
import '../../app/view/music_pod_scaffold.dart';
Expand All @@ -14,7 +13,6 @@ import '../../l10n/l10n.dart';
import '../../library/library_model.dart';
import '../../search/search_model.dart';
import '../../search/search_type.dart';
import '../../settings/view/settings_action.dart';
import 'radio_lib_page.dart';

class RadioPage extends StatelessWidget with WatchItMixin {
Expand All @@ -29,7 +27,6 @@ class RadioPage extends StatelessWidget with WatchItMixin {
appBar: HeaderBar(
adaptive: true,
actions: [
if (isMobile) const SettingsButton.icon(),
Flexible(
child: Padding(
padding: appBarSingleActionSpacing,
Expand Down
Loading

0 comments on commit a788794

Please sign in to comment.