-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace CodeListener with RedwoodView.Root (#2374)
* Replace CodeListener with RedwoodView.Root This moves loading/error/ready tracking to live beside the content, rather than as something that side-effects the content. This is not compatible with the old API and there is no shim. * Self-review updates * Fix some build problems * Track some API changes * Fix CI problems * Call super.Render() * Update samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchActivity.kt Co-authored-by: Jake Wharton <[email protected]> * Code review feedback --------- Co-authored-by: Jake Wharton <[email protected]>
- Loading branch information
1 parent
54f3477
commit d32766e
Showing
56 changed files
with
965 additions
and
670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
redwood-treehouse-host-composeui/api/android/redwood-treehouse-host-composeui.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
public class app/cash/redwood/treehouse/composeui/ComposeUiRoot : app/cash/redwood/widget/RedwoodView$Root { | ||
public static final field $stable I | ||
public fun <init> ()V | ||
public fun Render (Landroidx/compose/runtime/Composer;I)V | ||
public fun contentState (IZLjava/lang/Throwable;)V | ||
public synthetic fun getChildren ()Lapp/cash/redwood/widget/Widget$Children; | ||
public fun getChildren ()Lapp/cash/redwood/widget/compose/ComposeWidgetChildren; | ||
public fun getModifier ()Lapp/cash/redwood/Modifier; | ||
public synthetic fun getValue ()Ljava/lang/Object; | ||
public fun getValue ()Lkotlin/jvm/functions/Function2; | ||
public fun restart (Lkotlin/jvm/functions/Function0;)V | ||
public fun setModifier (Lapp/cash/redwood/Modifier;)V | ||
} | ||
|
||
public final class app/cash/redwood/treehouse/composeui/TreehouseContentKt { | ||
public static final fun TreehouseContent (Lapp/cash/redwood/treehouse/TreehouseApp;Lapp/cash/redwood/treehouse/TreehouseView$WidgetSystem;Lapp/cash/redwood/treehouse/TreehouseContentSource;Landroidx/compose/ui/Modifier;Lapp/cash/redwood/treehouse/CodeListener;Landroidx/compose/runtime/Composer;II)V | ||
public static final fun TreehouseContent (Lapp/cash/redwood/treehouse/TreehouseApp;Lapp/cash/redwood/treehouse/TreehouseView$WidgetSystem;Lapp/cash/redwood/treehouse/TreehouseContentSource;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V | ||
} | ||
|
16 changes: 15 additions & 1 deletion
16
redwood-treehouse-host-composeui/api/jvm/redwood-treehouse-host-composeui.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
public class app/cash/redwood/treehouse/composeui/ComposeUiRoot : app/cash/redwood/widget/RedwoodView$Root { | ||
public static final field $stable I | ||
public fun <init> ()V | ||
public fun Render (Landroidx/compose/runtime/Composer;I)V | ||
public fun contentState (IZLjava/lang/Throwable;)V | ||
public synthetic fun getChildren ()Lapp/cash/redwood/widget/Widget$Children; | ||
public fun getChildren ()Lapp/cash/redwood/widget/compose/ComposeWidgetChildren; | ||
public fun getModifier ()Lapp/cash/redwood/Modifier; | ||
public synthetic fun getValue ()Ljava/lang/Object; | ||
public fun getValue ()Lkotlin/jvm/functions/Function2; | ||
public fun restart (Lkotlin/jvm/functions/Function0;)V | ||
public fun setModifier (Lapp/cash/redwood/Modifier;)V | ||
} | ||
|
||
public final class app/cash/redwood/treehouse/composeui/TreehouseContentKt { | ||
public static final fun TreehouseContent (Lapp/cash/redwood/treehouse/TreehouseApp;Lapp/cash/redwood/treehouse/TreehouseView$WidgetSystem;Lapp/cash/redwood/treehouse/TreehouseContentSource;Landroidx/compose/ui/Modifier;Lapp/cash/redwood/treehouse/CodeListener;Landroidx/compose/runtime/Composer;II)V | ||
public static final fun TreehouseContent (Lapp/cash/redwood/treehouse/TreehouseApp;Lapp/cash/redwood/treehouse/TreehouseView$WidgetSystem;Lapp/cash/redwood/treehouse/TreehouseContentSource;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ost-composeui/src/commonMain/kotlin/app/cash/redwood/treehouse/composeui/ComposeUiRoot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package app.cash.redwood.treehouse.composeui | ||
|
||
import androidx.compose.runtime.Composable | ||
import app.cash.redwood.Modifier | ||
import app.cash.redwood.widget.RedwoodView | ||
import app.cash.redwood.widget.compose.ComposeWidgetChildren | ||
|
||
/** | ||
* A default base implementation of [RedwoodView.Root]. | ||
* | ||
* This composition contributes nothing to the view hierarchy. It delegates directly to its child | ||
* views. | ||
*/ | ||
public open class ComposeUiRoot : RedwoodView.Root<@Composable () -> Unit> { | ||
override val children: ComposeWidgetChildren = ComposeWidgetChildren() | ||
|
||
override var modifier: Modifier = Modifier | ||
|
||
override fun contentState( | ||
loadCount: Int, | ||
attached: Boolean, | ||
uncaughtException: Throwable?, | ||
) { | ||
} | ||
|
||
override fun restart(restart: (() -> Unit)?) { | ||
} | ||
|
||
override val value: @Composable () -> Unit = { | ||
Render() | ||
} | ||
|
||
@Composable | ||
public open fun Render() { | ||
children.Render() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.