chore: change player layout

This commit is contained in:
Kingkor Roy Tirtho 2023-03-28 11:46:07 +06:00
parent 6eb4244f32
commit 431e04c35c

View File

@ -1,5 +1,6 @@
import 'dart:ui'; import 'dart:ui';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@ -19,7 +20,6 @@ import 'package:spotube/models/local_track.dart';
import 'package:spotube/pages/lyrics/lyrics.dart'; import 'package:spotube/pages/lyrics/lyrics.dart';
import 'package:spotube/provider/authentication_provider.dart'; import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/provider/playlist_queue_provider.dart'; import 'package:spotube/provider/playlist_queue_provider.dart';
import 'package:spotube/provider/user_preferences_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 {
@ -38,9 +38,6 @@ class PlayerView extends HookConsumerWidget {
(value) => value?.activeTrack is LocalTrack, (value) => value?.activeTrack is LocalTrack,
)); ));
final breakpoint = useBreakpoints(); final breakpoint = useBreakpoints();
final canRotate = ref.watch(
userPreferencesProvider.select((s) => s.rotatingAlbumArt),
);
useEffect(() { useEffect(() {
if (breakpoint.isMoreThan(Breakpoints.md)) { if (breakpoint.isMoreThan(Breakpoints.md)) {
@ -75,7 +72,7 @@ class PlayerView extends HookConsumerWidget {
leading: BackButton(color: paletteColor.titleTextColor), leading: BackButton(color: paletteColor.titleTextColor),
), ),
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: Container( body: DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: UniversalImage.imageProvider(albumArt), image: UniversalImage.imageProvider(albumArt),
@ -84,31 +81,39 @@ class PlayerView extends HookConsumerWidget {
), ),
child: BackdropFilter( child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15), filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: Material( child: SafeArea(
color: paletteColor.color.withOpacity(.5), child: Padding(
child: SafeArea( padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
children: [ children: [
Padding( ClipRRect(
padding: const EdgeInsets.all(10), borderRadius: BorderRadius.circular(20),
child: UniversalImage(
path: albumArt,
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
alignment: Alignment.centerLeft,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( AutoSizeText(
height: 30, currentTrack?.name ?? "Not playing",
child: Text( style: TextStyle(
currentTrack?.name ?? "Not playing", fontSize: 20,
style: theme.textTheme.headlineSmall?.copyWith( color: paletteColor.titleTextColor,
fontWeight: FontWeight.bold,
color: paletteColor.titleTextColor,
),
), ),
maxLines: 1,
textAlign: TextAlign.start,
), ),
if (isLocalTrack) if (isLocalTrack)
Text( Text(
TypeConversionUtils.artists_X_String<Artist>( TypeConversionUtils.artists_X_String<Artist>(
currentTrack?.artists ?? [], currentTrack?.artists ?? [],
), ),
style: theme.textTheme.titleLarge!.copyWith( style: theme.textTheme.bodyMedium!.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: paletteColor.bodyTextColor, color: paletteColor.bodyTextColor,
), ),
@ -116,7 +121,7 @@ class PlayerView extends HookConsumerWidget {
else else
TypeConversionUtils.artists_X_ClickableArtists( TypeConversionUtils.artists_X_ClickableArtists(
currentTrack?.artists ?? [], currentTrack?.artists ?? [],
textStyle: theme.textTheme.titleLarge!.copyWith( textStyle: theme.textTheme.bodyMedium!.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: paletteColor.bodyTextColor, color: paletteColor.bodyTextColor,
), ),
@ -128,55 +133,8 @@ class PlayerView extends HookConsumerWidget {
], ],
), ),
), ),
const Spacer(), const SizedBox(height: 40),
HookBuilder(builder: (context) { PlayerControls(iconColor: paletteColor.bodyTextColor),
final ticker = useSingleTickerProvider();
final controller = useAnimationController(
duration: const Duration(seconds: 10),
vsync: ticker,
);
useEffect(
() {
controller.repeat();
if (!canRotate) controller.stop();
return null;
},
[controller],
);
return RotationTransition(
turns: Tween(begin: 0.0, end: 1.0).animate(controller),
child: Container(
decoration: BoxDecoration(
border: canRotate
? Border.all(
color: paletteColor.titleTextColor,
width: 2,
)
: null,
borderRadius:
!canRotate ? BorderRadius.circular(15) : null,
shape:
canRotate ? BoxShape.circle : BoxShape.rectangle,
),
child: !canRotate
? ClipRRect(
borderRadius: BorderRadius.circular(15),
child: UniversalImage(
path: albumArt,
width: MediaQuery.of(context).size.width *
(breakpoint.isSm ? 0.8 : 0.5),
),
)
: CircleAvatar(
backgroundImage:
UniversalImage.imageProvider(albumArt),
radius: MediaQuery.of(context).size.width *
(breakpoint.isSm ? 0.4 : 0.3),
),
),
);
}),
const Spacer(), const Spacer(),
PlayerActions( PlayerActions(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -211,7 +169,6 @@ class PlayerView extends HookConsumerWidget {
) )
], ],
), ),
PlayerControls(iconColor: paletteColor.bodyTextColor),
], ],
), ),
), ),