Skip to content

Commit

Permalink
feat: curved navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Mar 10, 2023
1 parent b836495 commit 776edf8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
31 changes: 23 additions & 8 deletions lib/components/root/spotube_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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/hooks/use_breakpoints.dart';
import 'package:spotube/hooks/use_brightness_value.dart';
import 'package:spotube/provider/downloader_provider.dart';
import 'package:spotube/provider/user_preferences_provider.dart';

Expand All @@ -29,6 +31,11 @@ class SpotubeNavigationBar extends HookConsumerWidget {

final insideSelectedIndex = useState<int>(selectedIndex);

final buttonColor = useBrightnessValue(
Theme.of(context).colorScheme.inversePrimary,
Theme.of(context).colorScheme.primary.withOpacity(0.2),
);

useEffect(() {
insideSelectedIndex.value = selectedIndex;
return null;
Expand All @@ -37,12 +44,18 @@ class SpotubeNavigationBar extends HookConsumerWidget {
if (layoutMode == LayoutMode.extended ||
(breakpoint.isMoreThan(Breakpoints.sm) &&
layoutMode == LayoutMode.adaptive)) return const SizedBox();
return NavigationBar(
destinations: [

return CurvedNavigationBar(
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
buttonBackgroundColor: buttonColor,
color: Theme.of(context).colorScheme.background,
height: 50,
items: [
...navbarTileList.map(
(e) {
return NavigationDestination(
icon: Badge(
return MouseRegion(
cursor: SystemMouseCursors.click,
child: Badge(
backgroundColor: Theme.of(context).primaryColor,
isLabelVisible: e.title == "Library" && downloadCount > 0,
label: Text(
Expand All @@ -52,15 +65,17 @@ class SpotubeNavigationBar extends HookConsumerWidget {
fontSize: 10,
),
),
child: Icon(e.icon),
child: Icon(
e.icon,
color: Theme.of(context).colorScheme.primary,
),
),
label: e.title,
);
},
),
],
selectedIndex: insideSelectedIndex.value,
onDestinationSelected: (i) {
index: insideSelectedIndex.value,
onTap: (i) {
insideSelectedIndex.value = i;
if (navbarTileList[i].title == "Settings") {
Sidebar.goToSettings(context);
Expand Down
13 changes: 13 additions & 0 deletions lib/hooks/use_brightness_value.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

T useBrightnessValue<T>(
T lightValue,
T darkValue,
) {
final context = useContext();

return Theme.of(context).brightness == Brightness.light
? lightValue
: darkValue;
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.5"
curved_navigation_bar:
dependency: "direct main"
description:
name: curved_navigation_bar
sha256: ea6412d00c5d83501bbf1cf9d1ac2ff11a20fbaf910c103c95ace7de82910334
url: "https://pub.dev"
source: hosted
version: "1.0.3"
dart_style:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
url: https://github.com/ThexXTURBOXx/catcher
collection: ^1.15.0
cupertino_icons: ^1.0.5
curved_navigation_bar: ^1.0.3
dbus: ^0.7.8
file_picker: ^5.2.2
fl_query: ^1.0.0-alpha.0
Expand Down

0 comments on commit 776edf8

Please sign in to comment.