SimpleCloudNotifier/flutter/lib/pages/settings/settings_picker_screen.dart

44 lines
1.1 KiB
Dart
Raw Permalink Normal View History

2025-04-19 01:49:28 +02:00
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(),
),
],
),
);
}
}