mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00

* feat: add riverpod based favorite album provider * feat: add album is saved, new releases and tracks providers * feat: add artist related providers * feat: add all categories providers * feat: add lyrics provider * feat: add playlist related providers * feat: add search provider * feat: add view and spotify friends provider * feat: add playlist create and update and favorite handlers * feat: use providers in home screen * chore: fix dart lint issues * feat: use new providers for playlist and albums screen * feat: use providers in artist page * feat: use providers on library page * feat: use provider for playlist and album card and heart button * feat: use provider in search page * feat: use providers in generate playlist * feat: use provider in lyrics screen * feat: use provider for create playlist * feat: use provider in add track dialog * feat: use providers in remaining pages and remove fl_query * fix: remove direct access to provider.value * fix: glitching when loading * fix: user album loading next page indicator * feat: make many provider autoDispose after 5 minutes of no usage * fix: ignore episodes in tracks
109 lines
3.7 KiB
Dart
109 lines
3.7 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:spotube/collections/side_bar_tiles.dart';
|
|
import 'package:spotube/components/root/sidebar.dart';
|
|
import 'package:spotube/extensions/constrains.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/hooks/utils/use_brightness_value.dart';
|
|
import 'package:spotube/provider/download_manager_provider.dart';
|
|
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
|
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
|
|
|
final navigationPanelHeight = StateProvider<double>((ref) => 50);
|
|
|
|
class SpotubeNavigationBar extends HookConsumerWidget {
|
|
final int? selectedIndex;
|
|
final void Function(int) onSelectedIndexChanged;
|
|
|
|
const SpotubeNavigationBar({
|
|
required this.selectedIndex,
|
|
required this.onSelectedIndexChanged,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final theme = Theme.of(context);
|
|
final downloadCount = ref.watch(downloadManagerProvider).$downloadCount;
|
|
final mediaQuery = MediaQuery.of(context);
|
|
final layoutMode =
|
|
ref.watch(userPreferencesProvider.select((s) => s.layoutMode));
|
|
|
|
final insideSelectedIndex = useState<int>(selectedIndex ?? 0);
|
|
|
|
final buttonColor = useBrightnessValue(
|
|
theme.colorScheme.inversePrimary,
|
|
theme.colorScheme.primary.withOpacity(0.2),
|
|
);
|
|
|
|
final navbarTileList =
|
|
useMemoized(() => getNavbarTileList(context.l10n), [context.l10n]);
|
|
|
|
final panelHeight = ref.watch(navigationPanelHeight);
|
|
|
|
useEffect(() {
|
|
if (selectedIndex != null) {
|
|
insideSelectedIndex.value = selectedIndex!;
|
|
}
|
|
return null;
|
|
}, [selectedIndex]);
|
|
|
|
if (layoutMode == LayoutMode.extended ||
|
|
(mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive) ||
|
|
panelHeight < 10) {
|
|
return const SizedBox();
|
|
}
|
|
|
|
return AnimatedContainer(
|
|
duration: const Duration(milliseconds: 100),
|
|
height: panelHeight,
|
|
child: ClipRect(
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
|
|
child: CurvedNavigationBar(
|
|
backgroundColor:
|
|
theme.colorScheme.secondaryContainer.withOpacity(0.72),
|
|
buttonBackgroundColor: buttonColor,
|
|
color: theme.colorScheme.background,
|
|
height: panelHeight,
|
|
animationDuration: const Duration(milliseconds: 350),
|
|
items: navbarTileList.map(
|
|
(e) {
|
|
/// Using this [Builder] as an workaround for the first item's
|
|
/// icon color not updating unless navigating to another page
|
|
return Builder(builder: (context) {
|
|
return MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Badge(
|
|
isLabelVisible: e.id == "library" && downloadCount > 0,
|
|
label: Text(downloadCount.toString()),
|
|
child: Icon(
|
|
e.icon,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
),
|
|
);
|
|
});
|
|
},
|
|
).toList(),
|
|
index: insideSelectedIndex.value,
|
|
onTap: (i) {
|
|
insideSelectedIndex.value = i;
|
|
if (navbarTileList[i].id == "settings") {
|
|
Sidebar.goToSettings(context);
|
|
return;
|
|
}
|
|
onSelectedIndexChanged(i);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|