loris/lib/pages/settings/app.dart

70 lines
1.8 KiB
Dart
Raw Normal View History

2022-08-10 16:47:34 +00:00
import 'package:localization/localization.dart';
import '../../business_logic/settings.dart' as settings;
import 'package:flutter/material.dart';
class AppSettings extends StatelessWidget {
const AppSettings({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
2022-08-10 18:49:51 +00:00
children: [
FutureBuilder<int>(
future: settings.loadBatchSize(),
builder: ((context, snapshot) {
if (snapshot.hasData) {
return PostBatchSlider(initialSize: snapshot.data ?? 5);
}
return const CircularProgressIndicator.adaptive();
})),
],
);
}
}
class PostBatchSlider extends StatefulWidget {
const PostBatchSlider({required this.initialSize, Key? key})
: super(key: key);
final int initialSize;
@override
State<PostBatchSlider> createState() => _PostBatchSliderState();
}
class _PostBatchSliderState extends State<PostBatchSlider> {
late int size;
@override
void initState() {
size = widget.initialSize;
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
2022-08-10 16:47:34 +00:00
children: [
Row(
children: [
Text("post-batch-size".i18n()),
Slider(
2022-08-10 18:49:51 +00:00
label: size.toString(),
value: size.toDouble(),
divisions: 19,
min: 5,
2022-08-10 16:47:34 +00:00
max: 100,
2022-08-10 18:49:51 +00:00
onChanged: ((value) {
settings.saveBatchSize(value.toInt());
setState(() {
size = value.toInt();
});
}),
2022-08-10 16:47:34 +00:00
)
],
2022-08-10 18:49:51 +00:00
),
SelectableText("post-batch-size-description".i18n()),
2022-08-10 16:47:34 +00:00
],
);
}
}