-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update README with Data Flow and Code Structure for Cupcake App #113
Open
ashwanil23
wants to merge
3
commits into
google-developer-training:main
Choose a base branch
from
ashwanil23:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows: User Interaction (Screens): The user interacts with the app through four key screens: StartOrderScreen: Users select the number of cupcakes. FlavorScreen: Users select the cupcake flavor. PickupScreen: Users choose a pickup date. SummaryScreen: The final order details are displayed, and users can share the order. Cupcake Screens Enum: The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.). OrderViewModel: The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup. As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time. Navigation: The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date). UI State and Updates: The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI. Order Summary: The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows: User Interaction (Screens): The user interacts with the app through four key screens: StartOrderScreen: Users select the number of cupcakes. FlavorScreen: Users select the cupcake flavor. PickupScreen: Users choose a pickup date. SummaryScreen: The final order details are displayed, and users can share the order. Cupcake Screens Enum: The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.). OrderViewModel: The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup. As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time. Navigation: The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date). UI State and Updates: The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI. Order Summary: The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
Data Flow and Code Structure (with Diagram Explanation): The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows: User Interaction (Screens): The user interacts with the app through four key screens: StartOrderScreen: Users select the number of cupcakes. FlavorScreen: Users select the cupcake flavor. PickupScreen: Users choose a pickup date. SummaryScreen: The final order details are displayed, and users can share the order. Cupcake Screens Enum: The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.). OrderViewModel: The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup. As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time. Navigation: The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date). UI State and Updates: The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI. Order Summary: The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds a detailed explanation of the data flow and code structure for the "Cupcake" app, providing a clear breakdown of user interactions, ViewModel state management, navigation flow, and UI reactivity. A diagram has been added to improve understanding, illustrating the architecture of the app and how data flows through various components like screens and the OrderViewModel.
This update is aimed at improving the documentation to help future contributors and users easily understand the project's structure and logic.
here is the sample of the diagram