fix(mobile): SafeArea bugs and back button color

This commit is contained in:
Kingkor Roy Tirtho 2022-11-24 12:12:55 +06:00
parent 3b6bf27a98
commit a8330ef2e1
6 changed files with 322 additions and 311 deletions

View File

@ -11,6 +11,7 @@ import 'package:spotube/components/Shared/Waypoint.dart';
import 'package:spotube/provider/SpotifyDI.dart'; import 'package:spotube/provider/SpotifyDI.dart';
import 'package:spotube/provider/SpotifyRequests.dart'; import 'package:spotube/provider/SpotifyRequests.dart';
import 'package:spotube/provider/UserPreferences.dart'; import 'package:spotube/provider/UserPreferences.dart';
import 'package:spotube/utils/platform.dart';
class Genres extends HookConsumerWidget { class Genres extends HookConsumerWidget {
const Genres({Key? key}) : super(key: key); const Genres({Key? key}) : super(key: key);
@ -43,7 +44,7 @@ class Genres extends HookConsumerWidget {
]; ];
return PlatformScaffold( return PlatformScaffold(
appBar: PageWindowTitleBar(), appBar: kIsDesktop ? PageWindowTitleBar() : null,
body: ListView.builder( body: ListView.builder(
itemCount: categories.length, itemCount: categories.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {

View File

@ -23,7 +23,8 @@ class UserLibrary extends HookConsumerWidget {
const UserAlbums(), const UserAlbums(),
][index.value]; ][index.value];
return PlatformScaffold( return SafeArea(
child: PlatformScaffold(
appBar: PageWindowTitleBar( appBar: PageWindowTitleBar(
titleWidth: 347, titleWidth: 347,
centerTitle: true, centerTitle: true,
@ -43,6 +44,7 @@ class UserLibrary extends HookConsumerWidget {
), ),
), ),
body: body, body: body,
),
); );
} }
} }

View File

