forked from touchlab/KaMPKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For touchlab#305 - Use Compose Multiplatform to show the UI from :sha…
…red on iOS
- Loading branch information
Showing
11 changed files
with
121 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ComposeContentView.swift | ||
// KaMPKitiOS | ||
// | ||
// Created by Petru on 7/21/23. | ||
// Copyright © 2023 Touchlab. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import shared | ||
import SwiftUI | ||
|
||
struct ComposeContentView: UIViewControllerRepresentable { | ||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { | ||
// no-op | ||
} | ||
|
||
func makeUIViewController(context: Context) -> some UIViewController { | ||
MainViewControllerKt.MainViewController( | ||
logger: koin.loggerWithTag(tag: "ViewController"), | ||
viewModel: KotlinDependencies.shared.getBreedViewModel().viewModel | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// ContentView.swift | ||
// KaMPKitiOS | ||
// | ||
// Created by Petru on 7/21/23. | ||
// Copyright © 2023 Touchlab. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import shared | ||
|
||
struct ContentView: View { | ||
var body: some View { | ||
ComposeContentView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// iOSApp.swift | ||
// KaMPKitiOS | ||
// | ||
// Created by Petru on 7/21/23. | ||
// Copyright © 2023 Touchlab. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct IOSApp: App { | ||
|
||
init() { | ||
startKoin() | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
shared/src/iosMain/kotlin/co/touchlab/kampkit/ui/MainViewController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package co.touchlab.kampkit.ui | ||
|
||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.ui.window.ComposeUIViewController | ||
import co.touchlab.kampkit.injectInstance | ||
import co.touchlab.kampkit.models.BreedViewModel | ||
import co.touchlab.kampkit.ui.theme.KaMPKitTheme | ||
import co.touchlab.kermit.Logger | ||
import platform.UIKit.UIApplication | ||
import platform.UIKit.UIScreen | ||
import platform.UIKit.UIUserInterfaceStyle | ||
|
||
fun MainViewController(logger: Logger, viewModel: BreedViewModel) = ComposeUIViewController { | ||
val isDarkThemeEnabled = | ||
UIScreen.mainScreen.traitCollection.userInterfaceStyle == UIUserInterfaceStyle.UIUserInterfaceStyleDark | ||
|
||
KaMPKitTheme(isDarkThemeEnabled, false) { | ||
MainScreen(viewModel, logger) | ||
} | ||
} |