mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +08:00
Settings: Move Editor Settings to their own screen
It just has the default settings right now, but we need to expose some settings in the Markdown Editor.
This commit is contained in:
46
lib/screens/settings_editors.dart
Normal file
46
lib/screens/settings_editors.dart
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gitjournal/settings.dart';
|
||||||
|
import 'package:gitjournal/screens/settings_widgets.dart';
|
||||||
|
|
||||||
|
class SettingsEditorsScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
SettingsEditorsScreenState createState() => SettingsEditorsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingsEditorsScreenState extends State<SettingsEditorsScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var settings = Settings.instance;
|
||||||
|
|
||||||
|
var body = Column(children: <Widget>[
|
||||||
|
ListPreference(
|
||||||
|
title: "Default Editor",
|
||||||
|
currentOption: settings.defaultEditor.toPublicString(),
|
||||||
|
options:
|
||||||
|
SettingsEditorType.options.map((f) => f.toPublicString()).toList(),
|
||||||
|
onChange: (String publicStr) {
|
||||||
|
var val = SettingsEditorType.fromPublicString(publicStr);
|
||||||
|
Settings.instance.defaultEditor = val;
|
||||||
|
Settings.instance.save();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Editor Settings'),
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||||
|
import 'package:gitjournal/screens/settings_editors.dart';
|
||||||
import 'package:gitjournal/settings.dart';
|
import 'package:gitjournal/settings.dart';
|
||||||
import 'package:gitjournal/state_container.dart';
|
import 'package:gitjournal/state_container.dart';
|
||||||
import 'package:gitjournal/utils.dart';
|
import 'package:gitjournal/utils.dart';
|
||||||
@ -168,17 +169,14 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
enabled: remoteGitConfigured,
|
enabled: remoteGitConfigured,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
SettingsHeader("Editor Settings"),
|
ListTile(
|
||||||
ListPreference(
|
title: const Text("Editor Settings"),
|
||||||
title: "Default Editor",
|
subtitle: const Text("Configure how different editors work"),
|
||||||
currentOption: settings.defaultEditor.toPublicString(),
|
onTap: () {
|
||||||
options:
|
var route = MaterialPageRoute(
|
||||||
SettingsEditorType.options.map((f) => f.toPublicString()).toList(),
|
builder: (context) => SettingsEditorsScreen(),
|
||||||
onChange: (String publicStr) {
|
);
|
||||||
var val = SettingsEditorType.fromPublicString(publicStr);
|
Navigator.of(context).push(route);
|
||||||
Settings.instance.defaultEditor = val;
|
|
||||||
Settings.instance.save();
|
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsHeader("Storage"),
|
SettingsHeader("Storage"),
|
||||||
|
Reference in New Issue
Block a user