mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix: get rid of overflow errors & status bar dark color
This commit is contained in:
parent
821b6c1f28
commit
5bb8231782
@ -15,6 +15,7 @@ import 'package:spotube/components/shared/animated_gradient.dart';
|
|||||||
import 'package:spotube/components/shared/dialogs/track_details_dialog.dart';
|
import 'package:spotube/components/shared/dialogs/track_details_dialog.dart';
|
||||||
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
||||||
import 'package:spotube/components/shared/image/universal_image.dart';
|
import 'package:spotube/components/shared/image/universal_image.dart';
|
||||||
|
import 'package:spotube/components/shared/panels/sliding_up_panel.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
import 'package:spotube/extensions/context.dart';
|
import 'package:spotube/extensions/context.dart';
|
||||||
import 'package:spotube/hooks/use_custom_status_bar_color.dart';
|
import 'package:spotube/hooks/use_custom_status_bar_color.dart';
|
||||||
@ -26,13 +27,10 @@ import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
|||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
|
|
||||||
class PlayerView extends HookConsumerWidget {
|
class PlayerView extends HookConsumerWidget {
|
||||||
final bool isOpen;
|
final PanelController panelController;
|
||||||
final Function() onClosePage;
|
|
||||||
|
|
||||||
const PlayerView({
|
const PlayerView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.isOpen,
|
required this.panelController,
|
||||||
required this.onClosePage,
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -50,7 +48,7 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (mediaQuery.lgAndUp) {
|
if (mediaQuery.lgAndUp) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
onClosePage();
|
panelController.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -65,35 +63,53 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final palette = usePaletteGenerator(albumArt);
|
final palette = usePaletteGenerator(albumArt);
|
||||||
final bgColor = palette.dominantColor?.color ?? theme.colorScheme.primary;
|
|
||||||
final titleTextColor = palette.dominantColor?.titleTextColor;
|
final titleTextColor = palette.dominantColor?.titleTextColor;
|
||||||
final bodyTextColor = palette.dominantColor?.bodyTextColor;
|
final bodyTextColor = palette.dominantColor?.bodyTextColor;
|
||||||
|
|
||||||
|
final bgColor = palette.dominantColor?.color ?? theme.colorScheme.primary;
|
||||||
|
|
||||||
|
final GlobalKey<ScaffoldState> scaffoldKey =
|
||||||
|
useMemoized(() => GlobalKey(), []);
|
||||||
|
|
||||||
|
useEffect(() {
|
||||||
|
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
|
||||||
|
|
||||||
|
return () {
|
||||||
|
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = true;
|
||||||
|
};
|
||||||
|
}, [panelController.isPanelOpen]);
|
||||||
|
|
||||||
useCustomStatusBarColor(
|
useCustomStatusBarColor(
|
||||||
bgColor,
|
bgColor,
|
||||||
isOpen,
|
panelController.isPanelOpen,
|
||||||
noSetBGColor: true,
|
noSetBGColor: true,
|
||||||
|
automaticSystemUiAdjustment: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final topPadding = MediaQueryData.fromView(View.of(context)).padding.top;
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
onClosePage();
|
panelController.close();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: IconTheme(
|
child: IconTheme(
|
||||||
data: theme.iconTheme.copyWith(color: bodyTextColor),
|
data: theme.iconTheme.copyWith(color: bodyTextColor),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
key: scaffoldKey,
|
||||||
appBar: PreferredSize(
|
appBar: PreferredSize(
|
||||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
preferredSize: Size.fromHeight(
|
||||||
child: SafeArea(
|
kToolbarHeight + topPadding,
|
||||||
minimum: const EdgeInsets.only(top: 30),
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(top: topPadding),
|
||||||
child: PageWindowTitleBar(
|
child: PageWindowTitleBar(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
foregroundColor: titleTextColor,
|
foregroundColor: titleTextColor,
|
||||||
toolbarOpacity: 1,
|
toolbarOpacity: 1,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(SpotubeIcons.angleDown, size: 18),
|
icon: const Icon(SpotubeIcons.angleDown, size: 18),
|
||||||
onPressed: onClosePage,
|
onPressed: panelController.close,
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -207,7 +223,7 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
color: bodyTextColor,
|
color: bodyTextColor,
|
||||||
),
|
),
|
||||||
onRouteChange: (route) {
|
onRouteChange: (route) {
|
||||||
onClosePage();
|
panelController.close();
|
||||||
GoRouter.of(context).push(route);
|
GoRouter.of(context).push(route);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -175,21 +175,19 @@ class PlayerOverlay extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
panelBuilder: (position) {
|
panelBuilder: (position) {
|
||||||
|
// this is the reason we're getting an update
|
||||||
final navigationHeight = ref.watch(navigationPanelHeight);
|
final navigationHeight = ref.watch(navigationPanelHeight);
|
||||||
if (navigationHeight == 50) return const SizedBox();
|
|
||||||
|
|
||||||
return AnimatedContainer(
|
return IgnorePointer(
|
||||||
clipBehavior: Clip.antiAlias,
|
ignoring: !panelController.isPanelOpen,
|
||||||
duration: const Duration(milliseconds: 250),
|
child: AnimatedContainer(
|
||||||
decoration: navigationHeight == 0
|
clipBehavior: Clip.antiAlias,
|
||||||
? const BoxDecoration(borderRadius: BorderRadius.zero)
|
duration: const Duration(milliseconds: 250),
|
||||||
: const BoxDecoration(borderRadius: radius),
|
decoration: navigationHeight == 0
|
||||||
child: HorizontalScrollableWidget(
|
? const BoxDecoration(borderRadius: BorderRadius.zero)
|
||||||
child: PlayerView(
|
: const BoxDecoration(borderRadius: radius),
|
||||||
isOpen: panelController.isPanelOpen,
|
child: HorizontalScrollableWidget(
|
||||||
onClosePage: () {
|
child: PlayerView(panelController: panelController),
|
||||||
panelController.close();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -51,7 +51,8 @@ class SpotubeNavigationBar extends HookConsumerWidget {
|
|||||||
}, [selectedIndex]);
|
}, [selectedIndex]);
|
||||||
|
|
||||||
if (layoutMode == LayoutMode.extended ||
|
if (layoutMode == LayoutMode.extended ||
|
||||||
(mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive)) {
|
(mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive) ||
|
||||||
|
panelHeight < 10) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ void useCustomStatusBarColor(
|
|||||||
Color color,
|
Color color,
|
||||||
bool isCurrentRoute, {
|
bool isCurrentRoute, {
|
||||||
bool noSetBGColor = false,
|
bool noSetBGColor = false,
|
||||||
|
bool? automaticSystemUiAdjustment,
|
||||||
}) {
|
}) {
|
||||||
final context = useContext();
|
final context = useContext();
|
||||||
final backgroundColor = Theme.of(context).scaffoldBackgroundColor;
|
final backgroundColor = Theme.of(context).scaffoldBackgroundColor;
|
||||||
@ -21,20 +22,30 @@ void useCustomStatusBarColor(
|
|||||||
final statusBarColor = SystemChrome.latestStyle?.statusBarColor;
|
final statusBarColor = SystemChrome.latestStyle?.statusBarColor;
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (isCurrentRoute && statusBarColor != color) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
if (automaticSystemUiAdjustment != null) {
|
||||||
SystemUiOverlayStyle(
|
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment =
|
||||||
statusBarColor:
|
automaticSystemUiAdjustment;
|
||||||
noSetBGColor ? Colors.transparent : color, // status bar color
|
}
|
||||||
statusBarIconBrightness: color.computeLuminance() > 0.179
|
if (isCurrentRoute && statusBarColor != color) {
|
||||||
? Brightness.dark
|
final isLight = color.computeLuminance() > 0.179;
|
||||||
: Brightness.light,
|
SystemChrome.setSystemUIOverlayStyle(
|
||||||
),
|
SystemUiOverlayStyle(
|
||||||
);
|
statusBarColor:
|
||||||
} else if (!isCurrentRoute && statusBarColor == color) {
|
noSetBGColor ? Colors.transparent : color, // status bar color
|
||||||
resetStatusbar();
|
statusBarIconBrightness:
|
||||||
}
|
isLight ? Brightness.dark : Brightness.light,
|
||||||
return;
|
),
|
||||||
|
);
|
||||||
|
} else if (!isCurrentRoute && statusBarColor == color) {
|
||||||
|
resetStatusbar();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () {
|
||||||
|
if (automaticSystemUiAdjustment != null) {
|
||||||
|
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [color, isCurrentRoute, statusBarColor]);
|
}, [color, isCurrentRoute, statusBarColor]);
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
|
Loading…
Reference in New Issue
Block a user