Skip to content

Commit 0d869a4

Browse files
authored
chore: adjust player color gradient according to position (#1295)
1 parent 7c7bbe7 commit 0d869a4

File tree

6 files changed

+62
-20
lines changed

6 files changed

+62
-20
lines changed

lib/app/view/desktop_home_page.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
6161
@override
6262
Widget build(BuildContext context) {
6363
final playerToTheRight = context.mediaQuerySize.width > kSideBarThreshHold;
64-
final isFullScreen = watchPropertyValue((AppModel m) => m.fullWindowMode);
64+
final isInFullWindowMode =
65+
watchPropertyValue((AppModel m) => m.fullWindowMode);
6566
final isVideo = watchPropertyValue((PlayerModel m) => m.isVideo == true);
6667

6768
registerStreamHandler(
@@ -121,7 +122,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
121122
),
122123
],
123124
),
124-
if (isFullScreen == true)
125+
if (isInFullWindowMode == true)
125126
Scaffold(
126127
backgroundColor: isVideo ? Colors.black : null,
127128
body: const PlayerView(position: PlayerPosition.fullWindow),

lib/player/view/bottom_player.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class BottomPlayer extends StatelessWidget with WatchItMixin {
142142
children: [
143143
if (!isMobile)
144144
PlayerColor(
145+
position: PlayerPosition.bottom,
145146
alpha: 0.2,
146147
size: Size(
147148
context.mediaQuerySize.width,

lib/player/view/full_height_player.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,14 @@ class FullHeightPlayer extends StatelessWidget with WatchItMixin {
179179
}
180180

181181
return Stack(
182-
children: [PlayerColor(alpha: 0.4, size: size), fullHeightPlayer],
182+
children: [
183+
PlayerColor(
184+
alpha: 0.4,
185+
size: size,
186+
position: playerPosition,
187+
),
188+
fullHeightPlayer,
189+
],
183190
);
184191
}
185192
}

lib/player/view/player_color.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,37 @@ import 'package:yaru/theme.dart';
55
import '../../extensions/build_context_x.dart';
66
import '../../extensions/theme_data_x.dart';
77
import '../player_model.dart';
8+
import 'player_view.dart';
89

910
class PlayerColor extends StatelessWidget with WatchItMixin {
10-
const PlayerColor({super.key, required this.size, required this.alpha});
11+
const PlayerColor({
12+
super.key,
13+
required this.size,
14+
required this.alpha,
15+
required this.position,
16+
});
1117

1218
final Size size;
1319
final double alpha;
20+
final PlayerPosition position;
1421

1522
@override
1623
Widget build(BuildContext context) {
1724
final theme = context.theme;
1825
final baseColor =
19-
watchPropertyValue((PlayerModel m) => m.color?.withValues(alpha: 0.3));
26+
watchPropertyValue((PlayerModel m) => m.color?.withValues(alpha: 0.4));
2027

21-
final color = baseColor ??
22-
theme.cardColor.scale(lightness: theme.isLight ? -0.2 : 0.2);
28+
final color = (baseColor ?? theme.cardColor).scale(
29+
lightness: theme.isLight ? -0.1 : 0.2,
30+
saturation: theme.isLight ? 0.9 : 0.5,
31+
);
2332
return Opacity(
24-
opacity: alpha * (theme.isLight ? 0.7 : 0.8),
33+
opacity: alpha * 0.8,
2534
child: Container(
2635
width: size.width,
2736
height: size.height,
2837
decoration: BoxDecoration(
29-
gradient: LinearGradient(
30-
colors: [
31-
color.withValues(alpha: 0.02),
32-
color,
33-
],
34-
begin: Alignment.topRight,
35-
end: Alignment.bottomLeft,
36-
),
38+
gradient: position.getGradient(color),
3739
),
3840
),
3941
);

lib/player/view/player_view.dart

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,29 @@ class _PlayerViewState extends State<PlayerView> {
6363
enum PlayerPosition {
6464
bottom,
6565
sideBar,
66-
fullWindow,
66+
fullWindow;
67+
68+
LinearGradient getGradient(Color color) {
69+
final colors = [
70+
color,
71+
color.withValues(alpha: 0.01),
72+
];
73+
return switch (this) {
74+
PlayerPosition.bottom => LinearGradient(
75+
colors: colors,
76+
begin: Alignment.centerLeft,
77+
end: Alignment.centerRight,
78+
),
79+
PlayerPosition.sideBar => LinearGradient(
80+
colors: colors,
81+
begin: Alignment.topRight,
82+
end: Alignment.bottomLeft,
83+
),
84+
PlayerPosition.fullWindow => LinearGradient(
85+
colors: colors,
86+
begin: Alignment.topCenter,
87+
end: Alignment.bottomCenter,
88+
)
89+
};
90+
}
6791
}

lib/settings/view/settings_tile.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '../../app/connectivity_model.dart';
99
import '../../app/view/routing_manager.dart';
1010
import '../../app_config.dart';
1111
import '../../common/page_ids.dart';
12+
import '../../common/view/global_keys.dart';
1213
import '../../common/view/icons.dart';
1314
import '../../common/view/progress.dart';
1415
import '../../extensions/build_context_x.dart';
@@ -38,9 +39,15 @@ class SettingsTile extends StatelessWidget with WatchItMixin {
3839
selected: selectedPageId == PageIDs.settings,
3940
leading: Icon(Iconz.settings),
4041
title: Text(context.l10n.settings),
41-
onTap: () => di<RoutingManager>().push(
42-
pageId: PageIDs.settings,
43-
),
42+
onTap: () {
43+
masterScaffoldKey.currentState
44+
?..closeEndDrawer()
45+
..closeDrawer();
46+
47+
di<RoutingManager>().push(
48+
pageId: PageIDs.settings,
49+
);
50+
},
4451
),
4552
if (trailing != null) Positioned(right: 15, child: trailing),
4653
],

0 commit comments

Comments
 (0)