Lukas Anda
09/12/2023, 7:43 AMIvan Matkov
09/12/2023, 8:25 AMLukas Anda
09/12/2023, 9:06 AMIvan Matkov
09/12/2023, 9:18 AMAlthough, that’s for injecting the whole screen view.It's not (see screenshot in readme). Another example of not-full-screen view is mapview in imageviewer example (not swiftUI but anyway).
where to put it from Compose codeCreate expect composable function, use
UIKitView
inside actual ios implementationLukas Anda
09/12/2023, 9:26 AMCreate expect composable function, useWould you mind please elaborate a bit more on this? It’s a bit confusing for me since the example only has iOS partinside actual ios implementationUIKitView
Ivan Matkov
09/12/2023, 9:30 AM@Composable
, so you can put different UI layout inside.
It's not our doc, just some article, but I guess it's ok to ref this as example 😅: https://proandroiddev.com/unifying-video-players-compose-multiplatform-for-ios-android-desktop-aa920d29bbf3Lukas Anda
09/12/2023, 9:33 AMIvan Matkov
09/12/2023, 9:34 AMLukas Anda
09/12/2023, 9:35 AMIvan Matkov
09/12/2023, 9:36 AMfrom the common codeYou cannot refer it from common. that's why you need expect/actual to refer it only from ios actual implementation
Lukas Anda
09/12/2023, 9:37 AMIvan Matkov
09/12/2023, 9:51 AMA Swift library can be used in Kotlin code if its API is exported to Objective-C withAs far as I know swift support is on the way. Pure Swift modules are not yet supported.@objc
Lukas Anda
09/12/2023, 9:54 AMAs far as I know swift support is on the wayDoes it mean that for now, it is or it is not possible to do what I need? Basically, this is the library https://github.com/colinc86/LaTeXSwiftUI I want to use in my compose implementation
jamshedalamqaderi
09/12/2023, 10:03 AMIvan Matkov
09/12/2023, 10:19 AMLukas Anda
09/12/2023, 10:48 AMjamshedalamqaderi
09/12/2023, 10:52 AMLukas Anda
09/12/2023, 10:54 AMjamshedalamqaderi
09/12/2023, 10:56 AMLukas Anda
09/12/2023, 10:57 AMjamshedalamqaderi
09/12/2023, 10:58 AM// in shared/iosMain
interface LottieAnimationInterface {
fun getView(): UIView
fun play()
}
jamshedalamqaderi
09/12/2023, 11:00 AM// in iosApp/LottiAnimationInterface.swift
import Lottie
import UIKit
import shared
class LottieAnimationInterfaceImpl: LottieAnimationInterface{
private var lottieAnimationView: LottieAnimationView?
private let animationName:String
init(animationName:String){
self.animationName = animationName
}
func getView() -> UIView{
lottieAnimationView = LottieAnimationView(filePath: self.animationName)
lottieAnimationView?.loopMode = .loop
return lottieAnimationView!
}
func play(){
lottieAnimationView?.play()
}
}
jamshedalamqaderi
09/12/2023, 11:01 AMimport UIKit
import SwiftUI
import shared
// This is where you're calling the compose shared code from iosMain and pass the implementation to the shared module
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainApp_iosKt.MainViewController(lottieInterfaceFactory: LottieAnimationInterfaceFactoryImpl(), googleLoginInterface: GoogleLoginInterfaceImpl())
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) { }
}
jamshedalamqaderi
09/12/2023, 11:01 AMval LocalLottieInterfaceFactory =
compositionLocalOf<LottieAnimationInterfaceFactory> { DummyLottieInterface() }
fun MainViewController(
lottieInterfaceFactory: LottieAnimationInterfaceFactory,
googleLoginInterface: GoogleLoginInterface
): UIViewController {
val controller = PreComposeApplication {
CompositionLocalProvider(LocalLottieInterfaceFactory provides lottieInterfaceFactory) {
KoinApplication(application = {
modules(
module {
single { googleLoginInterface }
}
)
modules(KoinPlatformModule, KoinModule)
}) {
App()
}
}
}
googleLoginInterface.setController(controller)
return controller
}
jamshedalamqaderi
09/12/2023, 11:02 AMLocalLottieInterfaceFactory.current
and this will return an object of LottieInterface
then you know what to do with UIKitView in composejamshedalamqaderi
09/12/2023, 11:03 AMLukas Anda
09/12/2023, 11:18 AMDima Avdeev
09/24/2023, 1:00 AM