1 /*
<lambda>null2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package androidx.compose.runtime
17
18 import android.view.View
19 import android.widget.Button
20 import android.widget.LinearLayout
21 import android.widget.TextView
22 import androidx.compose.ui.viewinterop.AndroidView
23
24 @Suppress("UNUSED_PARAMETER")
25 @Composable
26 fun TextView(id: Int = 0, text: String = "", onClickListener: View.OnClickListener? = null) {
27 AndroidView(factory = { TextView(it) }) { view ->
28 view.id = id
29 view.text = text
30 if (onClickListener != null) view.setOnClickListener(onClickListener)
31 }
32 }
33
34 @Suppress("UNUSED_PARAMETER")
35 @Composable
Buttonnull36 fun Button(id: Int = 0, text: String = "", onClickListener: View.OnClickListener? = null) {
37 AndroidView(factory = { Button(it) }) { view ->
38 view.id = id
39 view.text = text
40 if (onClickListener != null) view.setOnClickListener(onClickListener)
41 }
42 }
43
44 @Suppress("UNUSED_PARAMETER")
45 @Composable
LinearLayoutnull46 fun LinearLayout(
47 id: Int = 0,
48 orientation: Int = LinearLayout.VERTICAL,
49 onClickListener: View.OnClickListener? = null,
50 content: @Composable () -> Unit
51 ) {}
52