Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Compose「急いで」キャッチアップする

Swimmy
April 12, 2022
19

 Compose「急いで」キャッチアップする

Swimmy

April 12, 2022
Tweet

More Decks by Swimmy

Transcript

  1. 5 FragmentをまるっとCompose化 override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState:

    Bundle? ): View { return ComposeView(requireContext()).apply { setContent { // In Compose World
  2. 7 Viewの配置はどうやるん? 基本的にはColumn / Row / Boxで対応できる 困ったらConstraintLayout Column {

    Row { Text(“1行目”) Text(“1列目”) Text(“2行目”) Text(“2列目”) Text(“3行目”) Text(“3列目”) } }
  3. 13 Viewの状態はどうするん? val name = remember { mutableStateOf(“”) } TextField(

    value = name, onValueChange = { name = it } ) なんか、ViewModel不要論あるけども どうなん??
  4. 15 liveDataをstateとして扱う // ViewModel private val _name = MutableLiveData(“”) val

    name: LiveData<String> = _name // Compose val name by viewModel.hoge.observeAsState(“”)