Browse Source

Update imageviewer to not use `internal` visibility for composable functions

image_viewer_remove_internal
Oleksandr Karpovich 2 years ago
parent
commit
ddf1919a01
  1. 1
      experimental/examples/imageviewer/.gitignore
  2. 2
      experimental/examples/imageviewer/iosApp/Podfile
  3. 22
      experimental/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj
  4. 2
      experimental/examples/imageviewer/iosApp/iosApp/iosApp.swift
  5. 39
      experimental/examples/imageviewer/iosAppKt/build.gradle.kts
  6. 0
      experimental/examples/imageviewer/iosAppKt/src/iosMain/kotlin/example.imageviewer/main.ios.kt
  7. 1
      experimental/examples/imageviewer/settings.gradle.kts
  8. 13
      experimental/examples/imageviewer/shared/build.gradle.kts
  9. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt
  10. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt
  11. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImage.kt
  12. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LoadingScreen.kt
  13. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MainScreen.kt
  14. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Miniature.kt
  15. 4
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt
  16. 4
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt
  17. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt
  18. 2
      experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt
  19. 2
      experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/PreviewImage.desktop.kt
  20. 2
      experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt
  21. 2
      experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt
  22. 2
      experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt
  23. 2
      experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/PreviewImage.ios.kt
  24. 2
      experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt
  25. 2
      experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt

1
experimental/examples/imageviewer/.gitignore vendored

@ -19,3 +19,4 @@ iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/* iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj !iosApp/iosApp.xcodeproj/project.pbxproj
shared/shared.podspec shared/shared.podspec
iosAppKt/iosAppKt.podspec

2
experimental/examples/imageviewer/iosApp/Podfile

@ -1,5 +1,5 @@
target 'iosApp' do target 'iosApp' do
use_frameworks! use_frameworks!
platform :ios, '14.1' platform :ios, '14.1'
pod 'shared', :path => '../shared' pod 'iosAppKt', :path => '../iosAppKt'
end end

22
experimental/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj

@ -97,7 +97,6 @@
7555FF77242A565900829871 /* Sources */, 7555FF77242A565900829871 /* Sources */,
7555FF79242A565900829871 /* Resources */, 7555FF79242A565900829871 /* Resources */,
9964867F0862B4D9FB6ABFC7 /* Frameworks */, 9964867F0862B4D9FB6ABFC7 /* Frameworks */,
F34398AEB6C0D136D245A061 /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@ -174,23 +173,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
F34398AEB6C0D136D245A061 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
@ -340,7 +322,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}"; PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}";
PRODUCT_NAME = "Imageviewer"; PRODUCT_NAME = Imageviewer;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -364,7 +346,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}"; PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}";
PRODUCT_NAME = "Imageviewer"; PRODUCT_NAME = Imageviewer;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";

2
experimental/examples/imageviewer/iosApp/iosApp/iosApp.swift

@ -1,5 +1,5 @@
import UIKit import UIKit
import shared import iosAppKt
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { class AppDelegate: UIResponder, UIApplicationDelegate {

39
experimental/examples/imageviewer/iosAppKt/build.gradle.kts

@ -0,0 +1,39 @@
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("org.jetbrains.compose")
}
version = "1.0-SNAPSHOT"
val ktorVersion = extra["ktor.version"]
kotlin {
ios()
iosSimulatorArm64()
cocoapods {
summary = "Shared code for the sample"
homepage = "https://github.com/JetBrains/compose-jb"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "iosAppKt"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation("org.jetbrains.compose.components:components-resources:1.3.0-beta04-dev879")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation(project(":shared"))
}
}
}
}

0
experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/main.ios.kt → experimental/examples/imageviewer/iosAppKt/src/iosMain/kotlin/example.imageviewer/main.ios.kt

1
experimental/examples/imageviewer/settings.gradle.kts

@ -26,3 +26,4 @@ rootProject.name = "imageviewer"
include(":androidApp") include(":androidApp")
include(":shared") include(":shared")
include(":desktopApp") include(":desktopApp")
include(":iosAppKt")

