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

Fix incorrect Skiko render target on iOS Metal. #554

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions compose/mpp/demo/regenerate_xcode_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Script to regenerate xcode project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add copyright here?


# make script folder current or exit
cd "$(dirname "$0")" || exit

if command -v xcodegen >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to revert such checks to avoid extra indents of the main logic

# xcodegen exists

projPath="ComposeDemo.xcodeproj"

if [ -d "$projPath" ]; then
echo "Removing existing project"
rm -rf "$projPath"
fi

xcodegen
elijah-semyonov marked this conversation as resolved.
Show resolved Hide resolved
else
# xcodegen does not exist
echo "Error: xcodegen not found. Please install it using 'brew install xcodegen'."
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,19 @@ import androidx.compose.ui.interop.LocalLayerContainer
import androidx.compose.ui.interop.LocalUIViewController
import androidx.compose.ui.native.ComposeLayer
import androidx.compose.ui.platform.*
import androidx.compose.ui.platform.DefaultInputModeManager
import androidx.compose.ui.platform.Platform
import androidx.compose.ui.platform.UIKitTextInputService
import androidx.compose.ui.text.input.PlatformTextInputService
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.toOffset
import androidx.compose.ui.unit.*
import kotlin.math.roundToInt
import kotlinx.cinterop.CValue
import kotlinx.cinterop.ExportObjCClass
import kotlinx.cinterop.ObjCAction
import kotlinx.cinterop.useContents
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.jetbrains.skiko.SkikoUIView
import org.jetbrains.skiko.TextActions
import platform.CoreGraphics.CGPointMake
import platform.CoreGraphics.CGRectMake
import platform.CoreGraphics.CGSize
import platform.Foundation.NSCoder
import platform.Foundation.NSNotification
import platform.Foundation.NSNotificationCenter
import platform.Foundation.NSSelectorFromString
import platform.Foundation.NSValue
import platform.Foundation.*
import platform.UIKit.*
import platform.darwin.NSObject

Expand Down Expand Up @@ -180,11 +165,17 @@ internal actual class ComposeWindow : UIViewController {
).load()
val rootView = UIView() // rootView needs to interop with UIKit
rootView.backgroundColor = UIColor.whiteColor

skikoUIView.translatesAutoresizingMaskIntoConstraints = false
rootView.addSubview(skikoUIView)
rootView.setAutoresizesSubviews(true)
skikoUIView.setAutoresizingMask(
UIViewAutoresizingFlexibleWidth or UIViewAutoresizingFlexibleHeight
)

NSLayoutConstraint.activateConstraints(listOf(
skikoUIView.leadingAnchor.constraintEqualToAnchor(rootView.leadingAnchor),
skikoUIView.trailingAnchor.constraintEqualToAnchor(rootView.trailingAnchor),
skikoUIView.topAnchor.constraintEqualToAnchor(rootView.topAnchor),
skikoUIView.bottomAnchor.constraintEqualToAnchor(rootView.bottomAnchor)
))

view = rootView
val uiKitTextInputService = UIKitTextInputService(
showSoftwareKeyboard = {
Expand Down