mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Split Settings into AppSettings and Settings
This way I can eventually change Settings into RepoSettings without breaking anything.
This commit is contained in:
35
lib/app.dart
35
lib/app.dart
@ -17,6 +17,7 @@ import 'package:quick_actions/quick_actions.dart';
|
||||
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
||||
|
||||
import 'package:gitjournal/analytics.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/appstate.dart';
|
||||
import 'package:gitjournal/core/md_yaml_doc_codec.dart';
|
||||
import 'package:gitjournal/iap.dart';
|
||||
@ -45,23 +46,25 @@ class JournalApp extends StatefulWidget {
|
||||
|
||||
var appState = AppState();
|
||||
var settings = Settings.instance;
|
||||
var appSettings = AppSettings.instance;
|
||||
Log.i("AppSetting ${appSettings.toMap()}");
|
||||
Log.i("Setting ${settings.toLoggableMap()}");
|
||||
|
||||
if (settings.collectUsageStatistics) {
|
||||
if (appSettings.collectUsageStatistics) {
|
||||
_enableAnalyticsIfPossible(settings);
|
||||
}
|
||||
|
||||
if (settings.gitBaseDirectory.isEmpty) {
|
||||
if (appSettings.gitBaseDirectory.isEmpty) {
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
settings.gitBaseDirectory = dir.path;
|
||||
settings.save();
|
||||
appSettings.gitBaseDirectory = dir.path;
|
||||
appSettings.save();
|
||||
}
|
||||
|
||||
if (!Directory(settings.gitBaseDirectory).existsSync()) {
|
||||
if (!Directory(appSettings.gitBaseDirectory).existsSync()) {
|
||||
Log.w("Applications Documents Directory no longer exists");
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
settings.gitBaseDirectory = dir.path;
|
||||
settings.save();
|
||||
appSettings.gitBaseDirectory = dir.path;
|
||||
appSettings.save();
|
||||
Log.i("New Documents Directory Path ${dir.path}");
|
||||
}
|
||||
|
||||
@ -69,7 +72,7 @@ class JournalApp extends StatefulWidget {
|
||||
// FIXME: What about exceptions!
|
||||
settings.localGitRepoFolderName = "journal_local";
|
||||
var repoPath = p.join(
|
||||
settings.gitBaseDirectory,
|
||||
appSettings.gitBaseDirectory,
|
||||
settings.localGitRepoFolderName,
|
||||
);
|
||||
await GitRepository.init(repoPath);
|
||||
@ -78,11 +81,15 @@ class JournalApp extends StatefulWidget {
|
||||
settings.save();
|
||||
}
|
||||
|
||||
var app = ChangeNotifierProvider.value(
|
||||
Widget app = ChangeNotifierProvider.value(
|
||||
value: settings,
|
||||
child: ChangeNotifierProvider(
|
||||
create: (_) {
|
||||
return StateContainer(appState, settings);
|
||||
return StateContainer(
|
||||
appState: appState,
|
||||
settings: settings,
|
||||
gitBaseDirectory: appSettings.gitBaseDirectory,
|
||||
);
|
||||
},
|
||||
child: ChangeNotifierProvider(
|
||||
child: JournalApp(appState),
|
||||
@ -94,6 +101,11 @@ class JournalApp extends StatefulWidget {
|
||||
),
|
||||
);
|
||||
|
||||
app = ChangeNotifierProvider.value(
|
||||
value: appSettings,
|
||||
child: app,
|
||||
);
|
||||
|
||||
InAppPurchases.confirmProPurchaseBoot();
|
||||
|
||||
runApp(EasyLocalization(
|
||||
@ -279,9 +291,10 @@ class _JournalAppState extends State<JournalApp> {
|
||||
MaterialApp buildApp(BuildContext context, ThemeData themeData) {
|
||||
var stateContainer = Provider.of<StateContainer>(context);
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
|
||||
var initialRoute = '/';
|
||||
if (!settings.onBoardingCompleted) {
|
||||
if (!appSettings.onBoardingCompleted) {
|
||||
initialRoute = '/onBoarding';
|
||||
}
|
||||
if (settings.homeScreen == SettingsHomeScreen.AllFolders) {
|
||||
|
142
lib/app_settings.dart
Normal file
142
lib/app_settings.dart
Normal file
@ -0,0 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'package:gitjournal/features.dart';
|
||||
|
||||
class AppSettings extends ChangeNotifier {
|
||||
// singleton
|
||||
static final AppSettings _singleton = AppSettings._internal();
|
||||
factory AppSettings() => _singleton;
|
||||
AppSettings._internal();
|
||||
static AppSettings get instance => _singleton;
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
var onBoardingCompleted = false;
|
||||
var collectUsageStatistics = true;
|
||||
var collectCrashReports = true;
|
||||
|
||||
int version = 0;
|
||||
|
||||
var proMode = Features.alwaysPro;
|
||||
var proExpirationDate = "";
|
||||
|
||||
String _pseudoId;
|
||||
String get pseudoId => _pseudoId;
|
||||
|
||||
var debugLogLevel = 'v';
|
||||
|
||||
var experimentalBacklinks = true;
|
||||
var experimentalFs = false;
|
||||
var experimentalMarkdownToolbar = false;
|
||||
var experimentalGraphView = false;
|
||||
|
||||
var gitBaseDirectory = "";
|
||||
|
||||
void load(SharedPreferences pref) {
|
||||
onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
||||
|
||||
collectUsageStatistics =
|
||||
pref.getBool("collectUsageStatistics") ?? collectUsageStatistics;
|
||||
collectCrashReports =
|
||||
pref.getBool("collectCrashReports") ?? collectCrashReports;
|
||||
|
||||
version = pref.getInt("appSettingsVersion") ?? version;
|
||||
proMode = pref.getBool("proMode") ?? proMode;
|
||||
proExpirationDate =
|
||||
pref.getString("proExpirationDate") ?? proExpirationDate;
|
||||
|
||||
_pseudoId = pref.getString("pseudoId");
|
||||
if (_pseudoId == null) {
|
||||
_pseudoId = Uuid().v4();
|
||||
pref.setString("pseudoId", _pseudoId);
|
||||
}
|
||||
|
||||
debugLogLevel = pref.getString("debugLogLevel") ?? debugLogLevel;
|
||||
experimentalBacklinks =
|
||||
pref.getBool("experimentalBacklinks") ?? experimentalBacklinks;
|
||||
experimentalFs = pref.getBool("experimentalFs") ?? experimentalFs;
|
||||
experimentalMarkdownToolbar = pref.getBool("experimentalMarkdownToolbar") ??
|
||||
experimentalMarkdownToolbar;
|
||||
experimentalGraphView =
|
||||
pref.getBool("experimentalGraphView") ?? experimentalGraphView;
|
||||
|
||||
gitBaseDirectory = pref.getString("gitBaseDirectory") ?? "";
|
||||
}
|
||||
|
||||
Future<void> save() async {
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
var defaultSet = AppSettings._internal();
|
||||
|
||||
pref.setBool("onBoardingCompleted", onBoardingCompleted);
|
||||
|
||||
_setBool(pref, "collectUsageStatistics", collectUsageStatistics,
|
||||
defaultSet.collectUsageStatistics);
|
||||
_setBool(pref, "collectCrashReports", collectCrashReports,
|
||||
defaultSet.collectCrashReports);
|
||||
|
||||
_setString(pref, "proExpirationDate", proExpirationDate,
|
||||
defaultSet.proExpirationDate);
|
||||
_setBool(pref, "proMode", proMode, defaultSet.proMode);
|
||||
_setString(pref, "debugLogLevel", debugLogLevel, defaultSet.debugLogLevel);
|
||||
_setBool(pref, "experimentalBacklinks", experimentalBacklinks,
|
||||
defaultSet.experimentalBacklinks);
|
||||
_setBool(pref, "experimentalFs", experimentalFs, defaultSet.experimentalFs);
|
||||
_setBool(pref, "experimentalMarkdownToolbar", experimentalMarkdownToolbar,
|
||||
defaultSet.experimentalMarkdownToolbar);
|
||||
_setBool(pref, "experimentalGraphView", experimentalGraphView,
|
||||
defaultSet.experimentalGraphView);
|
||||
|
||||
pref.setInt("appSettingsVersion", version);
|
||||
pref.setString("gitBaseDirectory", gitBaseDirectory);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Map<String, String> toMap() {
|
||||
return {
|
||||
"onBoardingCompleted": onBoardingCompleted.toString(),
|
||||
"collectUsageStatistics": collectUsageStatistics.toString(),
|
||||
"collectCrashReports": collectCrashReports.toString(),
|
||||
"version": version.toString(),
|
||||
"proMode": proMode.toString(),
|
||||
'proExpirationDate': proExpirationDate,
|
||||
'pseudoId': pseudoId,
|
||||
'debugLogLevel': debugLogLevel,
|
||||
'experimentalBacklinks': experimentalBacklinks.toString(),
|
||||
'experimentalFs': experimentalFs.toString(),
|
||||
'experimentalMarkdownToolbar': experimentalMarkdownToolbar.toString(),
|
||||
'experimentalGraphView': experimentalGraphView.toString(),
|
||||
'gitBaseDirectory': gitBaseDirectory.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> _setString(
|
||||
SharedPreferences pref,
|
||||
String key,
|
||||
String value,
|
||||
String defaultValue,
|
||||
) async {
|
||||
if (value == defaultValue) {
|
||||
await pref.remove(key);
|
||||
} else {
|
||||
await pref.setString(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setBool(
|
||||
SharedPreferences pref,
|
||||
String key,
|
||||
bool value,
|
||||
bool defaultValue,
|
||||
) async {
|
||||
if (value == defaultValue) {
|
||||
await pref.remove(key);
|
||||
} else {
|
||||
await pref.setBool(key, value);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import 'package:sentry/sentry.dart';
|
||||
|
||||
import 'package:gitjournal/.env.dart';
|
||||
import 'package:gitjournal/app.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
|
||||
SentryClient _sentryClient;
|
||||
@ -64,7 +64,7 @@ Future<Event> get _environmentEvent async {
|
||||
),
|
||||
),
|
||||
userContext: User(
|
||||
id: Settings.instance.pseudoId,
|
||||
id: AppSettings.instance.pseudoId,
|
||||
),
|
||||
);
|
||||
return environment;
|
||||
@ -83,7 +83,7 @@ void flutterOnErrorHandler(FlutterErrorDetails details) {
|
||||
bool get reportCrashes => _reportCrashes ??= _initReportCrashes();
|
||||
bool _reportCrashes;
|
||||
bool _initReportCrashes() {
|
||||
return !JournalApp.isInDebugMode && Settings.instance.collectCrashReports;
|
||||
return !JournalApp.isInDebugMode && AppSettings.instance.collectCrashReports;
|
||||
}
|
||||
|
||||
Future<void> reportError(Object error, StackTrace stackTrace) async {
|
||||
|
26
lib/iap.dart
26
lib/iap.dart
@ -7,9 +7,9 @@ import 'package:in_app_purchase/store_kit_wrappers.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'package:gitjournal/app.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:gitjournal/features.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
|
||||
class InAppPurchases {
|
||||
@ -20,13 +20,13 @@ class InAppPurchases {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.instance.proMode == false) {
|
||||
if (AppSettings.instance.proMode == false) {
|
||||
Log.i("confirmProPurchaseBoot: Pro Mode is false");
|
||||
return;
|
||||
}
|
||||
|
||||
var currentDt = DateTime.now().toUtc().toIso8601String();
|
||||
var exp = Settings.instance.proExpirationDate;
|
||||
var exp = AppSettings.instance.proExpirationDate;
|
||||
|
||||
Log.i("Checking if ProMode should be enabled. Exp: $exp");
|
||||
if (exp != null && exp.isNotEmpty && exp.compareTo(currentDt) > 0) {
|
||||
@ -55,9 +55,9 @@ class InAppPurchases {
|
||||
Log.e("Failed to get subscription status", ex: e, stacktrace: stackTrace);
|
||||
Log.i("Disabling Pro mode as it has probably expired");
|
||||
|
||||
Settings.instance.proMode = false;
|
||||
Settings.instance.proExpirationDate = "";
|
||||
Settings.instance.save();
|
||||
AppSettings.instance.proMode = false;
|
||||
AppSettings.instance.proExpirationDate = "";
|
||||
AppSettings.instance.save();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -66,14 +66,14 @@ class InAppPurchases {
|
||||
var expiryDate = sub.expiryDate.toIso8601String();
|
||||
Log.i(sub.toString());
|
||||
|
||||
if (Settings.instance.proMode != isPro) {
|
||||
if (AppSettings.instance.proMode != isPro) {
|
||||
Log.i("Pro mode changed to $isPro");
|
||||
Settings.instance.proMode = isPro;
|
||||
Settings.instance.proExpirationDate = expiryDate;
|
||||
Settings.instance.save();
|
||||
AppSettings.instance.proMode = isPro;
|
||||
AppSettings.instance.proExpirationDate = expiryDate;
|
||||
AppSettings.instance.save();
|
||||
} else {
|
||||
Settings.instance.proExpirationDate = expiryDate;
|
||||
Settings.instance.save();
|
||||
AppSettings.instance.proExpirationDate = expiryDate;
|
||||
AppSettings.instance.save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ Future<DateTime> getExpiryDate(
|
||||
var body = {
|
||||
'receipt': receipt,
|
||||
"sku": sku,
|
||||
'pseudoId': Settings.instance.pseudoId,
|
||||
'pseudoId': AppSettings.instance.pseudoId,
|
||||
'is_purchase': isPurchase,
|
||||
};
|
||||
Log.i("getExpiryDate ${json.encode(body)}");
|
||||
|
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:gitjournal/app.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
|
||||
@ -14,6 +15,7 @@ void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
AppSettings.instance.load(pref);
|
||||
Settings.instance.load(pref);
|
||||
|
||||
JournalApp.isInDebugMode = foundation.kDebugMode;
|
||||
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
|
||||
class DebugScreen extends StatefulWidget {
|
||||
@ -79,8 +79,8 @@ class _DebugScreenState extends State<DebugScreen> {
|
||||
}
|
||||
|
||||
bool _shouldDisplay(LogMessage msg) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var filterLevel = settings.debugLogLevel;
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var filterLevel = appSettings.debugLogLevel;
|
||||
|
||||
if (filterLevel == null || filterLevel.isEmpty) {
|
||||
return true;
|
||||
@ -199,8 +199,8 @@ class _DebugScreenState extends State<DebugScreen> {
|
||||
}
|
||||
|
||||
void _showFilterSelection() async {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var filterLevel = settings.debugLogLevel;
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var filterLevel = appSettings.debugLogLevel;
|
||||
|
||||
var dialog = AlertDialog(
|
||||
title: Text(tr('settings.debug.levels.title')),
|
||||
@ -217,8 +217,8 @@ class _DebugScreenState extends State<DebugScreen> {
|
||||
);
|
||||
var l = await showDialog(context: context, builder: (context) => dialog);
|
||||
if (l != null) {
|
||||
settings.debugLogLevel = l;
|
||||
settings.save();
|
||||
appSettings.debugLogLevel = l;
|
||||
appSettings.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:function_types/function_types.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
|
||||
class OnBoardingScreen extends StatefulWidget {
|
||||
OnBoardingScreen();
|
||||
@ -111,9 +111,9 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
|
||||
}
|
||||
|
||||
void _finish() {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
settings.onBoardingCompleted = true;
|
||||
settings.save();
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
appSettings.onBoardingCompleted = true;
|
||||
appSettings.save();
|
||||
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, "/");
|
||||
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
|
||||
class ExperimentalSettingsScreen extends StatefulWidget {
|
||||
@override
|
||||
@ -15,7 +15,7 @@ class _ExperimentalSettingsScreenState
|
||||
extends State<ExperimentalSettingsScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@ -32,37 +32,37 @@ class _ExperimentalSettingsScreenState
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.experimental.backlinks')),
|
||||
value: settings.experimentalBacklinks,
|
||||
value: appSettings.experimentalBacklinks,
|
||||
onChanged: (bool newVal) {
|
||||
settings.experimentalBacklinks = newVal;
|
||||
settings.save();
|
||||
appSettings.experimentalBacklinks = newVal;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.experimental.fs')),
|
||||
value: settings.experimentalFs,
|
||||
value: appSettings.experimentalFs,
|
||||
onChanged: (bool newVal) {
|
||||
settings.experimentalFs = newVal;
|
||||
settings.save();
|
||||
appSettings.experimentalFs = newVal;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.experimental.graphView')),
|
||||
value: settings.experimentalGraphView,
|
||||
value: appSettings.experimentalGraphView,
|
||||
onChanged: (bool newVal) {
|
||||
settings.experimentalGraphView = newVal;
|
||||
settings.save();
|
||||
appSettings.experimentalGraphView = newVal;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.experimental.markdownToolbar')),
|
||||
value: settings.experimentalFs,
|
||||
value: appSettings.experimentalFs,
|
||||
onChanged: (bool newVal) {
|
||||
settings.experimentalFs = newVal;
|
||||
settings.save();
|
||||
appSettings.experimentalFs = newVal;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
|
@ -8,6 +8,7 @@ import 'package:git_bindings/git_bindings.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/screens/settings_widgets.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/setup/screens.dart';
|
||||
@ -132,8 +133,8 @@ class _GitRemoteSettingsScreenState extends State<GitRemoteSettingsScreen> {
|
||||
}
|
||||
|
||||
var stateContainer = Provider.of<StateContainer>(context);
|
||||
final settings = Provider.of<Settings>(context);
|
||||
var gitDir = settings.gitBaseDirectory;
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var gitDir = appSettings.gitBaseDirectory;
|
||||
|
||||
// Figure out the next available folder
|
||||
String repoFolderName = "journal_";
|
||||
|
@ -5,6 +5,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/features.dart';
|
||||
import 'package:gitjournal/screens/debug_screen.dart';
|
||||
@ -55,6 +56,7 @@ class SettingsListState extends State<SettingsList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var remoteGitConfigured = settings.remoteGitRepoConfigured;
|
||||
|
||||
var saveGitAuthor = (String gitAuthor) {
|
||||
@ -289,19 +291,19 @@ class SettingsListState extends State<SettingsList> {
|
||||
const SizedBox(height: 16.0),
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.usageStats')),
|
||||
value: settings.collectUsageStatistics,
|
||||
value: appSettings.collectUsageStatistics,
|
||||
onChanged: (bool val) {
|
||||
settings.collectUsageStatistics = val;
|
||||
settings.save();
|
||||
appSettings.collectUsageStatistics = val;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: Text(tr('settings.crashReports')),
|
||||
value: settings.collectCrashReports,
|
||||
value: appSettings.collectCrashReports,
|
||||
onChanged: (bool val) {
|
||||
settings.collectCrashReports = val;
|
||||
settings.save();
|
||||
appSettings.collectCrashReports = val;
|
||||
appSettings.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
|
@ -3,10 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'package:gitjournal/core/sorting_mode.dart';
|
||||
import 'package:gitjournal/features.dart';
|
||||
import 'package:gitjournal/folder_views/common.dart';
|
||||
import 'package:gitjournal/screens/note_editor.dart';
|
||||
|
||||
@ -18,15 +16,10 @@ class Settings extends ChangeNotifier {
|
||||
static Settings get instance => _singleton;
|
||||
|
||||
// Properties
|
||||
bool onBoardingCompleted = false;
|
||||
|
||||
String gitAuthor = "GitJournal";
|
||||
String gitAuthorEmail = "app@gitjournal.io";
|
||||
NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default;
|
||||
|
||||
bool collectUsageStatistics = true;
|
||||
bool collectCrashReports = true;
|
||||
|
||||
String yamlModifiedKey = "modified";
|
||||
String yamlCreatedKey = "created";
|
||||
String yamlTagsKey = "tags";
|
||||
@ -46,12 +39,6 @@ class Settings extends ChangeNotifier {
|
||||
String folderViewHeaderType = "TitleGenerated";
|
||||
int version = 0;
|
||||
|
||||
bool proMode = Features.alwaysPro;
|
||||
String proExpirationDate = "";
|
||||
|
||||
String _pseudoId;
|
||||
String get pseudoId => _pseudoId;
|
||||
|
||||
SettingsHomeScreen homeScreen = SettingsHomeScreen.Default;
|
||||
|
||||
SettingsMarkdownDefaultView markdownDefaultView =
|
||||
@ -60,12 +47,6 @@ class Settings extends ChangeNotifier {
|
||||
SettingsMarkdownDefaultView.Edit;
|
||||
|
||||
String imageLocationSpec = "."; // . means the same folder
|
||||
String debugLogLevel = 'v';
|
||||
|
||||
bool experimentalBacklinks = true;
|
||||
bool experimentalFs = false;
|
||||
bool experimentalMarkdownToolbar = false;
|
||||
bool experimentalGraphView = false;
|
||||
|
||||
bool zenMode = false;
|
||||
bool saveTitleInH1 = true;
|
||||
@ -82,22 +63,13 @@ class Settings extends ChangeNotifier {
|
||||
String remoteGitRepoFolderName = "";
|
||||
bool remoteGitRepoConfigured = false;
|
||||
|
||||
String gitBaseDirectory = "";
|
||||
|
||||
void load(SharedPreferences pref) {
|
||||
onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
||||
|
||||
gitAuthor = pref.getString("gitAuthor") ?? gitAuthor;
|
||||
gitAuthorEmail = pref.getString("gitAuthorEmail") ?? gitAuthorEmail;
|
||||
|
||||
noteFileNameFormat = NoteFileNameFormat.fromInternalString(
|
||||
pref.getString("noteFileNameFormat"));
|
||||
|
||||
collectUsageStatistics =
|
||||
pref.getBool("collectUsageStatistics") ?? collectUsageStatistics;
|
||||
collectCrashReports =
|
||||
pref.getBool("collectCrashReports") ?? collectCrashReports;
|
||||
|
||||
yamlModifiedKey = pref.getString("yamlModifiedKey") ?? yamlModifiedKey;
|
||||
yamlCreatedKey = pref.getString("yamlCreatedKey") ?? yamlCreatedKey;
|
||||
yamlTagsKey = pref.getString("yamlTagsKey") ?? yamlTagsKey;
|
||||
@ -137,16 +109,7 @@ class Settings extends ChangeNotifier {
|
||||
pref.getString("folderViewHeaderType") ?? folderViewHeaderType;
|
||||
|
||||
version = pref.getInt("settingsVersion") ?? version;
|
||||
proMode = pref.getBool("proMode") ?? proMode;
|
||||
emojiParser = pref.getBool("emojiParser") ?? emojiParser;
|
||||
proExpirationDate =
|
||||
pref.getString("proExpirationDate") ?? proExpirationDate;
|
||||
|
||||
_pseudoId = pref.getString("pseudoId");
|
||||
if (_pseudoId == null) {
|
||||
_pseudoId = Uuid().v4();
|
||||
pref.setString("pseudoId", _pseudoId);
|
||||
}
|
||||
|
||||
homeScreen =
|
||||
SettingsHomeScreen.fromInternalString(pref.getString("homeScreen"));
|
||||
@ -154,13 +117,6 @@ class Settings extends ChangeNotifier {
|
||||
imageLocationSpec =
|
||||
pref.getString("imageLocationSpec") ?? imageLocationSpec;
|
||||
|
||||
debugLogLevel = pref.getString("debugLogLevel") ?? debugLogLevel;
|
||||
experimentalBacklinks =
|
||||
pref.getBool("experimentalBacklinks") ?? experimentalBacklinks;
|
||||
experimentalFs = pref.getBool("experimentalFs") ?? experimentalFs;
|
||||
experimentalMarkdownToolbar = pref.getBool("experimentalMarkdownToolbar") ??
|
||||
experimentalMarkdownToolbar;
|
||||
|
||||
zenMode = pref.getBool("zenMode") ?? zenMode;
|
||||
saveTitleInH1 = pref.getBool("saveTitleInH1") ?? saveTitleInH1;
|
||||
swipeToDelete = pref.getBool("swipeToDelete") ?? swipeToDelete;
|
||||
@ -173,15 +129,12 @@ class Settings extends ChangeNotifier {
|
||||
remoteGitRepoConfigured = pref.getBool("remoteGitRepoConfigured") ?? false;
|
||||
localGitRepoFolderName = pref.getString("localGitRepoPath") ?? "";
|
||||
remoteGitRepoFolderName = pref.getString("remoteGitRepoPath") ?? "";
|
||||
gitBaseDirectory = pref.getString("gitBaseDirectory") ?? "";
|
||||
}
|
||||
|
||||
Future save() async {
|
||||
Future<void> save() async {
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
var defaultSet = Settings._internal();
|
||||
|
||||
await pref.setBool("onBoardingCompleted", onBoardingCompleted);
|
||||
|
||||
_setString(pref, "gitAuthor", gitAuthor, defaultSet.gitAuthor);
|
||||
_setString(
|
||||
pref, "gitAuthorEmail", gitAuthorEmail, defaultSet.gitAuthorEmail);
|
||||
@ -190,10 +143,6 @@ class Settings extends ChangeNotifier {
|
||||
"noteFileNameFormat",
|
||||
noteFileNameFormat.toInternalString(),
|
||||
defaultSet.noteFileNameFormat.toInternalString());
|
||||
_setBool(pref, "collectUsageStatistics", collectUsageStatistics,
|
||||
defaultSet.collectUsageStatistics);
|
||||
_setBool(pref, "collectCrashReports", collectCrashReports,
|
||||
defaultSet.collectCrashReports);
|
||||
_setString(
|
||||
pref, "yamlModifiedKey", yamlModifiedKey, defaultSet.yamlModifiedKey);
|
||||
_setString(
|
||||
@ -239,20 +188,11 @@ class Settings extends ChangeNotifier {
|
||||
pref, "showNoteSummary", showNoteSummary, defaultSet.showNoteSummary);
|
||||
_setString(pref, "folderViewHeaderType", folderViewHeaderType,
|
||||
defaultSet.folderViewHeaderType);
|
||||
_setString(pref, "proExpirationDate", proExpirationDate,
|
||||
defaultSet.proExpirationDate);
|
||||
_setBool(pref, "proMode", proMode, defaultSet.proMode);
|
||||
_setBool(pref, "emojiParser", emojiParser, defaultSet.emojiParser);
|
||||
_setString(pref, "homeScreen", homeScreen.toInternalString(),
|
||||
defaultSet.homeScreen.toInternalString());
|
||||
_setString(pref, "imageLocationSpec", imageLocationSpec,
|
||||
defaultSet.imageLocationSpec);
|
||||
_setString(pref, "debugLogLevel", debugLogLevel, defaultSet.debugLogLevel);
|
||||
_setBool(pref, "experimentalBacklinks", experimentalBacklinks,
|
||||
defaultSet.experimentalBacklinks);
|
||||
_setBool(pref, "experimentalFs", experimentalFs, defaultSet.experimentalFs);
|
||||
_setBool(pref, "experimentalMarkdownToolbar", experimentalMarkdownToolbar,
|
||||
defaultSet.experimentalMarkdownToolbar);
|
||||
_setBool(pref, "zenMode", zenMode, defaultSet.zenMode);
|
||||
_setBool(pref, "saveTitleInH1", saveTitleInH1, defaultSet.saveTitleInH1);
|
||||
_setBool(pref, "swipeToDelete", swipeToDelete, defaultSet.swipeToDelete);
|
||||
@ -265,7 +205,6 @@ class Settings extends ChangeNotifier {
|
||||
pref.setBool("remoteGitRepoConfigured", remoteGitRepoConfigured);
|
||||
pref.setString("localGitRepoPath", localGitRepoFolderName);
|
||||
pref.setString("remoteGitRepoPath", remoteGitRepoFolderName);
|
||||
pref.setString("gitBaseDirectory", gitBaseDirectory);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
@ -313,12 +252,9 @@ class Settings extends ChangeNotifier {
|
||||
|
||||
Map<String, String> toMap() {
|
||||
return <String, String>{
|
||||
"onBoardingCompleted": onBoardingCompleted.toString(),
|
||||
"gitAuthor": gitAuthor,
|
||||
"gitAuthorEmail": gitAuthorEmail,
|
||||
"noteFileNameFormat": noteFileNameFormat.toInternalString(),
|
||||
"collectUsageStatistics": collectUsageStatistics.toString(),
|
||||
"collectCrashReports": collectCrashReports.toString(),
|
||||
"yamlModifiedKey": yamlModifiedKey,
|
||||
"yamlCreatedKey": yamlCreatedKey,
|
||||
"yamlTagsKey": yamlTagsKey,
|
||||
@ -336,17 +272,10 @@ class Settings extends ChangeNotifier {
|
||||
"showNoteSummary": showNoteSummary.toString(),
|
||||
"folderViewHeaderType": folderViewHeaderType,
|
||||
"version": version.toString(),
|
||||
"proMode": proMode.toString(),
|
||||
'proExpirationDate': proExpirationDate,
|
||||
'pseudoId': pseudoId,
|
||||
'markdownDefaultView': markdownDefaultView.toInternalString(),
|
||||
'markdownLastUsedView': markdownLastUsedView.toInternalString(),
|
||||
'homeScreen': homeScreen.toInternalString(),
|
||||
'imageLocationSpec': imageLocationSpec,
|
||||
'debugLogLevel': debugLogLevel,
|
||||
'experimentalBacklinks': experimentalBacklinks.toString(),
|
||||
'experimentalFs': experimentalFs.toString(),
|
||||
'experimentalMarkdownToolbar': experimentalMarkdownToolbar.toString(),
|
||||
'zenMode': zenMode.toString(),
|
||||
'saveTitleInH1': saveTitleInH1.toString(),
|
||||
'swipeToDelete': swipeToDelete.toString(),
|
||||
@ -356,7 +285,6 @@ class Settings extends ChangeNotifier {
|
||||
'remoteGitRepoConfigured': remoteGitRepoConfigured.toString(),
|
||||
'localGitRepoFolderName': localGitRepoFolderName.toString(),
|
||||
'remoteGitRepoFolderName': remoteGitRepoFolderName.toString(),
|
||||
'gitBaseDirectory': gitBaseDirectory.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/analytics.dart';
|
||||
import 'package:gitjournal/apis/githost_factory.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/setup/autoconfigure.dart';
|
||||
@ -467,8 +468,8 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
||||
gitCloneErrorMessage = "";
|
||||
});
|
||||
|
||||
final settings = Provider.of<Settings>(context);
|
||||
var basePath = settings.gitBaseDirectory;
|
||||
final appSettings = Provider.of<AppSettings>(context);
|
||||
var basePath = appSettings.gitBaseDirectory;
|
||||
|
||||
// Just in case it was half cloned because of an error
|
||||
String repoPath = p.join(basePath, widget.repoFolderName);
|
||||
|
@ -23,6 +23,7 @@ import 'package:gitjournal/utils/logger.dart';
|
||||
class StateContainer with ChangeNotifier {
|
||||
final AppState appState;
|
||||
final Settings settings;
|
||||
final String gitBaseDirectory;
|
||||
|
||||
final _opLock = Lock();
|
||||
final _loadLock = Lock();
|
||||
@ -33,16 +34,18 @@ class StateContainer with ChangeNotifier {
|
||||
GitNoteRepository _gitRepo;
|
||||
NotesCache _notesCache;
|
||||
|
||||
StateContainer(this.appState, this.settings) {
|
||||
StateContainer({
|
||||
@required this.appState,
|
||||
@required this.settings,
|
||||
@required this.gitBaseDirectory,
|
||||
}) {
|
||||
assert(settings.localGitRepoConfigured);
|
||||
|
||||
String repoPath;
|
||||
if (settings.remoteGitRepoConfigured) {
|
||||
repoPath =
|
||||
p.join(settings.gitBaseDirectory, settings.remoteGitRepoFolderName);
|
||||
repoPath = p.join(gitBaseDirectory, settings.remoteGitRepoFolderName);
|
||||
} else if (settings.localGitRepoConfigured) {
|
||||
repoPath =
|
||||
p.join(settings.gitBaseDirectory, settings.localGitRepoFolderName);
|
||||
repoPath = p.join(gitBaseDirectory, settings.localGitRepoFolderName);
|
||||
}
|
||||
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath);
|
||||
@ -59,7 +62,7 @@ class StateContainer with ChangeNotifier {
|
||||
value: settings.remoteGitRepoConfigured.toString(),
|
||||
);
|
||||
|
||||
var cachePath = p.join(settings.gitBaseDirectory, "cache.json");
|
||||
var cachePath = p.join(gitBaseDirectory, "cache.json");
|
||||
_notesCache = NotesCache(
|
||||
filePath: cachePath,
|
||||
notesBasePath: _gitRepo.gitDirPath,
|
||||
@ -78,8 +81,8 @@ class StateContainer with ChangeNotifier {
|
||||
}
|
||||
|
||||
void removeExistingRemoteClone() async {
|
||||
var remoteGitDir = Directory(
|
||||
p.join(settings.gitBaseDirectory, settings.remoteGitRepoFolderName));
|
||||
var remoteGitDir =
|
||||
Directory(p.join(gitBaseDirectory, settings.remoteGitRepoFolderName));
|
||||
var dotGitDir = Directory(p.join(remoteGitDir.path, ".git"));
|
||||
|
||||
bool exists = dotGitDir.existsSync();
|
||||
@ -357,12 +360,11 @@ class StateContainer with ChangeNotifier {
|
||||
await migrateGitRepo(
|
||||
fromGitBasePath: settings.localGitRepoFolderName,
|
||||
toGitBaseFolder: settings.remoteGitRepoFolderName,
|
||||
gitBasePath: settings.gitBaseDirectory,
|
||||
gitBasePath: gitBaseDirectory,
|
||||
);
|
||||
}
|
||||
|
||||
var repoPath =
|
||||
p.join(settings.gitBaseDirectory, settings.remoteGitRepoFolderName);
|
||||
var repoPath = p.join(gitBaseDirectory, settings.remoteGitRepoFolderName);
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath);
|
||||
appState.notesFolder.reset(_gitRepo.gitDirPath);
|
||||
|
||||
|
@ -12,6 +12,7 @@ import 'package:share/share.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/analytics.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
@ -21,6 +22,7 @@ class AppDrawer extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
Widget setupGitButton;
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var textStyle = Theme.of(context).textTheme.bodyText1;
|
||||
var currentRoute = ModalRoute.of(context).settings.name;
|
||||
|
||||
@ -50,7 +52,7 @@ class AppDrawer extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
_AppDrawerHeader(),
|
||||
if (setupGitButton != null) ...[setupGitButton, divider],
|
||||
if (!settings.proMode)
|
||||
if (!appSettings.proMode)
|
||||
_buildDrawerTile(
|
||||
context,
|
||||
icon: Icons.power,
|
||||
@ -65,7 +67,7 @@ class AppDrawer extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!settings.proMode) divider,
|
||||
if (!appSettings.proMode) divider,
|
||||
_buildDrawerTile(
|
||||
context,
|
||||
icon: Icons.note,
|
||||
@ -80,7 +82,7 @@ class AppDrawer extends StatelessWidget {
|
||||
onTap: () => _navTopLevel(context, '/folders'),
|
||||
selected: currentRoute == "/folders",
|
||||
),
|
||||
if (settings.experimentalFs)
|
||||
if (appSettings.experimentalFs)
|
||||
_buildDrawerTile(
|
||||
context,
|
||||
icon: FontAwesomeIcons.solidFolderOpen,
|
||||
@ -89,7 +91,7 @@ class AppDrawer extends StatelessWidget {
|
||||
onTap: () => _navTopLevel(context, '/filesystem'),
|
||||
selected: currentRoute == "/filesystem",
|
||||
),
|
||||
if (settings.experimentalGraphView)
|
||||
if (appSettings.experimentalGraphView)
|
||||
_buildDrawerTile(
|
||||
context,
|
||||
icon: FontAwesomeIcons.projectDiagram,
|
||||
@ -258,7 +260,7 @@ void _navTopLevel(BuildContext context, String toRoute) {
|
||||
class _AppDrawerHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
@ -300,7 +302,7 @@ class _AppDrawerHeader extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
*/
|
||||
if (settings.proMode)
|
||||
if (appSettings.proMode)
|
||||
Positioned.fill(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
|
@ -11,12 +11,12 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/core/link.dart';
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/folder_views/common.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils.dart';
|
||||
import 'package:gitjournal/utils/link_resolver.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
@ -41,7 +41,7 @@ class NoteViewer extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
|
||||
var settings = Provider.of<Settings>(context);
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
var isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
// Copied from MarkdownStyleSheet except Grey is replaced with Highlight color
|
||||
@ -108,7 +108,7 @@ class NoteViewer extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
if (settings.experimentalBacklinks)
|
||||
if (appSettings.experimentalBacklinks)
|
||||
NoteBacklinkRenderer(
|
||||
note: note,
|
||||
rootFolder: rootFolder,
|
||||
|
@ -4,8 +4,8 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/analytics.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/features.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
|
||||
class ProOverlay extends StatelessWidget {
|
||||
final Widget child;
|
||||
@ -17,8 +17,9 @@ class ProOverlay extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
if (settings.proMode) {
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
|
||||
if (appSettings.proMode) {
|
||||
return child;
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,9 @@ import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/analytics.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:gitjournal/iap.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
import 'package:gitjournal/widgets/purchase_slider.dart';
|
||||
|
||||
@ -223,10 +223,10 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
||||
}
|
||||
|
||||
void _deliverProduct(SubscriptionStatus status) {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
settings.proMode = status.isPro;
|
||||
settings.proExpirationDate = status.expiryDate.toIso8601String();
|
||||
settings.save();
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
appSettings.proMode = status.isPro;
|
||||
appSettings.proExpirationDate = status.expiryDate.toIso8601String();
|
||||
appSettings.save();
|
||||
|
||||
logEvent(Event.PurchaseScreenThankYou);
|
||||
Navigator.of(context).popAndPushNamed('/purchase_thank_you');
|
||||
@ -401,7 +401,7 @@ class _RestorePurchaseButtonState extends State<RestorePurchaseButton> {
|
||||
computing = true;
|
||||
});
|
||||
await InAppPurchases.confirmProPurchase();
|
||||
if (Settings.instance.proMode) {
|
||||
if (AppSettings.instance.proMode) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:gitjournal/app.dart';
|
||||
@ -15,6 +16,7 @@ void main() async {
|
||||
enableFlutterDriverExtension();
|
||||
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
AppSettings.instance.load(pref);
|
||||
Settings.instance.load(pref);
|
||||
|
||||
await populateWithData(pref);
|
||||
@ -25,8 +27,10 @@ void main() async {
|
||||
Future<void> populateWithData(SharedPreferences pref) async {
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
|
||||
var appSettings = AppSettings.instance;
|
||||
appSettings.gitBaseDirectory = dir.path;
|
||||
|
||||
var settings = Settings.instance;
|
||||
settings.gitBaseDirectory = dir.path;
|
||||
settings.localGitRepoConfigured = true;
|
||||
settings.localGitRepoFolderName = "journal_local";
|
||||
settings.save();
|
||||
|
Reference in New Issue
Block a user