Skip to content

Commit

Permalink
Release v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Voklen committed Nov 12, 2023
2 parents b5ab146 + e2d1ec3 commit d840928
Show file tree
Hide file tree
Showing 29 changed files with 535 additions and 331 deletions.
32 changes: 7 additions & 25 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
prefer_single_quotes: true
3 changes: 3 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arb-dir: lib/localizations
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
4 changes: 2 additions & 2 deletions lib/backend_classes/filenames.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class Filename {
}

static String _twoDigits(int n) {
if (n >= 10) return "$n";
return "0$n";
if (n >= 10) return '$n';
return '0$n';
}

static DateTime? filenameToDate(String filename) {
Expand Down
14 changes: 14 additions & 0 deletions lib/backend_classes/localization.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

/// Gets the `AppLocalizations` of the context, must only be called within a
/// app with `localizationsDelegates` or will crash. This is used for obtaining
/// a string that is in the language of the current context.
///
/// Example:
/// ```dart
/// Text(locale(context).helloWorld)
/// ```
AppLocalizations locale(BuildContext context) {
return AppLocalizations.of(context)!;
}
4 changes: 3 additions & 1 deletion lib/backend_classes/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:shared_storage/shared_storage.dart';
class SavePath {
// Due to the constructors only one can ever be null at any time
const SavePath.normal(String this.path) : uri = null;

const SavePath.android(Uri this.uri) : path = null;

final String? path;
Expand Down Expand Up @@ -66,7 +67,8 @@ Future<SavePath> getPath() async {
bool? isAndroidScoped = preferences.getBool('is_android_scoped');
if (path != null) {
if (isAndroidScoped == true) {
DocumentFile document = DocumentFile.fromMap(json.decode(path));
final map = json.decode(path) as Map<String, dynamic>;
DocumentFile document = DocumentFile.fromMap(map);
return SavePath.android(document.uri);
}
return SavePath.normal(path);
Expand Down
9 changes: 5 additions & 4 deletions lib/backend_classes/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SettingsStorage {
return TomlDocument.load(_file);
}

Future<dynamic> _getFromFile(key) async {
Future<dynamic> _getFromFile(String key) async {
try {
final map = await settingsMap;
return map[key];
Expand Down Expand Up @@ -134,7 +134,8 @@ class SettingsStorage {
}

Future<Color?> getColorScheme() async {
String hex = await _getFromFile('color_scheme') ?? "";
final dynamic hex = await _getFromFile('color_scheme');
if (hex is! String) return null;
return HexColor.fromHex(hex);
}

Expand All @@ -161,7 +162,7 @@ class SettingsStorage {
await _writeToFile('date_format', dateFormat);
}

Future<void> _writeToFile(key, value) async {
Future<void> _writeToFile(String key, dynamic value) async {
var map = await settingsMap;
map[key] = value;
settingsMap = Future(() => map);
Expand Down Expand Up @@ -269,7 +270,7 @@ class PreviousEntryStorage {
final contents = await file.readAsString();
return contents;
} catch (error) {
return "";
return '';
}
}

Expand Down
84 changes: 84 additions & 0 deletions lib/localizations/app_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"startTyping": "Start typing…",
"@startTyping": {
"description": "Hint text on a black entry"
},
"previousEntries": "Previous Entries",
"@previousEntries": {
"description": "Previous Entries page title"
},
"entryDate": "{date}",
"@entryDate": {
"description": "A date for a previous entry",
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMMMd"
}
}
},
"settings": "Settings",
"@settings": {
"description": "Settings page title"
},
"theme": "Theme",
"@theme": {
"description": "Label for theme setting"
},
"lightTheme": "Light",
"@lightTheme": {
"description": "Label for light theme option"
},
"systemTheme": "System",
"@systemTheme": {
"description": "Label for system theme option"
},
"darkTheme": "Dark",
"@darkTheme": {
"description": "Label for dark theme option"
},
"fontSize": "Font size",
"@fontSize": {
"description": "Label for font size setting"
},
"checkSpelling": "Check spelling",
"@checkSpelling": {
"description": "Label for spell checking setting"
},
"colorScheme": "Color scheme",
"@colorScheme": {
"description": "Label for color scheme setting"
},
"filenameFormat": "Filename format",
"@filenameFormat": {
"description": "Label for filename format setting"
},
"changeSaveFolder": "Change path to save folder",
"@changeSaveFolder": {
"description": "Button to change save folder"
},
"exportEntries": "Export diary entries",
"@exportEntries": {
"description": "Button to export previous entries"
},
"resetSettings": "Reset settings (individually selectable)",
"@resetSettings": {
"description": "Button to reset settings"
},
"cancel": "Cancel",
"@cancel": {
"description": "Cancel action"
},
"unsavedChanges": "You have unsaved changes",
"@unsavedChanges": {
"description": "Dialog when attempting to close with unsaved changes on desktop"
},
"save": "Save",
"@save": {
"description": "Button to save changes"
},
"discardChanges": "Don't save",
"@discardChanges": {
"description": "Button to discard changes"
}
}
21 changes: 21 additions & 0 deletions lib/localizations/app_es.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"startTyping": "Empezar a escribir…",
"previousEntries": "Entradas Anteriores",
"entryDate": "{date}",
"settings": "Ajustes",
"theme": "Tema de colores",
"lightTheme": "Claro",
"systemTheme": "Automático",
"darkTheme": "Oscuro",
"fontSize": "Tamaño de fuente",
"checkSpelling": "Revisar la ortografía",
"colorScheme": "Color de la aplicación",
"filenameFormat": "Formato de nombre de archivo",
"changeSaveFolder": "Cambiar la ruta a la carpeta para guardar datos",
"exportEntries": "Exportar entradas del diario",
"resetSettings": "Reiniciar ajustes",
"cancel": "Cancelar",
"unsavedChanges": "Tiene cambios sin guardar",
"save": "Guardar cambios",
"discardChanges": "Descartar"
}
21 changes: 21 additions & 0 deletions lib/localizations/app_ru.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"startTyping": "Введите текст…",
"previousEntries": "Предыдущий Записи",
"entryDate": "{date}",
"settings": "Настройки",
"theme": "Тема",
"lightTheme": "Светлая",
"systemTheme": "По умолчанию",
"darkTheme": "Тёмная",
"fontSize": "Размер шрифта",
"checkSpelling": "Проверять орфографию",
"colorScheme": "Цвет приложения",
"filenameFormat": "Формат имени файла",
"changeSaveFolder": "Изменить путь к папке сохранения данных",
"exportEntries": "Экспортировать записи ежедневника",
"resetSettings": "Восстановить настройки по умолчанию (выбор для каждой настройки)",
"cancel": "Отменить",
"unsavedChanges": "У вас есть несохраненные изменения",
"save": "Сохранять",
"discardChanges": "Не сохранять"
}
12 changes: 9 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:daily_diary/backend_classes/storage.dart';
import 'package:daily_diary/widgets/themes.dart';
import 'package:daily_diary/screens/home.dart';

import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';

// This will be removed when widgets can react to spell check changes
Expand All @@ -14,7 +15,7 @@ bool? startupCheckSpelling;
SavePath? savePath;
SavePath? newSavePath;

main() async {
void main() async {
await loadSettings();
runApp(const App());
}
Expand All @@ -35,7 +36,7 @@ Future<void> loadSettings() async {
}

class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
const App({super.key});

static final settingsNotifier = SettingsNotifier(savePath!);
static final preferences = SharedPreferences.getInstance();
Expand All @@ -52,8 +53,13 @@ class App extends StatelessWidget {
darkTheme: theme.darkTheme,
themeMode: currentSettings.theme,
home: HomePage(
storage: DiaryStorage(savePath!),
child: EntryEditor(
storage: DiaryStorage(savePath!),
settings: currentSettings,
),
),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
);
},
);
Expand Down
Loading

0 comments on commit d840928

Please sign in to comment.