diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 719342d..27146e2 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -204,7 +204,21 @@ "ChildLayouter", "Paginated", "blazingly", - "Patreon" + "Patreon", + "dotenv", + "Summ", + "Favourite", + "geolocator", + "Geocoder", + "geocode", + "latlng", + "mipmap", + "xmark", + "Rabotayet", + "placemarks", + "placemark", + "spinkit", + "Yandex" ], "ignorePaths": [".github/workflows/**"] } diff --git a/README.md b/README.md index 185eddc..7107277 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,11 @@ -# Papa Burger +# Yandex Food Delivery Clone -Yandex food delivery app clone. +## 💫 About The Project -## Getting Started +[![Github-repository-preview.png](https://i.postimg.cc/JnDCG5Q6/Papa-Burger-food-delivery-app-Preview.png)] -This project is built using Flutter with Dart programming language. It has over -10 screens and a lot of functionals. It uses custom backend server, based on Dart -using Dart Frog package. - -![alt text](https://i.postimg.cc/JnDCG5Q6/Papa-Burger-food-delivery-app-Preview.png) +This project is built using Flutter & Dart. It has over +10 screens. It uses custom backend server, based on Dart using Dart Frog package. This application is used to order food from over than 1000 restaurants, making it easy to investigate favourite food and quickly get it done. diff --git a/lib/isolates.dart b/lib/isolates.dart index 6581800..dc3863e 100644 --- a/lib/isolates.dart +++ b/lib/isolates.dart @@ -9,19 +9,19 @@ import 'package:papa_burger/src/views/pages/main/state/main_bloc.dart'; Future useRestaurantsIsolate() async { final mainBloc = MainBloc(); final localStorage = LocalStorage(); - final recievePort = ReceivePort(); + final receivePort = ReceivePort(); final lat = localStorage.latitude; final lng = localStorage.longitude; try { final isolate = await Isolate.spawn( _getAllRestaurantsIsolate, - [recievePort.sendPort, lat, lng], + [receivePort.sendPort, lat, lng], ); - final response = await recievePort.first as List; + final response = await receivePort.first as List; mainBloc.allRestaurants.addAll(response); isolate.kill(priority: Isolate.immediate); } catch (e) { - recievePort.close(); + receivePort.close(); logE(e); } } diff --git a/lib/src/config/colors/app_colors.dart b/lib/src/config/colors/app_colors.dart new file mode 100644 index 0000000..63e8a7f --- /dev/null +++ b/lib/src/config/colors/app_colors.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; + +/// Defines the color palette for the App UI Kit. +abstract class AppColors { + /// Black + static const Color black = Color(0xFF000000); + + /// The background color. + static const Color background = Color.fromARGB(255, 32, 30, 30); + + /// White + static const Color white = Color(0xFFFFFFFF); + + /// Transparent + static const Color transparent = Color(0x00000000); + + /// The light blue color. + static const Color lightBlue = Color.fromARGB(255, 100, 181, 246); + + /// The blue primary color and swatch. + static const Color blue = Color(0xFF3898EC); + + /// The deep blue color. + static const Color deepBlue = Color(0xff337eff); + + /// The border outline color. + static const Color borderOutline = Color.fromARGB(45, 250, 250, 250); + + /// Light dark. + static const Color lightDark = Color.fromARGB(164, 120, 119, 119); + + /// Dark. + static const Color dark = Color.fromARGB(255, 58, 58, 58); + + /// Primary dark blue color. + static const Color primaryDarkBlue = Color(0xff1c1e22); + + /// Grey. + static const Color grey = Colors.grey; + + /// The bright grey color. + static const Color brightGrey = Color.fromARGB(255, 224, 224, 224); + + /// The dark grey color. + static const Color darkGrey = Color.fromARGB(255, 66, 66, 66); + + /// The emphasize grey color. + static const Color emphasizeGrey = Color.fromARGB(255, 97, 97, 97); + + /// The emphasize dark grey color. + static const Color emphasizeDarkGrey = Color.fromARGB(255, 40, 37, 37); + + /// Red material color. + static const MaterialColor red = Colors.red; +} diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart index 928e3b5..3e56007 100644 --- a/lib/src/config/config.dart +++ b/lib/src/config/config.dart @@ -4,5 +4,4 @@ export 'extensions/extensions.dart'; export 'logger.dart'; export 'routes/routes.dart'; export 'theme/app_theme.dart'; -export 'typedefs.dart'; export 'utils/utils.dart'; diff --git a/lib/src/config/extensions/build_context_extension.dart b/lib/src/config/extensions/build_context_extension.dart index 30b80a6..0b709af 100644 --- a/lib/src/config/extensions/build_context_extension.dart +++ b/lib/src/config/extensions/build_context_extension.dart @@ -1,59 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:papa_burger/src/config/colors/app_colors.dart'; +import 'package:papa_burger/src/config/extensions/extensions.dart'; /// Provides values of current device screen `width` and `height` by provided /// context. extension BuildContextX on BuildContext { - /// Returns [ThemeData] from [Theme.of]. - ThemeData get theme => Theme.of(this); - - /// Returns [TextTheme] from [Theme.of] - TextTheme get textTheme => theme.textTheme; - - /// Material body large text style. - TextStyle? get bodyLarge => textTheme.bodyLarge; - - /// Material body medium text style. - TextStyle? get bodyMedium => textTheme.bodyMedium; - - /// Material body small text style. - TextStyle? get bodySmall => textTheme.bodySmall; - - /// Material display large text style. - TextStyle? get displayLarge => textTheme.displayLarge; - - /// Material display medium text style. - TextStyle? get displayMedium => textTheme.displayMedium; - - /// Material display small text style. - TextStyle? get displaySmall => textTheme.displaySmall; - - /// Material headline large text style. - TextStyle? get headlineLarge => textTheme.headlineLarge; - - /// Material headline medium text style. - TextStyle? get headlineMedium => textTheme.headlineMedium; - - /// Material headline small text style. - TextStyle? get headlineSmall => textTheme.headlineSmall; - - /// Material label large text style. - TextStyle? get labelLarge => textTheme.labelLarge; - - /// Material label medium text style. - TextStyle? get labelMedium => textTheme.labelMedium; - - /// Material label small text style. - TextStyle? get labelSmall => textTheme.labelSmall; - - /// Material title large text style. - TextStyle? get titleLarge => textTheme.titleLarge; - - /// Material title medium text style. - TextStyle? get titleMedium => textTheme.titleMedium; - - /// Material title small text style. - TextStyle? get titleSmall => textTheme.titleSmall; - /// Defines current theme [Brightness]. Brightness get brightness => theme.brightness; @@ -64,21 +15,21 @@ extension BuildContextX on BuildContext { bool get isDark => !isLight; /// Defines an adaptive [Color], depending on current theme brightness. - Color get adaptiveColor => isDark ? Colors.white : Colors.black; + Color get adaptiveColor => isDark ? AppColors.white : AppColors.black; /// Defines a reversed adaptive [Color], depending on current theme /// brightness. - Color get reversedAdaptiveColor => isDark ? Colors.black : Colors.white; + Color get reversedAdaptiveColor => isDark ? AppColors.black : AppColors.white; - /// Defines a customisable adaptive [Color]. If [light] or [dark] is not + /// Defines a customizable adaptive [Color]. If [light] or [dark] is not /// provided default colors are used. Color customAdaptiveColor({Color? light, Color? dark}) => - isDark ? (light ?? Colors.white) : (dark ?? Colors.black); + isDark ? (light ?? AppColors.white) : (dark ?? AppColors.black); - /// Defines a customisable reversed adaptive [Color]. If [light] or [dark] + /// Defines a customizable reversed adaptive [Color]. If [light] or [dark] /// is not provided default reversed colors are used. Color customReversedAdaptiveColor({Color? light, Color? dark}) => - isDark ? (dark ?? Colors.black) : (light ?? Colors.white); + isDark ? (dark ?? AppColors.black) : (light ?? AppColors.white); /// Defines [MediaQueryData] based on provided context. Size get size => MediaQuery.sizeOf(this); diff --git a/lib/src/config/extensions/disalow_indicator_extension.dart b/lib/src/config/extensions/disalow_indicator_extension.dart deleted file mode 100644 index 1a2dd56..0000000 --- a/lib/src/config/extensions/disalow_indicator_extension.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/material.dart' - show NotificationListener, OverscrollIndicatorNotification, Widget; - -extension DisalowIndicator on Widget { - Widget disalowIndicator() => - NotificationListener( - onNotification: (overscroll) { - overscroll.disallowIndicator(); - return false; - }, - child: this, - ); -} diff --git a/lib/src/config/extensions/extensions.dart b/lib/src/config/extensions/extensions.dart index 787b7da..66852cf 100644 --- a/lib/src/config/extensions/extensions.dart +++ b/lib/src/config/extensions/extensions.dart @@ -1,9 +1,9 @@ export 'build_context_extension.dart'; export 'connection_state_to_status.dart'; -export 'disalow_indicator_extension.dart'; export 'ignore_pointer_extension.dart'; export 'navigator_extension.dart'; export 'show_bottom_modal_sheet_extension.dart'; export 'snack_bar_extension.dart'; +export 'text_style_extension.dart'; export 'to_upper_case_extension.dart'; export 'trimmed_converted_string_contains_extension.dart'; diff --git a/lib/src/config/extensions/ignore_pointer_extension.dart b/lib/src/config/extensions/ignore_pointer_extension.dart index d574c80..7d6f13a 100644 --- a/lib/src/config/extensions/ignore_pointer_extension.dart +++ b/lib/src/config/extensions/ignore_pointer_extension.dart @@ -1,15 +1,6 @@ -// ignore_for_file: avoid_bool_literals_in_conditional_expressions - import 'package:flutter/material.dart' show IgnorePointer, Widget; -extension IngnorePointerExtension on Widget { +extension IgnorePointerX on Widget { Widget ignorePointer({required bool isMoving, bool isMarker = false}) => - IgnorePointer( - /// If the boolen variable isMarker is true, that means that we use - /// ignore pointer for marker to allow user to move camera through it. - /// Otherwise we just ignoring pointer of any widget of it ancestor - /// when camera is moving in order to prevent random taps on any widgets - ignoring: isMarker ? true : isMoving, - child: this, - ); + IgnorePointer(ignoring: isMarker || isMoving, child: this); } diff --git a/lib/src/config/extensions/navigator_extension.dart b/lib/src/config/extensions/navigator_extension.dart index ba21f2e..355eece 100644 --- a/lib/src/config/extensions/navigator_extension.dart +++ b/lib/src/config/extensions/navigator_extension.dart @@ -48,8 +48,8 @@ extension NavigatorExtension on BuildContext { } } - void pop({bool withHaptickFeedback = false, dynamic result}) { - if (withHaptickFeedback) { + void pop({bool withHapticFeedback = false, dynamic result}) { + if (withHapticFeedback) { HapticFeedback.heavyImpact(); Navigator.pop(this, result); } else { @@ -80,7 +80,7 @@ extension NavigatorExtension on BuildContext { arguments: arguments, ); - void navigateToGoolgeMapView([PlaceDetails? placeDetails]) => + void navigateToGoogleMapView([PlaceDetails? placeDetails]) => Navigator.pushAndRemoveUntil( this, _defaultRoute( @@ -143,14 +143,14 @@ extension NavigatorExtension on BuildContext { void navigateToOrderDetailsView( OrderId orderId, { - GlobalKey? scaffoldMessangerKey, + GlobalKey? scaffoldMessengerKey, }) => Navigator.pushAndRemoveUntil( this, _defaultRoute( child: OrderDetailsView( orderId: orderId, - scaffoldMessengerKey: scaffoldMessangerKey, + scaffoldMessengerKey: scaffoldMessengerKey, ), ), (route) => true, diff --git a/lib/src/config/extensions/show_bottom_modal_sheet_extension.dart b/lib/src/config/extensions/show_bottom_modal_sheet_extension.dart index 5a3c766..6b08bd9 100644 --- a/lib/src/config/extensions/show_bottom_modal_sheet_extension.dart +++ b/lib/src/config/extensions/show_bottom_modal_sheet_extension.dart @@ -61,7 +61,7 @@ extension BottomModalSheetExtension on BuildContext { ), ), ], - ).disalowIndicator(), + ), bottomNavigationBar: IncreaseDecreaseQuantityBottomAppBar( item: item, quantity: ValueNotifier(1), @@ -107,7 +107,7 @@ extension BottomModalSheetExtension on BuildContext { ? CustomScrollView( controller: scrollController, slivers: children!, - ).disalowIndicator() + ) : Column( mainAxisSize: MainAxisSize.min, children: children!, diff --git a/lib/src/config/extensions/snack_bar_extension.dart b/lib/src/config/extensions/snack_bar_extension.dart index 31b28c7..a92d633 100644 --- a/lib/src/config/extensions/snack_bar_extension.dart +++ b/lib/src/config/extensions/snack_bar_extension.dart @@ -35,7 +35,7 @@ extension SnackBarExtension on BuildContext { ), ); - void showUndismissibleSnackBar( + void showUndismissableSnackBar( String text, { String? solution, Color color = Colors.white, diff --git a/lib/src/config/extensions/text_style_extension.dart b/lib/src/config/extensions/text_style_extension.dart new file mode 100644 index 0000000..8efbe6d --- /dev/null +++ b/lib/src/config/extensions/text_style_extension.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; + +/// {@template text_style_extension} +/// TextStyle extension that provides access to [ThemeData] and [TextTheme]. +/// {@endtemplate} +extension TextStyleExtension on BuildContext { + /// Returns [ThemeData] from [Theme.of]. + ThemeData get theme => Theme.of(this); + + /// Returns [TextTheme] from [Theme.of] + TextTheme get textTheme => theme.textTheme; + + /// Material body large text style. + TextStyle? get bodyLarge => textTheme.bodyLarge; + + /// Material body medium text style. + TextStyle? get bodyMedium => textTheme.bodyMedium; + + /// Material body small text style. + TextStyle? get bodySmall => textTheme.bodySmall; + + /// Material display large text style. + TextStyle? get displayLarge => textTheme.displayLarge; + + /// Material display medium text style. + TextStyle? get displayMedium => textTheme.displayMedium; + + /// Material display small text style. + TextStyle? get displaySmall => textTheme.displaySmall; + + /// Material headline large text style. + TextStyle? get headlineLarge => textTheme.headlineLarge; + + /// Material headline medium text style. + TextStyle? get headlineMedium => textTheme.headlineMedium; + + /// Material headline small text style. + TextStyle? get headlineSmall => textTheme.headlineSmall; + + /// Material label large text style. + TextStyle? get labelLarge => textTheme.labelLarge; + + /// Material label medium text style. + TextStyle? get labelMedium => textTheme.labelMedium; + + /// Material label small text style. + TextStyle? get labelSmall => textTheme.labelSmall; + + /// Material title large text style. + TextStyle? get titleLarge => textTheme.titleLarge; + + /// Material title medium text style. + TextStyle? get titleMedium => textTheme.titleMedium; + + /// Material title small text style. + TextStyle? get titleSmall => textTheme.titleSmall; +} diff --git a/lib/src/config/logger.dart b/lib/src/config/logger.dart index d56566c..fbd97ed 100644 --- a/lib/src/config/logger.dart +++ b/lib/src/config/logger.dart @@ -19,7 +19,7 @@ void logE( /// Log warning that used for printing warning/important messages /// to pay developer attention on it, rather than -/// using logI method, because it can be more noticable. +/// using logI method. void logW( dynamic message, { DateTime? time, diff --git a/lib/src/config/typedefs.dart b/lib/src/config/typedefs.dart deleted file mode 100644 index e829647..0000000 --- a/lib/src/config/typedefs.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:flutter/material.dart' show BuildContext, Widget; - -typedef Separator = Widget Function(BuildContext context, int index); diff --git a/lib/src/config/utils/app_constants.dart b/lib/src/config/utils/app_constants.dart index 5a9895d..e205882 100644 --- a/lib/src/config/utils/app_constants.dart +++ b/lib/src/config/utils/app_constants.dart @@ -20,17 +20,10 @@ import 'package:papa_burger/src/config/config.dart'; const double kDefaultHorizontalPadding = 12; const double kDefaultVerticalPadding = 12; -const double kDefaultSizedboxW = 12; -const double kDefaultSizedboxH = 12; - -const double kDefaultVerticalSpacingBetweenParagraphs = 24; -const double kDefaultVerticalSpacingBetweenContent = 12; -const double kDefaultVerticalSpacingBetweenSections = 12; - const double kDefaultBorderRadius = 16; const double kDefaultSearchBarRadius = 24; -const almatyCenterPosititon = LatLng(43.2364, 76.9185); +const almatyCenterPosition = LatLng(43.2364, 76.9185); const defaultTimeout = Duration(seconds: 10); diff --git a/lib/src/config/utils/app_routes.dart b/lib/src/config/utils/app_routes.dart index 44999ec..b667fb0 100644 --- a/lib/src/config/utils/app_routes.dart +++ b/lib/src/config/utils/app_routes.dart @@ -36,7 +36,7 @@ class AppRoutes { static const searchPage = SearchView(); static const registerPage = RegisterView(); static const notificationsPage = NotificationsView(); - static OrdersVieww ordersPage = OrdersVieww(); + static final ordersPage = OrdersView(); } class HomePage extends StatelessWidget { diff --git a/lib/src/models/auto_complete.dart b/lib/src/models/auto_complete.dart index d93fe5a..97790ac 100644 --- a/lib/src/models/auto_complete.dart +++ b/lib/src/models/auto_complete.dart @@ -8,7 +8,7 @@ class AutoComplete { required this.description, required this.placeId, required this.reference, - required this.structuredFormating, + required this.structuredFormatting, required this.terms, required this.types, required this.matchedSubstrings, @@ -18,7 +18,7 @@ class AutoComplete { description: json['description'] as String, placeId: json['place_id'] as String, reference: json['reference'] as String, - structuredFormating: StructuredFormating.fromJson( + structuredFormatting: StructuredFormatting.fromJson( json['structured_formatting'] as Map, ), terms: json['terms'] != null @@ -45,7 +45,7 @@ class AutoComplete { description: '', placeId: '', reference: '', - structuredFormating: StructuredFormating.empty(), + structuredFormatting: StructuredFormatting.empty(), terms: const [], types: const [], matchedSubstrings: const [], @@ -54,7 +54,7 @@ class AutoComplete { final String description; final String placeId; final String reference; - final StructuredFormating structuredFormating; + final StructuredFormatting structuredFormatting; final List terms; final List types; final List matchedSubstrings; @@ -64,7 +64,7 @@ class AutoComplete { 'description': description, 'placeId': placeId, 'reference': reference, - 'structuredFormating': structuredFormating.toMap(), + 'structuredFormatting': structuredFormatting.toMap(), 'terms': terms.map((x) => x.toMap()).toList(), 'types': types, 'matchedSubstrings': matchedSubstrings.map((x) => x.toMap()).toList(), @@ -75,15 +75,15 @@ class AutoComplete { } @immutable -class StructuredFormating { - const StructuredFormating({ +class StructuredFormatting { + const StructuredFormatting({ required this.mainText, required this.secondaryText, required this.mainTextMatchedSubstrings, }); - factory StructuredFormating.fromJson(Map json) => - StructuredFormating( + factory StructuredFormatting.fromJson(Map json) => + StructuredFormatting( mainText: json['main_text'] as String, secondaryText: json['secondary_text'] as String, mainTextMatchedSubstrings: json['main_text_matched_substrings'] != null @@ -97,8 +97,8 @@ class StructuredFormating { : [], ); - factory StructuredFormating.empty() { - return const StructuredFormating( + factory StructuredFormatting.empty() { + return const StructuredFormatting( mainText: '', secondaryText: '', mainTextMatchedSubstrings: [], diff --git a/lib/src/models/cart.dart b/lib/src/models/cart.dart index 2929354..09e6163 100644 --- a/lib/src/models/cart.dart +++ b/lib/src/models/cart.dart @@ -50,9 +50,9 @@ class Cart extends Equatable { return total; } - int get getDeliveryFee => subTotalgreaterThanMinimumPrice ? 0 : deliveryFee; + int get getDeliveryFee => subTotalGreaterMinPrice ? 0 : deliveryFee; - bool get subTotalgreaterThanMinimumPrice => _subTotal() > _minimumSubTotal; + bool get subTotalGreaterMinPrice => _subTotal() > _minimumSubTotal; double totalWithDeliveryFee() { if (getDeliveryFee == 0) { @@ -66,7 +66,7 @@ class Cart extends Equatable { return '$deliveryFee\$'; } - String totalSumm() => '${totalWithDeliveryFee().toStringAsFixed(2)}$currency'; + String totalSum() => '${totalWithDeliveryFee().toStringAsFixed(2)}$currency'; String totalRound() => '${totalWithDeliveryFee().round()}'; diff --git a/lib/src/models/exceptions.dart b/lib/src/models/exceptions.dart index 344968a..e32f5b2 100644 --- a/lib/src/models/exceptions.dart +++ b/lib/src/models/exceptions.dart @@ -9,7 +9,7 @@ abstract class ExceptionMessage implements Exception { final String message; } -/// Assosiated exception for create credit card invalid credentials +/// Associated exception for create credit card invalid credentials class NoSuchRestaurantException implements ExceptionMessage { /// {@macro credit_card_invalid_credentials_exception} NoSuchRestaurantException(this.error); @@ -20,7 +20,7 @@ class NoSuchRestaurantException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for create credit card invalid credentials +/// Associated exception for create credit card invalid credentials class NetworkException implements ExceptionMessage { /// {@macro credit_card_invalid_credentials_exception} NetworkException(this.error); @@ -31,7 +31,7 @@ class NetworkException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for create credit card invalid credentials +/// Associated exception for create credit card invalid credentials class CreditCardInvalidCredentialsException implements ExceptionMessage { /// {@macro credit_card_invalid_credentials_exception} CreditCardInvalidCredentialsException(this.error); @@ -42,7 +42,7 @@ class CreditCardInvalidCredentialsException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for create credit card invalid credentials +/// Associated exception for create credit card invalid credentials class CreditCardAlreadyExistsException implements ExceptionMessage { /// {@macro credit_card_already_exists_exception} const CreditCardAlreadyExistsException(this.error); @@ -53,7 +53,7 @@ class CreditCardAlreadyExistsException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for credit cards not found +/// Associated exception for credit cards not found class CreditCardsNotFoundException implements ExceptionMessage { /// {@macro credit_cards_not_found_exception} const CreditCardsNotFoundException(this.error); @@ -64,7 +64,7 @@ class CreditCardsNotFoundException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for credit card not found +/// Associated exception for credit card not found class CreditCardNotFoundException implements ExceptionMessage { /// {@macro credit_card_not_found_exception} const CreditCardNotFoundException(this.error); @@ -75,7 +75,7 @@ class CreditCardNotFoundException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class InvalidUserIdException implements ExceptionMessage { /// {@macro invalid_user_id_exception} const InvalidUserIdException(this.error); @@ -86,7 +86,7 @@ class InvalidUserIdException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class ClientRequestFailed implements ExceptionMessage { /// {@macro invalid_user_id_exception} const ClientRequestFailed({required this.body, this.statusCode}); @@ -98,7 +98,7 @@ class ClientRequestFailed implements ExceptionMessage { String get message => body['error'] as String; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class MalformedClientResponse implements ExceptionMessage { /// {@macro invalid_user_id_exception} const MalformedClientResponse(this.error); @@ -109,7 +109,7 @@ class MalformedClientResponse implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class ClientTimeoutException implements ExceptionMessage { /// {@macro client_timeout_exception} const ClientTimeoutException( @@ -124,7 +124,7 @@ class ClientTimeoutException implements ExceptionMessage { String get message => error ?? 'Client ran out of time.'; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class OrderDetailsNotFoundException implements ExceptionMessage { /// {@macro order_details_not_found_exception} const OrderDetailsNotFoundException(this.error); @@ -135,7 +135,7 @@ class OrderDetailsNotFoundException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class InvalidAddMenuItemsParametersException implements ExceptionMessage { /// {@macro invalid_add_menu_items_parameters_exception} const InvalidAddMenuItemsParametersException(this.error); @@ -146,7 +146,7 @@ class InvalidAddMenuItemsParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class InvalidCreateUserOrderParametersException implements ExceptionMessage { /// {@macro invalid_user_order_parameters_exception} const InvalidCreateUserOrderParametersException(this.error); @@ -157,7 +157,7 @@ class InvalidCreateUserOrderParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class InvalidUpdateUserOrderParametersException implements ExceptionMessage { /// {@macro invalid_update_user_order_parameters_exception} const InvalidUpdateUserOrderParametersException(this.error); @@ -168,7 +168,7 @@ class InvalidUpdateUserOrderParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class AddRestaurantInvalidParametersException implements ExceptionMessage { /// {@macro add_restaurant_invalid_parameters_exception} const AddRestaurantInvalidParametersException(this.error); @@ -179,7 +179,7 @@ class AddRestaurantInvalidParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class UpdateRestaurantInvalidParametersException implements ExceptionMessage { /// {@macro update_restaurant_invalid_parameters_exception} const UpdateRestaurantInvalidParametersException(this.error); @@ -190,7 +190,7 @@ class UpdateRestaurantInvalidParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class DeleteRestaurantInvalidParametersException implements ExceptionMessage { /// {@macro delete_restaurant_invalid_parameters_exception} const DeleteRestaurantInvalidParametersException(this.error); @@ -201,7 +201,7 @@ class DeleteRestaurantInvalidParametersException implements ExceptionMessage { String get message => error; } -/// Assosiated exception for invalid user id +/// Associated exception for invalid user id class NoRestaurantsFoundException implements ExceptionMessage { /// {@macro no_restaurants_found_exception} const NoRestaurantsFoundException(this.error); diff --git a/lib/src/models/form_fields/email.dart b/lib/src/models/form_fields/email.dart index 14bd3d5..7cc1724 100644 --- a/lib/src/models/form_fields/email.dart +++ b/lib/src/models/form_fields/email.dart @@ -1,19 +1,19 @@ import 'package:equatable/equatable.dart' show EquatableMixin; import 'package:flutter/foundation.dart' show immutable; -import 'package:formz/formz.dart' show FormzInput; +import 'package:formz/formz.dart'; +import 'package:papa_burger/src/models/form_fields/formz_validation_mixin.dart'; +/// {@template email} +/// Formz input for email. It can be empty or invalid. +/// {@endtemplate} @immutable class Email extends FormzInput - with EquatableMixin { - const Email.unvalidated([ - super.value = '', - ]) : isAlreadyRegistered = false, - super.pure(); + with EquatableMixin, FormzValidationMixin { + /// {@macro email.pure} + const Email.pure([super.value = '']) : super.pure(); - const Email.validated( - super.value, { - this.isAlreadyRegistered = false, - }) : super.dirty(); + /// {@macro email.dirty} + const Email.dirty(super.value) : super.dirty(); static final _emailRegex = RegExp( r'^(([\w-]+\.)+[\w-]+|([a-zA-Z]|[\w-]{2,}))@((([0-1]?' @@ -22,29 +22,31 @@ class Email extends FormzInput r')|([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$', ); - final bool isAlreadyRegistered; - @override EmailValidationError? validator(String value) { - return value.isEmpty - ? EmailValidationError.empty - : (isAlreadyRegistered - ? EmailValidationError.alreadyRegistered - : (_emailRegex.hasMatch(value) - ? null - : EmailValidationError.invalid)); + if (value.isEmpty) return EmailValidationError.empty; + if (!_emailRegex.hasMatch(value)) return EmailValidationError.invalid; + return null; } + /// Email validation errors message + @override + Map get validationErrorMessage => { + EmailValidationError.empty: 'This field is required', + EmailValidationError.invalid: 'Email is not correct', + null: null, + }; + @override - List get props => [ - value, - isAlreadyRegistered, - pure, - ]; + List get props => [pure, value]; } +/// Validation errors for [Email]. It can be empty, invalid or already +/// registered. enum EmailValidationError { + /// Empty email. empty, + + /// Invalid email. invalid, - alreadyRegistered, } diff --git a/lib/src/models/form_fields/form_fileds.dart b/lib/src/models/form_fields/form_fileds.dart index a43add1..75eac05 100644 --- a/lib/src/models/form_fields/form_fileds.dart +++ b/lib/src/models/form_fields/form_fileds.dart @@ -1,6 +1,3 @@ export 'email.dart'; -export 'optional_password.dart'; -export 'optional_password_confirmation.dart'; export 'password.dart'; -export 'password_confirmation.dart'; export 'username.dart'; diff --git a/lib/src/models/form_fields/formz_validation_mixin.dart b/lib/src/models/form_fields/formz_validation_mixin.dart new file mode 100644 index 0000000..ee34bbc --- /dev/null +++ b/lib/src/models/form_fields/formz_validation_mixin.dart @@ -0,0 +1,20 @@ +import 'package:formz/formz.dart'; + +/// Mixin on [FormzInput] that provides common functionality for form input +/// fields. +/// +/// It has: +/// - [validationError] getter that returns a validation error if input is +/// invalid +/// - [errorMessage] getter that returns an error message based on [E] +/// - [validationErrorMessage] map that contains error messages for each [E] +mixin FormzValidationMixin on FormzInput { + /// Returns the validation error if the input is invalid. + E? get validationError => invalid ? error : null; + + /// Returns email error text based on [E]. + String? get errorMessage => validationErrorMessage[validationError]; + + /// Email validation errors message + Map get validationErrorMessage; +} diff --git a/lib/src/models/form_fields/optional_password.dart b/lib/src/models/form_fields/optional_password.dart deleted file mode 100644 index 4bc6b76..0000000 --- a/lib/src/models/form_fields/optional_password.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/foundation.dart' show immutable; -import 'package:formz/formz.dart' show FormzInput; - -@immutable -class OptionalPassword - extends FormzInput { - const OptionalPassword.unvalidated([ - super.value = '', - ]) : super.pure(); - - const OptionalPassword.validated([ - super.value = '', - ]) : super.dirty(); - - @override - OptionalPasswordValidationError? validator(String value) { - return value.isEmpty - ? null - : (value.length >= 5 && value.length <= 120 - ? null - : OptionalPasswordValidationError.invalid); - } -} - -enum OptionalPasswordValidationError { - invalid, -} diff --git a/lib/src/models/form_fields/optional_password_confirmation.dart b/lib/src/models/form_fields/optional_password_confirmation.dart deleted file mode 100644 index efc8006..0000000 --- a/lib/src/models/form_fields/optional_password_confirmation.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:equatable/equatable.dart' show EquatableMixin; -import 'package:flutter/foundation.dart' show immutable; -import 'package:formz/formz.dart' show FormzInput; -import 'package:papa_burger/src/models/models.dart'; - -@immutable -class OptionalPasswordConfirmation - extends FormzInput - with EquatableMixin { - const OptionalPasswordConfirmation.unvalidated([ - super.value = '', - ]) : password = const OptionalPassword.unvalidated(), - super.pure(); - - const OptionalPasswordConfirmation.validated( - super.value, { - required this.password, - }) : super.dirty(); - - final OptionalPassword password; - - @override - OptionalPasswordConfirmationValidationError? validator(String value) { - return value.isEmpty - ? (password.value.isEmpty - ? null - : OptionalPasswordConfirmationValidationError.empty) - : (value == password.value - ? null - : OptionalPasswordConfirmationValidationError.invalid); - } - - @override - List get props => [value, password, pure]; -} - -enum OptionalPasswordConfirmationValidationError { - empty, - invalid, -} diff --git a/lib/src/models/form_fields/password.dart b/lib/src/models/form_fields/password.dart index 7371d82..703b20a 100644 --- a/lib/src/models/form_fields/password.dart +++ b/lib/src/models/form_fields/password.dart @@ -1,13 +1,20 @@ +import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart' show immutable; import 'package:formz/formz.dart' show FormzInput; +import 'package:papa_burger/src/models/form_fields/formz_validation_mixin.dart'; +/// {@template password} +/// Form input for a password. It extends [FormzInput] and uses +/// [PasswordValidationError] for its validation errors. +/// {@endtemplate} @immutable -class Password extends FormzInput { - const Password.unvalidated([ - super.value = '', - ]) : super.pure(); +class Password extends FormzInput + with EquatableMixin, FormzValidationMixin { + /// {@macro password.pure} + const Password.pure([super.value = '']) : super.pure(); - const Password.validated([ + /// {@macro password.dirty} + const Password.dirty([ super.value = '', ]) : super.dirty(); @@ -15,15 +22,30 @@ class Password extends FormzInput { PasswordValidationError? validator(String value) { if (value.isEmpty) { return PasswordValidationError.empty; - } else if (value.length < 5 || value.length > 120) { + } else if (value.length < 6 || value.length > 120) { return PasswordValidationError.invalid; } else { return null; } } + + @override + Map get validationErrorMessage => { + PasswordValidationError.empty: 'This field is required', + PasswordValidationError.invalid: + 'Password should contain at least 6 characters', + null: null, + }; + + @override + List get props => [value, pure]; } +/// Validation errors for [Password]. It can be empty or invalid. enum PasswordValidationError { + /// Empty password. empty, + + /// Invalid password. invalid, } diff --git a/lib/src/models/form_fields/password_confirmation.dart b/lib/src/models/form_fields/password_confirmation.dart deleted file mode 100644 index 6a804ce..0000000 --- a/lib/src/models/form_fields/password_confirmation.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:equatable/equatable.dart' show EquatableMixin; -import 'package:flutter/foundation.dart' show immutable; -import 'package:formz/formz.dart' show FormzInput; -import 'package:papa_burger/src/models/models.dart'; - -@immutable -class PasswordConfirmation - extends FormzInput - with EquatableMixin { - const PasswordConfirmation.unvalidated([ - super.value = '', - ]) : password = const Password.unvalidated(), - super.pure(); - - const PasswordConfirmation.validated( - super.value, { - required this.password, - }) : super.dirty(); - - final Password password; - - @override - PasswordConfirmationValidationError? validator(String value) { - return value.isEmpty - ? PasswordConfirmationValidationError.empty - : (value == password.value - ? null - : PasswordConfirmationValidationError.invalid); - } - - @override - List get props => [value, password, pure]; -} - -enum PasswordConfirmationValidationError { - empty, - invalid, -} diff --git a/lib/src/models/form_fields/username.dart b/lib/src/models/form_fields/username.dart index b4b54bb..62f5169 100644 --- a/lib/src/models/form_fields/username.dart +++ b/lib/src/models/form_fields/username.dart @@ -1,43 +1,48 @@ import 'package:equatable/equatable.dart' show EquatableMixin; import 'package:flutter/foundation.dart' show immutable; import 'package:formz/formz.dart' show FormzInput; +import 'package:papa_burger/src/models/form_fields/formz_validation_mixin.dart'; +/// {@template name} +/// Form input for a name. It extends [FormzInput] and uses +/// [UsernameValidationError] for its validation errors. +/// {@endtemplate} @immutable class Username extends FormzInput - with EquatableMixin { - const Username.unvalidated([ - super.value = '', - ]) : isAlreadyRegistered = false, - super.pure(); + with EquatableMixin, FormzValidationMixin { + /// {@macro name.pure} + const Username.pure([super.value = '']) : super.pure(); - const Username.validated( - super.value, { - this.isAlreadyRegistered = false, - }) : super.dirty(); + /// {@macro name.dirty} + const Username.dirty(super.value) : super.dirty(); - static final _usernameRegex = RegExp( - r'^(?=.{1,20}$)(?![_])(?!.*[_.]{2})[a-zA-Z0-9_]+(? get props => [value, isAlreadyRegistered, pure]; + Map get validationErrorMessage => { + UsernameValidationError.empty: 'This field is required', + UsernameValidationError.invalid: + 'Username must be between 3 and 16 characters. Also, it can only ' + 'contain letters, numbers, periods, and underscores.', + null: null, + }; + + @override + List get props => [value, pure]; } +/// Validation errors for [Username]. It can be empty or invalid. enum UsernameValidationError { + /// Empty name. empty, + + /// Invalid name. invalid, - alreadyTaken, } diff --git a/lib/src/models/menu_model.dart b/lib/src/models/menu_model.dart index 3309b46..8ccc890 100644 --- a/lib/src/models/menu_model.dart +++ b/lib/src/models/menu_model.dart @@ -10,10 +10,10 @@ class MenuModel { }); final Restaurant restaurant; - List getDiscounts(List restaunrantMenu) { + List getDiscounts(List restaurantMenu) { final allDiscounts = {}; - for (final menu in restaunrantMenu) { + for (final menu in restaurantMenu) { for (final item in menu.items) { assert( item.discount <= 100, diff --git a/lib/src/models/menu_tab_category.dart b/lib/src/models/menu_tab_category.dart index f5b21bc..45898bf 100644 --- a/lib/src/models/menu_tab_category.dart +++ b/lib/src/models/menu_tab_category.dart @@ -29,8 +29,7 @@ class MenuBloc with ChangeNotifier { Stream> get getMenus async* { try { final apiClient = server.ApiClient(); - final dbmenus = await apiClient.getRestaurantMenu(_restaurant.placeId); - final menus$ = dbmenus + final menus$ = (await apiClient.getRestaurantMenu(_restaurant.placeId)) .map( (e) => Menu( category: e.category, @@ -48,9 +47,8 @@ class MenuBloc with ChangeNotifier { .toList(); menus = menus$; yield menus$; - } catch (e) { - logE(e); - + } catch (error, stackTrace) { + logE('Failed to get menus.', error: error, stackTrace: stackTrace); yield []; } } @@ -161,7 +159,7 @@ class MenuBloc with ChangeNotifier { for (int i = 0; i < tabs.value.length; i++) { final tab = tabs.value[i]; - /// 240 is a value that substracts from offsetFrom to make tab category + /// 240 is a value that subtracts from offsetFrom to make tab category /// selection a bit more desired if (scrollController.offset >= tab.offsetFrom - 240 && scrollController.offset <= tab.offsetTo && diff --git a/lib/src/models/order_details.dart b/lib/src/models/order_details.dart index 0b7fc0d..024e99a 100644 --- a/lib/src/models/order_details.dart +++ b/lib/src/models/order_details.dart @@ -15,35 +15,35 @@ class OrderDetails { required this.restaurantName, required this.orderAddress, required this.orderMenuItems, - required this.totalOrderSumm, + required this.totalOrderSum, required this.orderDeliveryFee, }); - /// Assosiate order details id identifier + /// Associated order details id identifier final String id; - /// Assosiated order details status + /// Associated order details status final String status; - /// Assosiated order details date + /// Associated order details date final String date; - /// Assosiated order details restaurant place id + /// Associated order details restaurant place id final String restaurantPlaceId; - /// Assosiated order details restaurant name + /// Associated order details restaurant name final String restaurantName; - /// Assosiated order details order address + /// Associated order details order address final String orderAddress; - /// Assosiated order details order menu items + /// Associated order details order menu items final List orderMenuItems; - /// Assosisated order details total order summ - final double totalOrderSumm; + /// Assosisated order details total order sum + final double totalOrderSum; - /// Assosiated order details order deilvery fee + /// Associated order details order delivery fee final double orderDeliveryFee; Map toMap() { @@ -55,7 +55,7 @@ class OrderDetails { 'restaurant_name': restaurantName, 'order_address': orderAddress, 'order_menu_items': orderMenuItems.map((x) => x.toMap()).toList(), - 'total_order_summ': totalOrderSumm, + 'total_order_sum': totalOrderSum, 'order_delivery_fee': orderDeliveryFee, }; } @@ -73,7 +73,7 @@ class OrderDetails { (x) => OrderMenuItem.fromMap(x as Map), ), ), - totalOrderSumm: map['total_order_summ'] as double, + totalOrderSum: map['total_order_sum'] as double, orderDeliveryFee: map['order_delivery_fee'] as double, ); } @@ -89,7 +89,7 @@ class OrderDetails { orderMenuItems: orderDetails.orderMenuItems .map(OrderMenuItem.fromDB) .toList(), - totalOrderSumm: orderDetails.totalOrderSumm, + totalOrderSum: orderDetails.totalOrderSumm, orderDeliveryFee: orderDetails.orderDeliveryFee, ); } diff --git a/lib/src/models/order_menu_item.dart b/lib/src/models/order_menu_item.dart index 20ec0d2..732053b 100644 --- a/lib/src/models/order_menu_item.dart +++ b/lib/src/models/order_menu_item.dart @@ -14,19 +14,19 @@ class OrderMenuItem { required this.imageUrl, }); - /// Assosiated order menu items item's id identifier + /// Associated order menu items item's id identifier final int id; - /// Assosiated order menu items item's name + /// Associated order menu items item's name final String name; - /// Assosisated order menu items item's quanityt + /// Assosisated order menu items item's quantity final int quantity; - /// Assosiated order menu items item's price + /// Associated order menu items item's price final double price; - /// Assosiated order menu items item's image url + /// Associated order menu items item's image url final String imageUrl; Map toMap() { diff --git a/lib/src/models/restaurants_page.dart b/lib/src/models/restaurants_page.dart index 61f061c..684ffdb 100644 --- a/lib/src/models/restaurants_page.dart +++ b/lib/src/models/restaurants_page.dart @@ -30,7 +30,7 @@ class RestaurantsPage { static final Map _errorMessages = { 'zero results': Message( title: 'No restaurants :(', - solution: 'Try to change your current addres.', + solution: 'Try to change your current address.', ), 'unknown error': Message( title: 'Something went wrong!', diff --git a/lib/src/services/network/api/location_api.dart b/lib/src/services/network/api/location_api.dart index 47ec136..d775b80 100644 --- a/lib/src/services/network/api/location_api.dart +++ b/lib/src/services/network/api/location_api.dart @@ -35,7 +35,6 @@ class LocationApi { return Future.error('Location Permission has been denied'); } } - logW('DETERMING CURRENT POSITION'); return _getCurrentPosition(); } diff --git a/lib/src/services/network/api/orders_api.dart b/lib/src/services/network/api/orders_api.dart index 3e69ce0..52c7e41 100644 --- a/lib/src/services/network/api/orders_api.dart +++ b/lib/src/services/network/api/orders_api.dart @@ -41,7 +41,7 @@ class OrdersApi implements BaseOrdersRepository { required String restaurantPlaceId, required String restaurantName, required String orderAddress, - required String totalOrderSumm, + required String totalOrderSum, required String orderDeliveryFee, }) async { try { @@ -53,7 +53,7 @@ class OrdersApi implements BaseOrdersRepository { restaurantPlaceId: restaurantPlaceId, restaurantName: restaurantName, orderAddress: orderAddress, - totalOrderSumm: totalOrderSumm, + totalOrderSum: totalOrderSum, orderDeliveryFee: orderDeliveryFee, ) .timeout(defaultTimeout); @@ -127,7 +127,7 @@ class OrdersApi implements BaseOrdersRepository { String? restaurantPlaceId, String? restaurantName, String? orderAddress, - String? totalOrderSumm, + String? totalOrderSum, String? orderDeliveryFee, }) async { try { @@ -140,7 +140,7 @@ class OrdersApi implements BaseOrdersRepository { restaurantPlaceId: restaurantPlaceId, restaurantName: restaurantName, orderAddress: orderAddress, - totalOrderSumm: totalOrderSumm, + totalOrderSum: totalOrderSum, orderDeliveryFee: orderDeliveryFee, ) .timeout(defaultTimeout); diff --git a/lib/src/services/network/api/url_builder.dart b/lib/src/services/network/api/url_builder.dart index 7ff8bdf..a285465 100644 --- a/lib/src/services/network/api/url_builder.dart +++ b/lib/src/services/network/api/url_builder.dart @@ -7,7 +7,7 @@ class UrlBuilder { 'https://maps.googleapis.com/maps/api/place/autocomplete/json'; static const String placeDetailsUrl = 'https://maps.googleapis.com/maps/api/place/details/json'; - static const String geocedeUrl = + static const String geocodeUrl = 'https://maps.googleapis.com/maps/api/geocode/json'; static const String apiKey = googleApiKey; @@ -20,6 +20,6 @@ class UrlBuilder { } String buildGeocoderUrl({required double lat, required double lng}) { - return '$geocedeUrl?latlng=$lat,$lng&key=$apiKey'; + return '$geocodeUrl?latlng=$lat,$lng&key=$apiKey'; } } diff --git a/lib/src/services/network/api/user_api.dart b/lib/src/services/network/api/user_api.dart index 9beff8c..402b27d 100644 --- a/lib/src/services/network/api/user_api.dart +++ b/lib/src/services/network/api/user_api.dart @@ -25,7 +25,7 @@ class UserApi implements BaseUserRepository { String name, String email, String password, { - String profilePitcture = '', + String profilePicture = '', }) async { try { final user = await _apiClient @@ -33,7 +33,7 @@ class UserApi implements BaseUserRepository { name, email, password, - profilePicture: profilePitcture, + profilePicture: profilePicture, ) .timeout(defaultTimeout); return User.fromDb(user!); diff --git a/lib/src/services/network/notification_service.dart b/lib/src/services/network/notification_service.dart index a2b97a3..9e9a2ae 100644 --- a/lib/src/services/network/notification_service.dart +++ b/lib/src/services/network/notification_service.dart @@ -86,18 +86,18 @@ class NotificationService { ) async { final id = await showOngoingNotification( title: 'Papa Burger', - body: 'Your order №$orderId has been successfuly formed! ' + body: 'Your order №$orderId has been successfully formed! ' ' It will be delivered by $deliveryTime.', ); _userNotificationRepository.notifications().listen((value) async { if (value.isNotEmpty) { - await cancelOngoinNotification(id); + await cancelOngoingNotification(id); } }); } - static Future cancelOngoinNotification(int id) async { + static Future cancelOngoingNotification(int id) async { await _flutterLocalNotificationsPlugin.cancel(id); } diff --git a/lib/src/services/repositories/local_storage/base_local_storage_repository.dart b/lib/src/services/repositories/local_storage/base_local_storage_repository.dart index 04c206c..94b336b 100644 --- a/lib/src/services/repositories/local_storage/base_local_storage_repository.dart +++ b/lib/src/services/repositories/local_storage/base_local_storage_repository.dart @@ -3,13 +3,9 @@ import 'package:flutter/foundation.dart' show immutable; import 'package:papa_burger/src/models/models.dart'; -/// An abstract class to separate logic a bit, in order to ahchieve maximum -/// maintainability of the code base. +/// An abstract class to separate logic. @immutable abstract class BaseLocalStorageRepository { - /// All of the following methods are only the instances of each method - /// that is fully made and ready to use in [LocalStorageRepository]. - // void addItem(Item item); void removeItem(Item item); void removeAllItems(); void addId(int id); diff --git a/lib/src/services/repositories/local_storage/local_storage_repository.dart b/lib/src/services/repositories/local_storage/local_storage_repository.dart index 7293fb6..e23667f 100644 --- a/lib/src/services/repositories/local_storage/local_storage_repository.dart +++ b/lib/src/services/repositories/local_storage/local_storage_repository.dart @@ -7,7 +7,7 @@ import 'package:papa_burger/src/models/models.dart'; import 'package:papa_burger/src/services/repositories/local_storage/local_storage.dart'; /// [LocalStorageRepository] class, is made to maintain all the logic with -/// Local Storage with [Hive]. [Hive] helps to storage the data localy +/// Local Storage with [Hive]. [Hive] helps to storage the data locally /// on the mobile devices in orders to user them offline and/or reuse data /// without fetching for it once or more times @immutable @@ -92,14 +92,11 @@ class LocalStorageRepository extends BaseLocalStorageRepository { } void decreaseQuantity(Item item) { - // logger.w('---- DECREASING QUANTITY ON ITEM $item ----'); final cartItems = _cartBox.get(item.name) ?? {}; if (cartItems.containsKey(item) && cartItems[item]! as int > 1) { - // logger.w('SATISFIES IF STATEMENT, DECREMENTING QUANTITY'); cartItems[item] = cartItems[item]! - 1; _cartBox.put(item.name, cartItems); } else { - // logger.w('---- DONT SATISFIES IF STATEMENT, DELETING ITEM $item ----'); _cartBox.delete(item.name); } } @@ -139,7 +136,7 @@ class LocalStorageRepository extends BaseLocalStorageRepository { ); } - /// Add global palce id of restaurant to cart, that helps to determine from + /// Add global place id of restaurant to cart, that helps to determine from /// which restaurant item was added to prevent adding from the same restaurant @override void addPlaceId(String placeId) { @@ -150,9 +147,9 @@ class LocalStorageRepository extends BaseLocalStorageRepository { ); } - /// After removing all items from cart, manualy removing all excisting ids + /// After removing all items from cart, manually removing all existing ids /// from storage and setting new value of 0, that means that no there is no - /// items in the cart and any item from any restauraurant can be added. + /// items in the cart and any item from any restaurant can be added. @override void setRestIdTo0() { _idBox.clear().then( diff --git a/lib/src/services/repositories/orders/base_orders_repository.dart b/lib/src/services/repositories/orders/base_orders_repository.dart index 4b22a42..7203b11 100644 --- a/lib/src/services/repositories/orders/base_orders_repository.dart +++ b/lib/src/services/repositories/orders/base_orders_repository.dart @@ -8,7 +8,7 @@ abstract class BaseOrdersRepository { required String restaurantPlaceId, required String restaurantName, required String orderAddress, - required String totalOrderSumm, + required String totalOrderSum, required String orderDeliveryFee, }); @@ -31,7 +31,7 @@ abstract class BaseOrdersRepository { String? restaurantPlaceId, String? restaurantName, String? orderAddress, - String? totalOrderSumm, + String? totalOrderSum, String? orderDeliveryFee, }); diff --git a/lib/src/services/repositories/orders/orders_repository.dart b/lib/src/services/repositories/orders/orders_repository.dart index ce85014..f925432 100644 --- a/lib/src/services/repositories/orders/orders_repository.dart +++ b/lib/src/services/repositories/orders/orders_repository.dart @@ -44,7 +44,7 @@ class OrdersRepository implements BaseOrdersRepository { required String restaurantPlaceId, required String restaurantName, required String orderAddress, - required String totalOrderSumm, + required String totalOrderSum, required String orderDeliveryFee, }) async { await _ordersApi @@ -55,7 +55,7 @@ class OrdersRepository implements BaseOrdersRepository { restaurantPlaceId: restaurantPlaceId, restaurantName: restaurantName, orderAddress: orderAddress, - totalOrderSumm: totalOrderSumm, + totalOrderSum: totalOrderSum, orderDeliveryFee: orderDeliveryFee, ) .then((id) async { @@ -80,7 +80,7 @@ class OrdersRepository implements BaseOrdersRepository { } } }); - return 'Successfuly created order!'; + return 'Successfully created order!'; } @override @@ -91,7 +91,7 @@ class OrdersRepository implements BaseOrdersRepository { await deleteOrderMenuItems(uid, orderDetailsId: orderId).then( (value) => _ordersApi.deleteOrderDetails(uid, orderId: orderId), ); - return 'Successfuly deleted order.'; + return 'Successfully deleted order.'; } @override @@ -124,7 +124,7 @@ class OrdersRepository implements BaseOrdersRepository { String? restaurantPlaceId, String? restaurantName, String? orderAddress, - String? totalOrderSumm, + String? totalOrderSum, String? orderDeliveryFee, }) { return _ordersApi.updateOrderDetails( @@ -135,7 +135,7 @@ class OrdersRepository implements BaseOrdersRepository { restaurantPlaceId: restaurantPlaceId, restaurantName: restaurantName, orderAddress: orderAddress, - totalOrderSumm: totalOrderSumm, + totalOrderSum: totalOrderSum, orderDeliveryFee: orderDeliveryFee, ); } diff --git a/lib/src/services/repositories/user/user_repository.dart b/lib/src/services/repositories/user/user_repository.dart index abc052f..8b22d63 100644 --- a/lib/src/services/repositories/user/user_repository.dart +++ b/lib/src/services/repositories/user/user_repository.dart @@ -36,7 +36,7 @@ class UserRepository implements BaseUserRepository { name, email, password, - profilePitcture: profilePicture, + profilePicture: profilePicture, ); LocalStorage() ..saveUser(user.toJson()) diff --git a/lib/src/services/storage/local_storage.dart b/lib/src/services/storage/local_storage.dart index b124c1b..275950d 100644 --- a/lib/src/services/storage/local_storage.dart +++ b/lib/src/services/storage/local_storage.dart @@ -15,7 +15,7 @@ class LocalStorage { static final _instance = LocalStorage._(); - late final SharedPreferences _prefs; + late final SharedPreferences _sharedPreferences; static const String _tokenKey = 'token'; static const String _uidKey = 'uid'; @@ -33,11 +33,11 @@ class LocalStorage { static const String _cardSelection = 'card_selection'; Future init() async { - _prefs = await SharedPreferences.getInstance(); + _sharedPreferences = await SharedPreferences.getInstance(); } void deleteUserCookies() { - _prefs + _sharedPreferences ..remove(_tokenKey) ..remove(_uidKey) ..remove(_userKey) @@ -62,15 +62,15 @@ class LocalStorage { } void saveUid(String uid) { - _prefs.setString(_uidKey, uid); + _sharedPreferences.setString(_uidKey, uid); } void saveUser(String user) { - _prefs.setString(_userKey, user); + _sharedPreferences.setString(_userKey, user); } Stream get userFromDB async* { - final uid = _prefs.getString(_uidKey); + final uid = _sharedPreferences.getString(_uidKey); try { final apiClient = server.ApiClient(); if (uid != null) { @@ -92,7 +92,7 @@ class LocalStorage { } User? get getUser { - final user = _prefs.getString(_userKey); + final user = _sharedPreferences.getString(_userKey); if (user == null) { return null; } else { @@ -101,68 +101,69 @@ class LocalStorage { } void deleteDuration() { - _prefs.remove(_durationKey); + _sharedPreferences.remove(_durationKey); } void saveToken(String token) { - _prefs.setString(_tokenKey, token); + _sharedPreferences.setString(_tokenKey, token); } - String get getToken => _prefs.getString(_tokenKey) ?? ''; + String get getToken => _sharedPreferences.getString(_tokenKey) ?? ''; void saveEmail(String email) { - _prefs.setString(_emailKey, email); + _sharedPreferences.setString(_emailKey, email); } - String get getEmail => _prefs.getString(_emailKey) ?? ''; + String get getEmail => _sharedPreferences.getString(_emailKey) ?? ''; void savePassword(String password) { - _prefs.setString(_passwordKey, password); + _sharedPreferences.setString(_passwordKey, password); } - String get getPassword => _prefs.getString(_passwordKey) ?? ''; + String get getPassword => _sharedPreferences.getString(_passwordKey) ?? ''; void saveUsername(String username) { - _prefs.setString(_userNameKey, username); + _sharedPreferences.setString(_userNameKey, username); } - String get getUsername => _prefs.getString(_userNameKey) ?? ''; + String get getUsername => _sharedPreferences.getString(_userNameKey) ?? ''; void setFirstInstall() { - _prefs.setBool('isFirstInstall', true); + _sharedPreferences.setBool('isFirstInstall', true); } - bool get isFirstInstall => _prefs.getBool('isFirstInstall') ?? false; + bool get isFirstInstall => + _sharedPreferences.getBool('isFirstInstall') ?? false; void saveTimer(int duration) { - _prefs.setInt(_durationKey, duration); + _sharedPreferences.setInt(_durationKey, duration); } - int get getTimer => _prefs.getInt(_durationKey) ?? 60; + int get getTimer => _sharedPreferences.getInt(_durationKey) ?? 60; void saveLat(double lat) { _latController.sink.add(lat); - _prefs.setDouble(_latitudeKey, lat); + _sharedPreferences.setDouble(_latitudeKey, lat); } void saveLng(double lng) { _lngController.sink.add(lng); - _prefs.setDouble(_longitudeKey, lng); + _sharedPreferences.setDouble(_longitudeKey, lng); } void saveLatLng(double lat, double lng) { addLatLng(lat, lng); - _prefs + _sharedPreferences ..setDouble(_latitudeKey, lat) ..setDouble(_longitudeKey, lng); } void saveLatTemp(double lat) { - _prefs.setDouble(_latitudeTempKey, lat); + _sharedPreferences.setDouble(_latitudeTempKey, lat); } void saveLngTemp(double lng) { - _prefs.setDouble(_longitudeTempKey, lng); + _sharedPreferences.setDouble(_longitudeTempKey, lng); } void saveTemporaryLatLngForUpdate(double lat, double lng) { @@ -171,16 +172,16 @@ class LocalStorage { } void clearTempLatLng() { - _prefs + _sharedPreferences ..remove(_latitudeTempKey) ..remove(_longitudeTempKey); } bool get hasAddress => latitude != 0 && longitude != 0; - double get latitude => _prefs.getDouble(_latitudeKey) ?? 0; + double get latitude => _sharedPreferences.getDouble(_latitudeKey) ?? 0; - double get longitude => _prefs.getDouble(_longitudeKey) ?? 0; + double get longitude => _sharedPreferences.getDouble(_longitudeKey) ?? 0; final StreamController _latController = StreamController.broadcast(); @@ -198,29 +199,32 @@ class LocalStorage { Stream<(double lat, double lng)> get latLngStream => _latLngController.stream; - double get tempLatitude => _prefs.getDouble(_latitudeTempKey) ?? 0; + double get tempLatitude => + _sharedPreferences.getDouble(_latitudeTempKey) ?? 0; - double get tempLongitude => _prefs.getDouble(_longitudeTempKey) ?? 0; + double get tempLongitude => + _sharedPreferences.getDouble(_longitudeTempKey) ?? 0; void saveAddressName(String address) { - _prefs.setString(_addressKey, address); + _sharedPreferences.setString(_addressKey, address); } - String get getAddress => _prefs.getString(_addressKey) ?? noLocation; + String get getAddress => + _sharedPreferences.getString(_addressKey) ?? noLocation; void saveCreditCardSelection(CreditCard creditCard) { - _prefs.setString( + _sharedPreferences.setString( _cardSelection, creditCard.toJson(), ); } void deleteCreditCardSelection() { - _prefs.remove(_cardSelection); + _sharedPreferences.remove(_cardSelection); } CreditCard get getSelectedCreditCard { - final jsonString = _prefs.getString(_cardSelection) ?? ''; + final jsonString = _sharedPreferences.getString(_cardSelection) ?? ''; if (jsonString.isEmpty) { return const CreditCard.empty(); } diff --git a/lib/src/views/pages/cart/cart_view.dart b/lib/src/views/pages/cart/cart_view.dart index 5bfb803..9fc4274 100644 --- a/lib/src/views/pages/cart/cart_view.dart +++ b/lib/src/views/pages/cart/cart_view.dart @@ -172,7 +172,7 @@ class _CartViewState extends State { 'street ${locationNotifier.value}', 'Leave an order comment please 🙏', FontAwesomeIcons.house, - () => context.navigateToGoolgeMapView(), + () => context.navigateToGoogleMapView(), ); SliverToBoxAdapter deliveryTimeInfo() => buildRow( @@ -233,16 +233,16 @@ class _CartViewState extends State { ValueListenableBuilder( valueListenable: cardNotifier, builder: (context, selectedCard, _) { - final noSeletction = selectedCard == const CreditCard.empty(); + final noSelection = selectedCard == const CreditCard.empty(); return SliverToBoxAdapter( child: ListTile( onTap: () => showChoosePaymentModalBottomSheet(context), title: KText( - text: noSeletction + text: noSelection ? 'Choose credit card' : 'VISA •• ' '${selectedCard.number.characters.getRange(15, 19)}', - color: noSeletction ? Colors.red : Colors.black, + color: noSelection ? Colors.red : Colors.black, ), trailing: const CustomIcon( icon: Icons.arrow_forward_ios_sharp, @@ -322,13 +322,13 @@ class CartAppBar extends StatelessWidget { showCustomDialog( context, onTap: () { - context.pop(withHaptickFeedback: true); + context.pop(withHapticFeedback: true); CartBloc().removeAllItems().then((_) { CartBloc().removePlaceIdInCacheAndCart(); context.navigateToMenu(context, restaurant, fromCart: true); }); }, - alertText: 'Clear the Busket?', + alertText: 'Clear the cart?', actionText: 'Clear', ); diff --git a/lib/src/views/pages/cart/components/cart_bottom_app_bar.dart b/lib/src/views/pages/cart/components/cart_bottom_app_bar.dart index ef8a8fc..816041e 100644 --- a/lib/src/views/pages/cart/components/cart_bottom_app_bar.dart +++ b/lib/src/views/pages/cart/components/cart_bottom_app_bar.dart @@ -24,7 +24,7 @@ class CartBottomAppBar extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ KText( - text: cart.totalSumm(), + text: cart.totalSum(), size: 28, ), KText( diff --git a/lib/src/views/pages/cart/components/checkout_modal_bottom_sheet.dart b/lib/src/views/pages/cart/components/checkout_modal_bottom_sheet.dart index 164b7f8..108fd54 100644 --- a/lib/src/views/pages/cart/components/checkout_modal_bottom_sheet.dart +++ b/lib/src/views/pages/cart/components/checkout_modal_bottom_sheet.dart @@ -68,7 +68,7 @@ class CheckoutModalBottomSheet extends StatelessWidget { 'street ${LocationNotifier().value}', 'Leave an order comment please 🙏', FontAwesomeIcons.house, - () => context.navigateToGoolgeMapView(), + () => context.navigateToGoogleMapView(), ); ListTile deliveryTimeInfo() => buildRow( @@ -115,15 +115,15 @@ class CheckoutModalBottomSheet extends StatelessWidget { ValueListenableBuilder( valueListenable: SelectedCardNotifier(), builder: (context, selectedCard, _) { - final noSeletction = selectedCard == const CreditCard.empty(); + final noSelection = selectedCard == const CreditCard.empty(); return ListTile( onTap: () => showChoosePaymentModalBottomSheet(context), title: KText( - text: noSeletction + text: noSelection ? 'Choose payment method' : 'VISA •• ' '${selectedCard.number.characters.getRange(15, 19)}', - color: noSeletction ? Colors.red : Colors.black, + color: noSelection ? Colors.red : Colors.black, ), trailing: const CustomIcon( icon: Icons.arrow_forward_ios_sharp, diff --git a/lib/src/views/pages/cart/components/progress_bar_modal_bottom_sheet.dart b/lib/src/views/pages/cart/components/progress_bar_modal_bottom_sheet.dart index 2502024..bff6f62 100644 --- a/lib/src/views/pages/cart/components/progress_bar_modal_bottom_sheet.dart +++ b/lib/src/views/pages/cart/components/progress_bar_modal_bottom_sheet.dart @@ -62,11 +62,11 @@ class _OrderProgressBarModalBottomSheetState final deliverByWalk = deliveryTime < 8; final deliveryTime$ = (deliverByWalk ? 15 : deliveryTime) + 10; final deliveryDate = now.add(Duration(minutes: deliveryTime$)); - final formatedDeliveryDate = + final formattedDeliveryDate = deliveryDateFormat.format(deliveryDate); final restaurantName = restaurant.name; final orderAddress = LocationNotifier().value; - final totalOrderSumm = cart.totalRound(); + final totalOrderSum = cart.totalRound(); final orderDeliveryFee = cart.getDeliveryFee.toString(); final message = await _ordersBloc.createOrder( @@ -75,9 +75,9 @@ class _OrderProgressBarModalBottomSheetState restaurantPlaceId, restaurantName, orderAddress, - totalOrderSumm, + totalOrderSum, orderDeliveryFee, - formatedDeliveryDate, + formattedDeliveryDate, ); await CartBloc().removeAllItems().then((_) { CartBloc().removePlaceIdInCacheAndCart(); diff --git a/lib/src/views/pages/cart/state/cart_state.dart b/lib/src/views/pages/cart/state/cart_state.dart index e3e5242..f9a6e96 100644 --- a/lib/src/views/pages/cart/state/cart_state.dart +++ b/lib/src/views/pages/cart/state/cart_state.dart @@ -4,8 +4,8 @@ abstract class CartState { const CartState(); } -class CartStataeLoading extends CartState { - const CartStataeLoading(); +class CartStateLoading extends CartState { + const CartStateLoading(); } class CartStateError extends CartState { diff --git a/lib/src/views/pages/login/components/login_form.dart b/lib/src/views/pages/login/components/login_form.dart index 7a7a40c..f397f46 100644 --- a/lib/src/views/pages/login/components/login_form.dart +++ b/lib/src/views/pages/login/components/login_form.dart @@ -105,7 +105,7 @@ class __LogInFormState extends State<_LogInForm> { context.showSnackBar( 'Network connection failed.', duration: const Duration(days: 1), - solution: 'Try to recconect your wifi', + solution: 'Try to reconnect your wifi', dismissDirection: DismissDirection.none, snackBarAction: SnackBarAction( textColor: Colors.indigo.shade200, @@ -133,7 +133,7 @@ class __LogInFormState extends State<_LogInForm> { final emailError = state.email.invalid ? state.email.error : null; final passwordError = state.password.invalid ? state.password.error : null; - final isSubmissionInProggress = + final isSubmissionInProgress = state.submissionStatus == SubmissionStatus.inProgress; final cubit = context.read(); @@ -147,7 +147,7 @@ class __LogInFormState extends State<_LogInForm> { focusNode: _emailFocusNode, prefixIcon: const Icon(Icons.email_outlined), autoCorrect: false, - enabled: !isSubmissionInProggress, + enabled: !isSubmissionInProgress, textInputAction: TextInputAction.next, onChanged: cubit.onEmailChanged, errorText: emailError == null @@ -169,7 +169,7 @@ class __LogInFormState extends State<_LogInForm> { suffixIcon: CustomIcon( size: 20, type: IconType.iconButton, - onPressed: () => !isSubmissionInProggress + onPressed: () => !isSubmissionInProgress ? isTextObscured == true ? context .read() @@ -182,7 +182,7 @@ class __LogInFormState extends State<_LogInForm> { ? FontAwesomeIcons.eyeLowVision : FontAwesomeIcons.eye, ), - enabled: !isSubmissionInProggress, + enabled: !isSubmissionInProgress, onChanged: cubit.onPasswordChanged, errorText: passwordError == null ? null @@ -194,7 +194,7 @@ class __LogInFormState extends State<_LogInForm> { }, ), const ForgotPassword(), - if (isSubmissionInProggress) + if (isSubmissionInProgress) ExpandedElevatedButton.inProgress( backgroundColor: Colors.transparent, radius: 16, diff --git a/lib/src/views/pages/login/login_view.dart b/lib/src/views/pages/login/login_view.dart index d708571..c194172 100644 --- a/lib/src/views/pages/login/login_view.dart +++ b/lib/src/views/pages/login/login_view.dart @@ -41,7 +41,7 @@ class LoginView extends StatelessWidget { ], ), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/login/state/login_cubit.dart b/lib/src/views/pages/login/state/login_cubit.dart index f0d95b4..b827313 100644 --- a/lib/src/views/pages/login/state/login_cubit.dart +++ b/lib/src/views/pages/login/state/login_cubit.dart @@ -21,9 +21,8 @@ class LoginCubit extends Cubit { final previousScreenState = state; final previousEmailState = previousScreenState.email; final shouldValidate = previousEmailState.invalid; - final newEmailState = shouldValidate - ? Email.validated(newValue) - : Email.unvalidated(newValue); + final newEmailState = + shouldValidate ? Email.dirty(newValue) : Email.pure(newValue); final newScreenState = state.copyWith( email: newEmailState, @@ -37,7 +36,7 @@ class LoginCubit extends Cubit { final previousEmailState = previousScreenState.email; final previousEmailValue = previousEmailState.value; - final newEmailState = Email.validated( + final newEmailState = Email.dirty( previousEmailValue, ); final newScreenState = previousScreenState.copyWith( @@ -50,13 +49,8 @@ class LoginCubit extends Cubit { final previousScreenState = state; final previousPasswordState = previousScreenState.password; final shouldValidate = previousPasswordState.invalid; - final newPasswordState = shouldValidate - ? Password.validated( - newValue, - ) - : Password.unvalidated( - newValue, - ); + final newPasswordState = + shouldValidate ? Password.pure(newValue) : Password.dirty(newValue); final newScreenState = state.copyWith( password: newPasswordState, @@ -70,7 +64,7 @@ class LoginCubit extends Cubit { final previousPasswordState = previousScreenState.password; final previousPasswordValue = previousPasswordState.value; - final newPasswordState = Password.validated( + final newPasswordState = Password.pure( previousPasswordValue, ); final newScreenState = previousScreenState.copyWith( @@ -80,8 +74,8 @@ class LoginCubit extends Cubit { } void onLogOut() { - const email = Email.unvalidated(); - const password = Password.unvalidated(); + const email = Email.pure(); + const password = Password.dirty(); final newState = state.copyWith( email: email, password: password, @@ -92,8 +86,8 @@ class LoginCubit extends Cubit { } void idle() { - const email = Email.unvalidated(); - const password = Password.unvalidated(); + const email = Email.pure(); + const password = Password.dirty(); final newState = state.copyWith( email: email, password: password, @@ -103,8 +97,8 @@ class LoginCubit extends Cubit { } Future onSubmit() async { - final email = Email.validated(state.email.value); - final password = Password.validated(state.password.value); + final email = Email.dirty(state.email.value); + final password = Password.pure(state.password.value); final isFormValid = Formz.validate([email, password]).isValid; final newState = state.copyWith( diff --git a/lib/src/views/pages/login/state/login_state.dart b/lib/src/views/pages/login/state/login_state.dart index fa1d164..c73ed96 100644 --- a/lib/src/views/pages/login/state/login_state.dart +++ b/lib/src/views/pages/login/state/login_state.dart @@ -16,8 +16,8 @@ enum SubmissionStatus { class LoginState { const LoginState._({ - this.email = const Email.unvalidated(), - this.password = const Password.unvalidated(), + this.email = const Email.pure(), + this.password = const Password.pure(), this.submissionStatus = SubmissionStatus.idle, }); diff --git a/lib/src/views/pages/main/components/drawer/drawer_view.dart b/lib/src/views/pages/main/components/drawer/drawer_view.dart index 2bb49da..9240144 100644 --- a/lib/src/views/pages/main/components/drawer/drawer_view.dart +++ b/lib/src/views/pages/main/components/drawer/drawer_view.dart @@ -49,7 +49,7 @@ class DrawerView extends StatelessWidget { ), ), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/main/components/drawer/views/orders/components/order_card.dart b/lib/src/views/pages/main/components/drawer/views/orders/components/order_card.dart index 845ffcc..150d6d4 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/components/order_card.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/components/order_card.dart @@ -19,7 +19,7 @@ class OrderCard extends StatelessWidget { @override Widget build(BuildContext context) { final restaurantName = orderDetails.restaurantName; - final orderTotal = orderDetails.totalOrderSumm; + final orderTotal = orderDetails.totalOrderSum; final date = orderDetails.date; final status = orderDetails.status; final menuItems = orderDetails.orderMenuItems; @@ -27,7 +27,7 @@ class OrderCard extends StatelessWidget { return GestureDetector( onTap: () => context.navigateToOrderDetailsView( orderId, - scaffoldMessangerKey: scaffoldMessengerKey, + scaffoldMessengerKey: scaffoldMessengerKey, ), child: Card( elevation: 1, diff --git a/lib/src/views/pages/main/components/drawer/views/orders/components/order_details/order_details_view.dart b/lib/src/views/pages/main/components/drawer/views/orders/components/order_details/order_details_view.dart index d9cdec6..22ad1bb 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/components/order_details/order_details_view.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/components/order_details/order_details_view.dart @@ -87,7 +87,7 @@ class _OrderDetailsViewState extends State { }, ), ], - ).disalowIndicator(), + ), ); } } @@ -111,7 +111,7 @@ class OrderDetailsWithDetails extends StatelessWidget { @override Widget build(BuildContext context) { final orderId = orderDetails.id; - final totalSumm = '${orderDetails.totalOrderSumm.round()}$currency'; + final totalSum = '${orderDetails.totalOrderSum.round()}$currency'; final date = orderDetails.date; final restaurantName = orderDetails.restaurantName; final orderMenuItems = orderDetails.orderMenuItems; @@ -142,7 +142,7 @@ class OrderDetailsWithDetails extends StatelessWidget { size: 13, ), trailing: KText( - text: totalSumm, + text: totalSum, size: 20, fontWeight: FontWeight.w600, ), @@ -267,7 +267,7 @@ class OrderDetailsWithDetails extends StatelessWidget { text: 'Cost of goods', size: 20, ), - trailing: KText(text: totalSumm), + trailing: KText(text: totalSum), ), ListTile( contentPadding: EdgeInsets.zero, @@ -293,7 +293,7 @@ class OrderDetailsWithDetails extends StatelessWidget { fontWeight: FontWeight.bold, ), trailing: KText( - text: totalSumm, + text: totalSum, size: 20, fontWeight: FontWeight.w600, ), diff --git a/lib/src/views/pages/main/components/drawer/views/orders/orders_view.dart b/lib/src/views/pages/main/components/drawer/views/orders/orders_view.dart index 0360281..0443061 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/orders_view.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/orders_view.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:papa_burger/src/config/extensions/extensions.dart'; import 'package:papa_burger/src/views/pages/main/components/drawer/components/header_app_bar.dart'; import 'package:papa_burger/src/views/pages/main/components/drawer/views/orders/components/orders_list_view.dart'; import 'package:papa_burger/src/views/pages/main/components/drawer/views/orders/state/orders_bloc_test.dart'; import 'package:papa_burger/src/views/widgets/widgets.dart'; -class OrdersVieww extends StatelessWidget { - OrdersVieww({super.key}); +class OrdersView extends StatelessWidget { + OrdersView({super.key}); final _scaffoldMessengerKey = GlobalKey(); final _scaffoldKey = GlobalKey(); @@ -31,7 +30,7 @@ class OrdersVieww extends StatelessWidget { scaffoldMessengerKey: _scaffoldMessengerKey, ), ], - ).disalowIndicator(), + ), ), ), ); diff --git a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc.dart b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc.dart index 64542d0..e8758d9 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc.dart @@ -87,11 +87,11 @@ class OrdersBloc extends Bloc { restaurantPlaceId: event.restaurantPlaceId, restaurantName: event.restaurantName, orderAddress: event.orderAddress, - totalOrderSumm: event.totalOrderSumm, + totalOrderSum: event.totalOrderSum, orderDeliveryFee: event.orderDeliveryFee, ); final newState = state.copyWith( - status: OrdersStatus.successfulyCreated, + status: OrdersStatus.successfullyCreated, successMessage: message, ); emit(newState); diff --git a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc_test.dart b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc_test.dart index 8690a99..6d7b867 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc_test.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_bloc_test.dart @@ -79,7 +79,7 @@ class OrdersBlocTest { String restaurantPlaceId, String restaurantName, String orderAddress, - String totalOrderSumm, + String totalOrderSum, String orderDeliveryFee, String deliveryDate, ) async { @@ -91,7 +91,7 @@ class OrdersBlocTest { restaurantPlaceId: restaurantPlaceId, restaurantName: restaurantName, orderAddress: orderAddress, - totalOrderSumm: totalOrderSumm, + totalOrderSum: totalOrderSum, orderDeliveryFee: orderDeliveryFee, ); await NotificationService.showOngoingOrderNotification(deliveryDate, id); diff --git a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_event.dart b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_event.dart index 5a41377..4ffc1bf 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_event.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_event.dart @@ -19,7 +19,7 @@ class OrdersCreateOrder extends OrdersEvent { required this.restaurantPlaceId, required this.restaurantName, required this.orderAddress, - required this.totalOrderSumm, + required this.totalOrderSum, required this.orderDeliveryFee, }); @@ -28,7 +28,7 @@ class OrdersCreateOrder extends OrdersEvent { final String restaurantPlaceId; final String restaurantName; final String orderAddress; - final String totalOrderSumm; + final String totalOrderSum; final String orderDeliveryFee; } diff --git a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_state.dart b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_state.dart index bf9bff1..4b8f04e 100644 --- a/lib/src/views/pages/main/components/drawer/views/orders/state/orders_state.dart +++ b/lib/src/views/pages/main/components/drawer/views/orders/state/orders_state.dart @@ -3,8 +3,8 @@ part of 'orders_bloc.dart'; enum OrdersStatus { loading, success, - successfulyCreated, - successfulyDeleted, + successfullyCreated, + successfullyDeleted, idle, noInternet, clientFailure, diff --git a/lib/src/views/pages/main/components/drawer/views/profile/profile_view.dart b/lib/src/views/pages/main/components/drawer/views/profile/profile_view.dart index 745a528..a90ee0d 100644 --- a/lib/src/views/pages/main/components/drawer/views/profile/profile_view.dart +++ b/lib/src/views/pages/main/components/drawer/views/profile/profile_view.dart @@ -100,7 +100,7 @@ class ProfileView extends StatelessWidget { ), UserCredentialsView(formKey: formKey), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/main/components/header/header_view.dart b/lib/src/views/pages/main/components/header/header_view.dart index fc681a6..bb748cf 100644 --- a/lib/src/views/pages/main/components/header/header_view.dart +++ b/lib/src/views/pages/main/components/header/header_view.dart @@ -51,7 +51,7 @@ class _HeaderViewState extends State super.dispose(); } - ValueListenableBuilder _buildAdressName(BuildContext context) { + ValueListenableBuilder _buildAddressName(BuildContext context) { return ValueListenableBuilder( valueListenable: LocationNotifier(), builder: (context, address, _) { @@ -64,7 +64,7 @@ class _HeaderViewState extends State ); } - Row _buildAdressAndDeliveryText() => const Row( + Row _buildAddressAndDeliveryText() => const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ KText( @@ -177,12 +177,12 @@ class _HeaderViewState extends State horizontal: kDefaultHorizontalPadding, ), child: InkWell( - onTap: () => context.navigateToGoolgeMapView(), + onTap: () => context.navigateToGoogleMapView(), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - _buildAdressAndDeliveryText(), - _buildAdressName(context), + _buildAddressAndDeliveryText(), + _buildAddressName(context), ], ), ), diff --git a/lib/src/views/pages/main/components/header/state/badge_notifier.dart b/lib/src/views/pages/main/components/header/state/badge_notifier.dart index a5d782e..0a528af 100644 --- a/lib/src/views/pages/main/components/header/state/badge_notifier.dart +++ b/lib/src/views/pages/main/components/header/state/badge_notifier.dart @@ -16,9 +16,9 @@ class BadgeNotifier extends ValueNotifier { void _checkPendingOrders() { _ordersBloc.orders.listen((event) { if (event is OrdersWithListResult) { - final peningOrders = + final pendingOrders = event.orders.where((element) => element.status == 'Pending'); - if (peningOrders.isNotEmpty) { + if (pendingOrders.isNotEmpty) { value = true; } else { value = false; diff --git a/lib/src/views/pages/main/components/location/google_map_view.dart b/lib/src/views/pages/main/components/location/google_map_view.dart index ce105ad..fa016b1 100644 --- a/lib/src/views/pages/main/components/location/google_map_view.dart +++ b/lib/src/views/pages/main/components/location/google_map_view.dart @@ -64,7 +64,7 @@ class _GoogleMapViewState extends State void _subscribeToAddress() { _addressResultSubscription = _locationService.locationBloc.addressName.listen((result) { - final isLoading = result is Loading || result is InProggress; + final isLoading = result is Loading || result is InProgress; if (mounted) { setState(() { _isLoading = isLoading; @@ -159,7 +159,7 @@ class _GoogleMapViewState extends State ), ); - Widget _buildInProggress({bool alsoLoading = false}) { + Widget _buildInProgress({bool alsoLoading = false}) { const finding = KText( text: 'Finding you...', size: 26, @@ -320,11 +320,11 @@ class _GoogleMapViewState extends State return _buildErrorAddress(error) .ignorePointer(isMoving: _isMoving); } - if (addressResult is InProggress) { - return _buildInProggress(); + if (addressResult is InProgress) { + return _buildInProgress(); } if (addressResult is Loading) { - return _buildInProggress(alsoLoading: true); + return _buildInProgress(alsoLoading: true); } if (addressResult is AddressWithNoResult) { return _buildNoResult(); diff --git a/lib/src/views/pages/main/components/location/helper/location_helper.dart b/lib/src/views/pages/main/components/location/helper/location_helper.dart index 7e1cd6d..fa39450 100644 --- a/lib/src/views/pages/main/components/location/helper/location_helper.dart +++ b/lib/src/views/pages/main/components/location/helper/location_helper.dart @@ -50,12 +50,12 @@ class LocationHelper { final MapType _mapType = MapType.normal; final Set _markers = {}; final CameraPosition _initialCameraPosition = - const CameraPosition(target: almatyCenterPosititon, zoom: 11); + const CameraPosition(target: almatyCenterPosition, zoom: 11); late LatLng _dynamicMarkerPosition = _initialCameraPosition.target; final Completer _mapController = Completer(); final _dynamicMarkerPositionSubject = - BehaviorSubject.seeded(almatyCenterPosititon); + BehaviorSubject.seeded(almatyCenterPosition); void dispose() => _mapController.future.then((gMap) => gMap.dispose()); @@ -100,8 +100,8 @@ class LocationHelper { Future _navigateToCurrentPosition() async { await _getCurrentPosition().then((newPosition) { - final latlng = LatLng(newPosition.latitude, newPosition.longitude); - _animateCamera(latlng); + final latLng = LatLng(newPosition.latitude, newPosition.longitude); + _animateCamera(latLng); }); } diff --git a/lib/src/views/pages/main/components/location/search_location_with_autocomplete.dart b/lib/src/views/pages/main/components/location/search_location_with_autocomplete.dart index 480ca33..5159387 100644 --- a/lib/src/views/pages/main/components/location/search_location_with_autocomplete.dart +++ b/lib/src/views/pages/main/components/location/search_location_with_autocomplete.dart @@ -82,9 +82,9 @@ class _SearchLocationWithAutoCompleteState child: ListView.builder( itemBuilder: (context, index) { final autoCompleteLoc = results[index]; - final mainText = autoCompleteLoc.structuredFormating.mainText; + final mainText = autoCompleteLoc.structuredFormatting.mainText; final secondaryText = - autoCompleteLoc.structuredFormating.secondaryText; + autoCompleteLoc.structuredFormatting.secondaryText; final placeId = autoCompleteLoc.placeId; _getPlaceDetails(placeId); @@ -92,7 +92,7 @@ class _SearchLocationWithAutoCompleteState _placeDetails!.formattedAddress.isNotEmpty; return InkWell( onTap: () { - isOk ? context.navigateToGoolgeMapView(_placeDetails!) : null; + isOk ? context.navigateToGoogleMapView(_placeDetails!) : null; }, child: Container( padding: const EdgeInsets.symmetric( @@ -119,7 +119,7 @@ class _SearchLocationWithAutoCompleteState ); }, itemCount: results.length, - ).disalowIndicator(), + ), ); Widget _buildUnhandledState() => const KText(text: 'Unhandled state'); diff --git a/lib/src/views/pages/main/components/main_page_body.dart b/lib/src/views/pages/main/components/main_page_body.dart index b06f4f0..4719caa 100644 --- a/lib/src/views/pages/main/components/main_page_body.dart +++ b/lib/src/views/pages/main/components/main_page_body.dart @@ -77,7 +77,7 @@ class _MainPageBodyUIState extends State { final message = state.errMessage; if (noInternet) { - context.showUndismissibleSnackBar( + context.showUndismissableSnackBar( message, action: SnackBarAction( label: 'REFRESH', @@ -94,7 +94,7 @@ class _MainPageBodyUIState extends State { context.showSnackBar(message); } if (outOfTime) { - context.showUndismissibleSnackBar( + context.showUndismissableSnackBar( message, action: SnackBarAction( label: 'TRY AGAIN', @@ -155,7 +155,7 @@ class _MainPageBodyUIState extends State { ], ); }, - ).disalowIndicator(), + ), ); } } @@ -308,7 +308,7 @@ class MainPageNoInternetView extends StatelessWidget { }, childCount: 5, ), - ).disalowIndicator(), + ), ); } } @@ -423,7 +423,7 @@ class ResetFiltersButton extends StatelessWidget { hoverColor: Colors.transparent, focusColor: Colors.transparent, onTap: () { - context.read().add(const MainTestTagsFiltersReseted()); + context.read().add(const MainTestTagsFiltersClear()); }, child: Ink( padding: const EdgeInsets.symmetric( diff --git a/lib/src/views/pages/main/components/menu/components/menu_item_card.dart b/lib/src/views/pages/main/components/menu/components/menu_item_card.dart index f0afc6d..e2b5144 100644 --- a/lib/src/views/pages/main/components/menu/components/menu_item_card.dart +++ b/lib/src/views/pages/main/components/menu/components/menu_item_card.dart @@ -33,7 +33,7 @@ class _MenuItemCardState extends State { return showCustomDialog( context, onTap: () { - context.pop(withHaptickFeedback: true); + context.pop(withHapticFeedback: true); CartBloc().addItemToCartAfterCallingClearCart( menuItem, placeId, diff --git a/lib/src/views/pages/main/components/menu/menu_view.dart b/lib/src/views/pages/main/components/menu/menu_view.dart index 418af07..8669d79 100644 --- a/lib/src/views/pages/main/components/menu/menu_view.dart +++ b/lib/src/views/pages/main/components/menu/menu_view.dart @@ -168,7 +168,7 @@ class _MenuViewState extends State Positioned( right: 0, child: KText( - text: cart.totalSumm(), + text: cart.totalSum(), color: Colors.white.withOpacity(.7), ), ), @@ -367,7 +367,7 @@ class _MenuViewState extends State child: CustomCircularIndicator(color: Colors.black), ), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/main/components/restaurant/restaurants_filtered_view.dart b/lib/src/views/pages/main/components/restaurant/restaurants_filtered_view.dart index 4f0507b..53020cc 100644 --- a/lib/src/views/pages/main/components/restaurant/restaurants_filtered_view.dart +++ b/lib/src/views/pages/main/components/restaurant/restaurants_filtered_view.dart @@ -60,7 +60,7 @@ class RestaurantsFilteredView extends StatelessWidget { hasMore: false, ), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/main/components/restaurant/restaurants_list_view.dart b/lib/src/views/pages/main/components/restaurant/restaurants_list_view.dart index 8eadad5..f92fcbe 100644 --- a/lib/src/views/pages/main/components/restaurant/restaurants_list_view.dart +++ b/lib/src/views/pages/main/components/restaurant/restaurants_list_view.dart @@ -69,7 +69,7 @@ class RestaurantsListView extends StatelessWidget { }, childCount: 5, ), - ).disalowIndicator() + ) : SliverList( delegate: SliverChildBuilderDelegate( (context, index) { @@ -111,7 +111,7 @@ class RestaurantsListView extends StatelessWidget { }, childCount: restaurants.length + (hasMore ? 1 : 0), ), - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/main/components/search/search_view.dart b/lib/src/views/pages/main/components/search/search_view.dart index 8b96ae5..c3d3a24 100644 --- a/lib/src/views/pages/main/components/search/search_view.dart +++ b/lib/src/views/pages/main/components/search/search_view.dart @@ -100,7 +100,7 @@ class _SearchViewState extends State { ); }, itemCount: restaurants.length, - ).disalowIndicator(), + ), ); } @@ -175,7 +175,7 @@ class _SearchViewState extends State { ); }, itemCount: result.restaurants.length, - ).disalowIndicator(), + ), ); } else { return const KText(text: 'Unhandled state'); diff --git a/lib/src/views/pages/main/state/address_result.dart b/lib/src/views/pages/main/state/address_result.dart index 39a0ba3..40da2d3 100644 --- a/lib/src/views/pages/main/state/address_result.dart +++ b/lib/src/views/pages/main/state/address_result.dart @@ -17,8 +17,8 @@ abstract class AddressLoading implements AddressResult { } @immutable -class InProggress implements AddressLoading { - const InProggress(); +class InProgress implements AddressLoading { + const InProgress(); } @immutable diff --git a/lib/src/views/pages/main/state/bloc/main_test_bloc.dart b/lib/src/views/pages/main/state/bloc/main_test_bloc.dart index 8c76be5..dbc8197 100644 --- a/lib/src/views/pages/main/state/bloc/main_test_bloc.dart +++ b/lib/src/views/pages/main/state/bloc/main_test_bloc.dart @@ -29,7 +29,7 @@ class MainTestBloc extends Bloc { on<_MainTestFilterRestaurantsTagRemoved>( _onMainTestFilterRestaurantsTagRemoved, ); - on(_onMainTestTagsFiltersReset); + on(_onMainTestTagsFiltersReset); on(_onMainTestRefreshed); } @@ -104,7 +104,7 @@ class MainTestBloc extends Bloc { ), ); if (state.chosenTags.isEmpty) { - add(const MainTestTagsFiltersReseted()); + add(const MainTestTagsFiltersClear()); } else { final loading = state.copyWith( status: MainPageStatus.loading, @@ -131,7 +131,7 @@ class MainTestBloc extends Bloc { } Future _onMainTestTagsFiltersReset( - MainTestTagsFiltersReseted event, + MainTestTagsFiltersClear event, Emitter emit, ) async { final loading = state.copyWith( @@ -209,7 +209,7 @@ class MainTestBloc extends Bloc { Emitter emit, ) { if (state.withFilteredRestaurants) { - add(const MainTestTagsFiltersReseted()); + add(const MainTestTagsFiltersClear()); add(const MainTestRestaurantsAndTagsFetched()); } else { add(const MainTestRestaurantsAndTagsFetched()); diff --git a/lib/src/views/pages/main/state/bloc/main_test_event.dart b/lib/src/views/pages/main/state/bloc/main_test_event.dart index 444800a..40c23b1 100644 --- a/lib/src/views/pages/main/state/bloc/main_test_event.dart +++ b/lib/src/views/pages/main/state/bloc/main_test_event.dart @@ -40,8 +40,8 @@ class _MainTestFilterRestaurantsTagRemoved extends MainTestEvent { final Tag tag; } -class MainTestTagsFiltersReseted extends MainTestEvent { - const MainTestTagsFiltersReseted(); +class MainTestTagsFiltersClear extends MainTestEvent { + const MainTestTagsFiltersClear(); } class MainTestRefreshed extends MainTestEvent { diff --git a/lib/src/views/pages/main/state/location_bloc.dart b/lib/src/views/pages/main/state/location_bloc.dart index 50f7129..2a160b6 100644 --- a/lib/src/views/pages/main/state/location_bloc.dart +++ b/lib/src/views/pages/main/state/location_bloc.dart @@ -46,11 +46,10 @@ class LocationBloc { }, ).startWith(const LocationResultEmpty()); - final addressSubject = - BehaviorSubject.seeded(almatyCenterPosititon); + final addressSubject = BehaviorSubject.seeded(almatyCenterPosition); - /// Using this subject to then check whether user moving goole map camera or - /// it's idle to then accordingly emit or not emit the value of + /// Using this subject to then check whether user moving google map camera + /// or it's idle to then accordingly emit or not emit the value of /// address subject. final userMoveCamera = BehaviorSubject.seeded(false); @@ -59,9 +58,9 @@ class LocationBloc { return addressSubject .distinct() .debounceTime(const Duration(milliseconds: 300)) - .switchMap((latlng) { - final lat = latlng.latitude; - final lng = latlng.longitude; + .switchMap((latLng) { + final lat = latLng.latitude; + final lng = latLng.longitude; return Rx.fromCallable( () => locationApi.getFormattedAddress(lat, lng), ) @@ -78,7 +77,7 @@ class LocationBloc { }); }); } else { - return Stream.value(const InProggress()); + return Stream.value(const InProgress()); } }); @@ -92,11 +91,11 @@ class LocationBloc { }); final positionSubject = - BehaviorSubject.seeded(almatyCenterPosititon); + BehaviorSubject.seeded(almatyCenterPosition); final position = positionSubject.distinct().map((cameraPosition) { - final latlng = cameraPosition; - return LatLng(latlng.latitude, latlng.longitude); + final latLng = cameraPosition; + return LatLng(latLng.latitude, latLng.longitude); }); // final saveLocationSubject = BehaviorSubject(); @@ -110,7 +109,7 @@ class LocationBloc { // }); // }); - return LocationBloc._privateConstrucator( + return LocationBloc._( search: autocompleteSubject.sink, findLocation: addressSubject.sink, onCameraMove: positionSubject.sink, @@ -123,7 +122,7 @@ class LocationBloc { position: position, ); } - const LocationBloc._privateConstrucator({ + const LocationBloc._({ required this.search, required this.findLocation, required this.onCameraMove, diff --git a/lib/src/views/pages/main/state/main_bloc.dart b/lib/src/views/pages/main/state/main_bloc.dart index fe507e9..7d6ac0c 100644 --- a/lib/src/views/pages/main/state/main_bloc.dart +++ b/lib/src/views/pages/main/state/main_bloc.dart @@ -66,18 +66,18 @@ class MainBloc { } } - /// Stream to maintain all possible states of main page throught restaurants page + /// Stream to maintain all possible states of main page restaurants page /// from backend. /// /// Before it goes to the computing the method where we get our restaurants, we /// check whether _restaurantsPageSubject value(page) is empty, if it is not empty - /// returning already extsiting restaurants in order to avoid unnesecary Backend + /// returning already existing restaurants in order to avoid unnecessary Backend /// API call. /// - /// Gets Restaurants page from Backend and return appropriate state depening on + /// Gets Restaurants page from Backend and return appropriate state depending on /// the result from [getRestaurantsPageFromBackend()] method. Whether it's empty /// returning MainPageStateWithNoRestaurants. If it has error returning MainPageError - /// and if it has restaurants returning MainPageWithRestauraurants. + /// and if it has restaurants returning MainPageWithRestaurants. Stream get mainPageState { return _restaurantsPageSubject.distinct().switchMap( (page) { @@ -112,7 +112,7 @@ class MainBloc { }, ).startWith(const MainPageLoading()); } else { - logI('Returning already exsisting Restaurants from stream.'); + logI('Returning already existing Restaurants from stream.'); return Stream.value( MainPageWithRestaurants(restaurants: page.restaurants), ); @@ -121,7 +121,7 @@ class MainBloc { ); } - Future get _getRestauratnsPage async { + Future get _getRestaurantsPage async { final lat = LocalStorage().latitude.toString(); final lng = LocalStorage().longitude.toString(); return RestaurantApi().getRestaurantsPage(latitude: lat, longitude: lng); @@ -152,7 +152,7 @@ class MainBloc { } // Everything that is commented in this file and everything that is connected - // to it it means that I no longer use this methonds due to unavailability to + // to it it means that I no longer use this methods due to unavailability to // use Google maps APIs due to billing problems. // // So, instead of it I use my own Backend server from where I can get my own @@ -185,7 +185,7 @@ class MainBloc { // logger.w('Fetching for first page by Page Token $pageToken'); // // final firstPage = // // await _restaurantService.getRestaurantsPage(pageToken, forMainPage); - // final firstPage = await _getRestauratnsPage; + // final firstPage = await _getRestaurantsPage; // _doSomeFilteringOnPage(firstPage.restaurants); // // restaurants = firstPage.restaurants; // final hasMore = firstPage.nextPageToken == null ? false : true; @@ -226,7 +226,7 @@ class MainBloc { // lng: lng, // ); logI('Getting all restaurants'); - final page = await _getRestauratnsPage; + final page = await _getRestaurantsPage; allRestaurants.addAll(page.restaurants); _filterPage(page); _restaurantsPageSubject.add( diff --git a/lib/src/views/pages/notification/state/notification_bloc.dart b/lib/src/views/pages/notification/state/notification_bloc.dart index 028a834..25399ea 100644 --- a/lib/src/views/pages/notification/state/notification_bloc.dart +++ b/lib/src/views/pages/notification/state/notification_bloc.dart @@ -23,7 +23,7 @@ class NotificationBloc extends Bloc { final NotificationsRepository _notificationRepository; StreamSubscription? _messagesSubscription; - StreamSubscription? _connectionStateSubscrption; + StreamSubscription? _connectionStateSubscription; void _onNotificationStarted( NotificationStarted event, @@ -34,7 +34,7 @@ class NotificationBloc extends Bloc { add(_NotificationMessageChanged(message)); }); - _connectionStateSubscrption = + _connectionStateSubscription = _notificationRepository.connection().listen((status) { add(_NotificationConnectionStatusChanged(status)); }); @@ -65,7 +65,7 @@ class NotificationBloc extends Bloc { @override Future close() { _messagesSubscription?.cancel(); - _connectionStateSubscrption?.cancel(); + _connectionStateSubscription?.cancel(); return super.close(); } } diff --git a/lib/src/views/pages/register/components/register_form.dart b/lib/src/views/pages/register/components/register_form.dart index 43e9181..52e3f28 100644 --- a/lib/src/views/pages/register/components/register_form.dart +++ b/lib/src/views/pages/register/components/register_form.dart @@ -95,7 +95,7 @@ class _RegisterFormState extends State { final passwordError = state.password.invalid ? state.password.error : null; final usernameError = state.name.invalid ? state.name.error : null; - final isSubmissionInProggress = + final isSubmissionInProgress = state.submissionStatus == SubmissionStatus.inProgress; final cubit = context.read(); @@ -116,7 +116,7 @@ class _RegisterFormState extends State { focusNode: _usernameFocusNode, prefixIcon: const Icon(FontAwesomeIcons.user), autoCorrect: false, - enabled: !isSubmissionInProggress, + enabled: !isSubmissionInProgress, textInputAction: TextInputAction.next, onChanged: cubit.onNameChanged, errorText: usernameError == null @@ -132,7 +132,7 @@ class _RegisterFormState extends State { focusNode: _emailFocusNode, prefixIcon: const Icon(Icons.email_outlined), autoCorrect: false, - enabled: !isSubmissionInProggress, + enabled: !isSubmissionInProgress, textInputAction: TextInputAction.next, onChanged: cubit.onEmailChanged, errorText: emailError == null @@ -154,7 +154,7 @@ class _RegisterFormState extends State { suffixIcon: CustomIcon( size: 20, type: IconType.iconButton, - onPressed: () => !isSubmissionInProggress + onPressed: () => !isSubmissionInProgress ? isTextObscured == true ? context .read() @@ -167,7 +167,7 @@ class _RegisterFormState extends State { ? FontAwesomeIcons.eyeLowVision : FontAwesomeIcons.eye, ), - enabled: !isSubmissionInProggress, + enabled: !isSubmissionInProgress, onChanged: cubit.onPasswordChanged, errorText: passwordError == null ? null @@ -179,7 +179,7 @@ class _RegisterFormState extends State { }, ), const SizedBox(height: 24), - if (isSubmissionInProggress) + if (isSubmissionInProgress) ExpandedElevatedButton.inProgress( backgroundColor: Colors.transparent, radius: 16, diff --git a/lib/src/views/pages/register/register_view.dart b/lib/src/views/pages/register/register_view.dart index 88282d3..bde6c0a 100644 --- a/lib/src/views/pages/register/register_view.dart +++ b/lib/src/views/pages/register/register_view.dart @@ -32,7 +32,7 @@ class RegisterView extends StatelessWidget { ], ), ], - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/pages/register/state/register_cubit.dart b/lib/src/views/pages/register/state/register_cubit.dart index 0fd4ec6..5b0ca70 100644 --- a/lib/src/views/pages/register/state/register_cubit.dart +++ b/lib/src/views/pages/register/state/register_cubit.dart @@ -23,17 +23,10 @@ class RegisterCubit extends Cubit { final previousScreenState = state; final previousEmailState = previousScreenState.email; final shouldValidate = previousEmailState.invalid; - final newEmailState = shouldValidate - ? Email.validated( - newValue, - ) - : Email.unvalidated( - newValue, - ); + final newEmailState = + shouldValidate ? Email.dirty(newValue) : Email.pure(newValue); - final newScreenState = state.copyWith( - email: newEmailState, - ); + final newScreenState = state.copyWith(email: newEmailState); emit(newScreenState); } @@ -43,9 +36,7 @@ class RegisterCubit extends Cubit { final previousEmailState = previousScreenState.email; final previousEmailValue = previousEmailState.value; - final newEmailState = Email.validated( - previousEmailValue, - ); + final newEmailState = Email.dirty(previousEmailValue); final newScreenState = previousScreenState.copyWith( email: newEmailState, ); @@ -56,13 +47,8 @@ class RegisterCubit extends Cubit { final previousScreenState = state; final previousPasswordState = previousScreenState.password; final shouldValidate = previousPasswordState.invalid; - final newPasswordState = shouldValidate - ? Password.validated( - newValue, - ) - : Password.unvalidated( - newValue, - ); + final newPasswordState = + shouldValidate ? Password.dirty(newValue) : Password.pure(newValue); final newScreenState = state.copyWith( password: newPasswordState, @@ -76,12 +62,9 @@ class RegisterCubit extends Cubit { final previousPasswordState = previousScreenState.password; final previousPasswordValue = previousPasswordState.value; - final newPasswordState = Password.validated( - previousPasswordValue, - ); - final newScreenState = previousScreenState.copyWith( - password: newPasswordState, - ); + final newPasswordState = Password.dirty(previousPasswordValue); + final newScreenState = + previousScreenState.copyWith(password: newPasswordState); emit(newScreenState); } @@ -89,13 +72,8 @@ class RegisterCubit extends Cubit { final previousScreenState = state; final previousEmailState = previousScreenState.name; final shouldValidate = previousEmailState.invalid; - final newEmailState = shouldValidate - ? Username.validated( - newValue, - ) - : Username.unvalidated( - newValue, - ); + final newEmailState = + shouldValidate ? Username.dirty(newValue) : Username.pure(newValue); final newScreenState = state.copyWith( name: newEmailState, @@ -109,9 +87,7 @@ class RegisterCubit extends Cubit { final previousEmailState = previousScreenState.name; final previousEmailValue = previousEmailState.value; - final newEmailState = Username.validated( - previousEmailValue, - ); + final newEmailState = Username.dirty(previousEmailValue); final newScreenState = previousScreenState.copyWith( name: newEmailState, ); @@ -119,11 +95,9 @@ class RegisterCubit extends Cubit { } void idle() { - const email = Email.unvalidated(); - const password = Password.unvalidated(); - const name = Username.unvalidated(); + const password = Password.pure(); + const name = Username.pure(); final newState = state.copyWith( - email: email, password: password, name: name, submissionStatus: SubmissionStatus.idle, @@ -132,9 +106,9 @@ class RegisterCubit extends Cubit { } Future onRegisterSubmit() async { - final email = Email.validated(state.email.value); - final password = Password.validated(state.password.value); - final name = Username.validated(state.name.value); + final email = Email.dirty(state.email.value); + final password = Password.dirty(state.password.value); + final name = Username.dirty(state.name.value); final isFormValid = Formz.validate([ email, diff --git a/lib/src/views/pages/register/state/register_state.dart b/lib/src/views/pages/register/state/register_state.dart index 8e4e07f..4d32c82 100644 --- a/lib/src/views/pages/register/state/register_state.dart +++ b/lib/src/views/pages/register/state/register_state.dart @@ -2,9 +2,9 @@ part of 'register_cubit.dart'; class RegisterState extends Equatable { const RegisterState({ - this.name = const Username.unvalidated(), - this.email = const Email.unvalidated(), - this.password = const Password.unvalidated(), + this.name = const Username.pure(), + this.email = const Email.pure(), + this.password = const Password.pure(), this.profilePicture = '', this.submissionStatus = SubmissionStatus.idle, }); diff --git a/lib/src/views/pages/restaurants/restaurant_view.dart b/lib/src/views/pages/restaurants/restaurant_view.dart index df60ab4..c690b94 100644 --- a/lib/src/views/pages/restaurants/restaurant_view.dart +++ b/lib/src/views/pages/restaurants/restaurant_view.dart @@ -93,7 +93,7 @@ class _MainPageBodyUIState extends State { final message = state.errMessage; if (noInternet) { - context.showUndismissibleSnackBar( + context.showUndismissableSnackBar( message, action: SnackBarAction( label: 'REFRESH', @@ -110,7 +110,7 @@ class _MainPageBodyUIState extends State { context.showSnackBar(message); } if (outOfTime) { - context.showUndismissibleSnackBar( + context.showUndismissableSnackBar( message, action: SnackBarAction( label: 'TRY AGAIN', @@ -173,7 +173,7 @@ class _MainPageBodyUIState extends State { ], ); }, - ).disalowIndicator(), + ), ); } } diff --git a/lib/src/views/widgets/app_scaffold.dart b/lib/src/views/widgets/app_scaffold.dart index 5cd5bdd..77a7639 100644 --- a/lib/src/views/widgets/app_scaffold.dart +++ b/lib/src/views/widgets/app_scaffold.dart @@ -65,7 +65,7 @@ class AppScaffold extends StatelessWidget { /// The floating action button of the scaffold. final Widget? floatingActionButton; - /// The location of the floaing action button of the scaffold. + /// The location of the floating action button of the scaffold. final FloatingActionButtonLocation? floatingActionButtonLocation; /// The bottom navigation bar of the scaffold. diff --git a/lib/src/views/widgets/cached_image.dart b/lib/src/views/widgets/cached_image.dart index 6809a0e..e1255c3 100644 --- a/lib/src/views/widgets/cached_image.dart +++ b/lib/src/views/widgets/cached_image.dart @@ -36,7 +36,6 @@ class CachedImage extends StatelessWidget { this.top = 20, this.right = 0, this.radius = kDefaultBorderRadius, - this.sizeXMark = 18, this.sizeSimpleIcon = 32, this.onTap, this.onTapBorderRadius = kDefaultBorderRadius, @@ -57,7 +56,6 @@ class CachedImage extends StatelessWidget { left, right, bottom, - sizeXMark, sizeSimpleIcon, radius, onTapBorderRadius; @@ -82,17 +80,16 @@ class CachedImage extends StatelessWidget { Colors.indigo.withOpacity(.9), ]; - Config _config({required String cacheKeyName, int stalePerioud = 1}) => - Config( + Config _config({required String cacheKeyName, int stalePeriod = 1}) => Config( cacheKeyName, maxNrOfCacheObjects: 60, stalePeriod: Duration( - days: stalePerioud, + days: stalePeriod, ), ); - CacheManager _defaultCacheManager(String cackeKeyName) => CacheManager( - _config(cacheKeyName: cackeKeyName), + CacheManager _defaultCacheManager(String cacheKeyName) => CacheManager( + _config(cacheKeyName: cacheKeyName), ); Color _getRandomColor() { @@ -116,7 +113,7 @@ class CachedImage extends StatelessWidget { ), ); - Container _buildPlaceHolder(double width, double heigth) => Container( + Container _buildPlaceHolder(double width, double height) => Container( width: width, height: height, decoration: BoxDecoration( diff --git a/lib/src/views/widgets/custom_modal_bottom_sheet.dart b/lib/src/views/widgets/custom_modal_bottom_sheet.dart index f9030ae..9ecc2b8 100644 --- a/lib/src/views/widgets/custom_modal_bottom_sheet.dart +++ b/lib/src/views/widgets/custom_modal_bottom_sheet.dart @@ -54,7 +54,7 @@ class CustomModalBottomSheet extends StatelessWidget { content, ], ), - ).disalowIndicator(), + ), ), ), ); diff --git a/lib/src/views/widgets/show_custom_dialog.dart b/lib/src/views/widgets/show_custom_dialog.dart index e3014b6..0d21abd 100644 --- a/lib/src/views/widgets/show_custom_dialog.dart +++ b/lib/src/views/widgets/show_custom_dialog.dart @@ -39,7 +39,7 @@ Future showCustomDialog( children: [ Expanded( child: GestureDetector( - onTap: () => context.pop(withHaptickFeedback: true), + onTap: () => context.pop(withHapticFeedback: true), child: CustomButtonInShowDialog( borderRadius: BorderRadius.circular(18), padding: const EdgeInsets.all(10),