A new Flutter project.
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
This commit adds the ability to launch Google Maps navigation directly from the delivery map and enhances the Android manifest for better compatibility with certain features. Furthermore, Google Maps route fetching is now integrated, improving the application's user navigation experience.
-
.gitignore:
- Added
android/app/google-services.jsonandandroid/app/GoogleService-Info.plistto ignore Google service configuration files.
- Added
-
android/app/src/main/AndroidManifest.xml:
- Added intent visibility configuration for custom tabs service for API level 30 and above.
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart:
- Imported
google_navigation_launcher.dartto facilitate Google Maps navigation. - Added
_openGoogleNavigationApp()method to initiate Google Maps navigation for deliveries. - Modified button functionality:
- Changed the button to call
ctrl.fetchGoogleRoutefor fetching delivery route information. - Added a button to launch Google Maps navigation using
_openGoogleNavigationApp().
- Changed the button to call
- Imported
-
lib/services/google_navigation_launcher.dart:
- Added a new service class
GoogleNavigationLauncherto facilitate navigation using Google Maps. - Implemented
startNavigation()to launch Google Maps with the delivery route, including origin, destination, and waypoints.
- Added a new service class
-
linux/flutter/generated_plugin_registrant.cc & linux/flutter/generated_plugins.cmake:
- Registered
url_launcher_linuxplugin to allow URL launching capabilities on Linux.
- Registered
-
pubspec.yaml & pubspec.lock:
- Added
url_launcherversion 6.3.1 to facilitate external URL launching for Google Maps navigation.
- Added
The integration of Google Maps navigation provides a seamless way for delivery personnel to navigate between delivery points directly within the application. The modifications in the Android manifest and addition of URL launcher support across platforms enhance the application's flexibility and compatibility.
This commit introduces a new utility class LateFinal and integrates Google route fetching in the delivery map feature. The changes aim to enhance route visualization and manage late initialization of variables, improving the application's reliability and user experience.
-
lib/common/utils/late_final.dart:
- Added a new utility class
LateFinal<T>to manage late initialization and ensure values are set only once. It includes safeguards to prevent re-initialization and ensure controlled access.
- Added a new utility class
-
lib/features/user_delivery/delivery_map/delivery_map_controller.dart:
- Replaced
late final GoogleMapController mapControllerwithLateFinal<GoogleMapController>for safer initialization control. - Added
fetchGoogleRoute()to manage the fetching of route data using Google Maps API. - Introduced
_getPolyline()to retrieve route polylines and visualize them on the map, improving delivery path tracking. - Added
googleApiKeyas aLateFinal<String>for secure and controlled API key initialization. - Added
isStarted,polylineCoordinates, andpolylinesattributes to manage the map state and route visualization. - Updated
onMapCreated()method to useLateFinalfor managing map controller initialization. - Modified
createNumberedMarker()to utilize simplified type imports and added consistency improvements.
- Replaced
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart:
- Updated button icons to more relevant symbols for better UX.
- Added a new button that calls
ctrl.fetchGoogleRouteto fetch and display route information. - Enhanced
GoogleMapwidget to includepolylinesfromctrl.polylines, allowing users to view optimized delivery routes.
-
lib/services/extensions_services.dart:
- Added new extensions:
LatLngExtensionandGeoPointExtensionto convert betweenLatLng,GeoPoint, andPointLatLng, simplifying code readability and reuse.
- Added new extensions:
-
lib/services/navigation_route.dart:
- Added the
lastLatLnggetter to retrieve the last delivery point, improving route management functionality. - Imported
extensions_services.dartto utilize the newly definedLatLngandGeoPointextensions.
- Added the
-
pubspec.yaml & pubspec.lock:
- Added
flutter_polyline_pointsversion 2.1.0 to manage polyline calculations for route visualization.
- Added
The addition of LateFinal improves the safety and integrity of variable initialization across the application. Integration of route fetching and visualization significantly enhances delivery management by providing clear and optimized paths for deliveries. The new extensions further streamline code interactions with geographical data, contributing to a cleaner and more maintainable codebase.
This update significantly enhances the interactivity and usability of the delivery map by introducing features for dynamically managing delivery routes. Below are the detailed changes made:
-
lib/features/user_delivery/delivery_map/delivery_map_controller.dart:
- Added
DeliveryModelto manage deliveries within the controller. - Modified the
initmethod to include a list ofDeliveryModeldeliveries. - Implemented
reversedOrdermethod to reverse the delivery order and update the UI. - Added
changeOrdermethod to allow swapping of delivery points based on user interaction.
- Added
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart:
- Updated
DeliveryMapPageto accept adeliveriesparameter and initializedDeliveryMapStorewith the length of deliveries. - Enhanced the user interface with additional buttons for reversing delivery order and resetting counters using
IconButtonwidgets. - Integrated
ValueListenableBuilderto manage and track the current state of delivery count interactively. - Added Google Maps markers to reflect the dynamically updated delivery order and provide a more engaging visual representation.
- Updated
-
lib/features/user_delivery/delivery_map/delivery_map_store.dart:
- Modified
DeliveryMapStoreto manage the length of deliveries. - Added a
countValueNotifier to track the interaction count and functions (incrementCount,resetCount) to manage the counter.
- Modified
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart:
- Removed the
setDeliveriesPointsfunction as deliveries are now managed directly by theDeliveryMapController.
- Removed the
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated
_createRoutesto passctrl.deliveriesas an argument toDeliveryMapPage, ensuring the correct data flow.
- Updated
-
lib/my_material_app.dart:
- Updated
onGenerateRouteto correctly pass thedeliveriesdata toDeliveryMapPagewhen generating the route.
- Updated
-
lib/services/navigation_route.dart:
- Added
reversedOrderto reverse the current delivery order. - Added
swapOrderIdsto allow users to swap specific delivery points, enabling user-driven customization of routes.
- Added
These updates make the delivery map much more interactive and user-friendly by allowing users to dynamically manage delivery points, visualize their order on a map, and reorder deliveries with ease. The additional UI controls and value listeners ensure a smooth and responsive user experience, providing better control over deliveries.
This commit introduces significant improvements to the delivery map functionality, including the integration of a new store for managing map states, refactoring of controllers, and code clean-up to enhance modularity and maintainability.
-
lib/features/user_delivery/delivery_map/delivery_map_controller.dart:
- Added an ignore statement for linting to suppress public member API documentation warnings.
- Imported additional libraries for drawing custom map markers and logging.
- Implemented new methods:
initto initialize theDeliveryMapStore.disposeto properly clean up resources.createBasicRoutesto generate basic delivery routes and set page states accordingly.
- Added
createNumberedMarkerto generate custom numbered markers for map locations.
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart:
- Added a reference to the
DeliveryMapController(ctrl) and initialized it using the newDeliveryMapStore. - Moved the marker creation logic to the controller (
createNumberedMarker). - Updated button layouts to use the
Wrapwidget for better UI alignment. - Updated the lifecycle (
initStateanddispose) to initialize and dispose of the store and controller appropriately.
- Added a reference to the
-
lib/features/user_delivery/delivery_map/delivery_map_store.dart (new file):
- Introduced
DeliveryMapStoreto manage page state and handle errors for the delivery map. - Added methods for state management:
dispose,setPageState, andsetError.
- Introduced
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart:
- Renamed the
createBasicRoutesmethod tosetDeliveriesPointsfor better clarity regarding its functionality. - Removed redundant route creation logic to streamline the process.
- Renamed the
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated the method
_createRoutesto call the renamedsetDeliveriesPointsmethod from the controller. - Removed commented-out button code for improved code readability.
- Updated the method
-
lib/features/user_delivery/tab_bar_views/reservations/reservations_controller.dart:
- Cleaned up redundant spacing in the license comment block for consistency.
-
lib/managers/deliveries_manager.dart:
- Added a
FIXMEcomment to highlight a potential dependency issue forUserDeliveryStore. - Removed redundant
_setLoadingStateand_setErrorStatemethods to simplify state management. - Updated methods to directly set the store state (
setState) or call_setErrorto handle errors, improving code conciseness.
- Added a
This commit enhances the delivery map feature by modularizing map management and improving the consistency of state handling across the application. The introduction of a dedicated store (DeliveryMapStore) and controller (DeliveryMapController) results in cleaner code and easier maintainability, while also ensuring efficient resource management through proper initialization and disposal practices.
This commit includes the addition of new features such as a delivery map interface, along with various improvements and bug fixes across multiple files. Below are the detailed changes made:
-
assets/images/pin.png:
- Added a new image resource,
pin.png, which will be used for map markers in the delivery map view.
- Added a new image resource,
-
lib/common/models/address.dart:
- Corrected import typo from
model_finctions.darttomodel_functions.dartfor better accuracy.
- Corrected import typo from
-
lib/common/models/client.dart:
- Fixed import typo from
model_finctions.darttomodel_functions.dart.
- Fixed import typo from
-
lib/common/models/deliver_order.dart (new file):
- Added the
DeliveryOrderclass to represent a delivery order, containing information such as delivery ID, client name, address, phone number, and client location. - Introduced a method
fromDeliveryto createDeliveryOrderinstances fromDeliveryModel.
- Added the
-
lib/common/models/delivery.dart:
- Corrected import typo from
model_finctions.darttomodel_functions.dart.
- Corrected import typo from
-
lib/common/models/delivery_men.dart:
- Updated import path to correctly reference
model_functions.dart.
- Updated import path to correctly reference
-
lib/common/models/functions/model_functions.dart:
- Renamed from
model_finctions.darttomodel_functions.dartfor better clarity.
- Renamed from
-
lib/common/models/shop.dart:
- Fixed import typo from
model_finctions.darttomodel_functions.dart.
- Fixed import typo from
-
lib/features/user_admin/user_admin_page.dart:
- Removed redundant spacing in the GPL license comment block for consistency.
-
lib/features/user_business/user_business_page.dart:
- Cleaned up license comment block spacing.
-
lib/features/user_delivery/delivery_map/delivery_map_controller.dart (new file):
- Added
DeliveryMapControllerto handle Google Maps integration and manage map-related events.
- Added
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart (new file):
- Added
DeliveryMapPage, which provides a visual representation of the delivery map usingGoogleMaps. This includes features such as numbered markers for each delivery location.
- Added
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart:
- Added a
createBasicRoutesfunction to generate basic delivery routes based on the available deliveries. - Added a reference to the
NavigationRouteservice for route calculation.
- Added a
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Integrated
DeliveryMapPagefor route visualization. - Updated the floating action button to provide an option to create a route (
_createRoutes).
- Integrated
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_store.dart:
- Updated
deliveriesto useValueNotifierto track state changes reactively.
- Updated
-
lib/locator.dart:
- Registered the
NavigationRouteservice in the dependency locator.
- Registered the
-
lib/managers/deliveries_manager.dart:
- Replaced the internal distance calculation method with a call to
GeoLocation.calculateDistance().
- Replaced the internal distance calculation method with a call to
-
lib/my_material_app.dart:
- Added a route for
DeliveryMapPagein the application router.
- Added a route for
-
lib/repository/firebase_store/abstract_deliverymen_repository.dart:
- Removed deprecated
getCurrentGeoFirePointfunction from the interface.
- Removed deprecated
-
lib/repository/firebase_store/deliverymen_firebase_repository.dart:
- Removed local implementation of location permission handling, now replaced by
GeoLocation.
- Removed local implementation of location permission handling, now replaced by
-
lib/services/geo_location.dart (new file):
- Added a new service for handling geolocation operations, including calculating distances and obtaining the current location.
-
lib/services/navigation_route.dart (new file):
- Created a new
NavigationRouteservice to manage delivery routes, calculate optimized orders, and determine distances between delivery locations.
- Created a new
This commit introduces new features that allow delivery personnel to visualize and organize deliveries on a map using GoogleMaps, enhancing the delivery workflow. Several code improvements and bug fixes were implemented to increase maintainability, accuracy, and reliability of the system. The introduction of dedicated services for geolocation and route management makes the codebase more modular and easier to extend in the future.
This commit addresses several bugs within the user delivery and user manager pages of the application, enhances code consistency, and corrects delivery status transitions for better logic flow.
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated empty state message text from "Nenhuma entrega em andamento!" to "Scanneie os QRCode reservados no fornecedor." to provide better guidance to the delivery person.
-
lib/features/user_delivery/tab_bar_views/reservations/reservations_page.dart:
- Updated the text displayed when no deliveries are found from "Nenhuma entrega próxima encontrada!" to "Nenhuma entrega próxima para reservar!" for improved user clarity.
-
lib/features/user_delivery/user_delivery_page.dart:
- Removed redundant spacing in the GPL license comment block to maintain consistency across files.
-
lib/features/user_manager/tab_bar_views/manager_controller.dart:
- Added a line to nullify
_deliveriesSubscriptionafter it is canceled to prevent potential issues when the subscription is re-initialized.
- Added a line to nullify
-
lib/features/user_manager/tab_bar_views/show_delivery_list.dart:
- Renamed file from
show_delivery_list.darttomanager_list_view.dartfor a more descriptive and consistent naming convention. - Updated class name from
ShowDeliveryListtoManagerListViewand its internal state class accordingly. - Added
ctrl.dispose()to properly dispose of the controller and prevent resource leaks.
- Renamed file from
-
lib/features/user_manager/user_manager_page.dart:
- Updated references to the renamed file and class (
ManagerListViewinstead ofShowDeliveryList).
- Updated references to the renamed file and class (
-
lib/repository/firebase_store/abstract_deliveries_repository.dart:
- Modified the default value for
toStatusin theupdateDeliveryStatusmethod fromDeliveryStatus.orderInTransittoDeliveryStatus.orderPickedUpForDeliveryfor more accurate status progression.
- Modified the default value for
-
lib/repository/firebase_store/deliveries_firebase_repository.dart:
- Adjusted the default value of
toStatusinupdateDeliveryStatusmethod toDeliveryStatus.orderPickedUpForDelivery. - Modified the condition from
isGreaterThantoisEqualTofor delivery status filtering in thegetByDeliveryIdmethod to accurately retrieve deliveries at a specific status.
- Adjusted the default value of
These changes resolve several text-related bugs, improve class and file naming for maintainability, and correct the delivery status logic to ensure that the application handles delivery workflows as intended. Proper disposal of resources was also implemented to enhance application stability and performance.
This commit reinstates the DeliveryStatus.orderPickedUpForDelivery status that had been removed, and introduces updates to multiple files to ensure consistent usage of this status throughout the codebase. Additionally, GPLv3 license headers were added to all files in the lib/ directory, though these changes have been omitted from the diff to reduce its size.
-
lib/common/extensions/delivery_status_extensions.dart:
- Added
DeliveryStatus.orderPickedUpForDeliveryback to the enum list. - Updated the status descriptions with a new label: "Pedido Retirado para Entrega."
- Added an associated icon (
Symbols.deployed_code_rounded, with yellow color) for the reinstated status.
- Added
-
lib/common/models/delivery.dart:
- Reintroduced
DeliveryStatus.orderPickedUpForDeliveryto theDeliveryStatusenum, updating all subsequent status indices accordingly.
- Reintroduced
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart:
- Added
DeliveryStatusas a parameter to theinitmethod ofDeliveriesController. - Updated
_getDeliveries()to retrieve deliveries based on the new status.
- Added
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated
DeliveriesPageto include aDeliveryStatusparameter to manage different statuses more effectively. - Added a floating action button for adding deliveries.
- Updated
-
lib/features/user_delivery/tab_bar_views/show_delivery_list.dart:
- Modified
ShowDeliveryListto allow status-based operations. - Added a floating action button for QR code generation and delivery addition.
- Modified
-
lib/features/user_delivery/user_delivery_page.dart:
- Modified the tab controller to accommodate the reintroduced status.
- Added the "Preparando" tab for deliveries with the
orderPickedUpForDeliverystatus.
-
lib/features/user_manager/tab_bar_views/manager_controller.dart:
- Refactored
_deliveriesSubscriptionto properly fetch deliveries based on status. - Introduced a new
clearSelectionsmethod for clearing selected deliveries.
- Refactored
-
lib/features/user_manager/user_manager_page.dart:
- Updated tab bar to include the
orderPickedUpForDeliverystatus, reflecting this change in the UI. - Adjusted the floating action buttons and tab bar icons accordingly.
- Updated tab bar to include the
-
lib/repository/firebase_store/deliveries_firebase_repository.dart:
- Updated the repository methods to correctly query deliveries based on the newly reinstated status.
- Modified
getByManagerId()andgetByDeliveryId()methods to support filtering deliveries byorderPickedUpForDelivery.
These changes reintroduce the DeliveryStatus.orderPickedUpForDelivery status, improving the granularity of the delivery workflow. The reinstated status enables better tracking of deliveries during the transition between reservation and transit, while the updates to controllers, views, and repositories ensure seamless integration and usage throughout the app. The UI changes further enhance clarity for delivery personnel and managers.
This commit introduces the addition of the GNU General Public License (GPL) v3 to the project, as well as various code improvements, new features, and refactorings across multiple modules to enhance the delivery management and QR code functionalities.
-
LICENSE:
- Added the GNU General Public License (GPL) v3 to the project, ensuring that the software is shared under a copyleft license, promoting freedom to use, modify, and distribute.
-
android/gradle.properties:
- Commented out the
dev.steenbakker.mobile_scanner.useUnbundled=trueproperty to disable its use temporarily.
- Commented out the
-
lib/common/extensions/delivery_status_extensions.dart:
- Removed the
orderPickedUpForDeliverystatus from the extension methods. - Updated relevant icons and text mappings to reflect the updated statuses.
- Removed the
-
lib/common/models/delivery.dart:
- Removed the
orderPickedUpForDeliverystatus from theDeliveryStatusenum. - Updated the remaining statuses with corresponding index comments for better readability.
- Removed the
-
lib/common/utils/create_qrcode.dart:
- Added an import for
dart:convertto handle JSON encoding. - Modified the
_generateQRCodemethod to accept aMap<String, dynamic>instead of aStringto provide more structured data for QR code generation. - Adjusted text formatting within the PDF to make the
delivery.idbold and abbreviate address components for clarity.
- Added an import for
-
lib/features/qrcode_read/qrcode_read_page.dart:
- Refactored the
MobileScannerControllerinitialization to simplify the configuration. - Added
_startScanningcall withininitStateto automatically start scanning upon page load. - Streamlined the
disposemethod to ensure proper resource cleanup, including usingunawaitedto prevent blocking.
- Refactored the
-
lib/features/show_qrcode/show_qrcode.dart:
- Added a
FilledButtonlabeled "Próximo" to navigate back after viewing the QR code.
- Added a
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart (new file):
- Added a new controller to manage deliveries, handling state management and data fetching via Firestore.
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart (new file):
- Created a new page to list deliveries with a
DeliveryCardcomponent for each item. - Implemented interaction flow to read QR codes and update delivery status.
- Created a new page to list deliveries with a
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_store.dart (new file):
- Added a new store to manage state for deliveries, handling loading, success, and error states.
-
lib/features/user_delivery/tab_bar_views/reservations/reservations_controller.dart (new file):
- Created a controller for managing delivery reservations, including fetching nearby deliveries and updating the radius.
-
lib/features/user_delivery/tab_bar_views/reservations/reservations_page.dart (new file):
- Added a page to manage reservations, including sliders to adjust the radius for nearby deliveries and a list view to show available deliveries.
-
lib/features/user_delivery/user_delivery_page.dart:
- Updated the page to use a
TabBarfor separating reservations and deliveries into different views.
- Updated the page to use a
-
lib/features/user_manager/tab_bar_views/manager_controller.dart:
- Added a null assignment to
_deliveriesSubscriptionafter canceling it to ensure proper cleanup. - Updated delivery fetching logic to improve error handling.
- Added a null assignment to
-
lib/features/user_manager/user_manager_page.dart:
- Updated tab icons to reflect new status changes after removal of
orderPickedUpForDelivery. - Cleared
deliveriesSelectedafter navigating to the QR code page.
- Updated tab icons to reflect new status changes after removal of
-
lib/repository/firebase_store/abstract_deliveries_repository.dart:
- Added new methods
getByDeliveryIdandupdateDeliveryStatusto handle delivery updates based on delivery ID.
- Added new methods
-
lib/repository/firebase_store/deliveries_firebase_repository.dart:
- Implemented
updateDeliveryStatusto allow changing the status of a delivery document in Firestore. - Added
getByDeliveryIdto fetch deliveries assigned to a specific delivery ID. - Refined existing query logic to better handle status-based fetching of deliveries.
- Implemented
These updates add significant new functionality for delivery management, including better handling of reservations and status updates. The addition of the GNU GPL ensures that this software remains open and free, encouraging community collaboration.
This commit introduces enhancements in QR code generation, including visual refinements and a new page to display QR codes, improving the user experience and the flexibility of QR code usage. It also includes refactoring and the addition of a ShowQrcode page for better modularity.
-
lib/common/utils/create_qrcode.dart:
- Adjusted page format for QR code generation, setting dimensions to 350x450.
- Changed QR code image size from 200x200 to 300x300 for better readability.
- Added a
pw.TextStyleconstant for consistent styling of text fields. - Modified the layout to center-align all elements and added labels such as 'Key', 'Client', and address details with improved formatting and alignment.
- Set the QR code painter's
gaplessproperty totruefor better rendering quality.
-
lib/features/delivery_qrcode/delivery_qrcode.dart:
- Marked the
DeliveryQrcodeconstructor asconstto enable compile-time optimization where possible.
- Marked the
-
lib/features/show_qrcode/show_qrcode.dart (New File):
- Created the
ShowQrcodepage to display QR codes generated for deliveries. - Introduced a
convertPdfToImagemethod to convert PDF data to an image, allowing the generated QR code to be rendered as a visual component on the screen. - Added navigation functionality to return to the previous page and handled different states (loading, success, error) when displaying the QR code.
- Created the
-
lib/features/user_manager/user_manager_page.dart:
- Replaced the
logstatement in_showQRCodewith a navigation call to push theShowQrcodepage, passing the delivery data as arguments. - Updated
_showQRCodeto handle multiple deliveries using a loop and async navigation toShowQrcode.
- Replaced the
-
lib/my_material_app.dart:
- Added route handling for
ShowQrcode.routeName, allowing theShowQrcodepage to be accessible throughout the app. - Defined a new case in the
onGenerateRoutefunction to create a route for theShowQrcodepage with delivery data passed as arguments.
- Added route handling for
The addition of the ShowQrcode page and improvements to the QR code generation process enhance the usability of QR code features, providing a clearer, more accessible visual experience for users. The changes ensure better modularity and consistency across the app's functionalities.
Added the initial delivery QR Code generation functionality and updated the delivery card handling throughout the application.
-
Added Delivery SVG Icon
- Created and added the file
assets/svg/delivery.svg.
- Created and added the file
-
Updated Delivery Model
- Added a new property
selectedto theDeliveryModelclass inlib/common/models/delivery.dart. - Reorganized some properties to improve clarity.
- Added a new property
-
Created Delivery Info Model
- Added a new class
DeliveryInfoModelinlib/common/models/delivery_info.dartto simplify information transfer regarding deliveries.
- Added a new class
-
QR Code Generation Utility
- Added
lib/common/utils/create_qrcode.dartto generate QR Codes and export them as PDFs. - Moved QR Code generation logic from
DeliveryQrcodeControllerto this utility.
- Added
-
Updated Delivery Card and Custom ListTile
- Removed the
onTapparameter fromCustomListTileinlib/components/widgets/custom_list_tile.dart. - Updated
DeliveryCardinlib/components/widgets/delivery_card.dartto include selection functionality (selected) and added a button for additional actions.
- Removed the
-
Refactored User Business and User Admin Pages
- Modified
user_business_page.dartanduser_admin_page.dartto use the updatedDeliveryCardwidget with the newonTapproperty.
- Modified
-
Removed Unused Controllers
- Deleted the old
delivery_qrcode_controller.dartanduser_manager_store.dart, moving relevant logic to the newManagerControllerandManagerStoreclasses.
- Deleted the old
-
Introduced New User Manager Components
- Created
manager_controller.dart,manager_store.dart, andshow_delivery_list.dartto manage delivery-related workflows efficiently.
- Created
-
Updated Firebase Repository
- Enhanced
deliveries_firebase_repository.dartto support filtering deliveries by status.
- Enhanced
-
Removed Dependency
- Removed
signalsdependency frompubspec.yamland related packages frompubspec.lock.
- Removed
This commit enhances the app's delivery management features, including QR code generation and selection capabilities for deliveries, while removing redundant controllers and code to improve maintainability.
This commit introduces new custom widgets, such as CustomAppBar, CustomListTile, and a CustomDrawer, enhancing the modularity of the UI components. Additionally, the app's structural organization has been refined by breaking down larger classes into more manageable pieces.
-
lib/components/widgets/custom_app_bar/custom_app_bar.dart:
- Added a new widget called
CustomAppBarto provide a customizable app bar across different pages. - Implemented
ValueListenableBuilderfor brightness toggle using the controller.
- Added a new widget called
-
lib/components/widgets/custom_app_bar/custom_app_bar_controller.dart:
- Created a dedicated controller for the
CustomAppBarto manage settings fromAppSettings.
- Created a dedicated controller for the
-
lib/components/widgets/custom_list_tile.dart:
- Added a
CustomListTilewidget to create more customized and reusable list tiles with a leading icon, title, subtitle, and trailing widget.
- Added a
-
lib/components/widgets/delivery_card.dart:
- Refactored to use the newly added
CustomListTilefor a more consistent UI design. - Introduced an optional
qrCodeButtonto display a QR code for each delivery.
- Refactored to use the newly added
-
lib/components/widgets/main_drawer/custom_drawer.dart:
- Introduced a new
CustomDrawerwidget to replaceHomeDrawer, improving readability and modularity.
- Introduced a new
-
lib/components/widgets/main_drawer/custom_drawer_controller.dart (previously
home_controller.dart):- Renamed and moved the
HomeControllerto align it with theCustomDrawercomponent. - Cleaned up redundant methods and improved naming conventions for clarity.
- Renamed and moved the
-
lib/features/account/account_page.dart:
- Added UI elements to increase/decrease the size of QR codes dynamically.
-
lib/features/delivery_qrcode/:
- Added
delivery_qrcode.dartanddelivery_qrcode_controller.dartto manage the QR code generation and printing features. - Utilized the
printingandpdfpackages to allow QR code generation as PDFs.
- Added
-
lib/features/home/home_page.dart:
- Replaced the old
HomeDrawerwith the newCustomDrawerfor better modularization. - Cleaned up the navigation code and improved page controller initialization.
- Replaced the old
-
lib/features/user_*:
- Updated
UserAdminPage,UserBusinessPage,UserDeliveryPage, andUserManagerPageto utilize theCustomAppBarandCustomDrawer, ensuring UI consistency. - Added additional page controller parameters to enable cross-page management via the new
CustomDrawer.
- Updated
-
lib/features/qrcode_read/qrcode_read_page.dart:
- Modified the scanner controller lifecycle to handle multiple states effectively, preventing repeated activations of the camera when the page is not in use.
-
pubspec.yaml and pubspec.lock:
- Updated dependencies to include
printing,pdf,signals, and related packages required for the new features.
- Updated dependencies to include
The introduction of these custom widgets improves the consistency and maintainability of the codebase, while the modularized components simplify future updates. The refined UI elements ensure a seamless user experience across various parts of the app.
Add CheckReservedDeliveries Function and Updates to Deployment
This commit introduces a new scheduled function, checkReservedDeliveries, which verifies and resets reservations that have exceeded 5 minutes, ensuring that delivery slots are appropriately released for others if not picked up in time. Several updates were made to facilitate this addition and improve deployment automation.
-
Makefile
- Added new command
firebase_functions_deployto simplify the deployment of Firebase functions. - Added
schedule_cloundcommand to trigger thecheckReservedDeliveriesfunction locally via acurlcommand.
- Added new command
-
Firebase Cloud Functions (
functions/index.js)- Added
checkReservedDeliveriesfunction usingonScheduleto automatically verify and reset delivery reservations older than 5 minutes.- This function scans for deliveries with the
orderReservedForPickupstatus that were reserved more than 5 minutes ago and resets them. - It also updates the
updatedAttimestamp and nullifies fields such asdeliveryId,deliveryName, anddeliveryPhone.
- This function scans for deliveries with the
- Updated the
setUserClaimsfunction to specify thesouthamerica-east1region for consistency. - Refactored imports for better clarity, including
FieldValuefrom Firestore for timestamp updates.
- Added
-
Package Updates
- Updated dependencies in
functions/package-lock.jsonandfunctions/package.json.- Updated
firebase-functionsfrom version4.3.1to6.0.1for compatibility with the new function. - Updated related packages to ensure alignment with the latest Firebase and ESLint requirements.
- Updated
- Updated dependencies in
-
UI Enhancements (
lib/components/widgets/delivery_card.dart)- Updated the UI of
DeliveryCard.- Changed the card color from
surfaceContainertosurfaceContainerHighfor better visibility. - Improved the layout of the
subtitleto create a clearer visual separation between pickup and delivery information.
- Changed the card color from
- Updated the UI of
-
Dependencies Management (
package.json)- Added
@google-cloud/firestorefor more direct Firestore interactions. - Updated
firebase-adminto version12.6.0and added development dependencies foreslint.
- Added
The new checkReservedDeliveries function ensures that delivery reservations are canceled if they are not picked up within the expected time, improving the efficiency of the delivery system. Additional improvements include enhancements to the UI and simplifications in deployment workflows.
This commit introduces key updates to enhance the organization and handling of delivery information across the application. The changes include modifications to model classes, addition of new UI widgets, and adjustments to store and controller components to better reflect shop-level data and improve user interaction with the delivery system.
-
lib/common/models/shop_delivery_info.dart
- Added new getters
phoneandaddressto provide access to the shop's phone number and address from the first delivery in the list. - These changes enable better encapsulation and easier access to shop-related data within the model.
- Added new getters
-
lib/components/widgets/shop_card.dart (new file)
- Introduced
ShopCardwidget to display information about a shop, including its deliveries. - Added parameters for
shopInfo,action,isExpanded, andonExpansionChangedto manage the UI state and user interactions effectively. - Implemented an
ExpansionTileto show detailed shop information, including the number of deliveries and shop contact details.
- Introduced
-
lib/features/user_delivery/stores/user_delivery_store.dart
- Updated
deliveriesto useObservableList<ShopDeliveryInfo>instead ofDeliveryExtended, reflecting the new focus on shop-level data. - Modified
setDeliveriesmethod to accommodate the updatedShopDeliveryInfomodel, ensuring consistency in data handling.
- Updated
-
lib/features/user_delivery/user_delivery_controller.dart
- Renamed
changeStatusreference tochangeDeliveryStatusfor better clarity and consistency in the codebase.
- Renamed
-
lib/features/user_delivery/user_delivery_page.dart
- Replaced
DeliveryCardusage withShopCardto display shop-level data, reflecting the updated model. - Introduced
_expandedStatemap to manage the expanded state of eachShopCard, providing a better user experience when interacting with multiple shops.
- Replaced
-
lib/managers/deliveries_manager.dart
- Updated
_processeNearbyDeliveriesto useShopDeliveryInfoinstead ofDeliveryExtended, enhancing the organization of data at the shop level. - Modified the
_mapShopDeliveryInfoStreammethod to group deliveries by shop, allowing for more efficient data handling and improved structure. - Added a new transformer
_deliveryToShopInfoTransformerto convertDeliveryModelstreams intoShopDeliveryInfostreams, encapsulating multiple deliveries under a single shop entry. - Updated the subscription logic to
_subscribeToShopDeliveries, ensuring the store receives grouped shop information rather than individual deliveries.
- Updated
These updates significantly enhance the delivery system by organizing data around shops rather than individual deliveries, providing a more cohesive structure that simplifies both backend management and frontend presentation. This refactoring effort leads to a clearer, more maintainable codebase, and an improved user experience for interacting with shop and delivery information.
This commit introduces several improvements and optimizations to enhance the delivery system's functionality and maintainability. These changes include modifications to model classes, widget updates, controller adjustments, and manager class refinements, all contributing to a more streamlined and efficient codebase.
-
lib/common/models/shop_delivery_info.dart
- Imported
delivery_extended.dartto includeDeliveryExtendedinformation in the model. - Added a
deliveriesattribute of typeList<DeliveryExtended>to store extended delivery information for each shop. - Added a
lengthgetter to provide the number of deliveries in the list. - Removed the
numberOfDeliveriesattribute as it is now inferred from thedeliverieslist.
- Imported
-
lib/components/widgets/delivery_card.dart
- Updated the phone number display in the
subtitleto include a phone emoji (📞), providing a clearer representation for users.
- Updated the phone number display in the
-
lib/features/user_delivery/user_delivery_controller.dart
- Renamed the method reference
changeStatustochangeDeliveryStatusto improve clarity and consistency.
- Renamed the method reference
-
lib/managers/deliveries_manager.dart
- Refactored
getNearbyDeliveriesandrefreshNearbyDeliveriesmethods to use_setLoadingState()and_setErrorState()for better code reuse and readability. - Replaced
changeStatusmethod withchangeDeliveryStatus, and moved the logic for updating the delivery status into a new private method_getUpdatedDeliveryStatusto streamline the code. - Updated
_processeNearbyDeliveriesto use_subscribeToDeliveriesfor managing delivery subscriptions. - Introduced
_deliveryToExtendedTransformerto transform streams ofDeliveryModelintoDeliveryExtended, improving the reusability and separation of concerns in the code. - Added
_setLoadingState()and_setErrorState()utility methods to manage store states more effectively and reduce repetition.
- Refactored
These updates improve the structure and readability of the delivery system's code, enhance the reusability of functions, and make the entire flow more maintainable and scalable. The refactoring efforts lead to better code quality while maintaining the intended functionalities of the application.
This commit introduces significant updates to the delivery system, aimed at enhancing functionality, optimizing performance, and simplifying the management of deliveries. The changes include updates to the build configurations, new model classes for better data encapsulation, and the introduction of a dedicated manager to centralize delivery-related business logic. These improvements are expected to streamline the delivery workflow, reduce redundancy, and make the system more maintainable and scalable.
-
android/app/build.gradle
- Updated
sourceCompatibilityandtargetCompatibilityfrom Java 1.8 to Java 11 to leverage modern Java features and improve compatibility. - Changed
jvmTargetinkotlinOptionsfrom 1.8 to 11, ensuring alignment with the updated Java version.
- Updated
-
android/app/google-services.json.old
- Deleted the old
google-services.jsonconfiguration file as it is no longer needed, reducing potential confusion and ensuring the project uses the correct configuration.
- Deleted the old
-
android/build.gradle
- Removed forced jvmTarget settings across all modules to allow for more flexible configurations.
- Cleaned up redundant comments and updated dependencies to improve readability and maintainability of the build script.
-
lib/common/models/delivery_extended.dart (new file)
- Added
DeliveryExtendedclass to extendDeliveryModelwith an additionaldistanceFromShopattribute, providing more detailed information about deliveries. - Included methods to create
DeliveryExtendedfromDeliveryModeland convert back, ensuring compatibility and ease of use.
- Added
-
lib/common/models/shop_delivery_info.dart (new file)
- Introduced
ShopDeliveryInfoclass to encapsulate shop name, number of deliveries, and distance, providing a concise representation of shop delivery information.
- Introduced
-
lib/features/user_delivery/stores/user_delivery_store.dart
- Updated
deliveriesto useObservableList<DeliveryExtended>instead ofDeliveryModel, enabling the use of extended delivery information. - Modified
setDeliveriesmethod to accommodate the newDeliveryExtendedmodel, ensuring proper data handling.
- Updated
-
lib/features/user_delivery/user_delivery_controller.dart
- Refactored to use the new
DeliveriesManagerclass, centralizing the delivery-related logic. - Removed previous code for manually managing delivery locations and streams, simplifying the controller's responsibilities.
- Updated initialization and subscription management to use
DeliveriesManagermethods, improving code organization and maintainability.
- Refactored to use the new
-
lib/features/user_delivery/user_delivery_page.dart
- Removed unused
userIdandradiusInKmvariables from the initialization process, cleaning up the code. - Updated UI elements to reflect new delivery status management, including the use of
refreshNearbyDeliveriesfor better user experience.
- Removed unused
-
lib/managers/deliveries_manager.dart (new file)
- Created
DeliveriesManagerclass to centralize delivery-related business logic, making the system more modular and easier to maintain. - Implemented methods for initializing user location, fetching nearby deliveries, and changing delivery statuses, providing a clear separation of concerns.
- Provided utilities for mapping and listening to extended delivery streams, as well as calculating distances, to enhance the accuracy and efficiency of delivery management.
- Created
These changes collectively aim to enhance the delivery system by introducing modularity, improving data handling, and centralizing business logic. The refactoring efforts reduce redundancy, making the codebase more organized and easier to maintain, while the new features provide additional functionality to support a more robust delivery process. Se terminou, para que o
This commit introduces several updates to the DeliveryModel class, controller, repository, and relevant UI components to improve functionality and provide more complete information for delivery entities. The changes encompass additions to data models, modifications in business logic, and UI updates for enhanced user interaction.
- Delivery Model Update
- New Field Added:
deliveryPhonewas added toDeliveryModelto store the delivery person's phone number. - Class Modifications:
- Added
deliveryPhonefield to the constructor,copyWithmethod,toMapmethod, andfromMapmethod. - Updated
toString,==operator, andhashCodeto incorporate the newdeliveryPhonefield.
- Added
- Delivery Card Widget Update
- Updated the
DeliveryCardwidget to provide more detailed information about both the shop and client.- The card now shows the shop name and address, and the client's phone number, with improved formatting for phone numbers.
- Added a private method
_cleanPhoneto clean phone numbers for display.
- User Delivery Controller Update
- UserStore Update: Changed the reference from
userto_userfor consistency, while maintaining the originaluseras a separate reference for current use. - Status Update Method: Added
changeStatusmethod inUserDeliveryControllerto allow the delivery person to change the status of a delivery.- The method toggles the delivery status between
orderRegisteredForPickupandorderReservedForPickup. - It also updates the
deliveryId,deliveryName, anddeliveryPhonefields in theDeliveryModel.
- The method toggles the delivery status between
- User Delivery Page Update
- Removed unnecessary dialog and button actions for displaying delivery details.
- Updated the
DeliveryCardwidget to use thechangeStatusmethod from the controller instead of showing details.
- Abstract Deliveries Repository Interface Update
- Added a new
updateStatusmethod to update the status of a delivery.
- Deliveries Firebase Repository Update
- Updated the implementation of the
updateStatusmethod to modify the status and related delivery information in Firestore.- Adjusted Firestore references and
WriteBatchoperations for efficient data handling.
- Adjusted Firestore references and
- Refactored the retrieval and update of delivery models with enhanced error handling and consistency in method names.
This commit primarily focuses on adding new functionality to manage the phone number of delivery personnel, along with significant improvements in updating and managing delivery statuses, user interactions, and overall data consistency across the app.
This commit involves several improvements to the delivery management system, focusing on enhancing CRUD operations for the DeliverymenModel and ensuring better compatibility with Firestore.
lib/common/models/delivery_men.dart
- Fixed the import path of
model_finctions.dartto make it consistent and relative.
lib/features/user_delivery/user_delivery_controller.dart
- Changed the method used to add a new deliveryman from
add()toset(). This change reflects a more descriptive naming convention, providing a clearer understanding of the operation being performed.
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Commented out unimplemented methods,
updateStatus()andstreamShopByName(), to avoid confusion and streamline the code.
lib/repository/firebase_store/abstract_deliverymen_repository.dart
- Changed the method
add()toset()to make it consistent with its actual operation. - Added new methods for retrieving (
get()) and deleting (delete()) a deliveryman.
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Added the
dart:mathlibrary import for additional mathematical operations. - Defined constants for key fields to ensure consistency across the codebase, such as
keyCreatedAtandkeyUpdatedAt. - Improved logging messages for more accurate representation of delivery operations.
- Modified the
getNearby()method to limit the number of deliveries returned to 30 for better performance. - Added a helper function
_calculateDistanceSimple()to compute the distance between twoGeoPointobjects in a simple way.
lib/repository/firebase_store/deliverymen_firebase_repository.dart
- Implemented the
get()method to retrieve a deliveryman from Firestore, including error handling and logging. - Implemented the
delete()method to remove a deliveryman from Firestore, ensuring proper error management. - Refactored the
updateLocation()andset()methods to simplify their functionality and make use of the new helper function_updateLocation(). - Added
_deliverymenReference()helper method to provide a reusable document reference forDeliverymenModelusingwithConverter()for Firestore integration.
These changes enhance the delivery management workflow by standardizing CRUD operations, improving code readability, and optimizing the integration with Firestore. This refactoring also includes the introduction of helper functions to simplify repetitive tasks, ensuring that the deliverymen data is managed more effectively and consistently.
This commit introduces a set of improvements focused on enhancing code readability, maintainability, and extending functionality for delivery cards and status management.
-
Delivery Status Enum Update:
- Added a new delivery status:
orderReservedForPickup. - Updated the
DeliveryStatusExtensionto include this new status, along with its string representation and corresponding icon.
- Added a new delivery status:
-
Icon Handling Improvement:
- Refactored the
icongetter forDeliveryStatusto return anIconwidget directly instead of just anIconData, which allows for custom styling such as colors for each delivery status.
- Refactored the
-
Markdown Parsing Enhancement:
- Improved the
MarkdowntoRichTextwidget to utilize a combined regular expression for parsing bold and italic text, resulting in more efficient text processing. - This ensures that all markdown-like strings are correctly converted into rich text within the app, providing a better user experience.
- Improved the
-
Delivery Card Widget Refactoring:
- Updated the
DeliveryCardwidget to use theMarkdowntoRichTextfor rendering delivery information, improving consistency across the app. - Removed the explicit use of
showInMapand replaced it with a more genericactioncallback, allowing for more flexible reuse of theDeliveryCard.
- Updated the
-
UI Component Consolidation:
- Replaced individual widget tree components used in several ListTiles with the new
DeliveryCardwidget to unify the delivery UI representation across different parts of the app. - This change was applied in multiple pages (
user_admin_page.dart,user_business_page.dart,user_delivery_page.dart, etc.) to ensure consistency in the delivery-related UI.
- Replaced individual widget tree components used in several ListTiles with the new
-
Query Enhancement for Deliveries:
- Added a custom query filter in
DeliveriesFirebaseRepositoryto allow fetching deliveries by specific statuses, starting withorderRegisteredForPickup. - Refined the existing geospatial query to use a custom
queryBuilder, providing more flexibility in delivery data retrieval.
- Added a custom query filter in
lib/common/extensions/delivery_status_extensions.dart
- Added new case
orderReservedForPickuptostatusTextandicongetters. - Updated
icongetter to return a fully styledIconwidget with different colors per status.
lib/common/models/delivery.dart
- Introduced a new
DeliveryStatus:orderReservedForPickup.
lib/common/utils/markdown_to_rich_text.dart
- Combined bold and italic regex into a single regular expression for better performance and simplified text parsing logic.
lib/components/widgets/delivery_card.dart
- Replaced
showInMapcallback with a genericactioncallback to allow for more diverse actions upon card interaction. - Utilized
MarkdowntoRichTextto display delivery details more effectively.
- UI Pages Update (
user_admin_page.dart,user_business_page.dart,user_delivery_page.dart)
- Replaced individual implementations of delivery list items with the new
DeliveryCardwidget for consistency.
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Added
geopointFrommethod to extract geospatial data from Firestore documents. - Introduced a
queryBuilderfunction to filter deliveries by specific statuses. - Updated the
getNearbymethod to use the newqueryBuilderfor refined delivery data retrieval.
These changes bring consistency to the UI components used across different pages, enhance the delivery status management, and improve the maintainability of the code by consolidating functionality into reusable components. Furthermore, the new query capabilities in the repository facilitate more efficient and targeted data fetching, optimizing the app's performance.
This commit focuses on refactoring the way deliverymen's geolocation data is managed. The core goal is to replace the LocationService class with a new repository structure that offers a more modular and repository-oriented approach to handling deliverymen's data and location services.
-
Introduction of
DeliverymenFirebaseRepository:- Created a new repository class,
DeliverymenFirebaseRepository, that directly manages CRUD operations for deliverymen data within Firebase. - Implemented functions to handle the addition (
add) and update (updateLocation) of deliverymen data in Firestore, simplifying location management.
- Created a new repository class,
-
Abstracted Location Management:
- Introduced an abstract class,
AbstractDeliverymenRepository, which provides an interface for deliverymen operations such as obtaining the current location and updating deliverymen details. - Removed the
LocationServiceclass entirely, as its responsibilities have now been distributed and refactored into the repository pattern.
- Introduced an abstract class,
-
User Delivery Controller Refactoring:
- Updated the
UserDeliveryControllerto useDeliverymenFirebaseRepositoryinstead of the previousLocationService. - Refactored methods for creating and updating deliverymen location to utilize the new repository methods, improving separation of concerns.
- Updated the
lib/features/user_delivery/user_delivery_controller.dart
- Removed the import for
LocationServiceand added imports forAbstractDeliverymenRepositoryandDeliverymenFirebaseRepository. - Replaced all instances where
locationServicewas used with appropriate methods fromdeliverymenRepository. - Removed direct calls to location services and used the repository to handle location updates and creation.
- New File:
lib/repository/firebase_store/abstract_deliverymen_repository.dart
- Created an abstract class
AbstractDeliverymenRepositoryto define the contract for operations involving deliverymen, including getting the current location, adding, and updating deliverymen in Firestore. - This abstraction allows for better flexibility and testability, adhering to dependency inversion principles.
- New File:
lib/repository/firebase_store/deliverymen_firebase_repository.dart
- Implemented the
DeliverymenFirebaseRepositoryclass, which extendsAbstractDeliverymenRepository. - Handles all Firebase-related operations for deliverymen, including:
- Getting Current Location: Implements permissions handling and uses the
Geolocatorpackage to get the user's current position. - Adding Deliverymen: Adds new deliverymen entries with geolocation data to Firebase.
- Updating Deliverymen Location: Updates existing deliverymen's geolocation data in Firebase.
- Getting Current Location: Implements permissions handling and uses the
- This class serves as the new centralized point for managing deliverymen data in Firestore, providing a more maintainable and structured approach.
- Removed File:
lib/services/location_service.dart
- Deleted the
LocationServiceclass as its responsibilities were moved intoDeliverymenFirebaseRepository. - This removal simplifies the codebase by centralizing the deliverymen-related logic within the repository layer.
This refactoring improves code maintainability, testability, and follows best practices for modular design by adopting the repository pattern for managing deliverymen's geolocation data. The new structure aligns well with scalable software architecture, making future changes and extensions easier to manage.
This commit includes the following major changes and refactoring:
-
Package Update:
- Replaced the deprecated
geoflutterfire2package with the newergeoflutterfire_pluspackage across all files, ensuring compatibility and enhanced functionality for handling geospatial data. - Updated the
pubspec.yamlfile to includegeoflutterfire_plusversion^0.0.31and removed references to the deprecatedgeoflutterfire2package.
- Replaced the deprecated
-
Model Updates:
- Replaced references to
GeoPointandgeohashwithGeoFirePointattributes in models and refactored all related methods to use the newGeoFirePointdata type. - Updated the
DeliverymenModel,ClientModel, andAddressModelto utilizeGeoFirePointfor location data.
- Replaced references to
-
Functionality Adjustments:
- Modified the
getNearbymethod inDeliveriesFirebaseRepositoryto usegeoflutterfire_plus'sGeoCollectionReferencefor optimized querying of nearby deliveries. - Refactored the
LocationServiceto handle location updates usingGeoFirePointinstead of individualGeoPointattributes, streamlining the process of updating and retrieving geographical data.
- Modified the
lib/common/models/address.dart
- Changed
geoflutterfire2imports togeoflutterfire_plus. - Updated the
locationattribute to useGeoFirePointfrom the new package. - Adjusted all related methods and constructors to reflect this change.
lib/common/models/client.dart
- Replaced the import from
geoflutterfire2togeoflutterfire_plus. - Updated the
locationattribute and constructors to work with the newGeoFirePointdata type.
lib/common/models/delivery.dart
- Similar changes as above: replaced the
GeoPointattributes withGeoFirePoint. - Updated all methods, constructors, and utility functions to use
GeoFirePoint.
lib/common/models/delivery_men.dart
- Replaced
GeoPointandgeohashattributes with a singleGeoFirePoint location. - Updated methods such as
toMap,fromMap, andcopyWithto handle the newGeoFirePointdata type.
lib/common/models/functions/models_finctions.dart→lib/common/models/functions/model_finctions.dart
- Renamed to match naming conventions.
- Adjusted the
mapToGeoFirePointfunction to work with the newGeoFirePointstructure fromgeoflutterfire_plus.
lib/common/utils/address_functions.dart
- Updated
getGeoPointFromAddressStringto returnGeoFirePointinstead ofGeoPoint.
lib/features/user_delivery/user_delivery_controller.dart
- Updated the location management for deliverymen to use
GeoFirePointinstead ofGeoPoint. - Refactored the methods for creating and updating location data using the
geoflutterfire_pluspackage.
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Refactored the
getNearbymethod to useGeoCollectionReferencefromgeoflutterfire_plus, providing better geospatial querying capabilities.
lib/services/location_service.dart
- Updated the methods for location updates to use
GeoFirePoint. - Simplified the
_getCurrentGeoFirePointfunction to return aGeoFirePointinstead of separate latitude and longitude values.
pubspec.yaml
- Updated dependencies:
- Added
geoflutterfire_plus: ^0.0.31. - Removed
geoflutterfire2references.
- Added
This commit primarily focuses on replacing the deprecated geoflutterfire2 package with geoflutterfire_plus, updating all relevant models, services, and repositories to work with the new geospatial data structures.
This commit primarily involves refactoring and updating models, controllers, and services to leverage GeoFirePoint from the GeoFlutterFire2 package instead of using GeoPoint directly. It improves the geographical data handling in models and ensures consistency in how coordinates are managed across different parts of the application.
Files Added:
lib/common/models/functions/models_finctions.dart
- Purpose:
- Provides a utility function
mapToGeoFirePointto convert a map of coordinates into aGeoFirePointobject, centralizing this logic for reuse across models.
- Provides a utility function
Files Modified:
lib/common/models/address.dart
- Geographical Data Update:
- Replaced
GeoPointandgeohashattributes withGeoFirePoint location, simplifying location handling. - Updated all related methods and constructors to accommodate the change, including
fromMap,toMap, andcopyWith.
- Replaced
lib/common/models/client.dart
- Geographical Data Refactor:
- Replaced
geopointandgeohashattributes withGeoFirePoint location. - Refactored constructors and utility methods like
toMapandfromMapto work withGeoFirePoint. - Removed deprecated JSON handling methods that relied on
GeoPoint.
- Replaced
lib/common/models/delivery.dart
- Model Update:
- Replaced
geopointandgeohashwithGeoFirePointattributesclientLocationandshopLocationto handle geographical data. - Adjusted all constructors and methods to use
GeoFirePointobjects instead of individual latitude and longitude values.
- Replaced
lib/common/models/shop.dart
- Geographical Refactor:
- Similar to other models, replaced
GeoPointandgeohashwith a singleGeoFirePoint locationattribute. - Updated methods and constructors accordingly, ensuring consistency in the way geographical data is managed.
- Similar to other models, replaced
lib/common/utils/address_functions.dart
- Geographical Function Update:
- Removed the
createGeoPointHashmethod, asGeoFirePointnow handles the geohash generation. - Refactored
getGeoPointFromAddressStringto returnGeoFirePointinstead ofGeoPoint.
- Removed the
lib/features/add_client/add_client_controller.dart
- Model Update:
- Replaced references to
geopointandgeohashin the client creation process with thelocationattribute, reflecting the change inAddressModel.
- Replaced references to
lib/features/add_delivery/add_delivery_controller.dart
- Delivery Model Update:
- Updated the creation of the
DeliveryModelto use the newGeoFirePointattributes forclientLocationandshopLocation.
- Updated the creation of the
lib/features/add_shop/add_shop_controller.dart
- Shop Model Update:
- Modified the shop creation process to use
GeoFirePoint locationinstead ofGeoPoint.
- Modified the shop creation process to use
lib/features/user_delivery/user_delivery_controller.dart
- Location Management Refactor:
- Refactored location handling to use
GeoFirePointfor delivery personnel locations, ensuring consistent usage of the geographical library across the application. - Implemented new methods
createLocationandupdateLocationto streamline location updates for delivery personnel.
- Refactored location handling to use
lib/repository/firebase_store/abstract_client_repository.dart
- Method Update:
- Renamed
streamClientByNametostreamAllClientsto reflect its purpose more clearly.
- Renamed
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Parameter Update:
- Changed the parameter name
locationtogeopointto better reflect its usage and ensure compatibility with theGeoFirePointrefactor.
- Changed the parameter name
lib/services/location_service.dart
- Location Service Refactor:
- Introduced the
createLocationandupdateLocationmethods to handle delivery personnel locations more robustly. - Added
_getCurrentGeoFirePointto centralize the logic of obtaining the current geographical point and geohash.
- Introduced the
lib/features/map/map_page.dart
- Map Update:
- Adjusted the map page to use
GeoFirePointattributes when determining positions, aligning with the rest of the app’s refactored location handling.
- Adjusted the map page to use
lib/stores/user/user_store.dart
- State Management Update:
- Added
deliverymenas a new observable attribute to track the delivery personnel’s information, including their current location.
- Added
This commit refactors geographical data handling across the application, replacing GeoPoint and geohash with the more streamlined GeoFirePoint class. These changes improve the consistency and efficiency of geographical operations while also aligning the codebase with the GeoFlutterFire2 package’s best practices.
This commit refactors and enhances the client and delivery handling functionalities, improving state management, code clarity, and modularization. It introduces new methods for navigating between client-related pages and refines several store interactions to ensure consistency across the application.
Files Modified:
lib/features/add_client/add_cliend_page.dart
- Behavioral Update:
- Added a condition to immediately return to the previous screen if no edits were made, enhancing user flow and preventing unnecessary state changes.
- Bug Fix:
- Implemented
store.isValid()check before saving the client, ensuring data integrity.
- Implemented
lib/features/add_client/add_client_controller.dart
- Repository Update:
- Renamed the
repositoryvariable toclientRepositoryfor better clarity.
- Renamed the
- Data Initialization:
- Refactored the
_setClientValues()method to asynchronously fetch and set address details if not already provided, reducing potential errors and centralizing address initialization logic.
- Refactored the
lib/features/add_delivery/add_delivery_controller.dart
- Repository Initialization:
- Refactored repository initializations to use
Abstracttypes, improving adherence to dependency inversion principles and ensuring the controller can work with different repository implementations if necessary.
- Refactored repository initializations to use
lib/features/add_delivery/add_delivery_page.dart
- Navigation Logic:
- Added
_addClientand_editClientmethods for navigating to the Add Client page. This provides a consistent way to add or edit clients directly from the delivery page.
- Added
lib/features/add_delivery/widgets/build_main_content_form.dart
- Widget Update:
- Enhanced
BuildMainContentFormto includeaddClientandeditClientcallbacks, allowing user navigation to client management screens. - Adjusted list rendering logic to include options for adding and editing clients, improving the user experience.
- Enhanced
lib/features/clients/clients_controller.dart
- Redundant Logic Removal:
- Removed
editClientmethod fromClientsControllersince the navigation logic is now handled within theClientsPagewidget, centralizing navigation concerns.
- Removed
lib/features/clients/clients_page.dart
- Navigation Logic Update:
- Replaced the call to
ctrl.editClientwith direct navigation logic, ensuring consistency in navigating to the Add Client page and simplifying the controller's responsibilities.
- Replaced the call to
This commit streamlines the process of adding and editing clients within the app. By shifting navigation logic out of controllers and into the pages themselves, it maintains a clean separation of concerns and enhances code maintainability. Additionally, the refactor improves user flow by introducing conditions that prevent unnecessary navigation or state changes based on the form's current state.
This commit refactors the BigButton widget and introduces enhancements to the AddDeliveryStore and BuildMainContentForm classes. The changes focus on improving button usability, restructuring form state handling, and centralizing widget behavior.
Files Modified:
lib/components/widgets/big_bottom.dart
- Feature Enhancement:
- Added an
enableparameter to control the button's enabled/disabled state. - Button's color and text style now dynamically adjust based on the
enablestate.
- Added an
- UI Improvements:
- The
onPressedcallback is set tonullwhen the button is disabled, preventing user interaction. - Disabled buttons use a different color from the
colorScheme, improving visual feedback.
- The
lib/features/add_delivery/stores/add_delivery_store.dart
- Logging Removal:
- Removed unnecessary
logstatement from theselectClientaction to reduce console clutter.
- Removed unnecessary
- Validation Method:
- Added an
isValid()method to encapsulate the validation logic for the store's current state, ensuring all required fields are populated before allowing certain actions.
- Added an
lib/features/add_delivery/widgets/build_main_content_form.dart
- StatefulWidget Conversion:
- Converted
BuildMainContentFormfrom a StatelessWidget to a StatefulWidget to manage focus nodes and reactions more effectively.
- Converted
- Focus Management:
- Introduced focus nodes (
searchByNameFocus,searchByPhoneFocus) to manage input focus and unfocus logic. - Added a MobX reaction to unfocus all input fields when the search mode changes, providing a better user experience.
- Introduced focus nodes (
- Validation Binding:
- Integrated
isValid()fromAddDeliveryStorewith theBigButtonwidget, allowing the button to enable/disable based on the form's state.
- Integrated
lib/features/add_delivery/stores/add_delivery_store.dart
- State Management Refactor:
- Removed redundant logging statements and restructured the
isValidlogic for determining when a client and shop are selected. - Introduced a
reset()method to encapsulate store state resetting, ensuring consistency when clearing the form.
- Removed redundant logging statements and restructured the
This commit refines the BigButton component and enhances form state management for the AddDeliveryStore. The overall result is a more responsive UI with clear state-based interaction handling, improved focus management, and a more maintainable code structure.
This commit introduces various changes to the AddClient and AddShop features, refactoring code to improve state management, centralizing common operations, and enhancing the user experience.
Files Modified:
lib/features/add_client/add_cliend_page.dart
- File Import Refactor:
- Changed all imports to use relative paths (
import '/common/...') to ensure consistency across the project.
- Changed all imports to use relative paths (
- Improved Routing:
- Updated route name for better readability:
'addclient'to'add_client'.
- Updated route name for better readability:
- Navigation Improvement:
- Enhanced back navigation handling, ensuring the page only pops when mounted and passes the updated client model.
- Dropdown Handling:
- Added
nullcheck before updatingaddressTypeto avoid potential runtime errors.
- Added
lib/features/add_client/add_client_controller.dart
- Dependency Injection:
- Utilized
AbstractClientRepositoryfor repository abstraction, enabling better testing and flexibility.
- Utilized
- Refactored Address Handling:
- Introduced getter method for
addressto fetch it directly from the store. - Added a reaction to update the address when
resetAddressStringchanges, ensuring the UI is always in sync with state changes.
- Introduced getter method for
- Enhanced Error Handling:
- Provided more descriptive error messages for connectivity issues and invalid ZIP codes.
- Memory Management:
- Included a disposer for the reaction to prevent memory leaks.
lib/features/add_client/stores/add_client_store.dart
- Store State Refactoring:
- Removed the redundant
addressobservable and consolidated its state management in a single place. - Added actions to handle setting and resetting address strings and states (
setAddressString,toogleAddressString). - Improved observability of
resetAddressStringandresetZipCodeflags to centralize their usage.
- Removed the redundant
lib/features/add_shop/add_shop_controller.dart
- Removed Redundant Getters:
- Removed
isEdited,isValid, andstategetters to simplify code access. These can be directly accessed through the store.
- Removed
- Improved Error Handling:
- Introduced clearer error messages for ZIP code validation failures, differentiating between connectivity and invalid format errors.
lib/features/add_shop/add_shop_page.dart
- File Import Refactor:
- Changed all imports to use relative paths (
import '/common/...') for consistency.
- Changed all imports to use relative paths (
- Simplified Store Access:
- Replaced direct controller state access (
ctrl) with store references for attributes likeisValidandisEdited.
- Replaced direct controller state access (
- UI Enhancement:
- Added dynamic titles based on the mode (
Adicionar Lojavs.Editar Loja).
- Added dynamic titles based on the mode (
lib/features/add_shop/stores/add_shop_store.dart
- State Correction:
- Fixed an incorrect reset action (
resetZipCodeChanged) to properly update thezipCodeChangedstate instead ofupdateGeoPoint.
- Fixed an incorrect reset action (
This commit brings structural and state management improvements to the AddClient and AddShop features, providing better code maintainability, improved state handling, and enhanced error feedback mechanisms.
This commit refactors the AddDelivery feature, improving the controller and state management, introducing a modular structure with reusable components, and enhancing error handling and UI consistency.
lib/features/add_delivery/add_delivery_controller.dart
- Simplified Initialization:
- Removed the redundant
refreshShops()call during initialization. - Adjusted state handling in
setShopIdbased on shop availability. - Set shop state after retrieving shops and updated the list of shops in the store.
- Removed the redundant
lib/features/add_delivery/add_delivery_page.dart
- UI Handling Enhancements:
- Improved navigation handling when creating a delivery. The page now only closes upon successful creation.
- Refactored loading and error state handling into the new
ErrorCardwidget. - Replaced inline main content rendering logic with a new modular widget
BuildMainContentForm.
lib/features/add_delivery/stores/add_delivery_store.dart
- State Management Improvements:
- Added
reset()action to clear the store state, ensuring a clean slate on initialization. - Updated
setShops()to setnoShopsStatebased on the shop list content.
- Added
lib/features/add_delivery/widgets/build_main_content_form.dart
- Modularized Main Content:
- Extracted main content rendering logic from
AddDeliveryPageinto a separate widget for better maintainability and modularity. - Manages the shop selection, client search, and client list display functionalities.
- Extracted main content rendering logic from
lib/features/add_delivery/widgets/error_card.dart
- Reusable Error Card:
- Created a reusable
ErrorCardwidget to standardize error handling and display across the feature. - Supports custom title, message, icon, and color parameters for flexibility.
- Created a reusable
This commit refactors the AddDelivery feature by separating concerns into distinct widgets, enhancing state management, and improving code readability. These changes make the codebase more maintainable and the UI more responsive and user-friendly.
This commit introduces enhancements to the ClientModel and ShopModel classes for JSON serialization and deserialization. It also improves address handling in the AddShopController, refactors the shop repository methods to use streams, and restructures the shop management flows based on the user roles. Additional UI adjustments were made for better consistency and functionality.
Files Modified:
lib/common/models/client.dart
- Enhanced Serialization and Deserialization:
- Added logic to handle
geopointserialization and deserialization in thetoJsonandfromJsonmethods.
- Added logic to handle
lib/common/models/shop.dart
- Improved fromJson Logic:
- Adjusted the
fromJsonmethod to retain thegeopointinformation during deserialization.
- Adjusted the
lib/features/add_shop/add_shop_controller.dart
- Address Handling Refactor:
- Included a check to handle updates on the
GeoPointbased on flagupdateGeoPoint. - Added
resetUpdateGeoPoint()call after updating the address geolocation.
- Included a check to handle updates on the
lib/features/add_shop/add_shop_page.dart
- UI Adjustments:
- Improved code formatting for better readability and consistency.
- Changed
TextCapitalization.sentencestoTextCapitalization.wordsin the description field.
lib/features/add_shop/stores/add_shop_store.dart
- State Management Enhancements:
- Added new observable state and actions for handling address type updates and other field changes.
lib/features/shops/shops_controller.dart
- Role-Based Data Retrieval:
- Implemented role-based shop retrieval methods (
streamShopAll,streamShopByOwner,streamShopByManager). - Enhanced data flow based on the logged-in user role to segregate data access.
- Implemented role-based shop retrieval methods (
lib/features/shops/shops_page.dart
- Minor UI Updates:
- Improved modal and navigation actions for better user experience.
lib/repository/firebase_store/abstract_shop_repository.dart
- Interface Update:
- Refined the abstract repository to include new streaming methods for
ShopModeldata retrieval.
- Refined the abstract repository to include new streaming methods for
lib/repository/firebase_store/shop_firebase_repository.dart
- Method Implementation:
- Added
streamShopAll,streamShopByManager, andstreamShopByOwnermethods for real-time shop data retrieval. - Removed redundant
getShopByNamemethod.
- Added
This commit streamlines data handling and serialization processes for ClientModel and ShopModel, enhances UI components for better usability, and implements role-based data access within the shop management features.
Refactoring models and geolocation functions
Summary: This commit implements a refactor for the address and client models, optimizing the geolocation functions and making code cleaner by removing redundant services and controllers.
Details:
-
lib/common/models/address.dart- Removed
geolocation_service.dartimport. - Added
geohashfield and updated constructor accordingly. - Adjusted
createdAtandupdatedAtfields to be optional. - Removed
updateLocation()method, as it's now handled externally.
- Removed
-
lib/common/models/client.dart- Changed
geopointto a non-nullable field. - Added
geohashfield and updated all necessary methods to include it. - Updated constructor to assign default values to
createdAtandupdatedAt.
- Changed
-
lib/common/models/delivery.dart- Fixed typo in the
geohashfield name.
- Fixed typo in the
-
lib/common/models/shop.dart- Modified
geopointto a required field. - Added
geohash,createdAt, andupdatedAtfields.
- Modified
-
lib/common/utils/address_functions.dart- New utility class
AddressFunctionscreated for geolocation-related methods, including:createAddress(): Creates a newAddressModeland updates its location.updateAddressGeoLocation(): Updates geolocation and timestamps.createGeoPointHash(): Generates a geohash for a givenGeoPoint.getGeoPointFromAddressString(): FetchesGeoPointbased on the address string usinggeocodingpackage.
- New utility class
-
lib/components/widgets/address_card.dart- Replaced
AddressModelparameter withaddressStringfor better compatibility.
- Replaced
-
Controllers and Stores
- Modified address and shop controllers to use the new
AddressFunctionsmethods. - Removed outdated
reactionmechanisms and added flag management (zipCodeChanged,updateGeoPoint) for reactivity. - Refactored
init()andmountAddress()methods inadd_clientandadd_shopcontrollers.
- Modified address and shop controllers to use the new
-
Other changes:
- Renamed and moved
store_func.dartfor better modularization. - Deleted
geo_point_funcs.dartas it is now part ofAddressFunctions. - Deleted
nearby_deliveriesfeature files, replaced byuser_deliveryfunctionalities. - Adjusted all imports and dependencies to reflect these changes.
- Renamed and moved
This refactor improves the maintainability and organization of the project by consolidating similar functionality and removing redundancy. The changes ensure that geolocation handling is more robust and integrated directly into model creation and update methods.
Refactored Geo-Location Attributes and Standardized Geohash Key Naming
-
Address Model Update:
- Renamed
locationattribute togeopointfor better semantic clarity. - Updated all references to
locationinAddressModeltogeopoint.
- Renamed
-
Client Model Update:
- Renamed
locationattribute togeopointto maintain consistency with the Address model. - Updated all
locationreferences togeopointacross the ClientModel.
- Renamed
-
Delivery Model Update:
- Renamed
locationattribute togeopointandgeoHashtogeohash. - Updated references in DeliveryModel to reflect these changes.
- Renamed
-
Shop Model Update:
- Renamed
locationattribute togeopointfor consistency with other models. - Updated all relevant references.
- Renamed
-
Controller and Page Updates:
- Refactored controllers (
add_client_controller.dart,add_delivery_controller.dart,add_shop_controller.dart) to use the new attribute names. - Adjusted
MapPageand other dependent views to reflect the renamed attributes.
- Refactored controllers (
-
Nearby Deliveries Feature Refactor:
- Renamed
neaby_deliveriesfeature tonearby_deliveriesfor correct spelling. - Updated controllers and store references to the new directory and file names.
- Renamed
-
Repository Updates:
- Refactored geohash key reference in
DeliveriesFirebaseRepositoryandLocationServicefromgeoHashtogeohash. - Standardized all geospatial query and data handling logic to use
geopointandgeohashconsistently.
- Refactored geohash key reference in
-
Other Refactoring:
- Adjusted json serialization methods for
ShopModelto usegeopointinstead oflocation. - Enhanced logging messages to improve debugging information during geospatial queries and updates.
- Adjusted json serialization methods for
This commit refines the geolocation attributes for better clarity and consistency across the models, repositories, and services. Additionally, it corrects naming inconsistencies and updates the project structure to improve maintainability and semantic accuracy.
Refactored Directory Structure for Stores and Controllers in features Module
-
Renamed and Moved Store Files:
- Moved store files from
lib/stores/pages/tolib/features/{feature_name}/stores/. - Updated imports across controllers and pages to reflect new paths for store files.
- This change affects the following stores:
account_store.dartadd_client_store.dartadd_delivery_store.dartadd_shop_store.dartclients_store.darthome_store.dartnearby_deliveries_store.dartpersonal_data_store.dartshops_store.dartsign_in_store.dartsign_up_store.dartuser_admin_store.dartuser_business_store.dartuser_delivery_store.dartuser_manager_store.dart
- Moved store files from
-
Updated Imports and Dependencies:
- Updated all controller and page imports to reference the new paths for store files.
- Adjusted the import statements for each affected file to ensure compatibility with the new structure.
-
Renamed
use_deliveryFeature touser_delivery:- Renamed
lib/features/use_delivery/tolib/features/user_delivery/to maintain consistency in feature naming. - Updated all related imports to reflect this name change.
- Renamed
-
Refactored Controllers and Pages:
- Updated the following controllers and pages to accommodate the new store file structure:
account_controller.dartaccount_page.dartadd_client_controller.dartadd_client_page.dartadd_delivery_controller.dartadd_delivery_page.dartadd_shop_controller.dartadd_shop_page.dartclients_controller.dartclients_page.darthome_store.dartneaby_deliveries_controller.dartneaby_deliveries_page.dartperson_data_controller.dartshops_controller.dartshops_page.dartsign_in_controller.dartsign_up_controller.dartuser_admin_controller.dartuser_admin_page.dartuser_business_controller.dartuser_business_page.dartuser_delivery_controller.dartuser_delivery_page.dartuser_manager_controller.dartuser_manager_page.dart
- Updated the following controllers and pages to accommodate the new store file structure:
This commit restructures the project by organizing store files within each feature module, promoting a more modular and maintainable codebase. The refactor improves readability and helps in future scalability of the project.
Refactored Delivery and Client Controllers to Utilize Improved Repository and State Management
-
lib/features/add_client/add_client_controller.dart
- Added
repositorytoAddClientControllerfor managing client-related operations. - Implemented
ClientFirebaseRepositoryfor client data management.
- Added
-
lib/features/add_delivery/add_delivery_controller.dart
- Reorganized dependencies with final variables for repositories and user store.
- Refactored the
createDeliverymethod to handle errors and state transitions more effectively. - Implemented methods for searching clients and refreshing shop data using repositories.
-
lib/features/add_delivery/add_delivery_page.dart
- Updated
AddDeliveryPageto useAddDeliveryStorefor state management and refactored controller initialization.
- Updated
-
lib/features/map/map_page.dart
- Added a back navigation button to improve the user experience.
-
lib/features/person_data/person_data_controller.dart
- Replaced store references with user store properties for better separation of concerns.
-
lib/features/use_delivery/user_delivery_controller.dart
- Integrated
UserDeliveryStorefor state management and controller initialization.
- Integrated
-
lib/features/user_admin/user_admin_controller.dart
- Reorganized state management using
UserAdminStore. - Replaced individual state properties with general state management logic.
- Reorganized state management using
-
lib/features/user_business/user_business_controller.dart
- Integrated
UserBusinessStoreand consolidated state management.
- Integrated
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Added
getAllmethod to fetch all deliveries in the system.
- Added
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Implemented
getAllmethod to support the retrieval of all delivery records from the database. - Added error handling and logging for repository operations.
- Implemented
-
lib/stores/pages/add_client_store.dart
- Removed repository dependency to reduce coupling.
-
lib/stores/pages/add_delivery_store.dart
- Updated store to use observable lists for managing clients and shops.
- Simplified error handling and state management.
-
lib/stores/pages/user_admin_store.dart
- Introduced a new state management pattern using
PageStatefor consistency. - Replaced individual state properties with a single observable state property.
- Introduced a new state management pattern using
-
lib/stores/pages/user_business_store.dart
- Refactored state handling methods for consistency with other stores.
-
lib/stores/pages/user_delivery_store.dart
- Introduced
errorMessageandstateobservables for better error handling and UI updates.
- Introduced
This commit refines the delivery and client-related features by integrating repository patterns and improving state management with MobX stores. The refactor enhances code readability, reduces coupling between controllers and stores, and improves error handling and user feedback mechanisms.
Refactored Client and Shop-related features to improve state management and UI consistency.
-
lib/common/models/client.dart
- Adjusted
copyWithmethod foraddressto handle potential null values properly.
- Adjusted
-
lib/features/add_client/add_client_controller.dart
- Refactored
AddClientControllerto useAddClientStorefor better state management. - Introduced
_mountAddressand_setClientValuesmethods to handle address setup. - Added reaction disposers for observables to manage form updates.
- Refactored
-
lib/features/add_client/add_cliend_page.dart
- Updated page to use
AddClientStorefor state handling and input validation. - Replaced direct access to controller properties with store properties.
- Updated page to use
-
lib/features/clients/clients_controller.dart
- Implemented stream subscription for client data using
ClientsStore. - Added methods for client data retrieval and state updates.
- Implemented stream subscription for client data using
-
lib/features/clients/clients_page.dart
- Replaced
StreamBuilderwithObserverfor MobX-based state management. - Improved error handling and UI state consistency using
ClientsStore.
- Replaced
-
lib/features/add_shop/add_shop_controller.dart
- Refined
AddShopControllerto useAddShopStorefor form management. - Implemented state updates and error handling through store methods.
- Consolidated address setup methods for cleaner code structure.
- Refined
-
lib/features/add_shop/add_shop_page.dart
- Integrated
AddShopStoreinto the page for more reactive state updates and cleaner UI logic.
- Integrated
-
lib/features/shops/shops_controller.dart
- Refactored
ShopsControllerto useShopsStorefor shop data management. - Added shop data streaming and improved error handling through store.
- Refactored
-
lib/features/shops/shops_page.dart
- Replaced previous implementation with
Observerfor reactive UI updates. - Refactored
Dismissiblewidgets into a separate component (DismissibleShop).
- Replaced previous implementation with
-
lib/features/shops/widgets/dismissible_shop.dart
- Created a reusable
DismissibleShopwidget for managing shop edit/delete actions in a dismissible container.
- Created a reusable
-
lib/stores/pages/clients_store.dart
- Created a new
ClientsStorefor managing client data and UI states. - Implemented methods for setting client data, handling errors, and state management.
- Created a new
-
lib/stores/pages/shops_store.dart
- Updated
ShopsStoreto handle shop data and UI state more effectively. - Added methods for setting shop data and managing errors.
- Updated
-
lib/stores/pages/add_client_store.dart
- Refined
AddClientStoreby separating address and state management methods. - Improved form validation and error handling through store methods.
- Refined
-
lib/stores/pages/add_shop_store.dart
- Simplified error handling and state management by consolidating methods.
-
lib/stores/pages/nearby_deliveries_store.dart
- Renamed
setPageStatetosetStatefor consistency across stores. - Adjusted error handling methods to use the new naming convention.
- Renamed
This commit introduces a comprehensive refactor of Client and Shop-related features, focusing on state management improvements using MobX stores, better error handling, and UI consistency. The refactor leads to a more maintainable codebase and clearer separation of concerns between controllers and stores.
Refactored user_business, add_user_business, and related features.
-
lib/features/account/account_controller.dart
- Updated
AccountControllerto useAccountStorefor state management. - Implemented
getManagerShops()method to retrieve and store manager shops locally.
- Updated
-
lib/features/account/account_page.dart
- Integrated
AccountStoreintoAccountPagefor state management and UI updates. - Replaced references to
pageStorewithstoreto reflect the new structure.
- Integrated
-
lib/features/add_shop/add_shop_controller.dart
- Modified
AddShopControllerto utilizeAddShopStorefor improved state handling. - Refactored methods like
saveShop()andupdateShop()for cleaner logic and local store updates. - Updated shop values initialization to correctly set store properties.
- Modified
-
lib/features/add_shop/add_shop_page.dart
- Adjusted page to work with
AddShopStorefor reactive state management. - Implemented improved error handling and display for the form fields.
- Adjusted page to work with
-
lib/features/user_business/user_business_controller.dart
- Adjusted to utilize
UserBusinessStorefor state management. - Refactored delivery fetching logic to use the new
getByOwnerId()method.
- Adjusted to utilize
-
lib/features/user_business/user_business_page.dart
- Updated page to use
UserBusinessStorefor state management and reactive UI updates.
- Updated page to use
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Renamed methods like
streamDeliveryByShopIdandgetDeliveryByOwnerIdfor better clarity and consistency. - Added new methods like
updateManagerIdto handle specific delivery updates in the repository.
- Renamed methods like
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Refactored method names to align with repository conventions (e.g.,
getByShopId,getNearby). - Implemented new method
updateManagerIdfor batch updating the manager ID in delivery documents.
- Refactored method names to align with repository conventions (e.g.,
-
lib/stores/pages/account_store.dart
- Simplified store logic by removing direct repository calls and focusing on state management.
- Refactored state update methods for consistency.
-
lib/stores/pages/add_shop_store.dart
- Separated store logic from the controller, focusing on reactive state updates and form validation.
-
lib/stores/pages/user_business_store.dart
- Updated
PageStatetostatefor naming consistency across stores. - Added error handling and state management methods to handle various UI states.
- Updated
-
lib/stores/pages/user_manager_store.dart
- Integrated delivery and shop data management into
UserManagerStore. - Added state and error handling methods for cleaner management of UI states.
- Integrated delivery and shop data management into
This commit refactors and streamlines the business-related pages, controllers, and stores, introducing better state management and separation of concerns, leading to a more maintainable and consistent codebase.
Refactored DeliveryModel and UserModel to include new fields and updated page functionality for business users.
-
General Package Updates
- Updated
DeliveryModelto include the newownerIdfield. - Refactored
UserModelby renaming themanagerIdfield tobossIdfor better clarity.
- Updated
-
lib/common/models/delivery.dart
- Added
ownerIdfield toDeliveryModelfor better association between deliveries and their respective owners. - Adjusted constructors, methods, and
copyWithpattern to accommodate the new field.
- Added
-
lib/common/models/user.dart
- Renamed the
managerIdfield tobossIdthroughout the class to better reflect the role hierarchy. - Updated all related methods and factory constructors accordingly.
- Renamed the
-
lib/features/user_business/user_business_controller.dart
- Refactored the
UserBusinessControllerto properly use theownerIdfield for querying deliveries. - Implemented new state management for loading and displaying deliveries specific to business users.
- Refactored the
-
lib/features/user_business/user_business_page.dart
- Modified
UserBusinessPageto leverage the newUserBusinessStorefor managing deliveries. - Added error handling and refresh functionality to improve user experience.
- Modified
-
lib/stores/pages/user_business_store.dart
- Added
deliveriesobservable list and methods for updating deliveries in the store. - Implemented
pageStateobservable to manage loading and error states.
- Added
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Renamed
streamDeliveryByOwnerIdtogetDeliveryByOwnerIdfor better method naming consistency.
- Renamed
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Updated the implementation of
getDeliveryByOwnerIdto fetch deliveries based on the newownerIdfield.
- Updated the implementation of
-
lib/stores/pages/add_delivery_store.dart
- Updated the delivery creation logic to include
ownerIdwhen creating new deliveries in the store.
- Updated the delivery creation logic to include
-
Other minor updates:
- Adjusted various field names and method calls to match the new field names (
bossIdinstead ofmanagerId). - Updated error messages and UI text to provide clearer information to the user.
- Adjusted various field names and method calls to match the new field names (
This commit improves the consistency and clarity of the data models, introduces better state management for business users, and ensures that deliveries are correctly associated with their respective owners using the new ownerId field.
Updated Firebase packages and implemented geolocation-based delivery features.
-
General Package Updates
- Updated all Firebase-related packages to the latest versions to address compatibility issues.
- Updated the
geoflutterfire_pluspackage locally and began testing it to ensure it functions correctly.
-
Android Manifest
- Added
ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION, andACCESS_BACKGROUND_LOCATIONpermissions in theAndroidManifest.xmlto support geolocation services in the app.
- Added
-
lib/common/extensions/user_role_extensions.dart (New)
- Created
UserRoleExtensionsto add utility methods likedisplayNameandiconDataforUserRole.
- Created
-
lib/common/models/user.dart
- Removed the deprecated
ptUserRolemethod. - Updated code to use the new extension methods from
UserRoleExtensions.
- Removed the deprecated
-
lib/features/add_delivery/add_delivery_page.dart
- Added a refresh button for shops to the dropdown menu in the delivery creation form.
-
lib/features/home/home_controller.dart
- Renamed
isDeliverytoisDeliverymanto better reflect the role's meaning.
- Renamed
-
lib/features/home/home_page.dart
- Replaced
UserDeliveryPagewithNearbyDeliveriesPagein the PageView navigation.
- Replaced
-
lib/features/home/widgets/custom_drawer_header.dart
- Updated to use the
UserRoleExtensionsfor cleaner code and separation of concerns.
- Updated to use the
-
lib/features/neaby_deliveries/neaby_deliveries_controller.dart (New)
- Implemented
NearbyDeliveriesControllerto manage geolocation-based queries and subscriptions for nearby deliveries.
- Implemented
-
lib/features/neaby_deliveries/neaby_deliveries_page.dart (New)
- Created a new page
NearbyDeliveriesPageto display deliveries within a certain radius of the user's current location.
- Created a new page
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Renamed method
getDeliveryNearbytogetDeliveriesNearbyfor naming consistency.
- Renamed method
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Updated the geolocation query method to include a limit on the number of results and added better error handling.
-
lib/services/location_service.dart (New)
- Implemented a new
LocationServiceclass to handle permission requests and updating the user's location in Firestore.
- Implemented a new
-
lib/stores/pages/add_delivery_store.dart
- Added the
refreshShopsmethod to dynamically update the list of available shops based on the user's role.
- Added the
-
lib/stores/pages/user_business_store.dart (New)
- Created a new MobX store for managing state in the business user page.
-
pubspec.yaml / pubspec.lock
- Updated
geolocatorand added its dependencies (geolocator_android,geolocator_apple, etc.) to support geolocation in the app.
- Updated
This commit introduces significant updates to geolocation-based functionality in the delivery app. It refactors user role handling, introduces new pages and controllers for managing nearby deliveries, and updates the project dependencies to ensure compatibility and stability.
Added geoHash field to DeliveryModel and introduced geolocation-based queries for deliveries.
-
lib/common/models/delivery.dart
- Added the
geoHashfield toDeliveryModelfor more efficient geospatial queries. - Updated the constructor,
copyWith,toMap, andfromMapmethods to handle the newgeoHashfield.
- Added the
-
lib/common/utils/geo_point_funcs.dart (New)
- Created a utility function
createGeoPointHashusing the GeoFlutterFire package to generate geohashes based on aGeoPoint.
- Created a utility function
-
lib/components/widgets/delivery_card.dart
- Renamed from
lib/features/home/widgets/delivery_card.dartfor a more general use across features.
- Renamed from
-
lib/features/account/account_controller.dart
- Renamed from
lib/features/account_page/account_controller.dart.
- Renamed from
-
lib/features/account/account_page.dart
- Renamed from
lib/features/account_page/account_page.dart.
- Renamed from
-
lib/features/add_delivery/add_delivery_controller.dart
- Refactored to use
storeinstead ofpageStorefor consistency across the project.
- Refactored to use
-
lib/features/add_delivery/add_delivery_page.dart
- Updated method references to use
storeinstead ofpageStoreafter the refactor.
- Updated method references to use
-
lib/features/home/home_controller.dart
- Added logic to dynamically set the page title based on user role (Admin, Business, Manager, Delivery).
- Introduced a
PageControllerto manage different views for different user roles.
-
lib/features/home/home_page.dart
- Replaced static delivery list with a dynamic
PageViewthat shows different pages based on user roles.
- Replaced static delivery list with a dynamic
-
lib/features/use_delivery/user_delivery_controller.dart (New)
- Created a controller for managing the delivery page specific to delivery users.
-
lib/features/use_delivery/user_delivery_page.dart (New)
- Added a new page dedicated to delivery users, displaying relevant delivery information.
-
lib/features/user_admin/user_admin_controller.dart (New)
- Created a controller for the admin page, managing admin-specific actions and data.
-
lib/features/user_admin/user_admin_page.dart (New)
- Implemented the admin page with functionality for viewing and managing deliveries.
-
lib/features/user_business/user_business_controller.dart (New)
- Created a controller for the business page, managing data relevant to business users.
-
lib/features/user_business/user_business_page.dart (New)
- Implemented a business-specific page to display and manage deliveries.
-
lib/features/user_manager/user_manager_controller.dart (New)
- Created a controller for the manager page, handling manager-specific actions.
-
lib/features/user_manager/user_manager_page.dart (New)
- Implemented the manager-specific page to display and manage deliveries.
-
lib/my_material_app.dart
- Updated routes to reflect the new structure and renamed files.
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Added methods for streaming deliveries by owner and retrieving nearby deliveries based on geolocation.
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Integrated geospatial queries using GeoFlutterFire to stream deliveries near a specified location.
- Added a method to stream deliveries based on owner ID.
-
lib/repository/firebase_store/shop_firebase_repository.dart
- Implemented a method to get shops by owner ID.
-
lib/services/local_storage_service.dart
- Added a method to clear cached manager shops when the user logs out.
-
lib/stores/pages/add_delivery_store.dart
- Added logic to generate and store a geohash for the shop's location when creating a delivery.
-
lib/stores/pages/user_admin_store.dart (New)
- Created MobX store for managing admin page state.
-
lib/stores/pages/user_delivery_store.dart (New)
- Created MobX store for managing the delivery page state.
-
lib/stores/pages/user_manager_store.dart (New)
- Created MobX store for managing the manager page state.
-
lib/stores/user/user_store.dart
- Added logic to fetch and cache shops for manager and business users upon login.
- Enhanced the logout process to clear cached data.
This commit adds geolocation-based functionality to deliveries, reorganizes user roles, and introduces distinct pages for different user types (Admin, Business, Manager, Delivery). The overall structure was refactored to support these new features.
Introduced integration with Google Maps and improvements to delivery and shop models.
-
android/app/src/main/AndroidManifest.xml- Added meta-data for Google Maps API key for future use in map integrations.
-
lib/common/extensions/delivery_status_extensions.dart- Renamed from
emu_extensions.dartto better reflect its purpose. - Imported
material_symbols_iconspackage. - Added new
icongetter to provide icons for differentDeliveryStatusvalues.
- Renamed from
-
lib/common/models/delivery.dart- Added
shopPhonetoDeliveryModelto store the phone number of the shop. - Renamed
shopLocationtolocationfor consistency in representing the shop's location. - Updated
DeliveryModelconstructor,toMap,fromMap, and comparison methods to include the newshopPhoneand renamed fields.
- Added
-
lib/common/models/shop.dart- Renamed
userIdtoownerIdto clarify the purpose of the field. - Added
phonefield to store the shop's phone number. - Updated
toMap,fromMap, and other relevant methods to handle the new fields.
- Renamed
-
lib/common/theme/app_text_style.dart- Added
font14method to support text styling for smaller fonts.
- Added
-
lib/features/add_delivery/add_delivery_controller.dart- Updated
initmethod to be asynchronous, awaiting store initialization. - Added
noShopsStatefor handling cases where no shops are available.
- Updated
-
lib/features/add_delivery/add_delivery_page.dart- Added error handling for no shops and unknown errors with appropriate UI feedback.
- Modified the delivery creation flow to reflect the new
noShopsState.
-
lib/features/add_shop/add_shop_controller.dart- Added a
phoneControllerto manage the input for shop phone numbers.
- Added a
-
lib/features/home/home_controller.dart- Imported
DeliveriesFirebaseRepositoryfor streaming deliveries in the home page.
- Imported
-
lib/features/home/home_page.dart- Integrated delivery cards that allow users to view delivery details and navigate to a map view.
- Streamed deliveries from the repository for dynamic updates.
-
lib/features/home/widgets/delivery_card.dart(New)- Created
DeliveryCardwidget to display delivery information, including the client name, shop phone, and address.
- Created
-
lib/features/map/map_controller.dart(New)- Created
MapControllerto manage Google Maps interaction.
- Created
-
lib/features/map/map_page.dart(New)- Implemented
MapPageto display the delivery route from the shop to the client's location using Google Maps.
- Implemented
-
lib/my_material_app.dart- Added route generation for
MapPageto allow users to navigate to the delivery map.
- Added route generation for
-
lib/repository/firebase_store/shop_firebase_repository.dart- Renamed
userIdtoownerIdin Firestore queries and data handling. - Adjusted data map handling for consistency.
- Renamed
-
lib/stores/pages/add_delivery_store.dart- Added
NoShopStateenum to handle various states related to shop availability. - Updated the
initmethod to fetch shops and handle errors accordingly.
- Added
-
lib/stores/pages/add_shop_store.dart- Added
phoneanderrorPhoneobservables for managing and validating phone number input. - Included phone validation logic in
isValid()method.
- Added
This commit introduces Google Maps integration and enhances the delivery flow by adding phone numbers and updating shop and delivery models. It also improves error handling and user experience when creating deliveries.
Enhance Delivery Model and Refactor Delivery Features
-
lib/common/models/delivery.dart
- Added
clientPhonefield toDeliveryModel. - Removed
deliveryDatefield fromDeliveryModel. - Updated
copyWith,toMap,fromMap,toJson,fromJson,toString,==, andhashCodemethods to includeclientPhoneand excludedeliveryDate.
- Added
-
lib/common/models/shop.dart
- Modified
toJsonmethod to includeidand structuredlocationdata with latitude and longitude. - Updated
fromJsonfactory constructor to correctly parse nestedlocationdata and remove redundant fields.
- Modified
-
lib/features/delivery_request/delivery_request_controller.dart
- Deleted File: Removed
DeliveryRequestControlleras it is no longer needed.
- Deleted File: Removed
-
lib/features/delivery_request/delivery_request_page.dart
- Deleted File: Removed
DeliveryRequestPageto streamline delivery handling within the app.
- Deleted File: Removed
-
lib/features/home/home_page.dart
- Commented out
_deliceryRequestmethod and its invocation to eliminate navigation to the now-deletedDeliveryRequestPage.
- Commented out
-
lib/features/home/widgets/home_drawer.dart
- Removed
deliceryRequestparameter and associatedListTilefor delivery requests fromHomeDrawer.
- Removed
-
lib/my_material_app.dart
- Removed references to
DeliveryRequestPageroute from the application's navigation routes.
- Removed references to
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Refactored
addandupdatemethods to utilizeWriteBatchfor atomic Firestore operations. - Included
clientPhoneinDeliveryModelduring add and update operations. - Enhanced
getandgetAllmethods to handle Firestore timestamps correctly and ensure proper data conversion. - Improved error handling and logging for delivery data management.
- Refactored
-
lib/services/local_storage_service.dart
- Updated log messages to reflect changes in managing manager shops.
- Added error handling in
getManagerShopsto log exceptions and ensure robustness.
-
lib/stores/pages/add_delivery_store.dart
- Enhanced
createDeliverymethod to includeclientPhoneand implement comprehensive error handling. - Initialized
shopIdwith the first available shop's ID during theinitaction for default selection. - Updated import paths for consistency and clarity.
- Enhanced
These changes enhance the delivery model by adding necessary fields, refactor delivery-related features for improved state management, and remove obsolete delivery request components. These updates pave the way for a more streamlined and efficient delivery registration process in the delivery app.
Complete System Base and Initiate Delivery Registration Features
-
.gitignore
- Added
*.oldto ignore old backup files.
- Added
-
Makefile
- Renamed
firebase_emu_make_cachetarget tofirebase_emusavecachefor clarity.
- Renamed
-
firestore.rules
- Simplified Firestore security rules by removing specific access controls.
- Updated rules to allow read and write operations on all documents at development time.
-
lib/common/extensions/emu_extensions.dart
- Updated string literals in
DeliveryStatusExtensionto use single quotes for consistency.
- Updated string literals in
-
lib/common/models/address.dart
- Removed
createdAtandupdatedAtfields fromAddressModel. - Refactored
updateLocationmethod to uselocationinstead ofgeoPoint.
- Removed
-
lib/common/models/client.dart
- Renamed
geoAddresstolocationinClientModel. - Updated related methods and JSON serialization to reflect the name change.
- Renamed
-
lib/common/models/shop.dart
- Renamed
geoAddresstolocationinShopModel. - Updated related methods and JSON serialization to reflect the name change.
- Renamed
-
lib/components/widgets/dismissible_help_row.dart
- New File: Added
DismissibleHelpRowwidget class to provide a consistent UI for edit and delete actions.
- New File: Added
-
lib/features/add_delivery/add_delivery_controller.dart
- Implemented
AddDeliveryControllerwith properties and methods for managing delivery creation. - Integrated
AddDeliveryStorefor state management. - Added text controllers for phone and name inputs with appropriate masks.
- Implemented
-
lib/features/add_delivery/add_delivery_page.dart
- Enhanced
AddDeliveryPagewith form fields for selecting origin shop and destination client. - Integrated
DismissibleHelpRowfor better user interaction. - Added submission methods for name and phone searches.
- Included a
BigButtonto generate deliveries.
- Enhanced
-
lib/features/clients/clients_page.dart
- Updated
ClientsPageto use the newly createdDismissibleHelpRowwidget for editing and deleting clients. - Removed redundant code and streamlined the UI components.
- Updated
-
lib/features/home/home_page.dart
- Modified
HomePageto include a floating action button that navigates toAddDeliveryPagefor creating new deliveries. - Updated navigation imports for consistency.
- Modified
-
lib/features/shops/shops_page.dart
- Updated
ShopsPageto incorporateDismissibleHelpRowand enhanced dismissible list items for editing and deleting shops. - Improved UI layout and interaction handling.
- Updated
-
lib/repository/firebase_store/client_firebase_repository.dart
- Refactored client repository methods (
addandupdate) to useWriteBatchfor atomic Firestore operations. - Improved error handling and logging for client data management.
- Refactored client repository methods (
-
lib/repository/firebase_store/shop_firebase_repository.dart
- Refactored shop repository methods (
addandupdate) to useWriteBatchfor atomic Firestore operations. - Enhanced error handling and logging for shop data management.
- Refactored shop repository methods (
-
lib/stores/pages/add_client_store.dart
- Updated
AddClientStorewith changes to address updating and location handling. - Refactored state management variables and methods for better clarity and functionality.
- Updated
-
lib/stores/pages/add_delivery_store.dart
- New File: Added
AddDeliveryStoreclass with observable properties and actions for managing delivery data. - Implemented search functionalities by name and phone.
- Integrated local storage interactions for managing shops and clients.
- New File: Added
-
lib/stores/pages/add_shop_store.dart
- Modified
AddShopStorewith updates to address handling and validation. - Refactored methods for setting shop details and validating inputs.
- Enhanced state management for shop creation and updates.
- Modified
-
pubspec.yaml
- Updated application version from
0.4.04+22to0.6.00+23to reflect significant feature additions and improvements.
- Updated application version from
These changes complete the system's base functionality and lay the groundwork for developing the delivery registration feature in the delivery app.
Complete System Base Implementation and Prepare for Delivery Registration Development
-
lib/features/account_page/account_controller.dart
- Changed the
initmethod toFuture<void>and made it asynchronous. - Added
await pageStore.init()within theinitmethod.
- Changed the
-
lib/services/local_storage_service.dart
- Imported
dart:developerfor logging purposes. - Imported
../common/models/shop.dartto handleShopModel. - Added
_keyManagerShopsconstant for storing manager shops. - Implemented
setManagerShopsmethod to save a list of manager shops. - Implemented
getManagerShopsmethod to retrieve the list of manager shops.
- Imported
-
lib/stores/pages/account_store.dart
- Imported
../../services/local_storage_service.dartto use the local storage service. - Added
localStoreinstance usinglocator<LocalStorageService>(). - Created an asynchronous
initaction method to initialize the store. - Updated
getManagerShopsto callsetInLocalStoreafter fetching shops. - Added
setInLocalStoremethod to save shops to local storage. - Added
getInLocalStoreaction method to load shops from local storage.
- Imported
These changes complete the system's base functionality and set the foundation for developing the delivery registration feature in the delivery app.
Refactor Models, Update Controllers, Enhance UI Components, and Improve Repository Interactions
This commit introduces a series of modifications aimed at enhancing the application's data models, controllers, user interface components, and repository layers. The changes focus on improving code maintainability, ensuring data integrity, and enhancing the overall user experience. Below is a comprehensive overview of the updates made across various files:
-
lib/common/models/address.dart
- Import Path Adjustment:
- Updated the import statement for the
geolocation_serviceto use an absolute path. This change streamlines the import process, making the codebase more organized and easier to navigate.
- Updated the import statement for the
- Import Path Adjustment:
-
lib/common/models/client.dart
-
Field Renaming and Refactoring:
- Renamed the
geoAddressfield tolocationto better represent geographical data usingGeoPoint. - Updated all references to this field throughout the model, including constructors,
copyWithmethods, serialization (toMapandfromMap), string representations, and equality checks.
- Renamed the
-
Data Integrity Enhancements:
- Ensured that the
locationfield accurately reflects the geographical position by updating related methods and ensuring consistent data handling across the model.
- Ensured that the
-
-
lib/features/account_page/account_controller.dart
-
Imports and Dependencies:
- Added imports for
ShopModelandstore_functo facilitate interactions with shop data and utility functions.
- Added imports for
-
State Management Enhancements:
- Introduced
stateandshopsproperties to manage the current state of the account page and the list of shops managed by the user. - Implemented the
getManagerShopsmethod to fetch and manage shops associated with the current user, enhancing the controller's functionality.
- Introduced
-
-
lib/features/account_page/account_page.dart
-
Imports and Theming:
- Added imports for
store_func.dartandmaterial_symbols_iconsto incorporate additional UI components and iconography. - Utilized the
colorSchemefrom the theme to ensure consistent and adaptive coloring across UI elements.
- Added imports for
-
User Interface Enhancements:
- Introduced buttons for generating QR codes and loading managed shops, providing users with more interactive options.
- Enhanced conditional rendering based on the page state, displaying loading indicators and lists of managed shops as appropriate.
-
Icon Update:
- Changed the floating action button icon from a person-add symbol to a delivery-dining icon to better align with the application's delivery-focused functionality.
-
-
lib/features/add_shop/add_shop_page.dart
- Route Name Update:
- Changed the route name from
/add_storeto/add_shopto maintain consistency and clarity within the application's navigation structure.
- Changed the route name from
- Route Name Update:
-
lib/features/clients/clients_controller.dart
- Navigator Arguments Adjustment:
- Modified the arguments passed to the navigation method by removing the map wrapper around the
clientobject. This simplification enhances the clarity and efficiency of data passing between pages.
- Modified the arguments passed to the navigation method by removing the map wrapper around the
- Navigator Arguments Adjustment:
-
lib/features/clients/clients_page.dart
-
Imports and Widget Enhancements:
- Added imports for
material_symbols_iconsand a newly createddismissible_client.dartwidget to enrich the UI and encapsulate dismissible functionalities.
- Added imports for
-
Method Additions:
- Introduced the
_addClientmethod to streamline navigation to the Add Client page, promoting code reusability and cleaner button handlers.
- Introduced the
-
UI Refactoring:
- Replaced the inline
Dismissiblewidgets with the reusableDismissibleClientwidget. This change not only cleans up the UI code but also promotes better separation of concerns and easier maintenance.
- Replaced the inline
-
-
lib/features/clients/widgets/dismissible_client.dart (New File)
-
Reusable Dismissible Widget:
- Created the
DismissibleClientwidget to encapsulate the logic for dismissible client items. This modular approach enhances code reusability, readability, and maintainability.
- Created the
-
Enhanced Interaction Handling:
- Configured customized backgrounds for edit and delete actions within the dismissible widget, providing intuitive swipe interactions for users.
-
-
lib/features/home/home_page.dart
- Icon Update:
- Updated the floating action button icon from a person-add symbol to a delivery-dining icon, aligning the UI more closely with the application's delivery-centric features.
- Icon Update:
-
lib/features/qrcode_read/qrcode_read_page.dart
-
Imports and Dependencies:
- Added imports for
dart:asyncandqr_flutterto handle asynchronous operations and QR code generation/display.
- Added imports for
-
Lifecycle Management:
- Implemented
WidgetsBindingObserverto manage the scanner's lifecycle effectively, ensuring that the scanner starts and stops appropriately based on the app's state (e.g., when the app is resumed or paused).
- Implemented
-
Barcode Detection Handling:
- Introduced a
StreamSubscriptionto listen for barcode detections, enhancing the scanner's responsiveness and reliability.
- Introduced a
-
User Interface Enhancements:
- Integrated
QrImageViewto display the scanned QR code data, providing users with immediate visual feedback of the scanned information. - Enhanced error handling and data representation to offer clearer feedback and smoother user interactions.
- Integrated
-
Scanner Initialization:
- Configured the
MobileScannerControllerwith additional parameters to optimize scanning performance and user experience.
- Configured the
-
-
lib/repository/firebase_store/abstract_shop_repository.dart
- Interface Extension:
- Added a new method
getShopByManagerto the abstract repository interface. This method facilitates fetching shops managed by a specific manager, expanding the repository's capabilities.
- Added a new method
- Interface Extension:
-
lib/repository/firebase_store/client_firebase_repository.dart
-
Add Method Refactoring:
- Enhanced the
addmethod to incorporate address localization before saving a client. This ensures that each client's geographical data is accurately captured and stored. - Implemented checks to ensure that a client has an address before proceeding with the localization and storage processes.
- Enhanced the
-
Data Integrity Enhancements:
- Ensured that the client's address information is properly saved within the relevant subcollection, maintaining consistent and reliable data structures.
-
-
lib/repository/firebase_store/shop_firebase_repository.dart
-
Method Implementation:
- Implemented the
getShopByManagermethod to retrieve all shops managed by a specific manager. This method queries the Firestore database and processes the results to return a list ofShopModelinstances.
- Implemented the
-
Error Handling:
- Incorporated comprehensive error handling to log and manage any issues that arise during the data retrieval process, ensuring robustness and reliability.
-
-
lib/stores/pages/account_store.dart
-
State Management Enhancements:
- Added
shopsandstateobservables to manage the list of shops and the current page state within the account store.
- Added
-
Action Implementation:
- Developed the
getManagerShopsaction to fetch shops managed by the current user. This action updates the store's state based on the success or failure of the data retrieval process, facilitating responsive UI updates.
- Developed the
-
Repository Integration:
- Integrated the
ShopFirebaseRepositoryto handle data fetching, promoting a clean separation between the store and data layers.
- Integrated the
-
-
lib/stores/pages/account_store.g.dart
- Generated Code Updates:
- Updated the generated code to reflect the new
shopsandstateobservables and their corresponding getters, setters, and actions. This ensures that the MobX store remains in sync with the manual changes made to the store class.
- Updated the generated code to reflect the new
- Generated Code Updates:
-
lib/stores/pages/add_client_store.dart
-
Imports and Dependencies:
- Added imports for
generic_extensions.dartanddart:developerto utilize string manipulation extensions and logging functionalities.
- Added imports for
-
Observable Additions:
- Introduced the
isAddressEditedobservable to track changes made to a client's address, enabling more precise state management and validation.
- Introduced the
-
Method Refactoring and Enhancements:
- Refactored the
getClientFromFormmethod to handle address updates more effectively, ensuring that location data is accurately updated and reflected in the client model. - Implemented the
_updateLocationaction to update the client's address location only when changes have been made, optimizing performance and data accuracy.
- Refactored the
-
Validation Improvements:
- Replaced the
removeNonNumberutility method with theonlyNumbers()string extension for phone and zip code validations, promoting cleaner and more readable code.
- Replaced the
-
Address Handling Enhancements:
- Updated address handling logic to manage
locationandaddressStringfields instead of the previously usedgeoAddress, ensuring consistent data representation.
- Updated address handling logic to manage
-
Editing Flags Management:
- Enhanced the
_checkIsEditedmethod and related functionalities to manage bothisEditedandisAddressEditedflags. This provides a more granular control over state changes, ensuring that updates are handled appropriately.
- Enhanced the
-
Address Mounting Logic:
- Modified the
_mountAddressmethod to conditionally update the address based on theisAddressEditedflag, ensuring that only relevant changes trigger data updates.
- Modified the
-
Action Enhancements:
- Implemented additional actions and state checks to manage address edits and ensure data integrity throughout the client creation and editing processes.
-
-
lib/stores/pages/add_client_store.g.dart
- Generated Code Updates:
- Updated the generated code to include the new
isAddressEditedobservable and the_updateLocationasync action. - Refactored the
_checkIsEditedmethod to accommodate the new editing flags, ensuring that state changes are accurately tracked and managed. - Enhanced the
toStringmethod to include theisAddressEditedflag, providing a more comprehensive string representation of the store's state.
- Updated the generated code to include the new
- Generated Code Updates:
-
lib/stores/user/user_store.dart
- Getter Addition:
- Added an
idgetter to retrieve the current user's ID directly from thecurrentUserobject. This simplifies access to user identification data throughout the application.
- Added an
- Getter Addition:
-
pubspec.yaml
- Dependency Adjustments:
- Removed an unnecessary blank line to maintain a clean and organized dependencies section.
- No other changes were made in this file during this commit.
- Dependency Adjustments:
Conclusion:
This commit brings significant improvements to the application's architecture and functionality:
-
Data Model Enhancements: By renaming and refactoring fields, the data models now more accurately represent geographical data, improving data integrity and clarity.
-
State Management Upgrades: Introducing new observables and actions in stores like
AccountStoreandAddClientStoreensures more responsive and reliable state handling, enhancing the overall user experience. -
User Interface Improvements: Refactoring UI components to use reusable widgets like
DismissibleClientand enhancing interaction elements (e.g., buttons for QR code generation and shop loading) result in a cleaner, more intuitive, and maintainable UI codebase. -
Repository Layer Refinements: Extending repository interfaces and implementing new methods like
getShopByManagerprovide more robust data fetching capabilities, ensuring that the application can efficiently manage and display relevant data. -
Lifecycle and Error Handling Enhancements: Implementing lifecycle observers and comprehensive error handling across controllers and repositories contributes to a more stable and user-friendly application.
Overall, these changes collectively aim to bolster the application's robustness, maintainability, and user-centric design, paving the way for further feature expansions and optimizations.
Update SDK, Firebase, and Scanner Dependencies
This commit upgrades the Flutter SDK, updates Firebase dependencies, replaces the QR code scanner, and removes unnecessary Firebase modules. Below are the detailed changes made across various files:
-
android/app/build.gradle
- Upgraded
compileSdkfromflutter.compileSdkVersionto34. - Changed
jvmTargetfromJavaVersion.VERSION_1_8to"1.8". - Updated
minSdkto21andtargetSdkto34.
- Upgraded
-
android/app/src/main/AndroidManifest.xml
- Modified a comment by adding
FIXME:to indicate a pending change.
- Modified a comment by adding
-
android/build.gradle
- Configured
jvmTargetto1.8for all Kotlin modules. - Updated
buildscriptdependencies, includingkotlin_versionto'1.8.10'andcom.android.tools.build:gradleto'8.0.2'.
- Configured
-
android/gradle.properties
- Added
dev.steenbakker.mobile_scanner.useUnbundled=trueto enable unbundled mode formobile_scanner.
- Added
-
android/gradle/wrapper/gradle-wrapper.properties
- Updated
distributionUrlfromgradle-7.6.3-all.ziptogradle-8.1.1-all.zip.
- Updated
-
docs/Projeto_Delivery_Scrum.md
- Renamed from
doc/Projeto_Delivery_Scrum.mdtodocs/Projeto_Delivery_Scrum.md.
- Renamed from
-
docs/Regras de Segurança do Firebase.md (New File)
- Added comprehensive documentation on Firebase security rules for the Delivery application.
-
firestore.rules
- Introduced
isBusinessManager()function. - Updated permissions for
clients,shops, and their subcollections. - Refactored rules to enhance security and performance.
- Introduced
-
lib/common/extensions/emu_extensions.dart (New File)
- Added
DeliveryStatusExtensionto provide display names and colors for delivery statuses.
- Added
-
lib/common/extensions/generic_extensions.dart (New File)
- Implemented extensions for
num,DateTime, andStringto handle formatting and data manipulation.
- Implemented extensions for
-
lib/common/models/address.dart
- Replaced
latitudeandlongitudewithGeoPoint? location. - Updated methods to reflect the use of
GeoPoint.
- Replaced
-
lib/common/models/client.dart
- Added
addressStringandgeoAddressfields. - Updated
toMapandfromMapmethods to include new fields.
- Added
-
lib/common/models/delivery.dart (New File)
- Introduced
DeliveryModelwith comprehensive fields and methods to manage delivery data.
- Introduced
-
lib/common/models/shop.dart
- Made
nameanddescriptionrequired fields. - Replaced
latitudeandlongitudewithGeoPoint? location. - Updated methods to handle new fields.
- Made
-
lib/components/widgets/address_card.dart
- Changed method call from
address!.addressString()toaddress!.addressRepresentationString()for better representation.
- Changed method call from
-
lib/features/home/home_controller.dart
- Commented out
store.setHasPhone(currentUser!.phone != null);to disable phone check.
- Commented out
-
lib/features/home/home_page.dart
- Added an
Observerwidget to reactively manage UI changes.
- Added an
-
lib/features/qrcode_read/qrcode_read_page.dart
- Replaced
qr_code_scannerwithmobile_scanner. - Updated scanning logic to handle QR code detection using
MobileScannerController.
- Replaced
-
lib/features/sign_up/sign_up_page.dart
- Removed unused reaction disposer and related commented code for cleaner implementation.
-
lib/repository/firebase_store/abstract_deliveries_repository.dart (New File)
- Defined an abstract repository interface for managing deliveries.
-
lib/repository/firebase_store/deliveries_firebase_repository.dart (New File)
- Implemented
DeliveriesFirebaseRepositorywith methods to add, update, delete, and stream delivery data from Firestore.
- Implemented
-
lib/services/geolocation_service.dart
- Refactored to use the
geocodingpackage instead of the Google Geocoding API. - Updated
getGeoPointFromAddressto returnGeoPoint?.
- Refactored to use the
-
lib/stores/pages/add_client_store.dart
- Replaced
removeNonNumberwithonlyNumbers()extension. - Updated address handling to use
GeoPoint? location.
- Replaced
-
lib/stores/pages/add_shop_store.dart
- Similar refactoring as
add_client_store.dartfor address handling. - Utilized
onlyNumbers()extension for zip code validation.
- Similar refactoring as
-
lib/stores/pages/common/store_func.dart
- Removed the
removeNonNumbermethod in favor of using string extensions.
- Removed the
-
package.json
- Updated
firebase-functionsfrom^6.0.0to^6.0.1.
- Updated
-
package-lock.json
- Synced
firebase-functionsversion to6.0.1.
- Synced
-
pubspec.yaml
- Updated dependencies:
- Upgraded
get_itto^8.0.0. - Removed
qr_code_scannerand addedmobile_scanner,geocoding, andgeoflutterfire_plus. - Updated
firebase_coreto^2.32.0,cloud_firestoreto^4.17.5, and other Firebase packages to their latest versions.
- Upgraded
- Updated dependencies:
These updates enhance the project's compatibility with the latest Flutter and Firebase versions, improve security with refined Firestore rules, and ensure the app uses maintained and optimized packages for QR code scanning and geolocation. The refactoring also promotes cleaner code practices by leveraging Dart extensions and removing deprecated dependencies.
Implemented new features, enhancements, and configuration updates.
-
android/app/src/main/AndroidManifest.xml
- Added
android.permission.CAMERApermission.
- Added
-
firebase.json
- Updated Firebase emulator host to
192.168.0.22for the following services:- Functions
- Auth
- Firestore
- UI
- Database
- Storage
- Remote Config
- Updated Firebase emulator host to
-
functions/index.js
- Added
managerIdto user claims. - Modified
setUserClaimsfunction to includemanagerIdwhen provided. - Updated success message to include
managerId.
- Added
-
lib/common/models/shop.dart
- Added
managerIdandmanagerNamefields toShopModel. - Updated constructor to initialize
managerIdandmanagerName. - Included
managerIdandmanagerNameintoMap,fromMap,copyWith, andtoStringmethods.
- Added
-
lib/common/models/user.dart
- Added
managerIdfield toUserModel. - Updated constructor and
toMap/fromMapmethods to handlemanagerId. - Added
accountIdgetter based on user role. - Updated
toStringmethod to includemanagerId.
- Added
-
lib/features/account_page/account_controller.dart
- Introduced
AccountControllerclass managingUserStoreandAccountStore. - Implemented methods to toggle QR code visibility.
- Introduced
-
lib/features/account_page/account_page.dart
- Added
AccountPagewidget with QR code display and toggle functionality.
- Added
-
lib/features/add_shop/add_shop_controller.dart
- Added
setManagermethod to handle manager selection.
- Added
-
lib/features/add_shop/add_shop_page.dart
- Imported
QRCodeReadPage. - Added
_getManagermethod to navigate toQRCodeReadPageand set manager data. - Updated UI to include manager selection interface.
- Imported
-
lib/features/home/home_page.dart
- Imported
AccountPage. - Added
_accountPagemethod to navigate toAccountPage.
- Imported
-
lib/features/home/widgets/home_drawer.dart
- Added
accountcallback. - Included "Account" ListTile in the navigation drawer.
- Added
-
lib/features/qrcode_read/qrcode_read_page.dart
- Introduced
QRCodeReadPagewidget for scanning QR codes.
- Introduced
-
lib/features/stores/shops_controller.dart
- Imported
UserModel. - Added
currentUserandaccountIdfields. - Updated
editShopmethod parameters and logic to handle shop data.
- Imported
-
lib/features/stores/shops_page.dart
- Initialized
ShopsControllerininitState.
- Initialized
-
lib/main.dart
- Updated Firebase emulator host to
192.168.0.22for Auth, Firestore, and Functions.
- Updated Firebase emulator host to
-
lib/my_material_app.dart
- Imported
AccountPageandQRCodeReadPage. - Added routes for
AccountPageandQRCodeReadPage.
- Imported
-
lib/repository/firebase/firebase_auth_repository.dart
- Included
managerIdin user claims. - Refactored
adminCheckedlogic. - Updated methods to handle
managerId.
- Included
-
lib/repository/firebase_store/shop_firebase_repository.dart
- Imported
UserStore. - Updated
streamShopByNameto filter shops based onaccountId.
- Imported
-
lib/stores/pages/account_store.dart
- Introduced
AccountStorewithshowQRCodeobservable andtoggleShowQRCodeaction.
- Introduced
-
lib/stores/pages/add_shop_store.dart
- Added
managerIdandmanagerNameobservables. - Implemented
setManageraction. - Updated
getShopFromFormandsetShopFromShopmethods to handle manager data.
- Added
-
pubspec.yaml
- Bumped version to
0.4.01+19. - Added
qr_flutterandqr_code_scannerdependencies.
- Bumped version to
-
pubspec.lock
- Downgraded
jspackage from0.7.1to0.6.7. - Added
qr,qr_code_scanner, andqr_flutterpackages.
- Downgraded
These updates enhance the application's functionality by introducing QR code features, manager handling, and improved Firebase configurations.
Refactor Store Directory Structure, Update Makefile, and Modify User Model
This commit encompasses significant refactoring of the project's directory structure, updates to the Makefile, and modifications to the UserModel. Below is a detailed breakdown of the changes:
-
Makefile Updates (
Makefile)-
Changed Firebase Emulator Export Command:
-
Before:
firebase_emu_make_cache: rm -rf ./emulator_data; firebase emulators:export ./emulator_data
-
After:
firebase_emu_make_cache: firebase emulators:export ./emulator_data -f
-
Explanation:
- Removed the
rm -rf ./emulator_data;command to prevent forcefully deleting theemulator_datadirectory before exporting. - Added the
-fflag to thefirebase emulators:exportcommand to force the export, ensuring that existing data is overwritten without manual deletion.
- Removed the
-
-
-
Store Directory Refactoring
- Renaming
stores/mobx/tostores/pages/:- Files Renamed:
add_client_store.dart→pages/add_client_store.dartadd_client_store.g.dart→pages/add_client_store.g.dartadd_shop_store.dart→pages/add_shop_store.dartadd_shop_store.g.dart→pages/add_shop_store.g.dartcommon/store_func.dart→pages/common/store_func.darthome_store.dart→pages/home_store.darthome_store.g.dart→pages/home_store.g.dartpersonal_data_store.dart→pages/personal_data_store.dartpersonal_data_store.g.dart→pages/personal_data_store.g.dartshops_store.dart→pages/shops_store.dartshops_store.g.dart→pages/shops_store.g.dartsign_in_store.dart→pages/sign_in_store.dartsign_in_store.g.dart→pages/sign_in_store.g.dartsign_up_store.dart→pages/sign_up_store.dartsign_up_store.g.dart→pages/sign_up_store.g.dart
- Explanation:
- The MobX stores were relocated from the
mobxdirectory to a newpagesdirectory withinstoresto better organize store files based on their associated features or pages. - All import statements within the project were updated to reflect the new file paths.
- The MobX stores were relocated from the
- Files Renamed:
- Renaming
-
User Model Enhancements (
lib/common/models/user.dart)-
Imported Material Symbols Icons:
-
Before:
import 'package:flutter/material.dart';
-
After:
import 'package:flutter/material.dart'; import 'package:material_symbols_icons/material_symbols_icons.dart';
-
Explanation:
- Added the
material_symbols_iconspackage to utilize a broader range of icons, enhancing the UI's visual appeal.
- Added the
-
-
Updated Icon Assignments:
-
Before:
case UserRole.admin: title = 'Administrador'; icon = Icons.admin_panel_settings_rounded; break; // ... case UserRole.business: title = 'Comerciante'; icon = Icons.person_rounded; break; case UserRole.manager: title = 'Gerente'; icon = Icons.manage_accounts_outlined; break;
-
After:
case UserRole.admin: title = 'Administrador'; icon = Symbols.admin_panel_settings_rounded; break; // ... case UserRole.business: title = 'Comerciante'; icon = Symbols.business; break; case UserRole.manager: title = 'Gerente'; icon = Symbols.manage_accounts_rounded; break; default: title = 'Clique para entrar'; icon = Symbols.people_rounded; break;
-
Explanation:
- Replaced standard
IconswithSymbolsfrom thematerial_symbols_iconspackage for a more consistent and modern iconography. - Added a
defaultcase to handle scenarios where the user role might not match any predefined roles, providing a fallback title and icon.
- Replaced standard
-
-
-
Widget Import Path Corrections
-
Address Card Widget (
lib/components/widgets/address_card.dart):-
Before:
import '../../stores/mobx/common/store_func.dart';
-
After:
import '../../stores/pages/common/store_func.dart';
-
Explanation:
- Updated the import path to align with the refactored store directory structure.
-
-
Add Client Page (
lib/features/add_client/add_cliend_page.dart):-
Before:
import '../../stores/mobx/common/store_func.dart';
-
After:
import '../../stores/pages/common/store_func.dart';
-
Explanation:
- Corrected the import path to the relocated
store_func.dart. - Note: There's a typo in the filename
add_cliend_page.dart; it should likely beadd_client_page.dart. Ensure that the filename is corrected to prevent import issues.
- Corrected the import path to the relocated
-
-
Add Client Controller (
lib/features/add_client/add_client_controller.dart):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/add_client_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/add_client_store.dart';
-
Explanation:
- Updated import paths to reflect the new store directory structure.
-
-
Add Shop Controller & Page (
lib/features/add_shop/):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '/stores/mobx/add_shop_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/add_shop_store.dart';
-
Explanation:
- Corrected import paths following the store directory refactoring.
-
-
Home Controller (
lib/features/home/home_controller.dart):-
Before:
import '../../stores/mobx/home_store.dart';
-
After:
import '../../stores/pages/home_store.dart';
-
Explanation:
- Updated the import path to the relocated
home_store.dart.
- Updated the import path to the relocated
-
-
Person Data Controller & Page (
lib/features/person_data/):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/personal_data_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/personal_data_store.dart';
-
Explanation:
- Updated import paths to align with the new store directory structure.
-
-
Sign In & Sign Up Controllers (
lib/features/sign_in/,lib/features/sign_up/):-
Before:
import '../../stores/mobx/sign_in_store.dart'; import '../../stores/mobx/sign_up_store.dart';
-
After:
import '../../stores/pages/sign_in_store.dart'; import '../../stores/pages/sign_up_store.dart';
-
Explanation:
- Refactored import paths to point to the new locations of the store files.
-
-
Shops Controller & Page (
lib/features/stores/):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/shops_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/shops_store.dart';
-
Explanation:
- Updated import paths following the store directory refactoring.
-
-
-
Store Function Utilities (
lib/stores/pages/common/store_func.dart)-
Created
store_func.dart:-
Content:
import '../../../common/models/via_cep_address.dart'; import '../../../repository/viacep/via_cep_repository.dart'; enum PageState { initial, loading, success, error } enum ZipStatus { initial, loading, success, error } const addressTypes = [ 'Apartamento', 'Clínica', 'Comercial', 'Escritório', 'Residencial', 'Trabalho', ]; class StoreFunc { StoreFunc._(); static bool itsNotEmail(String? email) { final regex = RegExp(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'); return (email == null || email.isEmpty || !regex.hasMatch(email)); } static String removeNonNumber(String? value) { return value?.replaceAll(RegExp(r'[^\d]'), '') ?? ''; } static String? validCpf(String? cpf) { if (cpf == null || cpf.length != 11 || RegExp(r'^(\d)\1*$').hasMatch(cpf)) { return 'CPF inválido'; } int digit1 = _calculateDigit(cpf.substring(0, 9), 10); int digit2 = _calculateDigit(cpf.substring(0, 10), 11); bool valid = digit1 == int.parse(cpf[9]) && digit2 == int.parse(cpf[10]); if (!valid) { return 'CPF inválido'; } return null; } static int _calculateDigit(String cpf, int factor) { int total = 0; for (int i = 0; i < cpf.length; i++) { total += int.parse(cpf[i]) * factor--; } int rest = total % 11; return (rest < 2) ? 0 : 11 - rest; } static Future<(ZipStatus, String?, ViaCepAddressModel?)> fetchAddress( String? zipCode) async { try { final response = await ViaCepRepository.getLocalByCEP(zipCode!); if (!response.isSuccess) { return (ZipStatus.error, 'CEP inválido', null); } final viaAddress = response.data; if (viaAddress == null) { return (ZipStatus.error, 'CEP inválido', null); } return (ZipStatus.success, null, viaAddress); } catch (err) { return (ZipStatus.error, 'erro desconhecido: $err', null); } } }
-
Explanation:
- Consolidated utility functions and enums into a centralized
store_func.dartfile within thepages/common/directory. - Provides helper methods for email validation, CPF validation, number extraction, and address fetching.
- Defines
PageStateandZipStatusenums for consistent state management across stores.
- Consolidated utility functions and enums into a centralized
-
-
-
User Interface Enhancements
-
Address Card Widget Import Path Correction (
lib/components/widgets/address_card.dart):-
Before:
import '../../stores/mobx/common/store_func.dart';
-
After:
import '../../stores/pages/common/store_func.dart';
-
Explanation:
- Updated the import path to the relocated
store_func.dart.
- Updated the import path to the relocated
-
-
-
Controller Import Path Corrections
-
Add Client Controller (
lib/features/add_client/add_client_controller.dart):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/add_client_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/add_client_store.dart';
-
Explanation:
- Corrected import paths to reflect the new store directory structure.
-
-
Add Shop Controller (
lib/features/add_shop/add_shop_controller.dart):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '/stores/mobx/add_shop_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/add_shop_store.dart';
-
Explanation:
- Updated import paths following the store directory refactoring.
-
-
Home Controller (
lib/features/home/home_controller.dart):-
Before:
import '../../stores/mobx/home_store.dart';
-
After:
import '../../stores/pages/home_store.dart';
-
Explanation:
- Updated the import path to the relocated
home_store.dart.
- Updated the import path to the relocated
-
-
Person Data Controller (
lib/features/person_data/person_data_controller.dart):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/personal_data_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/personal_data_store.dart';
-
Explanation:
- Updated import paths to align with the new store directory structure.
-
-
Sign In & Sign Up Controllers (
lib/features/sign_in/sign_in_controller.dart,lib/features/sign_up/sign_up_controller.dart):-
Before:
import '../../stores/mobx/sign_in_store.dart'; import '../../stores/mobx/sign_up_store.dart';
-
After:
import '../../stores/pages/sign_in_store.dart'; import '../../stores/pages/sign_up_store.dart';
-
Explanation:
- Refactored import paths to point to the new locations of the store files.
-
-
Shops Controller (
lib/features/stores/shops_controller.dart):-
Before:
import '../../stores/mobx/common/store_func.dart'; import '../../stores/mobx/shops_store.dart';
-
After:
import '../../stores/pages/common/store_func.dart'; import '../../stores/pages/shops_store.dart';
-
Explanation:
- Updated import paths following the store directory refactoring.
-
-
-
Store Files Renaming
- Renaming Stores from
mobxtopages:- All store files within
lib/stores/mobx/have been renamed to reside withinlib/stores/pages/. This includes both the Dart files and their corresponding generated.g.dartfiles. - Example:
lib/stores/mobx/add_client_store.dart→lib/stores/pages/add_client_store.dartlib/stores/mobx/add_client_store.g.dart→lib/stores/pages/add_client_store.g.dart
- Explanation:
- This renaming improves the organizational structure of the project by categorizing stores based on their association with specific pages or features, enhancing maintainability and scalability.
- All store files within
- Renaming Stores from
-
Additional Notes
- Typographical Correction:
- The filename
add_cliend_page.dartappears to contain a typo. It should likely be renamed toadd_client_page.dartto maintain consistency and prevent potential import issues.
- The filename
- Consistency in Enum Usage:
- Ensured that enums
PageStateandZipStatusare consistently used across all stores, promoting uniform state management.
- Ensured that enums
- Iconography Enhancement:
- Transitioned from using standard Flutter
IconstoSymbolsfrom thematerial_symbols_iconspackage for a more modern and consistent icon set across the application.
- Transitioned from using standard Flutter
- Typographical Correction:
These changes collectively enhance the project's structure, improve code maintainability, and ensure consistency in state management and utility functions across different features. The refactoring also paves the way for easier scalability and integration of new features in the future.
Update Authentication Data, Firestore Export, Models, Widgets, Features, and State Management
This commit introduces a series of updates and enhancements across various parts of the project, including authentication data modifications, Firestore export updates, model refinements, new widgets, feature additions, and improvements to state management using MobX. Below is a comprehensive breakdown of the changes:
-
Authentication Data (
emulator_data/auth_export/accounts.json)- Updated User Entries:
- Ricardo Mattos:
- Updated
passwordUpdatedAttimestamp. - Added
disabledfield set tofalse.
- Updated
- Rudson Alves:
- Updated
passwordUpdatedAttimestamp. - Added
disabledfield set tofalse.
- Updated
- Ricardo Mattos:
- Changes:
- Removed newline at the end of the file.
- Updated
validSincetimestamps. - Adjusted
lastRefreshAttimestamps to reflect recent changes.
- Updated User Entries:
-
Firestore Export Metadata (
emulator_data/firestore_export/)- Files Updated:
all_namespaces_all_kinds.export_metadataoutput-0firestore_export.overall_export_metadata
- Changes:
- Binary files differ, indicating updates to Firestore emulator export data.
- Files Updated:
-
Dart Models
AddressModel(lib/common/models/address.dart):- Changes:
- Modified
geoAddressgetter to includecomplementif available. - Added
isValidAddressgetter to validate essential address fields.
- Modified
- Changes:
ClientModel(lib/common/models/client.dart):- Changes:
- Removed commented-out
idandaddressfields fromtoMap()andfromMap()methods. - Simplified
emailfield handling.
- Removed commented-out
- Changes:
ShopModel(lib/common/models/shop.dart):- New Model:
- Represents a shop with fields:
id,userId,address,name, anddescription. - Includes serialization methods:
toMap(),fromMap(), and other utility methods.
- Represents a shop with fields:
- New Model:
-
Widgets
AddressCard(lib/components/widgets/address_card.dart):- New Widget:
- Displays address information based on the
ZipStatus. - Handles different states: loading, error, success, and initial.
- Utilizes theming for consistent styling.
- Displays address information based on the
- New Widget:
-
Features
- Add Client Feature (
lib/features/add_client/):- Pages & Controllers:
- Updated
add_client_page.dartto integrate the newAddressCardwidget. - Refactored
add_client_controller.dartto useStoreFuncfor utility functions. - Enhanced form validation and state management using MobX.
- Updated
- Pages & Controllers:
- Add Shop Feature (
lib/features/add_shop/):- Controller (
add_shop_controller.dart):- Manages shop creation and updating processes.
- Integrates with
AddShopStorefor state management. - Handles initialization and disposal of controllers.
- Page (
add_shop_page.dart):- Developed UI for adding and updating shops.
- Integrated
AddressCardfor address display. - Managed form fields and submission logic.
- Controller (
- Clients Page (
lib/features/clients/clients_page.dart):- Changes:
- Removed unnecessary logging.
- Streamlined client deletion logic.
- Changes:
- Person Data Feature (
lib/features/person_data/):- Changes:
- Updated to use
PageStateinstead ofStatus. - Integrated
StoreFuncfor utility functions.
- Updated to use
- Changes:
- Shops Management Feature (
lib/features/stores/):- Controller (
shops_controller.dart):- Implements
ShopsControllerwith methods to edit and delete shops. - Utilizes
ShopFirebaseRepositoryfor data operations.
- Implements
- Page (
shops_page.dart):- Developed UI for managing shops.
- Implemented list views with dismissible items for editing and deleting.
- Added confirmation dialogs for deletion with proper error handling.
- Controller (
- Add Client Feature (
-
State Management with MobX
- Common Utilities (
lib/stores/mobx/common/store_func.dart):- New File:
- Replaces the deleted
generic_functions.dart. - Contains utility functions such as
itsNotEmail,removeNonNumber,validCpf, andfetchAddress. - Defines enums
PageStateandZipStatusfor consistent state representation.
- Replaces the deleted
- New File:
- Add Client Store (
lib/stores/mobx/add_client_store.dart):- Changes:
- Refactored to use
PageStateinstead ofPageStatus. - Integrated
StoreFuncfor validation and address fetching. - Enhanced form validation logic.
- Updated actions to manage state transitions and data processing.
- Refactored to use
- Changes:
- Add Shop Store (
lib/stores/mobx/add_shop_store.dart):- Changes:
- Refactored to use
StoreFuncfor utility functions. - Enhanced state management for shop data.
- Integrated address validation and coordinate fetching.
- Implemented methods for saving and updating shops with proper error handling.
- Refactored to use
- Changes:
- Shops Store (
lib/stores/mobx/shops_store.dart):- Changes:
- Updated to use
StoreFuncfor consistency.
- Updated to use
- Changes:
- Personal Data Store (
lib/stores/mobx/personal_data_store.dart):- Changes:
- Refactored to use
StoreFuncfor utility functions. - Updated state management to use
PageState.
- Refactored to use
- Changes:
- Sign In & Sign Up Stores (
lib/stores/mobx/sign_in_store.dart,lib/stores/mobx/sign_up_store.dart):- Changes:
- Updated to use
StoreFuncfor utility functions.
- Updated to use
- Changes:
- Common Utilities (
-
Repositories
- Address Repository (
lib/repository/firebase_store/address_firebase_repository.dart):- New Repository:
- Implements
AbstractAddressClientRepositorywith Firebase operations for addresses. - Handles adding, updating, and retrieving addresses with error management.
- Implements
- New Repository:
- Client Repository (
lib/repository/firebase_store/client_firebase_repository.dart):- Refinements:
- Updated collection keys from
keyClienttokeyClientsfor consistency. - Enhanced methods to handle nested address subcollections.
- Improved error handling with specific error codes.
- Updated collection keys from
- Refinements:
- Shop Repository (
lib/repository/firebase_store/shop_firebase_repository.dart):- New Repository:
- Implements
AbstractShopRepositorywith comprehensive Firebase operations for shops. - Includes methods for adding, updating, deleting, fetching, and streaming shops.
- Manages nested address subcollections with proper error handling.
- Implements
- New Repository:
- Address Repository (
-
Dependency Management
pubspec.yaml:- Added Dependency:
material_symbols_icons: ^4.2785.1for enhanced iconography.
- Added Dependency:
pubspec.lock:- Included
material_symbols_iconspackage with version4.2785.1.
- Included
-
Application Configuration (
lib/my_material_app.dart)- Route Management:
- Imported new pages:
AddShopPage. - Registered new routes for adding and editing shops.
- Updated navigation logic to pass
ShopModelarguments.
- Imported new pages:
- Route Management:
-
Miscellaneous
- Deletion of
generic_functions.dart(lib/stores/mobx/common/generic_functions.dart):- Removed the file in favor of the new
store_func.dartfor better organization and utility function management.
- Removed the file in favor of the new
- Store Initialization and Disposal:
- Enhanced controllers to initialize with existing data when editing and properly dispose of controllers to prevent memory leaks.
- Deletion of
-
Firestore Security Rules (
firestore.rules)- Note:
- While not directly modified in this diff, the comprehensive updates to models and repositories imply that security rules may need to be reviewed to accommodate new data structures and access patterns.
- Note:
-
Testing and Validation
- Changes:
- Updated models and state management to ensure data integrity and proper validation across forms.
- Enhanced error messages and state transitions to provide better user feedback.
- Changes:
These updates collectively enhance the application's functionality by introducing shop management features, improving form validations, refactoring utility functions for better maintainability, and strengthening state management with MobX. The introduction of new repositories ensures robust data handling with Firebase, while the addition of new widgets like AddressCard improves the user interface and experience.
Update Project Configurations, Firestore Rules, and Dependencies
This commit introduces a comprehensive set of updates and enhancements to the project, including configuration adjustments, Firestore security rule enhancements, the addition of new features and models, and updates to dependencies.
-
.gitignore
- Added Patterns:
*~: Ignores temporary backup files..vscode/: Includes VS Code configurations in version control.- iOS build artifacts:
/ios/Pods//ios/Flutter/Flutter.framework/ios/Flutter/Flutter.podspec/ios/Flutter/Generated.xcconfig/ios/Flutter/app.flx/ios/Flutter/app.zip/ios/Flutter/engine/ios/Flutter/flutter_assets/ios/ServiceDefinitions.json
- Firebase and Crashlytics related files:
firebase_app_id_file.jsoncrashlytics-build.propertiesserviceAccountKey.json- Firebase Emulator logs and data:
firebase-debug.logfirestore-debug.logdatabase-debug.logui-debug.logstorage-debug.logfirebase-debug.**-debug.logemulator_data/
- Node.js related:
node_modules/
- Environment variables:
.env.*
- Removed Patterns:
- Commented out exclusion for
.vscode/to include it in version control. - Changed
/build/exclusion to include thebuild/directory.
- Commented out exclusion for
- Other Adjustments:
- Added exclusions for various IDEs and build tools.
- Added Patterns:
-
Makefile
- Changes:
- Modified the
firebase_emu_make_cachetarget to remove the./emulator_datadirectory before exporting Firebase emulators. This ensures a clean state during emulator exports. - Before:
firebase emulators:export ./emulator_data - After:
rm -rf ./emulator_data; firebase emulators:export ./emulator_data
- Modified the
- Changes:
-
Documentation
- Renamed File:
- Moved
Projeto Delivery Scrum.mdtodoc/Projeto_Delivery_Scrum.mdfor better organization.
- Moved
- Renamed File:
-
Firebase Authentication Data
- Updated
accounts.json:- Added new user entries with roles and authentication details for Ricardo Mattos and Rudson Alves.
- Updated
-
Firestore Security Rules (
firestore.rules)- Added Helper Functions:
isAdmin(): Checks if the user has an admin role.isBusiness(): Checks if the user has a business role.isShopOwner(shop): Verifies if the user owns the shop.canAccessShop(shop): Determines if the user can access the shop based on role and ownership.isAuth(): Checks if the user is authenticated.
- Defined Rules for Collections:
appSettingsCollection:- Allows creation and read access with specific restrictions.
clientsCollection:- Admins (
role 0): Full read and write access. - Business Users (
role 1): Can read, create, and update but not delete. - Others: Can only read.
- Admins (
addressesSubcollection withinclients:- Mirrors permissions of the
clientscollection.
- Mirrors permissions of the
shopsCollection:- Read Access: Available to all authenticated users.
- Create Access: Admins or business users creating shops associated with their user ID.
- Update & Delete Access: Restricted to admins or business users who own the shop.
addressesSubcollection withinshops:- Read Access: Based on shop access permissions.
- Create & Update Access: Admins or business users who own the shop.
- Delete Access: Based on shop access permissions.
- Added Helper Functions:
-
Dart Models
AddressModel(lib/common/models/address.dart):- Removed the commented-out
idfield from thetoMap()method. - Updated the
fromMapfactory constructor to handle optionalid.
- Removed the commented-out
ShopModel(lib/common/models/shop.dart):- New Model: Represents a shop with fields such as
id,userId,address,name, anddescription. - Serialization Methods: Includes
toMap(),fromMap(),toJson(),fromJson(), andcopyWith()for easy data manipulation.
- New Model: Represents a shop with fields such as
UserModel(lib/common/models/user.dart):- Extended Enum: Added
managerrole toUserRoleenum. - Updated Display: Handles the
managerrole with appropriate titles and icons.
- Extended Enum: Added
-
Flutter Features
- Add Client Feature (
lib/features/add_client/):- Pages & Controllers:
- Updated imports and dependencies.
- Removed hardcoded
addressTypesarray. - Implemented form validation and state management using MobX.
- Updated UI components to reflect state changes.
- Pages & Controllers:
- Add Delivery Feature (
lib/features/add_delivery/):- New Pages & Controllers:
- Added
add_delivery_controller.dartandadd_delivery_page.dartwith basic scaffolding for delivery requests.
- Added
- New Pages & Controllers:
- Add Shop Feature (
lib/features/add_shop/):- New Pages & Controllers:
- Added
add_shop_controller.dartandadd_shop_page.dartwith form fields for adding shops. - Implemented MobX store
AddShopStorefor managing shop data and state.
- Added
- New Pages & Controllers:
- Delivery Request Feature (
lib/features/delivery_request/):- New Pages & Controllers:
- Added
delivery_request_controller.dartanddelivery_request_page.dartto handle delivery requests.
- Added
- New Pages & Controllers:
- Home Feature (
lib/features/home/):- Controller (
home_controller.dart):- Added getters
isAdminandisBusinessto determine user roles.
- Added getters
- Page (
home_page.dart):- Imported new pages for delivery requests and store management.
- Added navigation methods
_deliceryRequestand_storesPage.
- Drawer (
home_drawer.dart):- Imported
material_symbols_icons. - Added conditional
ListTilewidgets for delivery requests and store management based on user roles.
- Imported
- Controller (
- Add Client Feature (
-
Person Data Feature (
lib/features/person_data/):- Page (
person_data_page.dart):- Updated to use
PageStateinstead ofPageStatus. - Integrated error handling based on the updated state management.
- Updated to use
- Store (
personal_data_store.dart):- Replaced
Statusenum withPageState. - Updated observables and actions to align with the new state management.
- Enhanced validation methods for form fields.
- Replaced
- Page (
-
Shops Management Feature (
lib/features/stores/):- Controller (
shops_controller.dart):- Implemented
ShopsControllerwith references toShopsStoreandShopFirebaseRepository. - Added role-based getters
isAdminandisBusiness.
- Implemented
- Page (
shops_page.dart):- Developed
ShopsPagewith UI for managing shops. - Implemented list views with dismissible items for editing and deleting shops.
- Integrated loading states and empty state handling.
- Developed
- Store (
shops_store.dart):- Created
ShopsStorewith observablestateand actions to manage shop-related states.
- Created
- Controller (
-
Repositories
- Abstract Repositories:
abstract_address_repository.dart:- Renamed methods for consistency (
settoadd). - Updated
getmethod signature to acceptaddressIdinstead of anAddressModel.
- Renamed methods for consistency (
abstract_shop_repository.dart:- New Abstract Class: Defines methods for adding, updating, deleting, fetching, and streaming shops.
- Concrete Repositories:
address_firebase_repository.dart:- Implemented
AbstractAddressClientRepositorywith Firebase operations for addresses. - Added error handling and logging.
- Implemented
client_firebase_repository.dart:- Refactored to use
keyClientsandkeyAddressesfor collection names. - Enhanced methods to align with updated repository structure.
- Improved error handling with specific error codes.
- Refactored to use
shop_firebase_repository.dart:- New Repository: Implements
AbstractShopRepositorywith comprehensive Firebase operations for shops. - Includes methods for adding, updating, deleting, fetching, and streaming shops.
- Handles nested address subcollections with proper error management.
- New Repository: Implements
- Abstract Repositories:
-
Dependency Management
pubspec.yaml:- Added dependency:
material_symbols_icons: ^4.2785.1for enhanced iconography.
- Added dependency:
pubspec.lock:- Included
material_symbols_iconspackage with version4.2785.1.
- Included
-
Application Configuration (
lib/my_material_app.dart)- Route Management:
- Imported new pages:
add_delivery_page.dart,add_shop_page.dart,delivery_request_page.dart, andshops_page.dart. - Registered new routes for the added pages to enable navigation within the app.
- Imported new pages:
- Route Management:
-
Common Utilities (
lib/stores/mobx/common/generic_functions.dart)- Enums Added:
PageState: Represents the state of a page (initial, loading, success, error).ZipStatus: Represents the status of ZIP code validation and fetching.
- Constants:
addressTypes: List of address types used across the application.
- Enums Added:
-
State Management with MobX
- Add Client Store (
lib/stores/mobx/add_client_store.dart):- Refactored to use
PageStateinstead ofPageStatus. - Enhanced validation methods and state handling.
- Refactored to use
- Add Shop Store (
lib/stores/mobx/add_shop_store.dart):- Implemented observables and actions for managing shop data.
- Integrated ZIP code validation and address fetching.
- Shops Store (
lib/stores/mobx/shops_store.dart):- Managed the state of shops listing and operations.
- Personal Data Store (
lib/stores/mobx/personal_data_store.dart):- Updated to use
PageStatefor managing personal data states. - Enhanced form validation and error handling.
- Updated to use
- Add Client Store (
-
Firestore Data Export Metadata
- Updated Export Metadata Files:
- Differences in
emulator_data/firestore_export/indicate updates to Firestore emulator export data.
- Differences in
- Updated Export Metadata Files:
-
Storage Rules (
storage.rules)- New Rules:
- Deny all read and write operations to Firebase Storage to enhance security.
- New Rules:
These updates collectively improve the application's security, scalability, and maintainability. The addition of new features like shop and delivery request management expands the app's functionality, while the enhancements to Firestore rules ensure robust access control. Dependency updates and state management refinements contribute to a more stable and efficient development workflow.
Update project configurations, Firestore rules, and dependencies
This commit introduces several updates and enhancements to the project, including configuration changes, Firestore rules updates, and additional dependencies.
-
emulator_data/auth_export/accounts.json
- Updated the
usersarray by adding a new user with detailed authentication information.
- Updated the
-
emulator_data/firebase-export-metadata.json
- Added
storagesection with version13.17.0and pathstorage_export.
- Added
-
emulator_data/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata
- Added new export metadata file.
-
emulator_data/firestore_export/all_namespaces/all_kinds/output-0
- Added new output file for Firestore export.
-
emulator_data/storage_export/buckets.json
- Created
buckets.jsonwith bucket IDdelivery-16712.appspot.com.
- Created
-
firebase.json
- Added
storageandremoteconfigemulators with respective ports. - Updated ignore patterns and added storage rules configuration.
- Added
-
firestore.rules
- Defined rules for
appSettingscollection, including creation, read, and restriction on updates/deletes. - Updated
adminConfigdocument rules to allow creation and read access while blocking modifications. - Enhanced
clientsandaddressescollections with role-based permissions for administrators and business users.
- Defined rules for
-
lib/components/widgets/base_dismissible_container.dart
- Changed
disableColorfromoutlinetosecondaryContainerin the dismissible container.
- Changed
-
lib/features/clients/clients_controller.dart
- Imported
user.dart,user_store.dart, anddata_result.dart. - Added
userStorelocator and gettersuser,isAdmin, andisBusiness. - Implemented
deleteClientmethod to handle client deletion.
- Imported
-
lib/features/clients/clients_page.dart
- Imported
app_text_style.dartandstate_loading.dart. - Modified
_deleteClientto return a boolean and added a confirmation dialog. - Enhanced UI to conditionally display clients or a loading state.
- Imported
-
lib/repository/firebase_store/client_firebase_repository.dart
- Changed the collection key from
keyAddresstokeyClientwhen updating client data.
- Changed the collection key from
-
lib/services/geolocation_service.dart
- Removed unnecessary
foundation.dartimport. - Eliminated debug code mocking latitude and longitude.
- Updated
googleApigetter to asynchronously fetch the API key.
- Removed unnecessary
-
lib/services/remote_config.dart
- Imported
flutter_dotenv. - Modified
googleApigetter to load from.envin debug mode.
- Imported
-
lib/stores/mobx/add_client_store.dart
- Added
idto theClientModelconstructor. - Commented out direct assignment of
client.id.
- Added
-
lib/stores/user/user_store.dart
- Added
isAdminandisBusinessgetters to determine user roles.
- Added
-
package-lock.json
- Added new dependencies:
@eslint/config-array,@eslint/object-schema,glob,rimraf, and others. - Removed
optionalflags from certain dependencies.
- Added new dependencies:
-
package.json
- Included new dependencies:
@eslint/config-array,@eslint/object-schema,glob, andrimraf.
- Included new dependencies:
-
pubspec.lock
- Added
flutter_dotenvdependency.
- Added
-
pubspec.yaml
- Added
flutter_dotenvto dependencies. - Included
.envfile in assets.
- Added
-
remoteconfig.template.json
- Configured
google_api_keyparameter with a default value. - Added version description for emulator configuration.
- Configured
-
storage.rules
- Created new storage rules to deny all read and write operations.
These changes improve security, configuration management, and functionality across various components.
Adjusted cleartext traffic setting and added email verification resend functionality
This commit introduces changes in the AndroidManifest for debugging purposes and includes a new feature for resending email verification on the sign-in page.
-
android/app/src/main/AndroidManifest.xml- Changed
android:usesCleartextTrafficfromfalsetotrueto allow unencrypted traffic, which is useful for debugging in a local environment.
- Changed
-
lib/features/sign_in/sign_in_controller.dart- Added
resendVerificationEmail()method to resend the verification email to the user.
- Added
-
lib/features/sign_in/sign_in_page.dart- Added
_resendVerifEmail()method to handle the action of resending the email verification. - Included a
TextButtonto trigger the resend email functionality on the sign-in page.
- Added
-
lib/main.dart- Re-enabled logging and connection to Firebase emulators in
kDebugMode, including authentication, Firestore, and Firebase Functions emulators.
- Re-enabled logging and connection to Firebase emulators in
-
lib/repository/firebase/firebase_auth_repository.dart- Introduced a check to prevent multiple admin users by adding error handling for creating new admin users if one already exists.
- Refactored the
create()method to use a localfirebaseUservariable for easier access and management. - Added a
_deleteFirebaseUser()method to remove a user in case of an error during user creation. - Enhanced error handling for setting user claims and checking admin status.
- Ensured
getUserFrom()method reloads the user data to retrieve the latest user information.
This update improves the system by allowing email verification to be resent and refining error handling for user creation, particularly for administrative accounts.
Add Firebase Functions for User Claims and remove users collection
Firebase Functions were added to manage User Claims, storing the role and status attributes of users. This replaces the need for a users collection. Adjustments were also made to the Firebase emulator setup to accommodate these changes.
-
Makefile
- Added
firebase_emu_make_cachetarget to export emulator data using Firebase emulators.
- Added
-
firebase.json
- Added configuration for the Functions emulator, setting the port to 5001.
- Included Firebase Functions deployment setup, specifying the
nodejs18runtime and adding ignored directories likenode_modulesand.git.
-
firestore.rules
- Removed
userscollection access checks since user attributes are now handled via Custom Claims. - Updated rules to allow any user to create new users, but only admins (role = 0) can modify or delete them.
- Simplified the
adminConfigcreation and update logic, allowing any user to create it, but restricting updates to admins.
- Removed
-
lib/common/models/client.dart
- Added
idfield to theClientModelclass to store Firebase UID.
- Added
-
lib/common/settings/app_settings.dart
- Updated import paths.
-
lib/components/widgets/base_dismissible_container.dart
- Added a new reusable widget
baseDismissibleContainer, allowing the configuration of alignment, color, and icons for dismissible containers.
- Added a new reusable widget
-
lib/components/widgets/custom_text_field.dart
- Added
focusNodeandnextFocusNodeto support focus navigation between text fields.
- Added
-
lib/features/add_client/add_cliend_page.dart
- Refactored the page to handle client updates. Added logic to check if a client is being added or edited and adjusted the UI accordingly.
- Replaced
_save()with_saveClient()method to differentiate between adding and updating clients.
-
lib/features/add_client/add_client_controller.dart
- Added
updateClient()method to support updating existing clients. - Modified
init()to handle client updates by populating fields if a client is passed to the page.
- Added
-
lib/features/clients/clients_page.dart
- Integrated dismissible containers to allow for editing and deleting clients directly from the list.
- Added methods
_editClient()and_deleteClient()to handle client modification and deletion actions.
-
lib/repository/firebase/firebase_auth_repository.dart
- Removed logic related to the
userscollection. - Added
_setUserClaims()method to set Firebase Custom Claims forroleandstatus. - Refactored
getCurrentUser()to retrieve user claims from Firebase instead of fetching from Firestore.
- Removed logic related to the
-
lib/repository/firebase_store/client_firebase_repository.dart
- Refactored client retrieval methods to handle
idproperly when interacting with Firestore.
- Refactored client retrieval methods to handle
-
pubspec.yaml
- Added
cloud_functionsdependency for Firebase Functions integration.
- Added
Changes were successfully applied to implement Firebase Functions for managing User Claims and removing the users collection.
Improve Firebase integration and repository refactor
This commit introduces several changes and improvements related to Firebase integration, client management, and repository structure.
Modified files:
-
Makefile
- Added
firebase_emucommand to start Firebase emulators with data import. - Added
firebase_emu_debugcommand for starting Firebase emulators in debug mode. - Introduced
build_runnercommand to execute Dart build runner in watch mode.
- Added
-
android/app/build.gradle
- Loaded
keystorePropertiesfor signing configurations. - Applied signing configurations for the release build.
- Loaded
-
android/app/google-services.json
- Removed outdated
client_identry.
- Removed outdated
-
emulator_data/auth_export/accounts.json
- Updated exported authentication data for the Firebase emulator.
-
lib/components/widgets/message_snack_bar.dart
- Modified
showMessageSnackBarto acceptTextStylefor title and message, improving customization.
- Modified
-
lib/features/add_client/add_cliend_page.dart
- Enhanced form validation logic with
PageStatusmanagement. - Adjusted the save client flow to handle errors and show messages using
showMessageSnackBar.
- Enhanced form validation logic with
-
lib/features/add_client/add_client_controller.dart
- Reworked save client logic to utilize the new
PageStatussystem. - Refactored controller to ensure compatibility with form validation changes.
- Reworked save client logic to utilize the new
-
lib/features/clients/clients_page.dart
- Implemented
StreamBuilderto display clients dynamically from the Firebase Firestore.
- Implemented
-
lib/locator.dart
- Registered
AbstractClientRepositoryandClientFirebaseRepositoryto dependency injection.
- Registered
-
lib/repository/firestore/
- Refactored the repository structure, renaming files to
firebase_storeto reflect the Firebase store focus. - Added abstraction for repositories:
AbstractClientRepositoryandAbstractAddressClientRepository.
- Refactored the repository structure, renaming files to
-
lib/stores/mobx/add_client_store.dart
- Added
PageStatusto manage page loading state. - Improved error handling in the form submission process.
- Added
-
test/repository/firestore/client_firebase_repository_test.dart
- Updated repository tests to reflect the new structure and naming conventions.
This update enhances Firebase emulator handling, improves client management with better error handling and state management, and refactors the repository structure to be more scalable and consistent.
Added Firebase emulator setup, enhanced client repository, and integrated Remote Config for Google API key.
-
.gitignore
- Added
.envfiles to the ignore list.
- Added
-
Makefile
- Added
firebase_emucommand for starting Firebase emulators.
- Added
-
android/app/build.gradle
- Added Firebase Remote Config and Analytics dependencies.
-
android/app/google-services.json
- Added Firebase Realtime Database URL.
-
android/app/src/main/AndroidManifest.xml
- Set
android:usesCleartextTraffic="true"for development with an emulator.
- Set
-
Firebase Emulator Data
- Added pre-configured data for the Firebase Auth and Firestore emulators.
-
firebase.json
- Updated emulator ports and added configuration for Remote Config.
-
firestore.rules
- Updated Firestore rules to include user roles (
admin,business,delivery) and subcollection permissions forclientsandaddresses.
- Updated Firestore rules to include user roles (
-
Cloud Functions
- Initialized Python-based Firebase Cloud Functions setup.
-
lib/common/models/address.dart
- Added
geoAddressgetter for geolocation and movedtoMapmethod.
- Added
-
lib/common/models/client.dart
- Added error handling and updates for address management.
-
lib/features/add_client/add_cliend_page.dart
- Added functionality to save clients with geolocation.
-
lib/features/add_client/add_client_controller.dart
- Implemented saving logic for client creation with Firebase Firestore.
-
lib/main.dart
- Integrated Firebase emulator setup for development.
-
lib/repository/firebase/firebase_auth_repository.dart
- Updated Firebase authentication error codes.
-
lib/repository/firestore/client_firebase_repository.dart (New)
- Added methods to manage clients in Firebase Firestore, including adding, updating, and deleting clients.
-
lib/services/geolocation_service.dart (New)
- Added geolocation service to retrieve coordinates from a Google API for client addresses.
-
lib/services/remote_config.dart (New)
- Added Firebase Remote Config integration to fetch Google API key.
-
lib/stores/mobx/add_client_store.dart
- Integrated geolocation for addresses during client creation.
-
Firebase Remote Config
- Added template for remote configuration in
remoteconfig.template.json.
- Added template for remote configuration in
-
Tests
- Created tests for
ClientFirebaseRepositoryusing Firebase emulators.
- Created tests for
This commit introduces Firebase emulator setup, extends Firestore client repository functionalities, and integrates Firebase Remote Config for managing Google API keys, along with comprehensive tests.
Refactored and improved address management, added client-related features, and enhanced UI components.
-
lib/common/models/address.dart
- Renamed file from
adreess.darttoaddress.dart. - Updated
addressStringmethod to use "Endereço" and handle cases where the address number is not provided (S/Nfor "sem número").
- Renamed file from
-
lib/common/models/client.dart
- Updated the import of
address.dartafter the file rename.
- Updated the import of
-
lib/common/theme/app_text_style.dart
- Added
font12Heighttext style with adjustable line height.
- Added
-
lib/features/add_client/add_cliend_page.dart (New File)
- Created the
AddCliendPagefor adding clients, with fields for name, email, phone, and address. - Added dropdown for address type selection and error handling for invalid inputs.
- Created the
-
lib/features/add_client/add_client_controller.dart (New File)
- Created the
AddClientControllerto manage state and handle form inputs for the client creation page.
- Created the
-
lib/features/clients/clients_controller.dart (New File)
- Created a simple controller
ClientsControllerwith aninitmethod for the clients page.
- Created a simple controller
-
lib/features/clients/clients_page.dart (New File)
- Created the
ClientsPageto display a list of clients and a button to add new clients.
- Created the
-
lib/features/home/home_page.dart
- Added the
_clientsmethod to navigate to theClientsPage. - Updated the
HomeDrawerto include a "Clientes" option.
- Added the
-
lib/features/home/widgets/home_drawer.dart
- Updated
HomeDrawerto include aListTilefor navigating to the clients section.
- Updated
-
lib/my_material_app.dart
- Added routes for
ClientsPageandAddCliendPage.
- Added routes for
-
lib/stores/mobx/add_client_store.dart (New File)
- Created the
AddClientStoreusing MobX to manage the state of the client form, including address validation via the ViaCep API. - Added error handling and validation for name, email, phone, and CPF.
- Created the
-
lib/stores/mobx/personal_data_store.dart
- Updated the import of
address.dartafter the file rename.
- Updated the import of
This commit introduces a new client management feature, improves address handling, and adds several new UI components and stores for better form validation and data handling.
Added new text styles and updated various UI components to enhance user experience.
-
lib/common/theme/app_text_style.dart
- Added new text styles:
font12Bold,font14SemiBold,font15,font15Bold,font16,font16Bold, andfont18. - These styles provide more flexibility for different text sizes and weights across the application.
- Added new text styles:
-
lib/components/widgets/message_snack_bar.dart
- Refactored
showMessageSnackBarto include an optionaltitleparameter and updated themessageparameter to accept aWidget. - Added
closeIconandanimationfor improved user interaction. - Modified
SnackBarshape for better alignment and visual appearance.
- Refactored
-
lib/components/widgets/simple_message.dart (New File)
- Created
SimpleMessagewidget for displaying simple messages with optional icons based on message type. - Added a
MessageTypeenum to support different message types:none,error, andwarning. - Provided a static
openmethod for easily displaying the message in a dialog.
- Created
-
lib/features/sign_in/sign_in_controller.dart
- Added
sendPasswordResetEmailmethod for sending a password reset email.
- Added
-
lib/features/sign_in/sign_in_page.dart
- Updated
_signInand_recoverPasswordmethods to display rich text messages with different styles based on conditions. - Added a button for users to recover their password via email, integrating with the new reset password functionality.
- Created a
SnackBarTitlewidget to display titles in theSnackBar.
- Updated
-
lib/features/sign_up/sign_up_page.dart
- Enhanced the
signUpmethod to display the message using theTextwidget with custom styles. - Improved the error and success feedback to the user when signing up.
- Enhanced the
-
lib/repository/firebase/auth_repository.dart
- Added the
sendPasswordResetEmailmethod definition for password reset functionality.
- Added the
-
lib/repository/firebase/firebase_auth_repository.dart
- Implemented
sendPasswordResetEmailmethod to send password reset emails using Firebase'sauthAPI.
- Implemented
-
lib/stores/mobx/sign_in_store.dart
- Added
isEmailValidmethod to validate email format and ensure it's correct before performing actions.
- Added
This commit introduces several new text styles and UI improvements, along with the ability to send password reset emails. It enhances the feedback provided to users in various flows like sign-in and sign-up.
Implement personal data handling and splash screen initialization
In this commit, several improvements and additions were made to the code. The AddressModel class now includes new fields such as type, latitude, longitude, and updatedAt, allowing better control over address types and geographical coordinates. The serialization and deserialization of the model were updated to handle these new attributes. Additionally, the string representation of the address was modified to include the address type.
A new ClientModel class was introduced to manage client data, which includes fields for name, email, phone, and an associated AddressModel. Serialization methods and helper functions were added for easy handling of client data.
Other significant changes include updates to the UserRole enum, which renamed client and consumer to business for better clarity. The HomeController and HomePage now check if the user has a phone number and redirects to the PersonDataPage if it's missing.
Additionally, the DeliveryPersonController was removed and replaced by the PersonController to handle personal data. The PersonDataPage was introduced to manage and update user personal information, such as phone numbers and addresses.
Finally, the commit adds a SplashPage and SplashController for handling the app's splash screen and initializing user data when the app launches. Several adjustments were made to controllers and routes to accommodate these new features.
-
lib/common/models/adreess.dart
- Imported
dart:convertto handle JSON serialization. - Added
type,latitude, andlongitudeproperties toAddressModel. - Updated the constructor to initialize
typeas 'Residencial',latitude,longitude, andupdatedAtwith default values. - Modified the
addressStringmethod to include thetypein the string representation. - Added
updatedAtto store the last update time. - Updated
copyWithto handle the new properties (type,latitude,longitude,updatedAt). - Modified
toMapandfromMapto serialize and deserialize the new properties. - Added
toJsonandfromJsonmethods for JSON conversion. - Overrode
==andhashCodeto include the new properties.
- Imported
-
lib/common/models/client.dart
- Created
ClientModelto represent a client entity with fields such asid,name,email,phone,address, and timestamps (createdAt,updatedAt). - Added
copyWithmethod to create a copy of the object with modified values. - Implemented
toMapandfromMapmethods for serialization and deserialization of the client model. - Added
toJsonandfromJsonmethods for JSON conversion. - Overrode
==andhashCodefor object comparison. - Implemented
toStringmethod for string representation of the client model.
- Created
-
lib/common/models/user.dart
- Renamed the
clientrole tobusinessin theUserRoleenum to better reflect the role’s purpose.
- Renamed the
-
lib/components/widgets/custom_text_field.dart
- Added the
textCapitalizationparameter to customize text capitalization behavior.
- Added the
-
lib/features/home/home_controller.dart
- Added
storeas a new property initialized toHomeStore. - Updated
init()method to check if the user is logged in and set thestore.hasPhoneaccordingly.
- Added
-
lib/features/home/home_page.dart
- Updated the floating action button to navigate to
PersonDataPageinstead of the old delivery person page. - Added post-frame callback in
initStateto redirect toPersonDataPageif the user does not have a phone number registered.
- Updated the floating action button to navigate to
-
lib/features/person_data/person_data_controller.dart
- Created
PersonControllerto manage personal data input, including phone verification. - Implemented
save()method to request phone number verification and handle SMS code input through a custom dialog.
- Created
-
lib/features/person_data/person_data_page.dart
- Renamed from
DeliveryPersonPagetoPersonDataPageto generalize the functionality for personal data input. - Updated the UI to reflect personal data input (phone, ZIP code, etc.) instead of delivery person data.
- Renamed from
-
lib/features/person_data/widgets/text_input_dialog.dart
- Created a new widget
TextInputDialogto display a dialog for SMS code input, allowing for future extensions.
- Created a new widget
-
lib/features/sign_in/sign_in_controller.dart
- Refactored the
init()method to no longer initialize the user directly since this is handled elsewhere. - Added
userStatusgetter to expose the current user’s status.
- Refactored the
-
lib/features/sign_in/sign_in_page.dart
- Updated the navigation behavior to use
Navigator.pushReplacementNamedfor better user experience when transitioning between pages.
- Updated the navigation behavior to use
-
lib/features/sign_up/sign_up_page.dart
- Removed the back button from the app bar for consistency during sign-up.
-
lib/features/splash/splash_controller.dart
- Created
SplashControllerto manage initialization logic for the splash screen, including checking if the user is logged in.
- Created
-
lib/features/splash/splash_page.dart
- Created a new
SplashPageto serve as the app’s initial screen, showing loading animations and handling navigation based on the user’s login state.
- Created a new
-
lib/my_material_app.dart
- Set
SplashPageas the initial route. - Updated the route for
PersonDataPageto replace the old delivery person route.
- Set
-
lib/repository/firebase/firebase_auth_repository.dart
- Refactored
requestPhoneNumberVerificationto format the phone number properly and handle verification via Firebase’s phone authentication.
- Refactored
-
lib/stores/mobx/home_store.dart
- Created
HomeStoreto manage user-specific states such ashasPhoneandhasAddress.
- Created
-
lib/stores/mobx/personal_data_store.dart
- Renamed from
DeliveryPersonStoretoPersonalDataStoreto reflect its broader role in managing personal data.
- Renamed from
-
lib/stores/user/user_store.dart
- Added a new observable property
userStatusto track user authentication status changes. - Updated the
initializeUser,signUp, andlogoutmethods to toggleuserStatusbased on the user’s authentication state.
- Added a new observable property
Add Project Delivery Scrum Plan and Firebase Configuration
This commit introduces detailed planning for the Project Delivery using Scrum methodology and updates to the Firebase configuration and authentication flow.
-
Projeto Delivery Scrum.md- Added a comprehensive project planning document, including initial setup, user authentication, profile management, delivery request handling, geolocation, notifications, and admin control.
-
database.rules.json- Added default Firebase database security rules to disable read and write access by default for all users.
-
firebase.json- Configured Firebase emulators for authentication, Firestore, and storage.
- Linked database rules and Firestore index settings to the project.
-
firestore.indexes.json- Created an empty Firestore index configuration for future usage.
-
firestore.rules- Added Firestore security rules, defining permissions for user documents and app settings.
-
lib/common/models/user.dart- Extended the
UserModelclass to include new fields:emailVerified,photoURL,creationAt, andlastSignIn. - Introduced a new method
ptUserRoleto map user roles to titles and icons.
- Extended the
-
lib/common/theme/app_text_style.dart- Added several new text styles for different font sizes and weights.
-
lib/features/home/home_controller.dart- Integrated current user data retrieval into the
HomeController.
- Integrated current user data retrieval into the
-
lib/features/home/home_page.dart- Refactored the theme toggle button for better readability and consistency.
-
lib/features/home/widgets/custom_drawer_header.dart- Created a new custom widget for the drawer header that displays user information and a dynamic background image.
-
lib/features/home/widgets/home_drawer.dart- Refactored to use
CustomDrawerHeaderfor better modularization.
- Refactored to use
-
lib/features/sign_in/sign_in_controller.dart- Refactored the
signInmethod to align with new authentication flow.
- Refactored the
-
lib/features/sign_in/sign_in_page.dart- Added a theme toggle button to the app bar for improved UI consistency.
-
lib/features/sign_up/sign_up_controller.dart- Removed phone number validation and integrated email verification upon signup.
-
lib/features/sign_up/sign_up_page.dart- Updated the signup flow to guide the user to confirm their email for account activation.
-
lib/locator.dart- Registered and disposed of user-related services.
-
lib/repository/firebase/auth_repository.dart- Refactored authentication repository to support email and phone verification.
-
lib/repository/firebase/firebase_auth_repository.dart- Enhanced authentication logic, including phone verification and email confirmation handling.
-
lib/repository/firestore/user_firestore_repository.dart- Refactored user repository to handle Firestore interactions with extended attributes.
-
lib/repository/firestore/user_repository.dart- Added a new abstract repository for user-related Firestore operations.
-
lib/stores/mobx/sign_up_store.dart- Removed phone validation logic from the sign-up store.
-
lib/stores/user/user_store.dart- Refactored user store to support email link verification and new user authentication flow.
-
pubspec.lock,pubspec.yaml- Adjusted dependencies to move
build_runnerto dev dependencies for optimization.
- Adjusted dependencies to move
This commit structures the project with clear deliverables, improved user authentication logic, and enhanced modularization for future scalability.
Refactor and Enhance User Authentication and Management
This commit refactors several parts of the codebase to enhance user authentication, user management, and general structure for better maintainability and functionality.
-
lib/common/models/user.dart- Fixed a typo in the
userStatusmap conversion frommap['UserStatus']tomap['userStatus']to align with camelCase naming conventions.
- Fixed a typo in the
-
lib/common/settings/app_settings.dart- Updated the import path for
local_storage_service.dartfrom../storage/to../../services/for consistency with the new directory structure.
- Updated the import path for
-
lib/components/widgets/message_snack_bar.dart- Imported
app_text_style.dartfor consistent text styling. - Changed
messageparameter type fromWidgettoString. - Updated
timedefault value from3to5seconds for longer visibility. - Adjusted
SnackBarcontent to use aTextwidget with styling fromAppTextStyle. - Added
textColorforSnackBarActionto enhance visual clarity.
- Imported
-
lib/components/widgets/password_text_field.dart- Introduced a new optional callback
onFieldSubmitted. - Adjusted constructor parameters for better flexibility and default values.
- Enhanced
TextFieldsubmission logic to unfocus and callonFieldSubmittedif provided.
- Introduced a new optional callback
-
lib/features/home/home_controller.dart- Removed unused imports and Firebase authentication logic for a cleaner, more focused controller.
- Simplified
initmethod by removing the subscription to user status changes.
-
lib/features/home/widgets/home_drawer.dart- Updated color handling to consider both light and dark themes, improving UI consistency.
-
lib/features/sign_in/sign_in_controller.dart- Added import for
data_result.dart. - Refactored
signInmethod to return aDataResult<UserModel>for more explicit error handling and response management.
- Added import for
-
lib/features/sign_in/sign_in_page.dart- Added import for
mobx.dart. - Introduced a
ReactionDisposerto manage MobX reactions. - Updated
_signInmethod to handle responses with detailed error messages.
- Added import for
-
lib/features/sign_up/sign_up_controller.dart- Added a getter
isLoggedInto check if the user is logged in.
- Added a getter
-
lib/features/sign_up/sign_up_page.dart- Added import for
mobx.dart. - Introduced a
ReactionDisposerto manage MobX reactions for user login state changes. - Improved feedback messages in the
_signUpmethod for better user guidance.
- Added import for
-
lib/locator.dart- Updated import path for
local_storage_service.dartto reflect the new directory structure.
- Updated import path for
-
lib/repository/firebase/auth_repository.dart- Created a new
AuthRepositoryclass for handling all authentication-related tasks. - Implemented various methods for user authentication, profile updates, and monitoring authentication state.
- Created a new
-
lib/repository/firestore/user_firestore_repository.dart- Standardized log messages for consistency and clarity.
- Updated method names for better alignment with functionality.
-
lib/services/local_storage_service.dart- Renamed from
lib/common/storage/local_storage_service.darttolib/services/local_storage_service.dartto follow new directory organization. - Adjusted import paths accordingly.
- Renamed from
-
lib/stores/user/user_store.dart- Refactored to use the new
AuthRepositoryfor authentication tasks. - Simplified user state management and initialization logic.
- Improved login, sign-up, and logout methods for better error handling and response management.
- Refactored to use the new
-
lib/stores/user/user_store.g.dart- Updated generated code to reflect changes in the
UserStorefor MobX state management.
- Updated generated code to reflect changes in the
This commit enhances the overall structure and usability of the authentication system, providing a more streamlined and error-resilient approach to user management.
Refactor: Implement local storage service and enhance user management
This commit introduces a refactor to the codebase, focusing on implementing a new local storage service and enhancing user management across the application. The key changes are as follows:
-
Refactoring App Settings
- Replaced direct usage of
SharedPreferencesinAppSettingswith a newLocalStorageServicefor more modular and testable code. - Updated methods to use the new local storage service (
setIsDark,setAdminChecked).
- Replaced direct usage of
-
New LocalStorageService Added
- Created
lib/common/storage/local_storage_service.dartto encapsulate all local storage operations, including:- Theme settings (
isDark,setIsDark). - Admin check status (
adminChecked,setAdminChecked). - User caching (
setCachedUser,getCachedUser,clearCachedUser).
- Theme settings (
- Created
-
Updates to SignIn and SignUp Controllers
- Refactored
SignInControllerandSignUpControllerto usepageStoreinstead ofsignUpStorefor improved readability and consistency. - Enhanced the controllers to utilize the newly introduced
LocalStorageServicefor better state management.
- Refactored
-
Enhanced User Store with Local Caching
- Modified
UserStoreto useLocalStorageServicefor caching the current user and maintaining user session state. - Added methods for retrieving the current user from local storage or Firestore if not found locally.
- Modified
-
Firestore and Firebase Auth Repository Enhancements
- Introduced constants for Firestore collection and document names to improve maintainability and reduce hardcoded strings.
- Updated
FirebaseAuthRepositoryto integrate with local storage checks for the first user admin setup.
-
UI and Page Logic Updates
- Adjusted
SignInPageandSignUpPageto work with the updated controller logic, ensuring correct usage of stores and state management. - Improved the UI flow by utilizing cached user data where applicable to enhance user experience and reduce redundant network calls.
- Adjusted
-
Dependency Injection Setup Updates
- Updated
locator.dartto register the newLocalStorageServiceas a singleton, ensuring consistent usage across the application.
- Updated
-
Removed Deprecated or Unused Files
- Deleted obsolete files like
firebase_storage_repository.dartandsign_up_store.dartunderauthto clean up the codebase.
- Deleted obsolete files like
These changes collectively improve the overall code structure, enhance modularity, and optimize user management and state handling across the Flutter application.
Addition of new assets, refactoring of user model and controllers, and improvements to settings and authentication
This commit introduces several enhancements and refactors to the codebase, focusing on the user model, settings management, and new assets for the UI. Key changes include:
-
New Assets Added
- Added multiple new image assets to
assets/images/:delivery_00.jpg,delivery_02.jpg,delivery_03.jpg,delivery_04.jpg,delivery_name.png,text2871-7.png. - Updated existing image
delivery_01.jpg. - Added a new SVG asset
drawing.svgtoassets/svg/for improved graphic representation.
- Added multiple new image assets to
-
lib/common/models/user.dart
- Expanded
UserModelto includeid,role, anduserStatusproperties. - Introduced serialization methods (
toMap,fromMap,toJson,fromJson) for easier data handling and storage. - Added new enums
UserRoleandUserStatusfor better role management and user status tracking.
- Expanded
-
lib/common/settings/app_settings.dart
- Integrated
SharedPreferencesfor persistent app settings management. - Added methods for initialization, loading settings, toggling brightness, and tracking admin check status.
- Improved handling of brightness settings with
ValueNotifier.
- Integrated
-
lib/common/utils/data_result.dart
- Refactored error classes, renamed
FirebaseFailuretoFireAuthFailureand introducedFireStoreFailurefor more specific error handling.
- Refactored error classes, renamed
-
lib/features/home/home_controller.dart
- Integrated
AppSettingsthrough dependency injection for managing app settings directly within the controller. - Added new methods to check if the theme is dark and toggle brightness.
- Integrated
-
lib/features/home/home_page.dart
- Refactored to use a new
HomeDrawerwidget for the navigation drawer, separating concerns and improving code readability. - Added logout and login functionality handlers.
- Refactored to use a new
-
lib/features/home/widgets/home_drawer.dart
- Created a new
HomeDrawerwidget to manage the app's navigation drawer, improving modularity and encapsulation of drawer-related logic.
- Created a new
-
lib/features/sign_in/sign_in_page.dart
- Simplified imports and organized code structure for better maintainability.
-
lib/features/sign_up/sign_up_controller.dart
- Refactored to include
MaskedTextControllerfor formatted phone number input. - Adjusted logic to handle user role assignment during the signup process.
- Refactored to include
-
lib/features/sign_up/sign_up_page.dart
- Enhanced the signup form with additional fields and validation for role selection, phone number, and user status.
- Improved user experience with better error handling and feedback.
-
lib/locator.dart
- Updated service locator setup to include new dependencies and maintain proper dependency injection throughout the app.
-
lib/main.dart
- Updated initialization process to include
AppSettingssetup for persistent storage and settings management.
- Updated initialization process to include
-
lib/my_material_app.dart
- Refactored imports and dependencies to streamline the app initialization and usage of shared settings.
-
lib/repository/firebase/firebase_auth_repository.dart
- Enhanced user creation logic to set user roles dynamically based on admin checks.
- Improved error handling and logging for authentication-related operations.
-
lib/repository/firestore/user_firestore_repository.dart
- Introduced a new repository for handling Firestore operations related to the user, including add, set, update, delete, get, and getAll methods.
-
lib/services/firebase_service.dart
- Simplified import statements and improved service initialization logic.
-
lib/stores/mobx/common/generic_functions.dart
- Refactored utility functions into a common directory for better organization.
-
lib/stores/mobx/sign_in_store.dart and lib/stores/mobx/sign_up_store.dart
- Improved store classes with better state management, validation methods, and error handling.
- Added role management and validation for new fields such as phone number.
-
pubspec.yaml and pubspec.lock
- Added new dependencies:
shared_preferencesfor persistent storage andget_itfor service locator. - Updated dependency versions and lock file to reflect the new additions and changes.
- Added new dependencies:
These changes collectively improve the overall functionality, user experience, and maintainability of the codebase, enhancing authentication processes, state management, and UI components.
Enhancements and improvements to user authentication, state management, and UI components
This commit introduces several enhancements and improvements across various files to improve user authentication, state management, and UI components. Key changes include:
-
android/app/src/main/AndroidManifest.xml
- Commented out an intent filter for deep linking to
example.comto prevent unintended navigation behavior.
- Commented out an intent filter for deep linking to
-
assets/images/delivery_01.jpg
- Added a new image asset
delivery_01.jpgfor use in the drawer header.
- Added a new image asset
-
lib/common/models/user.dart
- Created a new
UserModelclass to represent user data, including name, email, phone, and password.
- Created a new
-
lib/common/settings/app_settings.dart
- Removed singleton pattern for
AppSettingsin favor of dependency injection.
- Removed singleton pattern for
-
lib/components/widgets/message_snack_bar.dart
- Added a utility widget
showMessageSnackBarto display messages using aSnackBar.
- Added a utility widget
-
lib/components/widgets/password_text_field.dart
- Added
focusNodeandnextFocusproperties to improve form navigation and accessibility.
- Added
-
lib/components/widgets/state_loading.dart
- Introduced
StateLoadingwidget to display a loading indicator overlay.
- Introduced
-
lib/features/home/home_controller.dart
- Integrated
UserStorefor managing user authentication state. - Added a
logoutmethod to handle user sign-out functionality.
- Integrated
-
lib/features/home/home_page.dart
- Updated to use
AppSettingsthrough dependency injection. - Added a navigation drawer with logout functionality and a new image header.
- Updated to use
-
lib/features/sign_in/sign_in_controller.dart
- Created
SignInControllerto manage user sign-in logic and state.
- Created
-
lib/features/sign_in/sign_in_page.dart
- Refactored to utilize
SignInControllerfor managing form input and sign-in logic. - Enhanced user experience with error handling and form validation.
- Refactored to utilize
-
lib/features/sign_up/sign_up_controller.dart
- Added
SignUpControllerto manage user registration process and state.
- Added
-
lib/features/sign_up/sign_up_page.dart
- Refactored to use
SignUpControllerand improved form validation and error handling.
- Refactored to use
-
lib/locator.dart
- Introduced a service locator using
GetItfor dependency injection across the application.
- Introduced a service locator using
-
lib/main.dart
- Set up dependency injection by calling
setupDependencies()during app initialization.
- Set up dependency injection by calling
-
lib/my_material_app.dart
- Updated to utilize
AppSettingsvia dependency injection through the service locator.
- Updated to utilize
-
lib/repository/firebase/firebase_auth_repository.dart
- Enhanced Firebase authentication repository with additional error handling and profile update methods.
-
lib/stores/mobx/generic_functions.dart
- Added utility functions for common form validation tasks.
-
lib/stores/mobx/sign_in_store.dart
- Created
SignInStoreto manage state and validation for the sign-in form.
- Created
-
lib/stores/mobx/sign_up_store.dart
- Enhanced
SignUpStorewith additional validation methods and state management.
- Enhanced
-
lib/stores/user/user_store.dart
- Refactored
UserStoreto include detailed user state management and profile handling.
- Refactored
-
pubspec.lock
- Updated to include new dependencies:
firebase_dynamic_linksandget_it.
- Updated to include new dependencies:
-
pubspec.yaml
- Updated app version to
0.0.1+3. - Added new dependencies for dynamic links and dependency injection.
- Updated app version to
These changes improve the overall user experience by enhancing the authentication process, simplifying state management, and providing a more robust and user-friendly interface.
Initial commit for setting up Firebase integration and project structure
This commit introduces Firebase integration and sets up the basic project structure for the delivery control app. The following changes have been made:
-
.firebaserc
- Created a new
.firebasercfile to define the Firebase project configuration.
- Created a new
-
Makefile
- Added a
Makefilefor common build and development tasks, such as cleaning the project, generating diffs, and pushing commits.
- Added a
-
android/app/build.gradle
- Updated
build.gradleto include dependencies for Firebase Authentication and Google Play services.
- Updated
-
android/settings.gradle
- Updated the Kotlin plugin version to
2.0.20.
- Updated the Kotlin plugin version to
-
firebase.json
- Modified
firebase.jsonto include emulator configuration and updated platform settings for Firebase.
- Modified
-
lib/common/theme/app_text_style.dart
- Created a new
AppTextStyleclass to define common text styles.
- Created a new
-
lib/common/utils/data_result.dart
- Added a new
FirebaseFailureclass to handle Firebase-specific errors.
- Added a new
-
lib/components/widgets/big_bottom.dart
- Created a
BigButtonwidget to provide a customizable button component.
- Created a
-
lib/components/widgets/custom_text_field.dart
- Added a
fullBorderparameter to control the appearance of text field borders.
- Added a
-
lib/components/widgets/password_text_field.dart
- Introduced a
PasswordTextFieldwidget with customizable parameters for enhanced user input security.
- Introduced a
-
lib/features/home/home_controller.dart
- Implemented
HomeControllerto manage user authentication states and subscription handling.
- Implemented
-
lib/features/home/home_page.dart
- Updated
HomePageto integrateHomeControllerfor managing authentication states.
- Updated
-
lib/features/sign_in/sign_in_page.dart
- Added
SignInPageto handle user login functionality.
- Added
-
lib/features/sign_up/sign_up_page.dart
- Added
SignUpPageto facilitate user registration with form validation.
- Added
-
lib/main.dart
- Refactored the main entry point to use
FirebaseServicefor initializing Firebase.
- Refactored the main entry point to use
-
lib/my_material_app.dart
- Updated the app's routing configuration to include
SignInPageandSignUpPage.
- Updated the app's routing configuration to include
-
lib/repository/firebase/firebase_auth_repository.dart
- Created
FirebaseAuthRepositoryfor managing Firebase authentication operations.
- Created
-
lib/services/firebase_service.dart
- Introduced
FirebaseServicefor handling Firebase initialization and logging.
- Introduced
-
lib/stores/auth/sign_up_store.dart
- Set up MobX store
SignUpStoreto manage the state and validation of user input during sign-up.
- Set up MobX store
-
lib/stores/user/user_store.dart
- Created
UserStoreto manage user authentication states and operations using MobX.
- Created
-
lib/stores/user/user_store.g.dart
- Generated MobX store code for
UserStore.
- Generated MobX store code for
-
pubspec.yaml
- Bumped version to
0.0.1+2to reflect the updated project configuration.
- Bumped version to
This commit establishes the foundation for the delivery control app with Firebase integration, user authentication, and structured codebase for further development.