Skip to content

Commit

Permalink
feat: add getting started page
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Feb 25, 2024
1 parent ca71406 commit 96a2a1f
Show file tree
Hide file tree
Showing 15 changed files with 887 additions and 216 deletions.
3 changes: 2 additions & 1 deletion lib/collections/intents.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:spotube/components/player/player_controls.dart';
import 'package:spotube/collections/routes.dart';
import 'package:spotube/components/player/player_controls.dart';
import 'package:spotube/models/logger.dart';
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
import 'package:spotube/services/audio_player/audio_player.dart';
Expand Down Expand Up @@ -64,6 +64,7 @@ class HomeTabIntent extends Intent {
class HomeTabAction extends Action<HomeTabIntent> {
@override
invoke(intent) {
final router = intent.ref.read(routerProvider);
switch (intent.tab) {
case HomeTabs.browse:
router.go("/");
Expand Down
5 changes: 5 additions & 0 deletions lib/collections/language_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class ISOLanguageName {
required this.name,
required this.nativeName,
});

@override
String toString() {
return "$name ($nativeName)";
}
}

// Uncomment the languages as we add support for them
Expand Down
299 changes: 163 additions & 136 deletions lib/collections/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'package:catcher_2/catcher_2.dart';
import 'package:flutter/foundation.dart' hide Category;
import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart' hide Search;
import 'package:spotube/pages/album/album.dart';
import 'package:spotube/pages/getting_started/getting_started.dart';
import 'package:spotube/pages/home/genres/genre_playlists.dart';
import 'package:spotube/pages/home/genres/genres.dart';
import 'package:spotube/pages/home/home.dart';
Expand All @@ -18,6 +20,8 @@ import 'package:spotube/pages/settings/blacklist.dart';
import 'package:spotube/pages/settings/about.dart';
import 'package:spotube/pages/settings/logs.dart';
import 'package:spotube/pages/track/track.dart';
import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/services/kv_store/kv_store.dart';
import 'package:spotube/utils/platform.dart';
import 'package:spotube/components/shared/spotube_page_route.dart';
import 'package:spotube/pages/artist/artist.dart';
Expand All @@ -31,157 +35,180 @@ import 'package:spotube/pages/mobile_login/mobile_login.dart';

final rootNavigatorKey = Catcher2.navigatorKey;
final shellRouteNavigatorKey = GlobalKey<NavigatorState>();
final router = GoRouter(
navigatorKey: rootNavigatorKey,
routes: [
ShellRoute(
navigatorKey: shellRouteNavigatorKey,
builder: (context, state, child) => RootApp(child: child),
routes: [
GoRoute(
path: "/",
pageBuilder: (context, state) => const SpotubePage(child: HomePage()),
routes: [
GoRoute(
path: "genres",
pageBuilder: (context, state) =>
const SpotubePage(child: GenrePage()),
),
GoRoute(
path: "genre/:categoryId",
pageBuilder: (context, state) => SpotubePage(
child: GenrePlaylistsPage(
category: state.extra as Category,
),
),
),
],
),
GoRoute(
path: "/search",
name: "Search",
pageBuilder: (context, state) =>
const SpotubePage(child: SearchPage()),
),
GoRoute(
path: "/library",
name: "Library",
final routerProvider = Provider((ref) {
return GoRouter(
navigatorKey: rootNavigatorKey,
routes: [
ShellRoute(
navigatorKey: shellRouteNavigatorKey,
builder: (context, state, child) => RootApp(child: child),
routes: [
GoRoute(
path: "/",
redirect: (context, state) async {
final authNotifier =
ref.read(AuthenticationNotifier.provider.notifier);
final json = await authNotifier.box.get(authNotifier.cacheKey);

if (json["cookie"] == null &&
!KVStoreService.doneGettingStarted) {
return "/getting-started";
}

return null;
},
pageBuilder: (context, state) =>
const SpotubePage(child: LibraryPage()),
const SpotubePage(child: HomePage()),
routes: [
GoRoute(
path: "generate",
pageBuilder: (context, state) =>
const SpotubePage(child: PlaylistGeneratorPage()),
routes: [
GoRoute(
path: "result",
pageBuilder: (context, state) => SpotubePage(
child: PlaylistGenerateResultPage(
state:
state.extra as PlaylistGenerateResultRouteState,
path: "genres",
pageBuilder: (context, state) =>
const SpotubePage(child: GenrePage()),
),
GoRoute(
path: "genre/:categoryId",
pageBuilder: (context, state) => SpotubePage(
child: GenrePlaylistsPage(
category: state.extra as Category,
),
),
),
],
),
GoRoute(
path: "/search",
name: "Search",
pageBuilder: (context, state) =>
const SpotubePage(child: SearchPage()),
),
GoRoute(
path: "/library",
name: "Library",
pageBuilder: (context, state) =>
const SpotubePage(child: LibraryPage()),
routes: [
GoRoute(
path: "generate",
pageBuilder: (context, state) =>
const SpotubePage(child: PlaylistGeneratorPage()),
routes: [
GoRoute(
path: "result",
pageBuilder: (context, state) => SpotubePage(
child: PlaylistGenerateResultPage(
state:
state.extra as PlaylistGenerateResultRouteState,
),
),
),
),
]),
]),
GoRoute(
path: "/lyrics",
name: "Lyrics",
pageBuilder: (context, state) =>
const SpotubePage(child: LyricsPage()),
),
GoRoute(
path: "/settings",
pageBuilder: (context, state) => const SpotubePage(
child: SettingsPage(),
]),
]),
GoRoute(
path: "/lyrics",
name: "Lyrics",
pageBuilder: (context, state) =>
const SpotubePage(child: LyricsPage()),
),
routes: [
GoRoute(
path: "blacklist",
pageBuilder: (context, state) => SpotubeSlidePage(
child: const BlackListPage(),
),
GoRoute(
path: "/settings",
pageBuilder: (context, state) => const SpotubePage(
child: SettingsPage(),
),
if (!kIsWeb)
routes: [
GoRoute(
path: "logs",
path: "blacklist",
pageBuilder: (context, state) => SpotubeSlidePage(
child: const LogsPage(),
child: const BlackListPage(),
),
),
GoRoute(
path: "about",
pageBuilder: (context, state) => SpotubeSlidePage(
child: const AboutSpotube(),
if (!kIsWeb)
GoRoute(
path: "logs",
pageBuilder: (context, state) => SpotubeSlidePage(
child: const LogsPage(),
),
),
GoRoute(
path: "about",
pageBuilder: (context, state) => SpotubeSlidePage(
child: const AboutSpotube(),
),
),
),
],
),
GoRoute(
path: "/album/:id",
pageBuilder: (context, state) {
assert(state.extra is AlbumSimple);
return SpotubePage(
child: AlbumPage(album: state.extra as AlbumSimple),
);
},
),
GoRoute(
path: "/artist/:id",
pageBuilder: (context, state) {
assert(state.pathParameters["id"] != null);
return SpotubePage(child: ArtistPage(state.pathParameters["id"]!));
},
],
),
GoRoute(
path: "/album/:id",
pageBuilder: (context, state) {
assert(state.extra is AlbumSimple);
return SpotubePage(
child: AlbumPage(album: state.extra as AlbumSimple),
);
},
),
GoRoute(
path: "/artist/:id",
pageBuilder: (context, state) {
assert(state.pathParameters["id"] != null);
return SpotubePage(
child: ArtistPage(state.pathParameters["id"]!));
},
),
GoRoute(
path: "/playlist/:id",
pageBuilder: (context, state) {
assert(state.extra is PlaylistSimple);
return SpotubePage(
child: state.pathParameters["id"] == "user-liked-tracks"
? LikedPlaylistPage(playlist: state.extra as PlaylistSimple)
: PlaylistPage(playlist: state.extra as PlaylistSimple),
);
},
),
GoRoute(
path: "/track/:id",
pageBuilder: (context, state) {
final id = state.pathParameters["id"]!;
return SpotubePage(
child: TrackPage(trackId: id),
);
},
),
],
),
GoRoute(
path: "/mini-player",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => SpotubePage(
child: MiniLyricsPage(prevSize: state.extra as Size),
),
GoRoute(
path: "/playlist/:id",
pageBuilder: (context, state) {
assert(state.extra is PlaylistSimple);
return SpotubePage(
child: state.pathParameters["id"] == "user-liked-tracks"
? LikedPlaylistPage(playlist: state.extra as PlaylistSimple)
: PlaylistPage(playlist: state.extra as PlaylistSimple),
);
},
),
GoRoute(
path: "/getting-started",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => const SpotubePage(
child: GettingStarting(),
),
GoRoute(
path: "/track/:id",
pageBuilder: (context, state) {
final id = state.pathParameters["id"]!;
return SpotubePage(
child: TrackPage(trackId: id),
);
},
),
GoRoute(
path: "/login",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => SpotubePage(
child: kIsMobile ? const WebViewLogin() : const DesktopLoginPage(),
),
],
),
GoRoute(
path: "/mini-player",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => SpotubePage(
child: MiniLyricsPage(prevSize: state.extra as Size),
),
),
GoRoute(
path: "/login",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => SpotubePage(
child: kIsMobile ? const WebViewLogin() : const DesktopLoginPage(),
GoRoute(
path: "/login-tutorial",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => const SpotubePage(
child: LoginTutorial(),
),
),
),
GoRoute(
path: "/login-tutorial",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) => const SpotubePage(
child: LoginTutorial(),
GoRoute(
path: "/lastfm-login",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) =>
const SpotubePage(child: LastFMLoginPage()),
),
),
GoRoute(
path: "/lastfm-login",
parentNavigatorKey: rootNavigatorKey,
pageBuilder: (context, state) =>
const SpotubePage(child: LastFMLoginPage()),
),
],
);
],
);
});
3 changes: 3 additions & 0 deletions lib/collections/spotube_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ abstract class SpotubeIcons {
static const discord = SimpleIcons.discord;
static const youtube = SimpleIcons.youtube;
static const radio = FeatherIcons.radio;
static const github = SimpleIcons.github;
static const openCollective = SimpleIcons.opencollective;
static const anonymous = FeatherIcons.user;
}
Loading

0 comments on commit 96a2a1f

Please sign in to comment.