Skip to content

Commit

Permalink
Merge pull request #2 from maelchiotti/dev
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
maelchiotti authored Feb 10, 2024
2 parents 0990559 + a58059a commit 2d445a5
Show file tree
Hide file tree
Showing 25 changed files with 117 additions and 33 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

Simple, local, material design notes.

<div align="center">
<img alt="Screenshot of the notes list" src="assets/screenshots/notes.jpg" width="30%">
<img alt="Screenshots of the note editor" src="assets/screenshots/editor.jpg" width="30%">
<img alt="Screenshot of the bin" src="assets/screenshots/bin.jpg" width="30%">
</div>

## Features

### Take notes
Expand Down Expand Up @@ -40,6 +46,10 @@ Simple, local, material design notes.
- Choose if you want your theme to be dynamic (use colors from your system, if supported)
- Choose your language (see the [supported ones](#supported-languages))

## Screenshots

See more screenshots [here](assets/screenshots).

## Supported languages

- English: 100%
Expand Down
50 changes: 50 additions & 0 deletions assets/data/data_screenshots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"deleted": false,
"pinned": true,
"created_time": "2024-02-08T19:38:47.174208",
"edited_time": "2024-02-08T19:52:18.551315",
"title": "Welcome to Material Notes",
"content": "[{\"insert\":\"Simple, local, material design notes\\n\\n\"}]"
},
{
"deleted": false,
"pinned": false,
"created_time": "2024-02-08T19:42:36.799343",
"edited_time": "2024-02-08T19:48:24.809869",
"title": "Share & backup",
"content": "[{\"insert\":\"Share text to create a note\\nShare notes as text\\nBackup notes as JSON\\n\"}]"
},
{
"deleted": true,
"pinned": false,
"created_time": "2024-02-08T19:51:24.586171",
"edited_time": "2024-02-08T19:51:44.551382",
"title": "Recover notes from the bin !",
"content": "[{\"insert\":\"\\n\"}]"
},
{
"deleted": false,
"pinned": false,
"created_time": "2024-02-08T19:43:32.194535",
"edited_time": "2024-02-08T19:48:20.806446",
"title": "Customize",
"content": "[{\"insert\":\"Choose your theme (including black)\\nUse a dynamic theme\\nChoose your language\\n\"}]"
},
{
"deleted": false,
"pinned": false,
"created_time": "2024-02-08T19:39:47.595979",
"edited_time": "2024-02-08T19:48:56.383382",
"title": "Take notes",
"content": "[{\"insert\":\"Write text notes (title + content)\"},{\"insert\":\"\\n\",\"attributes\":{\"block\":\"cl\",\"checked\":true}},{\"insert\":\"Add checklists\"},{\"insert\":\"\\n\",\"attributes\":{\"block\":\"cl\"}},{\"insert\":\"Use quick action to add from your homescreen\"},{\"insert\":\"\\n\",\"attributes\":{\"block\":\"cl\",\"checked\":true}}]"
},
{
"deleted": false,
"pinned": false,
"created_time": "2024-02-08T19:41:27.742611",
"edited_time": "2024-02-08T19:48:30.195413",
"title": "Organize",
"content": "[{\"insert\":\"Search\\nPin & recover from the bin\\nSort (date or title, ascending or descending)\\n\"}]"
}
]
Binary file added assets/screenshots/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/bin_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/dynamic_theming_black.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/dynamic_theming_dark.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/dynamic_theming_light.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/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 added assets/screenshots/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/light.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/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/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/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 added assets/screenshots/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/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/sort.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Future<void> main() async {
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();

SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
),
);

FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);

Expand Down
4 changes: 1 addition & 3 deletions lib/models/note/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import 'package:equatable/equatable.dart';
import 'package:fleather/fleather.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:uuid/uuid.dart';
import 'package:localmaterialnotes/utils/constants/constants.dart';

part 'note.g.dart';

// ignore_for_file: must_be_immutable

const uuid = Uuid();

