mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-15 00:25:17 +00:00

Configuration File Removals: .vscode/c_cpp_properties.json: Removed the entire configuration for C/C++ properties. .vscode/launch.json: Removed the Dart launch configurations for different environments and modes. .vscode/settings.json: Removed settings related to CMake, spell checking, file nesting, and Dart Flutter SDK path. .vscode/snippets.code-snippets: Removed code snippets for Dart, including PaginatedState and PaginatedNotifier templates. .vscode/tasks.json: Removed the tasks configuration file. Documentation Updates: CONTRIBUTION.md: Removed heart emoji from the introductory text. README.md: Updated the logo image and made minor text adjustments, including removing emojis and updating section titles. [1] [2] [3] [4] [5] Asset Removals: lib/collections/assets.gen.dart: Removed multiple unused asset references, including images related to Spotube logos and banners. [1] [2] [3] Minor Code Cleanups: cli/commands/build/linux.dart, cli/commands/build/windows.dart, cli/commands/translated.dart, cli/commands/untranslated.dart: Adjusted import statements for consistency. [1] [2] [3] [4] integration_test/app_test.dart: Removed an unnecessary blank line. lib/collections/routes.dart: Commented out the TrackRoute configuration.
127 lines
3.9 KiB
Dart
127 lines
3.9 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:spotube/collections/assets.gen.dart';
|
|
import 'package:spotube/collections/side_bar_tiles.dart';
|
|
import 'package:spotube/extensions/constrains.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/models/database/database.dart';
|
|
import 'package:spotube/modules/root/sidebar/sidebar_footer.dart';
|
|
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
|
|
|
class Sidebar extends HookConsumerWidget {
|
|
final Widget child;
|
|
|
|
const Sidebar({
|
|
required this.child,
|
|
super.key,
|
|
});
|
|
|
|
static Widget brandLogo() {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.black,
|
|
borderRadius: BorderRadius.circular(50),
|
|
),
|
|
child: Assets.spotubeLogoStableNotWallpaper.image(height: 50),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final mediaQuery = MediaQuery.of(context);
|
|
|
|
final layoutMode =
|
|
ref.watch(userPreferencesProvider.select((s) => s.layoutMode));
|
|
|
|
final sidebarTileList = useMemoized(
|
|
() => getSidebarTileList(context.l10n),
|
|
[context.l10n],
|
|
);
|
|
|
|
final sidebarLibraryTileList = useMemoized(
|
|
() => getSidebarLibraryTileList(context.l10n),
|
|
[context.l10n],
|
|
);
|
|
|
|
final tileList = [...sidebarTileList, ...sidebarLibraryTileList];
|
|
|
|
final router = context.watchRouter;
|
|
|
|
final selectedIndex = tileList.indexWhere(
|
|
(e) => router.currentPath.startsWith(e.pathPrefix),
|
|
);
|
|
|
|
if (layoutMode == LayoutMode.compact ||
|
|
(mediaQuery.smAndDown && layoutMode == LayoutMode.adaptive)) {
|
|
return child;
|
|
}
|
|
|
|
final navigationButtons = [
|
|
NavigationLabel(
|
|
child: mediaQuery.lgAndUp ? const Text("Spotube") : const Text(""),
|
|
),
|
|
for (final tile in sidebarTileList)
|
|
NavigationButton(
|
|
label: mediaQuery.lgAndUp ? Text(tile.title) : null,
|
|
child: Tooltip(
|
|
tooltip: TooltipContainer(child: Text(tile.title)),
|
|
child: Icon(tile.icon),
|
|
),
|
|
onPressed: () {
|
|
context.navigateTo(tile.route);
|
|
},
|
|
),
|
|
const NavigationDivider(),
|
|
if (mediaQuery.lgAndUp)
|
|
NavigationLabel(child: Text(context.l10n.library)),
|
|
for (final tile in sidebarLibraryTileList)
|
|
NavigationButton(
|
|
label: mediaQuery.lgAndUp ? Text(tile.title) : null,
|
|
onPressed: () {
|
|
context.navigateTo(tile.route);
|
|
},
|
|
child: Tooltip(
|
|
tooltip: TooltipContainer(child: Text(tile.title)),
|
|
child: Icon(tile.icon),
|
|
),
|
|
),
|
|
];
|
|
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Expanded(
|
|
child: mediaQuery.lgAndUp
|
|
? NavigationSidebar(
|
|
index: selectedIndex,
|
|
onSelected: (index) {
|
|
final tile = tileList[index];
|
|
context.navigateTo(tile.route);
|
|
},
|
|
children: navigationButtons,
|
|
)
|
|
: NavigationRail(
|
|
alignment: NavigationRailAlignment.start,
|
|
index: selectedIndex,
|
|
onSelected: (index) {
|
|
final tile = tileList[index];
|
|
context.navigateTo(tile.route);
|
|
},
|
|
children: navigationButtons,
|
|
),
|
|
),
|
|
const SidebarFooter(),
|
|
if (mediaQuery.lgAndUp) const Gap(130) else const Gap(65),
|
|
],
|
|
),
|
|
const VerticalDivider(),
|
|
Expanded(child: child),
|
|
],
|
|
);
|
|
}
|
|
}
|