Skip to content

Commit

Permalink
Release v1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Voklen committed Apr 29, 2023
2 parents 1cb09cc + 1547bc5 commit d7f8d97
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 69 deletions.
12 changes: 8 additions & 4 deletions Release checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
- [ ] git push

- [ ] Release on GitHub
- [ ] Set GitHub tag and title to version number (with 'v' at the start)
- [ ] Set GitHub target branch to releases
- [ ] Copy changelog in to GitHub
- [ ] Attach binaries to GitHub
- [ ] Set GitHub tag and title to version number (with 'v' at the start)
- [ ] Set GitHub target branch to releases
- [ ] Copy changelog in to GitHub
- [ ] Attach binaries to GitHub
- [ ] cp build/app/outputs/flutter-apk/app-release.apk daily_diary.apk
- [ ] cp -r build/linux/x64/release/bundle/ linux/
- [ ] tar -czvf linux.tar.gz linux/
- [ ] rm linux/
- [ ] Publish
13 changes: 6 additions & 7 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
return;
}
if (state == AppLifecycleState.paused) {
await _updateStorage();
_updateStorage();
}
resetIfNewDay();
}
Expand All @@ -122,19 +122,18 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
App.settingsNotifier.setFontSizeFromFile();
}

Future<File> _updateStorage() {
void _updateStorage() {
QuitHandler.disable();
return widget.storage.writeFile(_textController.text);
widget.storage.writeFile(_textController.text);
}

_textChanged(_) async {
QuitHandler.enable(context, _saveAndQuit);
}

_saveAndQuit() {
_updateStorage().then((_) {
Navigator.of(context).pop(true);
});
_updateStorage();
Navigator.of(context).pop(true);
}

SpellCheckConfiguration? _getSpellChecker(Settings currentSettings) {
Expand All @@ -161,7 +160,7 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
Future<bool> saveBeforeExit() async {
exiting = true;
if (Platform.isAndroid || Platform.isIOS) {
await _updateStorage();
_updateStorage();
}
return true;
}
Expand Down
73 changes: 42 additions & 31 deletions lib/screens/previous_entries.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:daily_diary/screens/home.dart';
import 'package:flutter/material.dart';

import 'package:intl/intl.dart';
Expand All @@ -24,41 +25,51 @@ class PreviousEntriesScreen extends StatelessWidget {
datesList.sort((b, a) => a.compareTo(b));
return ListView.builder(
itemCount: datesList.length,
itemBuilder: (context, index) {
DateTime date = datesList[index];
String humanDate = DateFormat.yMMMd().format(date);
return ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
String filename =
date.toIso8601String().substring(0, 10);
final storage =
PreviousEntryStorage(filename, savePath!);
return ViewOnlyScreen(
title: humanDate, storage: storage);
},
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.background,
),
child: SizedBox(
width: double.infinity,
child: Text(
humanDate,
style: Theme.of(context).textTheme.bodyMedium,
),
),
);
},
itemBuilder: (_, index) => PreviousEntry(
date: datesList[index],
),
);
},
),
),
);
}
}

