Add leading icons to every settings row
This commit is contained in:
1 parent
1656486d77
commit
27cc332383
6 files changed
+382
-24
No files matched your search
@@ -97,6 +97,7 @@ Minimum sizes: no hard-coded `fontSize` below 12 exists in `lib/screens` or `lib
|
||||
| Section header | padding 16, 20, 16, 8 (LTRB) | `SectionHeader` |
|
||||
| Settings row | padding 16 / 12, 24px icon, 16 gap, chevron 24 | `MeshNavTile` |
|
||||
| Switch row | `SwitchListTile`, `contentPadding` 16 / 4, `secondary` icon size 24 | `app_settings_screen.dart` |
|
||||
| Slider row | `SettingsValueSlider` (`ListTile`), `contentPadding` 16 / 4, `leading` icon size 24, 16 gap | `settings_reveal.dart` |
|
||||
| Popup menu row | 20px icon, 12 gap | `MeshMenuItemRow` |
|
||||
| Banner | padding 16 / 12, 24px icon, 12 gap | `RadioDisconnectedBanner` |
|
||||
| Sheet header | padding 20, 8, 8, 4 (LTRB), 36×4 drag handle | `BottomSheetHeader` |
|
||||
@@ -105,6 +106,8 @@ Minimum sizes: no hard-coded `fontSize` below 12 exists in `lib/screens` or `lib
|
||||
| Avatar | 40 | `AvatarCircle` |
|
||||
| List bottom padding under a FAB | 88 | `channels_screen.dart` |
|
||||
|
||||
Every settings row — including sliders, selectors, and child rows revealed inside `SettingsReveal` — has a leading 24px icon with a 16px gap (`MeshNavTile`, `SwitchListTile.secondary`, or `ListTile.leading`) so titles align vertically across a card.
|
||||
|
||||
Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small action buttons, 18 for inline refresh icons and spinners. Keep tappable icons at 20 or more.
|
||||
|
||||
**Tap targets.** Keep Flutter's 48×48 minimum (the default `materialTapTargetSize` and `IconButton` size). Don't shrink with `VisualDensity.compact`, `MaterialTapTargetSize.shrinkWrap` or small `BoxConstraints` unless the control sits inside a larger tappable row.
|
||||
@@ -118,7 +121,7 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act
|
||||
| Settings navigation row | `MeshNavTile` | `onTap: null` dims it to 50 % and reports it as disabled; use `subtitle` to say why |
|
||||
| Settings switch | `SwitchListTile` inside `MeshSettingsTileTheme` | Wrap the settings screen body once in `MeshSettingsTileTheme` |
|
||||
| Switch that reveals more controls | `SettingsReveal` | 200ms height ease, `surfaceContainerHighest`, 16px start indent. See [Reveal on enable](#reveal-on-enable) |
|
||||
| Settings slider | `SettingsValueSlider` | The title includes the selected number, so it stays visible. The drag bubble repeats it |
|
||||
| Settings slider | `SettingsValueSlider` | Requires a 24px `icon` (`ListTile.leading`). The title includes the selected number, so it stays visible. The drag bubble repeats it |
|
||||
| Radio-style choice in a sheet | `MeshSheetOption` | Used by the language picker and map time filter |
|
||||
| Choosing between images | Selectable thumbnail tiles in a centred `Wrap` | Image send versions (`_versionTile` in `image_send_preview_sheet.dart`). `InkWell` with `MeshRadii.sm`; selected tile gets a 3px `primary` border **and** a `primary` check badge (never colour alone); caption under the tile in `bodySmall`, w600 when selected; figures such as packet counts in `MeshTheme.mono` 12; wrap the tile in `Semantics(button: true, selected:, label:)` |
|
||||
| Popup menu row | **always** `PopupMenuItem(child: MeshMenuItemRow(icon:, label:))` | Label wraps to 2 lines then ellipsizes; `leading:` for `ThemedIcon`; no icon keeps the 20px slot |
|
||||
@@ -157,7 +160,7 @@ The same animation without the tint is `RevealOnEnable`. Use it when the reveale
|
||||
|
||||
Do not add a second duration, and do not reveal the controls with a plain `if` that pops them in. A block that swaps between two bodies, such as the filtered-message preview, keeps `AnimatedSize` but uses `RevealOnEnable.duration` and `RevealOnEnable.curve`.
|
||||
|
||||
Sliders that belong to a setting use `SettingsValueSlider`. Put the selected number in the title (a localized string with the count). The slider's drag label repeats that number; it is not the only place the value appears.
|
||||
Sliders that belong to a setting use `SettingsValueSlider` with a 24px `icon` (`ListTile.leading`) so the title and slider line up with adjacent rows. Put the selected number in the title (a localized string with the count). The slider's drag label repeats that number; it is not the only place the value appears.
|
||||
|
||||
## 6. Sheets, dialogs and pages
|
||||
|
||||
|
||||
@@ -496,6 +496,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SettingsValueSlider(
|
||||
icon: Icons.route,
|
||||
title: l10n.appSettings_directRetries(settings.directRetries),
|
||||
subtitle: l10n.appSettings_directRetriesSubtitle,
|
||||
value: settings.directRetries,
|
||||
@@ -505,6 +506,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SettingsValueSlider(
|
||||
icon: Icons.waves,
|
||||
title: l10n.appSettings_floodRetries(settings.floodRetries),
|
||||
subtitle: l10n.appSettings_floodRetriesSubtitle,
|
||||
value: settings.floodRetries,
|
||||
@@ -551,6 +553,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
visible: settings.channelMinHopsEnabled,
|
||||
children: [
|
||||
SettingsValueSlider(
|
||||
icon: Icons.linear_scale,
|
||||
title: l10n.appSettings_channelMinHopsCount(
|
||||
settings.channelMinHops,
|
||||
),
|
||||
@@ -560,6 +563,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
onChanged: settingsService.setChannelMinHops,
|
||||
),
|
||||
SettingsValueSlider(
|
||||
icon: Icons.repeat,
|
||||
title: l10n.appSettings_channelMinHopsRetries(
|
||||
settings.channelMinHopsRetries,
|
||||
),
|
||||
@@ -643,6 +647,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SettingsValueSlider(
|
||||
icon: Icons.login,
|
||||
title: l10n.appSettings_loginAttempts(settings.loginAttempts),
|
||||
subtitle: l10n.appSettings_loginAttemptsSubtitle,
|
||||
value: settings.loginAttempts,
|
||||
@@ -721,15 +726,10 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
leading: const Icon(Icons.link_outlined, size: 20),
|
||||
title: Text(context.l10n.appSettings_ipfsImageLinks),
|
||||
subtitle: Text(context.l10n.appSettings_ipfsImageLinksSubtitle),
|
||||
trailing: const Icon(Icons.chevron_right, size: 18),
|
||||
MeshNavTile(
|
||||
icon: Icons.link_outlined,
|
||||
title: context.l10n.appSettings_ipfsImageLinks,
|
||||
subtitle: context.l10n.appSettings_ipfsImageLinksSubtitle,
|
||||
onTap: () => _showIpfsImageLinksDialog(context, settingsService),
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
@@ -983,7 +983,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
size: 24,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -1368,6 +1368,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
|
||||
Widget _buildClockSyncChoice() {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
ButtonSegment<RepeaterClockSyncOverride> segment(
|
||||
RepeaterClockSyncOverride value,
|
||||
@@ -1378,16 +1379,31 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
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,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.schedule, size: 24, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
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: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SegmentedButton<RepeaterClockSyncOverride>(
|
||||
|
||||
@@ -67,8 +67,10 @@ class SettingsReveal extends StatelessWidget {
|
||||
/// 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.
|
||||
/// 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;
|
||||
@@ -78,6 +80,7 @@ class SettingsValueSlider extends StatelessWidget {
|
||||
|
||||
const SettingsValueSlider({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.value,
|
||||
@@ -91,6 +94,7 @@ class SettingsValueSlider extends StatelessWidget {
|
||||
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,
|
||||
|
||||
@@ -233,7 +233,7 @@ class TranslationSettingsSection extends StatelessWidget {
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(MeshRadii.xs),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -5,12 +7,17 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||
import 'package:meshcore_open/models/contact.dart';
|
||||
import 'package:meshcore_open/models/send_attempt_plan.dart';
|
||||
import 'package:meshcore_open/screens/app_settings_screen.dart';
|
||||
import 'package:meshcore_open/screens/repeater_settings_screen.dart';
|
||||
import 'package:meshcore_open/services/app_settings_service.dart';
|
||||
import 'package:meshcore_open/services/network_map/network_map_upload_service.dart';
|
||||
import 'package:meshcore_open/services/storage_service.dart';
|
||||
import 'package:meshcore_open/services/translation_service.dart';
|
||||
import 'package:meshcore_open/storage/prefs_manager.dart';
|
||||
import 'package:meshcore_open/theme/mesh_theme.dart';
|
||||
import 'package:meshcore_open/widgets/mesh_ui.dart';
|
||||
import 'package:meshcore_open/widgets/settings_reveal.dart';
|
||||
|
||||
void main() {
|
||||
@@ -117,4 +124,332 @@ void main() {
|
||||
expect(find.text(l10n.appSettings_channelMinHopsCount(2)), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'routing and repeaters/rooms rows and clock-sync selector have leading 24px icons with aligned titles',
|
||||
(tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
PrefsManager.reset();
|
||||
await PrefsManager.initialize();
|
||||
final settings = AppSettingsService();
|
||||
await settings.loadSettings();
|
||||
await settings.updateSettings(
|
||||
settings.settings.copyWith(channelMinHopsEnabled: true),
|
||||
);
|
||||
|
||||
tester.view.physicalSize = const Size(800, 8000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final connector = MeshCoreConnector();
|
||||
final translation = TranslationService(settings);
|
||||
final uploads = NetworkMapUploadService(
|
||||
connector: connector,
|
||||
settings: settings,
|
||||
);
|
||||
addTearDown(connector.dispose);
|
||||
addTearDown(translation.dispose);
|
||||
addTearDown(uploads.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: settings),
|
||||
ChangeNotifierProvider.value(value: connector),
|
||||
ChangeNotifierProvider.value(value: translation),
|
||||
ChangeNotifierProvider.value(value: uploads),
|
||||
],
|
||||
child: MaterialApp(
|
||||
theme: MeshTheme.light(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const AppSettingsScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final context = tester.element(find.byType(AppSettingsScreen));
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
final topLevelTitles = [
|
||||
l10n.appSettings_clearPathOnMaxRetry,
|
||||
l10n.appSettings_directRetries(settings.settings.directRetries),
|
||||
l10n.appSettings_floodRetries(settings.settings.floodRetries),
|
||||
l10n.appSettings_autoRouteRotation,
|
||||
l10n.appSettings_channelMinHops,
|
||||
l10n.appSettings_resetRoutingToDefault,
|
||||
l10n.appSettings_clockSyncAfterLogin,
|
||||
l10n.appSettings_loginPasswordAutofocus,
|
||||
l10n.appSettings_loginAttempts(settings.settings.loginAttempts),
|
||||
l10n.appSettings_autoFetchRepeaterSettings,
|
||||
l10n.appSettings_resetRepeaterRoomSettings,
|
||||
];
|
||||
final revealedTitles = [
|
||||
l10n.appSettings_channelMinHopsCount(settings.settings.channelMinHops),
|
||||
l10n.appSettings_channelMinHopsRetries(
|
||||
settings.settings.channelMinHopsRetries,
|
||||
),
|
||||
l10n.appSettings_channelMinHopsCountRepeaters,
|
||||
];
|
||||
|
||||
double expectRowLeadingIcon(String title) {
|
||||
final titleFinder = find.text(title);
|
||||
expect(titleFinder, findsOneWidget, reason: 'Missing row "$title"');
|
||||
final tileFinder = find.ancestor(
|
||||
of: titleFinder,
|
||||
matching: find.byType(ListTile),
|
||||
);
|
||||
expect(tileFinder, findsOneWidget, reason: 'No ListTile for "$title"');
|
||||
final iconFinder = find.descendant(
|
||||
of: tileFinder,
|
||||
matching: find.byType(Icon),
|
||||
);
|
||||
final icons = tester.widgetList<Icon>(iconFinder).toList();
|
||||
final titleRect = tester.getRect(titleFinder);
|
||||
final leadingIcons = [
|
||||
for (var i = 0; i < icons.length; i++)
|
||||
if (tester.getRect(iconFinder.at(i)).right < titleRect.left)
|
||||
(icon: icons[i], rect: tester.getRect(iconFinder.at(i))),
|
||||
];
|
||||
expect(
|
||||
leadingIcons,
|
||||
hasLength(1),
|
||||
reason: 'Expected 1 leading icon for "$title"',
|
||||
);
|
||||
expect(
|
||||
leadingIcons.single.icon.size,
|
||||
24,
|
||||
reason: 'Leading icon for "$title" must be 24px',
|
||||
);
|
||||
expect(
|
||||
leadingIcons.single.rect.size,
|
||||
const Size(24, 24),
|
||||
reason: 'Rendered leading icon for "$title" must be 24x24',
|
||||
);
|
||||
return titleRect.left;
|
||||
}
|
||||
|
||||
final topTitleLefts = [
|
||||
for (final title in topLevelTitles) expectRowLeadingIcon(title),
|
||||
];
|
||||
for (final left in topTitleLefts) {
|
||||
expect(left, closeTo(topTitleLefts.first, 0.5));
|
||||
}
|
||||
|
||||
final revealedTitleLefts = [
|
||||
for (final title in revealedTitles) expectRowLeadingIcon(title),
|
||||
];
|
||||
for (final left in revealedTitleLefts) {
|
||||
expect(left, closeTo(topTitleLefts.first + 16, 0.5));
|
||||
}
|
||||
|
||||
// Check the Default / On / Off clock-sync selector on RepeaterSettingsScreen.
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: connector),
|
||||
ChangeNotifierProvider.value(value: settings),
|
||||
],
|
||||
child: MaterialApp(
|
||||
theme: MeshTheme.light(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: RepeaterSettingsScreen(
|
||||
repeater: Contact(
|
||||
publicKey: Uint8List(32),
|
||||
name: 'Repeater',
|
||||
type: 2,
|
||||
pathLength: 0,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime(2026),
|
||||
),
|
||||
password: 'x',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
final rContext = tester.element(find.byType(RepeaterSettingsScreen));
|
||||
final rL10n = AppLocalizations.of(rContext);
|
||||
final selectorTitle = find.text(rL10n.repeater_clockSyncAfterLogin);
|
||||
await tester.ensureVisible(selectorTitle);
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
find.byType(SegmentedButton<RepeaterClockSyncOverride>),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final label in [
|
||||
rL10n.repeater_clockSyncDefault,
|
||||
rL10n.repeater_clockSyncOn,
|
||||
rL10n.repeater_clockSyncOff,
|
||||
]) {
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(w) => w is MeshSegmentLabel && w.text == label,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
|
||||
final clockIconFinder = find.byIcon(Icons.schedule);
|
||||
expect(clockIconFinder, findsOneWidget);
|
||||
final clockIcon = tester.widget<Icon>(clockIconFinder);
|
||||
expect(clockIcon.size, 24);
|
||||
final clockIconRect = tester.getRect(clockIconFinder);
|
||||
final selectorTitleRect = tester.getRect(selectorTitle);
|
||||
expect(clockIconRect.size, const Size(24, 24));
|
||||
expect(selectorTitleRect.left - clockIconRect.right, closeTo(16, 0.5));
|
||||
},
|
||||
);
|
||||
|
||||
for (final scale in [1.3, 2.0]) {
|
||||
testWidgets(
|
||||
'routing, repeaters/rooms, and clock-sync selector fit 320dp at ${scale}x',
|
||||
(tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
PrefsManager.reset();
|
||||
await PrefsManager.initialize();
|
||||
final settings = AppSettingsService();
|
||||
await settings.loadSettings();
|
||||
await settings.updateSettings(
|
||||
settings.settings.copyWith(channelMinHopsEnabled: true),
|
||||
);
|
||||
|
||||
tester.view.physicalSize = const Size(320, 568);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final overflows = <String>[];
|
||||
final previous = FlutterError.onError;
|
||||
FlutterError.onError = (details) {
|
||||
final text = details.exceptionAsString();
|
||||
if (text.contains('overflowed')) {
|
||||
overflows.add(text.split('\n').first);
|
||||
} else {
|
||||
previous?.call(details);
|
||||
}
|
||||
};
|
||||
addTearDown(() => FlutterError.onError = previous);
|
||||
|
||||
final connector = MeshCoreConnector();
|
||||
final translation = TranslationService(settings);
|
||||
final uploads = NetworkMapUploadService(
|
||||
connector: connector,
|
||||
settings: settings,
|
||||
);
|
||||
addTearDown(connector.dispose);
|
||||
addTearDown(translation.dispose);
|
||||
addTearDown(uploads.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: settings),
|
||||
ChangeNotifierProvider.value(value: connector),
|
||||
ChangeNotifierProvider.value(value: translation),
|
||||
ChangeNotifierProvider.value(value: uploads),
|
||||
],
|
||||
child: MaterialApp(
|
||||
theme: MeshTheme.light(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
builder: (context, child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: child!,
|
||||
),
|
||||
home: const AppSettingsScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final context = tester.element(find.byType(AppSettingsScreen));
|
||||
final l10n = AppLocalizations.of(context);
|
||||
for (final label in [
|
||||
l10n.appSettings_clearPathOnMaxRetry,
|
||||
l10n.appSettings_directRetries(settings.settings.directRetries),
|
||||
l10n.appSettings_floodRetries(settings.settings.floodRetries),
|
||||
l10n.appSettings_channelMinHopsCount(
|
||||
settings.settings.channelMinHops,
|
||||
),
|
||||
l10n.appSettings_channelMinHopsRetries(
|
||||
settings.settings.channelMinHopsRetries,
|
||||
),
|
||||
l10n.appSettings_channelMinHopsCountRepeaters,
|
||||
l10n.appSettings_resetRoutingToDefault,
|
||||
l10n.appSettings_clockSyncAfterLogin,
|
||||
l10n.appSettings_loginPasswordAutofocus,
|
||||
l10n.appSettings_loginAttempts(settings.settings.loginAttempts),
|
||||
l10n.appSettings_autoFetchRepeaterSettings,
|
||||
l10n.appSettings_resetRepeaterRoomSettings,
|
||||
]) {
|
||||
await tester.scrollUntilVisible(
|
||||
find.text(label),
|
||||
200,
|
||||
scrollable: find.byType(Scrollable).first,
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(label), findsOneWidget);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: connector),
|
||||
ChangeNotifierProvider.value(value: settings),
|
||||
],
|
||||
child: MaterialApp(
|
||||
theme: MeshTheme.light(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
builder: (context, child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: child!,
|
||||
),
|
||||
home: RepeaterSettingsScreen(
|
||||
repeater: Contact(
|
||||
publicKey: Uint8List(32),
|
||||
name: 'Repeater',
|
||||
type: 2,
|
||||
pathLength: 0,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime(2026),
|
||||
),
|
||||
password: 'x',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
final rContext = tester.element(find.byType(RepeaterSettingsScreen));
|
||||
final rL10n = AppLocalizations.of(rContext);
|
||||
await tester.scrollUntilVisible(
|
||||
find.text(rL10n.repeater_clockSyncAfterLogin),
|
||||
200,
|
||||
scrollable: find.byType(Scrollable).first,
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(rL10n.repeater_clockSyncAfterLogin), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(w) =>
|
||||
w is MeshSegmentLabel &&
|
||||
w.text == rL10n.repeater_clockSyncDefault,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
FlutterError.onError = previous;
|
||||
expect(overflows, isEmpty, reason: overflows.join('\n'));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user