Skip to content

Commit 2834129

Browse files
authored
Move counter sample button to basic widgets (#2583)
Migrate counter over to basic as well.
1 parent d9c30b0 commit 2834129

File tree

52 files changed

+228
-604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+228
-604
lines changed

redwood-basic-compose/api/redwood-basic-compose.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
public final class app/cash/redwood/basic/compose/ButtonKt {
2+
public static final fun Button (Ljava/lang/String;ZLkotlin/jvm/functions/Function0;Lapp/cash/redwood/Modifier;Landroidx/compose/runtime/Composer;II)V
3+
}
4+
15
public final class app/cash/redwood/basic/compose/ImageKt {
26
public static final fun Image (Ljava/lang/String;Lkotlin/jvm/functions/Function0;Lapp/cash/redwood/Modifier;Landroidx/compose/runtime/Composer;II)V
37
}

redwood-basic-compose/api/redwood-basic-compose.klib.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
final val app.cash.redwood.basic.compose/app_cash_redwood_basic_compose_ReuseImpl$stableprop // app.cash.redwood.basic.compose/app_cash_redwood_basic_compose_ReuseImpl$stableprop|#static{}app_cash_redwood_basic_compose_ReuseImpl$stableprop[0]
1010

1111
final fun (app.cash.redwood/Modifier).app.cash.redwood.basic.compose/reuse(): app.cash.redwood/Modifier // app.cash.redwood.basic.compose/reuse|[email protected](){}[0]
12+
final fun app.cash.redwood.basic.compose/Button(kotlin/String?, kotlin/Boolean, kotlin/Function0<kotlin/Unit>?, app.cash.redwood/Modifier?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // app.cash.redwood.basic.compose/Button|Button(kotlin.String?;kotlin.Boolean;kotlin.Function0<kotlin.Unit>?;app.cash.redwood.Modifier?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
1213
final fun app.cash.redwood.basic.compose/Image(kotlin/String, kotlin/Function0<kotlin/Unit>?, app.cash.redwood/Modifier?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // app.cash.redwood.basic.compose/Image|Image(kotlin.String;kotlin.Function0<kotlin.Unit>?;app.cash.redwood.Modifier?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
1314
final fun app.cash.redwood.basic.compose/Text(kotlin/String, app.cash.redwood/Modifier?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // app.cash.redwood.basic.compose/Text|Text(kotlin.String;app.cash.redwood.Modifier?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
1415
final fun app.cash.redwood.basic.compose/TextInput(app.cash.redwood.basic.api/TextFieldState?, kotlin/String?, kotlin/Function1<app.cash.redwood.basic.api/TextFieldState, kotlin/Unit>?, app.cash.redwood/Modifier?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // app.cash.redwood.basic.compose/TextInput|TextInput(app.cash.redwood.basic.api.TextFieldState?;kotlin.String?;kotlin.Function1<app.cash.redwood.basic.api.TextFieldState,kotlin.Unit>?;app.cash.redwood.Modifier?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]

redwood-basic-composeui/api/android/redwood-basic-composeui.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
public final class app/cash/redwood/basic/composeui/ComposeUiRedwoodBasicWidgetFactory : app/cash/redwood/basic/widget/RedwoodBasicWidgetFactory {
22
public static final field $stable I
33
public fun <init> (Lcoil3/ImageLoader;)V
4+
public fun Button ()Lapp/cash/redwood/basic/widget/Button;
45
public fun Image ()Lapp/cash/redwood/basic/widget/Image;
56
public synthetic fun Reuse (Ljava/lang/Object;Lapp/cash/redwood/basic/modifier/Reuse;)V
67
public fun Reuse (Lkotlin/jvm/functions/Function2;Lapp/cash/redwood/basic/modifier/Reuse;)V

redwood-basic-composeui/api/jvm/redwood-basic-composeui.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
public final class app/cash/redwood/basic/composeui/ComposeUiRedwoodBasicWidgetFactory : app/cash/redwood/basic/widget/RedwoodBasicWidgetFactory {
22
public static final field $stable I
33
public fun <init> (Lcoil3/ImageLoader;)V
4+
public fun Button ()Lapp/cash/redwood/basic/widget/Button;
45
public fun Image ()Lapp/cash/redwood/basic/widget/Image;
56
public synthetic fun Reuse (Ljava/lang/Object;Lapp/cash/redwood/basic/modifier/Reuse;)V
67
public fun Reuse (Lkotlin/jvm/functions/Function2;Lapp/cash/redwood/basic/modifier/Reuse;)V

redwood-basic-composeui/api/redwood-basic-composeui.klib.api

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
final class app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory : app.cash.redwood.basic.widget/RedwoodBasicWidgetFactory<kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>> { // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory|null[0]
1010
constructor <init>(coil3/ImageLoader) // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory.<init>|<init>(coil3.ImageLoader){}[0]
1111

12+
final fun Button(): app.cash.redwood.basic.widget/Button<kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>> // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory.Button|Button(){}[0]
1213
final fun Image(): app.cash.redwood.basic.widget/Image<kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>> // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory.Image|Image(){}[0]
1314
final fun Reuse(kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, app.cash.redwood.basic.modifier/Reuse) // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory.Reuse|Reuse(kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;app.cash.redwood.basic.modifier.Reuse){}[0]
1415
final fun Text(): app.cash.redwood.basic.widget/Text<kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>> // app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory.Text|Text(){}[0]
@@ -17,12 +18,14 @@ final class app.cash.redwood.basic.composeui/ComposeUiRedwoodBasicWidgetFactory
1718

1819
final val app.cash.redwood.basic.composeui/Typography // app.cash.redwood.basic.composeui/Typography|{}Typography[0]
1920
final fun <get-Typography>(): androidx.compose.material/Typography // app.cash.redwood.basic.composeui/Typography.<get-Typography>|<get-Typography>(){}[0]
21+
final val app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiButton$stableprop // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiButton$stableprop|#static{}app_cash_redwood_basic_composeui_ComposeUiButton$stableprop[0]
2022
final val app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiImage$stableprop // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiImage$stableprop|#static{}app_cash_redwood_basic_composeui_ComposeUiImage$stableprop[0]
2123
final val app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop|#static{}app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop[0]
2224
final val app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiText$stableprop // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiText$stableprop|#static{}app_cash_redwood_basic_composeui_ComposeUiText$stableprop[0]
2325
final val app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiTextInput$stableprop // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiTextInput$stableprop|#static{}app_cash_redwood_basic_composeui_ComposeUiTextInput$stableprop[0]
2426

2527
final fun app.cash.redwood.basic.composeui/RedwoodBasicTheme(kotlin/Boolean, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // app.cash.redwood.basic.composeui/RedwoodBasicTheme|RedwoodBasicTheme(kotlin.Boolean;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
28+
final fun app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiButton$stableprop_getter(): kotlin/Int // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiButton$stableprop_getter|app_cash_redwood_basic_composeui_ComposeUiButton$stableprop_getter(){}[0]
2629
final fun app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiImage$stableprop_getter(): kotlin/Int // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiImage$stableprop_getter|app_cash_redwood_basic_composeui_ComposeUiImage$stableprop_getter(){}[0]
2730
final fun app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop_getter(): kotlin/Int // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop_getter|app_cash_redwood_basic_composeui_ComposeUiRedwoodBasicWidgetFactory$stableprop_getter(){}[0]
2831
final fun app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiText$stableprop_getter(): kotlin/Int // app.cash.redwood.basic.composeui/app_cash_redwood_basic_composeui_ComposeUiText$stableprop_getter|app_cash_redwood_basic_composeui_ComposeUiText$stableprop_getter(){}[0]

samples/counter/shared-composeui/src/main/kotlin/com/example/redwood/counter/composeui/ComposeUiButton.kt renamed to redwood-basic-composeui/src/commonMain/kotlin/app/cash/redwood/basic/composeui/ComposeUiButton.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.example.redwood.counter.composeui
16+
package app.cash.redwood.basic.composeui
1717

1818
import androidx.compose.foundation.layout.fillMaxWidth
1919
import androidx.compose.material.Button
@@ -24,7 +24,7 @@ import androidx.compose.runtime.mutableStateOf
2424
import androidx.compose.runtime.setValue
2525
import androidx.compose.ui.Modifier
2626
import app.cash.redwood.Modifier as RedwoodModifier
27-
import com.example.redwood.counter.widget.Button
27+
import app.cash.redwood.basic.widget.Button
2828

2929
internal class ComposeUiButton : Button<@Composable () -> Unit> {
3030
private var text by mutableStateOf("")

redwood-basic-composeui/src/commonMain/kotlin/app/cash/redwood/basic/composeui/ComposeUiRedwoodBasicWidgetFactory.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package app.cash.redwood.basic.composeui
1717

1818
import androidx.compose.runtime.Composable
1919
import app.cash.redwood.basic.modifier.Reuse
20+
import app.cash.redwood.basic.widget.Button
2021
import app.cash.redwood.basic.widget.Image
2122
import app.cash.redwood.basic.widget.RedwoodBasicWidgetFactory
2223
import app.cash.redwood.basic.widget.Text
@@ -29,6 +30,7 @@ public class ComposeUiRedwoodBasicWidgetFactory(
2930
override fun TextInput(): TextInput<@Composable () -> Unit> = ComposeUiTextInput()
3031
override fun Text(): Text<@Composable () -> Unit> = ComposeUiText()
3132
override fun Image(): Image<@Composable () -> Unit> = ComposeUiImage(imageLoader)
33+
override fun Button(): Button<@Composable (() -> Unit)> = ComposeUiButton()
3234
override fun Reuse(value: @Composable () -> Unit, modifier: Reuse) {
3335
}
3436
}

redwood-basic-dom/api/redwood-basic-dom.klib.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
final class app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory : app.cash.redwood.basic.widget/RedwoodBasicWidgetFactory<org.w3c.dom/HTMLElement> { // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory|null[0]
1010
constructor <init>(org.w3c.dom/Document) // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory.<init>|<init>(org.w3c.dom.Document){}[0]
1111

12+
final fun Button(): app.cash.redwood.basic.widget/Button<org.w3c.dom/HTMLElement> // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory.Button|Button(){}[0]
1213
final fun Image(): app.cash.redwood.basic.widget/Image<org.w3c.dom/HTMLElement> // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory.Image|Image(){}[0]
1314
final fun Reuse(org.w3c.dom/HTMLElement, app.cash.redwood.basic.modifier/Reuse) // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory.Reuse|Reuse(org.w3c.dom.HTMLElement;app.cash.redwood.basic.modifier.Reuse){}[0]
1415
final fun Text(): app.cash.redwood.basic.widget/Text<org.w3c.dom/HTMLElement> // app.cash.redwood.basic.dom/HTMLElementRedwoodBasicWidgetFactory.Text|Text(){}[0]

redwood-basic-dom/src/commonMain/kotlin/app/cash/redwood/basic/dom/HTMLElementRedwoodBasicWidgetFactory.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package app.cash.redwood.basic.dom
1818
import app.cash.redwood.Modifier
1919
import app.cash.redwood.basic.api.TextFieldState
2020
import app.cash.redwood.basic.modifier.Reuse
21+
import app.cash.redwood.basic.widget.Button
2122
import app.cash.redwood.basic.widget.Image
2223
import app.cash.redwood.basic.widget.RedwoodBasicWidgetFactory
2324
import app.cash.redwood.basic.widget.Text
2425
import app.cash.redwood.basic.widget.TextInput
2526
import org.w3c.dom.Document
27+
import org.w3c.dom.HTMLButtonElement
2628
import org.w3c.dom.HTMLElement
2729
import org.w3c.dom.HTMLImageElement
2830
import org.w3c.dom.HTMLInputElement
@@ -34,6 +36,7 @@ public class HTMLElementRedwoodBasicWidgetFactory(
3436
override fun TextInput(): TextInput<HTMLElement> = HtmlTextInput(document.createElement("input") as HTMLInputElement)
3537
override fun Text(): Text<HTMLElement> = HtmlText(document.createElement("span") as HTMLSpanElement)
3638
override fun Image(): Image<HTMLElement> = HtmlImage(document.createElement("img") as HTMLImageElement)
39+
override fun Button(): Button<HTMLElement> = HtmlButton(document.createElement("button") as HTMLButtonElement)
3740
override fun Reuse(value: HTMLElement, modifier: Reuse) {
3841
}
3942
}
@@ -112,3 +115,25 @@ private class HtmlImage(
112115
value.onclick = { onClick?.invoke() }
113116
}
114117
}
118+
119+
internal class HtmlButton(
120+
override val value: HTMLButtonElement,
121+
) : Button<HTMLElement> {
122+
override var modifier: Modifier = Modifier
123+
124+
override fun text(text: String?) {
125+
value.textContent = text
126+
}
127+
128+
override fun enabled(enabled: Boolean) {
129+
value.disabled = !enabled
130+
}
131+
132+
override fun onClick(onClick: (() -> Unit)?) {
133+
value.onclick = if (onClick != null) {
134+
{ onClick() }
135+
} else {
136+
null
137+
}
138+
}
139+
}

redwood-basic-schema/api/redwood-basic-schema.api

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
public final class app/cash/redwood/basic/Button {
2+
public fun <init> (Ljava/lang/String;ZLkotlin/jvm/functions/Function0;)V
3+
public synthetic fun <init> (Ljava/lang/String;ZLkotlin/jvm/functions/Function0;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
4+
public final fun component1 ()Ljava/lang/String;
5+
public final fun component2 ()Z
6+
public final fun component3 ()Lkotlin/jvm/functions/Function0;
7+
public final fun copy (Ljava/lang/String;ZLkotlin/jvm/functions/Function0;)Lapp/cash/redwood/basic/Button;
8+
public static synthetic fun copy$default (Lapp/cash/redwood/basic/Button;Ljava/lang/String;ZLkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lapp/cash/redwood/basic/Button;
9+
public fun equals (Ljava/lang/Object;)Z
10+
public final fun getEnabled ()Z
11+
public final fun getOnClick ()Lkotlin/jvm/functions/Function0;
12+
public final fun getText ()Ljava/lang/String;
13+
public fun hashCode ()I
14+
public fun toString ()Ljava/lang/String;
15+
}
16+
117
public final class app/cash/redwood/basic/Image {
218
public fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
319
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILkotlin/jvm/internal/DefaultConstructorMarker;)V

0 commit comments

Comments
 (0)