Skip to content

Commit 76baeb7

Browse files
authored
chore: adjust player lyrics (#1375)
1 parent b15aca1 commit 76baeb7

File tree

3 files changed

+85
-92
lines changed

3 files changed

+85
-92
lines changed

lib/player/view/full_height_player_audio_body.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ class FullHeightPlayerAudioBody extends StatelessWidget with WatchItMixin {
4040
playerPosition == PlayerPosition.fullWindow &&
4141
mediaQuerySize.width > 1000;
4242
final theme = context.theme;
43-
final queueOrHistory = (audio?.audioType == AudioType.radio
44-
? const SizedBox(
45-
width: 400,
46-
height: 500,
47-
child: RadioHistoryList(simpleList: true),
48-
)
49-
: Padding(
50-
padding: const EdgeInsets.only(top: 50, bottom: 50),
51-
child: QueueOrLyrics(
52-
key: ValueKey(audio?.path),
53-
width: 400,
54-
selectedColor: theme.colorScheme.onSurface,
55-
),
56-
));
43+
final queueOrHistory = Padding(
44+
padding: const EdgeInsets.only(top: 50, bottom: 50),
45+
child: SizedBox(
46+
width: 400,
47+
child: (audio?.audioType == AudioType.radio
48+
? SizedBox(
49+
height: playerWithSidePanel ? 500 : null,
50+
child: const RadioHistoryList(simpleList: true),
51+
)
52+
: QueueOrLyrics(
53+
key: ValueKey(audio?.path),
54+
selectedColor: theme.colorScheme.onSurface,
55+
)),
56+
),
57+
);
5758
final column = Column(
5859
mainAxisAlignment: MainAxisAlignment.center,
5960
mainAxisSize: MainAxisSize.min,

lib/player/view/player_lyrics.dart

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import '../../l10n/l10n.dart';
1616
import '../player_model.dart';
1717

1818
class PlayerLyrics extends StatefulWidget with WatchItStatefulWidgetMixin {
19-
const PlayerLyrics({super.key, required this.audio, required this.width});
19+
const PlayerLyrics({super.key, required this.audio});
2020

2121
final Audio audio;
22-
final double width;
2322

2423
@override
2524
State<PlayerLyrics> createState() => _PlayerLyricsState();
@@ -100,65 +99,62 @@ class _PlayerLyricsState extends State<PlayerLyrics> {
10099
(PlayerModel m) => m.color ?? context.colorScheme.primary,
101100
);
102101

103-
return SizedBox(
104-
width: widget.width,
105-
child: Column(
106-
spacing: kLargestSpace,
107-
children: [
108-
Expanded(
109-
child: ScrollConfiguration(
110-
behavior: ScrollConfiguration.of(
111-
context,
112-
).copyWith(scrollbars: !_autoScroll),
113-
child: ListView.builder(
102+
return Column(
103+
spacing: kLargestSpace,
104+
children: [
105+
Expanded(
106+
child: ScrollConfiguration(
107+
behavior: ScrollConfiguration.of(
108+
context,
109+
).copyWith(scrollbars: !_autoScroll),
110+
child: ListView.builder(
111+
controller: _controller,
112+
itemCount: lrc!.length,
113+
itemBuilder: (context, index) => AutoScrollTag(
114+
index: index,
114115
controller: _controller,
115-
itemCount: lrc!.length,
116-
itemBuilder: (context, index) => AutoScrollTag(
117-
index: index,
118-
controller: _controller,
119-
key: ValueKey(index),
120-
child: AnimatedContainer(
121-
duration: const Duration(milliseconds: 300),
122-
child: ListTile(
123-
key: ValueKey('${index}_tile'),
124-
selected: _selectedIndex == index,
125-
selectedTileColor: Colors.transparent,
126-
selectedColor: color,
127-
title: Text(
128-
lrc!.elementAt(index).lyrics,
129-
style: context.textTheme.bodyLarge?.copyWith(
130-
fontSize: _selectedIndex == index ? 18 : 15,
131-
fontWeight: _selectedIndex == index
132-
? FontWeight.bold
133-
: FontWeight.w300,
134-
color: _selectedIndex == index ? color : null,
135-
),
116+
key: ValueKey(index),
117+
child: AnimatedContainer(
118+
duration: const Duration(milliseconds: 300),
119+
child: ListTile(
120+
key: ValueKey('${index}_tile'),
121+
selected: _selectedIndex == index,
122+
selectedTileColor: Colors.transparent,
123+
selectedColor: color,
124+
title: Text(
125+
lrc!.elementAt(index).lyrics,
126+
style: context.textTheme.bodyLarge?.copyWith(
127+
fontSize: _selectedIndex == index ? 18 : 15,
128+
fontWeight: _selectedIndex == index
129+
? FontWeight.bold
130+
: FontWeight.w300,
131+
color: _selectedIndex == index ? color : null,
136132
),
137133
),
138134
),
139135
),
140136
),
141137
),
142138
),
143-
SizedBox(
144-
width: 200,
145-
child: TextButton.icon(
146-
style: TextButton.styleFrom(
147-
iconColor: _autoScroll ? color : context.colorScheme.onSurface,
148-
foregroundColor: _autoScroll
149-
? color
150-
: context.colorScheme.onSurface,
151-
shape: RoundedRectangleBorder(
152-
borderRadius: BorderRadius.circular(kYaruButtonRadius),
153-
),
139+
),
140+
SizedBox(
141+
width: 200,
142+
child: TextButton.icon(
143+
style: TextButton.styleFrom(
144+
iconColor: _autoScroll ? color : context.colorScheme.onSurface,
145+
foregroundColor: _autoScroll
146+
? color
147+
: context.colorScheme.onSurface,
148+
shape: RoundedRectangleBorder(
149+
borderRadius: BorderRadius.circular(kYaruButtonRadius),
154150
),
155-
onPressed: () => setState(() => _autoScroll = !_autoScroll),
156-
label: Text(context.l10n.autoScrolling, maxLines: 1),
157-
icon: const Icon(Icons.auto_awesome),
158151
),
152+
onPressed: () => setState(() => _autoScroll = !_autoScroll),
153+
label: Text(context.l10n.autoScrolling, maxLines: 1),
154+
icon: const Icon(Icons.auto_awesome),
159155
),
160-
],
161-
),
156+
),
157+
],
162158
);
163159
}
164160
}

lib/player/view/queue/queue_or_lyrics.dart

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ class QueueOrLyrics extends StatefulWidget with WatchItStatefulWidgetMixin {
1313
super.key,
1414
this.selectedColor,
1515
this.shownInDialog = false,
16-
required this.width,
1716
});
1817

1918
final Color? selectedColor;
2019
final bool shownInDialog;
21-
final double width;
2220

2321
@override
2422
State<QueueOrLyrics> createState() => _QueueOrLyricsState();
@@ -54,34 +52,32 @@ class _QueueOrLyricsState extends State<QueueOrLyrics>
5452
}
5553
final audio = watchPropertyValue((PlayerModel m) => m.audio);
5654

57-
return SizedBox(
58-
width: widget.width,
59-
child: Column(
60-
spacing: kLargestSpace,
61-
children: [
62-
YaruTabBar(
63-
tabs: [
64-
Tab(text: context.l10n.queue),
65-
Tab(text: context.l10n.lyrics),
55+
return Column(
56+
spacing: kLargestSpace,
57+
children: [
58+
YaruTabBar(
59+
onTap: (i) => di<SettingsModel>().setShowPlayerLyrics(i == 1),
60+
tabs: [
61+
Tab(text: context.l10n.queue),
62+
Tab(text: context.l10n.lyrics),
63+
],
64+
tabController: _controller,
65+
),
66+
Expanded(
67+
child: TabBarView(
68+
controller: _controller,
69+
children: [
70+
QueueBody(
71+
selectedColor: widget.selectedColor,
72+
shownInDialog: widget.shownInDialog,
73+
),
74+
audio == null
75+
? const SizedBox.shrink()
76+
: PlayerLyrics(audio: audio),
6677
],
67-
tabController: _controller,
6878
),
69-
Expanded(
70-
child: TabBarView(
71-
controller: _controller,
72-
children: [
73-
QueueBody(
74-
selectedColor: widget.selectedColor,
75-
shownInDialog: widget.shownInDialog,
76-
),
77-
audio == null
78-
? const SizedBox.shrink()
79-
: PlayerLyrics(audio: audio, width: widget.width),
80-
],
81-
),
82-
),
83-
],
84-
),
79+
),
80+
],
8581
);
8682
}
8783
}

0 commit comments

Comments
 (0)