proof of concept navigation
This commit is contained in:
parent
ffc5845a62
commit
d3e07492ca
4 changed files with 83 additions and 7 deletions
|
@ -5,6 +5,8 @@ import 'package:get_it/get_it.dart';
|
|||
|
||||
import '../../domain/entities/song.dart';
|
||||
import '../state/audio_store.dart';
|
||||
import '../state/music_data_store.dart';
|
||||
import '../state/navigation_store.dart';
|
||||
import '../theming.dart';
|
||||
import '../widgets/album_art.dart';
|
||||
import '../widgets/album_background.dart';
|
||||
|
@ -12,6 +14,8 @@ import '../widgets/currently_playing_header.dart';
|
|||
import '../widgets/playback_control.dart';
|
||||
import '../widgets/song_customization_buttons.dart';
|
||||
import '../widgets/time_progress_indicator.dart';
|
||||
import 'album_details_page.dart';
|
||||
import 'artist_details_page.dart';
|
||||
import 'queue_page.dart';
|
||||
|
||||
class CurrentlyPlayingPage extends StatelessWidget {
|
||||
|
@ -54,7 +58,10 @@ class CurrentlyPlayingPage extends StatelessWidget {
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CurrentlyPlayingHeader(onTap: _openQueue),
|
||||
CurrentlyPlayingHeader(
|
||||
onTap: _openQueue,
|
||||
onMoreTap: _openMoreMenu,
|
||||
),
|
||||
const Spacer(
|
||||
flex: 10,
|
||||
),
|
||||
|
@ -142,4 +149,65 @@ class CurrentlyPlayingPage extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openMoreMenu(BuildContext context) {
|
||||
final AudioStore audioStore = GetIt.I<AudioStore>();
|
||||
final MusicDataStore musicDataStore = GetIt.I<MusicDataStore>();
|
||||
final NavigationStore navStore = GetIt.I<NavigationStore>();
|
||||
|
||||
final song = audioStore.currentSongStream.value;
|
||||
// EXPLORATORY
|
||||
final albums = musicDataStore.albumStream.value;
|
||||
final album = albums.singleWhere((a) => a.title == song.album);
|
||||
|
||||
final artists = musicDataStore.artistStream.value;
|
||||
final artist = artists.singleWhere((a) => a.name == album.artist);
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
backgroundColor: DARK2,
|
||||
builder: (context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
height: 2,
|
||||
color: LIGHT1,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Go to artist'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
navStore.pushOnLibrary(
|
||||
MaterialPageRoute<Widget>(
|
||||
builder: (BuildContext context) => ArtistDetailsPage(
|
||||
artist: artist,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Go to album'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
navStore.pushOnLibrary(
|
||||
MaterialPageRoute<Widget>(
|
||||
builder: (BuildContext context) => AlbumDetailsPage(
|
||||
album: album,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,11 @@ class LibraryPage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('LibraryPage.build');
|
||||
final GlobalKey<NavigatorState> nav = GlobalKey();
|
||||
|
||||
final NavigationStore navStore = GetIt.I<NavigationStore>();
|
||||
|
||||
return WillPopScope(
|
||||
child: Navigator(
|
||||
key: nav,
|
||||
key: navStore.libraryNavKey,
|
||||
initialRoute: 'library',
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
WidgetBuilder builder;
|
||||
|
@ -32,7 +30,7 @@ class LibraryPage extends StatelessWidget {
|
|||
),
|
||||
onWillPop: () async {
|
||||
if (navStore.navIndex == 1) {
|
||||
return !await nav.currentState.maybePop();
|
||||
return !await navStore.libraryNavKey.currentState.maybePop();
|
||||
}
|
||||
return Future.value(true);
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'navigation_store.g.dart';
|
||||
|
@ -9,10 +10,18 @@ class NavigationStore extends _NavigationStore with _$NavigationStore {
|
|||
abstract class _NavigationStore with Store {
|
||||
_NavigationStore();
|
||||
|
||||
final libraryNavKey = GlobalKey<NavigatorState>();
|
||||
|
||||
@observable int navIndex = 0;
|
||||
|
||||
@action
|
||||
void setNavIndex(int i) {
|
||||
navIndex = i;
|
||||
}
|
||||
|
||||
void pushOnLibrary(Route route) {
|
||||
// TODO: don't like this...
|
||||
setNavIndex(1);
|
||||
libraryNavKey.currentState.push(route);
|
||||
}
|
||||
}
|
|
@ -4,9 +4,10 @@ import '../theming.dart';
|
|||
import 'next_song.dart';
|
||||
|
||||
class CurrentlyPlayingHeader extends StatelessWidget {
|
||||
const CurrentlyPlayingHeader({Key key, this.onTap}) : super(key: key);
|
||||
const CurrentlyPlayingHeader({Key key, this.onTap, this.onMoreTap}) : super(key: key);
|
||||
|
||||
final Function onTap;
|
||||
final Function onMoreTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -38,7 +39,7 @@ class CurrentlyPlayingHeader extends StatelessWidget {
|
|||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onPressed: () => null,
|
||||
onPressed: () => onMoreTap(context),
|
||||
)
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
|
Loading…
Add table
Reference in a new issue