Skip to content

Commit

Permalink
Improvements (#10)
Browse files Browse the repository at this point in the history
* fix: "import" strings in french

* fix: small improvements to routes

* refactor: clean app/build.gradle

* fix: Kotlin plugin import

* feat: use floating snack bars

* fix: decode imported file as UTF-8

* fix: use launchUrl instead of launchUrlString whenever possible

* fix: padding at bottom of editor

* chore: upgrade fleather version

* fix: remove drawer on editor page

* feat: use radio buttons where appropriate in settings dialogs

* chore: bump app version

* docs: remake screenshots

* docs: add screenshots to README
  • Loading branch information
maelchiotti authored Mar 31, 2024
1 parent df62624 commit 799397e
Show file tree
Hide file tree
Showing 38 changed files with 102 additions and 72 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ Simple, local, material design notes.
<img alt="Screenshot of the settings" src="assets/screenshots/latest_settings_1.jpg" width="24%">
</div>

<div align="center">
<img alt="Screenshot of the notes list" src="assets/screenshots/latest_notes_selection.jpg" width="24%">
<img alt="Screenshots of the note editor" src="assets/screenshots/latest_search.jpg" width="24%">
<img alt="Screenshot of the bin" src="assets/screenshots/latest_theme_dynamic_dark.jpg" width="24%">
<img alt="Screenshot of the settings" src="assets/screenshots/latest_theme_dynamic_light.jpg" width="24%">
</div>

## Features

### Take notes
Expand Down
12 changes: 0 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.23" apply false
}

include ":app"
Binary file modified assets/screenshots/latest_bin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/latest_editor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/latest_notes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/latest_notes_selection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/latest_search.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/latest_settings_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/latest_theme_dynamic_dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 assets/screenshots/v1.0.0_bin_selection.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_dynamic_theming_black.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_dynamic_theming_dark.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_dynamic_theming_light.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_editor_about.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_light.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_notes_selection.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_search.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_settings_2.jpg
Binary file not shown.
Binary file removed assets/screenshots/v1.0.0_sort.jpg
Binary file not shown.
Binary file added assets/screenshots/v1.1.2_editor_about.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/v1.1.2_selection_bin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/v1.1.2_settings_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/v1.1.2_sort.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/v1.1.2_theme_light.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions lib/common/navigation/side_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ class SideNavigation extends StatefulWidget {
}

