Allow the bottom menu bar to be hidden

Fixes #261

The settings page for this is quite ugly right now, but the feature
works. I can improve its look another time.
This commit is contained in:
Vishesh Handa
2020-10-05 12:25:57 +02:00
parent cca83ffd4a
commit 62bea50506
6 changed files with 107 additions and 6 deletions

View File

@ -136,6 +136,10 @@ settings:
fileName: Filename fileName: Filename
drawer: drawer:
title: Sidebar Settings title: Sidebar Settings
bottomMenuBar:
title: Bottom Menu Bar
subtitle: Configure its appearance and behaviour
enable: Enable Buttom Menu Bar
editors: editors:
checklist: checklist:
@ -391,6 +395,7 @@ feature:
subtitle: Allow GitJournal to be translated subtitle: Allow GitJournal to be translated
inlineTags: Inline Tags inlineTags: Inline Tags
singleJournalEntry: Single Journal Entry File per day singleJournalEntry: Single Journal Entry File per day
configureBottomMenuBar: Configure the Bottom Menu Bar
feature_timeline: feature_timeline:
title: Feature Timeline title: Feature Timeline

View File

@ -39,6 +39,7 @@ class Features {
Feature.localization, Feature.localization,
Feature.inlineTags, Feature.inlineTags,
Feature.singleJournalEntry, Feature.singleJournalEntry,
Feature.configureBottomMenuBar,
]; ];
static final inProgress = <String>[ static final inProgress = <String>[
@ -337,6 +338,14 @@ class Feature {
"", "",
true, true,
); );
static final configureBottomMenuBar = Feature(
"configureBottomMenuBar",
DateTime(2020, 10, 05),
tr("feature.configureBottomMenuBar"),
"",
true,
);
} }
// Feature Adding checklist // Feature Adding checklist

View File

@ -109,11 +109,16 @@ class _FolderViewState extends State<FolderView> {
}, },
); );
var settings = Provider.of<Settings>(context);
final showButtomMenuBar = settings.bottomMenuBar;
// So the FAB doesn't hide parts of the last entry // So the FAB doesn't hide parts of the last entry
folderView = Padding( if (!showButtomMenuBar) {
child: folderView, folderView = Padding(
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 48.0), child: folderView,
); padding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 48.0),
);
}
var backButton = IconButton( var backButton = IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
@ -140,8 +145,10 @@ class _FolderViewState extends State<FolderView> {
extendBody: true, extendBody: true,
drawer: AppDrawer(), drawer: AppDrawer(),
floatingActionButton: createButton, floatingActionButton: createButton,
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, floatingActionButtonLocation:
bottomNavigationBar: NewNoteNavBar(onPressed: _newPost), showButtomMenuBar ? FloatingActionButtonLocation.endDocked : null,
bottomNavigationBar:
showButtomMenuBar ? NewNoteNavBar(onPressed: _newPost) : null,
); );
} }

View File

@ -0,0 +1,59 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gitjournal/settings.dart';
import 'package:gitjournal/widgets/new_note_nav_bar.dart';
import 'package:provider/provider.dart';
class BottomMenuBarSettings extends StatefulWidget {
@override
_BottomMenuBarSettingsState createState() => _BottomMenuBarSettingsState();
}
class _BottomMenuBarSettingsState extends State<BottomMenuBarSettings> {
@override
Widget build(BuildContext context) {
var settings = Provider.of<Settings>(context);
var body = Column(
children: [
Center(
child: NewNoteNavBar(
onPressed: (_) {},
),
),
const SizedBox(height: 16),
SwitchListTile(
title: Text(tr("settings.bottomMenuBar.enable")),
value: settings.bottomMenuBar,
onChanged: (bool newVal) {
setState(() {
settings.bottomMenuBar = newVal;
settings.save();
});
},
),
],
);
/*
var createButton = FloatingActionButton(
key: const ValueKey("FAB"),
onPressed: () => _newPost(widget.notesFolder.config.defaultEditor),
child: const Icon(Icons.add),
);
*/
return Scaffold(
appBar: AppBar(
title: Text(tr("settings.bottomMenuBar.title")),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: body,
);
}
}

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:dynamic_theme/dynamic_theme.dart'; import 'package:dynamic_theme/dynamic_theme.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:gitjournal/screens/settings_bottom_menu_bar.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -175,6 +176,20 @@ class SettingsListState extends State<SettingsList> {
}, },
), ),
), ),
ProOverlay(
feature: Feature.configureBottomMenuBar,
child: ListTile(
title: Text(tr("settings.bottomMenuBar.title")),
subtitle: Text(tr("settings.bottomMenuBar.subtitle")),
onTap: () {
var route = MaterialPageRoute(
builder: (context) => BottomMenuBarSettings(),
settings: const RouteSettings(name: '/settings/bottom_menu_bar'),
);
Navigator.of(context).push(route);
},
),
),
SettingsHeader(tr('settings.note.title')), SettingsHeader(tr('settings.note.title')),
ListTile( ListTile(
title: Text(tr('settings.note.defaultFolder')), title: Text(tr('settings.note.defaultFolder')),

View File

@ -56,6 +56,8 @@ class Settings extends ChangeNotifier {
Set<String> inlineTagPrefixes = {'#'}; Set<String> inlineTagPrefixes = {'#'};
bool bottomMenuBar = false;
// From AppState // From AppState
String localGitRepoFolderName = ""; String localGitRepoFolderName = "";
bool localGitRepoConfigured = false; bool localGitRepoConfigured = false;
@ -129,6 +131,8 @@ class Settings extends ChangeNotifier {
remoteGitRepoConfigured = pref.getBool("remoteGitRepoConfigured") ?? false; remoteGitRepoConfigured = pref.getBool("remoteGitRepoConfigured") ?? false;
localGitRepoFolderName = pref.getString("localGitRepoPath") ?? ""; localGitRepoFolderName = pref.getString("localGitRepoPath") ?? "";
remoteGitRepoFolderName = pref.getString("remoteGitRepoPath") ?? ""; remoteGitRepoFolderName = pref.getString("remoteGitRepoPath") ?? "";
bottomMenuBar = pref.getBool("bottomMenuBar") ?? bottomMenuBar;
} }
Future<void> save() async { Future<void> save() async {
@ -198,6 +202,7 @@ class Settings extends ChangeNotifier {
_setBool(pref, "swipeToDelete", swipeToDelete, defaultSet.swipeToDelete); _setBool(pref, "swipeToDelete", swipeToDelete, defaultSet.swipeToDelete);
_setStringSet(pref, "inlineTagPrefixes", inlineTagPrefixes, _setStringSet(pref, "inlineTagPrefixes", inlineTagPrefixes,
defaultSet.inlineTagPrefixes); defaultSet.inlineTagPrefixes);
_setBool(pref, "bottomMenuBar", bottomMenuBar, defaultSet.bottomMenuBar);
pref.setInt("settingsVersion", version); pref.setInt("settingsVersion", version);
@ -285,6 +290,7 @@ class Settings extends ChangeNotifier {
'remoteGitRepoConfigured': remoteGitRepoConfigured.toString(), 'remoteGitRepoConfigured': remoteGitRepoConfigured.toString(),
'localGitRepoFolderName': localGitRepoFolderName.toString(), 'localGitRepoFolderName': localGitRepoFolderName.toString(),
'remoteGitRepoFolderName': remoteGitRepoFolderName.toString(), 'remoteGitRepoFolderName': remoteGitRepoFolderName.toString(),
'bottomMenuBar': bottomMenuBar.toString(),
}; };
} }