fix attempt to toggle enableExchange while desktop menu minimized

This commit is contained in:
sneurlax 2024-07-05 14:46:14 -05:00
parent 38defea3d1
commit a066f77639
2 changed files with 23 additions and 11 deletions

View file

@ -61,6 +61,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
late final DMIController torButtonController;
double _width = expandedWidth;
bool _isMinimized = false;
void updateSelectedMenuItem(DesktopMenuItemId idKey) {
widget.onSelectionWillChange?.call(idKey);
@ -81,24 +82,25 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
setState(() {
_width = expanded ? minimizedWidth : expandedWidth;
_isMinimized = !_isMinimized;
});
}
@override
void initState() {
controllers = [
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
DMIController(isMinimized: _isMinimized),
];
torButtonController = DMIController();
torButtonController = DMIController(isMinimized: _isMinimized);
super.initState();
}

View file

@ -24,6 +24,10 @@ import 'desktop_menu.dart';
class DMIController {
VoidCallback? toggle;
final bool isMinimized;
DMIController({required this.isMinimized});
void dispose() {
toggle = null;
}
@ -287,11 +291,17 @@ class _DesktopMenuItemState<T> extends ConsumerState<DesktopMenuItem<T>>
labelLength = widget.labelLength;
controller = widget.controller;
_iconOnly = controller?.isMinimized ?? false;
controller?.toggle = toggle;
animationController = AnimationController(
vsync: this,
duration: duration,
)..forward();
);
if (_iconOnly) {
animationController.reverse();
} else {
animationController.forward();
}
super.initState();
}