Pablo
04/01/2025, 8:47 AMPablo
04/01/2025, 8:47 AMRouteMapPanel(
simpleMapCenterLocation = uiState.simpleMapCenterLocation,
selectedLocation = uiState.selectedLocation,
selectedLocationAddress = uiState.selectedLocationAddress,
originLocation = uiState.originLocation,
destinationLocation = uiState.destinationLocation,
hasLocationPermission = uiState.hasLocationPermission,
updateSimpleMapCenterLocation = { vm.updateSimpleMapCenterLocation(it) },
updateSelectedLocation = { vm.updateSelectedLocation(it) },
onOriginSelected = {
vm.updateSelectedLocation(null)
vm.transformLatLngIntoAddress(it, AddressType.ORIGIN)
},
onDestinationSelected = {
vm.updateSelectedLocation(null)
vm.transformLatLngIntoAddress(it, AddressType.DESTINATION)
},
onNavigate = { vm.navigate(context) },
onSwitchAddresses = { vm.switchAddresses() }
)
mattinger
04/01/2025, 4:26 PMmattinger
04/01/2025, 4:27 PMPablo
04/01/2025, 5:30 PMPablo
04/01/2025, 5:30 PMmattinger
04/01/2025, 5:44 PMdata class UIState(
val name: String
)
@Composable
fun MyScreen(uiState: UIState) {
Text(uiState.name)
}
@Composable
fun MyScreen(name: String) {
Text(name)
}
mattinger
04/01/2025, 5:46 PMmattinger
04/01/2025, 5:58 PMdata class UIState(
val name: String
)
class MyVM: ViewModel() {
var uiState by mutableStateOf( UIState("") )
fun onClick() {
}
}
@Composable
fun MyScreen(vmFactory: ViewModelProvider.Factory) {
val vm: MyVM = viewModel(factory = vmFactory)
MyScreen(vm)
}
@Composable
fun MyScreen(myVM: MyVM) {
MyScreen(myVM.uiState.name, onClick = myVM::onClick)
}
@Composable
fun MyScreen(name: String, onClick: () -> Unit) {
Button(onClick = onClick) {
Text(name)
}
}
mattinger
04/01/2025, 5:59 PMPablo
04/01/2025, 5:59 PMPablo
04/01/2025, 6:00 PMmattinger
04/01/2025, 6:02 PM