class PreviousEntry extends StatelessWidget {
const PreviousEntry({super.key, required this.date});

final DateTime date;

@override
Widget build(BuildContext context) {
if (date.isSameDate(DateTime.now())) {
return Container();
}
final String humanDate = DateFormat.yMMMd().format(date);
return ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
String filename = date.toIso8601String().substring(0, 10);
final storage = PreviousEntryStorage(filename, savePath!);
return ViewOnlyScreen(title: humanDate, storage: storage);
},
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.background,
),
child: SizedBox(
width: double.infinity,
child: Text(
humanDate,
style: Theme.of(context).textTheme.bodyMedium,
),
),
);
}
}
11 changes: 8 additions & 3 deletions lib/screens/view_only.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ class _ViewOnlyScreenState extends State<ViewOnlyScreen> {
child: FutureBuilder(
future: widget.storage.readFile(),
builder: ((context, AsyncSnapshot<String> file) {
return Text(
file.data ?? "",
style: TextStyle(fontSize: currentSettings.fontSize),
return FractionallySizedBox(
widthFactor: 1.0,
child: SingleChildScrollView(
child: Text(
file.data ?? "",
style: TextStyle(fontSize: currentSettings.fontSize),
),
),
);
}),
),
Expand Down
11 changes: 9 additions & 2 deletions lib/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ class DiaryStorage {
}
}

Future<File> writeFile(String counter) async {
return file.writeAsString(counter);
void writeFile(String text) {
if (text.isNotEmpty) {
file.writeAsStringSync(text);
return;
}
if (file.existsSync()) {
file.deleteSync();
return;
}
}

void recalculateDate() {
Expand Down
3 changes: 3 additions & 0 deletions metadata/en-GB/changelogs/8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed previous entry not scrolling. Thanks @Shashank3736
Does not save empty entries
Removed today's entry from "Previous entries"
38 changes: 19 additions & 19 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: "0d923fb610d0abf67f2149c3a50ef85f78bebecfc4d645719ca70bcf4abc788f"
sha256: e6c7ad8e572379df86ea64ef0a5395889fba3954411d47ca021b888d79f8e798
url: "https://pub.dev"
source: hosted
version: "5.2.7"
version: "5.2.11"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -106,10 +106,10 @@ packages:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf
sha256: "8ffe990dac54a4a5492747added38571a5ab474c8e5d196809ea08849c69b1bb"
url: "https://pub.dev"
source: hosted
version: "2.0.9"
version: "2.0.13"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -132,10 +132,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.18.0"
version: "0.18.1"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -196,18 +196,18 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7"
sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86"
url: "https://pub.dev"
source: hosted
version: "2.0.24"
version: "2.0.27"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7"
sha256: ad4c4d011830462633f03eb34445a45345673dfd4faf1ab0b4735fbd93b19183
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
path_provider_linux:
dependency: transitive
description:
Expand All @@ -228,10 +228,10 @@ packages:
dependency: transitive
description:
name: path_provider_windows
sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130
sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6
url: "https://pub.dev"
source: hosted
version: "2.1.5"
version: "2.1.6"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -276,18 +276,18 @@ packages:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6"
sha256: "6478c6bbbecfe9aced34c483171e90d7c078f5883558b30ec3163cf18402c749"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.4"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: cf2a42fb20148502022861f71698db12d937c7459345a1bdaa88fc91a91b3603
sha256: "0c1c16c56c9708aa9c361541a6f0e5cc6fc12a3232d866a687a7b7db30032b07"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "2.2.1"
shared_preferences_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -393,10 +393,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46
sha256: dd8f9344bc305ae2923e3d11a2a911d9a4e2c7dd6fe0ed10626d63211a69676e
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "4.1.3"
xdg_directories:
dependency: transitive
description:
Expand All @@ -407,4 +407,4 @@ packages:
version: "1.0.0"
sdks:
dart: ">=2.19.0-374.1.beta <3.0.0"
flutter: ">=3.0.0"
flutter: ">=3.3.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A diary that starts with a blank page every day (while saving the p
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.2.3+7
version: 1.2.4+8

environment:
sdk: '>=2.19.0-374.1.beta <3.0.0'
Expand Down
4 changes: 2 additions & 2 deletions test/storage/diary_storage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ main() {
test('Normal', () async {
final storage = DiaryStorage('test_data/');
const testText = 'This is a test diary\n a newline here\nwow, another';
await storage.writeFile(testText);
storage.writeFile(testText);
String result = await storage.readFile();

expect(result, testText);
Expand All @@ -23,7 +23,7 @@ main() {
test('Unicode', () async {
final storage = DiaryStorage('test_data/');
const testText = 'This is a اختبر diary\n a newline here\nа вот еще один';
await storage.writeFile(testText);
storage.writeFile(testText);
String result = await storage.readFile();

expect(result, testText);
Expand Down

0 comments on commit d7f8d97

Please sign in to comment.