mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
Allow backlinks preview to be disabled from the settings
This adds a new Experimental Settings page.
This commit is contained in:
@ -47,6 +47,10 @@ settings:
|
||||
title: Example Title
|
||||
privacy: Privacy Policy
|
||||
terms: Terms and Conditions
|
||||
experimental:
|
||||
title: Experimental Features
|
||||
subtitle: Try out features in Development
|
||||
backlinks: Show Backlinks in Markdown Preview
|
||||
|
||||
editors:
|
||||
checklist:
|
||||
|
45
lib/screens/settings_experimental.dart
Normal file
45
lib/screens/settings_experimental.dart
Normal file
@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
|
||||
class ExperimentalSettingsScreen extends StatefulWidget {
|
||||
@override
|
||||
_ExperimentalSettingsScreenState createState() =>
|
||||
_ExperimentalSettingsScreenState();
|
||||
}
|
||||
|
||||
class _ExperimentalSettingsScreenState
|
||||
extends State<ExperimentalSettingsScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settings = Settings.instance;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr('settings.experimental.title')),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Scrollbar(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.experimental.backlinks')),
|
||||
value: settings.experimentalBacklinks,
|
||||
onChanged: (bool newVal) {
|
||||
settings.experimentalBacklinks = newVal;
|
||||
settings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.fromLTRB(0.0, 16.0, 0.0, 0.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/screens/debug_screen.dart';
|
||||
import 'package:gitjournal/screens/settings_editors.dart';
|
||||
import 'package:gitjournal/screens/settings_experimental.dart';
|
||||
import 'package:gitjournal/screens/settings_images.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/state_container.dart';
|
||||
@ -270,6 +271,17 @@ class SettingsListState extends State<SettingsList> {
|
||||
Navigator.of(context).push(route);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(tr('settings.experimental.title')),
|
||||
subtitle: Text(tr('settings.experimental.subtitle')),
|
||||
onTap: () {
|
||||
var route = MaterialPageRoute(
|
||||
builder: (context) => ExperimentalSettingsScreen(),
|
||||
settings: const RouteSettings(name: '/settings/experimental'),
|
||||
);
|
||||
Navigator.of(context).push(route);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(tr('settings.privacy')),
|
||||
onTap: () {
|
||||
|
@ -49,6 +49,8 @@ class Settings {
|
||||
String imageLocationSpec = "."; // . means the same folder
|
||||
String debugLogLevel = 'v';
|
||||
|
||||
bool experimentalBacklinks = true;
|
||||
|
||||
void load(SharedPreferences pref) {
|
||||
gitAuthor = pref.getString("gitAuthor") ?? gitAuthor;
|
||||
gitAuthorEmail = pref.getString("gitAuthorEmail") ?? gitAuthorEmail;
|
||||
@ -102,6 +104,8 @@ class Settings {
|
||||
pref.getString("imageLocationSpec") ?? imageLocationSpec;
|
||||
|
||||
debugLogLevel = pref.getString("debugLogLevel") ?? debugLogLevel;
|
||||
experimentalBacklinks =
|
||||
pref.getBool("experimentalBacklinks") ?? experimentalBacklinks;
|
||||
}
|
||||
|
||||
Future save() async {
|
||||
@ -159,6 +163,8 @@ class Settings {
|
||||
_setString(pref, "imageLocationSpec", imageLocationSpec,
|
||||
defaultSet.imageLocationSpec);
|
||||
_setString(pref, "debugLogLevel", debugLogLevel, defaultSet.debugLogLevel);
|
||||
_setBool(pref, "experimentalBacklinks", experimentalBacklinks,
|
||||
defaultSet.experimentalBacklinks);
|
||||
|
||||
pref.setInt("settingsVersion", version);
|
||||
|
||||
@ -219,6 +225,7 @@ class Settings {
|
||||
'homeScreen': homeScreen.toInternalString(),
|
||||
'imageLocationSpec': imageLocationSpec,
|
||||
'debugLogLevel': debugLogLevel,
|
||||
'experimentalBacklinks': experimentalBacklinks.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:gitjournal/folder_views/common.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
import 'package:gitjournal/widgets/editor_scroll_view.dart';
|
||||
@ -79,7 +80,8 @@ class NoteViewer extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
NoteBacklinkRenderer(note: note, rootFolder: rootFolder),
|
||||
if (Settings.instance.experimentalBacklinks)
|
||||
NoteBacklinkRenderer(note: note, rootFolder: rootFolder),
|
||||
// _buildFooter(context),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
Reference in New Issue
Block a user