mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat(mini_player): show/hide lyrics #851
This commit is contained in:
parent
7818574356
commit
dcbb156833
@ -40,6 +40,7 @@ abstract class SpotubeIcons {
|
|||||||
static const trash = FeatherIcons.trash2;
|
static const trash = FeatherIcons.trash2;
|
||||||
static const clock = FeatherIcons.clock;
|
static const clock = FeatherIcons.clock;
|
||||||
static const lyrics = Icons.lyrics_rounded;
|
static const lyrics = Icons.lyrics_rounded;
|
||||||
|
static const lyricsOff = Icons.lyrics_outlined;
|
||||||
static const logout = FeatherIcons.logOut;
|
static const logout = FeatherIcons.logOut;
|
||||||
static const login = FeatherIcons.logIn;
|
static const login = FeatherIcons.logIn;
|
||||||
static const dashboard = FeatherIcons.grid;
|
static const dashboard = FeatherIcons.grid;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:palette_generator/palette_generator.dart';
|
import 'package:palette_generator/palette_generator.dart';
|
||||||
@ -32,6 +33,7 @@ class MiniLyricsPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
final areaActive = useState(false);
|
final areaActive = useState(false);
|
||||||
final hoverMode = useState(true);
|
final hoverMode = useState(true);
|
||||||
|
final showLyrics = useState(true);
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
@ -82,17 +84,41 @@ class MiniLyricsPage extends HookConsumerWidget {
|
|||||||
child: Sidebar.brandLogo(),
|
child: Sidebar.brandLogo(),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
SizedBox(
|
if (showLyrics.value)
|
||||||
height: 30,
|
SizedBox(
|
||||||
child: TabBar(
|
height: 30,
|
||||||
tabs: [
|
child: TabBar(
|
||||||
Tab(text: context.l10n.synced),
|
tabs: [
|
||||||
Tab(text: context.l10n.plain),
|
Tab(text: context.l10n.synced),
|
||||||
],
|
Tab(text: context.l10n.plain),
|
||||||
isScrollable: true,
|
],
|
||||||
|
isScrollable: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
tooltip: context.l10n.lyrics,
|
||||||
|
icon: showLyrics.value
|
||||||
|
? const Icon(SpotubeIcons.lyrics)
|
||||||
|
: const Icon(SpotubeIcons.lyricsOff),
|
||||||
|
style: ButtonStyle(
|
||||||
|
foregroundColor: showLyrics.value
|
||||||
|
? MaterialStateProperty.all(
|
||||||
|
theme.colorScheme.primary)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
showLyrics.value = !showLyrics.value;
|
||||||
|
areaActive.value = true;
|
||||||
|
hoverMode.value = false;
|
||||||
|
|
||||||
|
await DesktopTools.window.setSize(
|
||||||
|
showLyrics.value
|
||||||
|
? const Size(400, 500)
|
||||||
|
: const Size(400, 150),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
tooltip: context.l10n.show_hide_ui_on_hover,
|
tooltip: context.l10n.show_hide_ui_on_hover,
|
||||||
icon: hoverMode.value
|
icon: hoverMode.value
|
||||||
@ -105,9 +131,7 @@ class MiniLyricsPage extends HookConsumerWidget {
|
|||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!hoverMode.value == true) {
|
areaActive.value = true;
|
||||||
areaActive.value = true;
|
|
||||||
}
|
|
||||||
hoverMode.value = !hoverMode.value;
|
hoverMode.value = !hoverMode.value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -150,22 +174,25 @@ class MiniLyricsPage extends HookConsumerWidget {
|
|||||||
playlistQueue.activeTrack!.name!,
|
playlistQueue.activeTrack!.name!,
|
||||||
style: theme.textTheme.titleMedium,
|
style: theme.textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
Expanded(
|
if (showLyrics.value)
|
||||||
child: TabBarView(
|
Expanded(
|
||||||
children: [
|
child: TabBarView(
|
||||||
SyncedLyrics(
|
children: [
|
||||||
palette: PaletteColor(theme.colorScheme.background, 0),
|
SyncedLyrics(
|
||||||
isModal: true,
|
palette: PaletteColor(theme.colorScheme.background, 0),
|
||||||
defaultTextZoom: 65,
|
isModal: true,
|
||||||
),
|
defaultTextZoom: 65,
|
||||||
PlainLyrics(
|
),
|
||||||
palette: PaletteColor(theme.colorScheme.background, 0),
|
PlainLyrics(
|
||||||
isModal: true,
|
palette: PaletteColor(theme.colorScheme.background, 0),
|
||||||
defaultTextZoom: 65,
|
isModal: true,
|
||||||
),
|
defaultTextZoom: 65,
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
const Gap(20),
|
||||||
AnimatedCrossFade(
|
AnimatedCrossFade(
|
||||||
crossFadeState: areaActive.value
|
crossFadeState: areaActive.value
|
||||||
? CrossFadeState.showFirst
|
? CrossFadeState.showFirst
|
||||||
|
@ -112,7 +112,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
final lyricSlice = lyricValue.lyrics[index];
|
final lyricSlice = lyricValue.lyrics[index];
|
||||||
final isActive = lyricSlice.time.inSeconds == currentTime;
|
final isActive = lyricSlice.time.inSeconds == currentTime;
|
||||||
|
|
||||||
if (isActive && isUnSyncLyric == true) {
|
if (isActive) {
|
||||||
controller.scrollToIndex(
|
controller.scrollToIndex(
|
||||||
index,
|
index,
|
||||||
preferPosition: AutoScrollPosition.middle,
|
preferPosition: AutoScrollPosition.middle,
|
||||||
|
Loading…
Reference in New Issue
Block a user