This commit removes several placeholder image files (`img_dummy.jpg`, `img_dummy2.jpg`, `img_dummy3.jpg`, `img_dummy4.jpg`) from the `control_feature` module.
This commit introduces the commodity price prediction feature, including:
- **Data Layer:**
- Models for commodity prediction and price responses.
- `CommodityApiService` for fetching data from the backend.
- `CommodityRepository` to abstract data fetching logic.
- **DI Modules:**
- `appModule` for providing `CommodityRepository`.
- `networkModule` for setting up Retrofit and OkHttp.
- `viewModelModule` for providing `PredictionViewModel` and `CommodityViewModel`.
- **Presentation Layer:**
- `PredictionViewModel` and `CommodityViewModel` to handle business logic and expose data to UI.
- `PredictionScreen` to display commodity price predictions with a dropdown to select commodities and detailed breakdown of future prices (tomorrow, next week, next month, next 3 months).
- `CommodityPriceScreen` (initial setup, details to be implemented) to display current commodity prices.
- `CommodityListItem` composable for displaying individual commodity price information.
- `FeatureBanner` composable for both commodity price prediction and control features.
- **Navigation:**
- `SetupNavigation` to define navigation routes for `CommodityPriceScreen` and `PredictionScreen`.
- **Core Utilities:**
- `toRupiahFormat()` extension function to format numbers as Indonesian Rupiah.
- `percentageChange()` function to calculate percentage difference.
This commit introduces `ClusterViewModel` to manage the state and logic for fetching growth recipe recommendations.
Key functionalities:
- Manages a `StateFlow` named `_state` to represent the current state of the recommendation request (Idle, Loading, Success, Error).
- Provides a public `state` flow for observing changes in the recommendation request.
- Implements a `getRecommendation()` function that:
- Sets the state to `Loading`.
- Calls the `getRecommendation()` method of the `ClusteringRepository`.
- If successful and data is present, updates the state to `Success` with the last item from the response.
- If the response is empty, updates the state to `Error` with a "Data tidak ditemukan" message.
- Catches exceptions, maps them to user-friendly error messages, and updates the state to `Error`.
- Logs detailed error messages if fetching data fails.
This commit introduces the `ClusterScreen.kt` composable, which displays plant care recommendations.
The screen includes:
- A top app bar with the title "Rekomendasi Perawatan".
- Pull-to-refresh functionality to update recommendations.
- Display of an image based on the cluster number (1, 2, or 3).
- "Diperbarui Pada" (Updated On) timestamp, formatted to Indonesian locale.
- A "Rekomendasi" section showing general advice and specific care instructions.
- An image of a plant.
- `ListItemClustering` to display humidity, temperature, and pH values.
- Loading and error states handling.
A private `formatDate` utility function is included to format timestamps to "dd MMMM yyyy, HH:mm" in Indonesian.
This commit introduces a Koin module, `clusterNetworkModule`, to provide instances for network-related dependencies for the clustering feature.
Specifically, it provides:
- An `OkHttpClient` instance with a 5-second connection timeout.
- A `Retrofit` instance configured with a base URL ("http://labai.polinema.ac.id:5050/"), the provided `OkHttpClient`, and `GsonConverterFactory`.
- A `ClusteringService` instance created by the `Retrofit` instance.
This commit introduces the `ClusteringService` interface.
This interface defines a suspend function `getRecommendations` to fetch clustering recommendations from the "api/data" endpoint. It is expected to return a list of `ClusteringResponse` objects.