refactor(desktop): reorganize workspace panels and navigation
This commit is contained in:
1 parent
826745b407
commit
1f73765745
92 files changed
+5811
-2650
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
enum DesktopContent { workspace, library, settings }
|
||||
|
||||
typedef DesktopContentSelection = ({
|
||||
DesktopContent surface,
|
||||
int settingsTab,
|
||||
int settingsRequest,
|
||||
(String, String)? workspace,
|
||||
bool settingsVisited,
|
||||
bool resourcesSelected,
|
||||
});
|
||||
|
||||
final desktopContentProvider =
|
||||
NotifierProvider<DesktopContentController, DesktopContentSelection>(
|
||||
DesktopContentController.new,
|
||||
);
|
||||
|
||||
/// Navigation changes visibility without disposing any visited content.
|
||||
class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||
@override
|
||||
DesktopContentSelection build() => (
|
||||
surface: DesktopContent.workspace,
|
||||
settingsTab: 0,
|
||||
settingsRequest: 0,
|
||||
workspace: null,
|
||||
settingsVisited: false,
|
||||
resourcesSelected: false,
|
||||
);
|
||||
|
||||
void select(DesktopContent surface) {
|
||||
state = (
|
||||
surface: surface,
|
||||
settingsTab: state.settingsTab,
|
||||
settingsRequest: state.settingsRequest,
|
||||
workspace: state.workspace,
|
||||
settingsVisited:
|
||||
state.settingsVisited || surface == DesktopContent.settings,
|
||||
resourcesSelected: surface == DesktopContent.library,
|
||||
);
|
||||
}
|
||||
|
||||
void showSettings({int? tab, (String, String)? workspace}) {
|
||||
state = (
|
||||
surface: DesktopContent.settings,
|
||||
settingsTab: tab ?? state.settingsTab,
|
||||
settingsRequest: state.settingsRequest + (tab == null ? 0 : 1),
|
||||
workspace: workspace ?? state.workspace,
|
||||
settingsVisited: true,
|
||||
resourcesSelected: state.resourcesSelected,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user