a7c41063fa
Keep the Material-only settings implementation and its focused tests while preserving public cupertino parameters for later cleanup. This removes unreachable platform-specific widgets and test variants without changing the Material path.
86 lines
2.9 KiB
Dart
86 lines
2.9 KiB
Dart
import 'dart:async';
|
||
import 'package:flutter/material.dart';
|
||
import '../../ui/motion/animation_speed.dart';
|
||
import '../../ui/motion/quick_switch_animation.dart';
|
||
import 'settings_quick_switch_control.dart';
|
||
import 'settings_group.dart';
|
||
import 'settings_theme.dart';
|
||
|
||
class SettingsAnimationSection extends StatelessWidget {
|
||
const SettingsAnimationSection({
|
||
super.key,
|
||
required this.controller,
|
||
this.quickSwitchController,
|
||
});
|
||
final AnimationSpeedController controller;
|
||
final QuickSwitchAnimationController? quickSwitchController;
|
||
|
||
@override
|
||
Widget build(BuildContext context) => ListenableBuilder(
|
||
listenable: controller,
|
||
builder: (context, _) {
|
||
final speed = controller.speed;
|
||
final label = '${speed.toStringAsFixed(1)}×';
|
||
final reset = speed == 1 ? null : () => unawaited(controller.reset());
|
||
return SettingsGroup(
|
||
title: 'Animations',
|
||
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)),
|
||
TextButton(onPressed: reset, child: const Text('Reset')),
|
||
],
|
||
),
|
||
Semantics(
|
||
label: 'Animation speed',
|
||
child: 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')],
|
||
),
|
||
],
|
||
),
|
||
),
|
||
SettingsGroupItem(
|
||
child: SettingsQuickSwitchControl(
|
||
controller:
|
||
quickSwitchController ??
|
||
QuickSwitchAnimationController.instance,
|
||
),
|
||
),
|
||
],
|
||
);
|
||
},
|
||
);
|
||
}
|