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,163 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../integrations/platform/editor_window_chrome.dart';
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||
import '../../workspace/workspace_mode.dart';
|
||||
|
||||
/// Keeps window chrome outside the shared workspace surface.
|
||||
class DesktopWindowFrame extends StatelessWidget {
|
||||
const DesktopWindowFrame({
|
||||
super.key,
|
||||
required this.integratedTitlebar,
|
||||
required this.headerControls,
|
||||
required this.librarySelected,
|
||||
this.settingsSelected = false,
|
||||
required this.onModeChanged,
|
||||
required this.onLibraryPressed,
|
||||
required this.onSettingsPressed,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
static const railWidth = 44.0;
|
||||
static const railButtonSize = 32.0;
|
||||
static const railIconSize = 22.0;
|
||||
static const headerHeight = 40.0;
|
||||
static const contentInset = WorkspaceLayoutMetrics.desktopSpacing;
|
||||
final bool integratedTitlebar;
|
||||
final Widget headerControls;
|
||||
final bool librarySelected;
|
||||
final bool settingsSelected;
|
||||
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||
final VoidCallback? onLibraryPressed;
|
||||
final VoidCallback onSettingsPressed;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('desktop-window-header'),
|
||||
height: headerHeight,
|
||||
child: WindowHeaderPadding(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
if (integratedTitlebar)
|
||||
SizedBox(
|
||||
key: const Key('native-window-controls-space'),
|
||||
width: EditorWindowChrome.leadingWidth,
|
||||
height: headerHeight,
|
||||
),
|
||||
headerControls,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const Key('desktop-navigation-rail'),
|
||||
width: railWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
for (final library in [false, true])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: IconButton.filledTonal(
|
||||
key: ValueKey(
|
||||
library
|
||||
? 'desktop-rail-library'
|
||||
: 'desktop-rail-cut',
|
||||
),
|
||||
tooltip: library
|
||||
? context.l10n.navigationLibrary
|
||||
: context.l10n.navigationChat,
|
||||
isSelected:
|
||||
!settingsSelected && library == librarySelected,
|
||||
style: IconButton.styleFrom(
|
||||
fixedSize: const Size.square(railButtonSize),
|
||||
minimumSize: const Size.square(railButtonSize),
|
||||
maximumSize: const Size.square(railButtonSize),
|
||||
padding: EdgeInsets.zero,
|
||||
iconSize: railIconSize,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
backgroundColor:
|
||||
!settingsSelected &&
|
||||
library == librarySelected
|
||||
? null
|
||||
: Colors.transparent,
|
||||
),
|
||||
onPressed: library
|
||||
? onLibraryPressed
|
||||
: () => onModeChanged(WorkspaceMode.cut),
|
||||
icon: Icon(
|
||||
library
|
||||
? Icons.video_library_outlined
|
||||
: Icons.chat_bubble_outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
key: const Key('project-settings-button'),
|
||||
tooltip: context.l10n.settings,
|
||||
isSelected: settingsSelected,
|
||||
onPressed: onSettingsPressed,
|
||||
style: IconButton.styleFrom(
|
||||
fixedSize: const Size.square(railButtonSize),
|
||||
minimumSize: const Size.square(railButtonSize),
|
||||
maximumSize: const Size.square(railButtonSize),
|
||||
padding: EdgeInsets.zero,
|
||||
iconSize: railIconSize,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
icon: const Icon(Icons.settings_outlined),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: contentInset,
|
||||
bottom: contentInset,
|
||||
),
|
||||
child: SizedBox(
|
||||
key: const Key('desktop-content-container'),
|
||||
child: WindowHeaderPane(
|
||||
offset: const Offset(railWidth, headerHeight),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
constraints.maxWidth < 200
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
height: constraints.maxHeight,
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user