Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ dependencies {
ksp(libs.hilt.android.compiler)
ksp(libs.hilt.compiler)
implementation(libs.reorderable)
implementation(libs.androidx.foundation.layout)
implementation(libs.androidx.animation.core)
implementation(libs.core.splashscreen)

Expand All @@ -187,9 +188,6 @@ dependencies {

implementation(libs.kotlinx.serialization.json)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@ class SourceDataRepository @Inject constructor(
launch {
onWeather(weatherJob.await())
}


}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import androidx.lifecycle.viewModelScope
import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherBlock
import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherUnits
import com.pranshulgg.weather_master_app.data.repository.LocationsRepository
import com.pranshulgg.weather_master_app.data.repository.WeatherBlocksRepository
import com.pranshulgg.weather_master_app.data.repository.WeatherUnitsRepository
import com.pranshulgg.weather_master_app.domain.usecase.LoadWeatherBlocksUseCase
import com.pranshulgg.weather_master_app.domain.usecase.SaveWeatherBlocksUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class DailyScreenViewModel @Inject constructor(
private val locationsRepo: LocationsRepository,
private val weatherUnitsRepository: WeatherUnitsRepository,
private val loadWeatherBlocksUseCase: LoadWeatherBlocksUseCase,
private val saveWeatherBlocksUseCase: SaveWeatherBlocksUseCase
private val weatherBlocksRepository: WeatherBlocksRepository,
private val weatherUnitsRepository: WeatherUnitsRepository
) : ViewModel() {

private var _uiState = mutableStateOf(DailyScreenUiState())
Expand All @@ -41,19 +39,14 @@ class DailyScreenViewModel @Inject constructor(
}


// TODO: Duplicate from `WeatherViewModel`
fun loadBlocks() {
viewModelScope.launch {
val loadedBlocks = loadWeatherBlocksUseCase(isDaily = true)
val loadedBlocks = weatherBlocksRepository.loadBlocks(isDaily = true)
_uiState.value = _uiState.value.copy(blocks = loadedBlocks)
}
}

fun saveBlocks(blocks: List<WeatherBlock>) {
viewModelScope.launch {
saveWeatherBlocksUseCase(blocks, isDaily = true)
}
}

fun updateBlocksOrder(blocks: List<WeatherBlock>) {
_uiState.value = _uiState.value.copy(blocks = blocks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ fun MainScreen(navController: NavController, weatherViewModel: WeatherViewModel)
if (activeLocation != null) {
weatherViewModel.getWeather(
activeLocation,
activeLocation.source,
isManualRefresh = true
)
}
Expand Down Expand Up @@ -199,4 +200,7 @@ fun MainScreen(navController: NavController, weatherViewModel: WeatherViewModel)
onDismiss = viewModel::hideChangelogSheet,
show = mainScreenUiState.isChangelogSheetOpen
)
}
}



Loading
Loading