Merge branch 'feature/animation-speed'
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../ui/motion/animation_speed.dart';
|
||||
import 'settings_group.dart';
|
||||
import 'settings_theme.dart';
|
||||
|
||||
class SettingsAnimationSection extends StatelessWidget {
|
||||
const SettingsAnimationSection({super.key, required this.controller});
|
||||
final AnimationSpeedController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final speed = controller.speed;
|
||||
final label = '${speed.toStringAsFixed(1)}×';
|
||||
final reset = speed == 1 ? null : () => unawaited(controller.reset());
|
||||
return SettingsGroup(
|
||||
title: 'Animation speed',
|
||||
footer: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Text(
|
||||
'Saved on this device. Higher is faster. Default 1.0×. Respects reduced motion.',
|
||||
),
|
||||
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: 'Animation speed',
|
||||
child: cupertino
|
||||
? CupertinoSlider(
|
||||
value: speed,
|
||||
min: minAnimationSpeed,
|
||||
max: maxAnimationSpeed,
|
||||
divisions: 15,
|
||||
onChanged: controller.setSpeed,
|
||||
onChangeEnd: (_) => unawaited(controller.save()),
|
||||
)
|
||||
: Slider(
|
||||
value: speed,
|
||||
min: minAnimationSpeed,
|
||||
max: maxAnimationSpeed,
|
||||
divisions: 15,
|
||||
label: label,
|
||||
semanticFormatterCallback: (value) =>
|
||||
'${value.toStringAsFixed(1)} times',
|
||||
onChanged: controller.setSpeed,
|
||||
onChangeEnd: (_) => unawaited(controller.save()),
|
||||
),
|
||||
),
|
||||
const Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
children: [Text('0.5× · Slower'), Text('2.0× · Faster')],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import 'default_endpoint.dart';
|
||||
import 'settings_controller.dart';
|
||||
import 'settings_controls.dart';
|
||||
import 'settings_font_section.dart';
|
||||
import 'settings_animation_section.dart';
|
||||
import '../../ui/motion/animation_speed.dart';
|
||||
import '../../ui/theme/app_font_controller.dart';
|
||||
import 'settings_group.dart';
|
||||
import 'storage/settings_storage_section.dart';
|
||||
@@ -58,10 +60,12 @@ class SettingsScreen extends StatefulWidget {
|
||||
this.deliveryService,
|
||||
this.deliveryServiceController,
|
||||
this.fonts,
|
||||
this.animationSpeed,
|
||||
});
|
||||
|
||||
/// The device's interface font; defaults to the app's shared controller.
|
||||
final AppFontController? fonts;
|
||||
final AnimationSpeedController? animationSpeed;
|
||||
|
||||
/// Android background delivery; hidden when absent or unsupported.
|
||||
final NotificationServiceBridge? deliveryService;
|
||||
@@ -204,6 +208,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
),
|
||||
_single('Server', SettingsHealthSection(gateway: widget.client)),
|
||||
// A device-local choice: a browser and a phone keep their own.
|
||||
SettingsAnimationSection(
|
||||
controller:
|
||||
widget.animationSpeed ?? AnimationSpeedController.instance,
|
||||
),
|
||||
SettingsFontSection(
|
||||
controller: widget.fonts ?? AppFontController.instance,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user