From 46ba6b5001bb0c4ccb96a445ada55c0e4db1837f Mon Sep 17 00:00:00 2001 From: Colin White Date: Tue, 2 Jan 2024 02:12:40 -0500 Subject: [PATCH 01/10] Support the Emoji Search sample on desktop. --- gradle/libs.versions.toml | 3 +- redwood-treehouse-host/build.gradle | 2 +- samples/emoji-search/composeui/build.gradle | 79 ++++++++++++++++++ .../android/composeui/EmojiSearchUiTest.kt | 0 .../src/androidMain}/AndroidManifest.xml | 0 .../composeui/EmojiSearchActivity.kt | 18 +++- .../drawable-v24/ic_launcher_foreground.xml | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../src/androidMain}/res/values/colors.xml | 0 .../src/androidMain}/res/values/strings.xml | 0 .../src/androidMain}/res/values/themes.xml | 0 .../ComposeUiEmojiSearchWidgetFactory.kt} | 6 +- .../emojisearch}/composeui/ComposeUiImage.kt | 4 +- .../emojisearch}/composeui/ComposeUiText.kt | 4 +- .../composeui/ComposeUiTextInput.kt | 4 +- .../composeui/EmojiSearchApplication.kt | 0 .../emojisearch}/composeui/RealHostApi.kt | 14 +--- .../redwood/emojisearch}/composeui/theme.kt | 4 +- .../redwood/emojisearch/composeui/utils.kt | 32 +++++++ .../emojisearch/composeui/DesktopNavigator.kt | 26 ++++++ .../emojisearch/composeui/JvmHttpClient.kt | 74 ++++++++++++++++ .../redwood/emojisearch/composeui/main.kt | 66 +++++++++++++++ samples/emoji-search/launcher/build.gradle | 2 + .../emojisearch/presenter/EmojiSearch.kt | 8 +- .../presenter/NestedFlexBoxContainers.kt | 10 ++- settings.gradle | 2 +- 32 files changed, 323 insertions(+), 35 deletions(-) create mode 100644 samples/emoji-search/composeui/build.gradle rename samples/emoji-search/{android-composeui/src/androidTest => composeui/src/androidInstrumentedTest}/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/AndroidManifest.xml (100%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/androidMain/kotlin/com/example/redwood/emojisearch}/composeui/EmojiSearchActivity.kt (92%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/drawable-v24/ic_launcher_foreground.xml (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/drawable/ic_launcher_background.xml (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-hdpi/ic_launcher.webp (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-mdpi/ic_launcher.webp (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-xhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/values/colors.xml (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/values/strings.xml (100%) rename samples/emoji-search/{android-composeui/src/main => composeui/src/androidMain}/res/values/themes.xml (100%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/AndroidEmojiSearchWidgetFactory.kt => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt} (85%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/ComposeUiImage.kt (94%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/ComposeUiText.kt (93%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/ComposeUiTextInput.kt (97%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/EmojiSearchApplication.kt (100%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/RealHostApi.kt (84%) rename samples/emoji-search/{android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android => composeui/src/commonMain/kotlin/com/example/redwood/emojisearch}/composeui/theme.kt (95%) create mode 100644 samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt create mode 100644 samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt create mode 100644 samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt create mode 100644 samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c766c9b538..96c2d19fb0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,6 +22,7 @@ kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } @@ -69,7 +70,7 @@ assertk = "com.willowtreeapps.assertk:assertk:0.28.0" robolectric = { module = "org.robolectric:robolectric", version = "4.11.1" } okio = { module = "com.squareup.okio:okio", version.ref = "okio" } okio-assetfilesystem = { module = "com.squareup.okio:okio-assetfilesystem", version.ref = "okio" } -okHttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" } paging-compose-common = { module = "app.cash.paging:paging-compose-common", version = "3.3.0-alpha02-0.4.0" } zipline = { module = "app.cash.zipline:zipline", version.ref = "zipline" } zipline-gradlePlugin = { module = "app.cash.zipline:zipline-gradle-plugin", version.ref = "zipline" } diff --git a/redwood-treehouse-host/build.gradle b/redwood-treehouse-host/build.gradle index a8a6f629e7..b04ef0ff17 100644 --- a/redwood-treehouse-host/build.gradle +++ b/redwood-treehouse-host/build.gradle @@ -28,7 +28,7 @@ kotlin { androidMain { dependencies { - api libs.okHttp + api libs.okhttp implementation libs.androidx.activity } } diff --git a/samples/emoji-search/composeui/build.gradle b/samples/emoji-search/composeui/build.gradle new file mode 100644 index 0000000000..1926395b2c --- /dev/null +++ b/samples/emoji-search/composeui/build.gradle @@ -0,0 +1,79 @@ +apply plugin: 'com.android.application' +apply plugin: 'org.jetbrains.kotlin.multiplatform' +apply plugin: 'org.jetbrains.compose' + +redwoodBuild { + embedZiplineApplication(projects.samples.emojiSearch.presenterTreehouse) +} + +android { + namespace 'com.example.redwood.emojisearch.android.composeui' + + defaultConfig { + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + } + + buildFeatures { + // Needed to pass application ID to UIAutomator tests. + buildConfig = true + } +} + +compose { + desktop { + application { + mainClass = "com.example.redwood.emojisearch.composeui.Main" + } + } +} + +kotlin { + androidTarget() + jvm("desktop") + + sourceSets { + commonMain { + dependencies { + implementation projects.samples.emojiSearch.launcher + implementation projects.samples.emojiSearch.presenterTreehouse + implementation projects.samples.emojiSearch.schema.widget.protocol + implementation projects.redwoodLayoutComposeui + implementation projects.redwoodLazylayoutComposeui + implementation projects.redwoodTreehouseHost + implementation projects.redwoodTreehouseHostComposeui + implementation projects.redwoodWidgetCompose + implementation libs.coil.compose + implementation libs.coil.network + implementation libs.ktor.engine.okhttp + implementation libs.jetbrains.compose.material + implementation libs.jetbrains.compose.ui + implementation libs.jetbrains.compose.ui.tooling.preview + implementation libs.zipline.loader + } + } + androidMain { + dependencies { + implementation libs.androidx.activity.compose + implementation libs.androidx.appCompat + implementation libs.androidx.core + implementation libs.google.material + implementation libs.kotlinx.coroutines.android + implementation libs.okio.assetfilesystem + } + } + desktopMain { + dependencies { + implementation projects.samples.emojiSearch.presenter + implementation projects.redwoodComposeui + implementation compose.desktop.currentOs + implementation libs.kotlinx.coroutines.swing + } + } + androidInstrumentedTest { + dependencies { + implementation libs.androidx.test.runner + implementation projects.samples.emojiSearch.androidTests + } + } + } +} diff --git a/samples/emoji-search/android-composeui/src/androidTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt b/samples/emoji-search/composeui/src/androidInstrumentedTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt similarity index 100% rename from samples/emoji-search/android-composeui/src/androidTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt rename to samples/emoji-search/composeui/src/androidInstrumentedTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt diff --git a/samples/emoji-search/android-composeui/src/main/AndroidManifest.xml b/samples/emoji-search/composeui/src/androidMain/AndroidManifest.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/AndroidManifest.xml rename to samples/emoji-search/composeui/src/androidMain/AndroidManifest.xml diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt b/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt similarity index 92% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt rename to samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt index ebcd73a384..c45dbb34fc 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt +++ b/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,8 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.util.Log import androidx.activity.ComponentActivity @@ -63,6 +65,7 @@ class EmojiSearchActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) WindowCompat.setDecorFitsSystemWindows(window, false) + applySingletonImageLoader() val treehouseApp = createTreehouseApp() val treehouseContentSource = TreehouseContentSource(EmojiSearchPresenter::launch) @@ -70,7 +73,7 @@ class EmojiSearchActivity : ComponentActivity() { val widgetSystem = WidgetSystem { json, protocolMismatchHandler -> EmojiSearchProtocolFactory<@Composable () -> Unit>( provider = EmojiSearchWidgetFactories( - EmojiSearch = AndroidEmojiSearchWidgetFactory(), + EmojiSearch = ComposeUiEmojiSearchWidgetFactory(), RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), RedwoodLazyLayout = ComposeUiRedwoodLazyLayoutWidgetFactory(), ), @@ -141,7 +144,14 @@ class EmojiSearchActivity : ComponentActivity() { appScope = scope, spec = EmojiSearchAppSpec( manifestUrl = manifestUrlFlow, - hostApi = RealHostApi(this@EmojiSearchActivity, httpClient), + hostApi = RealHostApi( + client = httpClient, + openUrl = { url -> + val intent = Intent(Intent.ACTION_VIEW) + intent.setData(Uri.parse(url)) + startActivity(intent) + }, + ), ), ) diff --git a/samples/emoji-search/android-composeui/src/main/res/drawable-v24/ic_launcher_foreground.xml b/samples/emoji-search/composeui/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to samples/emoji-search/composeui/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml diff --git a/samples/emoji-search/android-composeui/src/main/res/drawable/ic_launcher_background.xml b/samples/emoji-search/composeui/src/androidMain/res/drawable/ic_launcher_background.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/drawable/ic_launcher_background.xml rename to samples/emoji-search/composeui/src/androidMain/res/drawable/ic_launcher_background.xml diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/emoji-search/composeui/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-hdpi/ic_launcher.webp b/samples/emoji-search/composeui/src/androidMain/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-hdpi/ic_launcher.webp rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-hdpi/ic_launcher.webp diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-mdpi/ic_launcher.webp b/samples/emoji-search/composeui/src/androidMain/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-mdpi/ic_launcher.webp rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-mdpi/ic_launcher.webp diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-xhdpi/ic_launcher.webp b/samples/emoji-search/composeui/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/samples/emoji-search/composeui/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/samples/emoji-search/android-composeui/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/samples/emoji-search/composeui/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to samples/emoji-search/composeui/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/samples/emoji-search/android-composeui/src/main/res/values/colors.xml b/samples/emoji-search/composeui/src/androidMain/res/values/colors.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/values/colors.xml rename to samples/emoji-search/composeui/src/androidMain/res/values/colors.xml diff --git a/samples/emoji-search/android-composeui/src/main/res/values/strings.xml b/samples/emoji-search/composeui/src/androidMain/res/values/strings.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/values/strings.xml rename to samples/emoji-search/composeui/src/androidMain/res/values/strings.xml diff --git a/samples/emoji-search/android-composeui/src/main/res/values/themes.xml b/samples/emoji-search/composeui/src/androidMain/res/values/themes.xml similarity index 100% rename from samples/emoji-search/android-composeui/src/main/res/values/themes.xml rename to samples/emoji-search/composeui/src/androidMain/res/values/themes.xml diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/AndroidEmojiSearchWidgetFactory.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt similarity index 85% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/AndroidEmojiSearchWidgetFactory.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt index 92aaabc39c..5f99c03d16 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/AndroidEmojiSearchWidgetFactory.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui import androidx.compose.runtime.Composable import com.example.redwood.emojisearch.widget.EmojiSearchWidgetFactory @@ -21,7 +21,7 @@ import com.example.redwood.emojisearch.widget.Image import com.example.redwood.emojisearch.widget.Text import com.example.redwood.emojisearch.widget.TextInput -class AndroidEmojiSearchWidgetFactory : EmojiSearchWidgetFactory<@Composable () -> Unit> { +class ComposeUiEmojiSearchWidgetFactory : EmojiSearchWidgetFactory<@Composable () -> Unit> { override fun TextInput(): TextInput<@Composable () -> Unit> = ComposeUiTextInput() override fun Text(): Text<@Composable () -> Unit> = ComposeUiText() override fun Image(): Image<@Composable () -> Unit> = ComposeUiImage() diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiImage.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt similarity index 94% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiImage.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt index 4d1a5c6229..bc1355a3de 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiImage.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.size diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiText.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt similarity index 93% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiText.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt index dc409734b3..8adb7c8a05 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiText.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui import androidx.compose.material.MaterialTheme import androidx.compose.material.Text diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiTextInput.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt similarity index 97% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiTextInput.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt index f28e663995..ee01d52475 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/ComposeUiTextInput.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui import androidx.compose.material.Text import androidx.compose.material.TextField diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchApplication.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt similarity index 100% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchApplication.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt similarity index 84% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt index 92bf6e2834..4928598712 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,12 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui -import android.content.Context -import android.content.Intent -import android.net.Uri -import androidx.core.content.ContextCompat.startActivity import com.example.redwood.emojisearch.treehouse.HostApi import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException @@ -36,8 +32,8 @@ class HttpException(response: Response) : RuntimeException("HTTP ${response.code} ${response.message}") class RealHostApi( - private val context: Context, private val client: OkHttpClient, + private val openUrl: (url: String) -> Unit, ) : HostApi { override suspend fun httpCall(url: String, headers: Map): String { return suspendCancellableCoroutine { continuation -> @@ -67,8 +63,6 @@ class RealHostApi( } override fun openUrl(url: String) { - val intent = Intent(Intent.ACTION_VIEW) - intent.setData(Uri.parse(url)) - startActivity(context, intent, null) + openUrl.invoke(url) } } diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/theme.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt similarity index 95% rename from samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/theme.kt rename to samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt index 6d3c10c7e2..8de58672cd 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/theme.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.android.composeui +package com.example.redwood.emojisearch.composeui import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.shape.RoundedCornerShape diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt new file mode 100644 index 0000000000..6363c61cd9 --- /dev/null +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt @@ -0,0 +1,32 @@ +/* + * 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 com.example.redwood.emojisearch.composeui + +import coil3.ImageLoader +import coil3.SingletonImageLoader +import coil3.annotation.ExperimentalCoilApi +import coil3.fetch.NetworkFetcher + +@OptIn(ExperimentalCoilApi::class) +fun applySingletonImageLoader() { + SingletonImageLoader.setSafe { context -> + ImageLoader.Builder(context) + .components { + add(NetworkFetcher.Factory()) + } + .build() + } +} diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt new file mode 100644 index 0000000000..83932d6329 --- /dev/null +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt @@ -0,0 +1,26 @@ +/* + * 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 com.example.redwood.emojisearch.composeui + +import com.example.redwood.emojisearch.presenter.Navigator +import java.awt.Desktop +import java.net.URI + +class DesktopNavigator : Navigator { + override fun openUrl(url: String) { + Desktop.getDesktop().browse(URI(url)) + } +} diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt new file mode 100644 index 0000000000..51156a0d64 --- /dev/null +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt @@ -0,0 +1,74 @@ +/* + * 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 com.example.redwood.emojisearch.composeui + +import com.example.redwood.emojisearch.presenter.HttpClient +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlinx.coroutines.CancellableContinuation +import kotlinx.coroutines.CompletionHandler +import kotlinx.coroutines.suspendCancellableCoroutine +import okhttp3.Call +import okhttp3.Callback +import okhttp3.Headers.Companion.toHeaders +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response +import okio.IOException + +class JvmHttpClient( + private val okHttpClient: OkHttpClient = OkHttpClient(), +) : HttpClient { + + override suspend fun call(url: String, headers: Map): String { + val request = Request.Builder() + .url(url) + .headers(headers.toHeaders()) + .build() + val response = okHttpClient.newCall(request).await() + return response.body?.string().orEmpty() + } +} + +private suspend fun Call.await(): Response { + return suspendCancellableCoroutine { continuation -> + val callback = ContinuationCallback(this, continuation) + enqueue(callback) + continuation.invokeOnCancellation(callback) + } +} + +private class ContinuationCallback( + private val call: Call, + private val continuation: CancellableContinuation, +) : Callback, CompletionHandler { + + override fun onResponse(call: Call, response: Response) { + continuation.resume(response) + } + + override fun onFailure(call: Call, e: IOException) { + if (!call.isCanceled()) { + continuation.resumeWithException(e) + } + } + + override fun invoke(cause: Throwable?) { + try { + call.cancel() + } catch (_: Throwable) {} + } +} diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt new file mode 100644 index 0000000000..b6c28b46e0 --- /dev/null +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt @@ -0,0 +1,66 @@ +/* + * 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. + */ +@file:JvmName("Main") + +package com.example.redwood.emojisearch.composeui + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Scaffold +import androidx.compose.ui.Modifier +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import app.cash.redwood.composeui.RedwoodContent +import app.cash.redwood.layout.composeui.ComposeUiRedwoodLayoutWidgetFactory +import app.cash.redwood.lazylayout.composeui.ComposeUiRedwoodLazyLayoutWidgetFactory +import app.cash.redwood.ui.Margin +import com.example.redwood.emojisearch.presenter.EmojiSearch +import com.example.redwood.emojisearch.widget.EmojiSearchWidgetFactories + +fun main() { + applySingletonImageLoader() + + val httpClient = JvmHttpClient() + val navigator = DesktopNavigator() + val factories = EmojiSearchWidgetFactories( + EmojiSearch = ComposeUiEmojiSearchWidgetFactory(), + RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), + RedwoodLazyLayout = ComposeUiRedwoodLazyLayoutWidgetFactory(), + ) + + application { + Window( + onCloseRequest = ::exitApplication, + title = "Emoji Search", + ) { + EmojiSearchTheme { + Scaffold { contentPadding -> + Box( + modifier = Modifier.padding(contentPadding), + ) { + RedwoodContent(factories) { + EmojiSearch( + httpClient = httpClient, + navigator = navigator, + safeAreaInsets = Margin.Zero, + ) + } + } + } + } + } + } +} diff --git a/samples/emoji-search/launcher/build.gradle b/samples/emoji-search/launcher/build.gradle index 9c68fa7519..73afa80738 100644 --- a/samples/emoji-search/launcher/build.gradle +++ b/samples/emoji-search/launcher/build.gradle @@ -9,6 +9,8 @@ kotlin { androidTarget() + jvm() + sourceSets { commonMain { dependencies { diff --git a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt index d954971b05..dd9a19b2c2 100644 --- a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt +++ b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt @@ -73,10 +73,11 @@ fun EmojiSearch( httpClient: HttpClient, navigator: Navigator, variant: Variant = Variant.LAZY_COLUMN, + safeAreaInsets: Margin = LocalUiConfiguration.current.safeAreaInsets, ) { when (variant) { - Variant.LAZY_COLUMN -> LazyColumn(httpClient, navigator) - Variant.SCROLLABLE_FLEXBOX -> NestedFlexBoxContainers(httpClient) + Variant.LAZY_COLUMN -> LazyColumn(httpClient, navigator, safeAreaInsets) + Variant.SCROLLABLE_FLEXBOX -> NestedFlexBoxContainers(httpClient, safeAreaInsets) } } @@ -85,6 +86,7 @@ fun EmojiSearch( private fun LazyColumn( httpClient: HttpClient, navigator: Navigator, + safeAreaInsets: Margin, ) { val scope = rememberCoroutineScope() val allEmojis = remember { mutableStateListOf() } @@ -134,7 +136,7 @@ private fun LazyColumn( width = Constraint.Fill, height = Constraint.Fill, horizontalAlignment = CrossAxisAlignment.Stretch, - margin = LocalUiConfiguration.current.safeAreaInsets, + margin = safeAreaInsets, ) { TextInput( state = TextFieldState(searchTerm.text), diff --git a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/NestedFlexBoxContainers.kt b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/NestedFlexBoxContainers.kt index 7e8f09eece..4f06caa7ad 100644 --- a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/NestedFlexBoxContainers.kt +++ b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/NestedFlexBoxContainers.kt @@ -27,7 +27,6 @@ import androidx.compose.runtime.saveable.SaverScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import app.cash.redwood.Modifier -import app.cash.redwood.compose.LocalUiConfiguration import app.cash.redwood.layout.api.Constraint import app.cash.redwood.layout.api.CrossAxisAlignment import app.cash.redwood.layout.api.MainAxisAlignment @@ -42,7 +41,10 @@ import example.values.TextFieldState import kotlinx.serialization.json.Json @Composable -fun NestedFlexBoxContainers(httpClient: HttpClient) { +fun NestedFlexBoxContainers( + httpClient: HttpClient, + safeAreaInsets: Margin, +) { val allEmojis = remember { mutableStateListOf() } val searchTermSaver = object : Saver { @@ -79,7 +81,7 @@ fun NestedFlexBoxContainers(httpClient: HttpClient) { height = Constraint.Fill, overflow = Overflow.Clip, horizontalAlignment = CrossAxisAlignment.Stretch, - margin = LocalUiConfiguration.current.safeAreaInsets, + margin = safeAreaInsets, verticalAlignment = MainAxisAlignment.Start, ) { TextInput( @@ -89,7 +91,7 @@ fun NestedFlexBoxContainers(httpClient: HttpClient) { modifier = Modifier.shrink(0.0), ) - if (filteredEmojis.count() > 0) { + if (filteredEmojis.isNotEmpty()) { Text( text = "Scroll Column - Nested Scroll Row + B Emojis", modifier = Modifier.margin(Margin(12.dp)), diff --git a/settings.gradle b/settings.gradle index 685d3edda6..361ea6f54a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -113,10 +113,10 @@ if (!hasProperty('redwoodNoApps')) { include ':samples:counter:schema:widget' include ':samples:counter:shared-composeui' - include ':samples:emoji-search:android-composeui' include ':samples:emoji-search:android-tests' include ':samples:emoji-search:android-views' include ':samples:emoji-search:browser' + include ':samples:emoji-search:composeui' include ':samples:emoji-search:ios-shared' include ':samples:emoji-search:launcher' include ':samples:emoji-search:presenter' From e3757a8cad48c382271e861c561c3f721e443aaf Mon Sep 17 00:00:00 2001 From: Colin White Date: Tue, 2 Jan 2024 02:31:29 -0500 Subject: [PATCH 02/10] Fix build. --- samples/emoji-search/composeui/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/emoji-search/composeui/build.gradle b/samples/emoji-search/composeui/build.gradle index 1926395b2c..7523fce548 100644 --- a/samples/emoji-search/composeui/build.gradle +++ b/samples/emoji-search/composeui/build.gradle @@ -7,7 +7,7 @@ redwoodBuild { } android { - namespace 'com.example.redwood.emojisearch.android.composeui' + namespace 'com.example.redwood.emojisearch.composeui' defaultConfig { testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' From 00bc31a19868accb9589e29f0ca847016faa6187 Mon Sep 17 00:00:00 2001 From: Colin White Date: Tue, 2 Jan 2024 13:14:47 -0500 Subject: [PATCH 03/10] Revert. --- .../emojisearch/android/views/EmojiSearchApplication.kt | 2 +- .../redwood/emojisearch/composeui/EmojiSearchActivity.kt | 2 +- .../composeui/ComposeUiEmojiSearchWidgetFactory.kt | 2 +- .../example/redwood/emojisearch/composeui/ComposeUiImage.kt | 2 +- .../example/redwood/emojisearch/composeui/ComposeUiText.kt | 4 +++- .../redwood/emojisearch/composeui/ComposeUiTextInput.kt | 2 +- .../com/example/redwood/emojisearch/composeui/RealHostApi.kt | 2 +- .../kotlin/com/example/redwood/emojisearch/composeui/theme.kt | 2 +- .../kotlin/com/example/redwood/emojisearch/composeui/utils.kt | 2 +- .../example/redwood/emojisearch/composeui/DesktopNavigator.kt | 2 +- .../example/redwood/emojisearch/composeui/JvmHttpClient.kt | 2 +- .../kotlin/com/example/redwood/emojisearch/composeui/main.kt | 2 +- 12 files changed, 14 insertions(+), 12 deletions(-) diff --git a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt index 5a19cbb65d..6f896e44d8 100644 --- a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt +++ b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt b/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt index c45dbb34fc..d51f49d82e 100644 --- a/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt +++ b/samples/emoji-search/composeui/src/androidMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt index 5f99c03d16..2ac7b76634 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt index bc1355a3de..b35634ece3 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt index 8adb7c8a05..b994ad20b3 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.example.redwood.emojisearch.composeui import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.DefaultMonotonicFrameClock import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue @@ -30,6 +31,7 @@ internal class ComposeUiText : Text<@Composable () -> Unit> { override var modifier: Modifier = Modifier override val value = @Composable { + DefaultMonotonicFrameClock Text( text = text, color = MaterialTheme.colors.onBackground, diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt index ee01d52475..f100f09b23 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt index 4928598712..a425ef5afb 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt index 8de58672cd..b8aea95402 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt index 6363c61cd9..7181338338 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt index 83932d6329..a6dff0df45 100644 --- a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt index 51156a0d64..38c790f555 100644 --- a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt index b6c28b46e0..6735427fa9 100644 --- a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt +++ b/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 1751481ea7faf4a141605fe6bd752c49583978da Mon Sep 17 00:00:00 2001 From: Colin White Date: Tue, 2 Jan 2024 16:51:37 -0500 Subject: [PATCH 04/10] Revert. --- .../redwood/emojisearch/android/views/EmojiSearchApplication.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt index 6f896e44d8..5a19cbb65d 100644 --- a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt +++ b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. From 42bec782bedd1b220b7aac49cff05d6b3a53fe10 Mon Sep 17 00:00:00 2001 From: Colin White Date: Wed, 3 Jan 2024 13:49:43 -0500 Subject: [PATCH 05/10] WIP. --- .../composeui/EmojiSearchApplication.kt | 32 ------------------- .../redwood/emojisearch/composeui/utils.kt | 2 -- 2 files changed, 34 deletions(-) delete mode 100644 samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt deleted file mode 100644 index 73fad3907f..0000000000 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/EmojiSearchApplication.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 com.example.redwood.emojisearch.android.composeui - -import android.app.Application -import coil3.ImageLoader -import coil3.PlatformContext -import coil3.SingletonImageLoader -import coil3.fetch.NetworkFetcher - -class EmojiSearchApplication : Application(), SingletonImageLoader.Factory { - override fun newImageLoader(context: PlatformContext): ImageLoader { - return ImageLoader.Builder(context) - .components { - add(NetworkFetcher.Factory()) - } - .build() - } -} diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt index 7181338338..0a404086d6 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt +++ b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt @@ -17,10 +17,8 @@ package com.example.redwood.emojisearch.composeui import coil3.ImageLoader import coil3.SingletonImageLoader -import coil3.annotation.ExperimentalCoilApi import coil3.fetch.NetworkFetcher -@OptIn(ExperimentalCoilApi::class) fun applySingletonImageLoader() { SingletonImageLoader.setSafe { context -> ImageLoader.Builder(context) From d58ed7e5cbee8a3424e0d999366357a3117ce8f7 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Feb 2024 14:49:25 -0500 Subject: [PATCH 06/10] Re-split frontends into Android and Desktop with a shared module --- .../android-composeui/build.gradle | 2 +- .../android/composeui/EmojiSearchUiTest.kt | 0 .../src/main}/AndroidManifest.xml | 1 - .../android}/composeui/EmojiSearchActivity.kt | 18 +++- .../android}/composeui/RealHostApi.kt | 4 +- .../drawable-v24/ic_launcher_foreground.xml | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../main}/res/mipmap-hdpi/ic_launcher.webp | Bin .../main}/res/mipmap-mdpi/ic_launcher.webp | Bin .../main}/res/mipmap-xhdpi/ic_launcher.webp | Bin .../main}/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../main}/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../src/main}/res/values/colors.xml | 0 .../src/main}/res/values/strings.xml | 0 .../src/main}/res/values/themes.xml | 0 samples/emoji-search/composeui/build.gradle | 79 ------------------ .../redwood/emojisearch/composeui/utils.kt | 30 ------- .../desktop-composeui/build.gradle | 30 +++++++ .../emojisearch/desktop}/DesktopNavigator.kt | 6 +- .../emojisearch/desktop}/JvmHttpClient.kt | 0 .../redwood/emojisearch/desktop}/main.kt | 20 ++++- .../shared-composeui/build.gradle | 11 +++ .../ComposeUiEmojiSearchWidgetFactory.kt | 2 +- .../emojisearch/composeui/ComposeUiImage.kt | 4 +- .../emojisearch/composeui/ComposeUiText.kt | 4 +- .../composeui/ComposeUiTextInput.kt | 2 +- .../redwood/emojisearch/composeui/theme.kt | 2 +- settings.gradle | 4 +- 29 files changed, 87 insertions(+), 132 deletions(-) rename samples/emoji-search/{composeui/src/androidInstrumentedTest => android-composeui/src/androidTest}/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/AndroidManifest.xml (95%) rename samples/emoji-search/{composeui/src/androidMain/kotlin/com/example/redwood/emojisearch => android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android}/composeui/EmojiSearchActivity.kt (92%) rename samples/emoji-search/{composeui/src/commonMain/kotlin/com/example/redwood/emojisearch => android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android}/composeui/RealHostApi.kt (95%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/drawable-v24/ic_launcher_foreground.xml (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/drawable/ic_launcher_background.xml (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-hdpi/ic_launcher.webp (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-mdpi/ic_launcher.webp (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-xhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/values/colors.xml (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/values/strings.xml (100%) rename samples/emoji-search/{composeui/src/androidMain => android-composeui/src/main}/res/values/themes.xml (100%) delete mode 100644 samples/emoji-search/composeui/build.gradle delete mode 100644 samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt create mode 100644 samples/emoji-search/desktop-composeui/build.gradle rename samples/emoji-search/{composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui => desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop}/DesktopNavigator.kt (86%) rename samples/emoji-search/{composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui => desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop}/JvmHttpClient.kt (100%) rename samples/emoji-search/{composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui => desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop}/main.kt (77%) create mode 100644 samples/emoji-search/shared-composeui/build.gradle rename samples/emoji-search/{composeui/src/commonMain => shared-composeui/src/main}/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt (97%) rename samples/emoji-search/{composeui/src/commonMain => shared-composeui/src/main}/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt (97%) rename samples/emoji-search/{composeui/src/commonMain => shared-composeui/src/main}/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt (91%) rename samples/emoji-search/{composeui/src/commonMain => shared-composeui/src/main}/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt (98%) rename samples/emoji-search/{composeui/src/commonMain => shared-composeui/src/main}/kotlin/com/example/redwood/emojisearch/composeui/theme.kt (98%) diff --git a/samples/emoji-search/android-composeui/build.gradle b/samples/emoji-search/android-composeui/build.gradle index a42a66c8a0..25769cf39f 100644 --- a/samples/emoji-search/android-composeui/build.gradle +++ b/samples/emoji-search/android-composeui/build.gradle @@ -28,12 +28,12 @@ dependencies { implementation projects.samples.emojiSearch.launcher implementation projects.samples.emojiSearch.presenterTreehouse implementation projects.samples.emojiSearch.schema.widget.protocol + implementation projects.samples.emojiSearch.sharedComposeui implementation libs.androidx.activity.compose implementation libs.androidx.appCompat implementation libs.androidx.core implementation libs.jetbrains.compose.material implementation libs.jetbrains.compose.ui - implementation libs.jetbrains.compose.ui.tooling.preview debugImplementation libs.jetbrains.compose.ui.tooling implementation projects.redwoodLayoutComposeui implementation projects.redwoodLazylayoutComposeui diff --git a/samples/emoji-search/composeui/src/androidInstrumentedTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt b/samples/emoji-search/android-composeui/src/androidTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt similarity index 100% rename from samples/emoji-search/composeui/src/androidInstrumentedTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt rename to samples/emoji-search/android-composeui/src/androidTest/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchUiTest.kt diff --git a/samples/emoji-search/composeui/src/androidMain/AndroidManifest.xml b/samples/emoji-search/android-composeui/src/main/AndroidManifest.xml similarity index 95% rename from samples/emoji-search/composeui/src/androidMain/AndroidManifest.xml rename to samples/emoji-search/android-composeui/src/main/AndroidManifest.xml index 2f7f8fd4ed..46143f4f27 100644 --- a/samples/emoji-search/composeui/src/androidMain/AndroidManifest.xml +++ b/samples/emoji-search/android-composeui/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ + ImageLoader.Builder(context) + .components { + add(NetworkFetcher.Factory()) + } + .build() + } val treehouseApp = createTreehouseApp() val treehouseContentSource = TreehouseContentSource(EmojiSearchPresenter::launch) diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt similarity index 95% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt rename to samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt index a425ef5afb..56b68115af 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/RealHostApi.kt +++ b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.composeui +package com.example.redwood.emojisearch.android.composeui import com.example.redwood.emojisearch.treehouse.HostApi import kotlin.coroutines.resume diff --git a/samples/emoji-search/composeui/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/samples/emoji-search/android-composeui/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml rename to samples/emoji-search/android-composeui/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/samples/emoji-search/composeui/src/androidMain/res/drawable/ic_launcher_background.xml b/samples/emoji-search/android-composeui/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/drawable/ic_launcher_background.xml rename to samples/emoji-search/android-composeui/src/main/res/drawable/ic_launcher_background.xml diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/emoji-search/android-composeui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml rename to samples/emoji-search/android-composeui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-hdpi/ic_launcher.webp b/samples/emoji-search/android-composeui/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-hdpi/ic_launcher.webp rename to samples/emoji-search/android-composeui/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-mdpi/ic_launcher.webp b/samples/emoji-search/android-composeui/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-mdpi/ic_launcher.webp rename to samples/emoji-search/android-composeui/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp b/samples/emoji-search/android-composeui/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp rename to samples/emoji-search/android-composeui/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp b/samples/emoji-search/android-composeui/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp rename to samples/emoji-search/android-composeui/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/samples/emoji-search/composeui/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp b/samples/emoji-search/android-composeui/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp rename to samples/emoji-search/android-composeui/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/samples/emoji-search/composeui/src/androidMain/res/values/colors.xml b/samples/emoji-search/android-composeui/src/main/res/values/colors.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/values/colors.xml rename to samples/emoji-search/android-composeui/src/main/res/values/colors.xml diff --git a/samples/emoji-search/composeui/src/androidMain/res/values/strings.xml b/samples/emoji-search/android-composeui/src/main/res/values/strings.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/values/strings.xml rename to samples/emoji-search/android-composeui/src/main/res/values/strings.xml diff --git a/samples/emoji-search/composeui/src/androidMain/res/values/themes.xml b/samples/emoji-search/android-composeui/src/main/res/values/themes.xml similarity index 100% rename from samples/emoji-search/composeui/src/androidMain/res/values/themes.xml rename to samples/emoji-search/android-composeui/src/main/res/values/themes.xml diff --git a/samples/emoji-search/composeui/build.gradle b/samples/emoji-search/composeui/build.gradle deleted file mode 100644 index 7523fce548..0000000000 --- a/samples/emoji-search/composeui/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.multiplatform' -apply plugin: 'org.jetbrains.compose' - -redwoodBuild { - embedZiplineApplication(projects.samples.emojiSearch.presenterTreehouse) -} - -android { - namespace 'com.example.redwood.emojisearch.composeui' - - defaultConfig { - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - } - - buildFeatures { - // Needed to pass application ID to UIAutomator tests. - buildConfig = true - } -} - -compose { - desktop { - application { - mainClass = "com.example.redwood.emojisearch.composeui.Main" - } - } -} - -kotlin { - androidTarget() - jvm("desktop") - - sourceSets { - commonMain { - dependencies { - implementation projects.samples.emojiSearch.launcher - implementation projects.samples.emojiSearch.presenterTreehouse - implementation projects.samples.emojiSearch.schema.widget.protocol - implementation projects.redwoodLayoutComposeui - implementation projects.redwoodLazylayoutComposeui - implementation projects.redwoodTreehouseHost - implementation projects.redwoodTreehouseHostComposeui - implementation projects.redwoodWidgetCompose - implementation libs.coil.compose - implementation libs.coil.network - implementation libs.ktor.engine.okhttp - implementation libs.jetbrains.compose.material - implementation libs.jetbrains.compose.ui - implementation libs.jetbrains.compose.ui.tooling.preview - implementation libs.zipline.loader - } - } - androidMain { - dependencies { - implementation libs.androidx.activity.compose - implementation libs.androidx.appCompat - implementation libs.androidx.core - implementation libs.google.material - implementation libs.kotlinx.coroutines.android - implementation libs.okio.assetfilesystem - } - } - desktopMain { - dependencies { - implementation projects.samples.emojiSearch.presenter - implementation projects.redwoodComposeui - implementation compose.desktop.currentOs - implementation libs.kotlinx.coroutines.swing - } - } - androidInstrumentedTest { - dependencies { - implementation libs.androidx.test.runner - implementation projects.samples.emojiSearch.androidTests - } - } - } -} diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt b/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt deleted file mode 100644 index 0a404086d6..0000000000 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/utils.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2022 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 com.example.redwood.emojisearch.composeui - -import coil3.ImageLoader -import coil3.SingletonImageLoader -import coil3.fetch.NetworkFetcher - -fun applySingletonImageLoader() { - SingletonImageLoader.setSafe { context -> - ImageLoader.Builder(context) - .components { - add(NetworkFetcher.Factory()) - } - .build() - } -} diff --git a/samples/emoji-search/desktop-composeui/build.gradle b/samples/emoji-search/desktop-composeui/build.gradle new file mode 100644 index 0000000000..24fdf48ec4 --- /dev/null +++ b/samples/emoji-search/desktop-composeui/build.gradle @@ -0,0 +1,30 @@ +apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'org.jetbrains.compose' + +compose { + desktop { + application { + mainClass = "com.example.redwood.emojisearch.desktop.Main" + } + } +} + +dependencies { + implementation compose.desktop.currentOs + implementation projects.samples.emojiSearch.launcher + implementation projects.samples.emojiSearch.presenter + implementation projects.samples.emojiSearch.presenterTreehouse + implementation projects.samples.emojiSearch.schema.widget.protocol + implementation projects.samples.emojiSearch.sharedComposeui + implementation projects.redwoodComposeui + implementation projects.redwoodLayoutComposeui + implementation projects.redwoodLazylayoutComposeui + implementation projects.redwoodTreehouseHost + implementation projects.redwoodTreehouseHostComposeui + implementation projects.redwoodWidgetCompose + implementation libs.coil.compose + implementation libs.coil.network + implementation libs.ktor.engine.okhttp + implementation libs.zipline.loader + implementation libs.kotlinx.coroutines.swing +} diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/DesktopNavigator.kt similarity index 86% rename from samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt rename to samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/DesktopNavigator.kt index a6dff0df45..cded0474f5 100644 --- a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/DesktopNavigator.kt +++ b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/DesktopNavigator.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.example.redwood.emojisearch.composeui +package com.example.redwood.emojisearch.desktop import com.example.redwood.emojisearch.presenter.Navigator import java.awt.Desktop import java.net.URI -class DesktopNavigator : Navigator { +object DesktopNavigator : Navigator { override fun openUrl(url: String) { Desktop.getDesktop().browse(URI(url)) } diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/JvmHttpClient.kt similarity index 100% rename from samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/JvmHttpClient.kt rename to samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/JvmHttpClient.kt diff --git a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt similarity index 77% rename from samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt rename to samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt index 6735427fa9..66d6ab52f0 100644 --- a/samples/emoji-search/composeui/src/desktopMain/kotlin/com/example/redwood/emojisearch/composeui/main.kt +++ b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -15,7 +15,7 @@ */ @file:JvmName("Main") -package com.example.redwood.emojisearch.composeui +package com.example.redwood.emojisearch.desktop import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding @@ -27,14 +27,26 @@ import app.cash.redwood.composeui.RedwoodContent import app.cash.redwood.layout.composeui.ComposeUiRedwoodLayoutWidgetFactory import app.cash.redwood.lazylayout.composeui.ComposeUiRedwoodLazyLayoutWidgetFactory import app.cash.redwood.ui.Margin +import coil3.ImageLoader +import coil3.SingletonImageLoader +import coil3.fetch.NetworkFetcher +import com.example.redwood.emojisearch.composeui.ComposeUiEmojiSearchWidgetFactory +import com.example.redwood.emojisearch.composeui.EmojiSearchTheme +import com.example.redwood.emojisearch.composeui.JvmHttpClient import com.example.redwood.emojisearch.presenter.EmojiSearch import com.example.redwood.emojisearch.widget.EmojiSearchWidgetFactories fun main() { - applySingletonImageLoader() + SingletonImageLoader.setSafe { context -> + ImageLoader.Builder(context) + .components { + add(NetworkFetcher.Factory()) + } + .build() + } val httpClient = JvmHttpClient() - val navigator = DesktopNavigator() + val navigator = DesktopNavigator val factories = EmojiSearchWidgetFactories( EmojiSearch = ComposeUiEmojiSearchWidgetFactory(), RedwoodLayout = ComposeUiRedwoodLayoutWidgetFactory(), diff --git a/samples/emoji-search/shared-composeui/build.gradle b/samples/emoji-search/shared-composeui/build.gradle new file mode 100644 index 0000000000..5f205f28d5 --- /dev/null +++ b/samples/emoji-search/shared-composeui/build.gradle @@ -0,0 +1,11 @@ +apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'app.cash.redwood' + +dependencies { + api projects.samples.emojiSearch.schema.widget + implementation projects.redwoodWidgetCompose + implementation libs.jetbrains.compose.material + implementation libs.jetbrains.compose.ui + implementation libs.jetbrains.compose.ui.tooling.preview + implementation libs.coil.compose +} diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt similarity index 97% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt rename to samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt index 2ac7b76634..5f99c03d16 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt similarity index 97% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt rename to samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt index b35634ece3..29800923da 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -15,6 +15,7 @@ */ package com.example.redwood.emojisearch.composeui +import app.cash.redwood.Modifier as RedwoodModifier import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable @@ -23,7 +24,6 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import app.cash.redwood.Modifier as RedwoodModifier import coil3.compose.AsyncImage import com.example.redwood.emojisearch.widget.Image diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt similarity index 91% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt rename to samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt index b994ad20b3..8adb7c8a05 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. @@ -18,7 +18,6 @@ package com.example.redwood.emojisearch.composeui import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.DefaultMonotonicFrameClock import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue @@ -31,7 +30,6 @@ internal class ComposeUiText : Text<@Composable () -> Unit> { override var modifier: Modifier = Modifier override val value = @Composable { - DefaultMonotonicFrameClock Text( text = text, color = MaterialTheme.colors.onBackground, diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt similarity index 98% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt rename to samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt index f100f09b23..ee01d52475 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. diff --git a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt similarity index 98% rename from samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt rename to samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt index b8aea95402..8de58672cd 100644 --- a/samples/emoji-search/composeui/src/commonMain/kotlin/com/example/redwood/emojisearch/composeui/theme.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Square, Inc. + * 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. diff --git a/settings.gradle b/settings.gradle index 361ea6f54a..d210b33c2b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -113,10 +113,11 @@ if (!hasProperty('redwoodNoApps')) { include ':samples:counter:schema:widget' include ':samples:counter:shared-composeui' + include ':samples:emoji-search:android-composeui' include ':samples:emoji-search:android-tests' include ':samples:emoji-search:android-views' include ':samples:emoji-search:browser' - include ':samples:emoji-search:composeui' + include ':samples:emoji-search:desktop-composeui' include ':samples:emoji-search:ios-shared' include ':samples:emoji-search:launcher' include ':samples:emoji-search:presenter' @@ -127,5 +128,6 @@ if (!hasProperty('redwoodNoApps')) { include ':samples:emoji-search:schema:testing' include ':samples:emoji-search:schema:widget' include ':samples:emoji-search:schema:widget:protocol' + include ':samples:emoji-search:shared-composeui' include ':samples:emoji-search:values' } From b7ba297f091261d635dbbcda769f38ed633ca15f Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Feb 2024 15:59:40 -0500 Subject: [PATCH 07/10] Spotless --- .../com/example/redwood/emojisearch/composeui/ComposeUiImage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt index 29800923da..bc1355a3de 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt @@ -15,7 +15,6 @@ */ package com.example.redwood.emojisearch.composeui -import app.cash.redwood.Modifier as RedwoodModifier import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable @@ -24,6 +23,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import app.cash.redwood.Modifier as RedwoodModifier import coil3.compose.AsyncImage import com.example.redwood.emojisearch.widget.Image From f0be46e7fa39e012482e9ad418dd1a0bc7083184 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Feb 2024 16:45:47 -0500 Subject: [PATCH 08/10] Fix version catalog references after merge --- samples/emoji-search/desktop-composeui/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/emoji-search/desktop-composeui/build.gradle b/samples/emoji-search/desktop-composeui/build.gradle index 24fdf48ec4..d6668cb547 100644 --- a/samples/emoji-search/desktop-composeui/build.gradle +++ b/samples/emoji-search/desktop-composeui/build.gradle @@ -23,8 +23,7 @@ dependencies { implementation projects.redwoodTreehouseHostComposeui implementation projects.redwoodWidgetCompose implementation libs.coil.compose - implementation libs.coil.network - implementation libs.ktor.engine.okhttp + implementation libs.coil.network.okhttp implementation libs.zipline.loader implementation libs.kotlinx.coroutines.swing } From ee57cb416e63b48cc9422a192e802e6f96f0afa0 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Feb 2024 16:51:27 -0500 Subject: [PATCH 09/10] Implicit Coil init --- samples/emoji-search/android-composeui/build.gradle | 1 - .../android/composeui/EmojiSearchActivity.kt | 11 ----------- samples/emoji-search/desktop-composeui/build.gradle | 1 - .../com/example/redwood/emojisearch/desktop/main.kt | 11 ----------- 4 files changed, 24 deletions(-) diff --git a/samples/emoji-search/android-composeui/build.gradle b/samples/emoji-search/android-composeui/build.gradle index 5321c2ed56..0768e0abbf 100644 --- a/samples/emoji-search/android-composeui/build.gradle +++ b/samples/emoji-search/android-composeui/build.gradle @@ -20,7 +20,6 @@ android { } dependencies { - implementation libs.coil.compose implementation libs.coil.network.okhttp implementation libs.google.material implementation libs.kotlinx.coroutines.android diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt index ea698d372c..845526f385 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt +++ b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/EmojiSearchActivity.kt @@ -44,9 +44,6 @@ import app.cash.zipline.ZiplineManifest import app.cash.zipline.loader.ManifestVerifier import app.cash.zipline.loader.asZiplineHttpClient import app.cash.zipline.loader.withDevelopmentServerPush -import coil3.ImageLoader -import coil3.SingletonImageLoader -import coil3.fetch.NetworkFetcher import com.example.redwood.emojisearch.composeui.ComposeUiEmojiSearchWidgetFactory import com.example.redwood.emojisearch.composeui.EmojiSearchTheme import com.example.redwood.emojisearch.launcher.EmojiSearchAppSpec @@ -71,14 +68,6 @@ class EmojiSearchActivity : ComponentActivity() { super.onCreate(savedInstanceState) WindowCompat.setDecorFitsSystemWindows(window, false) - SingletonImageLoader.setSafe { context -> - ImageLoader.Builder(context) - .components { - add(NetworkFetcher.Factory()) - } - .build() - } - val treehouseApp = createTreehouseApp() val treehouseContentSource = TreehouseContentSource(EmojiSearchPresenter::launch) diff --git a/samples/emoji-search/desktop-composeui/build.gradle b/samples/emoji-search/desktop-composeui/build.gradle index d6668cb547..849f87e767 100644 --- a/samples/emoji-search/desktop-composeui/build.gradle +++ b/samples/emoji-search/desktop-composeui/build.gradle @@ -22,7 +22,6 @@ dependencies { implementation projects.redwoodTreehouseHost implementation projects.redwoodTreehouseHostComposeui implementation projects.redwoodWidgetCompose - implementation libs.coil.compose implementation libs.coil.network.okhttp implementation libs.zipline.loader implementation libs.kotlinx.coroutines.swing diff --git a/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt index 66d6ab52f0..e685d05cb8 100644 --- a/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt +++ b/samples/emoji-search/desktop-composeui/src/main/kotlin/com/example/redwood/emojisearch/desktop/main.kt @@ -27,9 +27,6 @@ import app.cash.redwood.composeui.RedwoodContent import app.cash.redwood.layout.composeui.ComposeUiRedwoodLayoutWidgetFactory import app.cash.redwood.lazylayout.composeui.ComposeUiRedwoodLazyLayoutWidgetFactory import app.cash.redwood.ui.Margin -import coil3.ImageLoader -import coil3.SingletonImageLoader -import coil3.fetch.NetworkFetcher import com.example.redwood.emojisearch.composeui.ComposeUiEmojiSearchWidgetFactory import com.example.redwood.emojisearch.composeui.EmojiSearchTheme import com.example.redwood.emojisearch.composeui.JvmHttpClient @@ -37,14 +34,6 @@ import com.example.redwood.emojisearch.presenter.EmojiSearch import com.example.redwood.emojisearch.widget.EmojiSearchWidgetFactories fun main() { - SingletonImageLoader.setSafe { context -> - ImageLoader.Builder(context) - .components { - add(NetworkFetcher.Factory()) - } - .build() - } - val httpClient = JvmHttpClient() val navigator = DesktopNavigator val factories = EmojiSearchWidgetFactories( From ead2d216c692b08f169890113af7bdf153173903 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Feb 2024 16:53:39 -0500 Subject: [PATCH 10/10] Revert date changes --- .../redwood/emojisearch/android/composeui/RealHostApi.kt | 2 +- .../emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt | 2 +- .../com/example/redwood/emojisearch/composeui/ComposeUiImage.kt | 2 +- .../com/example/redwood/emojisearch/composeui/ComposeUiText.kt | 2 +- .../example/redwood/emojisearch/composeui/ComposeUiTextInput.kt | 2 +- .../kotlin/com/example/redwood/emojisearch/composeui/theme.kt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt index 56b68115af..8939af8b4d 100644 --- a/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt +++ b/samples/emoji-search/android-composeui/src/main/kotlin/com/example/redwood/emojisearch/android/composeui/RealHostApi.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt index 5f99c03d16..2ac7b76634 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiEmojiSearchWidgetFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt index bc1355a3de..b35634ece3 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiImage.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt index 8adb7c8a05..6f87870dc6 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiText.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt index ee01d52475..f100f09b23 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/ComposeUiTextInput.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt index 8de58672cd..b8aea95402 100644 --- a/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt +++ b/samples/emoji-search/shared-composeui/src/main/kotlin/com/example/redwood/emojisearch/composeui/theme.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Square, Inc. + * Copyright (C) 2022 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.