Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
101 lines
2.7 KiB
Dart
101 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'window_caption_controls.dart';
|
|
|
|
import 'package:cutdex_native/cutdex_native.dart';
|
|
|
|
/// Shared native titlebar layout; a close callback opts into editor navigation.
|
|
class EditorWindowChrome extends StatefulWidget {
|
|
const EditorWindowChrome({
|
|
super.key,
|
|
required this.headerHeight,
|
|
this.onCloseRequested,
|
|
required this.builder,
|
|
});
|
|
|
|
static const trafficLightWidth = 88.0;
|
|
static bool get isWindows => WindowChromeSession.isWindows;
|
|
static double get leadingWidth => isWindows ? 0 : trafficLightWidth;
|
|
final double headerHeight;
|
|
final VoidCallback? onCloseRequested;
|
|
final Widget Function(BuildContext context, bool integrated) builder;
|
|
|
|
@override
|
|
State<EditorWindowChrome> createState() => _EditorWindowChromeState();
|
|
}
|
|
|
|
class _EditorWindowChromeState extends State<EditorWindowChrome> {
|
|
late final _session = WindowChromeSession(
|
|
headerHeight: widget.headerHeight,
|
|
onCloseRequested: widget.onCloseRequested,
|
|
);
|
|
bool _integrated = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_session.addListener(_integrationChanged);
|
|
_session.attach();
|
|
}
|
|
|
|
void _integrationChanged() {
|
|
if (_integrated != _session.integrated) {
|
|
setState(() => _integrated = _session.integrated);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
_session.setInteractive(ModalRoute.of(context)?.isCurrent ?? true);
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant EditorWindowChrome oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
_session.configure(
|
|
headerHeight: widget.headerHeight,
|
|
onCloseRequested: widget.onCloseRequested,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_session.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!_integrated || !EditorWindowChrome.isWindows) {
|
|
return widget.builder(context, _integrated);
|
|
}
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) => WindowHeaderLayout(
|
|
captionBounds: Rect.fromLTWH(
|
|
constraints.maxWidth - WindowCaptionControls.width,
|
|
0,
|
|
WindowCaptionControls.width,
|
|
widget.headerHeight,
|
|
),
|
|
child: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Builder(builder: (context) => widget.builder(context, true)),
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
width: WindowCaptionControls.width,
|
|
height: widget.headerHeight,
|
|
child: WindowCaptionControls(
|
|
session: _session,
|
|
height: widget.headerHeight,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|