Add an interface size setting (0.5x to 2x)

Settings > Appearance > Interface size scales every dimension, text, icon
and dialog on this device. The app lays out in a smaller or larger viewport
and paints it scaled to the window, so hit testing and layout stay
consistent; the value is saved per device and applies when the slider is
released.
This commit is contained in:
2026-11-09 12:56:42 +00:00
parent 701fb98ef0
commit bb2adcc182
9 changed files with 402 additions and 3 deletions
@@ -0,0 +1,120 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/scale/ui_scale.dart';
import 'settings_group.dart';
import 'settings_theme.dart';
/// "Interface size": a 0.5×–2.0× slider for the whole app on this device.
/// The value previews beside the slider while dragging and applies when the
/// drag ends, so the slider does not resize under the pointer.
class SettingsScaleSection extends StatefulWidget {
const SettingsScaleSection({super.key, this.controller});
final UiScaleController? controller;
@override
State<SettingsScaleSection> createState() => _SettingsScaleSectionState();
}
class _SettingsScaleSectionState extends State<SettingsScaleSection> {
double? _draft;
UiScaleController get _controller =>
widget.controller ?? UiScaleController.instance;
void _apply(double value) {
setState(() => _draft = null);
_controller.setScale(value);
unawaited(_controller.save());
}
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: _controller,
builder: (context, _) {
final cupertino = usesCupertinoControls(context);
final value = _draft ?? _controller.scale;
final label = '${value.toStringAsFixed(1)}×';
final reset = _controller.scale == 1 && _draft == null
? null
: () {
setState(() => _draft = null);
unawaited(_controller.reset());
};
void drag(double next) => setState(() => _draft = next);
return SettingsGroup(
title: 'Interface size',
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Scales text, icons and spacing everywhere on this device. '
'Applies when you let go. Default 1.0×.',
),
if (_controller.saveFailed)
Text(
'Could not save; applies until reload.',
style: TextStyle(color: settingsErrorColor(context)),
),
],
),
children: [
SettingsGroupItem(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text(label, style: settingsTextStyle(context, title: true)),
cupertino
? CupertinoButton(
onPressed: reset,
child: const Text('Reset'),
)
: TextButton(
onPressed: reset,
child: const Text('Reset'),
),
],
),
Semantics(
label: 'Interface size',
child: cupertino
? CupertinoSlider(
key: const Key('settings-ui-scale'),
value: value,
min: minUiScale,
max: maxUiScale,
divisions: 15,
onChanged: drag,
onChangeEnd: _apply,
)
: Slider(
key: const Key('settings-ui-scale'),
value: value,
min: minUiScale,
max: maxUiScale,
divisions: 15,
label: label,
semanticFormatterCallback: (v) =>
'${v.toStringAsFixed(1)} times',
onChanged: drag,
onChangeEnd: _apply,
),
),
const Wrap(
alignment: WrapAlignment.spaceBetween,
children: [Text('0.5× · Smaller'), Text('2.0× · Larger')],
),
],
),
),
],
);
},
);
}
@@ -12,6 +12,7 @@ import 'settings_controller.dart';
import 'settings_controls.dart';
import 'settings_font_section.dart';
import 'settings_animation_section.dart';
import 'settings_scale_section.dart';
import '../../ui/motion/animation_speed.dart';
import '../../ui/theme/app_font_controller.dart';
import 'settings_group.dart';
@@ -6,6 +6,7 @@ extension _SettingsTopicPages on _SettingsScreenState {
return {
SettingsTopic.appearance: (_) => SettingsPageBody(
children: [
const SettingsScaleSection(),
SettingsAnimationSection(
controller:
widget.animationSpeed ?? AnimationSpeedController.instance,