mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00

When configuring the Git Repo server, we could optionally track one folder in the root git repo, instead of just the root folder. This was specifically to address my use case where I have my journals in a sub-directory. The setup screen was super ugly, though. Since now I'm in the process of adding folder support because of #18, I can remove this hack. It simplifies the code a lot.
57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:fimber/fimber.dart';
|
|
import 'package:gitjournal/note.dart';
|
|
|
|
class AppState {
|
|
//
|
|
// Saved on Disk
|
|
//
|
|
// FIXME: Make these 2 final
|
|
String localGitRepoPath = "";
|
|
bool localGitRepoConfigured = false;
|
|
|
|
// FIXME: Rename from 'path' to folderName
|
|
String remoteGitRepoFolderName = "";
|
|
bool remoteGitRepoConfigured = false;
|
|
|
|
bool onBoardingCompleted = false;
|
|
|
|
//
|
|
// Temporary
|
|
//
|
|
/// This is the directory where all the git repos are stored
|
|
String gitBaseDirectory = "";
|
|
|
|
bool get hasJournalEntries {
|
|
return notes.isNotEmpty;
|
|
}
|
|
|
|
List<Note> notes = [];
|
|
|
|
AppState(SharedPreferences pref) {
|
|
localGitRepoConfigured = pref.getBool("localGitRepoConfigured") ?? false;
|
|
remoteGitRepoConfigured = pref.getBool("remoteGitRepoConfigured") ?? false;
|
|
localGitRepoPath = pref.getString("localGitRepoPath") ?? "";
|
|
remoteGitRepoFolderName = pref.getString("remoteGitRepoPath") ?? "";
|
|
onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
|
}
|
|
|
|
void dumpToLog() {
|
|
Fimber.d(" ---- Settings ---- ");
|
|
Fimber.d("localGitRepoConfigured: $localGitRepoConfigured");
|
|
Fimber.d("remoteGitRepoConfigured: $remoteGitRepoConfigured");
|
|
Fimber.d("localGitRepoPath: $localGitRepoPath");
|
|
Fimber.d("remoteGitRepoFolderName: $remoteGitRepoFolderName");
|
|
Fimber.d("onBoardingCompleted: $onBoardingCompleted");
|
|
Fimber.d(" ------------------ ");
|
|
}
|
|
|
|
Future save(SharedPreferences pref) async {
|
|
await pref.setBool("localGitRepoConfigured", localGitRepoConfigured);
|
|
await pref.setBool("remoteGitRepoConfigured", remoteGitRepoConfigured);
|
|
await pref.setString("localGitRepoPath", localGitRepoPath);
|
|
await pref.setString("remoteGitRepoPath", remoteGitRepoFolderName);
|
|
await pref.setBool("onBoardingCompleted", onBoardingCompleted);
|
|
}
|
|
}
|