From 717b33515fd4ea7c9622bc3de21954107fc18853 Mon Sep 17 00:00:00 2001 From: Godsend Joseph Date: Wed, 4 Dec 2024 01:57:28 +0000 Subject: [PATCH] refactoring - do not clone this branch unless you know whare you are doing --- .../models/cloud_note_model.g.dart | 50 --------- .../cloud_notes/models/user_model.g.dart | 74 ------------ .../local_notes/models/note_model.g.dart | 47 -------- lib/app/router/route_config.dart | 89 --------------- lib/app/src/app.dart | 17 +-- lib/config/router/navigates_to.dart | 35 ++++++ lib/config/router/routes.dart | 66 +++++++++++ .../router/routes_name.dart} | 2 +- lib/data/exceptions/app_exceptions.dart | 67 +++++++++++ .../cloud_note_models}/cloud_note_model.dart | 2 +- .../models/cloud_note_models}/user_model.dart | 2 +- .../models/local_note_model}/note_model.dart | 0 lib/data/network/base_api_service.dart | 9 ++ lib/data/network/network_services_api.dart | 105 ++++++++++++++++++ lib/{app => }/helpers/hive_manager.dart | 2 +- .../cloud_notes/auth => helpers}/wrapper.dart | 4 +- lib/m_functions/navigate_to.dart | 29 ----- lib/main.dart | 8 +- .../cloud_notes/auth/forgot_password.dart | 0 .../pages}/cloud_notes/auth/login_screen.dart | 6 +- .../cloud_notes/auth/register_screen.dart | 6 +- .../cloud_notes/auth/reset_password.dart | 0 .../pages}/cloud_notes/auth/verify_code.dart | 4 +- .../pages/cloud_notes}/cloud_create_note.dart | 2 +- .../pages/cloud_notes}/cloud_edit_note.dart | 10 +- .../pages/cloud_notes}/cloud_notes.dart | 6 +- .../cloud_notes/cloud_read_note_screen.dart} | 28 ++--- .../pages/home}/home.dart | 4 +- .../local_notes/create_note_screen.dart | 4 +- .../pages}/local_notes/edit_note_screen.dart | 4 +- .../pages}/local_notes/local_notes.dart | 8 +- .../local_notes/read_notes_screens.dart | 8 +- .../notifications/notifications_view.dart | 0 .../pages/settings}/settings_screen.dart | 10 +- .../pages/trash}/trashed_notes.dart | 5 +- lib/presentation/views.dart | 27 +++++ .../widget/mNew_text_widget.dart | 27 ++--- lib/{ => presentation}/widget/mbutton.dart | 27 ++--- lib/request/get_request.dart | 68 ------------ lib/request/post_request.dart | 75 ------------- .../note_style_cubit/note_style_cubit.dart | 0 .../note_style_cubit/note_style_state.dart | 0 .../play_button_cubit/play_button_cubit.dart | 0 .../play_button_cubit/play_button_state.dart | 0 .../cubits/theme_cubit/theme_cubit.dart | 0 .../cubits/theme_cubit/theme_state.dart | 0 lib/utils/colors/m_colors.dart | 47 ++++++++ lib/utils/const_values.dart | 19 +--- .../api => utils/constant}/api_constant.dart | 0 lib/utils/constant/asset_dir.dart | 18 +++ lib/utils/text_style/m_text_style.dart | 0 lib/utils/{ => themes}/custom_theme.dart | 37 +++--- lib/utils/{ => tools}/hex_to_color.dart | 0 lib/utils/{ => tools}/message_dialog.dart | 0 lib/utils/{ => tools}/money_formatter.dart | 0 lib/utils/tools/sized_box_ex.dart | 15 +++ lib/utils/{ => tools}/slide_transition.dart | 0 57 files changed, 509 insertions(+), 564 deletions(-) delete mode 100644 lib/app/resources/home/views/cloud_notes/models/cloud_note_model.g.dart delete mode 100644 lib/app/resources/home/views/cloud_notes/models/user_model.g.dart delete mode 100644 lib/app/resources/home/views/local_notes/models/note_model.g.dart delete mode 100644 lib/app/router/route_config.dart create mode 100644 lib/config/router/navigates_to.dart create mode 100644 lib/config/router/routes.dart rename lib/{app/router/route_name.dart => config/router/routes_name.dart} (97%) create mode 100644 lib/data/exceptions/app_exceptions.dart rename lib/{app/resources/home/views/cloud_notes/models => data/models/cloud_note_models}/cloud_note_model.dart (91%) rename lib/{app/resources/home/views/cloud_notes/models => data/models/cloud_note_models}/user_model.dart (95%) rename lib/{app/resources/home/views/local_notes/models => data/models/local_note_model}/note_model.dart (100%) create mode 100644 lib/data/network/base_api_service.dart create mode 100644 lib/data/network/network_services_api.dart rename lib/{app => }/helpers/hive_manager.dart (94%) rename lib/{app/resources/home/views/cloud_notes/auth => helpers}/wrapper.dart (84%) delete mode 100644 lib/m_functions/navigate_to.dart rename lib/{app/resources/home/views => presentation/pages}/cloud_notes/auth/forgot_password.dart (100%) rename lib/{app/resources/home/views => presentation/pages}/cloud_notes/auth/login_screen.dart (96%) rename lib/{app/resources/home/views => presentation/pages}/cloud_notes/auth/register_screen.dart (96%) rename lib/{app/resources/home/views => presentation/pages}/cloud_notes/auth/reset_password.dart (100%) rename lib/{app/resources/home/views => presentation/pages}/cloud_notes/auth/verify_code.dart (98%) rename lib/{app/resources/home/views/cloud_notes/views => presentation/pages/cloud_notes}/cloud_create_note.dart (98%) rename lib/{app/resources/home/views/cloud_notes/views => presentation/pages/cloud_notes}/cloud_edit_note.dart (95%) rename lib/{app/resources/home/views/cloud_notes/controller => presentation/pages/cloud_notes}/cloud_notes.dart (98%) rename lib/{app/resources/home/views/cloud_notes/views/cloud_read_note.dart => presentation/pages/cloud_notes/cloud_read_note_screen.dart} (87%) rename lib/{app/resources/home/controller => presentation/pages/home}/home.dart (96%) rename lib/{app/resources/home/views => presentation/pages}/local_notes/create_note_screen.dart (97%) rename lib/{app/resources/home/views => presentation/pages}/local_notes/edit_note_screen.dart (96%) rename lib/{app/resources/home/views => presentation/pages}/local_notes/local_notes.dart (98%) rename lib/{app/resources/home/views => presentation/pages}/local_notes/read_notes_screens.dart (96%) rename lib/{app/resources => presentation/pages}/notifications/notifications_view.dart (100%) rename lib/{app/resources/settings/controller => presentation/pages/settings}/settings_screen.dart (95%) rename lib/{app/resources/trash/controller => presentation/pages/trash}/trashed_notes.dart (97%) create mode 100644 lib/presentation/views.dart rename lib/{ => presentation}/widget/mNew_text_widget.dart (87%) rename lib/{ => presentation}/widget/mbutton.dart (85%) delete mode 100644 lib/request/get_request.dart delete mode 100644 lib/request/post_request.dart rename lib/{ => state}/cubits/note_style_cubit/note_style_cubit.dart (100%) rename lib/{ => state}/cubits/note_style_cubit/note_style_state.dart (100%) rename lib/{ => state}/cubits/play_button_cubit/play_button_cubit.dart (100%) rename lib/{ => state}/cubits/play_button_cubit/play_button_state.dart (100%) rename lib/{ => state}/cubits/theme_cubit/theme_cubit.dart (100%) rename lib/{ => state}/cubits/theme_cubit/theme_state.dart (100%) create mode 100644 lib/utils/colors/m_colors.dart rename lib/{app/api => utils/constant}/api_constant.dart (100%) create mode 100644 lib/utils/constant/asset_dir.dart create mode 100644 lib/utils/text_style/m_text_style.dart rename lib/utils/{ => themes}/custom_theme.dart (73%) rename lib/utils/{ => tools}/hex_to_color.dart (100%) rename lib/utils/{ => tools}/message_dialog.dart (100%) rename lib/utils/{ => tools}/money_formatter.dart (100%) create mode 100644 lib/utils/tools/sized_box_ex.dart rename lib/utils/{ => tools}/slide_transition.dart (100%) diff --git a/lib/app/resources/home/views/cloud_notes/models/cloud_note_model.g.dart b/lib/app/resources/home/views/cloud_notes/models/cloud_note_model.g.dart deleted file mode 100644 index 6f87270..0000000 --- a/lib/app/resources/home/views/cloud_notes/models/cloud_note_model.g.dart +++ /dev/null @@ -1,50 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cloud_note_model.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class CloudNoteModelAdapter extends TypeAdapter { - @override - final int typeId = 1; - - @override - CloudNoteModel read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return CloudNoteModel( - id: fields[1] as int?, - uuid: fields[2] as String?, - title: fields[3] as String?, - notes: fields[4] as String?, - ); - } - - @override - void write(BinaryWriter writer, CloudNoteModel obj) { - writer - ..writeByte(4) - ..writeByte(1) - ..write(obj.id) - ..writeByte(2) - ..write(obj.uuid) - ..writeByte(3) - ..write(obj.title) - ..writeByte(4) - ..write(obj.notes); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is CloudNoteModelAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} diff --git a/lib/app/resources/home/views/cloud_notes/models/user_model.g.dart b/lib/app/resources/home/views/cloud_notes/models/user_model.g.dart deleted file mode 100644 index dffa83a..0000000 --- a/lib/app/resources/home/views/cloud_notes/models/user_model.g.dart +++ /dev/null @@ -1,74 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'user_model.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class UserModelAdapter extends TypeAdapter { - @override - final int typeId = 2; - - @override - UserModel read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return UserModel( - id: fields[1] as int?, - uuid: fields[2] as String?, - firstName: fields[3] as String?, - lastName: fields[4] as String?, - userName: fields[5] as String?, - email: fields[6] as String?, - emailVerified: fields[7] as String?, - hasSubscription: fields[8] as int?, - hasExceedTier: fields[9] as int?, - planDuration: fields[10] as String?, - planSubDate: fields[11] as String?, - accessToken: fields[12] as String?, - ); - } - - @override - void write(BinaryWriter writer, UserModel obj) { - writer - ..writeByte(12) - ..writeByte(1) - ..write(obj.id) - ..writeByte(2) - ..write(obj.uuid) - ..writeByte(3) - ..write(obj.firstName) - ..writeByte(4) - ..write(obj.lastName) - ..writeByte(5) - ..write(obj.userName) - ..writeByte(6) - ..write(obj.email) - ..writeByte(7) - ..write(obj.emailVerified) - ..writeByte(8) - ..write(obj.hasSubscription) - ..writeByte(9) - ..write(obj.hasExceedTier) - ..writeByte(10) - ..write(obj.planDuration) - ..writeByte(11) - ..write(obj.planSubDate) - ..writeByte(12) - ..write(obj.accessToken); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is UserModelAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} diff --git a/lib/app/resources/home/views/local_notes/models/note_model.g.dart b/lib/app/resources/home/views/local_notes/models/note_model.g.dart deleted file mode 100644 index eed2277..0000000 --- a/lib/app/resources/home/views/local_notes/models/note_model.g.dart +++ /dev/null @@ -1,47 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'note_model.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class NoteModelAdapter extends TypeAdapter { - @override - final int typeId = 0; - - @override - NoteModel read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return NoteModel( - title: fields[0] as String?, - notes: fields[1] as String?, - dateTime: fields[2] as dynamic, - ); - } - - @override - void write(BinaryWriter writer, NoteModel obj) { - writer - ..writeByte(3) - ..writeByte(0) - ..write(obj.title) - ..writeByte(1) - ..write(obj.notes) - ..writeByte(2) - ..write(obj.dateTime); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is NoteModelAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} diff --git a/lib/app/router/route_config.dart b/lib/app/router/route_config.dart deleted file mode 100644 index 7131e44..0000000 --- a/lib/app/router/route_config.dart +++ /dev/null @@ -1,89 +0,0 @@ -import 'package:go_router/go_router.dart'; -import 'package:note_app/app/resources/home/controller/home.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/auth/login_screen.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/auth/register_screen.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/auth/verify_code.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/auth/wrapper.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/controller/cloud_notes.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_create_note.dart'; -import 'package:note_app/app/resources/home/views/local_notes/create_note_screen.dart'; -import 'package:note_app/app/resources/home/views/local_notes/edit_note_screen.dart'; -import 'package:note_app/app/resources/home/views/local_notes/local_notes.dart'; -import 'package:note_app/app/resources/home/views/local_notes/read_notes_screens.dart'; -import 'package:note_app/app/resources/settings/controller/settings_screen.dart'; -import 'package:note_app/app/router/route_name.dart'; - -class AppNavigation { - AppNavigation._(); - - static final GoRouter router = GoRouter( - routes: [ - GoRoute( - path: '/', - name: RouteName.home_screen, - builder: (_, state) => HomeScreen(), - routes: [ - // initiate routes - GoRoute( - path: 'local_notes', - name: RouteName.local_notes, - builder: (_, state) => const LocalNotesScreen(), - ), - GoRoute( - path: 'cloud_notes', - name: RouteName.cloud_notes, - builder: (_, state) => const CloudNotesScreen(), - ), - GoRoute( - path: 'settings_screen', - name: RouteName.settings_screen, - builder: (_, state) => const SettingsScreen(), - ), - GoRoute( - path: 'wrapper', - name: RouteName.wrapper, - builder: (_, state) => const Wrapper(), - ), - - // ends here - - // Local Notes Route - GoRoute( - path: 'create_notes_screen', - name: RouteName.create_notes_screen, - builder: (_, state) => const CreateNoteScreen(), - ), - // ends here - - // Local Notes Route - GoRoute( - path: 'cloud_create_notes_screen', - name: RouteName.cloud_create_notes_screen, - builder: (_, state) => const CloudCreateNote(), - ), - // ends here - - // Auth Route - GoRoute( - path: 'login_screen', - name: RouteName.login_screen, - builder: (_, state) => const LoginScreen(), - ), - GoRoute( - path: 'register_screen', - name: RouteName.register_screen, - builder: (_, state) => const RegisterScreen(), - ), - GoRoute( - path: 'verify_code_screen', - name: RouteName.verify_code_screen, - builder: (_, state) => VerifyCode( - from: state.uri.queryParameters['from'], - ), - ), - // ends here - ], - ), - ], - ); -} diff --git a/lib/app/src/app.dart b/lib/app/src/app.dart index d7b4207..27aaab6 100644 --- a/lib/app/src/app.dart +++ b/lib/app/src/app.dart @@ -1,9 +1,10 @@ import 'package:flashy_flushbar/flashy_flushbar_provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:note_app/app/router/route_config.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; -import 'package:note_app/utils/custom_theme.dart'; +import 'package:note_app/config/router/routes.dart'; +import 'package:note_app/config/router/routes_name.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/utils/themes/custom_theme.dart'; import 'package:provider/provider.dart'; class App extends StatefulWidget { @@ -19,13 +20,15 @@ class _AppState extends State { return ScreenUtilInit( designSize: const Size(375, 812), builder: (BuildContext context, Widget? child) { - return MaterialApp.router( + return MaterialApp( debugShowCheckedModeBanner: false, - theme: - context.watch().state.isDarkTheme == false ? buildLightTheme() : buildDarkTheme(), + theme: context.watch().state.isDarkTheme == false + ? buildLightTheme() + : buildDarkTheme(), title: 'VNotes', - routerConfig: AppNavigation.router, builder: FlashyFlushbarProvider.init(), + initialRoute: RoutesName.home_screen, + onGenerateRoute: Routes.generateRoute, ); }, ); diff --git a/lib/config/router/navigates_to.dart b/lib/config/router/navigates_to.dart new file mode 100644 index 0000000..86816c2 --- /dev/null +++ b/lib/config/router/navigates_to.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +Future navigateTo( + BuildContext context, { + required String destination, + Map? arguments, + }) { + return Navigator.pushNamed( + context, + destination, + arguments: arguments, + ); +} + +Future navigateReplaceTo( + BuildContext context, { + required String destination, + Map? arguments, + }) { + return Navigator.pushReplacementNamed(context, destination, + arguments: arguments); +} + +Future navigateEndTo( + BuildContext context, { + required String destination, + Map? arguments, + }) { + return Navigator.pushNamedAndRemoveUntil( + context, + destination, + arguments: arguments, + (route) => false, + ); +} \ No newline at end of file diff --git a/lib/config/router/routes.dart b/lib/config/router/routes.dart new file mode 100644 index 0000000..941ab36 --- /dev/null +++ b/lib/config/router/routes.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:note_app/config/router/routes_name.dart'; +import 'package:note_app/helpers/wrapper.dart'; +import 'package:note_app/presentation/views.dart'; + +class Routes { + static Route generateRoute(RouteSettings settings) { + // Extract the arguments + final args = settings.arguments as Map?; + + switch (settings.name) { + // Middleware Wrapper + case RoutesName.wrapper: + return MaterialPageRoute(builder: (_) => const Wrapper()); + // ends here + + // + case RoutesName.home_screen: + return MaterialPageRoute(builder: (_) => const HomeScreen()); + + case RoutesName.local_notes: + return MaterialPageRoute(builder: (_) => const LocalNotesScreen()); + + case RoutesName.cloud_notes: + return MaterialPageRoute(builder: (_) => const CloudNotesScreen()); + + case RoutesName.settings_screen: + return MaterialPageRoute(builder: (_) => const SettingsScreen()); + + case RoutesName.create_notes_screen: + return MaterialPageRoute(builder: (_) => const CreateNoteScreen()); + // + + // Cloud Notes + case RoutesName.cloud_create_notes_screen: + return MaterialPageRoute(builder: (_) => const CloudCreateNote()); + // ends here + + //Auth + case RoutesName.login_screen: + return MaterialPageRoute(builder: (_) => const LoginScreen()); + + case RoutesName.register_screen: + return MaterialPageRoute(builder: (_) => const RegisterScreen()); + + case RoutesName.verify_code_screen: + return MaterialPageRoute(builder: (_) => VerifyCode( + from: args!['from'], + )); + // ends here + + default: + return MaterialPageRoute( + builder: (_) { + return const Scaffold( + body: Center( + child: Text( + 'No Routes Generated', + ), + ), + ); + }, + ); + } + } +} diff --git a/lib/app/router/route_name.dart b/lib/config/router/routes_name.dart similarity index 97% rename from lib/app/router/route_name.dart rename to lib/config/router/routes_name.dart index 3bd21b0..2fe88e3 100644 --- a/lib/app/router/route_name.dart +++ b/lib/config/router/routes_name.dart @@ -1,4 +1,4 @@ -class RouteName { +class RoutesName { // initiate routes static const String home_screen = 'home_screen'; static const String local_notes = 'local_notes'; diff --git a/lib/data/exceptions/app_exceptions.dart b/lib/data/exceptions/app_exceptions.dart new file mode 100644 index 0000000..97963cb --- /dev/null +++ b/lib/data/exceptions/app_exceptions.dart @@ -0,0 +1,67 @@ +/// Base class for custom application exceptions. +class AppExceptions implements Exception { + final _message; // Message associated with the exception + final _prefix; // Prefix for the exception + + /// Constructor for creating a [NoInternAppExceptionsetException] instance. + /// + /// the [message] parameter represents the message associated with the exception. + /// the [prefix] parameter represents the prefix for the exception. + AppExceptions([this._message, this._prefix]); + + @override + String toString() { + return _message; + } +} + +/// Exception class representing a no internet connection error. +class NoInternetException extends AppExceptions { + /// Constructor for creating a [NoInternetException] instance. + /// + /// the [message] parameter represents the error message. + NoInternetException([String? message]) + : super(message, 'No Internet Connection.'); +} + +/// Exception class representing a n unauthorized access error. +class UnauthorisedException extends AppExceptions { + /// Constructor for creating a [UnauthorisedException] instance. + /// + /// the [message] parameter represents the error message. + UnauthorisedException([String? message]) + : super(message, 'You do not have access to this.'); +} + +/// Exception class representing network request timing out error. +class RequestTimeOutException extends AppExceptions { + /// Constructor for creating a [RequestTimeOutException] instance. + /// + /// the [message] parameter represents the error message. + RequestTimeOutException([String? message]) + : super(message, 'Request Time Out.'); +} + +/// Exception class representing a data fetching error during communication. +class FetchDataException extends AppExceptions { + /// Constructor for creating a [FetchDataException] instance. + /// + /// the [message] parameter represents the error message. + FetchDataException([String? message]) : super(message, ''); +} + +/// Exception class representing an Invalid input error. +class InvalidInputException extends AppExceptions { + /// Constructor for creating a [InvalidInputException] instance. + /// + /// the [message] parameter represents the error message. + InvalidInputException([String? message]) : super(message, 'Invalid Input'); +} + +/// Exception class representing a bad request error. +class BadRequestException extends AppExceptions { + /// Constructor for creating a [BadRequestException] instance. + /// + /// the [message] parameter represents the error message. + BadRequestException([String? message]) : super(message, 'Invalid Request'); +} \ No newline at end of file diff --git a/lib/app/resources/home/views/cloud_notes/models/cloud_note_model.dart b/lib/data/models/cloud_note_models/cloud_note_model.dart similarity index 91% rename from lib/app/resources/home/views/cloud_notes/models/cloud_note_model.dart rename to lib/data/models/cloud_note_models/cloud_note_model.dart index 88d8fb2..07d8878 100644 --- a/lib/app/resources/home/views/cloud_notes/models/cloud_note_model.dart +++ b/lib/data/models/cloud_note_models/cloud_note_model.dart @@ -1,6 +1,6 @@ import 'package:hive/hive.dart'; -part 'cloud_note_model.g.dart'; +part '../../../app/resources/home/views/cloud_notes/models/cloud_note_model.g.dart'; @HiveType(typeId: 1) class CloudNoteModel { diff --git a/lib/app/resources/home/views/cloud_notes/models/user_model.dart b/lib/data/models/cloud_note_models/user_model.dart similarity index 95% rename from lib/app/resources/home/views/cloud_notes/models/user_model.dart rename to lib/data/models/cloud_note_models/user_model.dart index 2adaeb5..05a0f15 100644 --- a/lib/app/resources/home/views/cloud_notes/models/user_model.dart +++ b/lib/data/models/cloud_note_models/user_model.dart @@ -1,6 +1,6 @@ import 'package:hive/hive.dart'; -part 'user_model.g.dart'; +part '../../../app/resources/home/views/cloud_notes/models/user_model.g.dart'; @HiveType(typeId: 2) class UserModel { diff --git a/lib/app/resources/home/views/local_notes/models/note_model.dart b/lib/data/models/local_note_model/note_model.dart similarity index 100% rename from lib/app/resources/home/views/local_notes/models/note_model.dart rename to lib/data/models/local_note_model/note_model.dart diff --git a/lib/data/network/base_api_service.dart b/lib/data/network/base_api_service.dart new file mode 100644 index 0000000..c96d553 --- /dev/null +++ b/lib/data/network/base_api_service.dart @@ -0,0 +1,9 @@ +abstract class BaseApiService { + + Future getApi({String? requestEnd, Map? queryParams}); + + Future postApi({String requestEnd, Map? params}); + + Future deleteApi(String url); + +} \ No newline at end of file diff --git a/lib/data/network/network_services_api.dart b/lib/data/network/network_services_api.dart new file mode 100644 index 0000000..09e1c3b --- /dev/null +++ b/lib/data/network/network_services_api.dart @@ -0,0 +1,105 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:http/http.dart' as http; +import 'package:note_app/data/exceptions/app_exceptions.dart'; +import 'package:note_app/data/network/base_api_service.dart'; +import 'package:note_app/utils/constant/api_constant.dart'; + +class NetworkServicesApi implements BaseApiService { + + @override + Future getApi({String? requestEnd, Map? queryParams}) async { + dynamic jsonResponse; + try { + // + final Uri url = Uri.parse('${ApiConstants.apiUrl}/$requestEnd'); + final Uri finalUri = url.replace(queryParameters: queryParams); + + final response = await http.get( + finalUri, + headers: { + 'Accept': 'application/json', + }, + ).timeout( + const Duration(seconds: 30), + ); + jsonResponse = returnResponse(response); + + if (response.statusCode == 200) {} + } on SocketException { + throw NoInternetException(); + } on TimeoutException { + throw FetchDataException('Time out try again'); + } + + return jsonResponse; + } + + @override + Future postApi({String? requestEnd, Map? params}) async { + dynamic jsonResponse; + try { + // + var url = Uri.decodeFull('${ApiConstants.apiUrl}/$requestEnd'); + final response = await http + .post( + Uri.parse(url), + body: params, + ) + .timeout( + const Duration(seconds: 30), + ); + jsonResponse = returnResponse(response); + + if (response.statusCode == 200) {} + } on SocketException { + throw NoInternetException(); + } on TimeoutException { + throw FetchDataException('Time out try again'); + } + + return jsonResponse; + } + + @override + Future deleteApi(String url) async { + dynamic jsonResponse; + try { + // + final response = await http.delete(Uri.parse(url)).timeout( + const Duration(seconds: 30), + ); + jsonResponse = returnResponse(response); + + if (response.statusCode == 200) {} + } on SocketException { + throw NoInternetException(); + } on TimeoutException { + throw FetchDataException('Time out try again'); + } + + return jsonResponse; + } + + dynamic returnResponse(http.Response response) { + switch (response.statusCode) { + case 200: + dynamic jsonResponse = json.decode(response.body); + return jsonResponse; + case 201: + dynamic jsonResponse = json.decode(response.body); + return jsonResponse; + case 400: + dynamic jsonResponse = json.decode(response.body); + return jsonResponse; + case 401: + throw UnauthorisedException(); + case 500: + throw FetchDataException('Error communicating with the server ${response.statusCode}'); + default: + throw UnauthorisedException(); + } + } +} \ No newline at end of file diff --git a/lib/app/helpers/hive_manager.dart b/lib/helpers/hive_manager.dart similarity index 94% rename from lib/app/helpers/hive_manager.dart rename to lib/helpers/hive_manager.dart index d5061d2..99a490a 100644 --- a/lib/app/helpers/hive_manager.dart +++ b/lib/helpers/hive_manager.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:note_app/app/resources/home/views/cloud_notes/models/cloud_note_model.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/models/user_model.dart'; +import 'package:note_app/data/models/cloud_note_models/user_model.dart'; import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; import 'package:note_app/utils/const_values.dart'; import 'package:path_provider/path_provider.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/auth/wrapper.dart b/lib/helpers/wrapper.dart similarity index 84% rename from lib/app/resources/home/views/cloud_notes/auth/wrapper.dart rename to lib/helpers/wrapper.dart index ce7c6cb..96b6ade 100644 --- a/lib/app/resources/home/views/cloud_notes/auth/wrapper.dart +++ b/lib/helpers/wrapper.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/cloud_notes/auth/login_screen.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/controller/cloud_notes.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/models/user_model.dart'; +import 'package:note_app/presentation/pages/cloud_notes/cloud_notes.dart'; +import 'package:note_app/data/models/cloud_note_models/user_model.dart'; import 'package:note_app/utils/const_values.dart'; class Wrapper extends StatefulWidget { diff --git a/lib/m_functions/navigate_to.dart b/lib/m_functions/navigate_to.dart deleted file mode 100644 index d0edac8..0000000 --- a/lib/m_functions/navigate_to.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; - -Future navigateTo(BuildContext context, {required Widget destination}) { - return Navigator.push( - context, MaterialPageRoute(builder: (context) => destination)); -} - -Future navigateReplaceTo(BuildContext context, {required Widget destination}) { - return Navigator.pushReplacement( - context, MaterialPageRoute(builder: (context) => destination)); -} - -Future navigateEndTo(BuildContext context, {required Widget destination}) { - return Navigator.pushAndRemoveUntil(context, - MaterialPageRoute(builder: (context) => destination), (route) => false); -} - -void clearAndNavigate(BuildContext context, {String? path, Map? queryParameters}) { - while (context.canPop() == true) { - context.pop(); - } - - if(queryParameters == null) { - context.pushReplacementNamed(path!); - } else { - context.pushReplacementNamed(path!, queryParameters: queryParameters); - } -} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index c5450cc..dc46d80 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:note_app/app/api/api_constant.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/src/app.dart'; -import 'package:note_app/cubits/note_style_cubit/note_style_cubit.dart'; -import 'package:note_app/cubits/play_button_cubit/play_button_cubit.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/state/cubits/note_style_cubit/note_style_cubit.dart'; +import 'package:note_app/state/cubits/play_button_cubit/play_button_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/utils/constant/api_constant.dart'; import 'package:provider/provider.dart'; import 'package:yaml/yaml.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/auth/forgot_password.dart b/lib/presentation/pages/cloud_notes/auth/forgot_password.dart similarity index 100% rename from lib/app/resources/home/views/cloud_notes/auth/forgot_password.dart rename to lib/presentation/pages/cloud_notes/auth/forgot_password.dart diff --git a/lib/app/resources/home/views/cloud_notes/auth/login_screen.dart b/lib/presentation/pages/cloud_notes/auth/login_screen.dart similarity index 96% rename from lib/app/resources/home/views/cloud_notes/auth/login_screen.dart rename to lib/presentation/pages/cloud_notes/auth/login_screen.dart index 2509250..8b8c8fd 100644 --- a/lib/app/resources/home/views/cloud_notes/auth/login_screen.dart +++ b/lib/presentation/pages/cloud_notes/auth/login_screen.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:go_router/go_router.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/models/user_model.dart'; +import 'package:note_app/data/models/cloud_note_models/user_model.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:note_app/widget/mNew_text_widget.dart'; import 'package:note_app/widget/mbutton.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/auth/register_screen.dart b/lib/presentation/pages/cloud_notes/auth/register_screen.dart similarity index 96% rename from lib/app/resources/home/views/cloud_notes/auth/register_screen.dart rename to lib/presentation/pages/cloud_notes/auth/register_screen.dart index ead97dd..4e890ab 100644 --- a/lib/app/resources/home/views/cloud_notes/auth/register_screen.dart +++ b/lib/presentation/pages/cloud_notes/auth/register_screen.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:go_router/go_router.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/models/user_model.dart'; +import 'package:note_app/data/models/cloud_note_models/user_model.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:note_app/widget/mNew_text_widget.dart'; import 'package:note_app/widget/mbutton.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/auth/reset_password.dart b/lib/presentation/pages/cloud_notes/auth/reset_password.dart similarity index 100% rename from lib/app/resources/home/views/cloud_notes/auth/reset_password.dart rename to lib/presentation/pages/cloud_notes/auth/reset_password.dart diff --git a/lib/app/resources/home/views/cloud_notes/auth/verify_code.dart b/lib/presentation/pages/cloud_notes/auth/verify_code.dart similarity index 98% rename from lib/app/resources/home/views/cloud_notes/auth/verify_code.dart rename to lib/presentation/pages/cloud_notes/auth/verify_code.dart index b1cb2ab..bb2029b 100644 --- a/lib/app/resources/home/views/cloud_notes/auth/verify_code.dart +++ b/lib/presentation/pages/cloud_notes/auth/verify_code.dart @@ -7,10 +7,10 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:go_router/go_router.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:note_app/widget/mbutton.dart'; import 'package:otp_text_field_v2/otp_text_field_v2.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/views/cloud_create_note.dart b/lib/presentation/pages/cloud_notes/cloud_create_note.dart similarity index 98% rename from lib/app/resources/home/views/cloud_notes/views/cloud_create_note.dart rename to lib/presentation/pages/cloud_notes/cloud_create_note.dart index efdceb5..654e95c 100644 --- a/lib/app/resources/home/views/cloud_notes/views/cloud_create_note.dart +++ b/lib/presentation/pages/cloud_notes/cloud_create_note.dart @@ -6,8 +6,8 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:go_router/go_router.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/cloud_notes/views/cloud_edit_note.dart b/lib/presentation/pages/cloud_notes/cloud_edit_note.dart similarity index 95% rename from lib/app/resources/home/views/cloud_notes/views/cloud_edit_note.dart rename to lib/presentation/pages/cloud_notes/cloud_edit_note.dart index 6c0aa42..7553c8a 100644 --- a/lib/app/resources/home/views/cloud_notes/views/cloud_edit_note.dart +++ b/lib/presentation/pages/cloud_notes/cloud_edit_note.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/cloud_notes/models/cloud_note_model.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_read_note.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_read_note_screen.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/m_functions/navigate_to.dart'; import 'package:note_app/request/post_request.dart'; import 'package:note_app/utils/const_values.dart'; @@ -36,7 +36,6 @@ class _CloudEditNoteState extends State { var _isInit = true; Future editNote(String? title, String? notes, String? uuid) async { - final userModel = HiveManager().userModelBox; final storeData = HiveManager().noteModelBox; @@ -148,8 +147,9 @@ class _CloudEditNoteState extends State { }, icon: Icon( Icons.done, - color: - context.watch().state.isDarkTheme == false ? Colors.black45 : Colors.white38, + color: context.watch().state.isDarkTheme == false + ? Colors.black45 + : Colors.white38, ), label: Text( 'Update', diff --git a/lib/app/resources/home/views/cloud_notes/controller/cloud_notes.dart b/lib/presentation/pages/cloud_notes/cloud_notes.dart similarity index 98% rename from lib/app/resources/home/views/cloud_notes/controller/cloud_notes.dart rename to lib/presentation/pages/cloud_notes/cloud_notes.dart index 168859c..d470be6 100644 --- a/lib/app/resources/home/views/cloud_notes/controller/cloud_notes.dart +++ b/lib/presentation/pages/cloud_notes/cloud_notes.dart @@ -8,14 +8,14 @@ import 'package:go_router/go_router.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/cloud_notes/models/cloud_note_model.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_read_note.dart'; +import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_read_note_screen.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/m_functions/navigate_to.dart'; import 'package:note_app/request/get_request.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:provider/provider.dart'; class CloudNotesScreen extends StatefulWidget { diff --git a/lib/app/resources/home/views/cloud_notes/views/cloud_read_note.dart b/lib/presentation/pages/cloud_notes/cloud_read_note_screen.dart similarity index 87% rename from lib/app/resources/home/views/cloud_notes/views/cloud_read_note.dart rename to lib/presentation/pages/cloud_notes/cloud_read_note_screen.dart index b47a08d..719085a 100644 --- a/lib/app/resources/home/views/cloud_notes/views/cloud_read_note.dart +++ b/lib/presentation/pages/cloud_notes/cloud_read_note_screen.dart @@ -3,10 +3,10 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_tts/flutter_tts.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/models/cloud_note_model.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/views/cloud_edit_note.dart'; -import 'package:note_app/cubits/play_button_cubit/play_button_cubit.dart'; +import 'package:note_app/data/models/cloud_note_models/cloud_note_model.dart'; +import 'package:note_app/presentation/pages/cloud_notes/cloud_edit_note.dart'; import 'package:note_app/m_functions/navigate_to.dart'; +import 'package:note_app/state/cubits/play_button_cubit/play_button_cubit.dart'; import 'package:note_app/utils/const_values.dart'; import 'package:provider/provider.dart'; @@ -24,7 +24,7 @@ class CloudReadNote extends StatefulWidget { State createState() => _CloudReadNoteState(); } -enum TtsState { +enum TtsCloudState { playing, stopped, paused, @@ -41,7 +41,7 @@ class _CloudReadNoteState extends State { String? _newVoiceText; - TtsState ttsState = TtsState.stopped; + TtsCloudState ttsState = TtsCloudState.stopped; bool get isIOS => !kIsWeb && Platform.isIOS; @@ -71,21 +71,21 @@ class _CloudReadNoteState extends State { flutterTts!.setStartHandler(() { setState(() { logger.i('Playing'); - ttsState = TtsState.playing; + ttsState = TtsCloudState.playing; }); }); flutterTts!.setCompletionHandler(() { setState(() { logger.i('Complete'); - ttsState = TtsState.stopped; + ttsState = TtsCloudState.stopped; }); }); flutterTts!.setCancelHandler(() { setState(() { logger.i('Cancel'); - ttsState = TtsState.stopped; + ttsState = TtsCloudState.stopped; }); }); @@ -93,14 +93,14 @@ class _CloudReadNoteState extends State { flutterTts!.setPauseHandler(() { setState(() { logger.i('Paused'); - ttsState = TtsState.paused; + ttsState = TtsCloudState.paused; }); }); flutterTts!.setContinueHandler(() { setState(() { logger.i('Continued'); - ttsState = TtsState.continued; + ttsState = TtsCloudState.continued; }); }); } @@ -108,7 +108,7 @@ class _CloudReadNoteState extends State { flutterTts!.setErrorHandler((msg) { setState(() { logger.i('error: $msg'); - ttsState = TtsState.stopped; + ttsState = TtsCloudState.stopped; }); }); } @@ -142,7 +142,7 @@ class _CloudReadNoteState extends State { Future _stop() async { var result = await flutterTts!.stop(); - if (result == 1) setState(() => ttsState = TtsState.stopped); + if (result == 1) setState(() => ttsState = TtsCloudState.stopped); } // Android does not support pause as of this moment @@ -235,10 +235,10 @@ class _CloudReadNoteState extends State { ? FloatingActionButton( backgroundColor: Colors.white60, onPressed: () { - ttsState == TtsState.stopped ? _speak() : _stop(); + ttsState == TtsCloudState.stopped ? _speak() : _stop(); }, child: Icon( - ttsState == TtsState.stopped + ttsState == TtsCloudState.stopped ? Icons.play_circle_outline : Icons.stop_circle_outlined, color: Colors.black45, diff --git a/lib/app/resources/home/controller/home.dart b/lib/presentation/pages/home/home.dart similarity index 96% rename from lib/app/resources/home/controller/home.dart rename to lib/presentation/pages/home/home.dart index 2a135c1..0e48d74 100644 --- a/lib/app/resources/home/controller/home.dart +++ b/lib/presentation/pages/home/home.dart @@ -5,9 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:go_router/go_router.dart'; -import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; -import 'package:note_app/utils/const_values.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/greetings.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/local_notes/create_note_screen.dart b/lib/presentation/pages/local_notes/create_note_screen.dart similarity index 97% rename from lib/app/resources/home/views/local_notes/create_note_screen.dart rename to lib/presentation/pages/local_notes/create_note_screen.dart index ee33e98..361e21f 100644 --- a/lib/app/resources/home/views/local_notes/create_note_screen.dart +++ b/lib/presentation/pages/local_notes/create_note_screen.dart @@ -6,8 +6,8 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/local_notes/local_notes.dart'; import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; -import 'package:note_app/utils/slide_transition.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/utils/tools/slide_transition.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/home/views/local_notes/edit_note_screen.dart b/lib/presentation/pages/local_notes/edit_note_screen.dart similarity index 96% rename from lib/app/resources/home/views/local_notes/edit_note_screen.dart rename to lib/presentation/pages/local_notes/edit_note_screen.dart index 8ee4859..d4dc477 100644 --- a/lib/app/resources/home/views/local_notes/edit_note_screen.dart +++ b/lib/presentation/pages/local_notes/edit_note_screen.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; -import 'package:note_app/app/resources/home/views/local_notes/read_notes_screens.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/presentation/pages/local_notes/read_notes_screens.dart'; import 'package:note_app/m_functions/navigate_to.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:provider/provider.dart'; class EditNoteScreen extends StatefulWidget { diff --git a/lib/app/resources/home/views/local_notes/local_notes.dart b/lib/presentation/pages/local_notes/local_notes.dart similarity index 98% rename from lib/app/resources/home/views/local_notes/local_notes.dart rename to lib/presentation/pages/local_notes/local_notes.dart index af83416..efb5bf4 100644 --- a/lib/app/resources/home/views/local_notes/local_notes.dart +++ b/lib/presentation/pages/local_notes/local_notes.dart @@ -10,15 +10,15 @@ import 'package:hive/hive.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; -import 'package:note_app/app/resources/home/views/local_notes/read_notes_screens.dart'; +import 'package:note_app/presentation/pages/local_notes/read_notes_screens.dart'; import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/cubits/note_style_cubit/note_style_cubit.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/m_functions/navigate_to.dart'; +import 'package:note_app/state/cubits/note_style_cubit/note_style_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; import 'package:provider/provider.dart'; -import 'create_note_screen.dart'; +import '../../../../../presentation/pages/local_notes/create_note_screen.dart'; class LocalNotesScreen extends StatefulWidget { const LocalNotesScreen({Key? key}) : super(key: key); diff --git a/lib/app/resources/home/views/local_notes/read_notes_screens.dart b/lib/presentation/pages/local_notes/read_notes_screens.dart similarity index 96% rename from lib/app/resources/home/views/local_notes/read_notes_screens.dart rename to lib/presentation/pages/local_notes/read_notes_screens.dart index 2ae0c81..41dddbd 100644 --- a/lib/app/resources/home/views/local_notes/read_notes_screens.dart +++ b/lib/presentation/pages/local_notes/read_notes_screens.dart @@ -3,14 +3,14 @@ import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/app/resources/home/views/local_notes/edit_note_screen.dart'; +import 'package:note_app/presentation/pages/local_notes/edit_note_screen.dart'; import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; -import 'package:note_app/cubits/play_button_cubit/play_button_cubit.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/m_functions/navigate_to.dart'; import 'package:note_app/request/post_request.dart'; +import 'package:note_app/state/cubits/play_button_cubit/play_button_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/notifications/notifications_view.dart b/lib/presentation/pages/notifications/notifications_view.dart similarity index 100% rename from lib/app/resources/notifications/notifications_view.dart rename to lib/presentation/pages/notifications/notifications_view.dart diff --git a/lib/app/resources/settings/controller/settings_screen.dart b/lib/presentation/pages/settings/settings_screen.dart similarity index 95% rename from lib/app/resources/settings/controller/settings_screen.dart rename to lib/presentation/pages/settings/settings_screen.dart index 4751be8..d71fbd8 100644 --- a/lib/app/resources/settings/controller/settings_screen.dart +++ b/lib/presentation/pages/settings/settings_screen.dart @@ -2,13 +2,13 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/app/resources/trash/controller/trashed_notes.dart'; -import 'package:note_app/cubits/play_button_cubit/play_button_cubit.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/helpers/hive_manager.dart'; +import 'package:note_app/presentation/pages/trash/trashed_notes.dart'; import 'package:note_app/request/get_request.dart'; +import 'package:note_app/state/cubits/play_button_cubit/play_button_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; +import 'package:note_app/utils/tools/message_dialog.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; diff --git a/lib/app/resources/trash/controller/trashed_notes.dart b/lib/presentation/pages/trash/trashed_notes.dart similarity index 97% rename from lib/app/resources/trash/controller/trashed_notes.dart rename to lib/presentation/pages/trash/trashed_notes.dart index 5902261..9c06af2 100644 --- a/lib/app/resources/trash/controller/trashed_notes.dart +++ b/lib/presentation/pages/trash/trashed_notes.dart @@ -2,10 +2,9 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:hive/hive.dart'; -import 'package:note_app/app/helpers/hive_manager.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:note_app/app/resources/home/views/local_notes/models/note_model.dart'; +import 'package:note_app/data/models/local_note_model/note_model.dart'; +import 'package:note_app/helpers/hive_manager.dart'; class TrashedNotes extends StatefulWidget { const TrashedNotes({Key? key}) : super(key: key); diff --git a/lib/presentation/views.dart b/lib/presentation/views.dart new file mode 100644 index 0000000..0b0a731 --- /dev/null +++ b/lib/presentation/views.dart @@ -0,0 +1,27 @@ +export 'pages/home/home.dart'; + +// local notes +export 'pages/local_notes/local_notes.dart'; +export 'pages/local_notes/create_note_screen.dart'; +export 'pages/local_notes/edit_note_screen.dart'; +export 'pages/local_notes/read_notes_screens.dart'; + +// cloud notes +export 'pages/cloud_notes/cloud_notes.dart'; +export 'pages/cloud_notes/cloud_create_note.dart'; +export 'pages/cloud_notes/cloud_edit_note.dart'; +export 'pages/cloud_notes/cloud_read_note_screen.dart'; + +// cloud auth +export 'pages/cloud_notes/auth/login_screen.dart'; +export 'pages/cloud_notes/auth/register_screen.dart'; +export 'pages/cloud_notes/auth/verify_code.dart'; + +// settings +export 'pages/settings/settings_screen.dart'; + +// trash +export 'pages/trash/trashed_notes.dart'; + +// notifications +export 'pages/notifications/notifications_view.dart'; \ No newline at end of file diff --git a/lib/widget/mNew_text_widget.dart b/lib/presentation/widget/mNew_text_widget.dart similarity index 87% rename from lib/widget/mNew_text_widget.dart rename to lib/presentation/widget/mNew_text_widget.dart index 9f25d6e..cfaeacf 100644 --- a/lib/widget/mNew_text_widget.dart +++ b/lib/presentation/widget/mNew_text_widget.dart @@ -3,9 +3,10 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/utils/colors/m_colors.dart'; import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/money_formatter.dart'; +import 'package:note_app/utils/tools/money_formatter.dart'; class MNewTextField extends StatefulWidget { final double? height; @@ -110,8 +111,8 @@ class _MNewTextFieldState extends State { style: TextStyle( fontSize: 14.sp, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), ), ], @@ -171,14 +172,14 @@ class _MNewTextFieldState extends State { ? FaIcon( FontAwesomeIcons.eye, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ) : FaIcon( FontAwesomeIcons.eyeSlash, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), onPressed: widget.togglePasswordView, ), @@ -191,13 +192,13 @@ class _MNewTextFieldState extends State { enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide( - color: state.isDarkTheme == false ? defaultBlack : defaultWhite, + color: state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide( - color: state.isDarkTheme == false ? defaultBlack : defaultWhite, + color: state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), errorBorder: OutlineInputBorder( @@ -215,18 +216,18 @@ class _MNewTextFieldState extends State { border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide( - color: state.isDarkTheme == false ? defaultBlack : defaultWhite, + color: state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), hintText: '${widget.fieldName}', hintStyle: TextStyle( - color: state.isDarkTheme == false ? defaultBlack : defaultWhite, + color: state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), textAlign: widget.textAlign ?? TextAlign.left, style: TextStyle( fontSize: 14.sp, - color: state.isDarkTheme == false ? defaultBlack : defaultWhite, + color: state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), widget.removeBottomPadding == true diff --git a/lib/widget/mbutton.dart b/lib/presentation/widget/mbutton.dart similarity index 85% rename from lib/widget/mbutton.dart rename to lib/presentation/widget/mbutton.dart index 6f08db1..e4641f6 100644 --- a/lib/widget/mbutton.dart +++ b/lib/presentation/widget/mbutton.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:note_app/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/state/cubits/theme_cubit/theme_cubit.dart'; +import 'package:note_app/utils/colors/m_colors.dart'; import 'package:note_app/utils/const_values.dart'; class MButton extends StatefulWidget { @@ -65,8 +66,8 @@ class _MButtonState extends State { borderRadius: BorderRadius.circular(widget.radius ?? 8), side: BorderSide( color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), ), ), @@ -84,8 +85,8 @@ class _MButtonState extends State { ? FontWeight.bold : FontWeight.normal, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), textAlign: TextAlign.center, ), @@ -97,8 +98,8 @@ class _MButtonState extends State { ? FontWeight.bold : FontWeight.normal, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), textAlign: TextAlign.center, ), @@ -116,8 +117,8 @@ class _MButtonState extends State { ? FontWeight.bold : FontWeight.normal, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), textAlign: TextAlign.center, ), @@ -126,7 +127,7 @@ class _MButtonState extends State { ), Icon( widget.btnIcon!, - color: defaultWhite, + color: AppColors.defaultWhite, ), ], ) @@ -138,8 +139,8 @@ class _MButtonState extends State { ? FontWeight.bold : FontWeight.normal, color: state.isDarkTheme == false - ? defaultBlack - : defaultWhite, + ? AppColors.defaultBlack + : AppColors.defaultWhite, ), textAlign: TextAlign.center, ) @@ -148,7 +149,7 @@ class _MButtonState extends State { height: 20.w, child: CircularProgressIndicator( color: - state.isDarkTheme == false ? defaultBlack : defaultWhite, + state.isDarkTheme == false ? AppColors.defaultBlack : AppColors.defaultWhite, ), ), ), diff --git a/lib/request/get_request.dart b/lib/request/get_request.dart deleted file mode 100644 index 22ab090..0000000 --- a/lib/request/get_request.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; - -class GetRequest { - static Future makeGetRequest({ - String? requestEnd, - Map? queryParams, - String? outApiUrl, - String? bearer, - BuildContext? context, - }) async { - final userModel = HiveManager().userModelBox; - try { - final Uri url = Uri.parse('${outApiUrl ?? apiUrl}/$requestEnd'); - final Uri finalUri = url.replace(queryParameters: queryParams); - - var response = await http.get( - finalUri, - headers: { - 'Accept': 'application/json', - 'Authorization': 'Bearer $bearer', - }, - ).timeout(const Duration(seconds: 20)); // Set a timeout of 10 seconds - - var status = json.decode(response.body)['status']; - var errorMsg = json.decode(response.body)['message']; - - if (status == 401) { - showError('$errorMsg'); - userModel.delete(tokenKey); - } - - if (status == 400 || status == 500) { - showError('$errorMsg'); - } - - return json.decode(response.body); - } on TimeoutException catch (e) { - // Handle timeout exception - showError('Request timed out after 10 seconds.'); - return null; - } on FormatException catch (e) { - logger.i(e.toString()); - if (e.toString().contains('Unexpected character')) { - showError('Your Session has expired.'); - } - return null; - } catch (e) { - logger.e(e); - if (e.toString().contains('Connection timed out')) { - showError('Connection timed out'); - } else if (e.toString().contains('Connection closed')) { - showError('Connection closed!!!'); - } else if (e.toString().contains('Connection reset by peer')) { - showError('Connection reset by peer'); - } else { - showError('Something went wrong'); - } - return null; - } - } -} \ No newline at end of file diff --git a/lib/request/post_request.dart b/lib/request/post_request.dart deleted file mode 100644 index 671cbd4..0000000 --- a/lib/request/post_request.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'package:note_app/app/helpers/hive_manager.dart'; -import 'package:note_app/app/resources/home/views/cloud_notes/auth/verify_code.dart'; -import 'package:note_app/app/router/route_name.dart'; -import 'package:note_app/m_functions/navigate_to.dart'; -import 'package:note_app/utils/const_values.dart'; -import 'package:note_app/utils/message_dialog.dart'; - -class PostRequest { - static Future makePostRequest({ - String? requestEnd, - String? bearer, - String? vEmail, - dynamic jsonParam, - Map? params, - BuildContext? context, - }) async { - final userModel = HiveManager().userModelBox; - var url = Uri.decodeFull('$apiUrl/$requestEnd'); - - try { - var response = await http.post( - Uri.parse(url), - body: params, - headers: { - 'Accept': 'application/json', - 'Authorization': 'Bearer $bearer', - }, - ).timeout(const Duration(seconds: 20)); - - var status = json.decode(response.body)['status']; - var errorMsg = json.decode(response.body)['message']; - - if(status == 403) { - navigateTo(context!, destination: VerifyCode(email: vEmail)); - showError('$errorMsg'); - } - - if (status == 401) { - clearAndNavigate(context!, path: RouteName.login_screen); - userModel.delete(tokenKey); - logger.i(errorMsg); - showError('$errorMsg'); - } - - if (status != 200 && status != 201 && status != 202) { - logger.i(errorMsg); - showError('$errorMsg'); - } - - return json.decode(response.body); - } on TimeoutException catch (e) { - // Handle timeout exception - showError('Request timed out after 10 seconds.'); - return null; - } on FormatException catch (e) { - if (e.toString().contains('Unexpected character')) { - showError('Something Unexpected just happened'); - } - return null; - } on NoSuchMethodError catch (e) { - if (e.toString().contains('NoSuchMethodError')) { - showError('Something Unexpected just happened'); - } - return null; - } catch (e) { - logger.e(e); - return null; - } - } -} \ No newline at end of file diff --git a/lib/cubits/note_style_cubit/note_style_cubit.dart b/lib/state/cubits/note_style_cubit/note_style_cubit.dart similarity index 100% rename from lib/cubits/note_style_cubit/note_style_cubit.dart rename to lib/state/cubits/note_style_cubit/note_style_cubit.dart diff --git a/lib/cubits/note_style_cubit/note_style_state.dart b/lib/state/cubits/note_style_cubit/note_style_state.dart similarity index 100% rename from lib/cubits/note_style_cubit/note_style_state.dart rename to lib/state/cubits/note_style_cubit/note_style_state.dart diff --git a/lib/cubits/play_button_cubit/play_button_cubit.dart b/lib/state/cubits/play_button_cubit/play_button_cubit.dart similarity index 100% rename from lib/cubits/play_button_cubit/play_button_cubit.dart rename to lib/state/cubits/play_button_cubit/play_button_cubit.dart diff --git a/lib/cubits/play_button_cubit/play_button_state.dart b/lib/state/cubits/play_button_cubit/play_button_state.dart similarity index 100% rename from lib/cubits/play_button_cubit/play_button_state.dart rename to lib/state/cubits/play_button_cubit/play_button_state.dart diff --git a/lib/cubits/theme_cubit/theme_cubit.dart b/lib/state/cubits/theme_cubit/theme_cubit.dart similarity index 100% rename from lib/cubits/theme_cubit/theme_cubit.dart rename to lib/state/cubits/theme_cubit/theme_cubit.dart diff --git a/lib/cubits/theme_cubit/theme_state.dart b/lib/state/cubits/theme_cubit/theme_state.dart similarity index 100% rename from lib/cubits/theme_cubit/theme_state.dart rename to lib/state/cubits/theme_cubit/theme_state.dart diff --git a/lib/utils/colors/m_colors.dart b/lib/utils/colors/m_colors.dart new file mode 100644 index 0000000..f444c92 --- /dev/null +++ b/lib/utils/colors/m_colors.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:note_app/utils/tools/hex_to_color.dart'; + +class AppColors { + static Color darkColor = hexToColor('#333333'); + static Color? cardColor = Colors.grey[850]; + +//colors for the app + static Color primaryColor = hexToColor('#E0D3AFFF'); + static Color secondaryColor = hexToColor('#171B1E'); + static Color subTextColor = hexToColor('#B5A006'); + static Color greyTextColor = hexToColor('#798084'); + static Color scaffoldLightColor = hexToColor('#FAFAFA'); + + static Color primaryGrey = hexToColor('#F9F9F9'); + static Color secondaryGrey = hexToColor('#F5F5F5'); + static Color lightGrey = hexToColor('#F1F1F1'); + static Color primaryGold = hexToColor('#C9B902'); + static Color transparent = Colors.transparent; + static Color btnBorderColor = hexToColor('#CCE8D4'); + static Color textFieldBorderColor = hexToColor('#938989'); + + static Color borderColor = hexToColor('#EBECED'); + static Color green = hexToColor('#009A51'); + static Color darkGreen = hexToColor('#006D3A'); + static Color red = hexToColor('#F83446'); + static Color darkRed = hexToColor('#B02532'); + static Color redWarning = hexToColor('#FEEBED'); + + static Color dialogColor = Colors.white; + static Color backColorOne = Colors.white; + static Color defaultTextColor = Colors.black; + + + static Color boxColor = const Color.fromRGBO(235, 237, 242, 1); + + static Color grey = hexToColor('#AFACAB'); + +//other colors + static Color defaultWhite = const Color.fromRGBO(255, 255, 255, 1); + static Color defaultBlack = const Color.fromRGBO(0, 0, 0, 1); +// + + static Color btnSecondaryTextCode = const Color.fromRGBO(255, 255, 255, 1); + static Color btnPrimaryTextCode = const Color.fromRGBO(0, 0, 0, 1); + +} \ No newline at end of file diff --git a/lib/utils/const_values.dart b/lib/utils/const_values.dart index 1d24beb..b528e0b 100644 --- a/lib/utils/const_values.dart +++ b/lib/utils/const_values.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; -import 'package:note_app/app/api/api_constant.dart'; -import 'package:note_app/utils/hex_to_color.dart'; +import 'package:note_app/utils/constant/api_constant.dart'; +import 'package:note_app/utils/tools/hex_to_color.dart'; var logger = Logger(); @@ -17,21 +17,6 @@ const String dialogText = 'There is a new update for V Notes, ' 'would you like to update to check up ' 'what we have improved about the app'; -const Color backColor = Color.fromRGBO(224, 211, 175, 1); - -const Color appbarColor = Color.fromRGBO(48, 48, 48, 1); -const Color bodyColor = Color.fromRGBO(33, 33, 33, 1); - -//other colors -const defaultWhite = Color.fromRGBO(255, 255, 255, 1); -const defaultBlack = Color.fromRGBO(0, 0, 0, 1); - -// dark and light theme color -Color? darkColor = Colors.grey[900]; -const darkColorTwo = Color.fromRGBO(32, 32, 96, 1); - -Color? cardColor = Colors.grey[850]; - // Hive details const String noteBox = 'notebox'; const String cloudNoteBox = 'cloudNoteBox'; diff --git a/lib/app/api/api_constant.dart b/lib/utils/constant/api_constant.dart similarity index 100% rename from lib/app/api/api_constant.dart rename to lib/utils/constant/api_constant.dart diff --git a/lib/utils/constant/asset_dir.dart b/lib/utils/constant/asset_dir.dart new file mode 100644 index 0000000..19eeb3d --- /dev/null +++ b/lib/utils/constant/asset_dir.dart @@ -0,0 +1,18 @@ + +class AssetDir { + + + // Lufga Font Family + static String PublicSansBlack = 'PublicSansBlack'; + static String PublicSansBold = 'PublicSansBold'; + static String PublicSansExtraBold = 'PublicSansExtraBold'; + static String PublicSansExtraLight = 'PublicSansExtraLight'; + static String PublicSansLight = 'PublicSansLight'; + static String PublicSansMedium = 'PublicSansMedium'; + static String PublicSansRegular = 'PublicSansRegular'; + static String PublicSansSemiBold = 'PublicSansSemiBold'; + static String PublicSansThin = 'PublicSansThin'; + +// SVGs +// static String happyBird = '$svgAssets/undraw_happy_music_g6wc.svg'; +} \ No newline at end of file diff --git a/lib/utils/text_style/m_text_style.dart b/lib/utils/text_style/m_text_style.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/utils/custom_theme.dart b/lib/utils/themes/custom_theme.dart similarity index 73% rename from lib/utils/custom_theme.dart rename to lib/utils/themes/custom_theme.dart index fb801c8..60272fb 100644 --- a/lib/utils/custom_theme.dart +++ b/lib/utils/themes/custom_theme.dart @@ -1,26 +1,27 @@ import 'package:flutter/material.dart'; +import 'package:note_app/utils/colors/m_colors.dart'; import 'package:note_app/utils/const_values.dart'; ThemeData buildLightTheme() => ThemeData.light().copyWith( cardColor: Colors.white, - scaffoldBackgroundColor: backColor, - iconTheme: const IconThemeData( - color: defaultBlack, + scaffoldBackgroundColor: AppColors.primaryColor, + iconTheme: IconThemeData( + color: AppColors.defaultBlack, ), cardTheme: const CardTheme( color: Colors.white, ), - dialogTheme: const DialogTheme( - backgroundColor: backColor, - titleTextStyle: TextStyle( + dialogTheme: DialogTheme( + backgroundColor: AppColors.primaryColor, + titleTextStyle: const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, ), - contentTextStyle: TextStyle( + contentTextStyle: const TextStyle( color: Colors.black, ), ), - dividerColor: defaultBlack, + dividerColor: AppColors.defaultBlack, appBarTheme: AppBarTheme( centerTitle: true, elevation: 0.0, @@ -38,25 +39,25 @@ ThemeData buildLightTheme() => ThemeData.light().copyWith( textButtonTheme: TextButtonThemeData( style: ButtonStyle( textStyle: MaterialStateProperty.resolveWith( - (states) => const TextStyle( - color: defaultBlack, + (states) => TextStyle( + color: AppColors.defaultBlack, ), ), ), ), - dialogBackgroundColor: backColor, + dialogBackgroundColor: AppColors.primaryColor, textTheme: Typography.blackCupertino, ); ThemeData buildDarkTheme() => ThemeData.dark().copyWith( cardColor: Colors.grey[850], - scaffoldBackgroundColor: darkColor, - dividerColor: defaultWhite, - iconTheme: const IconThemeData( - color: defaultWhite, + scaffoldBackgroundColor: AppColors.darkColor, + dividerColor: AppColors.defaultWhite, + iconTheme: IconThemeData( + color: AppColors.defaultWhite, ), cardTheme: CardTheme( - color: cardColor, + color: AppColors.cardColor, ), dialogTheme: DialogTheme( backgroundColor: Colors.grey[900], @@ -92,8 +93,8 @@ ThemeData buildDarkTheme() => ThemeData.dark().copyWith( textButtonTheme: TextButtonThemeData( style: ButtonStyle( textStyle: MaterialStateProperty.resolveWith( - (states) => const TextStyle( - color: defaultBlack, + (states) => TextStyle( + color: AppColors.defaultBlack, ), ), ), diff --git a/lib/utils/hex_to_color.dart b/lib/utils/tools/hex_to_color.dart similarity index 100% rename from lib/utils/hex_to_color.dart rename to lib/utils/tools/hex_to_color.dart diff --git a/lib/utils/message_dialog.dart b/lib/utils/tools/message_dialog.dart similarity index 100% rename from lib/utils/message_dialog.dart rename to lib/utils/tools/message_dialog.dart diff --git a/lib/utils/money_formatter.dart b/lib/utils/tools/money_formatter.dart similarity index 100% rename from lib/utils/money_formatter.dart rename to lib/utils/tools/money_formatter.dart diff --git a/lib/utils/tools/sized_box_ex.dart b/lib/utils/tools/sized_box_ex.dart new file mode 100644 index 0000000..d461545 --- /dev/null +++ b/lib/utils/tools/sized_box_ex.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +extension SizedBoxExtension on int { + Widget get toHeight { + return SizedBox( + height: toDouble(), + ); + } + + Widget get toWidth { + return SizedBox( + width: toDouble(), + ); + } +} \ No newline at end of file diff --git a/lib/utils/slide_transition.dart b/lib/utils/tools/slide_transition.dart similarity index 100% rename from lib/utils/slide_transition.dart rename to lib/utils/tools/slide_transition.dart