Skip to content

Commit

Permalink
fix(android): dynamic status bar and safearea, playerview artist link…
Browse files Browse the repository at this point in the history
…, login success redirect
  • Loading branch information
KRTirtho committed Oct 12, 2022
1 parent 933b8d5 commit 8a72f62
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 27 deletions.
32 changes: 17 additions & 15 deletions lib/components/Home/Shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/components/Shared/ReplaceDownloadedFileDialog.dart';
import 'package:spotube/hooks/useUpdateChecker.dart';
import 'package:spotube/provider/Downloader.dart';
import 'package:spotube/utils/platform.dart';

const _path = {
0: "/",
Expand Down Expand Up @@ -66,21 +67,22 @@ class Shell extends HookConsumerWidget {
final preferredSize =
allowedPath ? PageWindowTitleBar.staticPreferredSize : Size.zero;
return Scaffold(
primary: true,
appBar: PreferredSize(
preferredSize: preferredSize,
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
height:
allowedPath ? PageWindowTitleBar.staticPreferredSize.height : 0,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 250),
opacity: allowedPath ? 1 : 0,
child: PageWindowTitleBar(preferredSize: preferredSize),
),
),
),
extendBodyBehindAppBar: true,
appBar: kIsDesktop
? PreferredSize(
preferredSize: preferredSize,
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
height: allowedPath
? PageWindowTitleBar.staticPreferredSize.height
: 0,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 250),
opacity: allowedPath ? 1 : 0,
child: PageWindowTitleBar(preferredSize: preferredSize),
),
),
)
: null,
body: Row(
children: [
Sidebar(
Expand Down
14 changes: 14 additions & 0 deletions lib/components/Library/UserLocalTracks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import 'package:metadata_god/metadata_god.dart';
import 'package:mime/mime.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/LoaderShimmers/ShimmerTrackTile.dart';
import 'package:spotube/components/Shared/TrackTile.dart';
import 'package:spotube/hooks/useAsyncEffect.dart';
import 'package:spotube/models/CurrentPlaylist.dart';
import 'package:spotube/models/Logger.dart';
import 'package:spotube/provider/Playback.dart';
Expand Down Expand Up @@ -132,6 +134,18 @@ class UserLocalTracks extends HookConsumerWidget {
final playback = ref.watch(playbackProvider);
final isPlaylistPlaying = playback.playlist?.id == "local";
final trackSnapshot = ref.watch(localTracksProvider);

useAsyncEffect(
() async {
if (!await Permission.storage.isGranted &&
!await Permission.storage.isLimited) {
await Permission.storage.request();
}
},
null,
[],
);

return Column(
children: [
Padding(
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 @@ -38,7 +38,7 @@ class TokenLogin extends HookConsumerWidget {
),
const SizedBox(height: 10),
TokenLoginForm(
onDone: () => ServiceUtils.navigate(context, "/"),
onDone: () => GoRouter.of(context).go("/"),
),
const SizedBox(height: 10),
Wrap(
Expand Down
3 changes: 2 additions & 1 deletion lib/components/Login/WebViewLogin.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/provider/Auth.dart';
import 'package:spotube/utils/platform.dart';
Expand Down Expand Up @@ -61,7 +62,7 @@ class WebViewLogin extends HookConsumerWidget {
);
if (mounted()) {
// ignore: use_build_context_synchronously
ServiceUtils.navigate(context, "/");
GoRouter.of(context).go("/");
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions lib/components/Player/PlayerView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class PlayerView extends HookConsumerWidget {
fontWeight: FontWeight.bold,
color: paletteColor.bodyTextColor,
),
onRouteChange: (route) {
GoRouter.of(context).pop();
GoRouter.of(context).push(route);
},
),
],
),
Expand Down
1 change: 0 additions & 1 deletion lib/components/Settings/Settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Settings extends HookConsumerWidget {
return SafeArea(
child: Scaffold(
appBar: PageWindowTitleBar(
leading: const BackButton(),
center: Text(
"Settings",
style: Theme.of(context).textTheme.headline5,
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Shared/TrackCollectionView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class TrackCollectionView extends HookConsumerWidget {

return SafeArea(
child: Scaffold(
appBar: (kIsDesktop)
appBar: kIsDesktop
? PageWindowTitleBar(
backgroundColor: color?.color,
foregroundColor: color?.titleTextColor,
Expand Down
30 changes: 22 additions & 8 deletions lib/utils/type_conversion_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'dart:io';
import 'package:flutter/widgets.dart' hide Image;
import 'package:metadata_god/metadata_god.dart' hide Image;
import 'package:path/path.dart';
import 'package:spotube/components/Shared/AnchorButton.dart';
import 'package:spotube/components/Shared/LinkText.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/models/SpotubeTrack.dart';
import 'package:spotube/utils/primitive_utils.dart';
import 'package:spotube/utils/service_utils.dart';
import 'package:youtube_explode_dart/youtube_explode_dart.dart';

enum ImagePlaceholder {
Expand Down Expand Up @@ -46,6 +48,7 @@ abstract class TypeConversionUtils {
WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.center,
WrapAlignment mainAxisAlignment = WrapAlignment.center,
TextStyle textStyle = const TextStyle(),
void Function(String route)? onRouteChange,
}) {
return Wrap(
crossAxisAlignment: crossAxisAlignment,
Expand All @@ -54,14 +57,25 @@ abstract class TypeConversionUtils {
.asMap()
.entries
.map(
(artist) => LinkText(
(artist.key != artists.length - 1)
? "${artist.value.name}, "
: artist.value.name!,
"/artist/${artist.value.id}",
overflow: TextOverflow.ellipsis,
style: textStyle,
),
(artist) => Builder(builder: (context) {
return AnchorButton(
(artist.key != artists.length - 1)
? "${artist.value.name}, "
: artist.value.name!,
onTap: () {
if (onRouteChange != null) {
onRouteChange("/artist/${artist.value.id}");
} else {
ServiceUtils.navigate(
context,
"/artist/${artist.value.id}",
);
}
},
overflow: TextOverflow.ellipsis,
style: textStyle,
);
}),
)
.toList(),
);
Expand Down

0 comments on commit 8a72f62

Please sign in to comment.