Reveal model settings on enable and align model row icons
This commit is contained in:
1 parent
94f24cf635
commit
e65b3982e2
9 files changed
+763
-83
No files matched your search
@@ -18,6 +18,7 @@ import '../widgets/language_picker_sheet.dart';
|
||||
import '../widgets/mesh_nav_tile.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/network_map_settings_section.dart';
|
||||
import '../widgets/settings_reveal.dart';
|
||||
import '../widgets/sync_progress_overlay.dart';
|
||||
import '../widgets/translation_settings_section.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
@@ -725,24 +726,27 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
if (settingsService.settings.imageMessagesEnabled) ...[
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
SettingsReveal(
|
||||
visible: settingsService.settings.imageMessagesEnabled,
|
||||
children: [
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.auto_awesome_outlined, size: 24),
|
||||
title: Text(context.l10n.imageMessages_autoProcessTitle),
|
||||
subtitle: Text(context.l10n.imageMessages_autoProcessSubtitle),
|
||||
value: settingsService.settings.imageProcessAutomatically,
|
||||
onChanged: (value) =>
|
||||
settingsService.setImageProcessAutomatically(value),
|
||||
),
|
||||
secondary: const Icon(Icons.auto_awesome_outlined, size: 24),
|
||||
title: Text(context.l10n.imageMessages_autoProcessTitle),
|
||||
subtitle: Text(context.l10n.imageMessages_autoProcessSubtitle),
|
||||
value: settingsService.settings.imageProcessAutomatically,
|
||||
onChanged: (value) =>
|
||||
settingsService.setImageProcessAutomatically(value),
|
||||
),
|
||||
if (_imageCodecService(context) != null) ...[
|
||||
const Divider(height: 1, indent: 16),
|
||||
const ImageCodecModelsSection(),
|
||||
if (_imageCodecService(context) != null) ...[
|
||||
const Divider(height: 1, indent: 16),
|
||||
const ImageCodecModelsSection(),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,9 @@ class _ImageCodecModelsSectionState extends State<ImageCodecModelsSection> {
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHighest,
|
||||
color: scheme.surfaceContainerLow,
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
border: Border.all(color: scheme.outlineVariant),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
||||
@@ -114,15 +114,11 @@ class _ModelDownloadRow extends StatelessWidget {
|
||||
padding:
|
||||
padding ??
|
||||
(actions.isEmpty
|
||||
? const EdgeInsets.fromLTRB(16, 8, 16, 8)
|
||||
: const EdgeInsets.fromLTRB(16, 8, 0, 8)),
|
||||
? const EdgeInsets.symmetric(horizontal: 16, vertical: 12)
|
||||
: const EdgeInsets.fromLTRB(16, 12, 4, 12)),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: _leading(scheme),
|
||||
),
|
||||
_leading(scheme),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -240,7 +236,7 @@ class _ModelDownloadRow extends StatelessWidget {
|
||||
);
|
||||
case ModelDownloadStatus.notDownloaded:
|
||||
return Icon(
|
||||
Icons.download_outlined,
|
||||
Icons.memory_outlined,
|
||||
size: 24,
|
||||
color: scheme.onSurfaceVariant,
|
||||
);
|
||||
@@ -256,6 +252,7 @@ class _ModelDownloadRow extends StatelessWidget {
|
||||
key: ValueKey('model-cancel-${item.id}'),
|
||||
tooltip: l10n.imageMessages_cancelDownload,
|
||||
onPressed: item.onCancel,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
];
|
||||
@@ -267,6 +264,7 @@ class _ModelDownloadRow extends StatelessWidget {
|
||||
key: ValueKey('model-download-${item.id}'),
|
||||
tooltip: l10n.imageMessages_downloadModel,
|
||||
onPressed: item.onDownload,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.download_outlined),
|
||||
),
|
||||
);
|
||||
@@ -277,6 +275,7 @@ class _ModelDownloadRow extends StatelessWidget {
|
||||
key: ValueKey('model-remove-${item.id}'),
|
||||
tooltip: l10n.imageMessages_removeModel,
|
||||
onPressed: item.onDelete,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Shows or hides [child] by animating its height.
|
||||
///
|
||||
/// Use this wherever turning something on reveals more controls, and for any
|
||||
/// other block that grows or collapses in place. Hidden controls are not in
|
||||
/// the tree, so they are not announced. The duration and curve are fixed so
|
||||
/// every reveal moves the same way. See documentation/design.md.
|
||||
class RevealOnEnable extends StatelessWidget {
|
||||
static const Duration duration = Duration(milliseconds: 200);
|
||||
static const Curve curve = Curves.easeInOut;
|
||||
|
||||
final bool visible;
|
||||
final Widget child;
|
||||
final AlignmentGeometry alignment;
|
||||
|
||||
const RevealOnEnable({
|
||||
super.key,
|
||||
required this.visible,
|
||||
required this.child,
|
||||
this.alignment = Alignment.topCenter,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedSize(
|
||||
duration: duration,
|
||||
curve: curve,
|
||||
alignment: alignment,
|
||||
child: visible
|
||||
? child
|
||||
: const SizedBox(width: double.infinity, height: 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Nested controls under a settings switch: the shared reveal animation on a
|
||||
/// tinted, indented panel.
|
||||
class SettingsReveal extends StatelessWidget {
|
||||
final bool visible;
|
||||
final List<Widget> children;
|
||||
|
||||
const SettingsReveal({
|
||||
super.key,
|
||||
required this.visible,
|
||||
required this.children,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RevealOnEnable(
|
||||
visible: visible,
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A settings slider whose selected value stays visible in the title.
|
||||
///
|
||||
/// The drag bubble repeats the same number. Pass a [title] that already
|
||||
/// includes [value], the way the channel-hop titles do, and an [icon] so the
|
||||
/// row aligns with neighbouring [SwitchListTile] and [MeshNavTile] rows.
|
||||
class SettingsValueSlider extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final int value;
|
||||
final int min;
|
||||
final int max;
|
||||
final ValueChanged<int> onChanged;
|
||||
|
||||
const SettingsValueSlider({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final clamped = value.clamp(min, max);
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
leading: Icon(icon, size: 24),
|
||||
title: Text(title),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (subtitle != null) Text(subtitle!),
|
||||
Slider(
|
||||
value: clamped.toDouble(),
|
||||
min: min.toDouble(),
|
||||
max: max.toDouble(),
|
||||
divisions: max > min ? max - min : null,
|
||||
label: '$clamped',
|
||||
onChanged: (next) => onChanged(next.round()),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import '../services/app_settings_service.dart';
|
||||
import '../services/translation_service.dart';
|
||||
import 'mesh_nav_tile.dart';
|
||||
import 'model_download_list.dart';
|
||||
import 'settings_reveal.dart';
|
||||
|
||||
/// [TranslationService] publishes this as `downloadFileName` while it merges
|
||||
/// downloaded chunks (see translation_service.dart). The service owns the
|
||||
@@ -43,59 +44,70 @@ class TranslationSettingsSection extends StatelessWidget {
|
||||
secondary: const Icon(Icons.translate, size: 24),
|
||||
title: Text(l10n.translation_enableTitle),
|
||||
subtitle: Text(l10n.translation_enableSubtitle),
|
||||
value: settings.translationEnabled,
|
||||
value: translationEnabled,
|
||||
onChanged: settingsService.setTranslationEnabled,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: tilePadding,
|
||||
secondary: Icon(
|
||||
Icons.auto_awesome_outlined,
|
||||
size: 24,
|
||||
color: disabledColor,
|
||||
),
|
||||
title: Text(
|
||||
l10n.translation_autoIncomingTitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
subtitle: Text(
|
||||
l10n.translation_autoIncomingSubtitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
value: settings.autoTranslateIncomingMessages,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setAutoTranslateIncomingMessages
|
||||
: null,
|
||||
SettingsReveal(
|
||||
visible: translationEnabled,
|
||||
children: [
|
||||
SwitchListTile(
|
||||
contentPadding: tilePadding,
|
||||
secondary: Icon(
|
||||
Icons.auto_awesome_outlined,
|
||||
size: 24,
|
||||
color: disabledColor,
|
||||
),
|
||||
title: Text(
|
||||
l10n.translation_autoIncomingTitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
subtitle: Text(
|
||||
l10n.translation_autoIncomingSubtitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
value: settings.autoTranslateIncomingMessages,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setAutoTranslateIncomingMessages
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: tilePadding,
|
||||
secondary: Icon(
|
||||
Icons.outgoing_mail,
|
||||
size: 24,
|
||||
color: disabledColor,
|
||||
),
|
||||
title: Text(
|
||||
l10n.translation_composerTitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
subtitle: Text(
|
||||
l10n.translation_composerSubtitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
value: settings.composerTranslationEnabled,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setComposerTranslationEnabled
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
MeshNavTile(
|
||||
icon: Icons.language,
|
||||
title: l10n.translation_targetLanguage,
|
||||
subtitle: _translationLanguageLabel(
|
||||
context,
|
||||
settings.translationTargetLanguageCode,
|
||||
),
|
||||
onTap: translationEnabled
|
||||
? () =>
|
||||
_showTranslationLanguageDialog(context, settingsService)
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
const _TranslationModels(),
|
||||
],
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: tilePadding,
|
||||
secondary: Icon(Icons.outgoing_mail, size: 24, color: disabledColor),
|
||||
title: Text(
|
||||
l10n.translation_composerTitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
subtitle: Text(
|
||||
l10n.translation_composerSubtitle,
|
||||
style: TextStyle(color: disabledColor),
|
||||
),
|
||||
value: settings.composerTranslationEnabled,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setComposerTranslationEnabled
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
MeshNavTile(
|
||||
icon: Icons.language,
|
||||
title: l10n.translation_targetLanguage,
|
||||
subtitle: _translationLanguageLabel(
|
||||
context,
|
||||
settings.translationTargetLanguageCode,
|
||||
),
|
||||
onTap: () => _showTranslationLanguageDialog(context, settingsService),
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
const _TranslationModels(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user