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,77 @@
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Paints the border outside the content clip, keeping both curves concentric.
|
||||
class WorkspaceCard extends StatefulWidget {
|
||||
const WorkspaceCard({super.key, required this.child});
|
||||
|
||||
static const radius = 12.0;
|
||||
static const borderWidth = 1.0;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<WorkspaceCard> createState() => _WorkspaceCardState();
|
||||
}
|
||||
|
||||
class _WorkspaceCardState extends State<WorkspaceCard> {
|
||||
late final ValueNotifier<Widget> _content;
|
||||
late final Widget _frame;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_content = ValueNotifier(widget.child);
|
||||
_frame = _WorkspaceCardFrame(
|
||||
child: ValueListenableBuilder<Widget>(
|
||||
valueListenable: _content,
|
||||
builder: (context, child, _) => child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant WorkspaceCard oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
_content.value = widget.child;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _frame;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_content.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// The frame subscribes only to theme changes; content has its own update slot.
|
||||
class _WorkspaceCardFrame extends StatelessWidget {
|
||||
const _WorkspaceCardFrame({required this.child});
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: surface,
|
||||
borderRadius: BorderRadius.circular(WorkspaceCard.radius),
|
||||
border: Border.all(
|
||||
color: AppTheme.sidebarDividerColor(context),
|
||||
width: WorkspaceCard.borderWidth,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(WorkspaceCard.borderWidth),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
WorkspaceCard.radius - WorkspaceCard.borderWidth,
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Material(color: surface, child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user