Skip to content

Commit

Permalink
side bar
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jun 29, 2024
1 parent e740184 commit 03b5cd7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
12 changes: 6 additions & 6 deletions lib/classes/providers/desktop_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:provider/provider.dart';
class DesktopNavigator extends ChangeNotifier {
bool _sidePanelOpen = true;

Widget Function(BuildContext) _sidePanelRoute = (context) => const SessionsPanel();
Widget Function(BuildContext)? _sidePanelRoute = (context) => const SessionsPanel();

Widget Function(BuildContext)? _settingsPanelRoute;

Expand All @@ -28,9 +28,7 @@ class DesktopNavigator extends ChangeNotifier {
"/log": (context) => const LogPanel(),
};

bool get sidePanelOpen => _sidePanelOpen;

Widget Function(BuildContext) get sidePanelRoute => _sidePanelRoute;
Widget Function(BuildContext)? get sidePanelRoute => _sidePanelRoute;

Widget Function(BuildContext)? get settingsPanelRoute => _settingsPanelRoute;

Expand All @@ -42,11 +40,13 @@ class DesktopNavigator extends ChangeNotifier {
}

void navigateSidePanel(String route) {
_sidePanelOpen = true;
if (_sidePanelRoute != _sidePanelRoutes[route]) {
_sidePanelRoute = _sidePanelRoutes[route] ?? _sidePanelRoute;
notifyListeners();
}
else {
_sidePanelRoute = null;
}
notifyListeners();
}

void navigateSettingsPanel(String route) {
Expand Down
7 changes: 0 additions & 7 deletions lib/ui/desktop/layout/side_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ class SideBar extends StatelessWidget {
Widget buildTopButtons(BuildContext context) {
return Column(
children: [
IconButton(
tooltip: 'Toggle Side Panel',
icon: const Icon(Icons.view_sidebar_rounded),
onPressed: () {
DesktopNavigator.of(context).toggleSidePanel();
},
),
IconButton(
tooltip: 'Sessions',
icon: const Icon(Icons.chat_rounded),
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/desktop/navigators/side_panel_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _SidePanelNavigatorState extends State<SidePanelNavigator> {

Widget buildRoutes(BuildContext context, DesktopNavigator desktopNavigator, Widget? child) {
if (desktopNavigator.settingsPanelRoute == null) {
return desktopNavigator.sidePanelRoute(context);
return desktopNavigator.sidePanelRoute!(context);
}

return ResizableContainer(
Expand All @@ -47,11 +47,10 @@ class _SidePanelNavigatorState extends State<SidePanelNavigator> {
onHoverExit: onHoverExit,
),
children: [
if (desktopNavigator.sidePanelOpen)
ResizableChild(
size: const ResizableSize.ratio(0.7),
minSize: 500,
child: desktopNavigator.sidePanelRoute(context),
child: desktopNavigator.sidePanelRoute!(context),
),
ResizableChild(
size: const ResizableSize.ratio(0.3),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/desktop/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
Widget buildResizableContainer(BuildContext context) {
return Consumer<DesktopNavigator>(
builder: (context, desktopNavigator, child) {
if (!desktopNavigator.sidePanelOpen) {
if (desktopNavigator.sidePanelRoute == null) {
return buildHomePanel();
}

Expand Down
10 changes: 8 additions & 2 deletions lib/ui/shared/shaders/wave_gradient_shader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WaveGradientShader extends StatefulWidget {

class _WaveGradientShaderState extends State<WaveGradientShader> with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _curvedAnimation;

@override
void initState() {
Expand All @@ -27,6 +28,11 @@ class _WaveGradientShaderState extends State<WaveGradientShader> with SingleTick
duration: Duration(milliseconds: (3000 * widget.durationFactor).clamp(2000, 4000).toInt()),
vsync: this,
)..repeat();

_curvedAnimation = CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
);
}

@override
Expand All @@ -41,14 +47,14 @@ class _WaveGradientShaderState extends State<WaveGradientShader> with SingleTick
final wave = Theme.of(context).colorScheme.secondary;

return AnimatedBuilder(
animation: _controller,
animation: _curvedAnimation,
builder: (context, child) {
return ShaderMask(
shaderCallback: (bounds) {
return LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
stops: [0.0, _controller.value, 1.0],
stops: [0.0, _curvedAnimation.value, 1.0],
colors: [
boundary,
wave,
Expand Down

0 comments on commit 03b5cd7

Please sign in to comment.