import 'dart:async'; import 'package:flutter/material.dart'; import '../../ui/motion/quick_switch_animation.dart'; import 'settings_theme.dart'; import 'quick_switch_preview.dart'; class SettingsQuickSwitchControl extends StatelessWidget { const SettingsQuickSwitchControl({super.key, required this.controller}); final QuickSwitchAnimationController controller; @override Widget build(BuildContext context) => ListenableBuilder( listenable: controller, builder: (context, _) => Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( 'Quick switch animation', style: settingsTextStyle(context, title: true), ), DropdownButton( value: controller.value, isExpanded: true, items: [ for (final animation in QuickSwitchAnimation.values) DropdownMenuItem(value: animation, child: Text(animation.label)), ], onChanged: (value) { if (value != null) unawaited(controller.setAnimation(value)); }, ), Text(controller.value.description), const SizedBox(height: 8), QuickSwitchPreview(animation: controller.value), if (controller.saveFailed) Text( 'Could not save; applies until reload.', style: TextStyle(color: settingsErrorColor(context)), ), ], ), ); }