User Model ========== The `User` model in the SailPilot application serves as the primary data structure for user information and authentication. It is stored locally using Hive, a NoSQL database, to facilitate offline-first capabilities. Fields ------ The model includes fields such as `id`, `username`, `first_name`, `last_name`, `email`, and `password`. These fields store essential user details. Serialization and Deserialization --------------------------------- - **toMap**: Converts the `User` object into a Map, facilitating serialization. - **fromMap**: Factory constructor to instantiate a `User` object from a Map, useful for deserialization. User Data Management -------------------- - **updateUserData**: Updates user data in the local storage and queues the changes for synchronization with the backend. - **getOrCreateUserProfile**: Retrieves an existing user profile or creates a new one if it doesn't exist. - **deleteUser**: Removes a user and their profile from local storage. - **getCurrentUser**: Fetches the currently logged-in user based on stored credentials. These methods ensure that the user data is consistent and up-to-date both locally and on the server, supporting the app's offline-first functionality. .. note:: The `User` model is central to the authentication process and user data management in SailPilot, interfacing with the app's local database and synchronization mechanisms. UserProfile Model ================= The `UserProfile` model in the SailPilot application provides additional details about the user. It extends the `User` model's data and is critical for managing user profile information. Fields ------ The model includes a variety of fields to store user profile details such as `dob`, `phone`, `address`, `city`, `area`, `zipcode`, `country`, and `profilePic`. Serialization and Deserialization --------------------------------- - **toMap**: Method to convert the `UserProfile` object into a Map, facilitating serialization. - **fromMap**: Factory constructor to create a `UserProfile` object from a Map, useful for deserialization. Profile Data Management ----------------------- - **updateUserProfileData**: Method to update the user profile in the local Hive database and queue the changes for synchronization with the backend server. This ensures data consistency across the app and server. This model plays a key role in personalizing the user experience in the SailPilot app by storing and managing detailed user information. .. note:: The `UserProfile` model's integration with the local Hive database and the data synchronization system underscores the app's offline-first architecture, ensuring user data is always up-to-date and accessible.