class _SideNavigationState extends State<SideNavigation> {
int index = RouterRoute.currentDrawerIndex;
int _index = RouterRoute.currentDrawerIndex;

void _navigate(int newIndex) {
setState(() {
index = newIndex;
_index = newIndex;
});

context.go(RouterRoute.getRouteFromIndex(index).path);
context.go(RouterRoute.getRouteFromIndex(_index).path);
context.pop();
}

@override
Widget build(BuildContext context) {
return NavigationDrawer(
onDestinationSelected: _navigate,
selectedIndex: index,
selectedIndex: _index,
children: <Widget>[
DrawerHeader(
child: Column(
Expand Down
8 changes: 7 additions & 1 deletion lib/common/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ PreferredSizeWidget? _getAppBar(BuildContext context) {
}
}

Widget? _getDrawer() {
if (RouterRoute.currentRoute.drawerIndex == null) return null;

return const SideNavigation();
}

Widget? _getFloatingActionButton(BuildContext context) {
switch (RouterRoute.currentRoute) {
case RouterRoute.notes:
Expand All @@ -47,7 +53,7 @@ final router = GoRouter(
return Scaffold(
key: drawerKey,
appBar: _getAppBar(context),
drawer: const SideNavigation(),
drawer: _getDrawer(),
body: child,
floatingActionButton: _getFloatingActionButton(context),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/routing/router_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum RouterRoute {
} else if (location == settings.path) {
return settings;
} else {
return notes;
throw Exception('Unexpected route: $location');
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"settings_export_markdown_description": "Exporter les notes dans un fichier Markdown (corbeille incluse)",
"settings_export_success": "Les notes ont bien été exportées.",
"settings_export_fail": "L''export a échoué : {error}.",
"settings_import": "Import",
"settings_import_description": "Importer les notes depuis un fichier",
"settings_import": "Importer",
"settings_import_description": "Importer les notes depuis un fichier JSON",
"settings_import_success": "Les notes ont bien été importées.",
"settings_import_fail": "L''import a échoué : {error}.",
"settings_about": "À propos",
Expand Down
4 changes: 2 additions & 2 deletions lib/l10n/app_localizations_fr.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ class AppLocalizationsFr extends AppLocalizations {
}

@override
String get settings_import => 'Import';
String get settings_import => 'Importer';

@override
String get settings_import_description => 'Importer les notes depuis un fichier';
String get settings_import_description => 'Importer les notes depuis un fichier JSON';

@override
String get settings_import_success => 'Les notes ont bien été importées.';
Expand Down
1 change: 1 addition & 0 deletions lib/pages/editor/editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class _EditorState extends ConsumerState<EditorPage> {
spellCheckConfiguration: SpellCheckConfiguration(
spellCheckService: DefaultSpellCheckService(),
),
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewPadding.bottom),
),
),
],
Expand Down
109 changes: 67 additions & 42 deletions lib/pages/settings/interactions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,35 @@ import 'package:localmaterialnotes/utils/preferences/preferences_manager.dart';
import 'package:localmaterialnotes/utils/snack_bar_manager.dart';
import 'package:localmaterialnotes/utils/theme_manager.dart';
import 'package:restart_app/restart_app.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:url_launcher/url_launcher.dart';

class Interactions {
Future<void> selectLanguage(BuildContext context) async {
await showAdaptiveDialog<Locale>(
context: context,
builder: (context) {
return SimpleDialog(
clipBehavior: Clip.hardEdge,
title: Text(localizations.settings_language),
children: AppLocalizations.supportedLocales.map((locale) {
return RadioListTile<Locale>(
value: locale,
groupValue: Localizations.localeOf(context),
title: Text(locale.nativeDisplayLanguage.capitalized),
selected: Localizations.localeOf(context) == locale,
onChanged: (locale) => Navigator.of(context).pop(locale),
);
}).toList(),
);
},
).then((locale) async {
if (locale == null) return;

LocaleManager().setLocale(locale);
await Restart.restartApp();
});
}

Future<void> selectTheme(BuildContext context) async {
await showAdaptiveDialog<ThemeMode>(
context: context,
Expand All @@ -28,23 +54,26 @@ class Interactions {
clipBehavior: Clip.hardEdge,
title: Text(localizations.settings_theme),
children: [
ListTile(
leading: const Icon(Icons.smartphone),
selected: ThemeManager().themeMode == ThemeMode.system,
RadioListTile<ThemeMode>(
value: ThemeMode.system,
groupValue: ThemeManager().themeMode,
title: Text(localizations.settings_theme_system),
onTap: () => Navigator.of(context).pop(ThemeMode.system),
selected: ThemeManager().themeMode == ThemeMode.system,
onChanged: (locale) => Navigator.of(context).pop(locale),
),
ListTile(
leading: const Icon(Icons.light_mode),
selected: ThemeManager().themeMode == ThemeMode.light,
RadioListTile<ThemeMode>(
value: ThemeMode.light,
groupValue: ThemeManager().themeMode,
title: Text(localizations.settings_theme_light),
onTap: () => Navigator.of(context).pop(ThemeMode.light),
selected: ThemeManager().themeMode == ThemeMode.light,
onChanged: (locale) => Navigator.of(context).pop(locale),
),
ListTile(
leading: const Icon(Icons.dark_mode),
selected: ThemeManager().themeMode == ThemeMode.dark,
RadioListTile<ThemeMode>(
value: ThemeMode.dark,
groupValue: ThemeManager().themeMode,
title: Text(localizations.settings_theme_dark),
onTap: () => Navigator.of(context).pop(ThemeMode.dark),
selected: ThemeManager().themeMode == ThemeMode.dark,
onChanged: (locale) => Navigator.of(context).pop(locale),
),
],
);
Expand All @@ -66,30 +95,6 @@ class Interactions {
blackThemingNotifier.value = value;
}

Future<void> selectLanguage(BuildContext context) async {
await showAdaptiveDialog<Locale>(
context: context,
builder: (context) {
return SimpleDialog(
clipBehavior: Clip.hardEdge,
title: Text(localizations.settings_language),
children: AppLocalizations.supportedLocales.map((locale) {
return ListTile(
selected: locale == Localizations.localeOf(context),
title: Text(locale.nativeDisplayLanguage.capitalized),
onTap: () => Navigator.of(context).pop(locale),
);
}).toList(),
);
},
).then((locale) async {
if (locale == null) return;

LocaleManager().setLocale(locale);
await Restart.restartApp();
});
}

void toggleSeparator(bool value) {
PreferencesManager().set<bool>(PreferenceKey.separator.name, value);
}
Expand All @@ -102,10 +107,12 @@ class Interactions {
clipBehavior: Clip.hardEdge,
title: Text(localizations.settings_confirmations),
children: Confirmations.values.map((confirmationsValue) {
return ListTile(
return RadioListTile<Confirmations>(
value: confirmationsValue,
groupValue: Confirmations.fromPreferences(),
title: Text(confirmationsValue.title),
selected: Confirmations.fromPreferences() == confirmationsValue,
onTap: () => Navigator.of(context).pop(confirmationsValue),
onChanged: (locale) => Navigator.of(context).pop(locale),
);
}).toList(),
);
Expand Down Expand Up @@ -178,14 +185,32 @@ class Interactions {
}

void openGitHub(_) {
launchUrlString('https://github.com/maelchiotti/LocalMaterialNotes');
launchUrl(
Uri(
scheme: 'https',
host: 'github.com',
path: 'maelchiotti/LocalMaterialNotes',
),
);
}

void openLicense(_) {
launchUrlString('https://github.com/maelchiotti/LocalMaterialNotes/blob/main/LICENSE');
launchUrl(
Uri(
scheme: 'https',
host: 'github.com',
path: 'maelchiotti/LocalMaterialNotes/blob/main/LICENSE',
),
);
}

void openIssues(_) {
launchUrlString('https://github.com/maelchiotti/LocalMaterialNotes/issues');
launchUrl(
Uri(
scheme: 'https',
host: 'github.com',
path: 'maelchiotti/LocalMaterialNotes/issues',
),
);
}
}
9 changes: 5 additions & 4 deletions lib/utils/database_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class DatabaseManager {
exportDirectory,
mimeType: mimeType,
displayName: 'materialnotes_export_${timestamp.filename}.$extension',
bytes: Uint8List.fromList(utf8.encode(notesAsString)), // Encode as UTF-8 to support checked/unchecked emojis
bytes: Uint8List.fromList(utf8.encode(notesAsString)),
);
}

Expand All @@ -129,11 +129,12 @@ class DatabaseManager {

if (importFiles == null || importFiles.isEmpty) throw Exception(localizations.error_permission);

final importData = await saf.getDocumentContentAsString(importFiles.first);
final importedData = await saf.getDocumentContent(importFiles.first);

if (importData == null) throw Exception(localizations.error_read_file);
if (importedData == null) throw Exception(localizations.error_read_file);

final notesJson = jsonDecode(importData) as List;
final importedString = utf8.decode(importedData);
final notesJson = jsonDecode(importedString) as List;
final notes = notesJson.map((e) => Note.fromJson(e as Map<String, dynamic>)).toList();

await addAll(notes);
Expand Down
1 change: 1 addition & 0 deletions lib/utils/snack_bar_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SnackBarManager {
void show({BuildContext? context}) {
ScaffoldMessenger.of(context ?? navigatorKey.currentContext!).showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
content: Text(text),
),
);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ packages:
dependency: "direct main"
description:
name: fleather
sha256: "4e5260e136c4d371bffd870148a838671599f08b564fd831112a9e664bd909e9"
sha256: dbff159100d700a7f27fbcc97ffb5a0bcbf4aed3e6aa932b48133aa4040fb79b
url: "https://pub.dev"
source: hosted
version: "1.14.1"
version: "1.14.2"
flutter:
dependency: "direct main"
description: flutter
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Simple, local, material design notes
repository: https://github.com/maelchiotti/LocalMaterialNotes
documentation: https://github.com/maelchiotti/LocalMaterialNotes/wiki

version: 1.1.1+4
version: 1.1.2+5
publish_to: none

environment:
Expand All @@ -15,7 +15,7 @@ dependencies:
device_info_plus: ^9.1.2
dynamic_color: ^1.6.9
equatable: ^2.0.5
fleather: ^1.14.1
fleather: ^1.14.2
flutter:
sdk: flutter
flutter_hooks: ^0.20.5
Expand Down

0 comments on commit 799397e

Please sign in to comment.