@ -81,7 +81,7 @@ class PlayerOverlay extends HookConsumerWidget {
), ),
Row( Row(
children: [ children: [
PlatformIconButton( IconButton(
icon: Icon( icon: Icon(
Icons.skip_previous_rounded, Icons.skip_previous_rounded,
color: paletteColor.bodyTextColor, color: paletteColor.bodyTextColor,
@ -91,7 +91,7 @@ class PlayerOverlay extends HookConsumerWidget {
}), }),
Consumer( Consumer(
builder: (context, ref, _) { builder: (context, ref, _) {
return PlatformIconButton( return IconButton(
icon: Icon( icon: Icon(
ref.read(playbackProvider).isPlaying ref.read(playbackProvider).isPlaying
? Icons.pause_rounded ? Icons.pause_rounded
@ -105,7 +105,7 @@ class PlayerOverlay extends HookConsumerWidget {
); );
}, },
), ),
PlatformIconButton( IconButton(
icon: Icon( icon: Icon(
Icons.skip_next_rounded, Icons.skip_next_rounded,
color: paletteColor.bodyTextColor, color: paletteColor.bodyTextColor,

View File

@ -73,8 +73,9 @@ class Search extends HookConsumerWidget {
} }
} }
return PlatformScaffold( return SafeArea(
appBar: !kIsMacOS ? PageWindowTitleBar() : null, child: PlatformScaffold(
appBar: kIsDesktop && !kIsMacOS ? PageWindowTitleBar() : null,
body: auth.isAnonymous body: auth.isAnonymous
? const AnonymousFallback() ? const AnonymousFallback()
: Column( : Column(
@ -86,11 +87,13 @@ class Search extends HookConsumerWidget {
), ),
child: PlatformTextField( child: PlatformTextField(
onChanged: (value) { onChanged: (value) {
ref.read(searchTermStateProvider.notifier).state = value; ref.read(searchTermStateProvider.notifier).state =
value;
}, },
prefixIcon: Icons.search_rounded, prefixIcon: Icons.search_rounded,
prefixIconColor: PlatformProperty.only( prefixIconColor: PlatformProperty.only(
ios: PlatformTheme.of(context).textTheme?.caption?.color, ios:
PlatformTheme.of(context).textTheme?.caption?.color,
other: null, other: null,
).resolve(platform!), ).resolve(platform!),
placeholder: "Search...", placeholder: "Search...",
@ -182,7 +185,8 @@ class Search extends HookConsumerWidget {
}, },
); );
}), }),
if (searchTrack.hasNextPage && tracks.isNotEmpty) if (searchTrack.hasNextPage &&
tracks.isNotEmpty)
Center( Center(
child: PlatformTextButton( child: PlatformTextButton(
onPressed: searchTrack.isFetchingNextPage onPressed: searchTrack.isFetchingNextPage
@ -204,8 +208,8 @@ class Search extends HookConsumerWidget {
.error?[searchPlaylist.pageParams.last]) .error?[searchPlaylist.pageParams.last])
else else
ScrollConfiguration( ScrollConfiguration(
behavior: behavior: ScrollConfiguration.of(context)
ScrollConfiguration.of(context).copyWith( .copyWith(
dragDevices: { dragDevices: {
PointerDeviceKind.touch, PointerDeviceKind.touch,
PointerDeviceKind.mouse, PointerDeviceKind.mouse,
@ -225,7 +229,8 @@ class Search extends HookConsumerWidget {
...playlists.mapIndexed( ...playlists.mapIndexed(
(i, playlist) { (i, playlist) {
if (i == playlists.length - 1 && if (i == playlists.length - 1 &&
searchPlaylist.hasNextPage) { searchPlaylist
.hasNextPage) {
return Waypoint( return Waypoint(
onEnter: () { onEnter: () {
searchPlaylist searchPlaylist
@ -256,8 +261,8 @@ class Search extends HookConsumerWidget {
.error?[searchArtist.pageParams.last]) .error?[searchArtist.pageParams.last])
else else
ScrollConfiguration( ScrollConfiguration(
behavior: behavior: ScrollConfiguration.of(context)
ScrollConfiguration.of(context).copyWith( .copyWith(
dragDevices: { dragDevices: {
PointerDeviceKind.touch, PointerDeviceKind.touch,
PointerDeviceKind.mouse, PointerDeviceKind.mouse,
@ -285,8 +290,8 @@ class Search extends HookConsumerWidget {
); );
} }
return Container( return Container(
margin: margin: const EdgeInsets
const EdgeInsets.symmetric( .symmetric(
horizontal: 15), horizontal: 15),
child: ArtistCard(artist), child: ArtistCard(artist),
); );
@ -301,7 +306,8 @@ class Search extends HookConsumerWidget {
if (albums.isNotEmpty) if (albums.isNotEmpty)
PlatformText( PlatformText(
"Albums", "Albums",
style: Theme.of(context).textTheme.headline5, style:
Theme.of(context).textTheme.headline5,
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (searchAlbum.isLoading && if (searchAlbum.isLoading &&
@ -312,8 +318,8 @@ class Search extends HookConsumerWidget {
.error?[searchAlbum.pageParams.last]) .error?[searchAlbum.pageParams.last])
else else
ScrollConfiguration( ScrollConfiguration(
behavior: behavior: ScrollConfiguration.of(context)
ScrollConfiguration.of(context).copyWith( .copyWith(
dragDevices: { dragDevices: {
PointerDeviceKind.touch, PointerDeviceKind.touch,
PointerDeviceKind.mouse, PointerDeviceKind.mouse,
@ -359,6 +365,7 @@ class Search extends HookConsumerWidget {
) )
], ],
), ),
),
); );
} }
} }

View File

@ -114,11 +114,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
? PageWindowTitleBar( ? PageWindowTitleBar(
backgroundColor: color?.color, backgroundColor: color?.color,
foregroundColor: color?.titleTextColor, foregroundColor: color?.titleTextColor,
leading: Row( leading: PlatformBackButton(color: color?.titleTextColor),
children: [
PlatformBackButton(color: color?.titleTextColor)
],
),
) )
: null, : null,
body: CustomScrollView( body: CustomScrollView(
@ -130,6 +126,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
pinned: true, pinned: true,
expandedHeight: 400, expandedHeight: 400,
automaticallyImplyLeading: kIsMobile, automaticallyImplyLeading: kIsMobile,
leading: kIsMobile
? PlatformBackButton(color: color?.titleTextColor)
: null,
iconTheme: IconThemeData(color: color?.titleTextColor), iconTheme: IconThemeData(color: color?.titleTextColor),
primary: true, primary: true,
backgroundColor: color?.color, backgroundColor: color?.color,

View File

@ -235,13 +235,15 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
macosTheme: macosTheme, macosTheme: macosTheme,
macosDarkTheme: macosDarkTheme, macosDarkTheme: macosDarkTheme,
themeMode: themeMode, themeMode: themeMode,
windowButtonConfig: PlatformWindowButtonConfig( windowButtonConfig: kIsDesktop
? PlatformWindowButtonConfig(
isMaximized: () => appWindow.isMaximized, isMaximized: () => appWindow.isMaximized,
onClose: appWindow.close, onClose: appWindow.close,
onRestore: appWindow.restore, onRestore: appWindow.restore,
onMaximize: appWindow.maximize, onMaximize: appWindow.maximize,
onMinimize: appWindow.minimize, onMinimize: appWindow.minimize,
), )
: null,
shortcuts: PlatformProperty.all({ shortcuts: PlatformProperty.all({
...WidgetsApp.defaultShortcuts.map((key, value) { ...WidgetsApp.defaultShortcuts.map((key, value) {
return MapEntry( return MapEntry(