https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

Lucas Schiavini

04/26/2022, 12:41 AM
And would a Stop the world pause break the swift UI necessarily?
r

ribesg

04/26/2022, 10:41 AM
I have a pretty big iOS app written entirely in Kotlin. The switch to the new memory model didn’t seem to change anything, but it’s still recent. Didn’t notice any new lag/freezing. I just had the compilation time tripled and I don’t have to care about freezing stuff anymore.
2
I’m not using Swift UI (you can’t in Kotlin afaik) but didn’t notice anything different in my usage of UIKit
l

Lucas Schiavini

04/26/2022, 11:15 AM
Whoa whoa whoa, I use all my apps with swift ui and it works with kotlin multiplatform seamlessly
@ribesg But that is my point exactly, with their new garbage collector, pauses should be less frequent, but longer. I want to be able to avoid pauses without sacrificing developer experience
r

ribesg

04/26/2022, 11:17 AM
I kinda hope you didn’t misunderstand me and there actually is a way to use Swift UI in Kotlin but I think you misunderstood. I’m using UIKit in Kotlin. I don’t have any Swift or XML code for the UI, only Kotlin
K 1
1
Last time I checked you couldn’t use any pure Swift lib in Kotlin, and Swift UI is pure Swift
K 1
l

Lucas Schiavini

04/26/2022, 11:19 AM
Ohhhhhhhh That is cool, I didn't know you could do that lol
r

ribesg

04/26/2022, 11:20 AM
It’s insanely cool, switching language all the time breaks my brain so it actually saves me a lot of time. Plus with some neat extension functions the UI code can be pretty tidy (especially on the constraints part). And not having to use XCode is a huge plus too
My only use of XCode currently is launching simulators and reading log, and rarely using the UI debugger thingy
❤️ 1
Here’s a Kotlin view for example:
Copy code
class EventListUIView(frame: CValue<CGRect>, header: UIView) : UIView(frame), UITextFieldDelegateProtocol {

    val collectionViewWrapper = EventListUICollectionViewWrapper()

    val loader = uiActivityIndicatorView(UIColor.wizParma) {
        large()
    }

    init {
        backgroundColor = UIColor.backgroundGray

        addSubview(collectionViewWrapper.view)
        addSubview(loader)
        addSubview(header)

        setupConstraints {
            with(header) {
                topToTopOf(parent, useSafeArea = true)
                fitHorizontallyTo(parent)
            }

            with(collectionViewWrapper.view) {
                topToTopOf(parent, useSafeArea = true)
                bottomToBottomOf(parent)
                fitHorizontallyTo(parent)
            }

            with(loader) {
                centerIn(parent)
            }
        }
    }

}
❤️ 2
5 Views