Skip to content

Commit

Permalink
Merge pull request #4 from maelchiotti/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
maelchiotti authored Feb 18, 2024
2 parents 2d445a5 + 75cb9cb commit 640b7be
Show file tree
Hide file tree
Showing 30 changed files with 731 additions and 324 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.1.0 - 2024-02-18

### Added

- Authentication on application launch
- Add tagline and about text in the info section of the settings

### Changed

- Revert to using default page transitions
- Automatically restart the app when changing the language

### Fixed

- Localize the welcome note
- Going back from the editor after adding a note from the quick action when the editor was already opened on an other note correctly goes back to the notes list

## 1.0.1 - 2024-02-10

### Added

- Welcome note when first launching the app

### Fixed

- System navigation bar transparency and the padding at the bottom of the settings page

## 1.0.0 - 2024-02-07

Initial release.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.maelchiotti.localmaterialnotes

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity : FlutterActivity() {
class MainActivity : FlutterFragmentActivity() {
}
1 change: 1 addition & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ arb-dir: lib/l10n
template-arb-file: app_en.arb
synthetic-package: false
use-escaping: true
format: true
output-localization-file: app_localizations.g.dart
untranslated-messages-file: lib/l10n/untranslated.txt
21 changes: 21 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import 'dart:async';

import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:localmaterialnotes/common/routing/router.dart';
import 'package:localmaterialnotes/l10n/app_localizations.g.dart';
import 'package:localmaterialnotes/pages/authentication/authentication_page.dart';
import 'package:localmaterialnotes/utils/constants/constants.dart';
import 'package:localmaterialnotes/utils/locale_manager.dart';
import 'package:localmaterialnotes/utils/preferences/lock_latency.dart';
import 'package:localmaterialnotes/utils/preferences/preference_key.dart';
import 'package:localmaterialnotes/utils/preferences/preferences_manager.dart';
import 'package:localmaterialnotes/utils/share_manager.dart';
import 'package:localmaterialnotes/utils/theme_manager.dart';

Expand Down Expand Up @@ -64,6 +69,22 @@ class _AppState extends ConsumerState<App> {
locale: LocaleManager().locale,
routerConfig: router,
debugShowCheckedModeBanner: false,
builder: (_, child) {
final lockPreference = PreferencesManager().get<bool>(PreferenceKey.lock);
final lock = lockPreference ?? PreferenceKey.lock.defaultValue! as bool;

final lockLatencyPreference = PreferencesManager().get<String>(PreferenceKey.lockLatency);
final lockLatency = lockLatencyPreference != null
? LockLatency.values.byName(lockLatencyPreference)
: PreferenceKey.lockLatency.defaultValue! as LockLatency;

return AppLock(
builder: (_, __) => child!,
lockScreenBuilder: (_) => const AuthenticationPage(),
enabled: lock,
backgroundLockLatency: Duration(minutes: lockLatency.minutes),
);
},
);
},
);
Expand Down
18 changes: 9 additions & 9 deletions lib/common/actions/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Future<void> addNote(BuildContext context, WidgetRef ref, {String? content}) asy
ref.read(currentNoteProvider.notifier).set(note);
await ref.read(notesProvider.notifier).add(note);

if (context.mounted) {
context.push(
RouterRoute.editor.fullPath!,
extra: EditorParameters.from({
'readonly': false,
'autofocus': true,
}),
);
}
if (!context.mounted) return;

final route = RouterRoute.editor.fullPath!;
final editorParameters = EditorParameters.from({'readonly': false, 'autofocus': true});