@JsonSerializable()
@Collection(inheritance: false)
class Note extends Equatable {
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 @@ -69,6 +69,7 @@ class _EditorState extends ConsumerState<EditorPage> {
TextField(
readOnly: widget.readOnly,
autofocus: widget.autofocus,
textCapitalization: TextCapitalization.sentences,
textInputAction: TextInputAction.next,
style: Theme.of(context).textTheme.titleLarge,
decoration: InputDecoration.collapsed(
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_settings_ui/flutter_settings_ui.dart';
import 'package:locale_names/locale_names.dart';
import 'package:localmaterialnotes/pages/settings/interactions.dart';
import 'package:localmaterialnotes/utils/constants/constants.dart';
import 'package:localmaterialnotes/utils/constants/paddings.dart';
import 'package:localmaterialnotes/utils/extensions/string_extension.dart';
import 'package:localmaterialnotes/utils/info_manager.dart';
import 'package:localmaterialnotes/utils/preferences/confirmations.dart';
Expand All @@ -24,6 +25,7 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
Widget build(BuildContext context) {
return SettingsList(
platform: DevicePlatform.android,
contentPadding: Paddings.custom.bottomSystemUi,
lightTheme: SettingsThemeData(
settingsListBackground: Theme.of(context).colorScheme.background,
),
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/constants/constants.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:localmaterialnotes/l10n/app_localizations.g.dart';
import 'package:localmaterialnotes/utils/theme_manager.dart';
import 'package:uuid/uuid.dart';

final themeModeNotifier = ValueNotifier(ThemeManager().themeMode);
final dynamicThemingNotifier = ValueNotifier(ThemeManager().useDynamicTheming);
Expand All @@ -10,3 +11,5 @@ final navigatorKey = GlobalKey<NavigatorState>(debugLabel: 'Root navigator key')
final drawerKey = GlobalKey<ScaffoldState>(debugLabel: 'Drawer key');

final localizations = AppLocalizations.of(navigatorKey.currentContext!)!;

const uuid = Uuid();
15 changes: 3 additions & 12 deletions lib/utils/constants/paddings.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:localmaterialnotes/utils/constants/constants.dart';

enum Paddings {
custom(0),
Expand Down Expand Up @@ -26,24 +27,14 @@ enum Paddings {

EdgeInsets get bottom => EdgeInsets.only(bottom: _padding);

EdgeInsets get fab => const EdgeInsets.only(bottom: kFloatingActionButtonMargin + 64);
EdgeInsets get bottomSystemUi => EdgeInsets.only(bottom: MediaQuery.of(navigatorKey.currentContext!).padding.bottom);

EdgeInsets get miniFab => const EdgeInsets.only(bottom: kFloatingActionButtonMargin + 48);
EdgeInsets get fab => const EdgeInsets.only(bottom: kFloatingActionButtonMargin + 64);

EdgeInsets get page => const EdgeInsets.all(16);

EdgeInsets get pageButBottom => const EdgeInsets.only(top: 16, left: 16, right: 16);

EdgeInsets get pageHorizontal => const EdgeInsets.symmetric(horizontal: 16);

EdgeInsets get pageVertical => const EdgeInsets.symmetric(vertical: 16);

EdgeInsets get drawer => const EdgeInsets.all(8);

EdgeInsets get editorDesktop => const EdgeInsets.all(16);

EdgeInsets get editorMobile => const EdgeInsets.all(4);

EdgeInsets get appBarActionsEnd => const EdgeInsets.only(right: 8);

final double _padding;
Expand Down
49 changes: 32 additions & 17 deletions lib/utils/database_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:is_first_run/is_first_run.dart';
import 'package:isar/isar.dart';
import 'package:localmaterialnotes/models/note/note.dart';
import 'package:localmaterialnotes/utils/constants/constants.dart';
Expand All @@ -20,24 +21,38 @@ class DatabaseManager {

DatabaseManager._internal();

String databaseName = 'materialnotes';
late String databaseDirectory;
late Isar database;
final _databaseName = 'materialnotes';
late String _databaseDirectory;
late Isar _database;

final _welcomeNote = Note(
id: uuid.v4(),
deleted: false,
pinned: true,
createdTime: DateTime.now(),
editedTime: DateTime.now(),
title: 'Welcome to Material Notes',
content: '[{"insert":"Simple, local, material design notes\\n\\n"}]',
);

Future<void> init() async {
databaseDirectory = (await getApplicationDocumentsDirectory()).path;
database = await Isar.open(
_databaseDirectory = (await getApplicationDocumentsDirectory()).path;
_database = await Isar.open(
[NoteSchema],
name: databaseName,
directory: databaseDirectory,
name: _databaseName,
directory: _databaseDirectory,
);

if (await IsFirstRun.isFirstCall()) {
await add(_welcomeNote);
}
}

Future<List<Note>> getAll({bool deleted = false}) async {
final sortMethod = SortMethod.methodFromPreferences();
final sortAscending = SortMethod.ascendingFromPreferences;

final sortedByPinned = database.notes.where().deletedEqualTo(deleted).sortByPinnedDesc();
final sortedByPinned = _database.notes.where().deletedEqualTo(deleted).sortByPinnedDesc();

switch (sortMethod) {
case SortMethod.date:
Expand All @@ -54,14 +69,14 @@ class DatabaseManager {
}

Future<void> add(Note note) async {
await database.writeTxn(() async {
await database.notes.put(note);
await _database.writeTxn(() async {
await _database.notes.put(note);
});
}

Future<void> addAll(List<Note> notes) async {
await database.writeTxn(() async {
await database.notes.putAll(notes);
await _database.writeTxn(() async {
await _database.notes.putAll(notes);
});
}

Expand All @@ -70,14 +85,14 @@ class DatabaseManager {
}

Future<void> delete(Id id) async {
await database.writeTxn(() async {
await database.notes.delete(id);
await _database.writeTxn(() async {
await _database.notes.delete(id);
});
}

Future<void> deleteAll() async {
await database.writeTxn(() async {
await database.notes.where().deletedEqualTo(true).deleteAll();
await _database.writeTxn(() async {
await _database.notes.where().deletedEqualTo(true).deleteAll();
});
}

Expand All @@ -91,7 +106,7 @@ class DatabaseManager {
final timestamp = DateTime.timestamp();
final exportFile = File('$exportDirectory/materialnotes_export_${timestamp.filename}.json');

final notes = await database.notes.where().findAll();
final notes = await _database.notes.where().findAll();
final notesJson = jsonEncode(notes);
await exportFile.writeAsString(notesJson);
}
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
is_first_run:
dependency: "direct main"
description:
name: is_first_run
sha256: "344d9783cbce7b9b90c45b398f85afa1c4a13bb26dcc726d1ee2ec873c8b9b8b"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
isar:
dependency: "direct main"
description:
Expand Down
3 changes: 2 additions & 1 deletion 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.0.0
version: 1.0.1
publish_to: none

environment:
Expand All @@ -27,6 +27,7 @@ dependencies:
flutter_settings_ui: ^3.0.0
go_router: ^13.1.0
intl: ^0.18.1
is_first_run: ^1.0.0
isar: ^3.1.0+1
isar_flutter_libs: ^3.1.0+1
json_annotation: ^4.8.1
Expand Down

0 comments on commit 2d445a5

Please sign in to comment.