Add Repeaters and Rooms settings for login and clock sync
Move login attempts and auto-fetch into the new section, and let a global clock-sync default be overridden per repeater. Co-authored-by: zjs81 <zjs81@users.noreply.github.com>
This commit is contained in:
53 files changed
+1533
-128
No files matched your search
@@ -83,6 +83,13 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
child: _settingsCard(_buildRoutingContent),
|
||||
),
|
||||
|
||||
// REPEATERS AND ROOMS
|
||||
SectionHeader(context.l10n.appSettings_repeatersAndRooms),
|
||||
MeshCard(
|
||||
padding: EdgeInsets.zero,
|
||||
child: _settingsCard(_buildRepeaterRoomContent),
|
||||
),
|
||||
|
||||
// IMAGE MESSAGES
|
||||
SectionHeader(context.l10n.appSettings_imageMessagesSection),
|
||||
MeshCard(
|
||||
@@ -428,20 +435,6 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
onChanged: settingsService.setJumpToOldestUnread,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.settings_remote_outlined, size: 24),
|
||||
title: Text(context.l10n.appSettings_autoFetchRepeaterSettings),
|
||||
subtitle: Text(
|
||||
context.l10n.appSettings_autoFetchRepeaterSettingsSubtitle,
|
||||
),
|
||||
value: settingsService.settings.autoFetchRepeaterSettings,
|
||||
onChanged: settingsService.setAutoFetchRepeaterSettings,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
@@ -520,15 +513,6 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
onChanged: settingsService.setFloodRetries,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SettingsValueSlider(
|
||||
title: l10n.appSettings_loginAttempts(settings.loginAttempts),
|
||||
subtitle: l10n.appSettings_loginAttemptsSubtitle,
|
||||
value: settings.loginAttempts,
|
||||
min: SendAttemptPlan.minLoginAttempts,
|
||||
max: SendAttemptPlan.maxLoginAttempts,
|
||||
onChanged: settingsService.setLoginAttempts,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
@@ -626,6 +610,83 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRepeaterRoomContent(
|
||||
BuildContext context,
|
||||
AppSettingsService settingsService,
|
||||
) {
|
||||
final settings = settingsService.settings;
|
||||
final l10n = context.l10n;
|
||||
return Column(
|
||||
children: [
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.schedule, size: 24),
|
||||
title: Text(l10n.appSettings_clockSyncAfterLogin),
|
||||
subtitle: Text(l10n.appSettings_clockSyncAfterLoginSubtitle),
|
||||
value: settings.clockSyncAfterLogin,
|
||||
onChanged: settingsService.setClockSyncAfterLogin,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.password, size: 24),
|
||||
title: Text(l10n.appSettings_loginPasswordAutofocus),
|
||||
subtitle: Text(l10n.appSettings_loginPasswordAutofocusSubtitle),
|
||||
value: settings.loginPasswordAutofocus,
|
||||
onChanged: settingsService.setLoginPasswordAutofocus,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SettingsValueSlider(
|
||||
title: l10n.appSettings_loginAttempts(settings.loginAttempts),
|
||||
subtitle: l10n.appSettings_loginAttemptsSubtitle,
|
||||
value: settings.loginAttempts,
|
||||
min: SendAttemptPlan.minLoginAttempts,
|
||||
max: SendAttemptPlan.maxLoginAttempts,
|
||||
onChanged: settingsService.setLoginAttempts,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.settings_remote_outlined, size: 24),
|
||||
title: Text(l10n.appSettings_autoFetchRepeaterSettings),
|
||||
subtitle: Text(l10n.appSettings_autoFetchRepeaterSettingsSubtitle),
|
||||
value: settings.autoFetchRepeaterSettings,
|
||||
onChanged: settingsService.setAutoFetchRepeaterSettings,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
leading: const Icon(Icons.restart_alt, size: 24),
|
||||
title: Text(l10n.appSettings_resetRepeaterRoomSettings),
|
||||
subtitle: Text(l10n.appSettings_resetRepeaterRoomSettingsSubtitle),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right, size: 18),
|
||||
onTap: () async {
|
||||
await settingsService.resetRepeaterRoomSettingsToDefault();
|
||||
if (context.mounted) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(l10n.appSettings_repeaterRoomSettingsReset),
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageMessagesContent(
|
||||
BuildContext context,
|
||||
AppSettingsService settingsService,
|
||||
|
||||
@@ -112,7 +112,8 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
int? _spreadingFactor;
|
||||
int? _codingRate;
|
||||
|
||||
bool _autoClockSyncAfterLogin = false;
|
||||
RepeaterClockSyncOverride _clockSyncOverride =
|
||||
RepeaterClockSyncOverride.followDefault;
|
||||
|
||||
// Identity keys
|
||||
final TextEditingController _prvKeyController = TextEditingController();
|
||||
@@ -527,13 +528,12 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
}
|
||||
});
|
||||
|
||||
final autoClockSync = await _storage
|
||||
.getRepeaterAutoClockSyncAfterLoginEnabled(
|
||||
widget.repeater.publicKeyHex,
|
||||
);
|
||||
final clockSync = await _storage.getRepeaterClockSyncOverride(
|
||||
widget.repeater.publicKeyHex,
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_autoClockSyncAfterLogin = autoClockSync;
|
||||
_clockSyncOverride = clockSync;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -953,7 +953,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
_buildSectionCard(
|
||||
l10n.repeater_features,
|
||||
RepeaterSettingSection.features,
|
||||
extra: [_buildClockSyncToggle()],
|
||||
extra: [_buildClockSyncChoice()],
|
||||
),
|
||||
_buildSectionCard(
|
||||
l10n.repeater_networkHealth,
|
||||
@@ -1366,22 +1366,59 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
];
|
||||
}
|
||||
|
||||
Widget _buildClockSyncToggle() {
|
||||
Widget _buildClockSyncChoice() {
|
||||
final l10n = context.l10n;
|
||||
return SwitchListTile(
|
||||
title: Text(l10n.repeater_clockSyncAfterLogin),
|
||||
subtitle: Text(l10n.repeater_clockSyncAfterLoginSubtitle),
|
||||
value: _autoClockSyncAfterLogin,
|
||||
onChanged: (value) async {
|
||||
setState(() {
|
||||
_autoClockSyncAfterLogin = value;
|
||||
});
|
||||
await _storage.setRepeaterAutoClockSyncAfterLoginEnabled(
|
||||
widget.repeater.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
},
|
||||
contentPadding: EdgeInsets.zero,
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
ButtonSegment<RepeaterClockSyncOverride> segment(
|
||||
RepeaterClockSyncOverride value,
|
||||
String label,
|
||||
) => ButtonSegment(value: value, label: MeshSegmentLabel(label));
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.repeater_clockSyncAfterLogin,
|
||||
style: textTheme.bodyLarge?.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
l10n.repeater_clockSyncAfterLoginSubtitle,
|
||||
style: textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SegmentedButton<RepeaterClockSyncOverride>(
|
||||
showSelectedIcon: false,
|
||||
style: const ButtonStyle(
|
||||
minimumSize: WidgetStatePropertyAll(Size.fromHeight(40)),
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
segments: [
|
||||
segment(
|
||||
RepeaterClockSyncOverride.followDefault,
|
||||
l10n.repeater_clockSyncDefault,
|
||||
),
|
||||
segment(RepeaterClockSyncOverride.on, l10n.repeater_clockSyncOn),
|
||||
segment(
|
||||
RepeaterClockSyncOverride.off,
|
||||
l10n.repeater_clockSyncOff,
|
||||
),
|
||||
],
|
||||
selected: {_clockSyncOverride},
|
||||
onSelectionChanged: (selected) async {
|
||||
final value = selected.first;
|
||||
setState(() => _clockSyncOverride = value);
|
||||
await _storage.setRepeaterClockSyncOverride(
|
||||
widget.repeater.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user