// If the editor is already opened with another note, replace the route with the new editor
RouterRoute.isEditor
? context.pushReplacement(route, extra: editorParameters)
: context.push(route, extra: editorParameters);
}
10 changes: 5 additions & 5 deletions lib/common/actions/delete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Future<bool> deleteNote(BuildContext context, WidgetRef ref, Note? note) async {
if (note == null) return false;

if (await showConfirmationDialog(
false,
context,
localizations.dialog_delete,
localizations.dialog_delete_body_single,
localizations.dialog_delete,
irreversible: false,
)) {
ref.read(currentNoteProvider.notifier).reset();
await ref.read(notesProvider.notifier).delete(note);
Expand All @@ -34,11 +34,11 @@ Future<bool> deleteNote(BuildContext context, WidgetRef ref, Note? note) async {

Future<void> deleteNotes(BuildContext context, WidgetRef ref, List<Note> notes) async {
if (await showConfirmationDialog(
false,
context,
localizations.dialog_delete,
localizations.dialog_delete_body(notes.length),
localizations.dialog_delete,
irreversible: false,
)) {
for (final note in notes) {
await ref.read(notesProvider.notifier).delete(note);
Expand All @@ -50,11 +50,11 @@ Future<bool> permanentlyDeleteNote(BuildContext context, WidgetRef ref, Note? no
if (note == null) return false;

if (await showConfirmationDialog(
true,
context,
localizations.dialog_permanently_delete,
localizations.dialog_permanently_delete_body_single,
localizations.dialog_permanently_delete,
irreversible: true,
)) {
ref.read(currentNoteProvider.notifier).reset();
await ref.read(binProvider.notifier).permanentlyDelete(note);
Expand All @@ -71,11 +71,11 @@ Future<bool> permanentlyDeleteNote(BuildContext context, WidgetRef ref, Note? no

Future<void> permanentlyDeleteNotes(BuildContext context, WidgetRef ref, List<Note> notes) async {
if (await showConfirmationDialog(
true,
context,
localizations.dialog_permanently_delete,
localizations.dialog_permanently_delete_body(notes.length),
localizations.dialog_permanently_delete,
irreversible: true,
)) {
for (final note in notes) {
await ref.read(binProvider.notifier).permanentlyDelete(note);
Expand All @@ -85,11 +85,11 @@ Future<void> permanentlyDeleteNotes(BuildContext context, WidgetRef ref, List<No

Future<void> emptyBin(BuildContext context, WidgetRef ref) async {
if (await showConfirmationDialog(
true,
context,
localizations.dialog_empty_bin,
localizations.dialog_empty_bin_body,
localizations.dialog_empty_bin,
irreversible: true,
)) {
await ref.read(binProvider.notifier).empty();

Expand Down
4 changes: 2 additions & 2 deletions lib/common/actions/restore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Future<bool> restoreNote(BuildContext context, WidgetRef ref, Note? note) async
if (note == null) return false;

if (await showConfirmationDialog(
false,
context,
localizations.dialog_restore,
localizations.dialog_restore_body_single,
localizations.dialog_restore,
irreversible: false,
)) {
ref.read(currentNoteProvider.notifier).reset();
await ref.read(binProvider.notifier).restore(note);
Expand All @@ -32,11 +32,11 @@ Future<bool> restoreNote(BuildContext context, WidgetRef ref, Note? note) async

Future<void> restoreNotes(BuildContext context, WidgetRef ref, List<Note> notes) async {
if (await showConfirmationDialog(
false,
context,
localizations.dialog_restore,
localizations.dialog_restore_body(notes.length),
localizations.dialog_restore,
irreversible: false,
)) {
for (final note in notes.where((note) => note.selected)) {
await ref.read(binProvider.notifier).restore(note);
Expand Down
16 changes: 9 additions & 7 deletions lib/common/dialogs/confirmation_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import 'package:localmaterialnotes/utils/constants/constants.dart';
import 'package:localmaterialnotes/utils/preferences/confirmations.dart';

Future<bool> showConfirmationDialog(
bool irreversible,
BuildContext context,
String title,
String body,
String confirmText,
) async {
final confirmationsSetting = Confirmations.fromPreferences();
if (confirmationsSetting == Confirmations.none ||
(confirmationsSetting == Confirmations.irreversible && !irreversible)) {
return true;
String confirmText, {
bool? irreversible,
}) async {
if (irreversible != null) {
final confirmationsSetting = Confirmations.fromPreferences();
if (confirmationsSetting == Confirmations.none ||
(confirmationsSetting == Confirmations.irreversible && !irreversible)) {
return true;
}
}

return await showAdaptiveDialog<bool>(
Expand Down
34 changes: 4 additions & 30 deletions lib/common/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ import 'package:localmaterialnotes/utils/constants/constants.dart';

typedef EditorParameters = Map<String, bool>?;

CustomTransitionPage _getCustomTransitionPage<T>(GoRouterState state, Widget child) {
return CustomTransitionPage<T>(
key: state.pageKey,
child: child,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(opacity: animation, child: child);
},
);
}

Page<dynamic> Function(BuildContext, GoRouterState) _defaultPageBuilder<T>(Widget child) {
return (BuildContext context, GoRouterState state) {
return _getCustomTransitionPage(state, child);
};
}

PreferredSizeWidget? _getAppBar(BuildContext context) {
switch (RouterRoute.currentRoute) {
case RouterRoute.notes:
Expand Down Expand Up @@ -71,31 +55,21 @@ final router = GoRouter(
routes: [
GoRoute(
path: RouterRoute.notes.path,
pageBuilder: _defaultPageBuilder(const NotesPage()),
builder: (context, state) => const NotesPage(),
routes: [
GoRoute(
path: RouterRoute.editor.path,
pageBuilder: (context, state) {
final parameters = state.extra as EditorParameters;

return _getCustomTransitionPage(
state,
EditorPage(
readOnly: parameters?['readonly'] ?? false,
autofocus: parameters?['autofocus'] ?? false,
),
);
},
builder: (context, state) => EditorPage(state.extra as EditorParameters),
),
],
),
GoRoute(
path: RouterRoute.bin.path,
pageBuilder: _defaultPageBuilder(const BinPage()),
builder: (context, state) => const BinPage(),
),
GoRoute(
path: RouterRoute.settings.path,
pageBuilder: _defaultPageBuilder(const SettingsPage()),
builder: (context, state) => const SettingsPage(),
),
],
),
Expand Down
2 changes: 2 additions & 0 deletions lib/common/routing/router_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ enum RouterRoute {
}

static bool get isBin => RouterRoute.currentRoute == RouterRoute.bin;

static bool get isEditor => RouterRoute.currentRoute == RouterRoute.editor;
}
5 changes: 1 addition & 4 deletions lib/common/widgets/note_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ class _NoteTileState extends ConsumerState<NoteTile> {

context.push(
RouterRoute.editor.fullPath!,
extra: EditorParameters.from({
'readonly': widget.note.deleted,
'autofocus': false,
}),
extra: EditorParameters.from({'readonly': widget.note.deleted, 'autofocus': false}),
);

if (widget.searchView) context.pop();
Expand Down
Loading

0 comments on commit 640b7be

Please sign in to comment.