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.json
andandroid/app/GoogleService-Info.plist
to 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.dart
to facilitate Google Maps navigation. - Added
_openGoogleNavigationApp()
method to initiate Google Maps navigation for deliveries. - Modified button functionality:
- Changed the button to call
ctrl.fetchGoogleRoute
for 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
GoogleNavigationLauncher
to 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_linux
plugin to allow URL launching capabilities on Linux.
- Registered
-
pubspec.yaml & pubspec.lock:
- Added
url_launcher
version 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 mapController
withLateFinal<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
googleApiKey
as aLateFinal<String>
for secure and controlled API key initialization. - Added
isStarted
,polylineCoordinates
, andpolylines
attributes to manage the map state and route visualization. - Updated
onMapCreated()
method to useLateFinal
for 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.fetchGoogleRoute
to fetch and display route information. - Enhanced
GoogleMap
widget to includepolylines
fromctrl.polylines
, allowing users to view optimized delivery routes.
-
lib/services/extensions_services.dart:
- Added new extensions:
LatLngExtension
andGeoPointExtension
to convert betweenLatLng
,GeoPoint
, andPointLatLng
, simplifying code readability and reuse.
- Added new extensions:
-
lib/services/navigation_route.dart:
- Added the
lastLatLng
getter to retrieve the last delivery point, improving route management functionality. - Imported
extensions_services.dart
to utilize the newly definedLatLng
andGeoPoint
extensions.
- Added the
-
pubspec.yaml & pubspec.lock:
- Added
flutter_polyline_points
version 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
DeliveryModel
to manage deliveries within the controller. - Modified the
init
method to include a list ofDeliveryModel
deliveries. - Implemented
reversedOrder
method to reverse the delivery order and update the UI. - Added
changeOrder
method to allow swapping of delivery points based on user interaction.
- Added
-
lib/features/user_delivery/delivery_map/delivery_map_page.dart:
- Updated
DeliveryMapPage
to accept adeliveries
parameter and initializedDeliveryMapStore
with the length of deliveries. - Enhanced the user interface with additional buttons for reversing delivery order and resetting counters using
IconButton
widgets. - Integrated
ValueListenableBuilder
to 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
DeliveryMapStore
to manage the length of deliveries. - Added a
count
ValueNotifier 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
setDeliveriesPoints
function as deliveries are now managed directly by theDeliveryMapController
.
- Removed the
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated
_createRoutes
to passctrl.deliveries
as an argument toDeliveryMapPage
, ensuring the correct data flow.
- Updated
-
lib/my_material_app.dart:
- Updated
onGenerateRoute
to correctly pass thedeliveries
data toDeliveryMapPage
when generating the route.
- Updated
-
lib/services/navigation_route.dart:
- Added
reversedOrder
to reverse the current delivery order. - Added
swapOrderIds
to 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:
init
to initialize theDeliveryMapStore
.dispose
to properly clean up resources.createBasicRoutes
to generate basic delivery routes and set page states accordingly.
- Added
createNumberedMarker
to 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
Wrap
widget for better UI alignment. - Updated the lifecycle (
initState
anddispose
) 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
DeliveryMapStore
to 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
createBasicRoutes
method tosetDeliveriesPoints
for 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
_createRoutes
to call the renamedsetDeliveriesPoints
method 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
FIXME
comment to highlight a potential dependency issue forUserDeliveryStore
. - Removed redundant
_setLoadingState
and_setErrorState
methods to simplify state management. - Updated methods to directly set the store state (
setState
) or call_setError
to 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.dart
tomodel_functions.dart
for better accuracy.
- Corrected import typo from
-
lib/common/models/client.dart:
- Fixed import typo from
model_finctions.dart
tomodel_functions.dart
.
- Fixed import typo from
-
lib/common/models/deliver_order.dart (new file):
- Added the
DeliveryOrder
class to represent a delivery order, containing information such as delivery ID, client name, address, phone number, and client location. - Introduced a method
fromDelivery
to createDeliveryOrder
instances fromDeliveryModel
.
- Added the
-
lib/common/models/delivery.dart:
- Corrected import typo from
model_finctions.dart
tomodel_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.dart
tomodel_functions.dart
for better clarity.
- Renamed from
-
lib/common/models/shop.dart:
- Fixed import typo from
model_finctions.dart
tomodel_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
DeliveryMapController
to 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
createBasicRoutes
function to generate basic delivery routes based on the available deliveries. - Added a reference to the
NavigationRoute
service for route calculation.
- Added a
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Integrated
DeliveryMapPage
for 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
deliveries
to useValueNotifier
to track state changes reactively.
- Updated
-
lib/locator.dart:
- Registered the
NavigationRoute
service 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
DeliveryMapPage
in the application router.
- Added a route for
-
lib/repository/firebase_store/abstract_deliverymen_repository.dart:
- Removed deprecated
getCurrentGeoFirePoint
function 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
NavigationRoute
service 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
_deliveriesSubscription
after 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.dart
tomanager_list_view.dart
for a more descriptive and consistent naming convention. - Updated class name from
ShowDeliveryList
toManagerListView
and 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 (
ManagerListView
instead ofShowDeliveryList
).
- Updated references to the renamed file and class (
-
lib/repository/firebase_store/abstract_deliveries_repository.dart:
- Modified the default value for
toStatus
in theupdateDeliveryStatus
method fromDeliveryStatus.orderInTransit
toDeliveryStatus.orderPickedUpForDelivery
for more accurate status progression.
- Modified the default value for
-
lib/repository/firebase_store/deliveries_firebase_repository.dart:
- Adjusted the default value of
toStatus
inupdateDeliveryStatus
method toDeliveryStatus.orderPickedUpForDelivery
. - Modified the condition from
isGreaterThan
toisEqualTo
for delivery status filtering in thegetByDeliveryId
method 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.orderPickedUpForDelivery
back 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.orderPickedUpForDelivery
to theDeliveryStatus
enum, updating all subsequent status indices accordingly.
- Reintroduced
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_controller.dart:
- Added
DeliveryStatus
as a parameter to theinit
method ofDeliveriesController
. - Updated
_getDeliveries()
to retrieve deliveries based on the new status.
- Added
-
lib/features/user_delivery/tab_bar_views/deliveries/deliveries_page.dart:
- Updated
DeliveriesPage
to include aDeliveryStatus
parameter 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
ShowDeliveryList
to 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
orderPickedUpForDelivery
status.
-
lib/features/user_manager/tab_bar_views/manager_controller.dart:
- Refactored
_deliveriesSubscription
to properly fetch deliveries based on status. - Introduced a new
clearSelections
method for clearing selected deliveries.
- Refactored
-
lib/features/user_manager/user_manager_page.dart:
- Updated tab bar to include the
orderPickedUpForDelivery
status, 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=true
property to disable its use temporarily.
- Commented out the
-
lib/common/extensions/delivery_status_extensions.dart:
- Removed the
orderPickedUpForDelivery
status from the extension methods. - Updated relevant icons and text mappings to reflect the updated statuses.
- Removed the
-
lib/common/models/delivery.dart:
- Removed the
orderPickedUpForDelivery
status from theDeliveryStatus
enum. - Updated the remaining statuses with corresponding index comments for better readability.
- Removed the
-
lib/common/utils/create_qrcode.dart:
- Added an import for
dart:convert
to handle JSON encoding. - Modified the
_generateQRCode
method to accept aMap<String, dynamic>
instead of aString
to provide more structured data for QR code generation. - Adjusted text formatting within the PDF to make the
delivery.id
bold and abbreviate address components for clarity.
- Added an import for
-
lib/features/qrcode_read/qrcode_read_page.dart:
- Refactored the
MobileScannerController
initialization to simplify the configuration. - Added
_startScanning
call withininitState
to automatically start scanning upon page load. - Streamlined the
dispose
method to ensure proper resource cleanup, including usingunawaited
to prevent blocking.
- Refactored the
-
lib/features/show_qrcode/show_qrcode.dart:
- Added a
FilledButton
labeled "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
DeliveryCard
component 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
TabBar
for 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
_deliveriesSubscription
after 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
deliveriesSelected
after 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
getByDeliveryId
andupdateDeliveryStatus
to handle delivery updates based on delivery ID.
- Added new methods
-
lib/repository/firebase_store/deliveries_firebase_repository.dart:
- Implemented
updateDeliveryStatus
to allow changing the status of a delivery document in Firestore. - Added
getByDeliveryId
to 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.TextStyle
constant 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
gapless
property totrue
for better rendering quality.
-
lib/features/delivery_qrcode/delivery_qrcode.dart:
- Marked the
DeliveryQrcode
constructor asconst
to enable compile-time optimization where possible.
- Marked the
-
lib/features/show_qrcode/show_qrcode.dart (New File):
- Created the
ShowQrcode
page to display QR codes generated for deliveries. - Introduced a
convertPdfToImage
method 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
log
statement in_showQRCode
with a navigation call to push theShowQrcode
page, passing the delivery data as arguments. - Updated
_showQRCode
to handle multiple deliveries using a loop and async navigation toShowQrcode
.
- Replaced the
-
lib/my_material_app.dart:
- Added route handling for
ShowQrcode.routeName
, allowing theShowQrcode
page to be accessible throughout the app. - Defined a new case in the
onGenerateRoute
function to create a route for theShowQrcode
page 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
selected
to theDeliveryModel
class inlib/common/models/delivery.dart
. - Reorganized some properties to improve clarity.
- Added a new property
-
Created Delivery Info Model
- Added a new class
DeliveryInfoModel
inlib/common/models/delivery_info.dart
to simplify information transfer regarding deliveries.
- Added a new class
-
QR Code Generation Utility
- Added
lib/common/utils/create_qrcode.dart
to generate QR Codes and export them as PDFs. - Moved QR Code generation logic from
DeliveryQrcodeController
to this utility.
- Added
-
Updated Delivery Card and Custom ListTile
- Removed the
onTap
parameter fromCustomListTile
inlib/components/widgets/custom_list_tile.dart
. - Updated
DeliveryCard
inlib/components/widgets/delivery_card.dart
to include selection functionality (selected
) and added a button for additional actions.
- Removed the
-
Refactored User Business and User Admin Pages
- Modified
user_business_page.dart
anduser_admin_page.dart
to use the updatedDeliveryCard
widget with the newonTap
property.
- Modified
-
Removed Unused Controllers
- Deleted the old
delivery_qrcode_controller.dart
anduser_manager_store.dart
, moving relevant logic to the newManagerController
andManagerStore
classes.
- Deleted the old
-
Introduced New User Manager Components
- Created
manager_controller.dart
,manager_store.dart
, andshow_delivery_list.dart
to manage delivery-related workflows efficiently.
- Created
-
Updated Firebase Repository
- Enhanced
deliveries_firebase_repository.dart
to support filtering deliveries by status.
- Enhanced
-
Removed Dependency
- Removed
signals
dependency frompubspec.yaml
and 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
CustomAppBar
to provide a customizable app bar across different pages. - Implemented
ValueListenableBuilder
for 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
CustomAppBar
to manage settings fromAppSettings
.
- Created a dedicated controller for the
-
lib/components/widgets/custom_list_tile.dart:
- Added a
CustomListTile
widget 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
CustomListTile
for a more consistent UI design. - Introduced an optional
qrCodeButton
to display a QR code for each delivery.
- Refactored to use the newly added
-
lib/components/widgets/main_drawer/custom_drawer.dart:
- Introduced a new
CustomDrawer
widget 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
HomeController
to align it with theCustomDrawer
component. - 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.dart
anddelivery_qrcode_controller.dart
to manage the QR code generation and printing features. - Utilized the
printing
andpdf
packages to allow QR code generation as PDFs.
- Added
-
lib/features/home/home_page.dart:
- Replaced the old
HomeDrawer
with the newCustomDrawer
for better modularization. - Cleaned up the navigation code and improved page controller initialization.
- Replaced the old
-
lib/features/user_*:
- Updated
UserAdminPage
,UserBusinessPage
,UserDeliveryPage
, andUserManagerPage
to utilize theCustomAppBar
andCustomDrawer
, 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_deploy
to simplify the deployment of Firebase functions. - Added
schedule_clound
command to trigger thecheckReservedDeliveries
function locally via acurl
command.
- Added new command
-
Firebase Cloud Functions (
functions/index.js
)- Added
checkReservedDeliveries
function usingonSchedule
to automatically verify and reset delivery reservations older than 5 minutes.- This function scans for deliveries with the
orderReservedForPickup
status that were reserved more than 5 minutes ago and resets them. - It also updates the
updatedAt
timestamp and nullifies fields such asdeliveryId
,deliveryName
, anddeliveryPhone
.
- This function scans for deliveries with the
- Updated the
setUserClaims
function to specify thesouthamerica-east1
region for consistency. - Refactored imports for better clarity, including
FieldValue
from Firestore for timestamp updates.
- Added
-
Package Updates
- Updated dependencies in
functions/package-lock.json
andfunctions/package.json
.- Updated
firebase-functions
from version4.3.1
to6.0.1
for 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
surfaceContainer
tosurfaceContainerHigh
for better visibility. - Improved the layout of the
subtitle
to 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/firestore
for more direct Firestore interactions. - Updated
firebase-admin
to version12.6.0
and 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
phone
andaddress
to 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
ShopCard
widget to display information about a shop, including its deliveries. - Added parameters for
shopInfo
,action
,isExpanded
, andonExpansionChanged
to manage the UI state and user interactions effectively. - Implemented an
ExpansionTile
to show detailed shop information, including the number of deliveries and shop contact details.
- Introduced
-
lib/features/user_delivery/stores/user_delivery_store.dart
- Updated
deliveries
to useObservableList<ShopDeliveryInfo>
instead ofDeliveryExtended
, reflecting the new focus on shop-level data. - Modified
setDeliveries
method to accommodate the updatedShopDeliveryInfo
model, ensuring consistency in data handling.
- Updated
-
lib/features/user_delivery/user_delivery_controller.dart
- Renamed
changeStatus
reference tochangeDeliveryStatus
for better clarity and consistency in the codebase.
- Renamed
-
lib/features/user_delivery/user_delivery_page.dart
- Replaced
DeliveryCard
usage withShopCard
to display shop-level data, reflecting the updated model. - Introduced
_expandedState
map to manage the expanded state of eachShopCard
, providing a better user experience when interacting with multiple shops.
- Replaced
-
lib/managers/deliveries_manager.dart
- Updated
_processeNearbyDeliveries
to useShopDeliveryInfo
instead ofDeliveryExtended
, enhancing the organization of data at the shop level. - Modified the
_mapShopDeliveryInfoStream
method to group deliveries by shop, allowing for more efficient data handling and improved structure. - Added a new transformer
_deliveryToShopInfoTransformer
to convertDeliveryModel
streams intoShopDeliveryInfo
streams, 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.dart
to includeDeliveryExtended
information in the model. - Added a
deliveries
attribute of typeList<DeliveryExtended>
to store extended delivery information for each shop. - Added a
length
getter to provide the number of deliveries in the list. - Removed the
numberOfDeliveries
attribute as it is now inferred from thedeliveries
list.
- Imported
-
lib/components/widgets/delivery_card.dart
- Updated the phone number display in the
subtitle
to 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
changeStatus
tochangeDeliveryStatus
to improve clarity and consistency.
- Renamed the method reference
-
lib/managers/deliveries_manager.dart
- Refactored
getNearbyDeliveries
andrefreshNearbyDeliveries
methods to use_setLoadingState()
and_setErrorState()
for better code reuse and readability. - Replaced
changeStatus
method withchangeDeliveryStatus
, and moved the logic for updating the delivery status into a new private method_getUpdatedDeliveryStatus
to streamline the code. - Updated
_processeNearbyDeliveries
to use_subscribeToDeliveries
for managing delivery subscriptions. - Introduced
_deliveryToExtendedTransformer
to transform streams ofDeliveryModel
intoDeliveryExtended
, 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
sourceCompatibility
andtargetCompatibility
from Java 1.8 to Java 11 to leverage modern Java features and improve compatibility. - Changed
jvmTarget
inkotlinOptions
from 1.8 to 11, ensuring alignment with the updated Java version.
- Updated
-
android/app/google-services.json.old
- Deleted the old
google-services.json
configuration 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
DeliveryExtended
class to extendDeliveryModel
with an additionaldistanceFromShop
attribute, providing more detailed information about deliveries. - Included methods to create
DeliveryExtended
fromDeliveryModel
and convert back, ensuring compatibility and ease of use.
- Added
-
lib/common/models/shop_delivery_info.dart (new file)
- Introduced
ShopDeliveryInfo
class 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
deliveries
to useObservableList<DeliveryExtended>
instead ofDeliveryModel
, enabling the use of extended delivery information. - Modified
setDeliveries
method to accommodate the newDeliveryExtended
model, ensuring proper data handling.
- Updated
-
lib/features/user_delivery/user_delivery_controller.dart
- Refactored to use the new
DeliveriesManager
class, 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
DeliveriesManager
methods, improving code organization and maintainability.
- Refactored to use the new
-
lib/features/user_delivery/user_delivery_page.dart
- Removed unused
userId
andradiusInKm
variables from the initialization process, cleaning up the code. - Updated UI elements to reflect new delivery status management, including the use of
refreshNearbyDeliveries
for better user experience.
- Removed unused
-
lib/managers/deliveries_manager.dart (new file)
- Created
DeliveriesManager
class 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:
deliveryPhone
was added toDeliveryModel
to store the delivery person's phone number. - Class Modifications:
- Added
deliveryPhone
field to the constructor,copyWith
method,toMap
method, andfromMap
method. - Updated
toString
,==
operator, andhashCode
to incorporate the newdeliveryPhone
field.
- Added
- Delivery Card Widget Update
- Updated the
DeliveryCard
widget 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
_cleanPhone
to clean phone numbers for display.
- User Delivery Controller Update
- UserStore Update: Changed the reference from
user
to_user
for consistency, while maintaining the originaluser
as a separate reference for current use. - Status Update Method: Added
changeStatus
method inUserDeliveryController
to allow the delivery person to change the status of a delivery.- The method toggles the delivery status between
orderRegisteredForPickup
andorderReservedForPickup
. - It also updates the
deliveryId
,deliveryName
, anddeliveryPhone
fields 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
DeliveryCard
widget to use thechangeStatus
method from the controller instead of showing details.
- Abstract Deliveries Repository Interface Update
- Added a new
updateStatus
method to update the status of a delivery.
- Deliveries Firebase Repository Update
- Updated the implementation of the
updateStatus
method to modify the status and related delivery information in Firestore.- Adjusted Firestore references and
WriteBatch
operations 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.dart
to 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:math
library import for additional mathematical operations. - Defined constants for key fields to ensure consistency across the codebase, such as
keyCreatedAt
andkeyUpdatedAt
. - 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 twoGeoPoint
objects 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 forDeliverymenModel
usingwithConverter()
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
DeliveryStatusExtension
to include this new status, along with its string representation and corresponding icon.
- Added a new delivery status:
-
Icon Handling Improvement:
- Refactored the
icon
getter forDeliveryStatus
to return anIcon
widget directly instead of just anIconData
, which allows for custom styling such as colors for each delivery status.
- Refactored the
-
Markdown Parsing Enhancement:
- Improved the
MarkdowntoRichText
widget 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
DeliveryCard
widget to use theMarkdowntoRichText
for rendering delivery information, improving consistency across the app. - Removed the explicit use of
showInMap
and replaced it with a more genericaction
callback, allowing for more flexible reuse of theDeliveryCard
.
- Updated the
-
UI Component Consolidation:
- Replaced individual widget tree components used in several ListTiles with the new
DeliveryCard
widget 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
DeliveriesFirebaseRepository
to 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
orderReservedForPickup
tostatusText
andicon
getters. - Updated
icon
getter to return a fully styledIcon
widget 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
showInMap
callback with a genericaction
callback to allow for more diverse actions upon card interaction. - Utilized
MarkdowntoRichText
to 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
DeliveryCard
widget for consistency.
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Added
geopointFrom
method to extract geospatial data from Firestore documents. - Introduced a
queryBuilder
function to filter deliveries by specific statuses. - Updated the
getNearby
method to use the newqueryBuilder
for 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
LocationService
class entirely, as its responsibilities have now been distributed and refactored into the repository pattern.
- Introduced an abstract class,
-
User Delivery Controller Refactoring:
- Updated the
UserDeliveryController
to useDeliverymenFirebaseRepository
instead 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
LocationService
and added imports forAbstractDeliverymenRepository
andDeliverymenFirebaseRepository
. - Replaced all instances where
locationService
was 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
AbstractDeliverymenRepository
to 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
DeliverymenFirebaseRepository
class, which extendsAbstractDeliverymenRepository
. - Handles all Firebase-related operations for deliverymen, including:
- Getting Current Location: Implements permissions handling and uses the
Geolocator
package 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
LocationService
class 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
geoflutterfire2
package with the newergeoflutterfire_plus
package across all files, ensuring compatibility and enhanced functionality for handling geospatial data. - Updated the
pubspec.yaml
file to includegeoflutterfire_plus
version^0.0.31
and removed references to the deprecatedgeoflutterfire2
package.
- Replaced the deprecated
-
Model Updates:
- Replaced references to
GeoPoint
andgeohash
withGeoFirePoint
attributes in models and refactored all related methods to use the newGeoFirePoint
data type. - Updated the
DeliverymenModel
,ClientModel
, andAddressModel
to utilizeGeoFirePoint
for location data.
- Replaced references to
-
Functionality Adjustments:
- Modified the
getNearby
method inDeliveriesFirebaseRepository
to usegeoflutterfire_plus
'sGeoCollectionReference
for optimized querying of nearby deliveries. - Refactored the
LocationService
to handle location updates usingGeoFirePoint
instead of individualGeoPoint
attributes, streamlining the process of updating and retrieving geographical data.
- Modified the
lib/common/models/address.dart
- Changed
geoflutterfire2
imports togeoflutterfire_plus
. - Updated the
location
attribute to useGeoFirePoint
from the new package. - Adjusted all related methods and constructors to reflect this change.
lib/common/models/client.dart
- Replaced the import from
geoflutterfire2
togeoflutterfire_plus
. - Updated the
location
attribute and constructors to work with the newGeoFirePoint
data type.
lib/common/models/delivery.dart
- Similar changes as above: replaced the
GeoPoint
attributes withGeoFirePoint
. - Updated all methods, constructors, and utility functions to use
GeoFirePoint
.
lib/common/models/delivery_men.dart
- Replaced
GeoPoint
andgeohash
attributes with a singleGeoFirePoint location
. - Updated methods such as
toMap
,fromMap
, andcopyWith
to handle the newGeoFirePoint
data type.
lib/common/models/functions/models_finctions.dart
→lib/common/models/functions/model_finctions.dart
- Renamed to match naming conventions.
- Adjusted the
mapToGeoFirePoint
function to work with the newGeoFirePoint
structure fromgeoflutterfire_plus
.
lib/common/utils/address_functions.dart
- Updated
getGeoPointFromAddressString
to returnGeoFirePoint
instead ofGeoPoint
.
lib/features/user_delivery/user_delivery_controller.dart
- Updated the location management for deliverymen to use
GeoFirePoint
instead ofGeoPoint
. - Refactored the methods for creating and updating location data using the
geoflutterfire_plus
package.
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Refactored the
getNearby
method to useGeoCollectionReference
fromgeoflutterfire_plus
, providing better geospatial querying capabilities.
lib/services/location_service.dart
- Updated the methods for location updates to use
GeoFirePoint
. - Simplified the
_getCurrentGeoFirePoint
function to return aGeoFirePoint
instead of separate latitude and longitude values.
pubspec.yaml
- Updated dependencies:
- Added
geoflutterfire_plus: ^0.0.31
. - Removed
geoflutterfire2
references.
- 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
mapToGeoFirePoint
to convert a map of coordinates into aGeoFirePoint
object, centralizing this logic for reuse across models.
- Provides a utility function
Files Modified:
lib/common/models/address.dart
- Geographical Data Update:
- Replaced
GeoPoint
andgeohash
attributes 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
geopoint
andgeohash
attributes withGeoFirePoint location
. - Refactored constructors and utility methods like
toMap
andfromMap
to work withGeoFirePoint
. - Removed deprecated JSON handling methods that relied on
GeoPoint
.
- Replaced
lib/common/models/delivery.dart
- Model Update:
- Replaced
geopoint
andgeohash
withGeoFirePoint
attributesclientLocation
andshopLocation
to handle geographical data. - Adjusted all constructors and methods to use
GeoFirePoint
objects instead of individual latitude and longitude values.
- Replaced
lib/common/models/shop.dart
- Geographical Refactor:
- Similar to other models, replaced
GeoPoint
andgeohash
with a singleGeoFirePoint location
attribute. - 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
createGeoPointHash
method, asGeoFirePoint
now handles the geohash generation. - Refactored
getGeoPointFromAddressString
to returnGeoFirePoint
instead ofGeoPoint
.
- Removed the
lib/features/add_client/add_client_controller.dart
- Model Update:
- Replaced references to
geopoint
andgeohash
in the client creation process with thelocation
attribute, reflecting the change inAddressModel
.
- Replaced references to
lib/features/add_delivery/add_delivery_controller.dart
- Delivery Model Update:
- Updated the creation of the
DeliveryModel
to use the newGeoFirePoint
attributes forclientLocation
andshopLocation
.
- Updated the creation of the
lib/features/add_shop/add_shop_controller.dart
- Shop Model Update:
- Modified the shop creation process to use
GeoFirePoint location
instead ofGeoPoint
.
- Modified the shop creation process to use
lib/features/user_delivery/user_delivery_controller.dart
- Location Management Refactor:
- Refactored location handling to use
GeoFirePoint
for delivery personnel locations, ensuring consistent usage of the geographical library across the application. - Implemented new methods
createLocation
andupdateLocation
to streamline location updates for delivery personnel.
- Refactored location handling to use
lib/repository/firebase_store/abstract_client_repository.dart
- Method Update:
- Renamed
streamClientByName
tostreamAllClients
to reflect its purpose more clearly.
- Renamed
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Parameter Update:
- Changed the parameter name
location
togeopoint
to better reflect its usage and ensure compatibility with theGeoFirePoint
refactor.
- Changed the parameter name
lib/services/location_service.dart
- Location Service Refactor:
- Introduced the
createLocation
andupdateLocation
methods to handle delivery personnel locations more robustly. - Added
_getCurrentGeoFirePoint
to 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
GeoFirePoint
attributes 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
deliverymen
as 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
repository
variable toclientRepository
for 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
Abstract
types, 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
_addClient
and_editClient
methods 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
BuildMainContentForm
to includeaddClient
andeditClient
callbacks, 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
editClient
method fromClientsController
since the navigation logic is now handled within theClientsPage
widget, centralizing navigation concerns.
- Removed
lib/features/clients/clients_page.dart
- Navigation Logic Update:
- Replaced the call to
ctrl.editClient
with 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
enable
parameter to control the button's enabled/disabled state. - Button's color and text style now dynamically adjust based on the
enable
state.
- Added an
- UI Improvements:
- The
onPressed
callback is set tonull
when 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
log
statement from theselectClient
action 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
BuildMainContentForm
from 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()
fromAddDeliveryStore
with theBigButton
widget, 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
isValid
logic 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
null
check before updatingaddressType
to avoid potential runtime errors.
- Added
lib/features/add_client/add_client_controller.dart
- Dependency Injection:
- Utilized
AbstractClientRepository
for repository abstraction, enabling better testing and flexibility.
- Utilized
- Refactored Address Handling:
- Introduced getter method for
address
to fetch it directly from the store. - Added a reaction to update the address when
resetAddressString
changes, 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
address
observable 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
resetAddressString
andresetZipCode
flags to centralize their usage.
- Removed the redundant
lib/features/add_shop/add_shop_controller.dart
- Removed Redundant Getters:
- Removed
isEdited
,isValid
, andstate
getters 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 likeisValid
andisEdited
.
- Replaced direct controller state access (
- UI Enhancement:
- Added dynamic titles based on the mode (
Adicionar Loja
vs.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 thezipCodeChanged
state 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
setShopId
based 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
ErrorCard
widget. - 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 setnoShopsState
based 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
AddDeliveryPage
into 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
ErrorCard
widget 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
geopoint
serialization and deserialization in thetoJson
andfromJson
methods.
- Added logic to handle
lib/common/models/shop.dart
- Improved fromJson Logic:
- Adjusted the
fromJson
method to retain thegeopoint
information during deserialization.
- Adjusted the
lib/features/add_shop/add_shop_controller.dart
- Address Handling Refactor:
- Included a check to handle updates on the
GeoPoint
based 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.sentences
toTextCapitalization.words
in 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
ShopModel
data retrieval.
- Refined the abstract repository to include new streaming methods for
lib/repository/firebase_store/shop_firebase_repository.dart
- Method Implementation:
- Added
streamShopAll
,streamShopByManager
, andstreamShopByOwner
methods for real-time shop data retrieval. - Removed redundant
getShopByName
method.
- 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.dart
import. - Added
geohash
field and updated constructor accordingly. - Adjusted
createdAt
andupdatedAt
fields to be optional. - Removed
updateLocation()
method, as it's now handled externally.
- Removed
-
lib/common/models/client.dart
- Changed
geopoint
to a non-nullable field. - Added
geohash
field and updated all necessary methods to include it. - Updated constructor to assign default values to
createdAt
andupdatedAt
.
- Changed
-
lib/common/models/delivery.dart
- Fixed typo in the
geohash
field name.
- Fixed typo in the
-
lib/common/models/shop.dart
- Modified
geopoint
to a required field. - Added
geohash
,createdAt
, andupdatedAt
fields.
- Modified
-
lib/common/utils/address_functions.dart
- New utility class
AddressFunctions
created for geolocation-related methods, including:createAddress()
: Creates a newAddressModel
and updates its location.updateAddressGeoLocation()
: Updates geolocation and timestamps.createGeoPointHash()
: Generates a geohash for a givenGeoPoint
.getGeoPointFromAddressString()
: FetchesGeoPoint
based on the address string usinggeocoding
package.
- New utility class
-
lib/components/widgets/address_card.dart
- Replaced
AddressModel
parameter withaddressString
for better compatibility.
- Replaced
-
Controllers and Stores
- Modified address and shop controllers to use the new
AddressFunctions
methods. - Removed outdated
reaction
mechanisms and added flag management (zipCodeChanged
,updateGeoPoint
) for reactivity. - Refactored
init()
andmountAddress()
methods inadd_client
andadd_shop
controllers.
- Modified address and shop controllers to use the new
-
Other changes:
- Renamed and moved
store_func.dart
for better modularization. - Deleted
geo_point_funcs.dart
as it is now part ofAddressFunctions
. - Deleted
nearby_deliveries
feature files, replaced byuser_delivery
functionalities. - 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
location
attribute togeopoint
for better semantic clarity. - Updated all references to
location
inAddressModel
togeopoint
.
- Renamed
-
Client Model Update:
- Renamed
location
attribute togeopoint
to maintain consistency with the Address model. - Updated all
location
references togeopoint
across the ClientModel.
- Renamed
-
Delivery Model Update:
- Renamed
location
attribute togeopoint
andgeoHash
togeohash
. - Updated references in DeliveryModel to reflect these changes.
- Renamed
-
Shop Model Update:
- Renamed
location
attribute togeopoint
for 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
MapPage
and other dependent views to reflect the renamed attributes.
- Refactored controllers (
-
Nearby Deliveries Feature Refactor:
- Renamed
neaby_deliveries
feature tonearby_deliveries
for correct spelling. - Updated controllers and store references to the new directory and file names.
- Renamed
-
Repository Updates:
- Refactored geohash key reference in
DeliveriesFirebaseRepository
andLocationService
fromgeoHash
togeohash
. - Standardized all geospatial query and data handling logic to use
geopoint
andgeohash
consistently.
- Refactored geohash key reference in
-
Other Refactoring:
- Adjusted json serialization methods for
ShopModel
to usegeopoint
instead 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.dart
add_client_store.dart
add_delivery_store.dart
add_shop_store.dart
clients_store.dart
home_store.dart
nearby_deliveries_store.dart
personal_data_store.dart
shops_store.dart
sign_in_store.dart
sign_up_store.dart
user_admin_store.dart
user_business_store.dart
user_delivery_store.dart
user_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_delivery
Feature 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.dart
account_page.dart
add_client_controller.dart
add_client_page.dart
add_delivery_controller.dart
add_delivery_page.dart
add_shop_controller.dart
add_shop_page.dart
clients_controller.dart
clients_page.dart
home_store.dart
neaby_deliveries_controller.dart
neaby_deliveries_page.dart
person_data_controller.dart
shops_controller.dart
shops_page.dart
sign_in_controller.dart
sign_up_controller.dart
user_admin_controller.dart
user_admin_page.dart
user_business_controller.dart
user_business_page.dart
user_delivery_controller.dart
user_delivery_page.dart
user_manager_controller.dart
user_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
repository
toAddClientController
for managing client-related operations. - Implemented
ClientFirebaseRepository
for client data management.
- Added
-
lib/features/add_delivery/add_delivery_controller.dart
- Reorganized dependencies with final variables for repositories and user store.
- Refactored the
createDelivery
method 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
AddDeliveryPage
to useAddDeliveryStore
for 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
UserDeliveryStore
for 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
UserBusinessStore
and consolidated state management.
- Integrated
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Added
getAll
method to fetch all deliveries in the system.
- Added
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Implemented
getAll
method 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
PageState
for 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
errorMessage
andstate
observables 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
copyWith
method foraddress
to handle potential null values properly.
- Adjusted
-
lib/features/add_client/add_client_controller.dart
- Refactored
AddClientController
to useAddClientStore
for better state management. - Introduced
_mountAddress
and_setClientValues
methods 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
AddClientStore
for 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
StreamBuilder
withObserver
for MobX-based state management. - Improved error handling and UI state consistency using
ClientsStore
.
- Replaced
-
lib/features/add_shop/add_shop_controller.dart
- Refined
AddShopController
to useAddShopStore
for 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
AddShopStore
into the page for more reactive state updates and cleaner UI logic.
- Integrated
-
lib/features/shops/shops_controller.dart
- Refactored
ShopsController
to useShopsStore
for shop data management. - Added shop data streaming and improved error handling through store.
- Refactored
-
lib/features/shops/shops_page.dart
- Replaced previous implementation with
Observer
for reactive UI updates. - Refactored
Dismissible
widgets into a separate component (DismissibleShop
).
- Replaced previous implementation with
-
lib/features/shops/widgets/dismissible_shop.dart
- Created a reusable
DismissibleShop
widget for managing shop edit/delete actions in a dismissible container.
- Created a reusable
-
lib/stores/pages/clients_store.dart
- Created a new
ClientsStore
for 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
ShopsStore
to 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
AddClientStore
by 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
setPageState
tosetState
for 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
AccountController
to useAccountStore
for state management. - Implemented
getManagerShops()
method to retrieve and store manager shops locally.
- Updated
-
lib/features/account/account_page.dart
- Integrated
AccountStore
intoAccountPage
for state management and UI updates. - Replaced references to
pageStore
withstore
to reflect the new structure.
- Integrated
-
lib/features/add_shop/add_shop_controller.dart
- Modified
AddShopController
to utilizeAddShopStore
for 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
AddShopStore
for 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
UserBusinessStore
for 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
UserBusinessStore
for state management and reactive UI updates.
- Updated page to use
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Renamed methods like
streamDeliveryByShopId
andgetDeliveryByOwnerId
for better clarity and consistency. - Added new methods like
updateManagerId
to 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
updateManagerId
for 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
PageState
tostate
for 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
DeliveryModel
to include the newownerId
field. - Refactored
UserModel
by renaming themanagerId
field tobossId
for better clarity.
- Updated
-
lib/common/models/delivery.dart
- Added
ownerId
field toDeliveryModel
for better association between deliveries and their respective owners. - Adjusted constructors, methods, and
copyWith
pattern to accommodate the new field.
- Added
-
lib/common/models/user.dart
- Renamed the
managerId
field tobossId
throughout 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
UserBusinessController
to properly use theownerId
field 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
UserBusinessPage
to leverage the newUserBusinessStore
for managing deliveries. - Added error handling and refresh functionality to improve user experience.
- Modified
-
lib/stores/pages/user_business_store.dart
- Added
deliveries
observable list and methods for updating deliveries in the store. - Implemented
pageState
observable to manage loading and error states.
- Added
-
lib/repository/firebase_store/abstract_deliveries_repository.dart
- Renamed
streamDeliveryByOwnerId
togetDeliveryByOwnerId
for better method naming consistency.
- Renamed
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Updated the implementation of
getDeliveryByOwnerId
to fetch deliveries based on the newownerId
field.
- Updated the implementation of
-
lib/stores/pages/add_delivery_store.dart
- Updated the delivery creation logic to include
ownerId
when 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 (
bossId
instead 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_plus
package locally and began testing it to ensure it functions correctly.
-
Android Manifest
- Added
ACCESS_FINE_LOCATION
,ACCESS_COARSE_LOCATION
, andACCESS_BACKGROUND_LOCATION
permissions in theAndroidManifest.xml
to support geolocation services in the app.
- Added
-
lib/common/extensions/user_role_extensions.dart (New)
- Created
UserRoleExtensions
to add utility methods likedisplayName
andiconData
forUserRole
.
- Created
-
lib/common/models/user.dart
- Removed the deprecated
ptUserRole
method. - 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
isDelivery
toisDeliveryman
to better reflect the role's meaning.
- Renamed
-
lib/features/home/home_page.dart
- Replaced
UserDeliveryPage
withNearbyDeliveriesPage
in the PageView navigation.
- Replaced
-
lib/features/home/widgets/custom_drawer_header.dart
- Updated to use the
UserRoleExtensions
for cleaner code and separation of concerns.
- Updated to use the
-
lib/features/neaby_deliveries/neaby_deliveries_controller.dart (New)
- Implemented
NearbyDeliveriesController
to manage geolocation-based queries and subscriptions for nearby deliveries.
- Implemented
-
lib/features/neaby_deliveries/neaby_deliveries_page.dart (New)
- Created a new page
NearbyDeliveriesPage
to 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
getDeliveryNearby
togetDeliveriesNearby
for 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
LocationService
class to handle permission requests and updating the user's location in Firestore.
- Implemented a new
-
lib/stores/pages/add_delivery_store.dart
- Added the
refreshShops
method 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
geolocator
and 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
geoHash
field toDeliveryModel
for more efficient geospatial queries. - Updated the constructor,
copyWith
,toMap
, andfromMap
methods to handle the newgeoHash
field.
- Added the
-
lib/common/utils/geo_point_funcs.dart (New)
- Created a utility function
createGeoPointHash
using 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.dart
for 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
store
instead ofpageStore
for consistency across the project.
- Refactored to use
-
lib/features/add_delivery/add_delivery_page.dart
- Updated method references to use
store
instead ofpageStore
after 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
PageController
to manage different views for different user roles.
-
lib/features/home/home_page.dart
- Replaced static delivery list with a dynamic
PageView
that 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.dart
to better reflect its purpose. - Imported
material_symbols_icons
package. - Added new
icon
getter to provide icons for differentDeliveryStatus
values.
- Renamed from
-
lib/common/models/delivery.dart
- Added
shopPhone
toDeliveryModel
to store the phone number of the shop. - Renamed
shopLocation
tolocation
for consistency in representing the shop's location. - Updated
DeliveryModel
constructor,toMap
,fromMap
, and comparison methods to include the newshopPhone
and renamed fields.
- Added
-
lib/common/models/shop.dart
- Renamed
userId
toownerId
to clarify the purpose of the field. - Added
phone
field 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
font14
method to support text styling for smaller fonts.
- Added
-
lib/features/add_delivery/add_delivery_controller.dart
- Updated
init
method to be asynchronous, awaiting store initialization. - Added
noShopsState
for 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
phoneController
to manage the input for shop phone numbers.
- Added a
-
lib/features/home/home_controller.dart
- Imported
DeliveriesFirebaseRepository
for 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
DeliveryCard
widget to display delivery information, including the client name, shop phone, and address.
- Created
-
lib/features/map/map_controller.dart
(New)- Created
MapController
to manage Google Maps interaction.
- Created
-
lib/features/map/map_page.dart
(New)- Implemented
MapPage
to 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
MapPage
to allow users to navigate to the delivery map.
- Added route generation for
-
lib/repository/firebase_store/shop_firebase_repository.dart
- Renamed
userId
toownerId
in Firestore queries and data handling. - Adjusted data map handling for consistency.
- Renamed
-
lib/stores/pages/add_delivery_store.dart
- Added
NoShopState
enum to handle various states related to shop availability. - Updated the
init
method to fetch shops and handle errors accordingly.
- Added
-
lib/stores/pages/add_shop_store.dart
- Added
phone
anderrorPhone
observables 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
clientPhone
field toDeliveryModel
. - Removed
deliveryDate
field fromDeliveryModel
. - Updated
copyWith
,toMap
,fromMap
,toJson
,fromJson
,toString
,==
, andhashCode
methods to includeclientPhone
and excludedeliveryDate
.
- Added
-
lib/common/models/shop.dart
- Modified
toJson
method to includeid
and structuredlocation
data with latitude and longitude. - Updated
fromJson
factory constructor to correctly parse nestedlocation
data and remove redundant fields.
- Modified
-
lib/features/delivery_request/delivery_request_controller.dart
- Deleted File: Removed
DeliveryRequestController
as it is no longer needed.
- Deleted File: Removed
-
lib/features/delivery_request/delivery_request_page.dart
- Deleted File: Removed
DeliveryRequestPage
to streamline delivery handling within the app.
- Deleted File: Removed
-
lib/features/home/home_page.dart
- Commented out
_deliceryRequest
method and its invocation to eliminate navigation to the now-deletedDeliveryRequestPage
.
- Commented out
-
lib/features/home/widgets/home_drawer.dart
- Removed
deliceryRequest
parameter and associatedListTile
for delivery requests fromHomeDrawer
.
- Removed
-
lib/my_material_app.dart
- Removed references to
DeliveryRequestPage
route from the application's navigation routes.
- Removed references to
-
lib/repository/firebase_store/deliveries_firebase_repository.dart
- Refactored
add
andupdate
methods to utilizeWriteBatch
for atomic Firestore operations. - Included
clientPhone
inDeliveryModel
during add and update operations. - Enhanced
get
andgetAll
methods 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
getManagerShops
to log exceptions and ensure robustness.
-
lib/stores/pages/add_delivery_store.dart
- Enhanced
createDelivery
method to includeclientPhone
and implement comprehensive error handling. - Initialized
shopId
with the first available shop's ID during theinit
action 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
*.old
to ignore old backup files.
- Added
-
Makefile
- Renamed
firebase_emu_make_cache
target tofirebase_emusavecache
for 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
DeliveryStatusExtension
to use single quotes for consistency.
- Updated string literals in
-
lib/common/models/address.dart
- Removed
createdAt
andupdatedAt
fields fromAddressModel
. - Refactored
updateLocation
method to uselocation
instead ofgeoPoint
.
- Removed
-
lib/common/models/client.dart
- Renamed
geoAddress
tolocation
inClientModel
. - Updated related methods and JSON serialization to reflect the name change.
- Renamed
-
lib/common/models/shop.dart
- Renamed
geoAddress
tolocation
inShopModel
. - Updated related methods and JSON serialization to reflect the name change.
- Renamed
-
lib/components/widgets/dismissible_help_row.dart
- New File: Added
DismissibleHelpRow
widget class to provide a consistent UI for edit and delete actions.
- New File: Added
-
lib/features/add_delivery/add_delivery_controller.dart
- Implemented
AddDeliveryController
with properties and methods for managing delivery creation. - Integrated
AddDeliveryStore
for state management. - Added text controllers for phone and name inputs with appropriate masks.
- Implemented
-
lib/features/add_delivery/add_delivery_page.dart
- Enhanced
AddDeliveryPage
with form fields for selecting origin shop and destination client. - Integrated
DismissibleHelpRow
for better user interaction. - Added submission methods for name and phone searches.
- Included a
BigButton
to generate deliveries.
- Enhanced
-
lib/features/clients/clients_page.dart
- Updated
ClientsPage
to use the newly createdDismissibleHelpRow
widget for editing and deleting clients. - Removed redundant code and streamlined the UI components.
- Updated
-
lib/features/home/home_page.dart
- Modified
HomePage
to include a floating action button that navigates toAddDeliveryPage
for creating new deliveries. - Updated navigation imports for consistency.
- Modified
-
lib/features/shops/shops_page.dart
- Updated
ShopsPage
to incorporateDismissibleHelpRow
and 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 (
add
andupdate
) to useWriteBatch
for 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 (
add
andupdate
) to useWriteBatch
for atomic Firestore operations. - Enhanced error handling and logging for shop data management.
- Refactored shop repository methods (
-
lib/stores/pages/add_client_store.dart
- Updated
AddClientStore
with 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
AddDeliveryStore
class 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
AddShopStore
with 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+22
to0.6.00+23
to 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
init
method toFuture<void>
and made it asynchronous. - Added
await pageStore.init()
within theinit
method.
- Changed the
-
lib/services/local_storage_service.dart
- Imported
dart:developer
for logging purposes. - Imported
../common/models/shop.dart
to handleShopModel
. - Added
_keyManagerShops
constant for storing manager shops. - Implemented
setManagerShops
method to save a list of manager shops. - Implemented
getManagerShops
method to retrieve the list of manager shops.
- Imported
-
lib/stores/pages/account_store.dart
- Imported
../../services/local_storage_service.dart
to use the local storage service. - Added
localStore
instance usinglocator<LocalStorageService>()
. - Created an asynchronous
init
action method to initialize the store. - Updated
getManagerShops
to callsetInLocalStore
after fetching shops. - Added
setInLocalStore
method to save shops to local storage. - Added
getInLocalStore
action 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_service
to 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
geoAddress
field tolocation
to better represent geographical data usingGeoPoint
. - Updated all references to this field throughout the model, including constructors,
copyWith
methods, serialization (toMap
andfromMap
), string representations, and equality checks.
- Renamed the
-
Data Integrity Enhancements:
- Ensured that the
location
field 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
ShopModel
andstore_func
to facilitate interactions with shop data and utility functions.
- Added imports for
-
State Management Enhancements:
- Introduced
state
andshops
properties to manage the current state of the account page and the list of shops managed by the user. - Implemented the
getManagerShops
method 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.dart
andmaterial_symbols_icons
to incorporate additional UI components and iconography. - Utilized the
colorScheme
from 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_store
to/add_shop
to 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
client
object. 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_icons
and a newly createddismissible_client.dart
widget to enrich the UI and encapsulate dismissible functionalities.
- Added imports for
-
Method Additions:
- Introduced the
_addClient
method to streamline navigation to the Add Client page, promoting code reusability and cleaner button handlers.
- Introduced the
-
UI Refactoring:
- Replaced the inline
Dismissible
widgets with the reusableDismissibleClient
widget. 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
DismissibleClient
widget 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:async
andqr_flutter
to handle asynchronous operations and QR code generation/display.
- Added imports for
-
Lifecycle Management:
- Implemented
WidgetsBindingObserver
to 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
StreamSubscription
to listen for barcode detections, enhancing the scanner's responsiveness and reliability.
- Introduced a
-
User Interface Enhancements:
- Integrated
QrImageView
to 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
MobileScannerController
with 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
getShopByManager
to 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
add
method 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
getShopByManager
method to retrieve all shops managed by a specific manager. This method queries the Firestore database and processes the results to return a list ofShopModel
instances.
- 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
shops
andstate
observables to manage the list of shops and the current page state within the account store.
- Added
-
Action Implementation:
- Developed the
getManagerShops
action 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
ShopFirebaseRepository
to 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
shops
andstate
observables 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.dart
anddart:developer
to utilize string manipulation extensions and logging functionalities.
- Added imports for
-
Observable Additions:
- Introduced the
isAddressEdited
observable to track changes made to a client's address, enabling more precise state management and validation.
- Introduced the
-
Method Refactoring and Enhancements:
- Refactored the
getClientFromForm
method to handle address updates more effectively, ensuring that location data is accurately updated and reflected in the client model. - Implemented the
_updateLocation
action to update the client's address location only when changes have been made, optimizing performance and data accuracy.
- Refactored the
-
Validation Improvements:
- Replaced the
removeNonNumber
utility 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
location
andaddressString
fields instead of the previously usedgeoAddress
, ensuring consistent data representation.
- Updated address handling logic to manage
-
Editing Flags Management:
- Enhanced the
_checkIsEdited
method and related functionalities to manage bothisEdited
andisAddressEdited
flags. This provides a more granular control over state changes, ensuring that updates are handled appropriately.
- Enhanced the
-
Address Mounting Logic:
- Modified the
_mountAddress
method to conditionally update the address based on theisAddressEdited
flag, 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
isAddressEdited
observable and the_updateLocation
async action. - Refactored the
_checkIsEdited
method to accommodate the new editing flags, ensuring that state changes are accurately tracked and managed. - Enhanced the
toString
method to include theisAddressEdited
flag, 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
id
getter to retrieve the current user's ID directly from thecurrentUser
object. 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
AccountStore
andAddClientStore
ensures more responsive and reliable state handling, enhancing the overall user experience. -
User Interface Improvements: Refactoring UI components to use reusable widgets like
DismissibleClient
and 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
getShopByManager
provide 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
compileSdk
fromflutter.compileSdkVersion
to34
. - Changed
jvmTarget
fromJavaVersion.VERSION_1_8
to"1.8"
. - Updated
minSdk
to21
andtargetSdk
to34
.
- 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
jvmTarget
to1.8
for all Kotlin modules. - Updated
buildscript
dependencies, includingkotlin_version
to'1.8.10'
andcom.android.tools.build:gradle
to'8.0.2'
.
- Configured
-
android/gradle.properties
- Added
dev.steenbakker.mobile_scanner.useUnbundled=true
to enable unbundled mode formobile_scanner
.
- Added
-
android/gradle/wrapper/gradle-wrapper.properties
- Updated
distributionUrl
fromgradle-7.6.3-all.zip
togradle-8.1.1-all.zip
.
- Updated
-
docs/Projeto_Delivery_Scrum.md
- Renamed from
doc/Projeto_Delivery_Scrum.md
todocs/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
DeliveryStatusExtension
to provide display names and colors for delivery statuses.
- Added
-
lib/common/extensions/generic_extensions.dart (New File)
- Implemented extensions for
num
,DateTime
, andString
to handle formatting and data manipulation.
- Implemented extensions for
-
lib/common/models/address.dart
- Replaced
latitude
andlongitude
withGeoPoint? location
. - Updated methods to reflect the use of
GeoPoint
.
- Replaced
-
lib/common/models/client.dart
- Added
addressString
andgeoAddress
fields. - Updated
toMap
andfromMap
methods to include new fields.
- Added
-
lib/common/models/delivery.dart (New File)
- Introduced
DeliveryModel
with comprehensive fields and methods to manage delivery data.
- Introduced
-
lib/common/models/shop.dart
- Made
name
anddescription
required fields. - Replaced
latitude
andlongitude
withGeoPoint? 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
Observer
widget to reactively manage UI changes.
- Added an
-
lib/features/qrcode_read/qrcode_read_page.dart
- Replaced
qr_code_scanner
withmobile_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
DeliveriesFirebaseRepository
with methods to add, update, delete, and stream delivery data from Firestore.
- Implemented
-
lib/services/geolocation_service.dart
- Refactored to use the
geocoding
package instead of the Google Geocoding API. - Updated
getGeoPointFromAddress
to returnGeoPoint?
.
- Refactored to use the
-
lib/stores/pages/add_client_store.dart
- Replaced
removeNonNumber
withonlyNumbers()
extension. - Updated address handling to use
GeoPoint? location
.
- Replaced
-
lib/stores/pages/add_shop_store.dart
- Similar refactoring as
add_client_store.dart
for address handling. - Utilized
onlyNumbers()
extension for zip code validation.
- Similar refactoring as
-
lib/stores/pages/common/store_func.dart
- Removed the
removeNonNumber
method in favor of using string extensions.
- Removed the
-
package.json
- Updated
firebase-functions
from^6.0.0
to^6.0.1
.
- Updated
-
package-lock.json
- Synced
firebase-functions
version to6.0.1
.
- Synced
-
pubspec.yaml
- Updated dependencies:
- Upgraded
get_it
to^8.0.0
. - Removed
qr_code_scanner
and addedmobile_scanner
,geocoding
, andgeoflutterfire_plus
. - Updated
firebase_core
to^2.32.0
,cloud_firestore
to^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.CAMERA
permission.
- Added
-
firebase.json
- Updated Firebase emulator host to
192.168.0.22
for the following services:- Functions
- Auth
- Firestore
- UI
- Database
- Storage
- Remote Config
- Updated Firebase emulator host to
-
functions/index.js
- Added
managerId
to user claims. - Modified
setUserClaims
function to includemanagerId
when provided. - Updated success message to include
managerId
.
- Added
-
lib/common/models/shop.dart
- Added
managerId
andmanagerName
fields toShopModel
. - Updated constructor to initialize
managerId
andmanagerName
. - Included
managerId
andmanagerName
intoMap
,fromMap
,copyWith
, andtoString
methods.
- Added
-
lib/common/models/user.dart
- Added
managerId
field toUserModel
. - Updated constructor and
toMap
/fromMap
methods to handlemanagerId
. - Added
accountId
getter based on user role. - Updated
toString
method to includemanagerId
.
- Added
-
lib/features/account_page/account_controller.dart
- Introduced
AccountController
class managingUserStore
andAccountStore
. - Implemented methods to toggle QR code visibility.
- Introduced
-
lib/features/account_page/account_page.dart
- Added
AccountPage
widget with QR code display and toggle functionality.
- Added
-
lib/features/add_shop/add_shop_controller.dart
- Added
setManager
method to handle manager selection.
- Added
-
lib/features/add_shop/add_shop_page.dart
- Imported
QRCodeReadPage
. - Added
_getManager
method to navigate toQRCodeReadPage
and set manager data. - Updated UI to include manager selection interface.
- Imported
-
lib/features/home/home_page.dart
- Imported
AccountPage
. - Added
_accountPage
method to navigate toAccountPage
.
- Imported
-
lib/features/home/widgets/home_drawer.dart
- Added
account
callback. - Included "Account" ListTile in the navigation drawer.
- Added
-
lib/features/qrcode_read/qrcode_read_page.dart
- Introduced
QRCodeReadPage
widget for scanning QR codes.
- Introduced
-
lib/features/stores/shops_controller.dart
- Imported
UserModel
. - Added
currentUser
andaccountId
fields. - Updated
editShop
method parameters and logic to handle shop data.
- Imported
-
lib/features/stores/shops_page.dart
- Initialized
ShopsController
ininitState
.
- Initialized
-
lib/main.dart
- Updated Firebase emulator host to
192.168.0.22
for Auth, Firestore, and Functions.
- Updated Firebase emulator host to
-
lib/my_material_app.dart
- Imported
AccountPage
andQRCodeReadPage
. - Added routes for
AccountPage
andQRCodeReadPage
.
- Imported
-
lib/repository/firebase/firebase_auth_repository.dart
- Included
managerId
in user claims. - Refactored
adminChecked
logic. - Updated methods to handle
managerId
.
- Included
-
lib/repository/firebase_store/shop_firebase_repository.dart
- Imported
UserStore
. - Updated
streamShopByName
to filter shops based onaccountId
.
- Imported
-
lib/stores/pages/account_store.dart
- Introduced
AccountStore
withshowQRCode
observable andtoggleShowQRCode
action.
- Introduced
-
lib/stores/pages/add_shop_store.dart
- Added
managerId
andmanagerName
observables. - Implemented
setManager
action. - Updated
getShopFromForm
andsetShopFromShop
methods to handle manager data.
- Added
-
pubspec.yaml
- Bumped version to
0.4.01+19
. - Added
qr_flutter
andqr_code_scanner
dependencies.
- Bumped version to
-
pubspec.lock
- Downgraded
js
package from0.7.1
to0.6.7
. - Added
qr
,qr_code_scanner
, andqr_flutter
packages.
- 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_data
directory before exporting. - Added the
-f
flag to thefirebase emulators:export
command 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.dart
add_client_store.g.dart
→pages/add_client_store.g.dart
add_shop_store.dart
→pages/add_shop_store.dart
add_shop_store.g.dart
→pages/add_shop_store.g.dart
common/store_func.dart
→pages/common/store_func.dart
home_store.dart
→pages/home_store.dart
home_store.g.dart
→pages/home_store.g.dart
personal_data_store.dart
→pages/personal_data_store.dart
personal_data_store.g.dart
→pages/personal_data_store.g.dart
shops_store.dart
→pages/shops_store.dart
shops_store.g.dart
→pages/shops_store.g.dart
sign_in_store.dart
→pages/sign_in_store.dart
sign_in_store.g.dart
→pages/sign_in_store.g.dart
sign_up_store.dart
→pages/sign_up_store.dart
sign_up_store.g.dart
→pages/sign_up_store.g.dart
- Explanation:
- The MobX stores were relocated from the
mobx
directory to a newpages
directory withinstores
to 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_icons
package 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
Icons
withSymbols
from thematerial_symbols_icons
package for a more consistent and modern iconography. - Added a
default
case 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.dart
file within thepages/common/
directory. - Provides helper methods for email validation, CPF validation, number extraction, and address fetching.
- Defines
PageState
andZipStatus
enums 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
mobx
topages
:- 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.dart
files. - Example:
lib/stores/mobx/add_client_store.dart
→lib/stores/pages/add_client_store.dart
lib/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.dart
appears to contain a typo. It should likely be renamed toadd_client_page.dart
to maintain consistency and prevent potential import issues.
- The filename
- Consistency in Enum Usage:
- Ensured that enums
PageState
andZipStatus
are consistently used across all stores, promoting uniform state management.
- Ensured that enums
- Iconography Enhancement:
- Transitioned from using standard Flutter
Icons
toSymbols
from thematerial_symbols_icons
package 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
passwordUpdatedAt
timestamp. - Added
disabled
field set tofalse
.
- Updated
- Rudson Alves:
- Updated
passwordUpdatedAt
timestamp. - Added
disabled
field set tofalse
.
- Updated
- Ricardo Mattos:
- Changes:
- Removed newline at the end of the file.
- Updated
validSince
timestamps. - Adjusted
lastRefreshAt
timestamps to reflect recent changes.
- Updated User Entries:
-
Firestore Export Metadata (
emulator_data/firestore_export/
)- Files Updated:
all_namespaces_all_kinds.export_metadata
output-0
firestore_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
geoAddress
getter to includecomplement
if available. - Added
isValidAddress
getter to validate essential address fields.
- Modified
- Changes:
ClientModel
(lib/common/models/client.dart
):- Changes:
- Removed commented-out
id
andaddress
fields fromtoMap()
andfromMap()
methods. - Simplified
email
field 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.dart
to integrate the newAddressCard
widget. - Refactored
add_client_controller.dart
to useStoreFunc
for 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
AddShopStore
for state management. - Handles initialization and disposal of controllers.
- Page (
add_shop_page.dart
):- Developed UI for adding and updating shops.
- Integrated
AddressCard
for 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
PageState
instead ofStatus
. - Integrated
StoreFunc
for utility functions.
- Updated to use
- Changes:
- Shops Management Feature (
lib/features/stores/
):- Controller (
shops_controller.dart
):- Implements
ShopsController
with methods to edit and delete shops. - Utilizes
ShopFirebaseRepository
for 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
PageState
andZipStatus
for consistent state representation.
- Replaces the deleted
- New File:
- Add Client Store (
lib/stores/mobx/add_client_store.dart
):- Changes:
- Refactored to use
PageState
instead ofPageStatus
. - Integrated
StoreFunc
for 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
StoreFunc
for 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
StoreFunc
for consistency.
- Updated to use
- Changes:
- Personal Data Store (
lib/stores/mobx/personal_data_store.dart
):- Changes:
- Refactored to use
StoreFunc
for 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
StoreFunc
for utility functions.
- Updated to use
- Changes:
- Common Utilities (
-
Repositories
- Address Repository (
lib/repository/firebase_store/address_firebase_repository.dart
):- New Repository:
- Implements
AbstractAddressClientRepository
with 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
keyClient
tokeyClients
for 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
AbstractShopRepository
with 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.1
for enhanced iconography.
- Added Dependency:
pubspec.lock
:- Included
material_symbols_icons
package 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
ShopModel
arguments.
- 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.dart
for 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.json
crashlytics-build.properties
serviceAccountKey.json
- Firebase Emulator logs and data:
firebase-debug.log
firestore-debug.log
database-debug.log
ui-debug.log
storage-debug.log
firebase-debug.*
*-debug.log
emulator_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_cache
target to remove the./emulator_data
directory 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.md
todoc/Projeto_Delivery_Scrum.md
for 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:
appSettings
Collection:- Allows creation and read access with specific restrictions.
clients
Collection:- 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 (
addresses
Subcollection withinclients
:- Mirrors permissions of the
clients
collection.
- Mirrors permissions of the
shops
Collection:- 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.
addresses
Subcollection 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
id
field from thetoMap()
method. - Updated the
fromMap
factory 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
manager
role toUserRole
enum. - Updated Display: Handles the
manager
role 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
addressTypes
array. - 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.dart
andadd_delivery_page.dart
with basic scaffolding for delivery requests.
- Added
- New Pages & Controllers:
- Add Shop Feature (
lib/features/add_shop/
):- New Pages & Controllers:
- Added
add_shop_controller.dart
andadd_shop_page.dart
with form fields for adding shops. - Implemented MobX store
AddShopStore
for managing shop data and state.
- Added
- New Pages & Controllers:
- Delivery Request Feature (
lib/features/delivery_request/
):- New Pages & Controllers:
- Added
delivery_request_controller.dart
anddelivery_request_page.dart
to handle delivery requests.
- Added
- New Pages & Controllers:
- Home Feature (
lib/features/home/
):- Controller (
home_controller.dart
):- Added getters
isAdmin
andisBusiness
to determine user roles.
- Added getters
- Page (
home_page.dart
):- Imported new pages for delivery requests and store management.
- Added navigation methods
_deliceryRequest
and_storesPage
.
- Drawer (
home_drawer.dart
):- Imported
material_symbols_icons
. - Added conditional
ListTile
widgets 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
PageState
instead ofPageStatus
. - Integrated error handling based on the updated state management.
- Updated to use
- Store (
personal_data_store.dart
):- Replaced
Status
enum 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
ShopsController
with references toShopsStore
andShopFirebaseRepository
. - Added role-based getters
isAdmin
andisBusiness
.
- Implemented
- Page (
shops_page.dart
):- Developed
ShopsPage
with 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
ShopsStore
with observablestate
and actions to manage shop-related states.
- Created
- Controller (
-
Repositories
- Abstract Repositories:
abstract_address_repository.dart
:- Renamed methods for consistency (
set
toadd
). - Updated
get
method signature to acceptaddressId
instead 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
AbstractAddressClientRepository
with Firebase operations for addresses. - Added error handling and logging.
- Implemented
client_firebase_repository.dart
:- Refactored to use
keyClients
andkeyAddresses
for 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
AbstractShopRepository
with 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.1
for enhanced iconography.
- Added dependency:
pubspec.lock
:- Included
material_symbols_icons
package 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
PageState
instead 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
PageState
for 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
users
array by adding a new user with detailed authentication information.
- Updated the
-
emulator_data/firebase-export-metadata.json
- Added
storage
section with version13.17.0
and 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.json
with bucket IDdelivery-16712.appspot.com
.
- Created
-
firebase.json
- Added
storage
andremoteconfig
emulators with respective ports. - Updated ignore patterns and added storage rules configuration.
- Added
-
firestore.rules
- Defined rules for
appSettings
collection, including creation, read, and restriction on updates/deletes. - Updated
adminConfig
document rules to allow creation and read access while blocking modifications. - Enhanced
clients
andaddresses
collections with role-based permissions for administrators and business users.
- Defined rules for
-
lib/components/widgets/base_dismissible_container.dart
- Changed
disableColor
fromoutline
tosecondaryContainer
in the dismissible container.
- Changed
-
lib/features/clients/clients_controller.dart
- Imported
user.dart
,user_store.dart
, anddata_result.dart
. - Added
userStore
locator and gettersuser
,isAdmin
, andisBusiness
. - Implemented
deleteClient
method to handle client deletion.
- Imported
-
lib/features/clients/clients_page.dart
- Imported
app_text_style.dart
andstate_loading.dart
. - Modified
_deleteClient
to 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
keyAddress
tokeyClient
when updating client data.
- Changed the collection key from
-
lib/services/geolocation_service.dart
- Removed unnecessary
foundation.dart
import. - Eliminated debug code mocking latitude and longitude.
- Updated
googleApi
getter to asynchronously fetch the API key.
- Removed unnecessary
-
lib/services/remote_config.dart
- Imported
flutter_dotenv
. - Modified
googleApi
getter to load from.env
in debug mode.
- Imported
-
lib/stores/mobx/add_client_store.dart
- Added
id
to theClientModel
constructor. - Commented out direct assignment of
client.id
.
- Added
-
lib/stores/user/user_store.dart
- Added
isAdmin
andisBusiness
getters to determine user roles.
- Added
-
package-lock.json
- Added new dependencies:
@eslint/config-array
,@eslint/object-schema
,glob
,rimraf
, and others. - Removed
optional
flags 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_dotenv
dependency.
- Added
-
pubspec.yaml
- Added
flutter_dotenv
to dependencies. - Included
.env
file in assets.
- Added
-
remoteconfig.template.json
- Configured
google_api_key
parameter 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:usesCleartextTraffic
fromfalse
totrue
to 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
TextButton
to 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 localfirebaseUser
variable 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_cache
target 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
nodejs18
runtime and adding ignored directories likenode_modules
and.git
.
-
firestore.rules
- Removed
users
collection 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
adminConfig
creation and update logic, allowing any user to create it, but restricting updates to admins.
- Removed
-
lib/common/models/client.dart
- Added
id
field to theClientModel
class 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
focusNode
andnextFocusNode
to 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
users
collection. - Added
_setUserClaims()
method to set Firebase Custom Claims forrole
andstatus
. - 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
id
properly when interacting with Firestore.
- Refactored client retrieval methods to handle
-
pubspec.yaml
- Added
cloud_functions
dependency 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_emu
command to start Firebase emulators with data import. - Added
firebase_emu_debug
command for starting Firebase emulators in debug mode. - Introduced
build_runner
command to execute Dart build runner in watch mode.
- Added
-
android/app/build.gradle
- Loaded
keystoreProperties
for signing configurations. - Applied signing configurations for the release build.
- Loaded
-
android/app/google-services.json
- Removed outdated
client_id
entry.
- Removed outdated
-
emulator_data/auth_export/accounts.json
- Updated exported authentication data for the Firebase emulator.
-
lib/components/widgets/message_snack_bar.dart
- Modified
showMessageSnackBar
to acceptTextStyle
for title and message, improving customization.
- Modified
-
lib/features/add_client/add_cliend_page.dart
- Enhanced form validation logic with
PageStatus
management. - 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
PageStatus
system. - Refactored controller to ensure compatibility with form validation changes.
- Reworked save client logic to utilize the new
-
lib/features/clients/clients_page.dart
- Implemented
StreamBuilder
to display clients dynamically from the Firebase Firestore.
- Implemented
-
lib/locator.dart
- Registered
AbstractClientRepository
andClientFirebaseRepository
to dependency injection.
- Registered
-
lib/repository/firestore/
- Refactored the repository structure, renaming files to
firebase_store
to reflect the Firebase store focus. - Added abstraction for repositories:
AbstractClientRepository
andAbstractAddressClientRepository
.
- Refactored the repository structure, renaming files to
-
lib/stores/mobx/add_client_store.dart
- Added
PageStatus
to 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
.env
files to the ignore list.
- Added
-
Makefile
- Added
firebase_emu
command 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 forclients
andaddresses
.
- Updated Firestore rules to include user roles (
-
Cloud Functions
- Initialized Python-based Firebase Cloud Functions setup.
-
lib/common/models/address.dart
- Added
geoAddress
getter for geolocation and movedtoMap
method.
- 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
ClientFirebaseRepository
using 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.dart
toaddress.dart
. - Updated
addressString
method to use "Endereço" and handle cases where the address number is not provided (S/N
for "sem número").
- Renamed file from
-
lib/common/models/client.dart
- Updated the import of
address.dart
after the file rename.
- Updated the import of
-
lib/common/theme/app_text_style.dart
- Added
font12Height
text style with adjustable line height.
- Added
-
lib/features/add_client/add_cliend_page.dart (New File)
- Created the
AddCliendPage
for 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
AddClientController
to 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
ClientsController
with aninit
method for the clients page.
- Created a simple controller
-
lib/features/clients/clients_page.dart (New File)
- Created the
ClientsPage
to display a list of clients and a button to add new clients.
- Created the
-
lib/features/home/home_page.dart
- Added the
_clients
method to navigate to theClientsPage
. - Updated the
HomeDrawer
to include a "Clientes" option.
- Added the
-
lib/features/home/widgets/home_drawer.dart
- Updated
HomeDrawer
to include aListTile
for navigating to the clients section.
- Updated
-
lib/my_material_app.dart
- Added routes for
ClientsPage
andAddCliendPage
.
- Added routes for
-
lib/stores/mobx/add_client_store.dart (New File)
- Created the
AddClientStore
using 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.dart
after 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
showMessageSnackBar
to include an optionaltitle
parameter and updated themessage
parameter to accept aWidget
. - Added
closeIcon
andanimation
for improved user interaction. - Modified
SnackBar
shape for better alignment and visual appearance.
- Refactored
-
lib/components/widgets/simple_message.dart (New File)
- Created
SimpleMessage
widget for displaying simple messages with optional icons based on message type. - Added a
MessageType
enum to support different message types:none
,error
, andwarning
. - Provided a static
open
method for easily displaying the message in a dialog.
- Created
-
lib/features/sign_in/sign_in_controller.dart
- Added
sendPasswordResetEmail
method for sending a password reset email.
- Added
-
lib/features/sign_in/sign_in_page.dart
- Updated
_signIn
and_recoverPassword
methods 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
SnackBarTitle
widget to display titles in theSnackBar
.
- Updated
-
lib/features/sign_up/sign_up_page.dart
- Enhanced the
signUp
method to display the message using theText
widget 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
sendPasswordResetEmail
method definition for password reset functionality.
- Added the
-
lib/repository/firebase/firebase_auth_repository.dart
- Implemented
sendPasswordResetEmail
method to send password reset emails using Firebase'sauth
API.
- Implemented
-
lib/stores/mobx/sign_in_store.dart
- Added
isEmailValid
method 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:convert
to handle JSON serialization. - Added
type
,latitude
, andlongitude
properties toAddressModel
. - Updated the constructor to initialize
type
as 'Residencial',latitude
,longitude
, andupdatedAt
with default values. - Modified the
addressString
method to include thetype
in the string representation. - Added
updatedAt
to store the last update time. - Updated
copyWith
to handle the new properties (type
,latitude
,longitude
,updatedAt
). - Modified
toMap
andfromMap
to serialize and deserialize the new properties. - Added
toJson
andfromJson
methods for JSON conversion. - Overrode
==
andhashCode
to include the new properties.
- Imported
-
lib/common/models/client.dart
- Created
ClientModel
to represent a client entity with fields such asid
,name
,email
,phone
,address
, and timestamps (createdAt
,updatedAt
). - Added
copyWith
method to create a copy of the object with modified values. - Implemented
toMap
andfromMap
methods for serialization and deserialization of the client model. - Added
toJson
andfromJson
methods for JSON conversion. - Overrode
==
andhashCode
for object comparison. - Implemented
toString
method for string representation of the client model.
- Created
-
lib/common/models/user.dart
- Renamed the
client
role tobusiness
in theUserRole
enum to better reflect the role’s purpose.
- Renamed the
-
lib/components/widgets/custom_text_field.dart
- Added the
textCapitalization
parameter to customize text capitalization behavior.
- Added the
-
lib/features/home/home_controller.dart
- Added
store
as a new property initialized toHomeStore
. - Updated
init()
method to check if the user is logged in and set thestore.hasPhone
accordingly.
- Added
-
lib/features/home/home_page.dart
- Updated the floating action button to navigate to
PersonDataPage
instead of the old delivery person page. - Added post-frame callback in
initState
to redirect toPersonDataPage
if 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
PersonController
to 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
DeliveryPersonPage
toPersonDataPage
to 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
TextInputDialog
to 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
userStatus
getter to expose the current user’s status.
- Refactored the
-
lib/features/sign_in/sign_in_page.dart
- Updated the navigation behavior to use
Navigator.pushReplacementNamed
for 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
SplashController
to 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
SplashPage
to 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
SplashPage
as the initial route. - Updated the route for
PersonDataPage
to replace the old delivery person route.
- Set
-
lib/repository/firebase/firebase_auth_repository.dart
- Refactored
requestPhoneNumberVerification
to format the phone number properly and handle verification via Firebase’s phone authentication.
- Refactored
-
lib/stores/mobx/home_store.dart
- Created
HomeStore
to manage user-specific states such ashasPhone
andhasAddress
.
- Created
-
lib/stores/mobx/personal_data_store.dart
- Renamed from
DeliveryPersonStore
toPersonalDataStore
to reflect its broader role in managing personal data.
- Renamed from
-
lib/stores/user/user_store.dart
- Added a new observable property
userStatus
to track user authentication status changes. - Updated the
initializeUser
,signUp
, andlogout
methods to toggleuserStatus
based 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
UserModel
class to include new fields:emailVerified
,photoURL
,creationAt
, andlastSignIn
. - Introduced a new method
ptUserRole
to 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
CustomDrawerHeader
for better modularization.
- Refactored to use
-
lib/features/sign_in/sign_in_controller.dart
- Refactored the
signIn
method 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_runner
to 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
userStatus
map 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.dart
from../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.dart
for consistent text styling. - Changed
message
parameter type fromWidget
toString
. - Updated
time
default value from3
to5
seconds for longer visibility. - Adjusted
SnackBar
content to use aText
widget with styling fromAppTextStyle
. - Added
textColor
forSnackBarAction
to 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
TextField
submission logic to unfocus and callonFieldSubmitted
if 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
init
method 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
signIn
method 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
ReactionDisposer
to manage MobX reactions. - Updated
_signIn
method to handle responses with detailed error messages.
- Added import for
-
lib/features/sign_up/sign_up_controller.dart
- Added a getter
isLoggedIn
to 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
ReactionDisposer
to manage MobX reactions for user login state changes. - Improved feedback messages in the
_signUp
method for better user guidance.
- Added import for
-
lib/locator.dart
- Updated import path for
local_storage_service.dart
to reflect the new directory structure.
- Updated import path for
-
lib/repository/firebase/auth_repository.dart
- Created a new
AuthRepository
class 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.dart
tolib/services/local_storage_service.dart
to follow new directory organization. - Adjusted import paths accordingly.
- Renamed from
-
lib/stores/user/user_store.dart
- Refactored to use the new
AuthRepository
for 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
UserStore
for 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
SharedPreferences
inAppSettings
with a newLocalStorageService
for 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.dart
to 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
SignInController
andSignUpController
to usepageStore
instead ofsignUpStore
for improved readability and consistency. - Enhanced the controllers to utilize the newly introduced
LocalStorageService
for better state management.
- Refactored
-
Enhanced User Store with Local Caching
- Modified
UserStore
to useLocalStorageService
for 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
FirebaseAuthRepository
to integrate with local storage checks for the first user admin setup.
-
UI and Page Logic Updates
- Adjusted
SignInPage
andSignUpPage
to 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.dart
to register the newLocalStorageService
as a singleton, ensuring consistent usage across the application.
- Updated
-
Removed Deprecated or Unused Files
- Deleted obsolete files like
firebase_storage_repository.dart
andsign_up_store.dart
underauth
to 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.svg
toassets/svg/
for improved graphic representation.
- Added multiple new image assets to
-
lib/common/models/user.dart
- Expanded
UserModel
to includeid
,role
, anduserStatus
properties. - Introduced serialization methods (
toMap
,fromMap
,toJson
,fromJson
) for easier data handling and storage. - Added new enums
UserRole
andUserStatus
for better role management and user status tracking.
- Expanded
-
lib/common/settings/app_settings.dart
- Integrated
SharedPreferences
for 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
FirebaseFailure
toFireAuthFailure
and introducedFireStoreFailure
for more specific error handling.
- Refactored error classes, renamed
-
lib/features/home/home_controller.dart
- Integrated
AppSettings
through 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
HomeDrawer
widget 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
HomeDrawer
widget 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
MaskedTextController
for 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
AppSettings
setup 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_preferences
for persistent storage andget_it
for 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.com
to 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.jpg
for use in the drawer header.
- Added a new image asset
-
lib/common/models/user.dart
- Created a new
UserModel
class to represent user data, including name, email, phone, and password.
- Created a new
-
lib/common/settings/app_settings.dart
- Removed singleton pattern for
AppSettings
in favor of dependency injection.
- Removed singleton pattern for
-
lib/components/widgets/message_snack_bar.dart
- Added a utility widget
showMessageSnackBar
to display messages using aSnackBar
.
- Added a utility widget
-
lib/components/widgets/password_text_field.dart
- Added
focusNode
andnextFocus
properties to improve form navigation and accessibility.
- Added
-
lib/components/widgets/state_loading.dart
- Introduced
StateLoading
widget to display a loading indicator overlay.
- Introduced
-
lib/features/home/home_controller.dart
- Integrated
UserStore
for managing user authentication state. - Added a
logout
method to handle user sign-out functionality.
- Integrated
-
lib/features/home/home_page.dart
- Updated to use
AppSettings
through 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
SignInController
to manage user sign-in logic and state.
- Created
-
lib/features/sign_in/sign_in_page.dart
- Refactored to utilize
SignInController
for 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
SignUpController
to manage user registration process and state.
- Added
-
lib/features/sign_up/sign_up_page.dart
- Refactored to use
SignUpController
and improved form validation and error handling.
- Refactored to use
-
lib/locator.dart
- Introduced a service locator using
GetIt
for 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
AppSettings
via 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
SignInStore
to manage state and validation for the sign-in form.
- Created
-
lib/stores/mobx/sign_up_store.dart
- Enhanced
SignUpStore
with additional validation methods and state management.
- Enhanced
-
lib/stores/user/user_store.dart
- Refactored
UserStore
to include detailed user state management and profile handling.
- Refactored
-
pubspec.lock
- Updated to include new dependencies:
firebase_dynamic_links
andget_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
.firebaserc
file to define the Firebase project configuration.
- Created a new
-
Makefile
- Added a
Makefile
for common build and development tasks, such as cleaning the project, generating diffs, and pushing commits.
- Added a
-
android/app/build.gradle
- Updated
build.gradle
to 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.json
to include emulator configuration and updated platform settings for Firebase.
- Modified
-
lib/common/theme/app_text_style.dart
- Created a new
AppTextStyle
class to define common text styles.
- Created a new
-
lib/common/utils/data_result.dart
- Added a new
FirebaseFailure
class to handle Firebase-specific errors.
- Added a new
-
lib/components/widgets/big_bottom.dart
- Created a
BigButton
widget to provide a customizable button component.
- Created a
-
lib/components/widgets/custom_text_field.dart
- Added a
fullBorder
parameter to control the appearance of text field borders.
- Added a
-
lib/components/widgets/password_text_field.dart
- Introduced a
PasswordTextField
widget with customizable parameters for enhanced user input security.
- Introduced a
-
lib/features/home/home_controller.dart
- Implemented
HomeController
to manage user authentication states and subscription handling.
- Implemented
-
lib/features/home/home_page.dart
- Updated
HomePage
to integrateHomeController
for managing authentication states.
- Updated
-
lib/features/sign_in/sign_in_page.dart
- Added
SignInPage
to handle user login functionality.
- Added
-
lib/features/sign_up/sign_up_page.dart
- Added
SignUpPage
to facilitate user registration with form validation.
- Added
-
lib/main.dart
- Refactored the main entry point to use
FirebaseService
for initializing Firebase.
- Refactored the main entry point to use
-
lib/my_material_app.dart
- Updated the app's routing configuration to include
SignInPage
andSignUpPage
.
- Updated the app's routing configuration to include
-
lib/repository/firebase/firebase_auth_repository.dart
- Created
FirebaseAuthRepository
for managing Firebase authentication operations.
- Created
-
lib/services/firebase_service.dart
- Introduced
FirebaseService
for handling Firebase initialization and logging.
- Introduced
-
lib/stores/auth/sign_up_store.dart
- Set up MobX store
SignUpStore
to manage the state and validation of user input during sign-up.
- Set up MobX store
-
lib/stores/user/user_store.dart
- Created
UserStore
to 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+2
to 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.