EditorSelector: Make it prettier

This commit is contained in:
Vishesh Handa
2020-03-30 13:36:07 +02:00
parent 564fa4cbc0
commit c2b78f0ae7

View File

@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/fa_icon.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gitjournal/screens/note_editor.dart'; import 'package:gitjournal/screens/note_editor.dart';
class NoteEditorSelector extends StatelessWidget { class NoteEditorSelector extends StatelessWidget {
@ -8,42 +10,60 @@ class NoteEditorSelector extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var onEditorChange = (EditorType et) => Navigator.of(context).pop(et); var list = Column(
children: <Widget>[
var children = <Widget>[ _buildTile(
// FIXME: Change this to ListTiles with nice icons context,
RadioListTile<EditorType>( EditorType.Markdown,
title: const Text("Markdown Editor"), "Markdown Editor",
value: EditorType.Markdown, FontAwesomeIcons.markdown,
groupValue: currentEditor, ),
onChanged: onEditorChange, _buildTile(
), context,
RadioListTile<EditorType>( EditorType.Raw,
title: const Text("Raw Editor"), "Raw Editor",
value: EditorType.Raw, FontAwesomeIcons.dna,
groupValue: currentEditor, ),
onChanged: onEditorChange, _buildTile(
), context,
RadioListTile<EditorType>( EditorType.Checklist,
title: const Text("Checklist Editor"), "Checklist Editor",
value: EditorType.Checklist, FontAwesomeIcons.tasks,
groupValue: currentEditor, ),
onChanged: onEditorChange, _buildTile(
), context,
RadioListTile<EditorType>( EditorType.Journal,
title: const Text("Journal Editor"), "Journal Editor",
value: EditorType.Journal, FontAwesomeIcons.book,
groupValue: currentEditor, ),
onChanged: onEditorChange, ],
), mainAxisSize: MainAxisSize.min,
]; );
return AlertDialog( return AlertDialog(
title: const Text("Choose Editor"), title: const Text("Choose Editor"),
content: Column( content: list,
children: children, );
mainAxisSize: MainAxisSize.min, }
),
ListTile _buildTile(
BuildContext context,
EditorType et,
String text,
IconData iconData,
) {
var selected = et == currentEditor;
var theme = Theme.of(context);
var listTileTheme = ListTileTheme.of(context);
var textStyle = theme.textTheme.body1.copyWith(
color: selected ? theme.primaryColor : listTileTheme.textColor,
);
return ListTile(
title: Text(text),
leading: FaIcon(iconData, color: textStyle.color),
onTap: () => Navigator.of(context).pop(et),
selected: selected,
); );
} }
} }