From 5f3de3a37956c861e7a473282f9c5f8b83a9901d Mon Sep 17 00:00:00 2001 From: Ali Ebadi Date: Thu, 27 Jan 2022 23:16:40 +0330 Subject: [PATCH 1/2] shamsi date added --- lib/core/utils/extension/shamsi_date.dart | 31 ++++++ lib/core/utils/extension/string.dart | 14 +++ .../theme/{theme.dart => app_theme.dart} | 0 lib/core/utils/utils.dart | 11 ++- lib/core/widgets/action_button.dart | 2 +- .../pages/notes/note_detail_screen.dart | 6 +- .../presentation/pages/notes/note_screen.dart | 10 +- .../note/presentation/widgets/note_card.dart | 97 ------------------- .../widgets/note_screen/note_card.dart | 7 +- 9 files changed, 64 insertions(+), 114 deletions(-) create mode 100644 lib/core/utils/extension/shamsi_date.dart rename lib/core/utils/theme/{theme.dart => app_theme.dart} (100%) delete mode 100644 lib/features/note/presentation/widgets/note_card.dart diff --git a/lib/core/utils/extension/shamsi_date.dart b/lib/core/utils/extension/shamsi_date.dart new file mode 100644 index 0000000..97e56b3 --- /dev/null +++ b/lib/core/utils/extension/shamsi_date.dart @@ -0,0 +1,31 @@ +import 'package:shamsi_date/shamsi_date.dart'; + +extension DateTimeEx on DateTime { + Jalali get _jalali => Jalali.fromDateTime(this); + + String get jalaliDate => + "${_jalali.day} ${_jalali.monthName} ${_jalali.year}"; + String get jalaliDateWithTime => + "${_jalali.day} ${_jalali.monthName} ${_jalali.year} ${_jalali.hour}:${_jalali.minute}"; +} + +extension JalaliEx on Jalali { + String get monthName { + final _months = [ + "فروردین", + "اردیبهشت", + "خرداد", + "تیر", + "مرداد", + "شهریور", + "مهر", + "آبان", + "آذر", + "دی", + "بهمن", + "اسفند" + ]; + + return _months[this.month - 1]; + } +} diff --git a/lib/core/utils/extension/string.dart b/lib/core/utils/extension/string.dart index 6a1321f..43435f2 100644 --- a/lib/core/utils/extension/string.dart +++ b/lib/core/utils/extension/string.dart @@ -1,3 +1,5 @@ +import 'shamsi_date.dart'; + extension StringEx on String? { bool get isEmptyString => _removeWhiteSpaces(this); @@ -9,3 +11,15 @@ extension StringEx on String? { return newStr.isEmpty; } } + +extension StringDateEx on String { + String get toJalaliDate { + final dateTime = DateTime.parse(this); + return dateTime.jalaliDate; + } + + String get toJalaliDateWithTime { + final dateTime = DateTime.parse(this); + return dateTime.jalaliDateWithTime; + } +} diff --git a/lib/core/utils/theme/theme.dart b/lib/core/utils/theme/app_theme.dart similarity index 100% rename from lib/core/utils/theme/theme.dart rename to lib/core/utils/theme/app_theme.dart diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart index 14d3aa1..b31725e 100644 --- a/lib/core/utils/utils.dart +++ b/lib/core/utils/utils.dart @@ -1,11 +1,12 @@ export 'localization.dart'; export 'constants.dart'; export 'strings.dart'; -export 'theme/colors.dart'; -export 'theme/spacing.dart'; -export 'theme/style.dart'; -export 'theme/theme.dart'; export 'extension/context.dart'; +export 'extension/map_index.dart'; export 'extension/random.dart'; +export 'extension/shamsi_date.dart'; export 'extension/string.dart'; -export 'extension/map_index.dart'; +export 'theme/app_theme.dart'; +export 'theme/colors.dart'; +export 'theme/spacing.dart'; +export 'theme/style.dart'; diff --git a/lib/core/widgets/action_button.dart b/lib/core/widgets/action_button.dart index 70e0818..1087937 100644 --- a/lib/core/widgets/action_button.dart +++ b/lib/core/widgets/action_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:simple_hive_note/core/utils/theme/theme.dart'; +import 'package:simple_hive_note/core/utils/theme/app_theme.dart'; class ActionButton extends StatelessWidget { const ActionButton({ diff --git a/lib/features/note/presentation/pages/notes/note_detail_screen.dart b/lib/features/note/presentation/pages/notes/note_detail_screen.dart index f553e18..33df0e1 100644 --- a/lib/features/note/presentation/pages/notes/note_detail_screen.dart +++ b/lib/features/note/presentation/pages/notes/note_detail_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:simple_hive_note/core/routes/app_routes.dart'; import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; import '../../../../../core/utils/utils.dart'; import '../../../../../core/widgets/widgets.dart'; @@ -31,6 +32,7 @@ class _NoteDetailScreenState extends State { @override Widget build(BuildContext context) { + final settingController = Get.find(); return GetBuilder( id: "note_detail", builder: (controller) { @@ -74,7 +76,9 @@ class _NoteDetailScreenState extends State { ), const SizedBox(height: AppSpacings.l), SelectableText( - controller.note!.dateWithTime, + settingController.currentLocale.value == "fa" + ? controller.note!.dateTime!.jalaliDateWithTime + : controller.note!.dateWithTime, style: AppTextStyle.date, ), const SizedBox(height: AppSpacings.xxl), diff --git a/lib/features/note/presentation/pages/notes/note_screen.dart b/lib/features/note/presentation/pages/notes/note_screen.dart index 1b3f49e..85754a8 100644 --- a/lib/features/note/presentation/pages/notes/note_screen.dart +++ b/lib/features/note/presentation/pages/notes/note_screen.dart @@ -9,7 +9,7 @@ import '../../../../../core/data/database_provider.dart'; import '../../../../../core/utils/utils.dart'; import '../../../../../core/widgets/widgets.dart'; import '../../controllers/note_controller.dart'; -import '../../widgets/note_card.dart'; +import '../../widgets/note_screen/note_card.dart'; class NoteScreen extends GetView { const NoteScreen({Key? key}) : super(key: key); @@ -86,14 +86,6 @@ class NoteScreen extends GetView { ); } } -// TODO: Add setting page => change theme, change language ---- Done -// TODO: Add Detail Screen => Edit Note --- Done -// TODO: Add Cancel Delete Button ----- Done -// TODO: Add Todo --- Done -// TODO: Add Remember me => Notification -// TODO: Add Choose Color => Color Pallete ----- Done -// TODO: Add Error Handling With dartz --- Done -// TODO: This is for end of application - Change to Clean architect. --- Done class _BuildNotesList extends StatelessWidget { const _BuildNotesList({Key? key, required this.controller}) : super(key: key); diff --git a/lib/features/note/presentation/widgets/note_card.dart b/lib/features/note/presentation/widgets/note_card.dart deleted file mode 100644 index 332eaaf..0000000 --- a/lib/features/note/presentation/widgets/note_card.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/material.dart'; - -import '../../../../core/utils/utils.dart'; -import '../../domain/entities/note_entity.dart'; - -class NoteCard extends StatelessWidget { - const NoteCard({ - Key? key, - required this.note, - this.selected = false, - this.onSelect, - this.onTap, - }) : super(key: key); - - final NoteEntity note; - final bool selected; - final Function()? onSelect; - final Function()? onTap; - - @override - Widget build(BuildContext context) { - return Material( - clipBehavior: Clip.antiAlias, - borderRadius: BorderRadius.circular(AppSpacings.m), - color: note.color ?? const Color(0xff5C4F45), - child: InkWell( - splashColor: Colors.black12, - onLongPress: onSelect, - onTap: onTap, - child: Container( - // constraints: const BoxConstraints( - // maxHeight: 300, - // minHeight: 100, - // ), - padding: const EdgeInsets.symmetric( - horizontal: AppSpacings.l, - vertical: AppSpacings.l, - ), - child: Stack( - children: [ - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - child: AutoSizeText( - note.title ?? '', - presetFontSizes: const [16, 14, 12, 10, 8], - textScaleFactor: 2, - softWrap: true, - style: AppTextStyle.title, - group: AutoSizeGroup(), - overflow: TextOverflow.fade, - ), - ), - const SizedBox(height: AppSpacings.m), - Text( - note.date, - style: AppTextStyle.date, - ), - ], - ), - if (selected) - Align( - alignment: Alignment.topLeft, - heightFactor: 2, - child: Container( - decoration: BoxDecoration( - color: AppColors.primary, - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - blurRadius: 10, - spreadRadius: 20, - color: note.color ?? AppColors.primary, - ), - ], - ), - child: Padding( - padding: const EdgeInsets.all(AppSpacings.m), - child: Icon( - Icons.check, - color: note.color, - size: 20, - ), - ), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/features/note/presentation/widgets/note_screen/note_card.dart b/lib/features/note/presentation/widgets/note_screen/note_card.dart index 841cebc..f8f6b1e 100644 --- a/lib/features/note/presentation/widgets/note_screen/note_card.dart +++ b/lib/features/note/presentation/widgets/note_screen/note_card.dart @@ -1,6 +1,8 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:simple_hive_note/core/utils/utils.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; import '../../../../../core/utils/utils.dart'; import '../../../domain/entities/note_entity.dart'; @@ -21,6 +23,7 @@ class NoteCard extends StatelessWidget { @override Widget build(BuildContext context) { + final settingController = Get.find(); return Material( clipBehavior: Clip.antiAlias, borderRadius: BorderRadius.circular(AppSpacings.m), @@ -58,7 +61,9 @@ class NoteCard extends StatelessWidget { ), const SizedBox(height: AppSpacings.m), Text( - note.date, + settingController.currentLocale.value == "fa" + ? note.dateTime!.jalaliDate + : note.date, style: AppTextStyle.date, ), ], From 148e64eb85f6ad88fa7daa35207a133813efd238 Mon Sep 17 00:00:00 2001 From: Ali Ebadi Date: Thu, 15 Sep 2022 11:06:52 +0430 Subject: [PATCH 2/2] Change font and add GoogleFonts --- .gitignore | 92 +- .metadata | 20 +- README.md | 32 +- analysis_options.yaml | 58 +- android/.gitignore | 26 +- android/app/build.gradle | 136 +- android/app/src/debug/AndroidManifest.xml | 14 +- android/app/src/main/AndroidManifest.xml | 68 +- .../ebdev/simple_hive_note/MainActivity.kt | 12 +- .../res/drawable-v21/launch_background.xml | 24 +- .../main/res/drawable/launch_background.xml | 24 +- .../app/src/main/res/values-night/styles.xml | 36 +- android/app/src/main/res/values/styles.xml | 36 +- android/app/src/profile/AndroidManifest.xml | 14 +- android/build.gradle | 62 +- android/gradle.properties | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 12 +- android/settings.gradle | 22 +- ios/.gitignore | 68 +- ios/Flutter/AppFrameworkInfo.plist | 52 +- ios/Flutter/Debug.xcconfig | 3 +- ios/Flutter/Release.xcconfig | 3 +- ios/Podfile | 41 + ios/Podfile.lock | 22 + ios/Runner.xcodeproj/project.pbxproj | 68 + .../contents.xcworkspacedata | 14 +- .../xcshareddata/IDEWorkspaceChecks.plist | 16 +- .../xcshareddata/WorkspaceSettings.xcsettings | 16 +- .../xcshareddata/xcschemes/Runner.xcscheme | 174 +-- .../contents.xcworkspacedata | 3 + .../xcshareddata/IDEWorkspaceChecks.plist | 16 +- .../xcshareddata/WorkspaceSettings.xcsettings | 16 +- ios/Runner/AppDelegate.swift | 26 +- .../AppIcon.appiconset/Contents.json | 244 +-- .../LaunchImage.imageset/Contents.json | 46 +- .../LaunchImage.imageset/README.md | 8 +- ios/Runner/Base.lproj/LaunchScreen.storyboard | 74 +- ios/Runner/Base.lproj/Main.storyboard | 52 +- ios/Runner/Info.plist | 2 + ios/Runner/Runner-Bridging-Header.h | 2 +- lib/app.dart | 96 +- lib/core/data/database_provider.dart | 158 +- lib/core/data/local_storage_provider.dart | 136 +- lib/core/exceptions/error.dart | 10 +- lib/core/exceptions/exception.dart | 20 +- lib/core/routes/app_pages.dart | 22 +- lib/core/routes/app_routes.dart | 12 +- lib/core/usecase/base_usecase.dart | 14 +- lib/core/utils/constants.dart | 32 +- lib/core/utils/extension/context.dart | 42 +- lib/core/utils/extension/map_index.dart | 16 +- lib/core/utils/extension/random.dart | 18 +- lib/core/utils/extension/shamsi_date.dart | 62 +- lib/core/utils/extension/string.dart | 50 +- lib/core/utils/localization.dart | 142 +- lib/core/utils/snackbar.dart | 49 +- lib/core/utils/strings.dart | 14 +- lib/core/utils/theme/app_theme.dart | 73 +- lib/core/utils/theme/colors.dart | 22 +- lib/core/utils/theme/spacing.dart | 16 +- lib/core/utils/theme/style.dart | 73 +- lib/core/utils/utils.dart | 24 +- lib/core/widgets/action_button.dart | 68 +- lib/core/widgets/error_text.dart | 48 +- lib/core/widgets/note_appbar.dart | 149 +- lib/core/widgets/widgets.dart | 6 +- lib/features/note/bindings/note_binding.dart | 64 +- .../note/bindings/note_detail_binding.dart | 24 +- lib/features/note/data/models/note.dart | 192 +-- lib/features/note/data/models/todo.dart | 84 +- .../data/repositories/note_repository.dart | 112 +- .../note/domain/entities/note_entity.dart | 58 +- .../domain/entities/note_entity.freezed.dart | 532 +++---- .../note/domain/entities/todo_entity.dart | 48 +- .../domain/repositories/note_repository.dart | 22 +- .../usecases/add_update_note_usecase.dart | 86 +- .../delete_multiple_notes_usecase.dart | 44 +- .../domain/usecases/delete_note_usecase.dart | 44 +- .../domain/usecases/get_all_note_usecase.dart | 74 +- .../domain/usecases/get_note_usecase.dart | 64 +- .../controllers/note_controller.dart | 386 ++--- .../controllers/note_detail_controller.dart | 50 +- .../controllers/setting_controller.dart | 132 +- .../pages/notes/add_update_note_screen.dart | 266 ++-- .../pages/notes/note_detail_screen.dart | 300 ++-- .../presentation/pages/notes/note_screen.dart | 255 ++-- .../note/presentation/pages/pages.dart | 8 +- .../pages/setting/setting_screen.dart | 222 +-- .../widgets/add_update/add_todo.dart | 238 +-- .../widgets/add_update/colors_bar.dart | 170 +-- .../widgets/add_update/input_field.dart | 88 +- .../widgets/note_screen/note_card.dart | 206 +-- lib/features/note/routes/note_routes.dart | 54 +- lib/main.dart | 50 +- pubspec.lock | 1330 +++++++++-------- pubspec.yaml | 185 +-- test/widget_test.dart | 62 +- web/index.html | 208 +-- web/manifest.json | 70 +- 99 files changed, 4496 insertions(+), 4264 deletions(-) create mode 100644 ios/Podfile create mode 100644 ios/Podfile.lock diff --git a/.gitignore b/.gitignore index 0fa6b67..8906afc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,46 +1,46 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Web related -lib/generated_plugin_registrant.dart - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/.metadata b/.metadata index fd70cab..6376fbe 100644 --- a/.metadata +++ b/.metadata @@ -1,10 +1,10 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b - channel: stable - -project_type: app +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b + channel: stable + +project_type: app diff --git a/README.md b/README.md index 046b2ef..274e295 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# simple_hive_note - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +# simple_hive_note + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4d..a7acf24 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,29 +1,29 @@ -# 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 - -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 +# 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 + +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 diff --git a/android/.gitignore b/android/.gitignore index 6f56801..5d99765 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -1,13 +1,13 @@ -gradle-wrapper.jar -/.gradle -/captures/ -/gradlew -/gradlew.bat -/local.properties -GeneratedPluginRegistrant.java - -# Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app -key.properties -**/*.keystore -**/*.jks +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index 3667fdb..d128ce3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,68 +1,68 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - -android { - compileSdkVersion flutter.compileSdkVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.ebdev.simple_hive_note" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - } - } -} - -flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.ebdev.simple_hive_note" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 5981a49..7699c41 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c24736a..ddc856f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/ebdev/simple_hive_note/MainActivity.kt b/android/app/src/main/kotlin/com/ebdev/simple_hive_note/MainActivity.kt index 69a9b46..05b2951 100644 --- a/android/app/src/main/kotlin/com/ebdev/simple_hive_note/MainActivity.kt +++ b/android/app/src/main/kotlin/com/ebdev/simple_hive_note/MainActivity.kt @@ -1,6 +1,6 @@ -package com.ebdev.simple_hive_note - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() { -} +package com.ebdev.simple_hive_note + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml index f74085f..1cb7aa2 100644 --- a/android/app/src/main/res/drawable-v21/launch_background.xml +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -1,12 +1,12 @@ - - - - - - - - + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml index 304732f..8403758 100644 --- a/android/app/src/main/res/drawable/launch_background.xml +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -1,12 +1,12 @@ - - - - - - - - + + + + + + + + diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml index 3db14bb..6b2369f 100644 --- a/android/app/src/main/res/values-night/styles.xml +++ b/android/app/src/main/res/values-night/styles.xml @@ -1,18 +1,18 @@ - - - - - - - + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index d460d1e..3e29b54 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,18 +1,18 @@ - - - - - - - + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index 5981a49..7699c41 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/android/build.gradle b/android/build.gradle index 24047dc..871ba76 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,31 +1,31 @@ -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -rootProject.buildDir = '../build' -subprojects { - project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { - project.evaluationDependsOn(':app') -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/gradle.properties b/android/gradle.properties index 94adc3a..46c1f16 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..571984a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jun 23 08:50:38 CEST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index 44e62bc..33f0745 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,11 +1,11 @@ -include ':app' - -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() - -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } - -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/ios/.gitignore b/ios/.gitignore index 7a7f987..ad322bc 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -1,34 +1,34 @@ -**/dgph -*.mode1v3 -*.mode2v3 -*.moved-aside -*.pbxuser -*.perspectivev3 -**/*sync/ -.sconsign.dblite -.tags* -**/.vagrant/ -**/DerivedData/ -Icon? -**/Pods/ -**/.symlinks/ -profile -xcuserdata -**/.generated/ -Flutter/App.framework -Flutter/Flutter.framework -Flutter/Flutter.podspec -Flutter/Generated.xcconfig -Flutter/ephemeral/ -Flutter/app.flx -Flutter/app.zip -Flutter/flutter_assets/ -Flutter/flutter_export_environment.sh -ServiceDefinitions.json -Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!default.mode1v3 -!default.mode2v3 -!default.pbxuser -!default.perspectivev3 +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..80391e4 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -1,26 +1,26 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - App - CFBundleIdentifier - io.flutter.flutter.app - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - App - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 9.0 - - + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index 592ceee..dfd2626 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ -#include "Generated.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index 592ceee..a97381a 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ -#include "Generated.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..8ee2123 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,22 @@ +PODS: + - Flutter (1.0.0) + - path_provider_ios (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + path_provider_ios: + :path: ".symlinks/plugins/path_provider_ios/ios" + +SPEC CHECKSUMS: + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.11.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 06650ab..cece8a4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 6D551B5733547EE1567D5275 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 365155F013178CA39E7A62BA /* Pods_Runner.framework */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; @@ -31,9 +32,12 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 365155F013178CA39E7A62BA /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B77003D14EB506FF112B1E1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 760A6FE6B8186B5CCF7D70A8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; @@ -42,6 +46,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C58C576775D17BF1D16131AA /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,12 +54,32 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6D551B5733547EE1567D5275 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 4E14585D3EDF5A9E56370D5C /* Pods */ = { + isa = PBXGroup; + children = ( + 3B77003D14EB506FF112B1E1 /* Pods-Runner.debug.xcconfig */, + C58C576775D17BF1D16131AA /* Pods-Runner.release.xcconfig */, + 760A6FE6B8186B5CCF7D70A8 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 60518947C233294451C5B189 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 365155F013178CA39E7A62BA /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +97,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 4E14585D3EDF5A9E56370D5C /* Pods */, + 60518947C233294451C5B189 /* Frameworks */, ); sourceTree = ""; }; @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 5CED505804A4598C0359217D /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + AF9B983ED79F8DC97F0B6D2F /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -183,6 +212,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 5CED505804A4598C0359217D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -197,6 +248,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + AF9B983ED79F8DC97F0B6D2F /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 919434a..c4b79bd 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist index 18d9810..fc6bf80 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -1,8 +1,8 @@ - - - - - IDEDidComputeMac32BitWarning - - - + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings index f9b0d7c..af0309c 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -1,8 +1,8 @@ - - - - - PreviewsEnabled - - - + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a..f9cbb25 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,87 +1,87 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist index 18d9810..fc6bf80 100644 --- a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -1,8 +1,8 @@ - - - - - IDEDidComputeMac32BitWarning - - - + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings index f9b0d7c..af0309c 100644 --- a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -1,8 +1,8 @@ - - - - - PreviewsEnabled - - - + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..3763683 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit -import Flutter - -@UIApplicationMain -@objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } -} +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json index d36b1fa..1950fd8 100644 --- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,122 +1,122 @@ -{ - "images" : [ - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@3x.png", - "scale" : "3x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@3x.png", - "scale" : "3x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@3x.png", - "scale" : "3x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@3x.png", - "scale" : "3x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@1x.png", - "scale" : "1x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@1x.png", - "scale" : "1x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@1x.png", - "scale" : "1x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@2x.png", - "scale" : "2x" - }, - { - "size" : "83.5x83.5", - "idiom" : "ipad", - "filename" : "Icon-App-83.5x83.5@2x.png", - "scale" : "2x" - }, - { - "size" : "1024x1024", - "idiom" : "ios-marketing", - "filename" : "Icon-App-1024x1024@1x.png", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json index 0bedcf2..d08a4de 100644 --- a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -1,23 +1,23 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "LaunchImage.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md index 89c2725..65a94b5 100644 --- a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -1,5 +1,5 @@ -# Launch Screen Assets - -You can customize the launch screen with your own desired assets by replacing the image files in this directory. - +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard index f2e259c..497371e 100644 --- a/ios/Runner/Base.lproj/LaunchScreen.storyboard +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard index f3c2851..bbb83ca 100644 --- a/ios/Runner/Base.lproj/Main.storyboard +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index e017ce8..7d216c2 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -43,5 +43,7 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h index 308a2a5..fae207f 100644 --- a/ios/Runner/Runner-Bridging-Header.h +++ b/ios/Runner/Runner-Bridging-Header.h @@ -1 +1 @@ -#import "GeneratedPluginRegistrant.h" +#import "GeneratedPluginRegistrant.h" diff --git a/lib/app.dart b/lib/app.dart index 83997ed..b30644d 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,30 +1,66 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import 'core/routes/app_pages.dart'; -import 'core/utils/utils.dart'; -import 'features/note/presentation/controllers/setting_controller.dart'; - -class App extends StatelessWidget { - App({Key? key}) : super(key: key); - - final controller = Get.put(SettingController(), permanent: true); - - @override - Widget build(BuildContext context) { - return GetMaterialApp( - title: 'Flutter Note', - translations: Localization(), - locale: controller.locale, - fallbackLocale: const Locale("fa", "IR"), - debugShowCheckedModeBanner: false, - defaultTransition: Transition.circularReveal, - transitionDuration: pageTransitionDuration, - theme: AppTheme.light, - darkTheme: AppTheme.dark, - themeMode: controller.themeMode, - initialRoute: AppPages.initialRoute, - getPages: AppPages.pages, - ); - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import 'core/routes/app_pages.dart'; +import 'core/utils/utils.dart'; +import 'features/note/presentation/controllers/setting_controller.dart'; + +class App extends StatelessWidget { + App({Key? key}) : super(key: key); + + final controller = Get.put(SettingController(), permanent: true); + + @override + Widget build(BuildContext context) { + return GetMaterialApp( + title: 'Flutter Note', + translations: Localization(), + locale: controller.locale, + fallbackLocale: const Locale("fa", "IR"), + debugShowCheckedModeBanner: false, + defaultTransition: Transition.circularReveal, + transitionDuration: pageTransitionDuration, + theme: AppTheme.light, + darkTheme: AppTheme.dark, + themeMode: controller.themeMode, + initialRoute: AppPages.initialRoute, + getPages: AppPages.pages, + builder: (context, child) { + return Theme( + data: controller.isDarkMode.value + ? AppTheme.dark.copyWith( + textTheme: controller.currentLocale.value == "fa" + ? FarsiTypography.textTheme.apply( + bodyColor: controller.isDarkMode.value + ? Colors.white + : Colors.black, + ) + : GoogleFonts.montserratTextTheme().apply( + bodyColor: controller.isDarkMode.value + ? Colors.white + : Colors.black, + ), + ) + : AppTheme.light.copyWith( + textTheme: controller.currentLocale.value == "fa" + ? FarsiTypography.textTheme.apply( + bodyColor: controller.isDarkMode.value + ? Colors.white + : Colors.black, + ) + : GoogleFonts.montserratTextTheme().apply( + bodyColor: controller.isDarkMode.value + ? Colors.white + : Colors.black, + displayColor: controller.isDarkMode.value + ? Colors.white + : Colors.black, + ), + ), + child: child!, + ); + }, + ); + } +} diff --git a/lib/core/data/database_provider.dart b/lib/core/data/database_provider.dart index 96e65a7..91af3d4 100644 --- a/lib/core/data/database_provider.dart +++ b/lib/core/data/database_provider.dart @@ -1,79 +1,79 @@ -import 'package:hive/hive.dart'; -import 'package:simple_hive_note/core/exceptions/exception.dart'; -import 'package:simple_hive_note/core/utils/strings.dart'; - -abstract class DatabaseRepository { - Box get box; - T get(String id); - List getAll(); - Future delete(String id); - Future deleteAll(List keys); - Future addUpdate(String id, T item); -} - -class DatabaseProvider implements DatabaseRepository { - DatabaseProvider._internal(); - - static final DatabaseProvider _singleton = DatabaseProvider._internal(); - - factory DatabaseProvider() { - return _singleton; - } - - @override - Box get box => Hive.box(AppStrings.databaseBox); - - @override - T get(String id) { - try { - final data = box.get(id); - if (data == null) { - throw NoteAppException.noRecords(); - } - return data; - } catch (e) { - rethrow; - } - } - - @override - List getAll() { - // box.clear(); - try { - final data = box.toMap().values; - if (data.isEmpty) { - throw NoteAppException.noRecords(); - } - return data.toList().cast(); - } catch (e) { - rethrow; - } - } - - @override - Future delete(String id) async { - try { - await box.delete(id); - } catch (e) { - rethrow; - } - } - - @override - Future deleteAll(List keys) async { - try { - await box.deleteAll(keys); - } catch (e) { - rethrow; - } - } - - @override - Future addUpdate(String id, T item) async { - try { - await box.put(id, item); - } catch (e) { - rethrow; - } - } -} +import 'package:hive/hive.dart'; +import 'package:simple_hive_note/core/exceptions/exception.dart'; +import 'package:simple_hive_note/core/utils/strings.dart'; + +abstract class DatabaseRepository { + Box get box; + T get(String id); + List getAll(); + Future delete(String id); + Future deleteAll(List keys); + Future addUpdate(String id, T item); +} + +class DatabaseProvider implements DatabaseRepository { + DatabaseProvider._internal(); + + static final DatabaseProvider _singleton = DatabaseProvider._internal(); + + factory DatabaseProvider() { + return _singleton; + } + + @override + Box get box => Hive.box(AppStrings.databaseBox); + + @override + T get(String id) { + try { + final data = box.get(id); + if (data == null) { + throw NoteAppException.noRecords(); + } + return data; + } catch (e) { + rethrow; + } + } + + @override + List getAll() { + // box.clear(); + try { + final data = box.toMap().values; + if (data.isEmpty) { + throw NoteAppException.noRecords(); + } + return data.toList().cast(); + } catch (e) { + rethrow; + } + } + + @override + Future delete(String id) async { + try { + await box.delete(id); + } catch (e) { + rethrow; + } + } + + @override + Future deleteAll(List keys) async { + try { + await box.deleteAll(keys); + } catch (e) { + rethrow; + } + } + + @override + Future addUpdate(String id, T item) async { + try { + await box.put(id, item); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/core/data/local_storage_provider.dart b/lib/core/data/local_storage_provider.dart index 6a13e68..39197d4 100644 --- a/lib/core/data/local_storage_provider.dart +++ b/lib/core/data/local_storage_provider.dart @@ -1,68 +1,68 @@ -import 'dart:convert' as convert; - -import 'package:get_storage/get_storage.dart'; -import 'package:simple_hive_note/core/exceptions/exception.dart'; - -abstract class LocalStorageRepository { - GetStorage get storage; - T? read(String key, {T Function(Map)? construct}); - Future write(String key, dynamic json); - Future remove(String key); - Future removeAll(); -} - -class LocalStorageProvider implements LocalStorageRepository { - LocalStorageProvider._initial(); - - static final LocalStorageProvider _singleton = - LocalStorageProvider._initial(); - - factory LocalStorageProvider() => _singleton; - - @override - GetStorage get storage => GetStorage(); - - @override - write(String key, dynamic value) async { - try { - await storage.write(key, convert.jsonEncode(value)); - } catch (e) { - rethrow; - } - } - - @override - T? read(String key, {T Function(Map)? construct}) { - try { - String? value = storage.read(key); - - if (value == null) { - throw NoteAppException.noRecords(); - } - - if (construct == null) return convert.jsonDecode(value); - Map json = convert.jsonDecode(value); - return construct(json); - } catch (e) { - rethrow; - } - } - - @override - remove(String key) async { - try { - await storage.remove(key); - } catch (e) { - rethrow; - } - } - - @override - removeAll() async { - try { - await storage.erase(); - } catch (e) { - rethrow; - } - } -} +import 'dart:convert' as convert; + +import 'package:get_storage/get_storage.dart'; +import 'package:simple_hive_note/core/exceptions/exception.dart'; + +abstract class LocalStorageRepository { + GetStorage get storage; + T? read(String key, {T Function(Map)? construct}); + Future write(String key, dynamic json); + Future remove(String key); + Future removeAll(); +} + +class LocalStorageProvider implements LocalStorageRepository { + LocalStorageProvider._initial(); + + static final LocalStorageProvider _singleton = + LocalStorageProvider._initial(); + + factory LocalStorageProvider() => _singleton; + + @override + GetStorage get storage => GetStorage(); + + @override + write(String key, dynamic value) async { + try { + await storage.write(key, convert.jsonEncode(value)); + } catch (e) { + rethrow; + } + } + + @override + T? read(String key, {T Function(Map)? construct}) { + try { + String? value = storage.read(key); + + if (value == null) { + throw NoteAppException.noRecords(); + } + + if (construct == null) return convert.jsonDecode(value); + Map json = convert.jsonDecode(value); + return construct(json); + } catch (e) { + rethrow; + } + } + + @override + remove(String key) async { + try { + await storage.remove(key); + } catch (e) { + rethrow; + } + } + + @override + removeAll() async { + try { + await storage.erase(); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/core/exceptions/error.dart b/lib/core/exceptions/error.dart index 9065c37..f2d5574 100644 --- a/lib/core/exceptions/error.dart +++ b/lib/core/exceptions/error.dart @@ -1,5 +1,5 @@ -class NoteError { - String? message; - - NoteError({this.message}); -} +class NoteError { + String? message; + + NoteError({this.message}); +} diff --git a/lib/core/exceptions/exception.dart b/lib/core/exceptions/exception.dart index 386bb99..7fc5531 100644 --- a/lib/core/exceptions/exception.dart +++ b/lib/core/exceptions/exception.dart @@ -1,10 +1,10 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'exception.freezed.dart'; - -@freezed -abstract class NoteAppException implements Exception, _$NoteAppException { - factory NoteAppException.noRecords() = NoRecordsException; - factory NoteAppException.empty(String message) = EmptyException; - factory NoteAppException.failedToParse() = FailedToParseException; -} +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'exception.freezed.dart'; + +@freezed +abstract class NoteAppException implements Exception, _$NoteAppException { + factory NoteAppException.noRecords() = NoRecordsException; + factory NoteAppException.empty(String message) = EmptyException; + factory NoteAppException.failedToParse() = FailedToParseException; +} diff --git a/lib/core/routes/app_pages.dart b/lib/core/routes/app_pages.dart index 7263e32..0adfce8 100644 --- a/lib/core/routes/app_pages.dart +++ b/lib/core/routes/app_pages.dart @@ -1,11 +1,11 @@ -import 'package:get/get.dart'; - -import '../../features/note/routes/note_routes.dart'; -import 'app_routes.dart'; - -class AppPages { - static String get initialRoute => AppRoutes.note; - static List get pages => [ - ...noteRoutes, - ]; -} +import 'package:get/get.dart'; + +import '../../features/note/routes/note_routes.dart'; +import 'app_routes.dart'; + +class AppPages { + static String get initialRoute => AppRoutes.note; + static List get pages => [ + ...noteRoutes, + ]; +} diff --git a/lib/core/routes/app_routes.dart b/lib/core/routes/app_routes.dart index 8629d7a..454aba9 100644 --- a/lib/core/routes/app_routes.dart +++ b/lib/core/routes/app_routes.dart @@ -1,6 +1,6 @@ -abstract class AppRoutes { - static const String note = '/note'; - static const String addUpdate = '/addUpdate'; - static const String noteDetail = '/noteDetail'; - static const String setting = '/setting'; -} +abstract class AppRoutes { + static const String note = '/note'; + static const String addUpdate = '/addUpdate'; + static const String noteDetail = '/noteDetail'; + static const String setting = '/setting'; +} diff --git a/lib/core/usecase/base_usecase.dart b/lib/core/usecase/base_usecase.dart index f31930c..793169f 100644 --- a/lib/core/usecase/base_usecase.dart +++ b/lib/core/usecase/base_usecase.dart @@ -1,7 +1,7 @@ -import 'package:dartz/dartz.dart'; - -import '../exceptions/error.dart'; - -abstract class BaseUseCase { - Future> call(); -} +import 'package:dartz/dartz.dart'; + +import '../exceptions/error.dart'; + +abstract class BaseUseCase { + Future> call(); +} diff --git a/lib/core/utils/constants.dart b/lib/core/utils/constants.dart index d92e340..f8fb1bf 100644 --- a/lib/core/utils/constants.dart +++ b/lib/core/utils/constants.dart @@ -1,16 +1,16 @@ -import 'package:flutter/material.dart'; - -const List colors = [ - Color(0xffFE9A37), - Color(0xffCBDB57), - Color(0xff9585BA), - Color(0xff5C4F45), - Color(0xffF96A4B), - Color(0xffDEA44D), - Color(0xff9E5C32), -]; - -const fa = Locale("fa", "IR"); -const us = Locale("en", "US"); -const animationDuration = Duration(milliseconds: 400); -const pageTransitionDuration = Duration(milliseconds: 700); +import 'package:flutter/material.dart'; + +const List colors = [ + Color(0xffFE9A37), + Color(0xffCBDB57), + Color(0xff9585BA), + Color(0xff5C4F45), + Color(0xffF96A4B), + Color(0xffDEA44D), + Color(0xff9E5C32), +]; + +const fa = Locale("fa", "IR"); +const us = Locale("en", "US"); +const animationDuration = Duration(milliseconds: 400); +const pageTransitionDuration = Duration(milliseconds: 700); diff --git a/lib/core/utils/extension/context.dart b/lib/core/utils/extension/context.dart index b05c50a..5ac7da3 100644 --- a/lib/core/utils/extension/context.dart +++ b/lib/core/utils/extension/context.dart @@ -1,21 +1,21 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/utils/theme/colors.dart'; - -extension ContextEx on BuildContext { - void showMessage(String message, {bool isError = false}) { - final snackBar = GetSnackBar( - duration: const Duration(seconds: 2), - snackPosition: SnackPosition.BOTTOM, - backgroundColor: isError ? AppColors.error : AppColors.primary, - messageText: Text( - message, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ); - Get.showSnackbar(snackBar); - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/utils/theme/colors.dart'; + +extension ContextEx on BuildContext { + void showMessage(String message, {bool isError = false}) { + final snackBar = GetSnackBar( + duration: const Duration(seconds: 2), + snackPosition: SnackPosition.BOTTOM, + backgroundColor: isError ? AppColors.error : AppColors.primary, + messageText: Text( + message, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ); + Get.showSnackbar(snackBar); + } +} diff --git a/lib/core/utils/extension/map_index.dart b/lib/core/utils/extension/map_index.dart index 5a5831b..c5e177f 100644 --- a/lib/core/utils/extension/map_index.dart +++ b/lib/core/utils/extension/map_index.dart @@ -1,8 +1,8 @@ -import 'dart:core'; - -extension IndexedIterable on Iterable { - Iterable mapIndexed(T Function(E e, int i) f) { - var i = 0; - return map((e) => f(e, i++)); - } -} +import 'dart:core'; + +extension IndexedIterable on Iterable { + Iterable mapIndexed(T Function(E e, int i) f) { + var i = 0; + return map((e) => f(e, i++)); + } +} diff --git a/lib/core/utils/extension/random.dart b/lib/core/utils/extension/random.dart index adc21c8..befaacd 100644 --- a/lib/core/utils/extension/random.dart +++ b/lib/core/utils/extension/random.dart @@ -1,9 +1,9 @@ -import 'dart:math'; - -final _random = Random(); - -extension RandomX on List { - int get _index => _random.nextInt(length); - - dynamic get randomElement => this[_index]; -} +import 'dart:math'; + +final _random = Random(); + +extension RandomX on List { + int get _index => _random.nextInt(length); + + dynamic get randomElement => this[_index]; +} diff --git a/lib/core/utils/extension/shamsi_date.dart b/lib/core/utils/extension/shamsi_date.dart index 97e56b3..17fdfe3 100644 --- a/lib/core/utils/extension/shamsi_date.dart +++ b/lib/core/utils/extension/shamsi_date.dart @@ -1,31 +1,31 @@ -import 'package:shamsi_date/shamsi_date.dart'; - -extension DateTimeEx on DateTime { - Jalali get _jalali => Jalali.fromDateTime(this); - - String get jalaliDate => - "${_jalali.day} ${_jalali.monthName} ${_jalali.year}"; - String get jalaliDateWithTime => - "${_jalali.day} ${_jalali.monthName} ${_jalali.year} ${_jalali.hour}:${_jalali.minute}"; -} - -extension JalaliEx on Jalali { - String get monthName { - final _months = [ - "فروردین", - "اردیبهشت", - "خرداد", - "تیر", - "مرداد", - "شهریور", - "مهر", - "آبان", - "آذر", - "دی", - "بهمن", - "اسفند" - ]; - - return _months[this.month - 1]; - } -} +import 'package:shamsi_date/shamsi_date.dart'; + +extension DateTimeEx on DateTime { + Jalali get _jalali => Jalali.fromDateTime(this); + + String get jalaliDate => + "${_jalali.day} ${_jalali.monthName} ${_jalali.year}"; + String get jalaliDateWithTime => + "${_jalali.day} ${_jalali.monthName} ${_jalali.year} ${_jalali.hour}:${_jalali.minute}"; +} + +extension JalaliEx on Jalali { + String get monthName { + final _months = [ + "فروردین", + "اردیبهشت", + "خرداد", + "تیر", + "مرداد", + "شهریور", + "مهر", + "آبان", + "آذر", + "دی", + "بهمن", + "اسفند" + ]; + + return _months[this.month - 1]; + } +} diff --git a/lib/core/utils/extension/string.dart b/lib/core/utils/extension/string.dart index 43435f2..e438d99 100644 --- a/lib/core/utils/extension/string.dart +++ b/lib/core/utils/extension/string.dart @@ -1,25 +1,25 @@ -import 'shamsi_date.dart'; - -extension StringEx on String? { - bool get isEmptyString => _removeWhiteSpaces(this); - - bool _removeWhiteSpaces(String? str) { - if (str == null) { - return true; - } - final newStr = str.trim(); - return newStr.isEmpty; - } -} - -extension StringDateEx on String { - String get toJalaliDate { - final dateTime = DateTime.parse(this); - return dateTime.jalaliDate; - } - - String get toJalaliDateWithTime { - final dateTime = DateTime.parse(this); - return dateTime.jalaliDateWithTime; - } -} +import 'shamsi_date.dart'; + +extension StringEx on String? { + bool get isEmptyString => _removeWhiteSpaces(this); + + bool _removeWhiteSpaces(String? str) { + if (str == null) { + return true; + } + final newStr = str.trim(); + return newStr.isEmpty; + } +} + +extension StringDateEx on String { + String get toJalaliDate { + final dateTime = DateTime.parse(this); + return dateTime.jalaliDate; + } + + String get toJalaliDateWithTime { + final dateTime = DateTime.parse(this); + return dateTime.jalaliDateWithTime; + } +} diff --git a/lib/core/utils/localization.dart b/lib/core/utils/localization.dart index 6b0435e..268dda5 100644 --- a/lib/core/utils/localization.dart +++ b/lib/core/utils/localization.dart @@ -1,71 +1,71 @@ -import 'package:get/get.dart'; - -class Localization extends Translations { - @override - Map> get keys => { - 'en_US': { - 'note': 'Note', - 'notes': "Notes", - 'title': 'Title', - 'type_something': 'Type Something ...', - 'save': 'Save', - 'delete': 'Delete', - "saving": "Saving ...", - "empty_note": "No notes found...\n click \"+\" to add new one.", - 'failed_load_notes': 'Failed to load notes, please try again.', - 'failed_add_notes': 'Failed to add notes, please try again.', - 'failed_update_notes': 'Failed to update notes, please try again.', - 'failed_delete_notes': 'Failed to delete notes, please try again.', - 'settings': "Settings", - 'change_language': "Change Language", - 'change_theme': "Change Theme", - "delete_msg": "Notes Deleted Successfully.", - "no_match_note": "No matched note found.", - "title_empty": 'Failed to add note, Title should not empty.', - "title_update_empty": - 'Failed to update note, Title should not empty.', - "note_added": "Note Added Successfully", - "note_updated": "Note Updated Successfully", - "theme_light": "Light", - "theme_dark": "Dark", - "persian": "Persian", - "english": "English", - "add_todo": "Add Todo", - "todo..": "Todo..", - "todo_title": "TODO's", - }, - 'fa_IR': { - 'note': "یادداشت", - 'notes': "یادداشت ها", - 'title': 'عنوان', - 'type_something': 'چیزی بنویسید ...', - 'save': 'ذخیره', - 'delete': 'حذف', - "saving": "در حال ذخیره ...", - 'empty_note': - "یادداشتی وجود ندارد\n با کلیک بر روی دکمه \"+\" یکی اضافه کنید", - 'failed_load_notes': - 'خطا در بارگذاری یادداشت ها، لطفا دوباره امتحان کنید.', - 'failed_add_notes': 'خطا در ایحاد یادداشت، لطفا دوباره امتحان کنید.', - 'failed_update_notes': - 'خطا در ویرایش یادداشت، لطفا دوباره امتحان کنید.', - 'failed_delete_notes': 'خطا در حذف یادداشت، لطفا دوباره اکتحان کنید.', - 'settings': "تنظیمات", - 'change_language': "تغییر زبان", - 'change_theme': 'تغییر نمایه', - "delete_msg": "یادداشت حذف شد.", - "no_match_note": "این یادداشت یافت نشد.", - "title_empty": "خطا در ایجاد یادداشت، عنوان نباید خالی باشد.", - "title_update_empty": "خطا در ویرایش یادداشت، عنوان نباید خالی باشد.", - "note_added": "یادداشت با موفقیت اضافه شد", - "note_updated": "یادداشت با موفقیت ویرایش شد", - "theme_light": "روشن", - "theme_dark": "تاریک", - "persian": "فارسی", - "english": "انگلیسی", - "add_todo": "افزودن کار", - "todo..": "کار..", - "todo_title": "کار ها", - }, - }; -} +import 'package:get/get.dart'; + +class Localization extends Translations { + @override + Map> get keys => { + 'en_US': { + 'note': 'Note', + 'notes': "Notes", + 'title': 'Title', + 'type_something': 'Type Something ...', + 'save': 'Save', + 'delete': 'Delete', + "saving": "Saving ...", + "empty_note": "No notes found...\n click \"+\" to add new one.", + 'failed_load_notes': 'Failed to load notes, please try again.', + 'failed_add_notes': 'Failed to add notes, please try again.', + 'failed_update_notes': 'Failed to update notes, please try again.', + 'failed_delete_notes': 'Failed to delete notes, please try again.', + 'settings': "Settings", + 'change_language': "Change Language", + 'change_theme': "Change Theme", + "delete_msg": "Notes Deleted Successfully.", + "no_match_note": "No matched note found.", + "title_empty": 'Failed to add note, Title should not empty.', + "title_update_empty": + 'Failed to update note, Title should not empty.', + "note_added": "Note Added Successfully", + "note_updated": "Note Updated Successfully", + "theme_light": "Light", + "theme_dark": "Dark", + "persian": "Persian", + "english": "English", + "add_todo": "Add Todo", + "todo..": "Todo..", + "todo_title": "TODO's", + }, + 'fa_IR': { + 'note': "یادداشت", + 'notes': "یادداشت ها", + 'title': 'عنوان', + 'type_something': 'چیزی بنویسید ...', + 'save': 'ذخیره', + 'delete': 'حذف', + "saving": "در حال ذخیره ...", + 'empty_note': + "یادداشتی وجود ندارد\n با کلیک بر روی دکمه \"+\" یکی اضافه کنید", + 'failed_load_notes': + 'خطا در بارگذاری یادداشت ها، لطفا دوباره امتحان کنید.', + 'failed_add_notes': 'خطا در ایحاد یادداشت، لطفا دوباره امتحان کنید.', + 'failed_update_notes': + 'خطا در ویرایش یادداشت، لطفا دوباره امتحان کنید.', + 'failed_delete_notes': 'خطا در حذف یادداشت، لطفا دوباره اکتحان کنید.', + 'settings': "تنظیمات", + 'change_language': "تغییر زبان", + 'change_theme': 'تغییر نمایه', + "delete_msg": "یادداشت حذف شد.", + "no_match_note": "این یادداشت یافت نشد.", + "title_empty": "خطا در ایجاد یادداشت، عنوان نباید خالی باشد.", + "title_update_empty": "خطا در ویرایش یادداشت، عنوان نباید خالی باشد.", + "note_added": "یادداشت با موفقیت اضافه شد", + "note_updated": "یادداشت با موفقیت ویرایش شد", + "theme_light": "روشن", + "theme_dark": "تاریک", + "persian": "فارسی", + "english": "انگلیسی", + "add_todo": "افزودن کار", + "todo..": "کار..", + "todo_title": "کار ها", + }, + }; +} diff --git a/lib/core/utils/snackbar.dart b/lib/core/utils/snackbar.dart index a729218..bd1198f 100644 --- a/lib/core/utils/snackbar.dart +++ b/lib/core/utils/snackbar.dart @@ -1,24 +1,25 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/utils/theme/colors.dart'; - -class AppSnackbar { - const AppSnackbar._(); - - static showSnackbar(String message, {bool isError = false}) { - final snackBar = GetSnackBar( - duration: const Duration(seconds: 2), - snackPosition: SnackPosition.BOTTOM, - backgroundColor: isError ? AppColors.error : AppColors.primary, - messageText: Text( - message, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - ); - Get.showSnackbar(snackBar); - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/utils/theme/colors.dart'; + +class AppSnackbar { + const AppSnackbar._(); + + static showSnackbar(String message, {bool isError = false}) { + final snackBar = GetSnackBar( + duration: const Duration(seconds: 2), + snackPosition: SnackPosition.BOTTOM, + snackStyle: SnackStyle.GROUNDED, + backgroundColor: isError ? AppColors.error : AppColors.primary, + messageText: Text( + message, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ); + Get.showSnackbar(snackBar); + } +} diff --git a/lib/core/utils/strings.dart b/lib/core/utils/strings.dart index 35a7ee0..fdb1ba5 100644 --- a/lib/core/utils/strings.dart +++ b/lib/core/utils/strings.dart @@ -1,7 +1,7 @@ -class AppStrings { - const AppStrings._(); - - static const String databaseBox = "note_box"; - static const String isDark = "isDark"; - static const String locale = "locale"; -} +class AppStrings { + const AppStrings._(); + + static const String databaseBox = "note_box"; + static const String isDark = "isDark"; + static const String locale = "locale"; +} diff --git a/lib/core/utils/theme/app_theme.dart b/lib/core/utils/theme/app_theme.dart index 684783c..fce33f5 100644 --- a/lib/core/utils/theme/app_theme.dart +++ b/lib/core/utils/theme/app_theme.dart @@ -1,35 +1,38 @@ -import 'package:flutter/material.dart'; - -import 'colors.dart'; - -class AppTheme { - static ThemeData dark = ThemeData.dark().copyWith( - // scaffoldBackgroundColor: AppColors.scaffoldBackground, - colorScheme: ColorScheme.fromSwatch().copyWith( - primary: AppColors.primary, - secondary: AppColors.secondary, - ), - brightness: Brightness.dark, - checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.all(AppColors.primary), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(40), - ), - ), - ); - - static ThemeData light = ThemeData.light().copyWith( - scaffoldBackgroundColor: Colors.white, - colorScheme: ColorScheme.fromSwatch().copyWith( - primary: AppColors.primary, - secondary: AppColors.secondary, - ), - brightness: Brightness.light, - checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.all(AppColors.primary), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(40), - ), - ), - ); -} +import 'package:flutter/material.dart'; + +import 'colors.dart'; + +class AppTheme { + static ThemeData dark = ThemeData.dark().copyWith( + // scaffoldBackgroundColor: AppColors.scaffoldBackground, + // colorScheme: ColorScheme.fromSwatch().copyWith( + // primary: AppColors.primary, + // secondary: AppColors.secondary, + // ), + brightness: Brightness.dark, + primaryColor: AppColors.primary, + primaryColorDark: Colors.black, + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.all(AppColors.primary), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40), + ), + ), + ); + + static ThemeData light = ThemeData.light().copyWith( + scaffoldBackgroundColor: Colors.white, + colorScheme: ColorScheme.fromSwatch().copyWith( + primary: AppColors.primary, + secondary: AppColors.secondary, + ), + brightness: Brightness.light, + primaryColorLight: Colors.white, + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.all(AppColors.primary), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40), + ), + ), + ); +} diff --git a/lib/core/utils/theme/colors.dart b/lib/core/utils/theme/colors.dart index aace28a..26f8b3f 100644 --- a/lib/core/utils/theme/colors.dart +++ b/lib/core/utils/theme/colors.dart @@ -1,11 +1,11 @@ -import 'package:flutter/cupertino.dart'; - -class AppColors { - const AppColors._(); - - static const primary = Color(0xff333333); - static const secondary = Color(0xFFFFC833); - static const scaffoldBackground = Color(0xff333333); - static const error = Color(0xFFC94F59); - static const success = Color(0xFF53D1B6); -} +import 'package:flutter/cupertino.dart'; + +class AppColors { + const AppColors._(); + + static const primary = Color(0xff333333); + static const secondary = Color(0xFFFFC833); + static const scaffoldBackground = Color(0xff333333); + static const error = Color(0xFFC94F59); + static const success = Color(0xFF53D1B6); +} diff --git a/lib/core/utils/theme/spacing.dart b/lib/core/utils/theme/spacing.dart index 228af99..85fd746 100644 --- a/lib/core/utils/theme/spacing.dart +++ b/lib/core/utils/theme/spacing.dart @@ -1,8 +1,8 @@ -class AppSpacings { - const AppSpacings._(); - static const double s = 4.0; - static const double m = 8.0; - static const double l = 12.0; - static const double xl = 16.0; - static const double xxl = 24.0; -} +class AppSpacings { + const AppSpacings._(); + static const double s = 4.0; + static const double m = 8.0; + static const double l = 12.0; + static const double xl = 16.0; + static const double xxl = 24.0; +} diff --git a/lib/core/utils/theme/style.dart b/lib/core/utils/theme/style.dart index 1b26782..23fb423 100644 --- a/lib/core/utils/theme/style.dart +++ b/lib/core/utils/theme/style.dart @@ -1,18 +1,55 @@ -import 'package:flutter/material.dart'; - -class AppTextStyle { - const AppTextStyle._(); - - static const title = TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - ); - static const description = TextStyle( - fontSize: 20, - ); - - static const date = TextStyle( - fontSize: 15, - color: Colors.white60, - ); -} +import 'package:flutter/material.dart'; + +class AppTextStyle { + const AppTextStyle._(); + + static const title = TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + ); + static const description = TextStyle( + fontSize: 20, + ); + + static const date = TextStyle( + fontSize: 15, + color: Colors.white60, + ); +} + +class FarsiTypography { + static TextTheme get textTheme => const TextTheme( + headlineLarge: TextStyle( + fontSize: 30, + ), + headlineMedium: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + ), + headlineSmall: TextStyle( + fontSize: 26, + fontWeight: FontWeight.bold, + ), + titleLarge: TextStyle( + fontSize: 24, + // fontWeight: FontWeight.bold, + ), + titleMedium: TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + ), + titleSmall: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + bodyLarge: TextStyle( + fontSize: 18, + ), + bodyMedium: TextStyle( + fontSize: 16, + ), + bodySmall: TextStyle( + fontSize: 14, + ), + ).apply(fontFamily: "IRANSans"); +} diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart index b31725e..74c128a 100644 --- a/lib/core/utils/utils.dart +++ b/lib/core/utils/utils.dart @@ -1,12 +1,12 @@ -export 'localization.dart'; -export 'constants.dart'; -export 'strings.dart'; -export 'extension/context.dart'; -export 'extension/map_index.dart'; -export 'extension/random.dart'; -export 'extension/shamsi_date.dart'; -export 'extension/string.dart'; -export 'theme/app_theme.dart'; -export 'theme/colors.dart'; -export 'theme/spacing.dart'; -export 'theme/style.dart'; +export 'localization.dart'; +export 'constants.dart'; +export 'strings.dart'; +export 'extension/context.dart'; +export 'extension/map_index.dart'; +export 'extension/random.dart'; +export 'extension/shamsi_date.dart'; +export 'extension/string.dart'; +export 'theme/app_theme.dart'; +export 'theme/colors.dart'; +export 'theme/spacing.dart'; +export 'theme/style.dart'; diff --git a/lib/core/widgets/action_button.dart b/lib/core/widgets/action_button.dart index 1087937..366238e 100644 --- a/lib/core/widgets/action_button.dart +++ b/lib/core/widgets/action_button.dart @@ -1,34 +1,34 @@ -import 'package:flutter/material.dart'; -import 'package:simple_hive_note/core/utils/theme/app_theme.dart'; - -class ActionButton extends StatelessWidget { - const ActionButton({ - Key? key, - required this.onPressed, - required this.child, - }) : super(key: key); - - final Widget child; - final VoidCallback onPressed; - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onPressed, - child: Container( - height: 40, - constraints: const BoxConstraints(minWidth: 40), - padding: const EdgeInsets.symmetric(horizontal: 8), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.grey.shade600, - ), - child: Theme( - data: AppTheme.dark, - child: child, - ), - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:simple_hive_note/core/utils/theme/app_theme.dart'; + +class ActionButton extends StatelessWidget { + const ActionButton({ + Key? key, + required this.onPressed, + required this.child, + }) : super(key: key); + + final Widget child; + final VoidCallback onPressed; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onPressed, + child: Container( + height: 40, + constraints: const BoxConstraints(minWidth: 40), + padding: const EdgeInsets.symmetric(horizontal: 8), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.grey.shade600, + ), + child: Theme( + data: AppTheme.dark, + child: child, + ), + ), + ); + } +} diff --git a/lib/core/widgets/error_text.dart b/lib/core/widgets/error_text.dart index 7e48065..338cc07 100644 --- a/lib/core/widgets/error_text.dart +++ b/lib/core/widgets/error_text.dart @@ -1,24 +1,24 @@ -import 'package:animate_do/animate_do.dart'; -import 'package:flutter/material.dart'; - -class ErrorText extends StatelessWidget { - const ErrorText({Key? key, required this.message}) : super(key: key); - final String message; - - @override - Widget build(BuildContext context) { - return FadeInDown( - child: Center( - child: Text( - message, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - letterSpacing: 1.5, - ), - textAlign: TextAlign.center, - ), - ), - ); - } -} +import 'package:animate_do/animate_do.dart'; +import 'package:flutter/material.dart'; + +class ErrorText extends StatelessWidget { + const ErrorText({Key? key, required this.message}) : super(key: key); + final String message; + + @override + Widget build(BuildContext context) { + return FadeInDown( + child: Center( + child: Text( + message, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + letterSpacing: 1.5, + ), + textAlign: TextAlign.center, + ), + ), + ); + } +} diff --git a/lib/core/widgets/note_appbar.dart b/lib/core/widgets/note_appbar.dart index d2d9d33..0cbfc08 100644 --- a/lib/core/widgets/note_appbar.dart +++ b/lib/core/widgets/note_appbar.dart @@ -1,74 +1,75 @@ -import 'package:animate_do/animate_do.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../utils/utils.dart'; -import 'action_button.dart'; - -class NoteAppbar extends StatelessWidget with PreferredSizeWidget { - const NoteAppbar({ - Key? key, - this.title, - this.actions, - this.autoImplementLeading = true, - }) : super(key: key); - - final bool autoImplementLeading; - final String? title; - final List? actions; - - @override - Widget build(BuildContext context) { - return FadeInDown( - child: Container( - margin: const EdgeInsets.symmetric(horizontal: AppSpacings.xl), - padding: const EdgeInsets.symmetric(vertical: AppSpacings.xl), - child: SafeArea( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (autoImplementLeading) ...{ - ActionButton( - child: Icon( - Get.locale == fa - ? Icons.keyboard_arrow_right_rounded - : Icons.keyboard_arrow_left_rounded, - ), - onPressed: () => Navigator.pop(context), - ), - const SizedBox(width: AppSpacings.l), - }, - title != null - ? Expanded( - child: Text( - title!, - style: const TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ) - : const Spacer(), - if (actions != null) ...{ - ...actions! - .mapIndexed( - (action, i) => Padding( - padding: (i == actions!.length - 1) - ? EdgeInsets.zero - : const EdgeInsets.symmetric( - horizontal: AppSpacings.l), - child: action, - ), - ) - .toList(), - }, - ], - ), - ), - ), - ); - } - - @override - Size get preferredSize => const Size.fromHeight(100); -} +import 'package:animate_do/animate_do.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../utils/utils.dart'; +import 'action_button.dart'; + +class NoteAppbar extends StatelessWidget with PreferredSizeWidget { + const NoteAppbar({ + Key? key, + this.title, + this.actions, + this.autoImplementLeading = true, + }) : super(key: key); + + final bool autoImplementLeading; + final String? title; + final List? actions; + + @override + Widget build(BuildContext context) { + return FadeInDown( + child: Container( + margin: const EdgeInsets.symmetric(horizontal: AppSpacings.xl), + padding: const EdgeInsets.symmetric(vertical: AppSpacings.xl), + child: SafeArea( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (autoImplementLeading) ...{ + ActionButton( + child: Icon( + Get.locale == fa + ? Icons.keyboard_arrow_right_rounded + : Icons.keyboard_arrow_left_rounded, + ), + onPressed: () => Navigator.pop(context), + ), + const SizedBox(width: AppSpacings.l), + }, + title != null + ? Expanded( + child: Text( + title!, + style: const TextStyle( + fontSize: 35, + fontWeight: FontWeight.bold, + ), + // style: Get.theme.textTheme.headlineLarge, + ), + ) + : const Spacer(), + if (actions != null) ...{ + ...actions! + .mapIndexed( + (action, i) => Padding( + padding: (i == actions!.length - 1) + ? EdgeInsets.zero + : const EdgeInsets.symmetric( + horizontal: AppSpacings.l), + child: action, + ), + ) + .toList(), + }, + ], + ), + ), + ), + ); + } + + @override + Size get preferredSize => const Size.fromHeight(100); +} diff --git a/lib/core/widgets/widgets.dart b/lib/core/widgets/widgets.dart index 2acb038..217dc1b 100644 --- a/lib/core/widgets/widgets.dart +++ b/lib/core/widgets/widgets.dart @@ -1,3 +1,3 @@ -export 'action_button.dart'; -export 'error_text.dart'; -export 'note_appbar.dart'; +export 'action_button.dart'; +export 'error_text.dart'; +export 'note_appbar.dart'; diff --git a/lib/features/note/bindings/note_binding.dart b/lib/features/note/bindings/note_binding.dart index 9722e02..efe6a5e 100644 --- a/lib/features/note/bindings/note_binding.dart +++ b/lib/features/note/bindings/note_binding.dart @@ -1,32 +1,32 @@ -import 'package:get/get.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/add_update_note_usecase.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/delete_multiple_notes_usecase.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/delete_note_usecase.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; - -import '../data/repositories/note_repository.dart'; -import '../domain/usecases/get_all_note_usecase.dart'; -import '../presentation/controllers/note_controller.dart'; - -class NoteBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut(() => const NoteRepositoryImpl()); - Get.lazyPut(() => GetNoteUsecase(Get.find())); - Get.lazyPut(() => GetAllNotesUsecase(Get.find())); - Get.lazyPut(() => AddUpdateNoteUsecase(Get.find())); - Get.lazyPut(() => DeleteNoteUsecase(Get.find())); - Get.lazyPut(() => DeleteNoteUsecase(Get.find())); - Get.lazyPut( - () => DeleteMultipleNoteUsecase(Get.find())); - Get.lazyPut( - () => NoteController( - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - ), - ); - } -} +import 'package:get/get.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/add_update_note_usecase.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/delete_multiple_notes_usecase.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/delete_note_usecase.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; + +import '../data/repositories/note_repository.dart'; +import '../domain/usecases/get_all_note_usecase.dart'; +import '../presentation/controllers/note_controller.dart'; + +class NoteBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => const NoteRepositoryImpl()); + Get.lazyPut(() => GetNoteUsecase(Get.find())); + Get.lazyPut(() => GetAllNotesUsecase(Get.find())); + Get.lazyPut(() => AddUpdateNoteUsecase(Get.find())); + Get.lazyPut(() => DeleteNoteUsecase(Get.find())); + Get.lazyPut(() => DeleteNoteUsecase(Get.find())); + Get.lazyPut( + () => DeleteMultipleNoteUsecase(Get.find())); + Get.lazyPut( + () => NoteController( + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + ), + ); + } +} diff --git a/lib/features/note/bindings/note_detail_binding.dart b/lib/features/note/bindings/note_detail_binding.dart index 819b31d..7c55c5d 100644 --- a/lib/features/note/bindings/note_detail_binding.dart +++ b/lib/features/note/bindings/note_detail_binding.dart @@ -1,12 +1,12 @@ -import 'package:get/get.dart'; -import 'package:simple_hive_note/features/note/data/repositories/note_repository.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; -import 'package:simple_hive_note/features/note/presentation/controllers/note_detail_controller.dart'; - -class NoteDetailBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut(() => GetNoteUsecase(Get.find())); - Get.lazyPut(() => NoteDetailController(Get.find())); - } -} +import 'package:get/get.dart'; +import 'package:simple_hive_note/features/note/data/repositories/note_repository.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/note_detail_controller.dart'; + +class NoteDetailBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => GetNoteUsecase(Get.find())); + Get.lazyPut(() => NoteDetailController(Get.find())); + } +} diff --git a/lib/features/note/data/models/note.dart b/lib/features/note/data/models/note.dart index beb74b9..04df05b 100644 --- a/lib/features/note/data/models/note.dart +++ b/lib/features/note/data/models/note.dart @@ -1,96 +1,96 @@ -import 'dart:ui' show Color; - -import 'package:equatable/equatable.dart'; -import 'package:hive/hive.dart'; -import 'package:simple_hive_note/features/note/data/models/todo.dart'; -import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; - -part 'note.g.dart'; - -@HiveType(typeId: 0) -class Note extends Equatable implements Comparable { - @HiveField(0) - final String? id; - - @HiveField(1) - final String? title; - - @HiveField(2) - final String? description; - - @HiveField(3) - final int? colorValue; - - @HiveField(4) - final String? dateTime; - - @HiveField(5) - final List? todos; - - const Note({ - this.id, - this.title, - this.description, - this.colorValue, - this.dateTime, - this.todos = const [], - }); - - factory Note.fromNote(NoteEntity note) { - return Note( - id: note.id, - title: note.title, - description: note.description, - dateTime: note.dateTime?.toIso8601String(), - colorValue: note.color?.value, - todos: note.todos.map((todo) => Todo.fromDomain(todo)).toList(), - ); - } - - NoteEntity toDomain() { - return NoteEntity( - id: id, - title: title, - description: description, - dateTime: DateTime.tryParse(dateTime!), - color: Color(colorValue!), - todos: todos?.map((todo) => todo.toDomain()).toList() ?? [], - ); - } - - bool get validNote => title?.isNotEmpty == true; - - Note copyWith({ - String? id, - String? title, - String? description, - int? colorValue, - String? dateTime, - List? todos, - }) { - return Note( - id: id ?? this.id, - title: title ?? this.title, - description: description ?? this.description, - colorValue: colorValue ?? this.colorValue, - dateTime: dateTime ?? this.dateTime, - todos: todos ?? this.todos, - ); - } - - @override - int compareTo(other) { - try { - final _isAfter = DateTime.parse(other.dateTime).isAfter( - DateTime.parse(dateTime!), - ); - return _isAfter ? 1 : -1; - } catch (_) { - return 1; - } - } - - @override - List get props => - [id, title, description, colorValue, dateTime, todos]; -} +import 'dart:ui' show Color; + +import 'package:equatable/equatable.dart'; +import 'package:hive/hive.dart'; +import 'package:simple_hive_note/features/note/data/models/todo.dart'; +import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; + +part 'note.g.dart'; + +@HiveType(typeId: 0) +class Note extends Equatable implements Comparable { + @HiveField(0) + final String? id; + + @HiveField(1) + final String? title; + + @HiveField(2) + final String? description; + + @HiveField(3) + final int? colorValue; + + @HiveField(4) + final String? dateTime; + + @HiveField(5) + final List? todos; + + const Note({ + this.id, + this.title, + this.description, + this.colorValue, + this.dateTime, + this.todos = const [], + }); + + factory Note.fromNote(NoteEntity note) { + return Note( + id: note.id, + title: note.title, + description: note.description, + dateTime: note.dateTime?.toIso8601String(), + colorValue: note.color?.value, + todos: note.todos.map((todo) => Todo.fromDomain(todo)).toList(), + ); + } + + NoteEntity toDomain() { + return NoteEntity( + id: id, + title: title, + description: description, + dateTime: DateTime.tryParse(dateTime!), + color: Color(colorValue!), + todos: todos?.map((todo) => todo.toDomain()).toList() ?? [], + ); + } + + bool get validNote => title?.isNotEmpty == true; + + Note copyWith({ + String? id, + String? title, + String? description, + int? colorValue, + String? dateTime, + List? todos, + }) { + return Note( + id: id ?? this.id, + title: title ?? this.title, + description: description ?? this.description, + colorValue: colorValue ?? this.colorValue, + dateTime: dateTime ?? this.dateTime, + todos: todos ?? this.todos, + ); + } + + @override + int compareTo(other) { + try { + final _isAfter = DateTime.parse(other.dateTime).isAfter( + DateTime.parse(dateTime!), + ); + return _isAfter ? 1 : -1; + } catch (_) { + return 1; + } + } + + @override + List get props => + [id, title, description, colorValue, dateTime, todos]; +} diff --git a/lib/features/note/data/models/todo.dart b/lib/features/note/data/models/todo.dart index 66f062e..6aed4df 100644 --- a/lib/features/note/data/models/todo.dart +++ b/lib/features/note/data/models/todo.dart @@ -1,42 +1,42 @@ -import 'package:equatable/equatable.dart'; -import 'package:hive/hive.dart'; -import '../../domain/entities/todo_entity.dart'; - -part 'todo.g.dart'; - -@HiveType(typeId: 1) -class Todo extends Equatable { - @HiveField(0) - final String? id; - - @HiveField(1) - final String? title; - - @HiveField(2) - final bool? isCompleted; - - const Todo({ - this.id, - this.title, - this.isCompleted, - }); - - factory Todo.fromDomain(TodoEntity todo) { - return Todo( - id: todo.id, - title: todo.title, - isCompleted: todo.isCompleted, - ); - } - - TodoEntity toDomain() { - return TodoEntity( - id: id, - title: title, - isCompleted: isCompleted ?? false, - ); - } - - @override - List get props => [id, title, isCompleted]; -} +import 'package:equatable/equatable.dart'; +import 'package:hive/hive.dart'; +import '../../domain/entities/todo_entity.dart'; + +part 'todo.g.dart'; + +@HiveType(typeId: 1) +class Todo extends Equatable { + @HiveField(0) + final String? id; + + @HiveField(1) + final String? title; + + @HiveField(2) + final bool? isCompleted; + + const Todo({ + this.id, + this.title, + this.isCompleted, + }); + + factory Todo.fromDomain(TodoEntity todo) { + return Todo( + id: todo.id, + title: todo.title, + isCompleted: todo.isCompleted, + ); + } + + TodoEntity toDomain() { + return TodoEntity( + id: id, + title: title, + isCompleted: isCompleted ?? false, + ); + } + + @override + List get props => [id, title, isCompleted]; +} diff --git a/lib/features/note/data/repositories/note_repository.dart b/lib/features/note/data/repositories/note_repository.dart index bd19869..ebcdc70 100644 --- a/lib/features/note/data/repositories/note_repository.dart +++ b/lib/features/note/data/repositories/note_repository.dart @@ -1,56 +1,56 @@ -import 'package:simple_hive_note/core/data/database_provider.dart'; - -import '../../domain/repositories/note_repository.dart'; -import '../models/note.dart'; - -class NoteRepositoryImpl implements NoteRepository { - const NoteRepositoryImpl(); - - @override - Future addUpdateNote(Note note) async { - try { - await DatabaseProvider().addUpdate(note.id!, note); - } catch (e) { - rethrow; - } - } - - @override - Future deleteMultiNotes(List ids) async { - try { - await DatabaseProvider().deleteAll(ids); - } catch (e) { - rethrow; - } - } - - @override - Future deleteNote(String id) async { - try { - await DatabaseProvider().delete(id); - } catch (e) { - rethrow; - } - } - - @override - List getAllNotes() { - try { - final notes = - DatabaseProvider().getAll().map((note) => note as Note).toList(); - return notes; - } catch (e) { - rethrow; - } - } - - @override - Future getNote(String id) async { - try { - final note = await DatabaseProvider().get(id) as Note; - return note; - } catch (e) { - rethrow; - } - } -} +import 'package:simple_hive_note/core/data/database_provider.dart'; + +import '../../domain/repositories/note_repository.dart'; +import '../models/note.dart'; + +class NoteRepositoryImpl implements NoteRepository { + const NoteRepositoryImpl(); + + @override + Future addUpdateNote(Note note) async { + try { + await DatabaseProvider().addUpdate(note.id!, note); + } catch (e) { + rethrow; + } + } + + @override + Future deleteMultiNotes(List ids) async { + try { + await DatabaseProvider().deleteAll(ids); + } catch (e) { + rethrow; + } + } + + @override + Future deleteNote(String id) async { + try { + await DatabaseProvider().delete(id); + } catch (e) { + rethrow; + } + } + + @override + List getAllNotes() { + try { + final notes = + DatabaseProvider().getAll().map((note) => note as Note).toList(); + return notes; + } catch (e) { + rethrow; + } + } + + @override + Future getNote(String id) async { + try { + final note = await DatabaseProvider().get(id) as Note; + return note; + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/note/domain/entities/note_entity.dart b/lib/features/note/domain/entities/note_entity.dart index 2dffd6d..b70d2b5 100644 --- a/lib/features/note/domain/entities/note_entity.dart +++ b/lib/features/note/domain/entities/note_entity.dart @@ -1,29 +1,29 @@ -import 'dart:ui' show Color; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:intl/intl.dart'; -import '../../domain/entities/todo_entity.dart'; - -part 'note_entity.freezed.dart'; - -@freezed -class NoteEntity with _$NoteEntity { - NoteEntity._(); - - factory NoteEntity({ - String? id, - String? title, - String? description, - Color? color, - DateTime? dateTime, - @Default([]) List todos, - }) = _NoteEntity; - - final DateFormat _formatter = DateFormat('MMMM dd, yyyy'); - String get date => dateTime != null ? _formatter.format(dateTime!) : ''; - - final DateFormat _formatter1 = DateFormat('MMMM dd, yyyy h:m a'); - String get dateWithTime => - dateTime != null ? _formatter1.format(dateTime!) : ''; - - bool get hasTodo => todos.isNotEmpty; -} +import 'dart:ui' show Color; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:intl/intl.dart'; +import '../../domain/entities/todo_entity.dart'; + +part 'note_entity.freezed.dart'; + +@freezed +class NoteEntity with _$NoteEntity { + NoteEntity._(); + + factory NoteEntity({ + String? id, + String? title, + String? description, + Color? color, + DateTime? dateTime, + @Default([]) List todos, + }) = _NoteEntity; + + final DateFormat _formatter = DateFormat('MMMM dd, yyyy'); + String get date => dateTime != null ? _formatter.format(dateTime!) : ''; + + final DateFormat _formatter1 = DateFormat('MMMM dd, yyyy h:m a'); + String get dateWithTime => + dateTime != null ? _formatter1.format(dateTime!) : ''; + + bool get hasTodo => todos.isNotEmpty; +} diff --git a/lib/features/note/domain/entities/note_entity.freezed.dart b/lib/features/note/domain/entities/note_entity.freezed.dart index 3907e92..17a68c5 100644 --- a/lib/features/note/domain/entities/note_entity.freezed.dart +++ b/lib/features/note/domain/entities/note_entity.freezed.dart @@ -1,266 +1,266 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target - -part of 'note_entity.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); - -/// @nodoc -class _$NoteEntityTearOff { - const _$NoteEntityTearOff(); - - _NoteEntity call( - {String? id, - String? title, - String? description, - Color? color, - DateTime? dateTime, - List todos = const []}) { - return _NoteEntity( - id: id, - title: title, - description: description, - color: color, - dateTime: dateTime, - todos: todos, - ); - } -} - -/// @nodoc -const $NoteEntity = _$NoteEntityTearOff(); - -/// @nodoc -mixin _$NoteEntity { - String? get id => throw _privateConstructorUsedError; - String? get title => throw _privateConstructorUsedError; - String? get description => throw _privateConstructorUsedError; - Color? get color => throw _privateConstructorUsedError; - DateTime? get dateTime => throw _privateConstructorUsedError; - List get todos => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $NoteEntityCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $NoteEntityCopyWith<$Res> { - factory $NoteEntityCopyWith( - NoteEntity value, $Res Function(NoteEntity) then) = - _$NoteEntityCopyWithImpl<$Res>; - $Res call( - {String? id, - String? title, - String? description, - Color? color, - DateTime? dateTime, - List todos}); -} - -/// @nodoc -class _$NoteEntityCopyWithImpl<$Res> implements $NoteEntityCopyWith<$Res> { - _$NoteEntityCopyWithImpl(this._value, this._then); - - final NoteEntity _value; - // ignore: unused_field - final $Res Function(NoteEntity) _then; - - @override - $Res call({ - Object? id = freezed, - Object? title = freezed, - Object? description = freezed, - Object? color = freezed, - Object? dateTime = freezed, - Object? todos = freezed, - }) { - return _then(_value.copyWith( - id: id == freezed - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - title: title == freezed - ? _value.title - : title // ignore: cast_nullable_to_non_nullable - as String?, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - color: color == freezed - ? _value.color - : color // ignore: cast_nullable_to_non_nullable - as Color?, - dateTime: dateTime == freezed - ? _value.dateTime - : dateTime // ignore: cast_nullable_to_non_nullable - as DateTime?, - todos: todos == freezed - ? _value.todos - : todos // ignore: cast_nullable_to_non_nullable - as List, - )); - } -} - -/// @nodoc -abstract class _$NoteEntityCopyWith<$Res> implements $NoteEntityCopyWith<$Res> { - factory _$NoteEntityCopyWith( - _NoteEntity value, $Res Function(_NoteEntity) then) = - __$NoteEntityCopyWithImpl<$Res>; - @override - $Res call( - {String? id, - String? title, - String? description, - Color? color, - DateTime? dateTime, - List todos}); -} - -/// @nodoc -class __$NoteEntityCopyWithImpl<$Res> extends _$NoteEntityCopyWithImpl<$Res> - implements _$NoteEntityCopyWith<$Res> { - __$NoteEntityCopyWithImpl( - _NoteEntity _value, $Res Function(_NoteEntity) _then) - : super(_value, (v) => _then(v as _NoteEntity)); - - @override - _NoteEntity get _value => super._value as _NoteEntity; - - @override - $Res call({ - Object? id = freezed, - Object? title = freezed, - Object? description = freezed, - Object? color = freezed, - Object? dateTime = freezed, - Object? todos = freezed, - }) { - return _then(_NoteEntity( - id: id == freezed - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - title: title == freezed - ? _value.title - : title // ignore: cast_nullable_to_non_nullable - as String?, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - color: color == freezed - ? _value.color - : color // ignore: cast_nullable_to_non_nullable - as Color?, - dateTime: dateTime == freezed - ? _value.dateTime - : dateTime // ignore: cast_nullable_to_non_nullable - as DateTime?, - todos: todos == freezed - ? _value.todos - : todos // ignore: cast_nullable_to_non_nullable - as List, - )); - } -} - -/// @nodoc - -class _$_NoteEntity extends _NoteEntity { - _$_NoteEntity( - {this.id, - this.title, - this.description, - this.color, - this.dateTime, - this.todos = const []}) - : super._(); - - @override - final String? id; - @override - final String? title; - @override - final String? description; - @override - final Color? color; - @override - final DateTime? dateTime; - @JsonKey() - @override - final List todos; - - @override - String toString() { - return 'NoteEntity(id: $id, title: $title, description: $description, color: $color, dateTime: $dateTime, todos: $todos)'; - } - - @override - bool operator ==(dynamic other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _NoteEntity && - const DeepCollectionEquality().equals(other.id, id) && - const DeepCollectionEquality().equals(other.title, title) && - const DeepCollectionEquality() - .equals(other.description, description) && - const DeepCollectionEquality().equals(other.color, color) && - const DeepCollectionEquality().equals(other.dateTime, dateTime) && - const DeepCollectionEquality().equals(other.todos, todos)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - const DeepCollectionEquality().hash(title), - const DeepCollectionEquality().hash(description), - const DeepCollectionEquality().hash(color), - const DeepCollectionEquality().hash(dateTime), - const DeepCollectionEquality().hash(todos)); - - @JsonKey(ignore: true) - @override - _$NoteEntityCopyWith<_NoteEntity> get copyWith => - __$NoteEntityCopyWithImpl<_NoteEntity>(this, _$identity); -} - -abstract class _NoteEntity extends NoteEntity { - factory _NoteEntity( - {String? id, - String? title, - String? description, - Color? color, - DateTime? dateTime, - List todos}) = _$_NoteEntity; - _NoteEntity._() : super._(); - - @override - String? get id; - @override - String? get title; - @override - String? get description; - @override - Color? get color; - @override - DateTime? get dateTime; - @override - List get todos; - @override - @JsonKey(ignore: true) - _$NoteEntityCopyWith<_NoteEntity> get copyWith => - throw _privateConstructorUsedError; -} +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'note_entity.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +class _$NoteEntityTearOff { + const _$NoteEntityTearOff(); + + _NoteEntity call( + {String? id, + String? title, + String? description, + Color? color, + DateTime? dateTime, + List todos = const []}) { + return _NoteEntity( + id: id, + title: title, + description: description, + color: color, + dateTime: dateTime, + todos: todos, + ); + } +} + +/// @nodoc +const $NoteEntity = _$NoteEntityTearOff(); + +/// @nodoc +mixin _$NoteEntity { + String? get id => throw _privateConstructorUsedError; + String? get title => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; + Color? get color => throw _privateConstructorUsedError; + DateTime? get dateTime => throw _privateConstructorUsedError; + List get todos => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $NoteEntityCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $NoteEntityCopyWith<$Res> { + factory $NoteEntityCopyWith( + NoteEntity value, $Res Function(NoteEntity) then) = + _$NoteEntityCopyWithImpl<$Res>; + $Res call( + {String? id, + String? title, + String? description, + Color? color, + DateTime? dateTime, + List todos}); +} + +/// @nodoc +class _$NoteEntityCopyWithImpl<$Res> implements $NoteEntityCopyWith<$Res> { + _$NoteEntityCopyWithImpl(this._value, this._then); + + final NoteEntity _value; + // ignore: unused_field + final $Res Function(NoteEntity) _then; + + @override + $Res call({ + Object? id = freezed, + Object? title = freezed, + Object? description = freezed, + Object? color = freezed, + Object? dateTime = freezed, + Object? todos = freezed, + }) { + return _then(_value.copyWith( + id: id == freezed + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + title: title == freezed + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String?, + description: description == freezed + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + color: color == freezed + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as Color?, + dateTime: dateTime == freezed + ? _value.dateTime + : dateTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + todos: todos == freezed + ? _value.todos + : todos // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +abstract class _$NoteEntityCopyWith<$Res> implements $NoteEntityCopyWith<$Res> { + factory _$NoteEntityCopyWith( + _NoteEntity value, $Res Function(_NoteEntity) then) = + __$NoteEntityCopyWithImpl<$Res>; + @override + $Res call( + {String? id, + String? title, + String? description, + Color? color, + DateTime? dateTime, + List todos}); +} + +/// @nodoc +class __$NoteEntityCopyWithImpl<$Res> extends _$NoteEntityCopyWithImpl<$Res> + implements _$NoteEntityCopyWith<$Res> { + __$NoteEntityCopyWithImpl( + _NoteEntity _value, $Res Function(_NoteEntity) _then) + : super(_value, (v) => _then(v as _NoteEntity)); + + @override + _NoteEntity get _value => super._value as _NoteEntity; + + @override + $Res call({ + Object? id = freezed, + Object? title = freezed, + Object? description = freezed, + Object? color = freezed, + Object? dateTime = freezed, + Object? todos = freezed, + }) { + return _then(_NoteEntity( + id: id == freezed + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + title: title == freezed + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String?, + description: description == freezed + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + color: color == freezed + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as Color?, + dateTime: dateTime == freezed + ? _value.dateTime + : dateTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + todos: todos == freezed + ? _value.todos + : todos // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$_NoteEntity extends _NoteEntity { + _$_NoteEntity( + {this.id, + this.title, + this.description, + this.color, + this.dateTime, + this.todos = const []}) + : super._(); + + @override + final String? id; + @override + final String? title; + @override + final String? description; + @override + final Color? color; + @override + final DateTime? dateTime; + @JsonKey() + @override + final List todos; + + @override + String toString() { + return 'NoteEntity(id: $id, title: $title, description: $description, color: $color, dateTime: $dateTime, todos: $todos)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _NoteEntity && + const DeepCollectionEquality().equals(other.id, id) && + const DeepCollectionEquality().equals(other.title, title) && + const DeepCollectionEquality() + .equals(other.description, description) && + const DeepCollectionEquality().equals(other.color, color) && + const DeepCollectionEquality().equals(other.dateTime, dateTime) && + const DeepCollectionEquality().equals(other.todos, todos)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(id), + const DeepCollectionEquality().hash(title), + const DeepCollectionEquality().hash(description), + const DeepCollectionEquality().hash(color), + const DeepCollectionEquality().hash(dateTime), + const DeepCollectionEquality().hash(todos)); + + @JsonKey(ignore: true) + @override + _$NoteEntityCopyWith<_NoteEntity> get copyWith => + __$NoteEntityCopyWithImpl<_NoteEntity>(this, _$identity); +} + +abstract class _NoteEntity extends NoteEntity { + factory _NoteEntity( + {String? id, + String? title, + String? description, + Color? color, + DateTime? dateTime, + List todos}) = _$_NoteEntity; + _NoteEntity._() : super._(); + + @override + String? get id; + @override + String? get title; + @override + String? get description; + @override + Color? get color; + @override + DateTime? get dateTime; + @override + List get todos; + @override + @JsonKey(ignore: true) + _$NoteEntityCopyWith<_NoteEntity> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/note/domain/entities/todo_entity.dart b/lib/features/note/domain/entities/todo_entity.dart index 5284126..be8bab5 100644 --- a/lib/features/note/domain/entities/todo_entity.dart +++ b/lib/features/note/domain/entities/todo_entity.dart @@ -1,24 +1,24 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -part 'todo_entity.freezed.dart'; - -@freezed -class TodoEntity with _$TodoEntity { - const TodoEntity._(); - - factory TodoEntity({ - String? id, - String? title, - @Default(false) bool isCompleted, - }) = _TodoEntity; - - factory TodoEntity.empty() { - const _uuid = Uuid(); - return TodoEntity( - id: _uuid.v4(), - title: '', - isCompleted: false, - ); - } -} +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:uuid/uuid.dart'; + +part 'todo_entity.freezed.dart'; + +@freezed +class TodoEntity with _$TodoEntity { + const TodoEntity._(); + + factory TodoEntity({ + String? id, + String? title, + @Default(false) bool isCompleted, + }) = _TodoEntity; + + factory TodoEntity.empty() { + const _uuid = Uuid(); + return TodoEntity( + id: _uuid.v4(), + title: '', + isCompleted: false, + ); + } +} diff --git a/lib/features/note/domain/repositories/note_repository.dart b/lib/features/note/domain/repositories/note_repository.dart index e02245a..14da8ab 100644 --- a/lib/features/note/domain/repositories/note_repository.dart +++ b/lib/features/note/domain/repositories/note_repository.dart @@ -1,11 +1,11 @@ -import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; - -import '../../data/models/note.dart'; - -abstract class NoteRepository { - List getAllNotes(); - Future getNote(String id); - Future addUpdateNote(Note note); - Future deleteNote(String id); - Future deleteMultiNotes(List ids); -} +import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; + +import '../../data/models/note.dart'; + +abstract class NoteRepository { + List getAllNotes(); + Future getNote(String id); + Future addUpdateNote(Note note); + Future deleteNote(String id); + Future deleteMultiNotes(List ids); +} diff --git a/lib/features/note/domain/usecases/add_update_note_usecase.dart b/lib/features/note/domain/usecases/add_update_note_usecase.dart index 8c05403..f6fa3b1 100644 --- a/lib/features/note/domain/usecases/add_update_note_usecase.dart +++ b/lib/features/note/domain/usecases/add_update_note_usecase.dart @@ -1,43 +1,43 @@ -import 'package:dartz/dartz.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/exceptions/error.dart'; -import 'package:simple_hive_note/features/note/data/models/note.dart'; -import 'package:uuid/uuid.dart'; - -import '../entities/note_entity.dart'; -import '../repositories/note_repository.dart'; -import '../../../../core/utils/utils.dart'; - -class AddUpdateNoteUsecase { - final NoteRepository _repository; - final _uuid = const Uuid(); - - const AddUpdateNoteUsecase(this._repository); - - Future> call(NoteEntity noteEntity) async { - final bool _isEdit = noteEntity.id != null; - try { - noteEntity.todos.removeWhere((todo) => todo.title.isEmptyString); - final note = Note.fromNote(noteEntity); - - if (!note.validNote) { - return left( - NoteError( - message: _isEdit ? "title_update_empty".tr : "title_empty".tr, - ), - ); - } - - await _repository - .addUpdateNote(_isEdit ? note : note.copyWith(id: _uuid.v4())); - return right(unit); - } catch (e) { - print(e); - return left( - NoteError( - message: _isEdit ? "failed_update_notes".tr : "failed_add_notes".tr, - ), - ); - } - } -} +import 'package:dartz/dartz.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/exceptions/error.dart'; +import 'package:simple_hive_note/features/note/data/models/note.dart'; +import 'package:uuid/uuid.dart'; + +import '../entities/note_entity.dart'; +import '../repositories/note_repository.dart'; +import '../../../../core/utils/utils.dart'; + +class AddUpdateNoteUsecase { + final NoteRepository _repository; + final _uuid = const Uuid(); + + const AddUpdateNoteUsecase(this._repository); + + Future> call(NoteEntity noteEntity) async { + final bool _isEdit = noteEntity.id != null; + try { + noteEntity.todos.removeWhere((todo) => todo.title.isEmptyString); + final note = Note.fromNote(noteEntity); + + if (!note.validNote) { + return left( + NoteError( + message: _isEdit ? "title_update_empty".tr : "title_empty".tr, + ), + ); + } + + await _repository + .addUpdateNote(_isEdit ? note : note.copyWith(id: _uuid.v4())); + return right(unit); + } catch (e) { + print(e); + return left( + NoteError( + message: _isEdit ? "failed_update_notes".tr : "failed_add_notes".tr, + ), + ); + } + } +} diff --git a/lib/features/note/domain/usecases/delete_multiple_notes_usecase.dart b/lib/features/note/domain/usecases/delete_multiple_notes_usecase.dart index 9a7eade..1f62654 100644 --- a/lib/features/note/domain/usecases/delete_multiple_notes_usecase.dart +++ b/lib/features/note/domain/usecases/delete_multiple_notes_usecase.dart @@ -1,22 +1,22 @@ -import 'package:dartz/dartz.dart'; -import 'package:get/get_utils/src/extensions/internacionalization.dart'; - -import '../../../../core/exceptions/error.dart'; -import '../repositories/note_repository.dart'; - -class DeleteMultipleNoteUsecase { - final NoteRepository _repository; - - const DeleteMultipleNoteUsecase(this._repository); - - Future> call(List ids) async { - try { - await _repository.deleteMultiNotes(ids); - return right(unit); - } catch (e) { - return left( - NoteError(message: "failed_delete_notes".tr), - ); - } - } -} +import 'package:dartz/dartz.dart'; +import 'package:get/get_utils/src/extensions/internacionalization.dart'; + +import '../../../../core/exceptions/error.dart'; +import '../repositories/note_repository.dart'; + +class DeleteMultipleNoteUsecase { + final NoteRepository _repository; + + const DeleteMultipleNoteUsecase(this._repository); + + Future> call(List ids) async { + try { + await _repository.deleteMultiNotes(ids); + return right(unit); + } catch (e) { + return left( + NoteError(message: "failed_delete_notes".tr), + ); + } + } +} diff --git a/lib/features/note/domain/usecases/delete_note_usecase.dart b/lib/features/note/domain/usecases/delete_note_usecase.dart index b5bcdf3..ee193d8 100644 --- a/lib/features/note/domain/usecases/delete_note_usecase.dart +++ b/lib/features/note/domain/usecases/delete_note_usecase.dart @@ -1,22 +1,22 @@ -import 'package:dartz/dartz.dart'; -import 'package:get/get_utils/src/extensions/internacionalization.dart'; - -import '../../../../core/exceptions/error.dart'; -import '../repositories/note_repository.dart'; - -class DeleteNoteUsecase { - final NoteRepository _repository; - - const DeleteNoteUsecase(this._repository); - - Future> call(String id) async { - try { - await _repository.deleteNote(id); - return right(unit); - } catch (e) { - return left( - NoteError(message: "failed_delete_notes".tr), - ); - } - } -} +import 'package:dartz/dartz.dart'; +import 'package:get/get_utils/src/extensions/internacionalization.dart'; + +import '../../../../core/exceptions/error.dart'; +import '../repositories/note_repository.dart'; + +class DeleteNoteUsecase { + final NoteRepository _repository; + + const DeleteNoteUsecase(this._repository); + + Future> call(String id) async { + try { + await _repository.deleteNote(id); + return right(unit); + } catch (e) { + return left( + NoteError(message: "failed_delete_notes".tr), + ); + } + } +} diff --git a/lib/features/note/domain/usecases/get_all_note_usecase.dart b/lib/features/note/domain/usecases/get_all_note_usecase.dart index 826bef9..091e8c1 100644 --- a/lib/features/note/domain/usecases/get_all_note_usecase.dart +++ b/lib/features/note/domain/usecases/get_all_note_usecase.dart @@ -1,37 +1,37 @@ -import 'package:simple_hive_note/core/exceptions/error.dart'; - -import 'package:dartz/dartz.dart'; -import 'package:simple_hive_note/core/exceptions/exception.dart'; -import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; -import 'package:simple_hive_note/features/note/domain/repositories/note_repository.dart'; - -import '../../../../core/usecase/base_usecase.dart'; -import 'package:get/get.dart'; - -class GetAllNotesUsecase extends BaseUseCase> { - final NoteRepository _repository; - - GetAllNotesUsecase(this._repository); - - @override - Future>> call([Unit? params]) async { - try { - final notes = _repository.getAllNotes(); - final sortedNotes = - (notes..sort()).map((note) => note.toDomain()).toList(); - - return right(sortedNotes); - } catch (e) { - print("USECASE ERROR ====> $e"); - if (e is NoRecordsException) { - return left( - NoteError(message: 'empty_note'.tr), - ); - } else { - return left( - NoteError(message: "failed_load_notes".tr), - ); - } - } - } -} +import 'package:simple_hive_note/core/exceptions/error.dart'; + +import 'package:dartz/dartz.dart'; +import 'package:simple_hive_note/core/exceptions/exception.dart'; +import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; +import 'package:simple_hive_note/features/note/domain/repositories/note_repository.dart'; + +import '../../../../core/usecase/base_usecase.dart'; +import 'package:get/get.dart'; + +class GetAllNotesUsecase extends BaseUseCase> { + final NoteRepository _repository; + + GetAllNotesUsecase(this._repository); + + @override + Future>> call([Unit? params]) async { + try { + final notes = _repository.getAllNotes(); + final sortedNotes = + (notes..sort()).map((note) => note.toDomain()).toList(); + + return right(sortedNotes); + } catch (e) { + print("USECASE ERROR ====> $e"); + if (e is NoRecordsException) { + return left( + NoteError(message: 'empty_note'.tr), + ); + } else { + return left( + NoteError(message: "failed_load_notes".tr), + ); + } + } + } +} diff --git a/lib/features/note/domain/usecases/get_note_usecase.dart b/lib/features/note/domain/usecases/get_note_usecase.dart index 054ee5f..1005508 100644 --- a/lib/features/note/domain/usecases/get_note_usecase.dart +++ b/lib/features/note/domain/usecases/get_note_usecase.dart @@ -1,32 +1,32 @@ -import 'package:dartz/dartz.dart'; -import 'package:get/get.dart'; - -import '../../../../core/exceptions/error.dart'; -import '../../../../core/exceptions/exception.dart'; -import '../entities/note_entity.dart'; -import '../repositories/note_repository.dart'; - -class GetNoteUsecase { - final NoteRepository _repository; - - const GetNoteUsecase(this._repository); - - Future> call(String id) async { - try { - final note = await _repository.getNote(id); - final noteEntity = note.toDomain(); - - return right(noteEntity); - } catch (e) { - if (e is NoRecordsException) { - return left( - NoteError(message: 'no_match_note'.tr), - ); - } else { - return left( - NoteError(message: "failed_load_notes".tr), - ); - } - } - } -} +import 'package:dartz/dartz.dart'; +import 'package:get/get.dart'; + +import '../../../../core/exceptions/error.dart'; +import '../../../../core/exceptions/exception.dart'; +import '../entities/note_entity.dart'; +import '../repositories/note_repository.dart'; + +class GetNoteUsecase { + final NoteRepository _repository; + + const GetNoteUsecase(this._repository); + + Future> call(String id) async { + try { + final note = await _repository.getNote(id); + final noteEntity = note.toDomain(); + + return right(noteEntity); + } catch (e) { + if (e is NoRecordsException) { + return left( + NoteError(message: 'no_match_note'.tr), + ); + } else { + return left( + NoteError(message: "failed_load_notes".tr), + ); + } + } + } +} diff --git a/lib/features/note/presentation/controllers/note_controller.dart b/lib/features/note/presentation/controllers/note_controller.dart index 7e06ede..d92b6b4 100644 --- a/lib/features/note/presentation/controllers/note_controller.dart +++ b/lib/features/note/presentation/controllers/note_controller.dart @@ -1,193 +1,193 @@ -import 'package:flutter/cupertino.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; -import 'package:uuid/uuid.dart'; - -import '../../../../core/routes/app_routes.dart'; -import '../../../../core/utils/snackbar.dart'; -import '../../../../core/utils/utils.dart'; -import '../../domain/entities/note_entity.dart'; -import '../../domain/usecases/add_update_note_usecase.dart'; -import '../../domain/usecases/delete_multiple_notes_usecase.dart'; -import '../../domain/usecases/delete_note_usecase.dart'; -import '../../domain/usecases/get_all_note_usecase.dart'; -import '../../domain/entities/todo_entity.dart'; - -class NoteController extends GetxController { - final GetNoteUsecase _getNoteUsecase; - final GetAllNotesUsecase _getAllNotesUsecase; - final AddUpdateNoteUsecase _addUpdateNoteUsecase; - final DeleteNoteUsecase _deleteNoteUsecase; - final DeleteMultipleNoteUsecase _deleteMultipleNoteUsecase; - NoteController( - this._getNoteUsecase, - this._getAllNotesUsecase, - this._addUpdateNoteUsecase, - this._deleteNoteUsecase, - this._deleteMultipleNoteUsecase, - ); - - List notes = []; - NoteEntity? note; - String? error; - - List selectedIds = []; - - late TextEditingController titleController; - late TextEditingController descriptionController; - - RxBool isLoading = false.obs; - RxList todos = [].obs; - Rx selectedColor = (colors.randomElement as Color).obs; - - @override - void onInit() { - super.onInit(); - - fetchAllNotes(); - } - - void setSelectedColor(Color value) => selectedColor.value = value; - - void setNoteError(String error) { - this.error = error; - // update(['note_list', 'note_detail']); - } - - bool isErrorNotEmpty() => error != null; - - fetchNote(String noteId) async { - final failOrSuccess = await _getNoteUsecase(noteId); - - failOrSuccess.fold( - (error) => setNoteError(error.message!), - (note) { - this.note = note; - error = null; - }, - ); - update(['note_detail']); - } - - fetchAllNotes() async { - final failOrSuccess = await _getAllNotesUsecase(); - - failOrSuccess.fold( - (error) => setNoteError(error.message!), - (noteEntities) { - notes.clear(); - notes.addAll(noteEntities); - error = null; - }, - ); - update(['note_list']); - } - - addUpdateNote(NoteEntity note, {bool pop = true}) async { - final bool _isEdit = note.id != null; - final failOrSuccess = await _addUpdateNoteUsecase(note); - - isLoading.value = true; - - await Future.delayed(animationDuration); - - failOrSuccess.fold( - (error) { - AppSnackbar.showSnackbar(error.message ?? "", isError: true); - }, - (_) { - if (_isEdit) { - AppSnackbar.showSnackbar("note_updated".tr); - } else { - AppSnackbar.showSnackbar("note_added".tr); - } - if (pop) { - Get.offAndToNamed(AppRoutes.note); - } - }, - ); - - isLoading.value = false; - } - - bool isSelected(String? id) => (id != null) && (selectedIds.contains(id)); - - toggleSelect(String noteId) { - if (selectedIds.contains(noteId)) { - selectedIds.remove(noteId); - } else { - selectedIds.add(noteId); - } - update(['note_list', 'note_actions']); - } - - void cancelDeleting() { - selectedIds.clear(); - update(['note_list', 'note_actions']); - } - - deleteMultiNotes() async { - final failOrSuccess = await _deleteMultipleNoteUsecase(selectedIds); - - failOrSuccess.fold( - (error) => AppSnackbar.showSnackbar(error.message ?? "", isError: true), - (_) { - AppSnackbar.showSnackbar("${selectedIds.length} ${"delete_msg".tr}"); - selectedIds.clear(); - update(['note_list', 'note_actions']); - }, - ); - } - - delete(String noteId) async { - final failOrSuccess = await _deleteNoteUsecase(noteId); - - failOrSuccess.fold( - (error) => AppSnackbar.showSnackbar(error.message ?? "", isError: true), - (_) { - AppSnackbar.showSnackbar("1 ${"delete_msg".tr}"); - update(['note_list']); - }, - ); - } - - addEmptyTodo() { - todos.add(TodoEntity.empty()); - } - - removeTodo(TodoEntity todo) { - todos.remove(todo); - } - - todoValueChanged(String value, String id) { - final updateTodoList = todos.map((todo) { - if (todo.id == id) { - return todo.copyWith(title: value); - } - return todo; - }).toList(); - - todos.value = updateTodoList; - } - - toggleTodoIsCompleted(String todoId) async { - final updatedNote = note!.copyWith( - todos: note!.todos.map((todo) { - if (todo.id == todoId) { - return todo.copyWith(isCompleted: !todo.isCompleted); - } - return todo; - }).toList(), - ); - - final failOrSuccess = await _addUpdateNoteUsecase(updatedNote); - - failOrSuccess.fold( - (error) => AppSnackbar.showSnackbar(error.message ?? ""), - (_) { - note = updatedNote; - }, - ); - update(['note_detail']); - } -} +import 'package:flutter/cupertino.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; +import 'package:uuid/uuid.dart'; + +import '../../../../core/routes/app_routes.dart'; +import '../../../../core/utils/snackbar.dart'; +import '../../../../core/utils/utils.dart'; +import '../../domain/entities/note_entity.dart'; +import '../../domain/usecases/add_update_note_usecase.dart'; +import '../../domain/usecases/delete_multiple_notes_usecase.dart'; +import '../../domain/usecases/delete_note_usecase.dart'; +import '../../domain/usecases/get_all_note_usecase.dart'; +import '../../domain/entities/todo_entity.dart'; + +class NoteController extends GetxController { + final GetNoteUsecase _getNoteUsecase; + final GetAllNotesUsecase _getAllNotesUsecase; + final AddUpdateNoteUsecase _addUpdateNoteUsecase; + final DeleteNoteUsecase _deleteNoteUsecase; + final DeleteMultipleNoteUsecase _deleteMultipleNoteUsecase; + NoteController( + this._getNoteUsecase, + this._getAllNotesUsecase, + this._addUpdateNoteUsecase, + this._deleteNoteUsecase, + this._deleteMultipleNoteUsecase, + ); + + List notes = []; + NoteEntity? note; + String? error; + + List selectedIds = []; + + late TextEditingController titleController; + late TextEditingController descriptionController; + + RxBool isLoading = false.obs; + RxList todos = [].obs; + Rx selectedColor = (colors.randomElement as Color).obs; + + @override + void onInit() { + super.onInit(); + + fetchAllNotes(); + } + + void setSelectedColor(Color value) => selectedColor.value = value; + + void setNoteError(String error) { + this.error = error; + // update(['note_list', 'note_detail']); + } + + bool isErrorNotEmpty() => error != null; + + fetchNote(String noteId) async { + final failOrSuccess = await _getNoteUsecase(noteId); + + failOrSuccess.fold( + (error) => setNoteError(error.message!), + (note) { + this.note = note; + error = null; + }, + ); + update(['note_detail']); + } + + fetchAllNotes() async { + final failOrSuccess = await _getAllNotesUsecase(); + + failOrSuccess.fold( + (error) => setNoteError(error.message!), + (noteEntities) { + notes.clear(); + notes.addAll(noteEntities); + error = null; + }, + ); + update(['note_list']); + } + + addUpdateNote(NoteEntity note, {bool pop = true}) async { + final bool _isEdit = note.id != null; + final failOrSuccess = await _addUpdateNoteUsecase(note); + + isLoading.value = true; + + await Future.delayed(animationDuration); + + failOrSuccess.fold( + (error) { + AppSnackbar.showSnackbar(error.message ?? "", isError: true); + }, + (_) { + if (_isEdit) { + AppSnackbar.showSnackbar("note_updated".tr); + } else { + AppSnackbar.showSnackbar("note_added".tr); + } + if (pop) { + Get.offAndToNamed(AppRoutes.note); + } + }, + ); + + isLoading.value = false; + } + + bool isSelected(String? id) => (id != null) && (selectedIds.contains(id)); + + toggleSelect(String noteId) { + if (selectedIds.contains(noteId)) { + selectedIds.remove(noteId); + } else { + selectedIds.add(noteId); + } + update(['note_list', 'note_actions']); + } + + void cancelDeleting() { + selectedIds.clear(); + update(['note_list', 'note_actions']); + } + + deleteMultiNotes() async { + final failOrSuccess = await _deleteMultipleNoteUsecase(selectedIds); + + failOrSuccess.fold( + (error) => AppSnackbar.showSnackbar(error.message ?? "", isError: true), + (_) { + AppSnackbar.showSnackbar("${selectedIds.length} ${"delete_msg".tr}"); + selectedIds.clear(); + update(['note_list', 'note_actions']); + }, + ); + } + + delete(String noteId) async { + final failOrSuccess = await _deleteNoteUsecase(noteId); + + failOrSuccess.fold( + (error) => AppSnackbar.showSnackbar(error.message ?? "", isError: true), + (_) { + AppSnackbar.showSnackbar("1 ${"delete_msg".tr}"); + update(['note_list']); + }, + ); + } + + addEmptyTodo() { + todos.add(TodoEntity.empty()); + } + + removeTodo(TodoEntity todo) { + todos.remove(todo); + } + + todoValueChanged(String value, String id) { + final updateTodoList = todos.map((todo) { + if (todo.id == id) { + return todo.copyWith(title: value); + } + return todo; + }).toList(); + + todos.value = updateTodoList; + } + + toggleTodoIsCompleted(String todoId) async { + final updatedNote = note!.copyWith( + todos: note!.todos.map((todo) { + if (todo.id == todoId) { + return todo.copyWith(isCompleted: !todo.isCompleted); + } + return todo; + }).toList(), + ); + + final failOrSuccess = await _addUpdateNoteUsecase(updatedNote); + + failOrSuccess.fold( + (error) => AppSnackbar.showSnackbar(error.message ?? ""), + (_) { + note = updatedNote; + }, + ); + update(['note_detail']); + } +} diff --git a/lib/features/note/presentation/controllers/note_detail_controller.dart b/lib/features/note/presentation/controllers/note_detail_controller.dart index 27ac8af..d214c90 100644 --- a/lib/features/note/presentation/controllers/note_detail_controller.dart +++ b/lib/features/note/presentation/controllers/note_detail_controller.dart @@ -1,25 +1,25 @@ -import 'package:get/get_state_manager/get_state_manager.dart'; -import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; -import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; - -class NoteDetailController extends GetxController { - final GetNoteUsecase _getNoteUsecase; - - NoteDetailController(this._getNoteUsecase); - - Future getNote(String noteId) async { - final failOrSuccess = await _getNoteUsecase(noteId); - - failOrSuccess.fold( - (e) { - print(e.message); - return Future.error(e.message ?? ""); - }, - (note) { - return note; - }, - ); - update(['note_detail']); - return null; - } -} +import 'package:get/get_state_manager/get_state_manager.dart'; +import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; +import 'package:simple_hive_note/features/note/domain/usecases/get_note_usecase.dart'; + +class NoteDetailController extends GetxController { + final GetNoteUsecase _getNoteUsecase; + + NoteDetailController(this._getNoteUsecase); + + Future getNote(String noteId) async { + final failOrSuccess = await _getNoteUsecase(noteId); + + failOrSuccess.fold( + (e) { + print(e.message); + return Future.error(e.message ?? ""); + }, + (note) { + return note; + }, + ); + update(['note_detail']); + return null; + } +} diff --git a/lib/features/note/presentation/controllers/setting_controller.dart b/lib/features/note/presentation/controllers/setting_controller.dart index 3fb45cf..d9f67ca 100644 --- a/lib/features/note/presentation/controllers/setting_controller.dart +++ b/lib/features/note/presentation/controllers/setting_controller.dart @@ -1,66 +1,66 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../core/data/local_storage_provider.dart'; -import '../../../../core/utils/constants.dart'; -import '../../../../core/utils/strings.dart'; - -class SettingController extends GetxController { - late RxBool isDarkMode = true.obs; - late RxString currentLocale = "".obs; - - ThemeMode get themeMode => - _getIsDarkMode() ? ThemeMode.dark : ThemeMode.light; - - Locale get locale => _getLocale() == "fa" ? fa : us; - - final settings = ["change_theme".tr, "change_language".tr]; - - @override - void onInit() { - isDarkMode.value = _getIsDarkMode(); - currentLocale.value = _getLocale(); - super.onInit(); - } - - void toggleTheme() { - changeTheme(!isDarkMode.value); - final mode = isDarkMode.value ? ThemeMode.dark : ThemeMode.light; - Get.changeThemeMode(mode); - } - - void toggleLocale() { - changeLocale(currentLocale.value == "fa" ? "us" : "fa"); - final locale = currentLocale.value == "fa" ? fa : us; - Get.updateLocale(locale); - } - - void changeTheme(bool value) async { - isDarkMode.value = value; - await LocalStorageProvider().write(AppStrings.isDark, value); - Get.changeThemeMode(themeMode); - print("isDarkMode = $isDarkMode"); - } - - void changeLocale(String value) async { - currentLocale.value = value; - await LocalStorageProvider().write(AppStrings.locale, value); - print("locale = $currentLocale"); - } - - bool _getIsDarkMode() { - try { - return LocalStorageProvider().read(AppStrings.isDark); - } catch (e) { - return Get.isDarkMode; - } - } - - String _getLocale() { - try { - return LocalStorageProvider().read(AppStrings.locale); - } catch (e) { - return "fa"; - } - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../core/data/local_storage_provider.dart'; +import '../../../../core/utils/constants.dart'; +import '../../../../core/utils/strings.dart'; + +class SettingController extends GetxController { + late RxBool isDarkMode = true.obs; + late RxString currentLocale = "".obs; + + ThemeMode get themeMode => + _getIsDarkMode() ? ThemeMode.dark : ThemeMode.light; + + Locale get locale => _getLocale() == "fa" ? fa : us; + + final settings = ["change_theme".tr, "change_language".tr]; + + @override + void onInit() { + isDarkMode.value = _getIsDarkMode(); + currentLocale.value = _getLocale(); + super.onInit(); + } + + void toggleTheme() { + changeTheme(!isDarkMode.value); + final mode = isDarkMode.value ? ThemeMode.dark : ThemeMode.light; + Get.changeThemeMode(mode); + } + + void toggleLocale() { + changeLocale(currentLocale.value == "fa" ? "us" : "fa"); + final locale = currentLocale.value == "fa" ? fa : us; + Get.updateLocale(locale); + } + + void changeTheme(bool value) async { + isDarkMode.value = value; + await LocalStorageProvider().write(AppStrings.isDark, value); + Get.changeThemeMode(themeMode); + print("isDarkMode = $isDarkMode"); + } + + void changeLocale(String value) async { + currentLocale.value = value; + await LocalStorageProvider().write(AppStrings.locale, value); + print("locale = $currentLocale"); + } + + bool _getIsDarkMode() { + try { + return LocalStorageProvider().read(AppStrings.isDark); + } catch (e) { + return Get.isDarkMode; + } + } + + String _getLocale() { + try { + return LocalStorageProvider().read(AppStrings.locale); + } catch (e) { + return "fa"; + } + } +} diff --git a/lib/features/note/presentation/pages/notes/add_update_note_screen.dart b/lib/features/note/presentation/pages/notes/add_update_note_screen.dart index c609862..590a3c3 100644 --- a/lib/features/note/presentation/pages/notes/add_update_note_screen.dart +++ b/lib/features/note/presentation/pages/notes/add_update_note_screen.dart @@ -1,133 +1,133 @@ -import 'package:animate_do/animate_do.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../../core/utils/utils.dart'; -import '../../../../../core/widgets/widgets.dart'; -import '../../../domain/entities/note_entity.dart'; -import '../../controllers/note_controller.dart'; -import '../../widgets/add_update/add_todo.dart'; -import '../../widgets/add_update/colors_bar.dart'; -import '../../widgets/add_update/input_field.dart'; -import '../../../domain/entities/todo_entity.dart'; - -class AddUpdateNoteScreen extends StatefulWidget { - const AddUpdateNoteScreen({Key? key}) : super(key: key); - - @override - State createState() => _AddUpdateNoteScreenState(); -} - -class _AddUpdateNoteScreenState extends State { - final controller = Get.find(); - - @override - void initState() { - super.initState(); - final NoteEntity? note = Get.arguments; - - controller.titleController = TextEditingController(text: note?.title); - controller.descriptionController = - TextEditingController(text: note?.description); - - controller.selectedColor.value = - note?.color ?? colors.randomElement as Color; - controller.todos.value = note?.todos ?? []; - } - - @override - Widget build(BuildContext context) { - final NoteEntity? note = Get.arguments; - return Obx( - () => Stack( - children: [ - _BuildForm( - controller: controller, - note: note, - ), - if (controller.isLoading.value) - FadeIn( - child: Container( - color: Colors.black.withOpacity(.2), - ), - ), - ], - ), - ); - } -} - -class _BuildForm extends StatelessWidget { - _BuildForm({ - Key? key, - required this.controller, - required this.note, - }) : super(key: key); - - final NoteController controller; - final NoteEntity? note; - List todos = []; - - @override - Widget build(BuildContext context) { - return Obx( - () => Scaffold( - backgroundColor: controller.selectedColor.value, - bottomNavigationBar: ColorsBar( - selectedColor: controller.selectedColor.value, - onChanged: controller.setSelectedColor, - ), - appBar: NoteAppbar( - actions: [ - ActionButton( - child: Text( - controller.isLoading.value ? "saving".tr : "save".tr, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - onPressed: _addUdpdateNote, - ), - ], - ), - body: SingleChildScrollView( - padding: const EdgeInsets.all(AppSpacings.xl), - child: Column( - children: [ - BuildField( - controller: controller.titleController, - hint: "title".tr, - autoFocus: true, - textInputAction: TextInputAction.next, - maxLines: 2, - ), - // const SizedBox(height: 10), - BuildAddTodoList(controller: controller), - BuildField( - controller: controller.descriptionController, - hint: "type_something".tr, - maxLines: null, - fonSize: 20, - ), - ], - ), - ), - ), - ); - } - - _addUdpdateNote() { - final noteEntity = NoteEntity( - id: note != null ? note!.id! : null, - title: controller.titleController.text, - description: controller.descriptionController.text, - dateTime: DateTime.now(), - color: controller.selectedColor.value, - todos: controller.todos.value, - ); - - controller.addUpdateNote(noteEntity); - } -} +import 'package:animate_do/animate_do.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../../core/utils/utils.dart'; +import '../../../../../core/widgets/widgets.dart'; +import '../../../domain/entities/note_entity.dart'; +import '../../controllers/note_controller.dart'; +import '../../widgets/add_update/add_todo.dart'; +import '../../widgets/add_update/colors_bar.dart'; +import '../../widgets/add_update/input_field.dart'; +import '../../../domain/entities/todo_entity.dart'; + +class AddUpdateNoteScreen extends StatefulWidget { + const AddUpdateNoteScreen({Key? key}) : super(key: key); + + @override + State createState() => _AddUpdateNoteScreenState(); +} + +class _AddUpdateNoteScreenState extends State { + final controller = Get.find(); + + @override + void initState() { + super.initState(); + final NoteEntity? note = Get.arguments; + + controller.titleController = TextEditingController(text: note?.title); + controller.descriptionController = + TextEditingController(text: note?.description); + + controller.selectedColor.value = + note?.color ?? colors.randomElement as Color; + controller.todos.value = note?.todos ?? []; + } + + @override + Widget build(BuildContext context) { + final NoteEntity? note = Get.arguments; + return Obx( + () => Stack( + children: [ + _BuildForm( + controller: controller, + note: note, + ), + if (controller.isLoading.value) + FadeIn( + child: Container( + color: Colors.black.withOpacity(.2), + ), + ), + ], + ), + ); + } +} + +class _BuildForm extends StatelessWidget { + _BuildForm({ + Key? key, + required this.controller, + required this.note, + }) : super(key: key); + + final NoteController controller; + final NoteEntity? note; + List todos = []; + + @override + Widget build(BuildContext context) { + return Obx( + () => Scaffold( + backgroundColor: controller.selectedColor.value, + bottomNavigationBar: ColorsBar( + selectedColor: controller.selectedColor.value, + onChanged: controller.setSelectedColor, + ), + appBar: NoteAppbar( + actions: [ + ActionButton( + child: Text( + controller.isLoading.value ? "saving".tr : "save".tr, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + onPressed: _addUdpdateNote, + ), + ], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(AppSpacings.xl), + child: Column( + children: [ + BuildField( + controller: controller.titleController, + hint: "title".tr, + autoFocus: true, + textInputAction: TextInputAction.next, + maxLines: 2, + ), + // const SizedBox(height: 10), + BuildAddTodoList(controller: controller), + BuildField( + controller: controller.descriptionController, + hint: "type_something".tr, + maxLines: null, + fonSize: 20, + ), + ], + ), + ), + ), + ); + } + + _addUdpdateNote() { + final noteEntity = NoteEntity( + id: note != null ? note!.id! : null, + title: controller.titleController.text, + description: controller.descriptionController.text, + dateTime: DateTime.now(), + color: controller.selectedColor.value, + todos: controller.todos.value, + ); + + controller.addUpdateNote(noteEntity); + } +} diff --git a/lib/features/note/presentation/pages/notes/note_detail_screen.dart b/lib/features/note/presentation/pages/notes/note_detail_screen.dart index 33df0e1..0ecc5f0 100644 --- a/lib/features/note/presentation/pages/notes/note_detail_screen.dart +++ b/lib/features/note/presentation/pages/notes/note_detail_screen.dart @@ -1,150 +1,150 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/routes/app_routes.dart'; -import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; -import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; - -import '../../../../../core/utils/utils.dart'; -import '../../../../../core/widgets/widgets.dart'; -import '../../controllers/note_controller.dart'; -import '../../../domain/entities/todo_entity.dart'; - -class NoteDetailScreen extends StatefulWidget { - const NoteDetailScreen({Key? key}) : super(key: key); - - @override - State createState() => _NoteDetailScreenState(); -} - -class _NoteDetailScreenState extends State { - @override - void initState() { - super.initState(); - - _getNote(); - } - - _getNote() { - final NoteController controller = Get.find(); - final String noteId = Get.arguments as String; - controller.fetchNote(noteId); - } - - @override - Widget build(BuildContext context) { - final settingController = Get.find(); - return GetBuilder( - id: "note_detail", - builder: (controller) { - return controller.note == null - ? Scaffold( - appBar: const NoteAppbar(), - body: ErrorText(message: controller.error ?? ""), - ) - : Scaffold( - backgroundColor: controller.note!.color ?? colors.randomElement, - appBar: NoteAppbar( - actions: [ - ActionButton( - onPressed: () { - Get.toNamed(AppRoutes.addUpdate, - arguments: controller.note!); - }, - child: const Icon(Icons.edit), - ), - ActionButton( - onPressed: () { - controller.delete(controller.note!.id!); - Get.back(); - }, - child: const Icon(Icons.delete), - ), - ], - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: AppSpacings.l, - vertical: AppSpacings.s, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SelectableText( - controller.note!.title ?? "", - style: AppTextStyle.title, - ), - const SizedBox(height: AppSpacings.l), - SelectableText( - settingController.currentLocale.value == "fa" - ? controller.note!.dateTime!.jalaliDateWithTime - : controller.note!.dateWithTime, - style: AppTextStyle.date, - ), - const SizedBox(height: AppSpacings.xxl), - if (controller.note!.hasTodo) ...{ - _BuildTodoList(note: controller.note!), - const SizedBox(height: AppSpacings.xxl), - }, - SelectableText( - controller.note!.description ?? "", - style: AppTextStyle.description, - ), - ], - ), - ), - ), - ); - }, - ); - } -} - -class _BuildTodoList extends StatelessWidget { - const _BuildTodoList({Key? key, required this.note}) : super(key: key); - - final NoteEntity note; - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "todo_title".tr, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline, - ), - ), - ListView.builder( - itemCount: note.todos.length, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (BuildContext context, int index) { - final todo = note.todos[index]; - return CheckboxListTile( - controlAffinity: ListTileControlAffinity.leading, - contentPadding: EdgeInsets.zero, - dense: true, - value: todo.isCompleted, - title: Text( - todo.title ?? "", - style: TextStyle( - fontSize: 18, - decoration: - todo.isCompleted ? TextDecoration.lineThrough : null, - ), - ), - onChanged: (value) { - final controller = Get.find(); - controller.toggleTodoIsCompleted(todo.id!); - }, - ); - }, - ), - ], - ); - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/routes/app_routes.dart'; +import 'package:simple_hive_note/features/note/domain/entities/note_entity.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; + +import '../../../../../core/utils/utils.dart'; +import '../../../../../core/widgets/widgets.dart'; +import '../../controllers/note_controller.dart'; +import '../../../domain/entities/todo_entity.dart'; + +class NoteDetailScreen extends StatefulWidget { + const NoteDetailScreen({Key? key}) : super(key: key); + + @override + State createState() => _NoteDetailScreenState(); +} + +class _NoteDetailScreenState extends State { + @override + void initState() { + super.initState(); + + _getNote(); + } + + _getNote() { + final NoteController controller = Get.find(); + final String noteId = Get.arguments as String; + controller.fetchNote(noteId); + } + + @override + Widget build(BuildContext context) { + final settingController = Get.find(); + return GetBuilder( + id: "note_detail", + builder: (controller) { + return controller.note == null + ? Scaffold( + appBar: const NoteAppbar(), + body: ErrorText(message: controller.error ?? ""), + ) + : Scaffold( + backgroundColor: controller.note!.color ?? colors.randomElement, + appBar: NoteAppbar( + actions: [ + ActionButton( + onPressed: () { + Get.toNamed(AppRoutes.addUpdate, + arguments: controller.note!); + }, + child: const Icon(Icons.edit), + ), + ActionButton( + onPressed: () { + controller.delete(controller.note!.id!); + Get.back(); + }, + child: const Icon(Icons.delete), + ), + ], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: AppSpacings.l, + vertical: AppSpacings.s, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SelectableText( + controller.note!.title ?? "", + style: AppTextStyle.title, + ), + const SizedBox(height: AppSpacings.l), + SelectableText( + settingController.currentLocale.value == "fa" + ? controller.note!.dateTime!.jalaliDateWithTime + : controller.note!.dateWithTime, + style: AppTextStyle.date, + ), + const SizedBox(height: AppSpacings.xxl), + if (controller.note!.hasTodo) ...{ + _BuildTodoList(note: controller.note!), + const SizedBox(height: AppSpacings.xxl), + }, + SelectableText( + controller.note!.description ?? "", + style: AppTextStyle.description, + ), + ], + ), + ), + ), + ); + }, + ); + } +} + +class _BuildTodoList extends StatelessWidget { + const _BuildTodoList({Key? key, required this.note}) : super(key: key); + + final NoteEntity note; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "todo_title".tr, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + decoration: TextDecoration.underline, + ), + ), + ListView.builder( + itemCount: note.todos.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (BuildContext context, int index) { + final todo = note.todos[index]; + return CheckboxListTile( + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.zero, + dense: true, + value: todo.isCompleted, + title: Text( + todo.title ?? "", + style: TextStyle( + fontSize: 18, + decoration: + todo.isCompleted ? TextDecoration.lineThrough : null, + ), + ), + onChanged: (value) { + final controller = Get.find(); + controller.toggleTodoIsCompleted(todo.id!); + }, + ); + }, + ), + ], + ); + } +} diff --git a/lib/features/note/presentation/pages/notes/note_screen.dart b/lib/features/note/presentation/pages/notes/note_screen.dart index 85754a8..46eb2d9 100644 --- a/lib/features/note/presentation/pages/notes/note_screen.dart +++ b/lib/features/note/presentation/pages/notes/note_screen.dart @@ -1,127 +1,128 @@ -import 'package:animate_do/animate_do.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; -import 'package:get/get.dart'; -import 'package:hive_flutter/hive_flutter.dart'; -import 'package:simple_hive_note/core/routes/app_routes.dart'; - -import '../../../../../core/data/database_provider.dart'; -import '../../../../../core/utils/utils.dart'; -import '../../../../../core/widgets/widgets.dart'; -import '../../controllers/note_controller.dart'; -import '../../widgets/note_screen/note_card.dart'; - -class NoteScreen extends GetView { - const NoteScreen({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: NoteAppbar( - title: "notes".tr, - autoImplementLeading: false, - actions: [ - GetBuilder( - id: 'note_actions', - builder: (controller) => controller.selectedIds.isEmpty - ? ActionButton( - onPressed: () { - Get.toNamed(AppRoutes.note + AppRoutes.setting); - }, - child: const Icon(Icons.settings), - ) - : Row( - children: [ - ActionButton( - onPressed: () async { - await controller.deleteMultiNotes(); - // context.showMessage( - // "${controller.selectedIds.length} ${"delete_msg".tr}"); - }, - child: Row( - children: [ - Text( - "${"delete".tr} - ${controller.selectedIds.length}", - style: const TextStyle( - color: Colors.white, - ), - ), - const SizedBox(width: 8), - const Icon(Icons.delete), - ], - ), - ), - const SizedBox(width: AppSpacings.l), - ActionButton( - onPressed: controller.cancelDeleting, - child: const Icon(Icons.close_rounded), - ), - ], - ), - ), - ], - ), - floatingActionButton: FadeInUp( - child: FloatingActionButton( - onPressed: () { - Get.toNamed(AppRoutes.addUpdate); - }, - child: const Icon(Icons.add), - ), - ), - body: ValueListenableBuilder( - valueListenable: DatabaseProvider().box.listenable(), - builder: (BuildContext context, _, Widget? child) { - controller.fetchAllNotes(); - return child!; - }, - child: GetBuilder( - id: "note_list", - // builder: (controller) => _BuildNotesList(controller: controller), - builder: (controller) => controller.isErrorNotEmpty() - ? ErrorText(message: controller.error ?? "") - : _BuildNotesList(controller: controller), - ), - ), - ); - } -} - -class _BuildNotesList extends StatelessWidget { - const _BuildNotesList({Key? key, required this.controller}) : super(key: key); - - final NoteController controller; - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - padding: const EdgeInsets.all(AppSpacings.xl), - child: StaggeredGrid.count( - crossAxisCount: 2, - mainAxisSpacing: AppSpacings.xl, - crossAxisSpacing: AppSpacings.xl, - children: List.generate( - controller.notes.length, - (index) { - final note = controller.notes[index]; - return FadeInDown( - delay: Duration(milliseconds: 100 * index), - child: NoteCard( - note: note, - selected: controller.isSelected(note.id), - onSelect: () => controller.toggleSelect(note.id!), - onTap: () { - if (controller.selectedIds.isEmpty) { - Get.toNamed(AppRoutes.noteDetail, arguments: note.id); - } else { - controller.toggleSelect(note.id!); - } - }, - ), - ); - }, - ), - ), - ); - } -} +import 'package:animate_do/animate_do.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; +import 'package:get/get.dart'; +import 'package:hive_flutter/hive_flutter.dart'; +import 'package:simple_hive_note/core/routes/app_routes.dart'; + +import '../../../../../core/data/database_provider.dart'; +import '../../../../../core/utils/utils.dart'; +import '../../../../../core/widgets/widgets.dart'; +import '../../controllers/note_controller.dart'; +import '../../widgets/note_screen/note_card.dart'; + +class NoteScreen extends GetView { + const NoteScreen({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: NoteAppbar( + title: "notes".tr, + autoImplementLeading: false, + actions: [ + GetBuilder( + id: 'note_actions', + builder: (controller) => controller.selectedIds.isEmpty + ? ActionButton( + onPressed: () { + Get.toNamed(AppRoutes.note + AppRoutes.setting); + }, + child: const Icon(Icons.settings), + ) + : Row( + children: [ + ActionButton( + onPressed: () async { + await controller.deleteMultiNotes(); + // context.showMessage( + // "${controller.selectedIds.length} ${"delete_msg".tr}"); + }, + child: Row( + children: [ + Text( + "${"delete".tr} - ${controller.selectedIds.length}", + // style: const TextStyle( + // color: Colors.white, + // ), + style: Get.theme.textTheme.bodyMedium, + ), + const SizedBox(width: 8), + const Icon(Icons.delete), + ], + ), + ), + const SizedBox(width: AppSpacings.l), + ActionButton( + onPressed: controller.cancelDeleting, + child: const Icon(Icons.close_rounded), + ), + ], + ), + ), + ], + ), + floatingActionButton: FadeInUp( + child: FloatingActionButton( + onPressed: () { + Get.toNamed(AppRoutes.addUpdate); + }, + child: const Icon(Icons.add), + ), + ), + body: ValueListenableBuilder( + valueListenable: DatabaseProvider().box.listenable(), + builder: (BuildContext context, _, Widget? child) { + controller.fetchAllNotes(); + return child!; + }, + child: GetBuilder( + id: "note_list", + // builder: (controller) => _BuildNotesList(controller: controller), + builder: (controller) => controller.isErrorNotEmpty() + ? ErrorText(message: controller.error ?? "") + : _BuildNotesList(controller: controller), + ), + ), + ); + } +} + +class _BuildNotesList extends StatelessWidget { + const _BuildNotesList({Key? key, required this.controller}) : super(key: key); + + final NoteController controller; + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + padding: const EdgeInsets.all(AppSpacings.xl), + child: StaggeredGrid.count( + crossAxisCount: 2, + mainAxisSpacing: AppSpacings.xl, + crossAxisSpacing: AppSpacings.xl, + children: List.generate( + controller.notes.length, + (index) { + final note = controller.notes[index]; + return FadeInDown( + delay: Duration(milliseconds: 100 * index), + child: NoteCard( + note: note, + selected: controller.isSelected(note.id), + onSelect: () => controller.toggleSelect(note.id!), + onTap: () { + if (controller.selectedIds.isEmpty) { + Get.toNamed(AppRoutes.noteDetail, arguments: note.id); + } else { + controller.toggleSelect(note.id!); + } + }, + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/features/note/presentation/pages/pages.dart b/lib/features/note/presentation/pages/pages.dart index ead97cd..32bb788 100644 --- a/lib/features/note/presentation/pages/pages.dart +++ b/lib/features/note/presentation/pages/pages.dart @@ -1,4 +1,4 @@ -export 'notes/add_update_note_screen.dart'; -export 'notes/note_detail_screen.dart'; -export 'notes/note_screen.dart'; -export 'setting/setting_screen.dart'; +export 'notes/add_update_note_screen.dart'; +export 'notes/note_detail_screen.dart'; +export 'notes/note_screen.dart'; +export 'setting/setting_screen.dart'; diff --git a/lib/features/note/presentation/pages/setting/setting_screen.dart b/lib/features/note/presentation/pages/setting/setting_screen.dart index 2772224..bb2bb5e 100644 --- a/lib/features/note/presentation/pages/setting/setting_screen.dart +++ b/lib/features/note/presentation/pages/setting/setting_screen.dart @@ -1,111 +1,111 @@ -// ignore_for_file: prefer_const_constructors - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; - -import '../../../../../core/utils/utils.dart'; -import '../../../../../core/widgets/widgets.dart'; - -class SettingScreen extends GetView { - const SettingScreen({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: NoteAppbar( - title: "settings".tr, - ), - body: Column( - children: [ - ListTile( - title: Text( - "change_theme".tr, - style: TextStyle( - fontSize: 20, - ), - ), - leading: Icon(Icons.dark_mode_rounded), - minLeadingWidth: 20, - onTap: () => controller.toggleTheme(), - trailing: Obx( - () => Text( - controller.isDarkMode.value - ? "theme_dark".tr - : "theme_light".tr, - ), - ), - ), - ListTile( - title: Text( - "change_language".tr, - style: TextStyle( - fontSize: 20, - ), - ), - leading: Icon(Icons.language), - minLeadingWidth: 20, - onTap: () => controller.toggleLocale(), - trailing: Obx( - () => Text( - controller.currentLocale.value == "fa" - ? "persian".tr - : "english".tr, - ), - ), - ), - ], - ), - ); - } -} - -class _SettingItem extends StatelessWidget { - const _SettingItem({ - Key? key, - required this.title, - required this.children, - }) : super(key: key); - final String title; - final List children; - - @override - Widget build(BuildContext context) { - return Container( - clipBehavior: Clip.antiAlias, - // margin: EdgeInsets.all(AppSpacings.xl), - decoration: BoxDecoration( - // color: Colors.red, - borderRadius: BorderRadius.circular(AppSpacings.l), - ), - child: ExpansionTile( - childrenPadding: EdgeInsets.zero, - title: Text( - title, - style: const TextStyle( - fontSize: 18, - ), - ), - trailing: SizedBox.shrink(), - children: children, - ), - ); - // return InkWell( - // child: Container( - // padding: const EdgeInsets.all(AppSpacings.xl), - // child: Row( - // children: [ - // Icon(setting.icon), - // const SizedBox(width: AppSpacings.m), - // Text( - // setting.title, - // style: const TextStyle( - // fontSize: 20, - // ), - // ), - // ], - // ), - // ), - // ); - } -} +// ignore_for_file: prefer_const_constructors + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; + +import '../../../../../core/utils/utils.dart'; +import '../../../../../core/widgets/widgets.dart'; + +class SettingScreen extends GetView { + const SettingScreen({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: NoteAppbar( + title: "settings".tr, + ), + body: Column( + children: [ + ListTile( + title: Text( + "change_theme".tr, + style: TextStyle( + fontSize: 20, + ), + ), + leading: Icon(Icons.dark_mode_rounded), + minLeadingWidth: 20, + onTap: () => controller.toggleTheme(), + trailing: Obx( + () => Text( + controller.isDarkMode.value + ? "theme_dark".tr + : "theme_light".tr, + ), + ), + ), + ListTile( + title: Text( + "change_language".tr, + style: TextStyle( + fontSize: 20, + ), + ), + leading: Icon(Icons.language), + minLeadingWidth: 20, + onTap: () => controller.toggleLocale(), + trailing: Obx( + () => Text( + controller.currentLocale.value == "fa" + ? "persian".tr + : "english".tr, + ), + ), + ), + ], + ), + ); + } +} + +class _SettingItem extends StatelessWidget { + const _SettingItem({ + Key? key, + required this.title, + required this.children, + }) : super(key: key); + final String title; + final List children; + + @override + Widget build(BuildContext context) { + return Container( + clipBehavior: Clip.antiAlias, + // margin: EdgeInsets.all(AppSpacings.xl), + decoration: BoxDecoration( + // color: Colors.red, + borderRadius: BorderRadius.circular(AppSpacings.l), + ), + child: ExpansionTile( + childrenPadding: EdgeInsets.zero, + title: Text( + title, + style: const TextStyle( + fontSize: 18, + ), + ), + trailing: SizedBox.shrink(), + children: children, + ), + ); + // return InkWell( + // child: Container( + // padding: const EdgeInsets.all(AppSpacings.xl), + // child: Row( + // children: [ + // Icon(setting.icon), + // const SizedBox(width: AppSpacings.m), + // Text( + // setting.title, + // style: const TextStyle( + // fontSize: 20, + // ), + // ), + // ], + // ), + // ), + // ); + } +} diff --git a/lib/features/note/presentation/widgets/add_update/add_todo.dart b/lib/features/note/presentation/widgets/add_update/add_todo.dart index 2072bac..ee7225e 100644 --- a/lib/features/note/presentation/widgets/add_update/add_todo.dart +++ b/lib/features/note/presentation/widgets/add_update/add_todo.dart @@ -1,119 +1,119 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/utils/theme/spacing.dart'; -import 'package:simple_hive_note/features/note/presentation/controllers/note_controller.dart'; - -class BuildAddTodoList extends StatelessWidget { - const BuildAddTodoList({Key? key, required this.controller}) - : super(key: key); - - final NoteController controller; - - @override - Widget build(BuildContext context) { - return Column( - children: [ - Obx( - () => ListView.builder( - itemCount: controller.todos.length, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (BuildContext context, int index) { - final todo = controller.todos[index]; - return _TodoFieldTile( - value: todo.title, - onChange: (value) => - controller.todoValueChanged(value, todo.id!), - onRemove: () => controller.removeTodo(todo), - ); - }, - ), - ), - _AddTodoTile( - onAdd: controller.addEmptyTodo, - ), - ], - ); - } -} - -class _TodoFieldTile extends StatefulWidget { - const _TodoFieldTile({ - Key? key, - required this.onRemove, - required this.onChange, - this.value, - }) : super(key: key); - - final String? value; - final VoidCallback onRemove; - final Function(String value) onChange; - - @override - _TodoFieldTileState createState() => _TodoFieldTileState(); -} - -class _TodoFieldTileState extends State<_TodoFieldTile> { - late TextEditingController todoController; - late FocusNode focusNode; - - @override - void initState() { - super.initState(); - todoController = TextEditingController(text: widget.value); - focusNode = FocusNode(); - focusNode.requestFocus(); - } - - @override - Widget build(BuildContext context) { - return ListTile( - dense: true, - contentPadding: EdgeInsets.zero, - title: TextField( - controller: todoController, - autofocus: true, - focusNode: focusNode, - style: const TextStyle(fontSize: 16), - maxLines: 3, - minLines: 1, - textInputAction: TextInputAction.newline, - onChanged: widget.onChange, - decoration: InputDecoration( - isDense: true, - border: InputBorder.none, - hintText: "todo..".tr, - ), - ), - trailing: IconButton( - onPressed: widget.onRemove, - icon: const Icon(Icons.delete), - ), - ); - } -} - -class _AddTodoTile extends StatelessWidget { - const _AddTodoTile({Key? key, this.onAdd}) : super(key: key); - - final VoidCallback? onAdd; - - @override - Widget build(BuildContext context) { - return ListTile( - contentPadding: EdgeInsets.zero, - dense: true, - title: Row( - children: [ - const Icon(Icons.add), - const SizedBox(width: AppSpacings.l), - Text( - "add_todo".tr, - style: const TextStyle(fontSize: 16), - ), - ], - ), - onTap: onAdd, - ); - } -} +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/utils/theme/spacing.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/note_controller.dart'; + +class BuildAddTodoList extends StatelessWidget { + const BuildAddTodoList({Key? key, required this.controller}) + : super(key: key); + + final NoteController controller; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Obx( + () => ListView.builder( + itemCount: controller.todos.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (BuildContext context, int index) { + final todo = controller.todos[index]; + return _TodoFieldTile( + value: todo.title, + onChange: (value) => + controller.todoValueChanged(value, todo.id!), + onRemove: () => controller.removeTodo(todo), + ); + }, + ), + ), + _AddTodoTile( + onAdd: controller.addEmptyTodo, + ), + ], + ); + } +} + +class _TodoFieldTile extends StatefulWidget { + const _TodoFieldTile({ + Key? key, + required this.onRemove, + required this.onChange, + this.value, + }) : super(key: key); + + final String? value; + final VoidCallback onRemove; + final Function(String value) onChange; + + @override + _TodoFieldTileState createState() => _TodoFieldTileState(); +} + +class _TodoFieldTileState extends State<_TodoFieldTile> { + late TextEditingController todoController; + late FocusNode focusNode; + + @override + void initState() { + super.initState(); + todoController = TextEditingController(text: widget.value); + focusNode = FocusNode(); + focusNode.requestFocus(); + } + + @override + Widget build(BuildContext context) { + return ListTile( + dense: true, + contentPadding: EdgeInsets.zero, + title: TextField( + controller: todoController, + autofocus: true, + focusNode: focusNode, + style: const TextStyle(fontSize: 16), + maxLines: 3, + minLines: 1, + textInputAction: TextInputAction.newline, + onChanged: widget.onChange, + decoration: InputDecoration( + isDense: true, + border: InputBorder.none, + hintText: "todo..".tr, + ), + ), + trailing: IconButton( + onPressed: widget.onRemove, + icon: const Icon(Icons.delete), + ), + ); + } +} + +class _AddTodoTile extends StatelessWidget { + const _AddTodoTile({Key? key, this.onAdd}) : super(key: key); + + final VoidCallback? onAdd; + + @override + Widget build(BuildContext context) { + return ListTile( + contentPadding: EdgeInsets.zero, + dense: true, + title: Row( + children: [ + const Icon(Icons.add), + const SizedBox(width: AppSpacings.l), + Text( + "add_todo".tr, + style: const TextStyle(fontSize: 16), + ), + ], + ), + onTap: onAdd, + ); + } +} diff --git a/lib/features/note/presentation/widgets/add_update/colors_bar.dart b/lib/features/note/presentation/widgets/add_update/colors_bar.dart index 7b0cfe0..25c5349 100644 --- a/lib/features/note/presentation/widgets/add_update/colors_bar.dart +++ b/lib/features/note/presentation/widgets/add_update/colors_bar.dart @@ -1,85 +1,85 @@ -import 'package:animate_do/animate_do.dart'; -import 'package:flutter/material.dart'; -import 'package:simple_hive_note/core/utils/utils.dart'; - -class ColorsBar extends StatelessWidget { - const ColorsBar({Key? key, this.selectedColor, required this.onChanged}) - : super(key: key); - final Color? selectedColor; - final Function(Color color) onChanged; - - @override - Widget build(BuildContext context) { - return FadeInRight( - delay: const Duration(milliseconds: 600), - child: SafeArea( - minimum: const EdgeInsets.only(bottom: 12), - child: Material( - color: selectedColor, - child: SizedBox( - height: kToolbarHeight, - child: Center( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: colors - .map( - (color) => _ColorBox( - color: color, - isSelected: selectedColor == color, - onTap: () => onChanged(color), - ), - ) - .toList(), - ), - ), - ), - ), - ), - ), - ); - } -} - -class _ColorBox extends StatelessWidget { - const _ColorBox({ - Key? key, - this.isSelected = false, - this.onTap, - required this.color, - }) : super(key: key); - - final bool isSelected; - final Color color; - final VoidCallback? onTap; - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(AppSpacings.s), - child: GestureDetector( - onTap: onTap, - child: Material( - shape: const CircleBorder(), - elevation: isSelected ? 2 : 0.2, - child: Container( - height: 40, - width: 40, - margin: const EdgeInsets.all(AppSpacings.s), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: color, - ), - child: isSelected - ? const Icon( - Icons.check, - color: Colors.white, - size: 36, - ) - : null, - ), - ), - ), - ); - } -} +import 'package:animate_do/animate_do.dart'; +import 'package:flutter/material.dart'; +import 'package:simple_hive_note/core/utils/utils.dart'; + +class ColorsBar extends StatelessWidget { + const ColorsBar({Key? key, this.selectedColor, required this.onChanged}) + : super(key: key); + final Color? selectedColor; + final Function(Color color) onChanged; + + @override + Widget build(BuildContext context) { + return FadeInRight( + delay: const Duration(milliseconds: 600), + child: SafeArea( + minimum: const EdgeInsets.only(bottom: 12), + child: Material( + color: selectedColor, + child: SizedBox( + height: kToolbarHeight, + child: Center( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: colors + .map( + (color) => _ColorBox( + color: color, + isSelected: selectedColor == color, + onTap: () => onChanged(color), + ), + ) + .toList(), + ), + ), + ), + ), + ), + ), + ); + } +} + +class _ColorBox extends StatelessWidget { + const _ColorBox({ + Key? key, + this.isSelected = false, + this.onTap, + required this.color, + }) : super(key: key); + + final bool isSelected; + final Color color; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(AppSpacings.s), + child: GestureDetector( + onTap: onTap, + child: Material( + shape: const CircleBorder(), + elevation: isSelected ? 2 : 0.2, + child: Container( + height: 40, + width: 40, + margin: const EdgeInsets.all(AppSpacings.s), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: color, + ), + child: isSelected + ? const Icon( + Icons.check, + color: Colors.white, + size: 36, + ) + : null, + ), + ), + ), + ); + } +} diff --git a/lib/features/note/presentation/widgets/add_update/input_field.dart b/lib/features/note/presentation/widgets/add_update/input_field.dart index d144857..bf55b7b 100644 --- a/lib/features/note/presentation/widgets/add_update/input_field.dart +++ b/lib/features/note/presentation/widgets/add_update/input_field.dart @@ -1,44 +1,44 @@ -import 'package:flutter/material.dart'; - -class BuildField extends StatelessWidget { - const BuildField({ - Key? key, - required this.controller, - required this.hint, - this.maxLines = 1, - this.fonSize = 30, - this.autoFocus = false, - this.textInputAction, - }) : super(key: key); - - final TextEditingController controller; - final String hint; - final int? maxLines; - final double? fonSize; - final bool autoFocus; - final TextInputAction? textInputAction; - - @override - Widget build(BuildContext context) { - return TextField( - controller: controller, - autofocus: autoFocus, - maxLines: maxLines, - minLines: 1, - textInputAction: textInputAction, - style: TextStyle( - fontSize: fonSize, - fontWeight: maxLines != null ? FontWeight.bold : null, - ), - cursorColor: Colors.white, - decoration: InputDecoration( - border: InputBorder.none, - hintText: hint, - hintStyle: TextStyle( - fontSize: fonSize, - fontWeight: maxLines != null ? FontWeight.bold : null, - ), - ), - ); - } -} +import 'package:flutter/material.dart'; + +class BuildField extends StatelessWidget { + const BuildField({ + Key? key, + required this.controller, + required this.hint, + this.maxLines = 1, + this.fonSize = 30, + this.autoFocus = false, + this.textInputAction, + }) : super(key: key); + + final TextEditingController controller; + final String hint; + final int? maxLines; + final double? fonSize; + final bool autoFocus; + final TextInputAction? textInputAction; + + @override + Widget build(BuildContext context) { + return TextField( + controller: controller, + autofocus: autoFocus, + maxLines: maxLines, + minLines: 1, + textInputAction: textInputAction, + style: TextStyle( + fontSize: fonSize, + fontWeight: maxLines != null ? FontWeight.bold : null, + ), + cursorColor: Colors.white, + decoration: InputDecoration( + border: InputBorder.none, + hintText: hint, + hintStyle: TextStyle( + fontSize: fonSize, + fontWeight: maxLines != null ? FontWeight.bold : null, + ), + ), + ); + } +} diff --git a/lib/features/note/presentation/widgets/note_screen/note_card.dart b/lib/features/note/presentation/widgets/note_screen/note_card.dart index f8f6b1e..391eeb8 100644 --- a/lib/features/note/presentation/widgets/note_screen/note_card.dart +++ b/lib/features/note/presentation/widgets/note_screen/note_card.dart @@ -1,103 +1,103 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:simple_hive_note/core/utils/utils.dart'; -import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; - -import '../../../../../core/utils/utils.dart'; -import '../../../domain/entities/note_entity.dart'; - -class NoteCard extends StatelessWidget { - const NoteCard({ - Key? key, - required this.note, - this.selected = false, - this.onSelect, - this.onTap, - }) : super(key: key); - - final NoteEntity note; - final bool selected; - final Function()? onSelect; - final Function()? onTap; - - @override - Widget build(BuildContext context) { - final settingController = Get.find(); - return Material( - clipBehavior: Clip.antiAlias, - borderRadius: BorderRadius.circular(AppSpacings.m), - color: note.color ?? const Color(0xff5C4F45), - child: InkWell( - splashColor: Colors.black12, - onLongPress: onSelect, - onTap: onTap, - child: Container( - // constraints: const BoxConstraints( - // maxHeight: 300, - // minHeight: 100, - // ), - padding: const EdgeInsets.symmetric( - horizontal: AppSpacings.l, - vertical: AppSpacings.l, - ), - child: Stack( - children: [ - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - child: AutoSizeText( - note.title ?? '', - presetFontSizes: const [16, 14, 12, 10, 8], - textScaleFactor: 2, - softWrap: true, - style: AppTextStyle.title, - group: AutoSizeGroup(), - overflow: TextOverflow.fade, - ), - ), - const SizedBox(height: AppSpacings.m), - Text( - settingController.currentLocale.value == "fa" - ? note.dateTime!.jalaliDate - : note.date, - style: AppTextStyle.date, - ), - ], - ), - if (selected) - Align( - alignment: Alignment.topLeft, - heightFactor: 2, - child: Container( - decoration: BoxDecoration( - color: AppColors.primary, - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - blurRadius: 10, - spreadRadius: 20, - color: note.color ?? AppColors.primary, - ), - ], - ), - child: Padding( - padding: const EdgeInsets.all(AppSpacings.m), - child: Icon( - Icons.check, - color: note.color, - size: 20, - ), - ), - ), - ), - ], - ), - ), - ), - ); - } -} +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_hive_note/core/utils/utils.dart'; +import 'package:simple_hive_note/features/note/presentation/controllers/setting_controller.dart'; + +import '../../../../../core/utils/utils.dart'; +import '../../../domain/entities/note_entity.dart'; + +class NoteCard extends StatelessWidget { + const NoteCard({ + Key? key, + required this.note, + this.selected = false, + this.onSelect, + this.onTap, + }) : super(key: key); + + final NoteEntity note; + final bool selected; + final Function()? onSelect; + final Function()? onTap; + + @override + Widget build(BuildContext context) { + final settingController = Get.find(); + return Material( + clipBehavior: Clip.antiAlias, + borderRadius: BorderRadius.circular(AppSpacings.m), + color: note.color ?? const Color(0xff5C4F45), + child: InkWell( + splashColor: Colors.black12, + onLongPress: onSelect, + onTap: onTap, + child: Container( + // constraints: const BoxConstraints( + // maxHeight: 300, + // minHeight: 100, + // ), + padding: const EdgeInsets.symmetric( + horizontal: AppSpacings.l, + vertical: AppSpacings.l, + ), + child: Stack( + children: [ + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: AutoSizeText( + note.title ?? '', + presetFontSizes: const [16, 14, 12, 10, 8], + textScaleFactor: 2, + softWrap: true, + style: AppTextStyle.title, + group: AutoSizeGroup(), + overflow: TextOverflow.fade, + ), + ), + const SizedBox(height: AppSpacings.m), + Text( + settingController.currentLocale.value == "fa" + ? note.dateTime!.jalaliDate + : note.date, + style: AppTextStyle.date, + ), + ], + ), + if (selected) + Align( + alignment: Alignment.topLeft, + heightFactor: 2, + child: Container( + decoration: BoxDecoration( + color: AppColors.primary, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + blurRadius: 10, + spreadRadius: 20, + color: note.color ?? AppColors.primary, + ), + ], + ), + child: Padding( + padding: const EdgeInsets.all(AppSpacings.m), + child: Icon( + Icons.check, + color: note.color, + size: 20, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/note/routes/note_routes.dart b/lib/features/note/routes/note_routes.dart index d356da6..593cca4 100644 --- a/lib/features/note/routes/note_routes.dart +++ b/lib/features/note/routes/note_routes.dart @@ -1,27 +1,27 @@ -import 'package:get/get.dart'; - -import '../../../core/routes/app_routes.dart'; -import '../bindings/note_binding.dart'; -import '../presentation/pages/pages.dart'; - -List noteRoutes = [ - GetPage( - name: AppRoutes.note, - page: () => const NoteScreen(), - binding: NoteBinding(), - children: [ - GetPage( - name: AppRoutes.setting, - page: () => SettingScreen(), - ), - ], - ), - GetPage( - name: AppRoutes.addUpdate, - page: () => const AddUpdateNoteScreen(), - ), - GetPage( - name: AppRoutes.noteDetail, - page: () => const NoteDetailScreen(), - ), -]; +import 'package:get/get.dart'; + +import '../../../core/routes/app_routes.dart'; +import '../bindings/note_binding.dart'; +import '../presentation/pages/pages.dart'; + +List noteRoutes = [ + GetPage( + name: AppRoutes.note, + page: () => const NoteScreen(), + binding: NoteBinding(), + children: [ + GetPage( + name: AppRoutes.setting, + page: () => SettingScreen(), + ), + ], + ), + GetPage( + name: AppRoutes.addUpdate, + page: () => const AddUpdateNoteScreen(), + ), + GetPage( + name: AppRoutes.noteDetail, + page: () => const NoteDetailScreen(), + ), +]; diff --git a/lib/main.dart b/lib/main.dart index f12c272..bcf5b53 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,25 +1,25 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:get_storage/get_storage.dart'; -import 'package:hive_flutter/hive_flutter.dart'; -import 'package:simple_hive_note/core/utils/utils.dart'; - -import 'app.dart'; -import 'features/note/data/models/note.dart'; -import 'features/note/data/models/todo.dart'; - -void main() async { - await Hive.initFlutter(); - await GetStorage.init(); - Hive.registerAdapter(NoteAdapter()); - Hive.registerAdapter(TodoAdapter()); - await Hive.openBox(AppStrings.databaseBox); - - SystemChrome.setSystemUIOverlayStyle( - const SystemUiOverlayStyle( - statusBarColor: Colors.transparent, - statusBarIconBrightness: Brightness.dark, - ), - ); - runApp(App()); -} +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get_storage/get_storage.dart'; +import 'package:hive_flutter/hive_flutter.dart'; +import 'package:simple_hive_note/core/utils/utils.dart'; + +import 'app.dart'; +import 'features/note/data/models/note.dart'; +import 'features/note/data/models/todo.dart'; + +void main() async { + await Hive.initFlutter(); + await GetStorage.init(); + Hive.registerAdapter(NoteAdapter()); + Hive.registerAdapter(TodoAdapter()); + await Hive.openBox(AppStrings.databaseBox); + + SystemChrome.setSystemUIOverlayStyle( + const SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarIconBrightness: Brightness.dark, + ), + ); + runApp(App()); +} diff --git a/pubspec.lock b/pubspec.lock index 919c0d2..477e889 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,658 +1,672 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - url: "https://pub.dartlang.org" - source: hosted - version: "33.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - animate_do: - dependency: "direct main" - description: - name: animate_do - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.0" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.8.2" - auto_size_text: - dependency: "direct main" - description: - name: auto_size_text - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - build: - dependency: transitive - description: - name: build - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" - build_config: - dependency: transitive - description: - name: build_config - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - build_daemon: - dependency: transitive - description: - name: build_daemon - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - build_resolvers: - dependency: transitive - description: - name: build_resolvers - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - build_runner: - dependency: "direct dev" - description: - name: build_runner - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.7" - build_runner_core: - dependency: transitive - description: - name: build_runner_core - url: "https://pub.dartlang.org" - source: hosted - version: "7.2.3" - built_collection: - dependency: transitive - description: - name: built_collection - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.1" - built_value: - dependency: transitive - description: - name: built_value - url: "https://pub.dartlang.org" - source: hosted - version: "8.1.3" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - checked_yaml: - dependency: transitive - description: - name: checked_yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.5" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - code_builder: - dependency: transitive - description: - name: code_builder - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.0" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - dart_style: - dependency: transitive - description: - name: dart_style - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" - dartz: - dependency: "direct main" - description: - name: dartz - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.1" - equatable: - dependency: "direct main" - description: - name: equatable - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.3" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.2" - fixnum: - dependency: transitive - description: - name: fixnum - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - flutter_staggered_grid_view: - dependency: "direct main" - description: - name: flutter_staggered_grid_view - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - freezed: - dependency: "direct dev" - description: - name: freezed - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - freezed_annotation: - dependency: "direct main" - description: - name: freezed_annotation - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - get: - dependency: "direct main" - description: - name: get - url: "https://pub.dartlang.org" - source: hosted - version: "4.6.1" - get_storage: - dependency: "direct main" - description: - name: get_storage - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.3" - glob: - dependency: transitive - description: - name: glob - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - graphs: - dependency: transitive - description: - name: graphs - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - hive: - dependency: "direct main" - description: - name: hive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" - hive_flutter: - dependency: "direct main" - description: - name: hive_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - hive_generator: - dependency: "direct dev" - description: - name: hive_generator - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - intl: - dependency: "direct main" - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.17.0" - io: - dependency: transitive - description: - name: io - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.3" - json_annotation: - dependency: transitive - description: - name: json_annotation - url: "https://pub.dartlang.org" - source: hosted - version: "4.4.0" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.11" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.7.0" - mime: - dependency: transitive - description: - name: mime - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - package_config: - dependency: transitive - description: - name: package_config - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path_provider: - dependency: transitive - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.8" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - path_provider_ios: - dependency: transitive - description: - name: path_provider_ios - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.7" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.4" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.4" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - pool: - dependency: transitive - description: - name: pool - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.0" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.4" - pub_semver: - dependency: transitive - description: - name: pub_semver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - pubspec_parse: - dependency: transitive - description: - name: pubspec_parse - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - shamsi_date: - dependency: "direct main" - description: - name: shamsi_date - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - shelf: - dependency: transitive - description: - name: shelf - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_gen: - dependency: transitive - description: - name: source_gen - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - source_helper: - dependency: transitive - description: - name: source_helper - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - stream_transform: - dependency: transitive - description: - name: stream_transform - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.3" - timing: - dependency: transitive - description: - name: timing - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - uuid: - dependency: "direct main" - description: - name: uuid - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.5" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - watcher: - dependency: transitive - description: - name: watcher - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.3" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" -sdks: - dart: ">=2.15.1 <3.0.0" - flutter: ">=2.5.0" +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "38.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "3.4.1" + animate_do: + dependency: "direct main" + description: + name: animate_do + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + auto_size_text: + dependency: "direct main" + description: + name: auto_size_text + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.11" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.3" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.3.2" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" + dartz: + dependency: "direct main" + description: + name: dartz + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.1" + equatable: + dependency: "direct main" + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_staggered_grid_view: + dependency: "direct main" + description: + name: flutter_staggered_grid_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.5" + get_storage: + dependency: "direct main" + description: + name: get_storage + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + hive: + dependency: "direct main" + description: + name: hive + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + hive_flutter: + dependency: "direct main" + description: + name: hive_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + hive_generator: + dependency: "direct dev" + description: + name: hive_generator + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.3" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.4" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.5.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.10" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.14" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.7" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + shamsi_date: + dependency: "direct main" + description: + name: shamsi_date + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.2" + source_helper: + dependency: transitive + description: + name: source_helper + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.9" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + uuid: + dependency: "direct main" + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.17.0 <3.0.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f25e06b..31c30dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,92 +1,93 @@ -name: simple_hive_note -description: A new Flutter project. - -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 - -environment: - sdk: ">=2.15.1 <3.0.0" - -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. -dependencies: - animate_do: ^2.1.0 - auto_size_text: ^3.0.0 - cupertino_icons: ^1.0.2 - dartz: ^0.10.1 - equatable: ^2.0.3 - flutter: - sdk: flutter - flutter_staggered_grid_view: ^0.6.0 - freezed_annotation: ^1.1.0 - get: ^4.6.1 - get_storage: ^2.0.3 - hive: ^2.0.5 - hive_flutter: ^1.1.0 - intl: ^0.17.0 - shamsi_date: ^1.0.0 - uuid: ^3.0.5 - -dev_dependencies: - build_runner: ^2.1.7 - flutter_lints: ^1.0.0 - flutter_test: - sdk: flutter - freezed: ^1.1.1 - hive_generator: ^1.1.1 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - fonts: - - family: IRANSans - fonts: - - asset: assets/fonts/Iransans.ttf - - asset: assets/fonts/Iransans-light.ttf - weight: 300 - - asset: assets/fonts/Iransans-Bold.ttf - weight: 700 - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages +name: simple_hive_note +description: A new Flutter project. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.15.1 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + animate_do: ^2.1.0 + auto_size_text: ^3.0.0 + cupertino_icons: ^1.0.2 + dartz: ^0.10.1 + equatable: ^2.0.3 + flutter: + sdk: flutter + flutter_staggered_grid_view: ^0.6.0 + freezed_annotation: ^1.1.0 + get: ^4.6.5 + get_storage: ^2.0.3 + google_fonts: ^3.0.1 + hive: ^2.0.5 + hive_flutter: ^1.1.0 + intl: ^0.17.0 + shamsi_date: ^1.0.0 + uuid: ^3.0.5 + +dev_dependencies: + build_runner: ^2.1.7 + flutter_lints: ^1.0.0 + flutter_test: + sdk: flutter + freezed: ^1.1.1 + hive_generator: ^1.1.1 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + fonts: + - family: IRANSans + fonts: + - asset: assets/fonts/Iransans.ttf + - asset: assets/fonts/Iransans-light.ttf + weight: 300 + - asset: assets/fonts/Iransans-Bold.ttf + weight: 700 + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/test/widget_test.dart b/test/widget_test.dart index 7538c11..91bbaf4 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,31 +1,31 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:simple_hive_note/app.dart'; - -import 'package:simple_hive_note/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(App()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:simple_hive_note/app.dart'; + +import 'package:simple_hive_note/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(App()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/web/index.html b/web/index.html index 6f043ec..6b7a6e9 100644 --- a/web/index.html +++ b/web/index.html @@ -1,104 +1,104 @@ - - - - - - - - - - - - - - - - - - - - simple_hive_note - - - - - - - + + + + + + + + + + + + + + + + + + + + simple_hive_note + + + + + + + diff --git a/web/manifest.json b/web/manifest.json index 6403cdb..58a556e 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -1,35 +1,35 @@ -{ - "name": "simple_hive_note", - "short_name": "simple_hive_note", - "start_url": ".", - "display": "standalone", - "background_color": "#0175C2", - "theme_color": "#0175C2", - "description": "A new Flutter project.", - "orientation": "portrait-primary", - "prefer_related_applications": false, - "icons": [ - { - "src": "icons/Icon-192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "icons/Icon-512.png", - "sizes": "512x512", - "type": "image/png" - }, - { - "src": "icons/Icon-maskable-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "icons/Icon-maskable-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable" - } - ] -} +{ + "name": "simple_hive_note", + "short_name": "simple_hive_note", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}