2023-02-10 22:32:26 +00:00
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
|
|
|
|
part 'desktop_sidebar_view_model.g.dart';
|
|
|
|
|
|
|
|
enum SidebarItem {
|
2023-02-14 19:53:17 +00:00
|
|
|
dashboard,
|
|
|
|
support,
|
|
|
|
settings,
|
|
|
|
transactions;
|
2023-02-10 22:32:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class DesktopSidebarViewModel = DesktopSidebarViewModelBase with _$DesktopSidebarViewModel;
|
|
|
|
|
|
|
|
abstract class DesktopSidebarViewModelBase with Store {
|
|
|
|
DesktopSidebarViewModelBase();
|
|
|
|
|
|
|
|
@observable
|
|
|
|
SidebarItem currentPage = SidebarItem.dashboard;
|
|
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
void onPageChange(SidebarItem item) {
|
2023-02-14 19:53:17 +00:00
|
|
|
|
|
|
|
if(currentPage == item){
|
|
|
|
resetSidebar();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2023-02-10 22:32:26 +00:00
|
|
|
currentPage = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void resetSidebar() {
|
|
|
|
currentPage = SidebarItem.dashboard;
|
|
|
|
}
|
|
|
|
}
|