2019-09-19 16:01:30 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/theme.dart';
|
|
|
|
import 'package:git_touch/widgets/table_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class PickerItem<T> {
|
|
|
|
final T value;
|
|
|
|
final String text;
|
|
|
|
PickerItem(this.value, {@required this.text});
|
|
|
|
}
|
|
|
|
|
|
|
|
class PickerGroupItem<T> {
|
|
|
|
final String title;
|
|
|
|
final T value;
|
|
|
|
final Iterable<PickerItem<T>> items;
|
|
|
|
final Function(T value) onChange;
|
|
|
|
PickerGroupItem({
|
|
|
|
@required this.title,
|
|
|
|
@required this.value,
|
|
|
|
@required this.items,
|
|
|
|
@required this.onChange,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
class PickerGroup extends StatelessWidget {
|
|
|
|
final Iterable<PickerGroupItem<String>> items;
|
|
|
|
|
|
|
|
PickerGroup({@required this.items});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-09-23 11:08:51 +02:00
|
|
|
var themeProvider = Provider.of<ThemeModel>(context);
|
|
|
|
switch (themeProvider.theme) {
|
2019-09-19 16:01:30 +02:00
|
|
|
case AppThemeType.cupertino:
|
|
|
|
default:
|
|
|
|
// TODO: Material
|
|
|
|
return TableView(
|
|
|
|
items: items.map((item) {
|
|
|
|
return TableViewItem(
|
|
|
|
text: Text(item.title),
|
|
|
|
rightWidget: Text(item.value),
|
|
|
|
onTap: () {
|
2019-09-23 11:08:51 +02:00
|
|
|
themeProvider.showPicker(context, item);
|
2019-09-19 16:01:30 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|