feat: initial Cutdex application
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.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,155 @@
|
||||
import 'package:cutdex/l10n/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../integrations/editor_tools.dart';
|
||||
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
|
||||
import '../../integrations/mcp/mcp_settings.dart';
|
||||
import 'settings_layout.dart';
|
||||
import '../../settings/settings_operation.dart';
|
||||
|
||||
class McpSettingsPanel extends ConsumerStatefulWidget {
|
||||
const McpSettingsPanel({super.key, this.workspace});
|
||||
final (String, String)? workspace;
|
||||
|
||||
@override
|
||||
ConsumerState<McpSettingsPanel> createState() => _McpSettingsPanelState();
|
||||
}
|
||||
|
||||
class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
|
||||
String? _port;
|
||||
String? _error;
|
||||
|
||||
Future<void> _toggle(bool enabled, McpSettingsValue settings) async {
|
||||
final port = int.tryParse(_port ?? '${settings.port}');
|
||||
if (enabled && (port == null || port < 1 || port > 65535)) {
|
||||
setState(() => _error = context.l10n.invalidPort);
|
||||
return;
|
||||
}
|
||||
setState(() => _error = null);
|
||||
await ref
|
||||
.read(settingsOperationProvider('mcp').notifier)
|
||||
.run(
|
||||
() => ref
|
||||
.read(mcpSettingsProvider.notifier)
|
||||
.saveSettings(enabled: enabled, port: enabled ? port : null),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Theme(
|
||||
data: AppTheme.settingsContentTheme(Theme.of(context)),
|
||||
child: Builder(builder: _buildContent),
|
||||
);
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
final operation = ref.watch(settingsOperationProvider('mcp'));
|
||||
final error =
|
||||
_error ?? (operation.hasError ? context.l10n.saveMcpFailed : null);
|
||||
final settings = ref.watch(mcpSettingsProvider);
|
||||
final value = settings.asData?.value;
|
||||
final ids = widget.workspace;
|
||||
final connection = ids == null
|
||||
? null
|
||||
: ref.watch(editorMcpConnectionProvider(ids.$1, ids.$2));
|
||||
final status = value?.enabled != true
|
||||
? context.l10n.disabled
|
||||
: ids == null
|
||||
? context.l10n.waitingForProject
|
||||
: connection!.hasError
|
||||
? context.l10n.startFailed
|
||||
: connection.isLoading
|
||||
? context.l10n.starting
|
||||
: context.l10n.running;
|
||||
return SettingsPageSection(
|
||||
title: 'MCP',
|
||||
icon: Icons.terminal_outlined,
|
||||
children: [
|
||||
AppField(
|
||||
label: context.l10n.mcpService,
|
||||
description: settings.isLoading
|
||||
? context.l10n.loadingSettings
|
||||
: status,
|
||||
orientation: AppFieldOrientation.horizontal,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: AppSwitch(
|
||||
semanticLabel: context.l10n.mcpService,
|
||||
value: value?.enabled ?? false,
|
||||
onChanged: value == null || operation.isLoading
|
||||
? null
|
||||
: (enabled) => _toggle(enabled, value),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (value != null) ...[
|
||||
AppField(
|
||||
orientation: AppFieldOrientation.horizontal,
|
||||
label: context.l10n.listenPort,
|
||||
child: SizedBox(
|
||||
width: AppSettingsMetrics.controlWidth,
|
||||
child: TextFormField(
|
||||
style: AppTheme.inputTextStyle(context),
|
||||
cursorHeight: AppTheme.inputCursorHeight(context),
|
||||
initialValue: '${value.port}',
|
||||
enabled: !value.enabled && !operation.isLoading,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
prefixText: '127.0.0.1 : ',
|
||||
),
|
||||
onChanged: (text) => _port = text,
|
||||
),
|
||||
),
|
||||
),
|
||||
AppField(
|
||||
orientation: AppFieldOrientation.horizontal,
|
||||
label: context.l10n.accessToken,
|
||||
child: IconButton(
|
||||
tooltip: context.l10n.copyAccessToken,
|
||||
icon: const Icon(Icons.copy_outlined),
|
||||
onPressed: () async {
|
||||
await Clipboard.setData(ClipboardData(text: value.token));
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.accessTokenCopied)),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
if (settings.hasError)
|
||||
TextButton(
|
||||
onPressed: () => ref.invalidate(mcpSettingsProvider),
|
||||
child: Text(context.l10n.loadMcpFailed),
|
||||
),
|
||||
if (value?.enabled == true && connection?.hasError == true) ...[
|
||||
Text(
|
||||
context.l10n.mcpStartError(
|
||||
context.l10n.errorMessage(connection!.error!),
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: operation.isLoading
|
||||
? null
|
||||
: () => ref.invalidate(
|
||||
editorMcpConnectionProvider(ids!.$1, ids.$2),
|
||||
),
|
||||
child: Text(context.l10n.retryStart),
|
||||
),
|
||||
],
|
||||
if (error != null)
|
||||
Text(
|
||||
error,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user