Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update imageviewer to not use internal visibility for composable functions #2705

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions experimental/examples/imageviewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj
shared/shared.podspec
iosAppKt/iosAppKt.podspec
4 changes: 2 additions & 2 deletions experimental/examples/imageviewer/iosApp/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target 'iosApp' do
use_frameworks!
platform :ios, '14.1'
pod 'shared', :path => '../shared'
end
pod 'iosAppKt', :path => '../iosAppKt'
end
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
7555FF77242A565900829871 /* Sources */,
7555FF79242A565900829871 /* Resources */,
9964867F0862B4D9FB6ABFC7 /* Frameworks */,
F34398AEB6C0D136D245A061 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -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";
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 */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -340,7 +322,7 @@
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}";
PRODUCT_NAME = "Imageviewer";
PRODUCT_NAME = Imageviewer;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -364,7 +346,7 @@
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.Imageviewer${TEAM_ID}";
PRODUCT_NAME = "Imageviewer";
PRODUCT_NAME = Imageviewer;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import shared
import iosAppKt

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
39 changes: 39 additions & 0 deletions experimental/examples/imageviewer/iosAppKt/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"))
}
}
}
}
1 change: 1 addition & 0 deletions experimental/examples/imageviewer/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ rootProject.name = "imageviewer"
include(":androidApp")
include(":shared")
include(":desktopApp")
include(":iosAppKt")
13 changes: 0 additions & 13 deletions experimental/examples/imageviewer/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("org.jetbrains.compose")
kotlin("plugin.serialization")
Expand All @@ -15,18 +14,6 @@ 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 = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
val commonMain by getting {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import example.imageviewer.view.FullscreenImage
import example.imageviewer.view.MainScreen

@Composable
internal fun ImageViewerCommon(state: MutableState<State>, dependencies: Dependencies) {
fun ImageViewerCommon(state: MutableState<State>, dependencies: Dependencies) {
state.refresh(dependencies)

Surface(modifier = Modifier.fillMaxSize()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object ImageviewerColors {
}

@Composable
internal fun ImageViewerTheme(content: @Composable () -> Unit) {
fun ImageViewerTheme(content: @Composable () -> Unit) {
isSystemInDarkTheme() // todo check and change colors
MaterialTheme(
colors = MaterialTheme.colors.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.jetbrains.compose.resources.rememberImageBitmap
import org.jetbrains.compose.resources.resource

@Composable
internal fun FullscreenImage(
fun FullscreenImage(
picture: Picture?,
getImage: suspend (Picture) -> ImageBitmap,
getFilter: (FilterType) -> BitmapFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
internal fun LoadingScreen(text: String = "") {
fun LoadingScreen(text: String = "") {
Box(
modifier = Modifier.fillMaxSize().background(color = MaterialTheme.colors.background)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.jetbrains.compose.resources.rememberImageBitmap
import org.jetbrains.compose.resources.resource

@Composable
internal fun MainScreen(state: MutableState<State>, dependencies: Dependencies) {
fun MainScreen(state: MutableState<State>, dependencies: Dependencies) {
Column {
TopContent(state, dependencies)
ScrollableColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.jetbrains.compose.resources.resource

@OptIn(ExperimentalResourceApi::class)
@Composable
internal fun Miniature(
fun Miniature(
picture: Picture,
image: ImageBitmap?,
onClickSelect: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.jetbrains.compose.resources.resource

@OptIn(ExperimentalResourceApi::class)
@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 index = state.value.currentImageIndex
val imageState = remember(pictures, index) { mutableStateOf<ImageBitmap?>(null) }
Expand Down Expand Up @@ -50,4 +50,4 @@ internal fun PreviewImage(state: MutableState<State>, getImage: suspend (Picture
}

@Composable
internal expect fun needShowPreview(): Boolean
expect fun needShowPreview(): Boolean
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
internal expect fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit)
expect fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit)

@Composable
internal fun TouchScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
fun TouchScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
val scrollState = rememberScrollState()
Column(modifier.verticalScroll(scrollState)) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sealed interface ToastState {
}

@Composable
internal fun Toast(
fun Toast(
state: MutableState<ToastState>
) {
val value = state.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable

@Composable
internal expect fun Tooltip(
expect fun Tooltip(
text: String,
content: @Composable () -> Unit
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable

@Composable
internal actual fun needShowPreview(): Boolean = true
actual fun needShowPreview(): Boolean = true
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
internal actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) {
val scrollState = rememberScrollState()
Modifier.verticalScroll(scrollState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp

@OptIn(ExperimentalFoundationApi::class)
@Composable
internal actual fun Tooltip(
actual fun Tooltip(
text: String,
content: @Composable () -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

@Composable
internal fun ImageViewerIos() {
fun ImageViewerIos() {
val toastState = remember { mutableStateOf<ToastState>(ToastState.Hidden) }
val state = remember { mutableStateOf(State()) }
val ioScope: CoroutineScope = rememberCoroutineScope { Dispatchers.Default }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable

@Composable
internal actual fun needShowPreview(): Boolean = true
actual fun needShowPreview(): Boolean = true
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
internal actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) =
actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) =
TouchScrollableColumn(modifier, content)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package example.imageviewer.view
import androidx.compose.runtime.Composable

@Composable
internal actual fun Tooltip(
actual fun Tooltip(
text: String,
content: @Composable () -> Unit
) {
Expand Down