feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s

This commit is contained in:
lingjhf committed 2026-10-09 01:56:01 +08:00
1 parent aa5255d1e4
commit 2e0033ce2d
260 files changed
+43963 -5591

No files matched your search

+36 -20
View File
@@ -7,6 +7,7 @@ import '../../integrations/agent/agent_settings.dart';
import '../../integrations/agent/agent_models.dart';
import '../../l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
@@ -115,7 +116,10 @@ class _AgentSettingsPanelState extends ConsumerState<AgentSettingsPanel>
);
Widget _buildContent(BuildContext context) {
ref.watch(settingsOperationProvider('agent-save'));
ref.watch(
settingsOperationProvider('agent-save')
.select((value) => value.isLoading),
);
final settings = ref.watch(agentSettingsProvider);
return ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
@@ -144,12 +148,12 @@ class _AgentSettingsPanelState extends ConsumerState<AgentSettingsPanel>
: SettingsPageSection(
key: const Key('agent-provider-list'),
title: context.l10n.agentSettings,
icon: Icons.auto_awesome_outlined,
icon: AppIcons.assistant,
action: OutlinedButton.icon(
onPressed: settings.asData == null
? null
: () => _showProviderForm(true),
icon: const Icon(Icons.add),
icon: const Icon(AppIcons.add),
label: Text(context.l10n.agentAddProvider),
),
children: [
@@ -191,9 +195,9 @@ class _ProviderCard extends StatelessWidget {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final icon = switch (provider.apiType) {
'anthropicMessages' => Icons.auto_awesome_outlined,
'openAiResponses' => Icons.bolt_outlined,
_ => Icons.forum_outlined,
'anthropicMessages' => AppIcons.assistant,
'openAiResponses' => AppIcons.lightning,
_ => AppIcons.conversations,
};
return Container(
padding: EdgeInsets.zero,
@@ -231,7 +235,7 @@ class _ProviderCard extends StatelessWidget {
key: ValueKey('agent-provider-edit-${provider.id}'),
tooltip: context.l10n.agentEditProvider,
onPressed: onEdit,
icon: const Icon(Icons.edit_outlined, size: AppIconSize.header),
icon: const Icon(AppIcons.edit, size: AppIconSize.header),
),
const SizedBox(width: 8),
AppSwitch(
@@ -247,7 +251,7 @@ class _ProviderCard extends StatelessWidget {
}
TextStyle _providerInputStyle(BuildContext context) =>
Theme.of(context).textTheme.bodyMedium!;
AppTheme.inputTextStyle(context);
InputDecoration _providerInputDecoration(
BuildContext context, {
@@ -341,7 +345,7 @@ class _ProviderEditorState extends State<_ProviderEditor> {
TextButton.icon(
key: const Key('agent-provider-back'),
onPressed: widget.saving ? null : widget.onBack,
icon: const Icon(Icons.arrow_back, size: 16),
icon: const Icon(AppIcons.arrowBack, size: 16),
label: Text(context.l10n.agentBackToProviders),
),
],
@@ -363,10 +367,11 @@ class _ProviderEditorState extends State<_ProviderEditor> {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: const Key('agent-provider-name'),
controller: _name,
@@ -403,10 +408,11 @@ class _ProviderEditorState extends State<_ProviderEditor> {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: const Key('agent-provider-base-url'),
controller: _baseUrl,
@@ -434,10 +440,11 @@ class _ProviderEditorState extends State<_ProviderEditor> {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: const Key('agent-provider-api-key'),
controller: _apiKey,
@@ -495,7 +502,7 @@ class _ProviderEditorState extends State<_ProviderEditor> {
onPressed: () => setState(
() => _models = [..._models, _ModelControllers()],
),
icon: const Icon(Icons.add, size: AppIconSize.header),
icon: const Icon(AppIcons.add, size: AppIconSize.header),
label: Text(context.l10n.agentAddModel),
),
),
@@ -610,9 +617,12 @@ class _ModelFields extends StatelessWidget {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(_providerInputStyle(context)),
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: Key('agent-model-id-$index'),
controller: controllers.id,
decoration: _providerInputDecoration(
@@ -627,9 +637,12 @@ class _ModelFields extends StatelessWidget {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(_providerInputStyle(context)),
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: Key('agent-model-context-$index'),
controller: controllers.contextWindow,
keyboardType: TextInputType.number,
@@ -642,9 +655,12 @@ class _ModelFields extends StatelessWidget {
child: TextFormField(
style: _providerInputStyle(context),
textAlignVertical: TextAlignVertical.center,
cursorHeight: 18,
cursorHeight: AppTheme.inputCursorHeight(context),
cursorWidth: 1.5,
strutStyle: StrutStyle.fromTextStyle(_providerInputStyle(context)),
strutStyle: StrutStyle.fromTextStyle(
_providerInputStyle(context),
forceStrutHeight: true,
),
key: Key('agent-model-output-$index'),
controller: controllers.maxOutputTokens,
keyboardType: TextInputType.number,
@@ -678,7 +694,7 @@ class _ModelFields extends StatelessWidget {
),
tooltip: context.l10n.agentDeleteModel,
onPressed: canDelete ? onDelete : null,
icon: const Icon(Icons.delete_outline, size: AppIconSize.header),
icon: const Icon(AppIcons.delete, size: AppIconSize.header),
),
);
return LayoutBuilder(
@@ -33,3 +33,20 @@ class AppearanceSettings extends _$AppearanceSettings {
if (ref.mounted) state = AsyncData(appearance);
});
}
@Riverpod(keepAlive: true)
class PaletteSettings extends _$PaletteSettings {
final _writes = SettingsWriteQueue();
@override
Future<AppPalette> build() =>
ref.watch(paletteSettingsRepositoryProvider).load();
Future<void> setPalette(AppPalette palette) => _writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
await ref.read(paletteSettingsRepositoryProvider).save(palette);
if (ref.mounted) state = AsyncData(palette);
});
}
@@ -53,3 +53,47 @@ abstract class _$AppearanceSettings extends $AsyncNotifier<AppAppearance> {
return element.handleCreate(ref, build);
}
}
@ProviderFor(PaletteSettings)
final paletteSettingsProvider = PaletteSettingsProvider._();
final class PaletteSettingsProvider
extends $AsyncNotifierProvider<PaletteSettings, AppPalette> {
PaletteSettingsProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'paletteSettingsProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$paletteSettingsHash();
@$internal
@override
PaletteSettings create() => PaletteSettings();
}
String _$paletteSettingsHash() => r'95eecd4a35c8de3afbf6c94b1e13f282acb0f4ff';
abstract class _$PaletteSettings extends $AsyncNotifier<AppPalette> {
FutureOr<AppPalette> build();
@$mustCallSuper
@override
WhenComplete runBuild() {
final ref = this.ref as $Ref<AsyncValue<AppPalette>, AppPalette>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<AsyncValue<AppPalette>, AppPalette>,
AsyncValue<AppPalette>,
Object?,
Object?
>;
return element.handleCreate(ref, build);
}
}
+67 -47
View File
@@ -5,12 +5,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../integrations/editor_tools.dart';
import 'package:cutdex_ui/icons.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';
import '../../shared/widgets/error_notification_host.dart';
class McpSettingsPanel extends ConsumerStatefulWidget {
const McpSettingsPanel({super.key, this.workspace});
@@ -53,38 +55,42 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
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,
icon: AppIcons.terminal,
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),
),
),
Consumer(
builder: (context, ref, _) {
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 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(
@@ -95,6 +101,7 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
child: TextFormField(
style: AppTheme.inputTextStyle(context),
cursorHeight: AppTheme.inputCursorHeight(context),
textAlignVertical: TextAlignVertical.center,
initialValue: '${value.port}',
enabled: !value.enabled && !operation.isLoading,
keyboardType: TextInputType.number,
@@ -111,13 +118,13 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
label: context.l10n.accessToken,
child: IconButton(
tooltip: context.l10n.copyAccessToken,
icon: const Icon(Icons.copy_outlined),
icon: const Icon(AppIcons.copy),
onPressed: () async {
await Clipboard.setData(ClipboardData(text: value.token));
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.accessTokenCopied)),
);
ErrorNotificationHost.of(
context,
).showMessage(content: Text(context.l10n.accessTokenCopied));
}
},
),
@@ -128,22 +135,35 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
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
Consumer(
builder: (context, ref, _) {
final connection = ids == null
? null
: () => ref.invalidate(
editorMcpConnectionProvider(ids!.$1, ids.$2),
: ref.watch(editorMcpConnectionProvider(ids.$1, ids.$2));
if (value?.enabled != true || connection?.hasError != true) {
return const SizedBox.shrink();
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
context.l10n.mcpStartError(
context.l10n.errorMessage(connection!.error!),
),
child: Text(context.l10n.retryStart),
),
],
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,
+236 -101
View File
@@ -9,10 +9,12 @@ import '../../shared/layout/workspace_layout_metrics.dart';
import '../../workspace/persistence/project_location_directory.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'appearance_settings.dart';
import 'timeline_ruler_settings_field.dart';
import 'language_settings.dart';
import 'location_settings.dart';
import 'mcp_settings_panel.dart';
@@ -31,11 +33,13 @@ class SettingsContent extends ConsumerStatefulWidget {
this.initialTab = 0,
this.navigationRequest = 0,
this.cardLayout = false,
}) : assert(initialTab >= 0 && initialTab <= 2);
this.onBack,
}) : assert(initialTab >= 0 && initialTab <= 3);
final int initialTab;
final int navigationRequest;
final bool cardLayout;
final VoidCallback? onBack;
final (String, String)? workspace;
@@ -68,6 +72,14 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
);
}
Future<void> _setPalette(AppPalette palette) async {
await ref
.read(settingsOperationProvider('palette').notifier)
.run(
() => ref.read(paletteSettingsProvider.notifier).setPalette(palette),
);
}
Future<void> _setLanguage(AppLanguage language) async {
await ref
.read(settingsOperationProvider('language').notifier)
@@ -84,10 +96,6 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
);
Widget _buildContent(BuildContext context) {
final appearanceSave = ref.watch(settingsOperationProvider('appearance'));
final languageSave = ref.watch(settingsOperationProvider('language'));
final appearance = ref.watch(appearanceSettingsProvider);
final language = ref.watch(languageSettingsProvider);
return LayoutBuilder(
builder: (context, constraints) => Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -103,6 +111,7 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
_SettingsNavigation(
value: _tab,
compact: constraints.maxWidth < 600,
onBack: widget.onBack,
onChanged: (value) => setState(() => _tab = value),
),
),
@@ -113,11 +122,9 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
width: WorkspaceLayoutMetrics.desktopSpacing,
)
else
VerticalDivider(
key: const Key('settings-sidebar-divider'),
const VerticalDivider(
key: Key('settings-sidebar-divider'),
width: 1,
thickness: 1,
color: Theme.of(context).colorScheme.outlineVariant,
),
Expanded(
child: _surface(
@@ -136,86 +143,58 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
padding: _settingsContentPadding,
child: SettingsPageSection(
title: context.l10n.general,
icon: Icons.settings_outlined,
icon: AppIcons.settings,
children: [
AppField(
label: context.l10n.appearance,
orientation: AppFieldOrientation.horizontal,
error:
(appearanceSave.hasError
? context.l10n.saveAppearanceFailed
: null) ??
(appearance.hasError
? context.l10n.loadAppearanceFailed
: null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<AppAppearance>(
emptyLabel: context.l10n.noMatchingOptions,
controlHeight:
AppSettingsMetrics.controlHeight,
value:
appearance.asData?.value ??
AppAppearance.system,
label: context.l10n.theme,
options: [
AppSelectOption(
AppAppearance.system,
context.l10n.system,
),
AppSelectOption(
AppAppearance.penLight,
'Pen · ${context.l10n.light}',
),
AppSelectOption(
AppAppearance.penDark,
'Pen · ${context.l10n.dark}',
),
],
onChanged:
appearanceSave.isLoading ||
appearance.isLoading
? null
: _setMode,
),
),
),
AppField(
label: context.l10n.language,
orientation: AppFieldOrientation.horizontal,
error:
(languageSave.hasError
? context.l10n.saveLanguageFailed
: null) ??
(language.hasError
? context.l10n.loadLanguageFailed
: null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<AppLanguage>(
emptyLabel: context.l10n.noMatchingOptions,
controlHeight:
AppSettingsMetrics.controlHeight,
value:
language.asData?.value ??
AppLanguage.system,
Consumer(
builder: (context, ref, _) {
final language = ref.watch(
languageSettingsProvider,
);
final languageSave = ref.watch(
settingsOperationProvider('language'),
);
return AppField(
label: context.l10n.language,
options: [
for (final option in AppLanguage.values)
AppSelectOption(
option,
option == AppLanguage.system
? context.l10n.system
: option.nativeName,
),
],
onChanged:
languageSave.isLoading ||
language.isLoading
? null
: _setLanguage,
),
),
orientation: AppFieldOrientation.horizontal,
error:
(languageSave.hasError
? context.l10n.saveLanguageFailed
: null) ??
(language.hasError
? context.l10n.loadLanguageFailed
: null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<AppLanguage>(
emptyLabel:
context.l10n.noMatchingOptions,
controlHeight:
AppTheme.isDesktop(context)
? AppDesktopMetrics.button
: AppSettingsMetrics.controlHeight,
value:
language.asData?.value ??
AppLanguage.system,
label: context.l10n.language,
options: [
for (final option
in AppLanguage.values)
AppSelectOption(
option,
option == AppLanguage.system
? context.l10n.system
: option.nativeName,
),
],
onChanged:
languageSave.isLoading ||
language.isLoading
? null
: _setLanguage,
),
),
);
},
),
const _ProjectLocationField(),
const _ResourceLocationField(),
@@ -246,6 +225,136 @@ class _SettingsContentState extends ConsumerState<SettingsContent> {
),
),
),
ExcludeFocus(
excluding: _tab != 3,
child: TickerMode(
enabled: _tab == 3,
child: SingleChildScrollView(
primary: false,
padding: _settingsContentPadding,
child: SettingsPageSection(
title: context.l10n.appearance,
icon: AppIcons.appearance,
children: [
Consumer(
builder: (context, ref, _) {
final palette = ref.watch(
paletteSettingsProvider,
);
final paletteSave = ref.watch(
settingsOperationProvider('palette'),
);
return AppField(
label: context.l10n.colorPalette,
orientation: AppFieldOrientation.horizontal,
error:
(paletteSave.hasError
? context.l10n.saveAppearanceFailed
: null) ??
(palette.hasError
? context.l10n.loadAppearanceFailed
: null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<AppPalette>(
key: const Key(
'settings-color-palette',
),
emptyLabel:
context.l10n.noMatchingOptions,
controlHeight:
AppTheme.isDesktop(context)
? AppDesktopMetrics.button
: AppSettingsMetrics.controlHeight,
value:
palette.asData?.value ??
AppPalette.graphite,
label: context.l10n.colorPalette,
options: [
AppSelectOption(
AppPalette.graphite,
context.l10n.paletteGraphite,
),
AppSelectOption(
AppPalette.violet,
context.l10n.paletteViolet,
),
AppSelectOption(
AppPalette.teal,
context.l10n.paletteTeal,
),
],
onChanged:
paletteSave.isLoading ||
palette.isLoading
? null
: _setPalette,
),
),
);
},
),
Consumer(
builder: (context, ref, _) {
final appearance = ref.watch(
appearanceSettingsProvider,
);
final appearanceSave = ref.watch(
settingsOperationProvider('appearance'),
);
return AppField(
label: context.l10n.theme,
orientation: AppFieldOrientation.horizontal,
error:
(appearanceSave.hasError
? context.l10n.saveAppearanceFailed
: null) ??
(appearance.hasError
? context.l10n.loadAppearanceFailed
: null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<AppAppearance>(
emptyLabel:
context.l10n.noMatchingOptions,
controlHeight:
AppTheme.isDesktop(context)
? AppDesktopMetrics.button
: AppSettingsMetrics.controlHeight,
value:
appearance.asData?.value ??
AppAppearance.system,
label: context.l10n.theme,
options: [
AppSelectOption(
AppAppearance.system,
context.l10n.system,
),
AppSelectOption(
AppAppearance.penLight,
context.l10n.light,
),
AppSelectOption(
AppAppearance.penDark,
context.l10n.dark,
),
],
onChanged:
appearanceSave.isLoading ||
appearance.isLoading
? null
: _setMode,
),
),
);
},
),
const TimelineRulerSettingsField(),
],
),
),
),
),
],
),
),
@@ -262,20 +371,36 @@ class _SettingsNavigation extends StatelessWidget {
required this.value,
required this.compact,
required this.onChanged,
this.onBack,
});
final int value;
final bool compact;
final ValueChanged<int> onChanged;
final VoidCallback? onBack;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final entries = [
(context.l10n.general, Icons.settings_outlined),
(context.l10n.agentSettings, Icons.auto_awesome_outlined),
('MCP', Icons.terminal_outlined),
(0, context.l10n.general, AppIcons.settings),
(3, context.l10n.appearance, AppIcons.appearance),
(1, context.l10n.agentSettings, AppIcons.assistant),
(2, 'MCP', AppIcons.terminal),
];
final title = Text(
context.l10n.settings,
style: theme.textTheme.titleSmall?.copyWith(fontSize: 16),
maxLines: 1,
overflow: TextOverflow.ellipsis,
);
final back = IconButton(
key: const Key('settings-sidebar-back'),
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
onPressed: onBack,
style: AppTheme.projectTabActionStyle(context, size: 28),
icon: const Icon(AppIcons.arrowBack, size: 16),
);
return ColoredBox(
key: const Key('settings-sidebar'),
color: AppTheme.settingsSidebarBackground(context),
@@ -284,26 +409,36 @@ class _SettingsNavigation extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 20),
child: Text(
context.l10n.settings,
style: theme.textTheme.titleSmall?.copyWith(fontSize: 16),
),
child: onBack == null
? title
: compact
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [back, const SizedBox(height: 8), title],
)
: Row(
children: [
back,
const SizedBox(width: 8),
Expanded(child: title),
],
),
),
for (var index = 0; index < entries.length; index++)
Padding(
padding: const EdgeInsets.only(bottom: 1),
child: Semantics(
selected: value == index,
selected: value == entries[index].$1,
child: Tooltip(
message: entries[index].$1,
message: entries[index].$2,
child: TextButton(
key: ValueKey('settings-navigation-$index'),
onPressed: () => onChanged(index),
key: ValueKey('settings-navigation-${entries[index].$1}'),
onPressed: () => onChanged(entries[index].$1),
style: TextButton.styleFrom(
minimumSize: const Size(0, 30),
padding: const EdgeInsets.symmetric(horizontal: 8),
foregroundColor: theme.colorScheme.onSurface,
backgroundColor: value == index
backgroundColor: value == entries[index].$1
? theme.colorScheme.onSurface.withValues(alpha: .078)
: Colors.transparent,
shape: RoundedRectangleBorder(
@@ -314,12 +449,12 @@ class _SettingsNavigation extends StatelessWidget {
child: Row(
children: [
if (!compact) ...[
Icon(entries[index].$2, size: 16),
Icon(entries[index].$3, size: 16),
const SizedBox(width: 8),
],
Expanded(
child: Text(
entries[index].$1,
entries[index].$2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
+5 -1
View File
@@ -24,7 +24,11 @@ class SettingsDialog extends StatelessWidget {
height: math.min(704, math.max(520, viewport.height * .88)),
contentOnly: true,
scrollContent: false,
child: SettingsContent(workspace: workspace, initialTab: initialTab),
child: SettingsContent(
workspace: workspace,
initialTab: initialTab,
onBack: () => Navigator.of(context).pop(),
),
),
);
}
+1
View File
@@ -49,6 +49,7 @@ class SettingsPage extends ConsumerWidget {
final content = SettingsContent(
workspace: workspace,
initialTab: initialTab,
onBack: desktop ? back : null,
);
if (!desktop) {
return Scaffold(
@@ -0,0 +1,27 @@
import 'package:cutdex_sdk/timeline_ui.dart' show TimelineRulerTimecodeLayout;
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../persistence/settings/timeline_ruler_settings_repository.dart';
import '../../settings/settings_write_queue.dart';
export 'package:cutdex_sdk/timeline_ui.dart' show TimelineRulerTimecodeLayout;
part 'timeline_ruler_settings.g.dart';
@Riverpod(keepAlive: true)
class TimelineRulerSettings extends _$TimelineRulerSettings {
final _writes = SettingsWriteQueue();
@override
Future<TimelineRulerTimecodeLayout> build() =>
ref.watch(timelineRulerSettingsRepositoryProvider).load();
Future<void> setLayout(TimelineRulerTimecodeLayout layout) =>
_writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
await ref.read(timelineRulerSettingsRepositoryProvider).save(layout);
if (ref.mounted) state = AsyncData(layout);
});
}
@@ -0,0 +1,68 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'timeline_ruler_settings.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(TimelineRulerSettings)
final timelineRulerSettingsProvider = TimelineRulerSettingsProvider._();
final class TimelineRulerSettingsProvider
extends
$AsyncNotifierProvider<
TimelineRulerSettings,
TimelineRulerTimecodeLayout
> {
TimelineRulerSettingsProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'timelineRulerSettingsProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$timelineRulerSettingsHash();
@$internal
@override
TimelineRulerSettings create() => TimelineRulerSettings();
}
String _$timelineRulerSettingsHash() =>
r'26aef397f2aee8114b1d1229bb1c0b3f7a377f73';
abstract class _$TimelineRulerSettings
extends $AsyncNotifier<TimelineRulerTimecodeLayout> {
FutureOr<TimelineRulerTimecodeLayout> build();
@$mustCallSuper
@override
WhenComplete runBuild() {
final ref =
this.ref
as $Ref<
AsyncValue<TimelineRulerTimecodeLayout>,
TimelineRulerTimecodeLayout
>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<
AsyncValue<TimelineRulerTimecodeLayout>,
TimelineRulerTimecodeLayout
>,
AsyncValue<TimelineRulerTimecodeLayout>,
Object?,
Object?
>;
return element.handleCreate(ref, build);
}
}
@@ -0,0 +1,59 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../settings/settings_operation.dart';
import 'timeline_ruler_settings.dart';
class TimelineRulerSettingsField extends ConsumerWidget {
const TimelineRulerSettingsField({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
if (!AppTheme.isDesktop(context)) return const SizedBox.shrink();
final layout = ref.watch(timelineRulerSettingsProvider);
final save = ref.watch(settingsOperationProvider('timeline-ruler'));
return AppField(
label: context.l10n.timelineRulerStyle,
orientation: AppFieldOrientation.horizontal,
error:
(save.hasError ? context.l10n.saveAppearanceFailed : null) ??
(layout.hasError ? context.l10n.loadAppearanceFailed : null),
child: SizedBox(
width: AppSettingsMetrics.controlWidth,
child: AppSelect<TimelineRulerTimecodeLayout>(
key: const Key('settings-timeline-ruler-style'),
emptyLabel: context.l10n.noMatchingOptions,
controlHeight: AppDesktopMetrics.button,
value: layout.asData?.value ?? TimelineRulerTimecodeLayout.inline,
label: context.l10n.timelineRulerStyle,
options: [
AppSelectOption(
TimelineRulerTimecodeLayout.inline,
context.l10n.timelineRulerInline,
),
AppSelectOption(
TimelineRulerTimecodeLayout.centered,
context.l10n.timelineRulerCentered,
),
AppSelectOption(
TimelineRulerTimecodeLayout.overlay,
context.l10n.timelineRulerOverlay,
),
],
onChanged: layout.isLoading || save.isLoading
? null
: (value) => ref
.read(settingsOperationProvider('timeline-ruler').notifier)
.run(
() => ref
.read(timelineRulerSettingsProvider.notifier)
.setLayout(value),
),
),
),
);
}
}