Improve slider inactive track contrast inside SettingsReveal panels
This commit is contained in:
1 parent
84c0b97710
commit
816dc92f2b
4 files changed
+175
-5
No files matched your search
@@ -164,7 +164,7 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act
|
|||||||
|
|
||||||
### Reveal on enable
|
### Reveal on enable
|
||||||
|
|
||||||
A switch that uncovers more controls uses `SettingsReveal` (`lib/widgets/settings_reveal.dart`). The block's height eases over 200ms (`RevealOnEnable.duration`, `Curves.easeInOut`, aligned to the top). While the switch is off the extra controls are not in the tree, so they are not announced. The panel uses `surfaceContainerHighest` and a 16px start indent.
|
A switch that uncovers more controls uses `SettingsReveal` (`lib/widgets/settings_reveal.dart`). The block's height eases over 200ms (`RevealOnEnable.duration`, `Curves.easeInOut`, aligned to the top). While the switch is off the extra controls are not in the tree, so they are not announced. The panel uses `surfaceContainerHighest` and a 16px start indent. Because the panel already sits on `surfaceContainerHighest`, controls and inset notices inside it must contrast against `surfaceContainerHighest` as well as `surfaceContainerLow` (`MeshTheme`'s slider inactive track and value indicator step away from `surfaceContainerHighest`, and inset notice boxes inside `SettingsReveal` use `surfaceContainerLow` with an `outlineVariant` border).
|
||||||
|
|
||||||
The same animation without the tint is `RevealOnEnable`. Use it when the revealed control is not a settings sub-panel: the Bluetooth-off banner on the scanner and the device-info rows on the Settings screen.
|
The same animation without the tint is `RevealOnEnable`. Use it when the revealed control is not a settings sub-panel: the Bluetooth-off banner on the scanner and the device-info rows on the Settings screen.
|
||||||
|
|
||||||
|
|||||||
@@ -823,8 +823,9 @@ class AppSettingsScreen extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: scheme.surfaceContainerHighest,
|
color: scheme.surfaceContainerLow,
|
||||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||||
|
border: Border.all(color: scheme.outlineVariant),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
reason,
|
reason,
|
||||||
|
|||||||
@@ -403,6 +403,25 @@ class MeshTheme {
|
|||||||
fontFamilyFallback: MeshFonts.sansFallback,
|
fontFamilyFallback: MeshFonts.sansFallback,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// SettingsReveal uses surfaceContainerHighest, so inactive slider tracks and
|
||||||
|
// drag bubbles need a distinct step toward onSurfaceVariant / inverseSurface
|
||||||
|
// to stay legible inside both MeshCard and SettingsReveal.
|
||||||
|
final sliderInactiveTrack = Color.lerp(
|
||||||
|
scheme.surfaceContainerHighest,
|
||||||
|
scheme.onSurfaceVariant,
|
||||||
|
brightness == Brightness.dark ? 0.42 : 0.54,
|
||||||
|
)!;
|
||||||
|
final sliderInactiveTick = Color.lerp(
|
||||||
|
sliderInactiveTrack,
|
||||||
|
scheme.onSurface,
|
||||||
|
0.7,
|
||||||
|
)!;
|
||||||
|
final sliderActiveTick = Color.lerp(
|
||||||
|
scheme.primary,
|
||||||
|
scheme.onPrimary,
|
||||||
|
0.65,
|
||||||
|
)!;
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
extensions: [bubble, icons, map],
|
extensions: [bubble, icons, map],
|
||||||
@@ -649,14 +668,19 @@ class MeshTheme {
|
|||||||
),
|
),
|
||||||
sliderTheme: SliderThemeData(
|
sliderTheme: SliderThemeData(
|
||||||
activeTrackColor: scheme.primary,
|
activeTrackColor: scheme.primary,
|
||||||
inactiveTrackColor: scheme.surfaceContainerHighest,
|
inactiveTrackColor: sliderInactiveTrack,
|
||||||
|
disabledActiveTrackColor: scheme.onSurface.withValues(alpha: 0.38),
|
||||||
|
disabledInactiveTrackColor: sliderInactiveTrack.withValues(alpha: 0.38),
|
||||||
|
activeTickMarkColor: sliderActiveTick,
|
||||||
|
inactiveTickMarkColor: sliderInactiveTick,
|
||||||
thumbColor: scheme.primary,
|
thumbColor: scheme.primary,
|
||||||
|
disabledThumbColor: scheme.onSurface.withValues(alpha: 0.38),
|
||||||
overlayColor: scheme.primary.withValues(alpha: 0.12),
|
overlayColor: scheme.primary.withValues(alpha: 0.12),
|
||||||
valueIndicatorColor: scheme.surfaceContainerHighest,
|
valueIndicatorColor: scheme.inverseSurface,
|
||||||
valueIndicatorTextStyle: TextStyle(
|
valueIndicatorTextStyle: TextStyle(
|
||||||
fontFamily: MeshFonts.mono,
|
fontFamily: MeshFonts.mono,
|
||||||
fontFamilyFallback: MeshFonts.monoFallback,
|
fontFamilyFallback: MeshFonts.monoFallback,
|
||||||
color: scheme.onSurface,
|
color: scheme.onInverseSurface,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
trackHeight: 3,
|
trackHeight: 3,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||||
import 'package:meshcore_open/models/contact.dart';
|
import 'package:meshcore_open/models/contact.dart';
|
||||||
|
import 'package:meshcore_open/models/custom_theme.dart';
|
||||||
import 'package:meshcore_open/models/send_attempt_plan.dart';
|
import 'package:meshcore_open/models/send_attempt_plan.dart';
|
||||||
import 'package:meshcore_open/screens/app_settings_screen.dart';
|
import 'package:meshcore_open/screens/app_settings_screen.dart';
|
||||||
import 'package:meshcore_open/screens/repeater_settings_screen.dart';
|
import 'package:meshcore_open/screens/repeater_settings_screen.dart';
|
||||||
@@ -452,4 +453,148 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (final entry in <(String, ThemeData)>[
|
||||||
|
('light', MeshTheme.light()),
|
||||||
|
('dark', MeshTheme.dark()),
|
||||||
|
for (final preset in [
|
||||||
|
...CustomTheme.presets,
|
||||||
|
...CustomTheme.holidayPresets,
|
||||||
|
])
|
||||||
|
('custom:${preset.name}', MeshTheme.fromCustom(preset)),
|
||||||
|
]) {
|
||||||
|
testWidgets(
|
||||||
|
'slider inactive track, tick marks, and drag bubble contrast inside SettingsReveal and MeshCard (${entry.$1})',
|
||||||
|
(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: entry.$2,
|
||||||
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
supportedLocales: AppLocalizations.supportedLocales,
|
||||||
|
home: const AppSettingsScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final screenContext = tester.element(find.byType(AppSettingsScreen));
|
||||||
|
final l10n = AppLocalizations.of(screenContext);
|
||||||
|
final scheme = entry.$2.colorScheme;
|
||||||
|
|
||||||
|
final revealFinder = find.byType(SettingsReveal).first;
|
||||||
|
final revealMaterial = tester.widget<Material>(
|
||||||
|
find
|
||||||
|
.descendant(of: revealFinder, matching: find.byType(Material))
|
||||||
|
.first,
|
||||||
|
);
|
||||||
|
final revealBg = revealMaterial.color!;
|
||||||
|
expect(revealBg, scheme.surfaceContainerHighest);
|
||||||
|
|
||||||
|
final directRowFinder = find.ancestor(
|
||||||
|
of: find.text(
|
||||||
|
l10n.appSettings_directRetries(settings.settings.directRetries),
|
||||||
|
),
|
||||||
|
matching: find.byType(SettingsValueSlider),
|
||||||
|
);
|
||||||
|
final directCardMaterial = tester.widget<Material>(
|
||||||
|
find
|
||||||
|
.ancestor(of: directRowFinder, matching: find.byType(Material))
|
||||||
|
.first,
|
||||||
|
);
|
||||||
|
final cardBg = directCardMaterial.color!;
|
||||||
|
expect(cardBg, scheme.surfaceContainerLow);
|
||||||
|
|
||||||
|
final hopsRowFinder = find.ancestor(
|
||||||
|
of: find.text(
|
||||||
|
l10n.appSettings_channelMinHopsCount(
|
||||||
|
settings.settings.channelMinHops,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
matching: find.byType(SettingsValueSlider),
|
||||||
|
);
|
||||||
|
final revealedSliderFinder = find.descendant(
|
||||||
|
of: hopsRowFinder,
|
||||||
|
matching: find.byType(Slider),
|
||||||
|
);
|
||||||
|
final directSliderFinder = find.descendant(
|
||||||
|
of: directRowFinder,
|
||||||
|
matching: find.byType(Slider),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (final sliderFinder in [revealedSliderFinder, directSliderFinder]) {
|
||||||
|
final sliderContext = tester.element(sliderFinder);
|
||||||
|
final sliderTheme = SliderTheme.of(sliderContext);
|
||||||
|
final inactiveTrack = sliderTheme.inactiveTrackColor!;
|
||||||
|
final inactiveTick = sliderTheme.inactiveTickMarkColor!;
|
||||||
|
final activeTick = sliderTheme.activeTickMarkColor!;
|
||||||
|
final valueIndicator = sliderTheme.valueIndicatorColor!;
|
||||||
|
|
||||||
|
expect(inactiveTrack.a, 1.0);
|
||||||
|
expect(inactiveTrack, isNot(revealBg));
|
||||||
|
expect(inactiveTrack, isNot(cardBg));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(inactiveTrack, revealBg),
|
||||||
|
greaterThanOrEqualTo(2.1),
|
||||||
|
reason: 'Inactive track must stand out on SettingsReveal',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(inactiveTrack, cardBg),
|
||||||
|
greaterThanOrEqualTo(2.5),
|
||||||
|
reason: 'Inactive track must stand out on MeshCard',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(inactiveTick, inactiveTrack),
|
||||||
|
greaterThanOrEqualTo(2.5),
|
||||||
|
reason: 'Inactive tick marks must stand out on inactive track',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(activeTick, sliderTheme.activeTrackColor!),
|
||||||
|
greaterThanOrEqualTo(1.8),
|
||||||
|
reason: 'Active tick marks must stand out on active track',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(valueIndicator, revealBg),
|
||||||
|
greaterThanOrEqualTo(3.0),
|
||||||
|
reason: 'Drag bubble must stand out on SettingsReveal',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
meshContrastRatio(valueIndicator, cardBg),
|
||||||
|
greaterThanOrEqualTo(3.0),
|
||||||
|
reason: 'Drag bubble must stand out on MeshCard',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user