# Modification Design: Login-Based Home Screen

## Overview

This document outlines the design for modifying the home screen to display different content based on the user's authentication status. The goal is to show a "logged out" view to unauthenticated users and a "logged in" view to authenticated users, as depicted in the provided design images.

## Analysis

The current `HomeScreen` displays a static UI that does not change based on the authentication state. The `AuthState` class manages the user's login status, and the `HomeScreen` needs to react to changes in this state. The `provider` package is already in use for state management, which makes it the ideal tool for this task.

## Alternatives Considered

1.  **Conditional Logic in `build()` Method:** The simplest approach is to use a conditional statement (like an `if` or ternary operator) directly within the `HomeScreen`'s `build` method. This would involve wrapping the `Scaffold`'s body with a `Consumer<AuthState>` widget to listen for changes and rebuild the UI accordingly. This is a straightforward and efficient solution for this use case.

2.  **Separate `StatelessWidget`s for Each State:** A more modular approach would be to create two separate widgets, for instance `LoggedInHome` and `LoggedOutHome`. The `HomeScreen` would then act as a container that decides which of these two widgets to display based on the authentication state. This approach is slightly more verbose but can lead to cleaner code if the UI for each state is complex.

For this modification, the first alternative is the most appropriate due to its simplicity and the relatively contained nature of the changes.

## Detailed Design

The `HomeScreen` will be modified to use a `Consumer<AuthState>` widget from the `provider` package. This widget will wrap the `Scaffold`'s body. The `builder` of the `Consumer` will receive the `authState` and decide which UI to render.

### Mermaid Diagram

```mermaid
graph TD
    A[HomeScreen build()] --> B{Consumer<AuthState>};
    B --> C{authState.isLoggedIn?};
    C -- Yes --> D["LoggedIn UI (home_login.png)"];
    C -- No --> E["LoggedOut UI (home_logout.png)"];
```

### Implementation Details

1.  **`lib/home/home_screen.dart`:**
    *   The `build` method will be updated.
    *   The `body` of the `Scaffold` will be a `Consumer<AuthState>`.
    *   The `builder` of the `Consumer` will have the following logic:
        ```dart
        builder: (context, authState, child) {
          if (authState.isLoggedIn) {
            // Return the widget for the logged-in state
          } else {
            // Return the widget for the logged-out state
          }
        }
        ```

2.  **Logged-In UI:** This will be a new private widget, `_LoggedInView`, that shows a `ListView` with some dummy data, an `AppBar` with a "Profile" button, and a "Logout" button.

3.  **Logged-Out UI:** This will be a new private widget, `_LoggedOutView`, that shows a centered `Column` with a "Login" button.

## Summary

The `HomeScreen` will be refactored to be dynamic, showing either a logged-in or logged-out view based on the `AuthState`. This will be achieved using the `provider` package's `Consumer` widget to listen for authentication state changes and conditionally render the appropriate UI. This approach is clean, efficient, and aligns with the existing architecture of the application.