13
experimental/examples/imageviewer/shared/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library") id("com.android.library")
id("org.jetbrains.compose") id("org.jetbrains.compose")
kotlin("plugin.serialization") kotlin("plugin.serialization")
@ -15,18 +14,6 @@ kotlin {
ios() ios()
iosSimulatorArm64() iosSimulatorArm64()
cocoapods {
summary = "Shared code for the sample"
homepage = "https://github.com/JetBrains/compose-jb"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}
sourceSets { sourceSets {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt

@ -10,7 +10,7 @@ import example.imageviewer.view.FullscreenImage
import example.imageviewer.view.MainScreen import example.imageviewer.view.MainScreen
@Composable @Composable
internal fun ImageViewerCommon(state: MutableState<State>, dependencies: Dependencies) { fun ImageViewerCommon(state: MutableState<State>, dependencies: Dependencies) {
state.refresh(dependencies) state.refresh(dependencies)
Surface(modifier = Modifier.fillMaxSize()) { Surface(modifier = Modifier.fillMaxSize()) {

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt

@ -22,7 +22,7 @@ object ImageviewerColors {
} }
@Composable @Composable
internal fun ImageViewerTheme(content: @Composable () -> Unit) { fun ImageViewerTheme(content: @Composable () -> Unit) {
isSystemInDarkTheme() // todo check and change colors isSystemInDarkTheme() // todo check and change colors
MaterialTheme( MaterialTheme(
colors = MaterialTheme.colors.copy( colors = MaterialTheme.colors.copy(

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImage.kt

@ -32,7 +32,7 @@ import org.jetbrains.compose.resources.rememberImageBitmap
import org.jetbrains.compose.resources.resource import org.jetbrains.compose.resources.resource
@Composable @Composable
internal fun FullscreenImage( fun FullscreenImage(
picture: Picture?, picture: Picture?,
getImage: suspend (Picture) -> ImageBitmap, getImage: suspend (Picture) -> ImageBitmap,
getFilter: (FilterType) -> BitmapFilter, getFilter: (FilterType) -> BitmapFilter,

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LoadingScreen.kt

@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@Composable @Composable
internal fun LoadingScreen(text: String = "") { fun LoadingScreen(text: String = "") {
Box( Box(
modifier = Modifier.fillMaxSize().background(color = MaterialTheme.colors.background) modifier = Modifier.fillMaxSize().background(color = MaterialTheme.colors.background)
) { ) {

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MainScreen.kt

@ -18,7 +18,7 @@ import org.jetbrains.compose.resources.rememberImageBitmap
import org.jetbrains.compose.resources.resource import org.jetbrains.compose.resources.resource
@Composable @Composable
internal fun MainScreen(state: MutableState<State>, dependencies: Dependencies) { fun MainScreen(state: MutableState<State>, dependencies: Dependencies) {
Column { Column {
TopContent(state, dependencies) TopContent(state, dependencies)
ScrollableColumn( ScrollableColumn(

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Miniature.kt

@ -20,7 +20,7 @@ import org.jetbrains.compose.resources.resource
@OptIn(ExperimentalResourceApi::class) @OptIn(ExperimentalResourceApi::class)
@Composable @Composable
internal fun Miniature( fun Miniature(
picture: Picture, picture: Picture,
image: ImageBitmap?, image: ImageBitmap?,
onClickSelect: () -> Unit, onClickSelect: () -> Unit,

4
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt

@ -20,7 +20,7 @@ import org.jetbrains.compose.resources.resource
@OptIn(ExperimentalResourceApi::class) @OptIn(ExperimentalResourceApi::class)
@Composable @Composable
internal fun PreviewImage(state: MutableState<State>, getImage: suspend (Picture) -> ImageBitmap) { fun PreviewImage(state: MutableState<State>, getImage: suspend (Picture) -> ImageBitmap) {
val pictures = state.value.pictures val pictures = state.value.pictures
val index = state.value.currentImageIndex val index = state.value.currentImageIndex
val imageState = remember(pictures, index) { mutableStateOf<ImageBitmap?>(null) } val imageState = remember(pictures, index) { mutableStateOf<ImageBitmap?>(null) }
@ -50,4 +50,4 @@ internal fun PreviewImage(state: MutableState<State>, getImage: suspend (Picture
} }
@Composable @Composable
internal expect fun needShowPreview(): Boolean expect fun needShowPreview(): Boolean

4
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt

@ -7,10 +7,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@Composable @Composable
internal expect fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) expect fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit)
@Composable @Composable
internal fun TouchScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) { fun TouchScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Column(modifier.verticalScroll(scrollState)) { Column(modifier.verticalScroll(scrollState)) {
content() content()

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt

@ -23,7 +23,7 @@ sealed interface ToastState {
} }
@Composable @Composable
internal fun Toast( fun Toast(
state: MutableState<ToastState> state: MutableState<ToastState>
) { ) {
val value = state.value val value = state.value

2
experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt

@ -3,7 +3,7 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@Composable @Composable
internal expect fun Tooltip( expect fun Tooltip(
text: String, text: String,
content: @Composable () -> Unit content: @Composable () -> Unit
) )

2
experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/PreviewImage.desktop.kt

@ -3,4 +3,4 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@Composable @Composable
internal actual fun needShowPreview(): Boolean = true actual fun needShowPreview(): Boolean = true

2
experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt

@ -11,7 +11,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@Composable @Composable
internal actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) { actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Modifier.verticalScroll(scrollState) Modifier.verticalScroll(scrollState)

2
experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt

@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
@Composable @Composable
internal actual fun Tooltip( actual fun Tooltip(
text: String, text: String,
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {

2
experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt

@ -23,7 +23,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@Composable @Composable
internal fun ImageViewerIos() { fun ImageViewerIos() {
val toastState = remember { mutableStateOf<ToastState>(ToastState.Hidden) } val toastState = remember { mutableStateOf<ToastState>(ToastState.Hidden) }
val state = remember { mutableStateOf(State()) } val state = remember { mutableStateOf(State()) }
val ioScope: CoroutineScope = rememberCoroutineScope { Dispatchers.Default } val ioScope: CoroutineScope = rememberCoroutineScope { Dispatchers.Default }

2
experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/PreviewImage.ios.kt

@ -3,4 +3,4 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@Composable @Composable
internal actual fun needShowPreview(): Boolean = true actual fun needShowPreview(): Boolean = true

2
experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt

@ -4,5 +4,5 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@Composable @Composable
internal actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) = actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) =
TouchScrollableColumn(modifier, content) TouchScrollableColumn(modifier, content)

2
experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt

@ -3,7 +3,7 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@Composable @Composable
internal actual fun Tooltip( actual fun Tooltip(
text: String, text: String,
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {

Loading…
Cancel
Save