Skip to content

Commit

Permalink
One bug need to fix in MVI clean code feature
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed Jun 30, 2023
1 parent db279bc commit 5d22a06
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,39 @@ import androidx.compose.foundation.layout.height
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.example.jetpack_compose_all_in_one.ui.theme.Blue10
import com.example.jetpack_compose_all_in_one.ui.theme.L1BoxColor2
import com.example.jetpack_compose_all_in_one.utils.requestAllLocation
import com.google.accompanist.permissions.ExperimentalPermissionsApi


@OptIn(ExperimentalPermissionsApi::class)
@Composable
fun WeatherScreen(
viewModel: WeatherViewModel
) {
var isLocationAvailable by remember { mutableStateOf(false) }
val requestingLocation = requestAllLocation { isLocationAvailable = it }

LaunchedEffect(Unit) {
requestingLocation.launchMultiplePermissionRequest()
}

LaunchedEffect(isLocationAvailable) {
if (isLocationAvailable) {
viewModel.loadWeatherInfo()
}
}

Box(
modifier = Modifier.fillMaxSize()
) {
Expand Down

0 comments on commit 5d22a06

Please sign in to comment.