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.
104 lines
2.7 KiB
Dart
104 lines
2.7 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cutdex_ui/theme.dart';
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
|
|
Future<String?> askName(
|
|
BuildContext context, {
|
|
required String title,
|
|
required String label,
|
|
String? description,
|
|
String initialValue = '',
|
|
String? submitLabel,
|
|
}) => showAppDialog<String>(
|
|
context: context,
|
|
builder: (_) => _NameDialog(
|
|
title: title,
|
|
label: label,
|
|
description: description,
|
|
initialValue: initialValue,
|
|
submitLabel: submitLabel,
|
|
),
|
|
);
|
|
|
|
class _NameDialog extends StatefulWidget {
|
|
const _NameDialog({
|
|
required this.title,
|
|
required this.label,
|
|
this.description,
|
|
required this.initialValue,
|
|
this.submitLabel,
|
|
});
|
|
final String title;
|
|
final String label;
|
|
final String? description;
|
|
final String initialValue;
|
|
final String? submitLabel;
|
|
@override
|
|
State<_NameDialog> createState() => _NameDialogState();
|
|
}
|
|
|
|
class _NameDialogState extends State<_NameDialog> {
|
|
late final _controller = TextEditingController(text: widget.initialValue)
|
|
..selection = TextSelection(
|
|
baseOffset: 0,
|
|
extentOffset: widget.initialValue.length,
|
|
);
|
|
final _form = GlobalKey<FormState>();
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _submit() {
|
|
if (_form.currentState!.validate()) {
|
|
Navigator.pop(context, _controller.text.trim());
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => AppDialog(
|
|
title: widget.title,
|
|
description: widget.description,
|
|
width: 420,
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(context.l10n.cancel),
|
|
),
|
|
FilledButton(
|
|
onPressed: _submit,
|
|
child: Text(widget.submitLabel ?? context.l10n.create),
|
|
),
|
|
],
|
|
child: Builder(
|
|
builder: (dialogContext) => Form(
|
|
key: _form,
|
|
child: TextFormField(
|
|
controller: _controller,
|
|
style: AppTheme.inputTextStyle(dialogContext),
|
|
cursorHeight: AppTheme.inputCursorHeight(dialogContext),
|
|
autofocus: true,
|
|
maxLength: 80,
|
|
buildCounter: (
|
|
_, {
|
|
required currentLength,
|
|
required isFocused,
|
|
maxLength,
|
|
}) => null,
|
|
decoration: InputDecoration(hintText: widget.label),
|
|
validator: (value) => value == null || value.trim().isEmpty
|
|
? context.l10n.enterName
|
|
: RegExp(r'[/\\\x00-\x1F]').hasMatch(value) ||
|
|
['.', '..'].contains(value.trim())
|
|
? context.l10n.invalidName
|
|
: null,
|
|
onFieldSubmitted: (_) => _submit(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|