mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
ListPreference: Make the dialog a bit prettier
This commit is contained in:
@ -27,8 +27,8 @@ class ListPreference extends StatelessWidget {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
var children = <Widget>[];
|
var children = <Widget>[];
|
||||||
for (var o in options) {
|
for (var o in options) {
|
||||||
var tile = RadioListTile<String>(
|
var tile = LabeledRadio(
|
||||||
title: Text(o),
|
label: o,
|
||||||
value: o,
|
value: o,
|
||||||
groupValue: currentOption,
|
groupValue: currentOption,
|
||||||
onChanged: (String val) {
|
onChanged: (String val) {
|
||||||
@ -39,10 +39,9 @@ class ListPreference extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
content: SingleChildScrollView(
|
content: Column(
|
||||||
child: ListBody(
|
children: children,
|
||||||
children: children,
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -97,3 +96,36 @@ class ProListTile extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LabeledRadio extends StatelessWidget {
|
||||||
|
const LabeledRadio({
|
||||||
|
this.label,
|
||||||
|
this.groupValue,
|
||||||
|
this.value,
|
||||||
|
this.onChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String groupValue;
|
||||||
|
final String value;
|
||||||
|
final Function onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (value != groupValue) onChanged(value);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Radio<String>(
|
||||||
|
groupValue: groupValue,
|
||||||
|
value: value,
|
||||||
|
onChanged: onChanged,
|
||||||
|
),
|
||||||
|
Text(label),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user