Skip to content

Commit

Permalink
Cleaned up.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygohko committed Sep 7, 2024
1 parent b038512 commit ff091db
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 25 deletions.
10 changes: 7 additions & 3 deletions lib/binding_tags_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class _BindingTagsPageState extends State<BindingTagsPage> {
}
if (!added) {
final snackBar = SnackBar(
content: Text(snackBarText,
content: Text(
snackBarText,
style: TextStyle(
color: TsukimisouColors.scheme.onSecondary,
),
Expand Down Expand Up @@ -211,8 +212,11 @@ class _BindingTagsPageState extends State<BindingTagsPage> {
} on IOException {
if (mounted) {
// Save error
await showErrorDialog(context, localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage, localizations.ok);
await showErrorDialog(
context,
localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage,
localizations.ok);
}
}

Expand Down
9 changes: 6 additions & 3 deletions lib/editing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _EditingPageState extends State<EditingPage> {
),
],
),
body: Padding(
body: Padding(
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _controller,
Expand Down Expand Up @@ -142,8 +142,11 @@ class _EditingPageState extends State<EditingPage> {
} on IOException {
if (mounted) {
// Save error
await showErrorDialog(context, localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage, localizations.ok);
await showErrorDialog(
context,
localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage,
localizations.ok);
}
}
if (mounted) {
Expand Down
27 changes: 16 additions & 11 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ class _HomePageState extends State<HomePage> {
// TODO: Showing error at here may cause problem. Check this later.
final localizations = AppLocalizations.of(context)!;
await common_uis.showErrorDialog(
context,
localizations.memoStoreIsNotCompatible,
localizations.memoStoreInTheLocalStorageIsNotCompatible,
localizations.ok);
context,
localizations.memoStoreIsNotCompatible,
localizations.memoStoreInTheLocalStorageIsNotCompatible,
localizations.ok);
}
} on IOException {
// Load error
Expand Down Expand Up @@ -226,8 +226,11 @@ class _HomePageState extends State<HomePage> {
messenger.hideCurrentMaterialBanner();
appState.mergingWithGoogleDrive = false;
if (mounted) {
await common_uis.showErrorDialog(context, localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage, localizations.ok);
await common_uis.showErrorDialog(
context,
localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage,
localizations.ok);
}
return;
}
Expand All @@ -245,7 +248,7 @@ class _HomePageState extends State<HomePage> {
// Saving failed.
if (mounted) {
await common_uis.showErrorDialog(context, localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToGoogleDrive, localizations.ok);
localizations.couldNotSaveMemoStoreToGoogleDrive, localizations.ok);
}
}
setState(() {
Expand Down Expand Up @@ -299,7 +302,8 @@ class _HomePageState extends State<HomePage> {
}

void _showPrivacyPolicy() async {
await launchUrl(Uri.parse('https://sites.gonypage.jp/home/tsukimisou/privacy-policy'));
await launchUrl(
Uri.parse('https://sites.gonypage.jp/home/tsukimisou/privacy-policy'));
if (mounted) {
if (!common_uis.hasLargeScreen()) {
Navigator.of(context).pop();
Expand Down Expand Up @@ -567,7 +571,7 @@ class _HomePageState extends State<HomePage> {
onTap: _showAbout,
shape: border,
);
} else if (i == privacyPolicyIndex){
} else if (i == privacyPolicyIndex) {
return ListTile(
title: Text(localizations.privacyPolicy),
onTap: _showPrivacyPolicy,
Expand All @@ -580,8 +584,9 @@ class _HomePageState extends State<HomePage> {
alignment: Alignment.centerLeft,
child: Text(
localizations.showingMemos(
_shownMemos.length, memoStore.memos.length, tags.length),
style: common_uis.TsukimisouTextStyles.homePageDrawerFooter(context),
_shownMemos.length, memoStore.memos.length, tags.length),
style: common_uis.TsukimisouTextStyles.homePageDrawerFooter(
context),
),
),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/memo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ import 'package:uuid/uuid.dart';
class Memo {
/// A ID of this memo.
var id = '';

/// Epoch milliseconds from last modified.
var lastModified = 0;

/// Revision of this memo.
var revision = 0;

/// Revision when last merged.
var lastMergedRevision = 0;
var _text = '';
Expand Down
2 changes: 2 additions & 0 deletions lib/memo_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import 'memo.dart';
class MemoStore extends ChangeNotifier {
/// Memos that are stored in this memo store.
var memos = <Memo>[];

/// Memo IDs that are removed.
var removedMemoIds = <String>[];

/// Epoch milliseconds from last merged.
var lastMerged = 0;

Expand Down
8 changes: 4 additions & 4 deletions lib/searching_page_contents.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class _SearchingPageContentsState extends State<SearchingPageContents> {
elevation: 2.0,
child: InkWell(
onTap: appState.mergingWithGoogleDrive
? null
: () async {
await common_uis.viewMemo(context, memo);
},
? null
: () async {
await common_uis.viewMemo(context, memo);
},
child: common_uis.memoCardContents(context, memo, unsynchronized),
),
);
Expand Down
14 changes: 10 additions & 4 deletions lib/viewing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class _ViewingPageState extends State<ViewingPage> {
common_uis.TsukimisouTextStyles.viewingPageMemoAttribute(context);
final size = MediaQuery.of(context).size;
final width = _fullScreen ? size.width : common_uis.MemoDialogsSize.width;
final height = _fullScreen ? size.height : common_uis.MemoDialogsSize.height;
final height =
_fullScreen ? size.height : common_uis.MemoDialogsSize.height;
var actions = <Widget>[];
if (common_uis.hasLargeScreen()) {
actions.add(
Expand Down Expand Up @@ -119,7 +120,9 @@ class _ViewingPageState extends State<ViewingPage> {
height: height,
child: Scaffold(
appBar: AppBar(
leading: common_uis.hasLargeScreen() ? const CloseButton() : const BackButton(),
leading: common_uis.hasLargeScreen()
? const CloseButton()
: const BackButton(),
title: Text(localizations.memoAtDateTime(dateTime.toSmartString())),
actions: actions,
),
Expand Down Expand Up @@ -239,8 +242,11 @@ class _ViewingPageState extends State<ViewingPage> {
} on IOException {
if (mounted) {
// Save error
await common_uis.showErrorDialog(context, localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage, localizations.ok);
await common_uis.showErrorDialog(
context,
localizations.savingWasFailed,
localizations.couldNotSaveMemoStoreToLocalStorage,
localizations.ok);
}
}
if (mounted) {
Expand Down

0 comments on commit ff091db

Please sign in to comment.