feat: change default platform option and platform specific back button

This commit is contained in:
Kingkor Roy Tirtho 2022-11-04 12:09:27 +06:00
parent 5e96913ba3
commit 36c5e02f18
8 changed files with 58 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class ArtistProfile extends HookConsumerWidget {
return SafeArea( return SafeArea(
child: PlatformScaffold( child: PlatformScaffold(
appBar: const PageWindowTitleBar( appBar: const PageWindowTitleBar(
leading: BackButton(), leading: PlatformBackButton(),
), ),
body: HookBuilder( body: HookBuilder(
builder: (context) { builder: (context) {

View File

@ -16,7 +16,7 @@ class TokenLogin extends HookConsumerWidget {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: const PageWindowTitleBar(leading: BackButton()), appBar: const PageWindowTitleBar(leading: PlatformBackButton()),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Center( child: Center(
child: Container( child: Container(

View File

@ -75,7 +75,7 @@ class PlayerView extends HookConsumerWidget {
child: Column( child: Column(
children: [ children: [
PageWindowTitleBar( PageWindowTitleBar(
leading: const BackButton(), leading: const PlatformBackButton(),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
foregroundColor: paletteColor.titleTextColor, foregroundColor: paletteColor.titleTextColor,
), ),

View File

@ -21,7 +21,7 @@ class PlaylistGenreView extends ConsumerWidget {
Widget build(BuildContext context, ref) { Widget build(BuildContext context, ref) {
return Scaffold( return Scaffold(
appBar: const PageWindowTitleBar( appBar: const PageWindowTitleBar(
leading: BackButton(), leading: PlatformBackButton(),
), ),
body: Column( body: Column(
children: [ children: [

View File

@ -10,6 +10,7 @@ import 'package:spotube/components/Settings/ColorSchemePickerDialog.dart';
import 'package:spotube/components/Shared/AdaptiveListTile.dart'; import 'package:spotube/components/Shared/AdaptiveListTile.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart'; import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/hooks/useBreakpoints.dart'; import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/main.dart';
import 'package:spotube/models/SpotifyMarkets.dart'; import 'package:spotube/models/SpotifyMarkets.dart';
import 'package:spotube/models/SpotubeTrack.dart'; import 'package:spotube/models/SpotubeTrack.dart';
import 'package:spotube/provider/Auth.dart'; import 'package:spotube/provider/Auth.dart';
@ -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( PlatformListTile(
leading: const Icon(Icons.palette_outlined), leading: const Icon(Icons.palette_outlined),
title: const PlatformText("Accent Color Scheme"), title: const PlatformText("Accent Color Scheme"),

View File

@ -37,6 +37,7 @@ class AdaptiveListTile extends HookWidget {
onTap?.call(); onTap?.call();
showPlatformAlertDialog( showPlatformAlertDialog(
context, context,
barrierDismissible: true,
builder: (context) { builder: (context) {
return StatefulBuilder(builder: (context, update) { return StatefulBuilder(builder: (context, update) {
return PlatformAlertDialog( return PlatformAlertDialog(

View File

@ -115,7 +115,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
backgroundColor: color?.color, backgroundColor: color?.color,
foregroundColor: color?.titleTextColor, foregroundColor: color?.titleTextColor,
leading: Row( leading: Row(
children: [BackButton(color: color?.titleTextColor)], children: [
PlatformBackButton(color: color?.titleTextColor)
],
), ),
) )
: null, : null,

View File

@ -141,6 +141,11 @@ class Spotube extends StatefulHookConsumerWidget {
@override @override
SpotubeState createState() => SpotubeState(); 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 { class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
@ -181,6 +186,13 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
prevSize = appWindow.size; prevSize = appWindow.size;
} }
TargetPlatform appPlatform = TargetPlatform.android;
void changePlatform(TargetPlatform targetPlatform) {
appPlatform = targetPlatform;
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final themeMode = final themeMode =
@ -199,7 +211,7 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
}; };
}, []); }, []);
platform = TargetPlatform.macOS; platform = appPlatform;
return PlatformApp.router( return PlatformApp.router(
routeInformationParser: router.routeInformationParser, routeInformationParser: router.routeInformationParser,