我使用 Jetpack Compose 和导航撰写,我想将 id 传递给此viewmodel:
class RecallViewModel(private val id:Long,application: Application):AndroidViewModel(application) {
............................
}
Run Code Online (Sandbox Code Playgroud)
可组合函数:
我不知道如何获得application可组合函数:
@Composable
fun RecallScreen(
id:Long,
onEnd:() -> Unit
){
val recallViewModel = viewModel(factory = RecallViewModelFactory(
id = id,application = "i don't know how to get application"))
}
Run Code Online (Sandbox Code Playgroud)
和工厂
class RecallViewModelFactory(private val id:Long,val application: Application):ViewModelProvider.AndroidViewModelFactory(application) {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return RecallViewModel(id,application) as T
}
}
Run Code Online (Sandbox Code Playgroud)
composable(
"${Routes.recall}/{id}",
arguments = listOf(navArgument("id") { type = NavType.LongType })
) …Run Code Online (Sandbox Code Playgroud) android kotlin android-jetpack-navigation android-jetpack-compose
我有录制语音的按钮,所以我希望它在用户按下它时开始录制,并在用户离开时停止录制
@Composable
fun Screen(){
Button(){
Text("record")
}
}
Run Code Online (Sandbox Code Playgroud) android kotlin android-jetpack-compose android-compose-button android-jetpack-compose-button
这是产品表单组件我想裁剪图像并在没有后端的情况下上传,然后将其上传到firebase存储
我想以恒定的纵横比自动或手动裁剪以适合卡或者我想在卡本身中裁剪它我尝试使用react-image -crop 但我没有成功,它需要大量设置,我不知道该怎么做
import React, { useState } from 'react'
import Input from '../../components/input/input.component'
import Button from '../../components/button/button.component'
import {db} from '../../firebase'
import './addproduct.styles.scss'
import { storage } from 'firebase'
import Spinner from '../../components/spinner/spinner.component'
const AddProduct = ({catigories}) => {
const [name,setName] = useState('')
const [price,setPrice] = useState('')
const [catigory,setCatigory] = useState('')
const [newCatigoryName,setNewCatigoryName] = useState('')
const [newCatigoryImg,setNewCatigorImg] = useState(null)
const [image,setImage] = useState(null)
const [isSending,setIsSending] = useState(false)
console.log(image)
const handleSubmit = async (event) => {
event.preventDefault()
if(name && …Run Code Online (Sandbox Code Playgroud) android ×2
kotlin ×2
android-jetpack-compose-button ×1
firebase ×1
javascript ×1
react-hooks ×1
reactjs ×1