mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 01:45:55 +08:00
FontSize Dialog: Highlight the prev font size
This commit is contained in:
@ -136,12 +136,12 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
var fontSize = await showDialog<NoteFontSize>(
|
var fontSize = await showDialog<NoteFontSize>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => FontSizeSettingsDialog(),
|
builder: (context) => FontSizeSettingsDialog(settings.noteFontSize),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fontSize != null) {
|
if (fontSize != null) {
|
||||||
Settings.instance.noteFontSize = fontSize;
|
settings.noteFontSize = fontSize;
|
||||||
Settings.instance.save();
|
settings.save();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -268,12 +268,16 @@ class VersionNumberTileState extends State<VersionNumberTile> {
|
|||||||
|
|
||||||
class FontSizeSettingsDialog extends StatelessWidget {
|
class FontSizeSettingsDialog extends StatelessWidget {
|
||||||
final String title = "Font Size";
|
final String title = "Font Size";
|
||||||
|
final NoteFontSize prevSize;
|
||||||
|
|
||||||
|
FontSizeSettingsDialog(this.prevSize);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var sizes = <Widget>[];
|
var sizes = <Widget>[];
|
||||||
for (var fontSize in NoteFontSize.options) {
|
for (var fontSize in NoteFontSize.options) {
|
||||||
var tile = _constructTile(context, fontSize);
|
var highlight = fontSize == prevSize;
|
||||||
|
var tile = _constructTile(context, fontSize, highlight);
|
||||||
sizes.add(tile);
|
sizes.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,15 +291,27 @@ class FontSizeSettingsDialog extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTile _constructTile(BuildContext context, NoteFontSize fontSize) {
|
Widget _constructTile(
|
||||||
|
BuildContext context,
|
||||||
|
NoteFontSize fontSize,
|
||||||
|
bool highlight,
|
||||||
|
) {
|
||||||
var style = Theme.of(context).textTheme.body1;
|
var style = Theme.of(context).textTheme.body1;
|
||||||
style = style.copyWith(fontSize: fontSize.toDouble());
|
style = style.copyWith(fontSize: fontSize.toDouble());
|
||||||
|
|
||||||
return ListTile(
|
var tile = ListTile(
|
||||||
title: Text(fontSize.toPublicString(), style: style),
|
title: Text(fontSize.toPublicString(), style: style),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pop(fontSize);
|
Navigator.of(context).pop(fontSize);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
if (!highlight) {
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
color: Theme.of(context).highlightColor,
|
||||||
|
child: tile,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user