Skip to content

Commit

Permalink
Release v1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Voklen committed Jan 14, 2024
2 parents c05c647 + 91bae3d commit 416aa61
Show file tree
Hide file tree
Showing 23 changed files with 199 additions and 143 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@

[![Github version](https://img.shields.io/github/v/release/Voklen/daily-diary.svg?logo=github&color=forestgreen)](https://github.com/Voklen/Daily-Diary/releases/latest)
[![F-droid version](https://img.shields.io/f-droid/v/com.voklen.daily_diary.svg?logo=F-Droid)](https://f-droid.org/packages/com.voklen.daily_diary/)
[![Flutter](https://img.shields.io/badge/_Flutter_-3.10.6-blue?&logo=Flutter)](https://github.com/flutter/flutter/tree/3.10.6)
[![Flutter](https://img.shields.io/badge/_Flutter_-3.16.7-blue?&logo=Flutter)](https://github.com/flutter/flutter/tree/3.16.7)
[![License](https://img.shields.io/github/license/Voklen/Daily-Diary)](LICENCE)

Jot down whatever you want throughout the day and the app will reset the next morning. All previous days are stored in plaintext files which can be exported and moved to a different device.
Jot down whatever you want throughout the day and the app will reset the next morning. All previous
days are stored in plaintext files which can be exported and moved to a different device.

Settings are stored in a config.toml file that can also be moved between devices.

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.voklen.daily_diary/)
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.voklen.daily_diary/)

or get the APK from the [Releases Section](https://github.com/Voklen/Daily-Diary/releases/latest).

## Screenshots

| ![The main diary writing screen with nothing written yet](metadata/en-GB/images/phoneScreenshots/4%20Empty.png) | ![Settings screen](metadata/en-GB/images/phoneScreenshots/1%20Settings.png) |
| :-------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
| ![The main diary writing screen with nothing written yet](metadata/en-GB/images/phoneScreenshots/4.1%20Empty.png) | ![Settings screen](metadata/en-GB/images/phoneScreenshots/1.1%20Settings.png) |
|:-----------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------:|

| ![A screen displaying the previous entries](metadata/en-GB/images/phoneScreenshots/2%20Previous%20entries.png) | ![A previous diary entry displaying sugar consumption](metadata/en-GB/images/phoneScreenshots/3%20Sugar%20tracking.png) | ![An entry from Shakespeare's diary](metadata/en-GB/images/phoneScreenshots/0%20Shakespeare's%20diary.png) |
| :------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------: |
| ![A screen displaying the previous entries](metadata/en-GB/images/phoneScreenshots/2.1%20Previous%20entries.png) | ![A previous diary entry displaying sugar consumption](metadata/en-GB/images/phoneScreenshots/3.1%20Sugar%20tracking.png) | ![An entry from Shakespeare's diary](metadata/en-GB/images/phoneScreenshots/0.1%20Shakespeare's%20diary.png) |
|:----------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------:|

## Running

Expand Down
23 changes: 20 additions & 3 deletions lib/backend_classes/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';

import 'package:daily_diary/backend_classes/filenames.dart';
import 'package:daily_diary/backend_classes/path.dart';
import 'package:daily_diary/screens/home.dart';

import 'package:toml/toml.dart';

Expand All @@ -18,11 +19,21 @@ class DiaryStorage {
Future<MyFile> get storageFile => path.getChild(filename);

Future<String> readFile() async {
return (await storageFile).readAsString();
try {
MyFile file = await storageFile;
return await file.readAsString();
} on Exception {
return '';
}
}

Future<void> writeFile(String text) async {
return (await storageFile).writeFile(text);
try {
MyFile file = await storageFile;
return await file.writeFile(text);
} on Exception {
return;
}
}

void recalculateDate() {
Expand Down Expand Up @@ -168,8 +179,14 @@ class PreviousEntriesStorage {
Stream<MyFile> files = await path.list();
Stream<EntryFile?> asEntryFiles = files.map(EntryFile.create);
Stream<EntryFile> withoutNull = asEntryFiles.where((s) => s != null).cast();
List<EntryFile> asList = await withoutNull.toList();
Stream<EntryFile> withoutToday = withoutNull.where(_isNotToday);
List<EntryFile> asList = await withoutToday.toList();
asList.sort((b, a) => a.compareTo(b));
return asList;
}
}

bool _isNotToday(EntryFile date) {
bool isToday = date.entryDate.isSameDate(DateTime.now());
return !isToday;
}
54 changes: 21 additions & 33 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class EntryEditor extends StatefulWidget {

class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
final _textController = TextEditingController();
bool exiting = false;
bool loaded = false;

@override
initState() {
Expand All @@ -89,6 +89,7 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
widget.storage.readFile().then((value) {
setState(() {
_textController.text = value;
loaded = true;
});
});
}
Expand All @@ -102,10 +103,7 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
@override
didChangeAppLifecycleState(AppLifecycleState state) async {
super.didChangeAppLifecycleState(state);
if (exiting) {
return;
}
if (state == AppLifecycleState.paused) {
if (state == AppLifecycleState.inactive) {
_updateStorage();
}
resetIfNewDay();
Expand All @@ -116,6 +114,7 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
}

void _updateStorage() {
if (!loaded) return;
UnsavedChangesAlert.disable();
widget.storage.writeFile(_textController.text);
}
Expand Down Expand Up @@ -150,14 +149,6 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {
}
}

Future<bool> saveBeforeExit() async {
exiting = true;
if (Platform.isAndroid || Platform.isIOS) {
_updateStorage();
}
return true;
}

void resetIfNewDay() {
DateTime startWriting = widget.storage.date;
DateTime now = DateTime.now();
Expand All @@ -173,26 +164,23 @@ class _EntryEditorState extends State<EntryEditor> with WidgetsBindingObserver {

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: saveBeforeExit,
child: RawKeyboardListener(
autofocus: true,
focusNode: FocusNode(),
onKey: keyPressed,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _textController,
onChanged: _textChanged,
expands: true,
maxLines: null,
keyboardType: TextInputType.multiline,
spellCheckConfiguration: _getSpellChecker(widget.settings),
textCapitalization: TextCapitalization.sentences,
style: TextStyle(fontSize: widget.settings.fontSize),
decoration: InputDecoration.collapsed(
hintText: locale(context).startTyping,
),
return RawKeyboardListener(
autofocus: true,
focusNode: FocusNode(),
onKey: keyPressed,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _textController,
onChanged: _textChanged,
expands: true,
maxLines: null,
keyboardType: TextInputType.multiline,
spellCheckConfiguration: _getSpellChecker(widget.settings),
textCapitalization: TextCapitalization.sentences,
style: TextStyle(fontSize: widget.settings.fontSize),
decoration: InputDecoration.collapsed(
hintText: locale(context).startTyping,
),
),
),
Expand Down
48 changes: 24 additions & 24 deletions lib/screens/previous_entries.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:daily_diary/backend_classes/path.dart';
import 'package:daily_diary/screens/home.dart';
import 'package:flutter/material.dart';

import 'package:daily_diary/main.dart';
import 'package:daily_diary/backend_classes/localization.dart';
import 'package:daily_diary/backend_classes/path.dart';
import 'package:daily_diary/backend_classes/storage.dart';
import 'package:daily_diary/screens/view_only.dart';

Expand All @@ -13,18 +12,17 @@ class PreviousEntriesScreen extends StatelessWidget {
final entries = PreviousEntriesStorage(savePath!);

Widget _listBuilder(context, AsyncSnapshot<List<EntryFile>> snapshot) {
List<EntryFile>? datesList = snapshot.data;
if (datesList == null) {
List<EntryFile>? entryFiles = snapshot.data;
if (entryFiles == null) {
return const Scaffold();
}
if (datesList.isEmpty) {
if (entryFiles.isEmpty) {
return const NoEntriesYet();
}
return ListView.builder(
itemCount: datesList.length,
itemBuilder: (_, index) => PreviousEntry(
file: datesList[index],
),
List<Widget> entryWidgets =
entryFiles.map((e) => PreviousEntry(file: e)).toList();
return ListView(
children: entryWidgets,
);
}

Expand All @@ -50,26 +48,28 @@ class PreviousEntry extends StatelessWidget {

final EntryFile file;

void onPressed(BuildContext context, String humanDate) {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) {
return ViewOnlyScreen(title: humanDate, entryFile: file);
},
),
);
}

@override
Widget build(BuildContext context) {
DateTime date = file.entryDate;
if (date.isSameDate(DateTime.now())) {
return Container();
}
final String humanDate = locale(context).entryDate(date);

return ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) {
return ViewOnlyScreen(title: humanDate, entryFile: file);
},
),
);
},
onPressed: () => onPressed(context, humanDate),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.background,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
child: SizedBox(
width: double.infinity,
Expand Down
7 changes: 5 additions & 2 deletions lib/widgets/quit_handler.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';

import 'package:daily_diary/backend_classes/localization.dart';
Expand All @@ -8,12 +9,13 @@ import 'package:flutter_window_close/flutter_window_close.dart';
/// On mobile using this class will have no effect
class QuitHandler {
static void enable(BuildContext context, void Function() saveAndQuit) {
if (Platform.isAndroid || Platform.isIOS) return;
FlutterWindowClose.setWindowShouldCloseHandler(
() => show(context, saveAndQuit),
() => _show(context, saveAndQuit),
);
}

static Future<bool> show(
static Future<bool> _show(
BuildContext context,
void Function() saveAndQuit,
) async {
Expand Down Expand Up @@ -54,6 +56,7 @@ class UnsavedChangesAlert extends StatelessWidget {
}

static void disable() {
if (Platform.isAndroid || Platform.isIOS) return;
FlutterWindowClose.setWindowShouldCloseHandler(() async => true);
}

Expand Down
16 changes: 16 additions & 0 deletions lib/widgets/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@ class Themes {

final Color colorSeed;

ThemeData get _baseLightTheme => ThemeData(
colorSchemeSeed: colorSeed,
brightness: Brightness.light,
);

ThemeData get _baseDarkTheme => ThemeData(
colorSchemeSeed: colorSeed,
brightness: Brightness.dark,
);

ThemeData get lightTheme => ThemeData(
colorSchemeSeed: colorSeed,
brightness: Brightness.light,
appBarTheme: AppBarTheme(
backgroundColor: _baseLightTheme.colorScheme.inversePrimary,
),
);

ThemeData get darkTheme => ThemeData(
colorSchemeSeed: colorSeed,
brightness: Brightness.dark,
appBarTheme: AppBarTheme(
backgroundColor: _baseDarkTheme.colorScheme.inversePrimary,
),
);
}
3 changes: 3 additions & 0 deletions metadata/en-GB/changelogs/15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
‣ Switch to material 3 (but change the code to make it look mostly like material 2)
‣ Fix bug where the app does not save if you close by swiping up (thanks @mgolden356)
‣ Fix bug where it deletes a note if you exit too fast (thanks again @mgolden356)
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed metadata/en-GB/images/phoneScreenshots/4 Empty.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 416aa61

Please sign in to comment.