Advertisement
Guido_Fe

Untitled

Dec 14th, 2022
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.75 KB | None | 0 0
  1. import androidx.compose.material3.*
  2. import com.guidofe.pocketlibrary.viewmodels.EditBookVM
  3. import com.guidofe.pocketlibrary.viewmodels.interfaces.IEditBookVM
  4. ...
  5.  
  6. val verticalSpace = 8.dp
  7. val horizontalSpace = 8.dp
  8.  
  9. @OptIn(
  10.     ExperimentalMaterial3Api::class, ExperimentalPermissionsApi::class
  11. )
  12. @Destination
  13. @Composable
  14. fun EditBookPage(
  15.     bookId: Long? = null,
  16.     isbn: String? = null,
  17.     newBookDestination: BookDestination? = null,
  18.     navigator: DestinationsNavigator,
  19.     vm: IEditBookVM = hiltViewModel<EditBookVM>(),
  20.     coverPhotoRecipient: ResultRecipient<TakeCoverPhotoPageDestination, Uri>
  21. ) {
  22.     coverPhotoRecipient.onNavResult { result ->
  23.         Log.d("debug", "EditPage received result")
  24.         if (result is NavResult.Value) {
  25.             Log.d("debug", "EditPage result is valid, == ${result.value}")
  26.             vm.state.coverUri = result.value
  27.         } else {
  28.             Log.e("debug", "EditPage result is not valid")
  29.         }
  30.     }
  31.     val scrollState = rememberScrollState()
  32.     val focusManager = LocalFocusManager.current
  33.     ...
  34.    
  35.     Column(
  36.         horizontalAlignment = Alignment.CenterHorizontally,
  37.         verticalArrangement = Arrangement.spacedBy(verticalSpace),
  38.         modifier = Modifier
  39.             .verticalScroll(scrollState)
  40.             .fillMaxWidth()
  41.             .nestedScroll(vm.scaffoldState.scrollBehavior!!.nestedScrollConnection)
  42.             .padding(8.dp)
  43.     ) {
  44.  
  45.         ...
  46.        
  47.         OutlinedTextField(
  48.             value = vm.state.title,
  49.             label = { Text(stringResource(id = R.string.title) + "*") },
  50.             onValueChange = { vm.state.title = it },
  51.             singleLine = true,
  52.             modifier = Modifier.fillMaxWidth()
  53.         )
  54.        ...
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement