Skip to content

Commit

Permalink
feat: change default platform option and platform specific back button
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Nov 4, 2022
1 parent 5e96913 commit 36c5e02
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/components/Artist/ArtistProfile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ArtistProfile extends HookConsumerWidget {
return SafeArea(
child: PlatformScaffold(
appBar: const PageWindowTitleBar(
leading: BackButton(),
leading: PlatformBackButton(),
),
body: HookBuilder(
builder: (context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Login/TokenLogin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TokenLogin extends HookConsumerWidget {

return SafeArea(
child: Scaffold(
appBar: const PageWindowTitleBar(leading: BackButton()),
appBar: const PageWindowTitleBar(leading: PlatformBackButton()),
body: SingleChildScrollView(
child: Center(
child: Container(
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Player/PlayerView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PlayerView extends HookConsumerWidget {
child: Column(
children: [
PageWindowTitleBar(
leading: const BackButton(),
leading: const PlatformBackButton(),
backgroundColor: Colors.transparent,
foregroundColor: paletteColor.titleTextColor,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Playlist/PlaylistGenreView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PlaylistGenreView extends ConsumerWidget {
Widget build(BuildContext context, ref) {
return Scaffold(
appBar: const PageWindowTitleBar(
leading: BackButton(),
leading: PlatformBackButton(),
),
body: Column(
children: [
Expand Down
37 changes: 37 additions & 0 deletions lib/components/Settings/Settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:spotube/components/Settings/ColorSchemePickerDialog.dart';
import 'package:spotube/components/Shared/AdaptiveListTile.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/main.dart';
import 'package:spotube/models/SpotifyMarkets.dart';
import 'package:spotube/models/SpotubeTrack.dart';
import 'package:spotube/provider/Auth.dart';
Expand Down Expand Up @@ -204,6 +205,42 @@ class Settings extends HookConsumerWidget {
},
),
),
AdaptiveListTile(
leading: const Icon(Icons.ad_units_rounded),
title: const PlatformText("Mimic Platform"),
trailing: (context, update) =>
PlatformDropDownMenu<TargetPlatform>(
value: Spotube.of(context).appPlatform,
items: [
PlatformDropDownMenuItem(
value: TargetPlatform.android,
child: const PlatformText("Android (Material You)"),
),
PlatformDropDownMenuItem(
value: TargetPlatform.iOS,
child: const PlatformText("iOS (Cupertino)"),
),
PlatformDropDownMenuItem(
value: TargetPlatform.macOS,
child: const PlatformText("macOS (Aqua)"),
),
PlatformDropDownMenuItem(
value: TargetPlatform.linux,
child: const PlatformText("Linux (GTK+Libadwaita)"),
),
PlatformDropDownMenuItem(
value: TargetPlatform.windows,
child: const PlatformText("Windows 11 (Fluent UI)"),
),
],
onChanged: (value) {
if (value != null) {
Spotube.of(context).changePlatform(value);
update?.call(() {});
}
},
),
),
PlatformListTile(
leading: const Icon(Icons.palette_outlined),
title: const PlatformText("Accent Color Scheme"),
Expand Down
1 change: 1 addition & 0 deletions lib/components/Shared/AdaptiveListTile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AdaptiveListTile extends HookWidget {
onTap?.call();
showPlatformAlertDialog(
context,
barrierDismissible: true,
builder: (context) {
return StatefulBuilder(builder: (context, update) {
return PlatformAlertDialog(
Expand Down
4 changes: 3 additions & 1 deletion lib/components/Shared/TrackCollectionView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
backgroundColor: color?.color,
foregroundColor: color?.titleTextColor,
leading: Row(
children: [BackButton(color: color?.titleTextColor)],
children: [
PlatformBackButton(color: color?.titleTextColor)
],
),
)
: null,
Expand Down
14 changes: 13 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ class Spotube extends StatefulHookConsumerWidget {

@override
SpotubeState createState() => SpotubeState();

/// ↓↓ ADDED
/// InheritedWidget style accessor to our State object.
static SpotubeState of(BuildContext context) =>
context.findAncestorStateOfType<SpotubeState>()!;
}

class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
Expand Down Expand Up @@ -181,6 +186,13 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
prevSize = appWindow.size;
}

TargetPlatform appPlatform = TargetPlatform.android;

void changePlatform(TargetPlatform targetPlatform) {
appPlatform = targetPlatform;
setState(() {});
}

@override
Widget build(BuildContext context) {
final themeMode =
Expand All @@ -199,7 +211,7 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
};
}, []);

platform = TargetPlatform.macOS;
platform = appPlatform;

return PlatformApp.router(
routeInformationParser: router.routeInformationParser,
Expand Down

0 comments on commit 36c5e02

Please sign in to comment.