Implement settings
This commit is contained in:
43
flutter/lib/pages/settings/settings_picker_screen.dart
Normal file
43
flutter/lib/pages/settings/settings_picker_screen.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
|
||||
class SettingsPickerScreen<T> extends StatelessWidget {
|
||||
const SettingsPickerScreen({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.initialValue,
|
||||
required this.values,
|
||||
required this.onValueChanged,
|
||||
this.icons,
|
||||
}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
final T initialValue;
|
||||
final List<T> values;
|
||||
final void Function(T value) onValueChanged;
|
||||
final Widget Function(T v)? icons;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(title)),
|
||||
body: SettingsList(
|
||||
platform: PlatformUtils.detectPlatform(context),
|
||||
sections: [
|
||||
SettingsSection(
|
||||
tiles: values.map((e) {
|
||||
return SettingsTile(
|
||||
leading: icons != null ? icons!(e) : null,
|
||||
title: Text(e.toString()),
|
||||
onPressed: (_) {
|
||||
onValueChanged(e);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user