Skip to content

Commit

Permalink
Merge pull request #1 from tooploox/task/kmp-native-coroutines
Browse files Browse the repository at this point in the history
Use KMP-Native-Coroutines
  • Loading branch information
bpedryc authored Jun 29, 2023
2 parents 47fdcf0 + 7b6ea4c commit 8e03092
Show file tree
Hide file tree
Showing 26 changed files with 235 additions and 317 deletions.
2 changes: 0 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions app/src/main/kotlin/co/touchlab/kampkit/android/ui/Composables.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.touchlab.kampkit.android.ui

import android.annotation.SuppressLint
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.TweenSpec
Expand All @@ -21,17 +20,14 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import co.touchlab.kampkit.android.R
import co.touchlab.kampkit.db.Breed
import co.touchlab.kampkit.models.BreedViewModel
Expand All @@ -45,13 +41,7 @@ fun MainScreen(
viewModel: BreedViewModel,
log: Logger
) {
val lifecycleOwner = LocalLifecycleOwner.current
val lifecycleAwareDogsFlow = remember(viewModel.breedState, lifecycleOwner) {
viewModel.breedState.flowWithLifecycle(lifecycleOwner.lifecycle)
}

@SuppressLint("StateFlowValueCalledInComposition") // False positive lint check when used inside collectAsState()
val dogsState by lifecycleAwareDogsFlow.collectAsState(viewModel.breedState.value)
val dogsState by viewModel.breedState.collectAsStateWithLifecycle()

MainScreenContent(
dogsState = dogsState,
Expand Down
12 changes: 7 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.8.0"
kotlin = "1.8.21"

## SDK Versions
minSdk = "21"
Expand All @@ -11,18 +11,18 @@ android-gradle-plugin = "7.4.1"
ktlint-gradle = "11.2.0"
gradle-versions = "0.42.0"

compose = "1.4.0-alpha03"
composeCompiler = "1.4.0-dev-k1.8.0-33c0ad36f83"
compose = "1.4.3"
composeCompiler = "1.4.7"

android-desugaring = "1.1.8" # Don't bump to 1.2.x until AGP is 7.3.x
androidx-core = "1.9.0"
androidx-test-junit = "1.1.3"
androidx-activity-compose = "1.5.1"
androidx-lifecycle = "2.5.1"
androidx-lifecycle = "2.6.0"

junit = "4.13.2"

coroutines = "1.6.4"
coroutines = "1.7.1"
kotlinx-datetime = "0.4.0"
ktor = "2.1.1"

Expand All @@ -42,6 +42,7 @@ android-desugaring = { module = "com.android.tools:desugar_jdk_libs", version.re
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle"}
androidx-test-junit = { module = "androidx.test.ext:junit-ktx", version.ref = "androidx-test-junit" }

compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" }
Expand Down Expand Up @@ -99,6 +100,7 @@ app-ui = [
"androidx-core",
"androidx-lifecycle-runtime",
"androidx-lifecycle-viewmodel",
"androidx-lifecycle-runtime-compose",
"compose-ui",
"compose-tooling",
"compose-foundation",
Expand Down
63 changes: 54 additions & 9 deletions ios/KaMPKitiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
3C73D04A2A335103003E6929 /* BreedsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C73D0492A335103003E6929 /* BreedsViewModel.swift */; };
3CD290EC2A251417004C7AD1 /* KMPNativeCoroutinesCombine in Frameworks */ = {isa = PBXBuildFile; productRef = 3CD290EB2A251417004C7AD1 /* KMPNativeCoroutinesCombine */; };
3CD290EE2A251417004C7AD1 /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = 3CD290ED2A251417004C7AD1 /* KMPNativeCoroutinesCore */; };
3DFF917C64A18A83DA010EE1 /* Pods_KaMPKitiOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B859F3FB23133D22AB9DD835 /* Pods_KaMPKitiOS.framework */; };
461C74AA2788F5F3004B1FFC /* CombineAdapters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461C74A92788F5F3004B1FFC /* CombineAdapters.swift */; };
46A5B5EF26AF54F7002EFEAA /* BreedListScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46A5B5EE26AF54F7002EFEAA /* BreedListScreen.swift */; };
46A5B5EF26AF54F7002EFEAA /* BreedsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46A5B5EE26AF54F7002EFEAA /* BreedsScreen.swift */; };
46A5B60826B04921002EFEAA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 46A5B60626B04920002EFEAA /* Main.storyboard */; };
46B5284D249C5CF400A7725D /* Koin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46B5284C249C5CF400A7725D /* Koin.swift */; };
F1465F0123AA94BF0055F7C3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1465F0023AA94BF0055F7C3 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -39,8 +41,8 @@
/* Begin PBXFileReference section */
1DFCC00C8DAA719770A18D1A /* Pods-KaMPKitiOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KaMPKitiOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-KaMPKitiOS/Pods-KaMPKitiOS.release.xcconfig"; sourceTree = "<group>"; };
2A1ED6A4A2A53F5F75C58E5F /* Pods-KaMPKitiOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KaMPKitiOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-KaMPKitiOS/Pods-KaMPKitiOS.release.xcconfig"; sourceTree = "<group>"; };
461C74A92788F5F3004B1FFC /* CombineAdapters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineAdapters.swift; sourceTree = "<group>"; };
46A5B5EE26AF54F7002EFEAA /* BreedListScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreedListScreen.swift; sourceTree = "<group>"; };
3C73D0492A335103003E6929 /* BreedsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreedsViewModel.swift; sourceTree = "<group>"; };
46A5B5EE26AF54F7002EFEAA /* BreedsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreedsScreen.swift; sourceTree = "<group>"; };
46A5B60726B04920002EFEAA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
46B5284C249C5CF400A7725D /* Koin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Koin.swift; sourceTree = "<group>"; };
B859F3FB23133D22AB9DD835 /* Pods_KaMPKitiOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_KaMPKitiOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -65,6 +67,8 @@
buildActionMask = 2147483647;
files = (
3DFF917C64A18A83DA010EE1 /* Pods_KaMPKitiOS.framework in Frameworks */,
3CD290EC2A251417004C7AD1 /* KMPNativeCoroutinesCombine in Frameworks */,
3CD290EE2A251417004C7AD1 /* KMPNativeCoroutinesCore in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -85,6 +89,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3C73D0482A335061003E6929 /* Breeds */ = {
isa = PBXGroup;
children = (
46A5B5EE26AF54F7002EFEAA /* BreedsScreen.swift */,
3C73D0492A335103003E6929 /* BreedsViewModel.swift */,
);
path = Breeds;
sourceTree = "<group>";
};
6278498AD96A4D949D39BF44 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -129,14 +142,13 @@
F1465EFF23AA94BF0055F7C3 /* KaMPKitiOS */ = {
isa = PBXGroup;
children = (
3C73D0482A335061003E6929 /* Breeds */,
F1465F0023AA94BF0055F7C3 /* AppDelegate.swift */,
46A5B60626B04920002EFEAA /* Main.storyboard */,
46B5284C249C5CF400A7725D /* Koin.swift */,
F1465F0923AA94BF0055F7C3 /* Assets.xcassets */,
F1465F0B23AA94BF0055F7C3 /* LaunchScreen.storyboard */,
F1465F0E23AA94BF0055F7C3 /* Info.plist */,
46A5B5EE26AF54F7002EFEAA /* BreedListScreen.swift */,
461C74A92788F5F3004B1FFC /* CombineAdapters.swift */,
);
path = KaMPKitiOS;
sourceTree = "<group>";
Expand Down Expand Up @@ -178,6 +190,10 @@
dependencies = (
);
name = KaMPKitiOS;
packageProductDependencies = (
3CD290EB2A251417004C7AD1 /* KMPNativeCoroutinesCombine */,
3CD290ED2A251417004C7AD1 /* KMPNativeCoroutinesCore */,
);
productName = KaMPKitiOS;
productReference = F1465EFD23AA94BF0055F7C3 /* KaMPKitiOS.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -250,6 +266,9 @@
Base,
);
mainGroup = F1465EF423AA94BF0055F7C3;
packageReferences = (
3CD290EA2A251417004C7AD1 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */,
);
productRefGroup = F1465EFE23AA94BF0055F7C3 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -354,8 +373,8 @@
buildActionMask = 2147483647;
files = (
46B5284D249C5CF400A7725D /* Koin.swift in Sources */,
461C74AA2788F5F3004B1FFC /* CombineAdapters.swift in Sources */,
46A5B5EF26AF54F7002EFEAA /* BreedListScreen.swift in Sources */,
3C73D04A2A335103003E6929 /* BreedsViewModel.swift in Sources */,
46A5B5EF26AF54F7002EFEAA /* BreedsScreen.swift in Sources */,
F1465F0123AA94BF0055F7C3 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -542,6 +561,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8UD86646U9;
INFOPLIST_FILE = KaMPKitiOS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -570,6 +590,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8UD86646U9;
INFOPLIST_FILE = KaMPKitiOS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -709,6 +730,30 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
3CD290EA2A251417004C7AD1 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/rickclephas/KMP-NativeCoroutines.git";
requirement = {
kind = exactVersion;
version = "1.0.0-ALPHA-9";
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
3CD290EB2A251417004C7AD1 /* KMPNativeCoroutinesCombine */ = {
isa = XCSwiftPackageProductDependency;
package = 3CD290EA2A251417004C7AD1 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
productName = KMPNativeCoroutinesCombine;
};
3CD290ED2A251417004C7AD1 /* KMPNativeCoroutinesCore */ = {
isa = XCSwiftPackageProductDependency;
package = 3CD290EA2A251417004C7AD1 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
productName = KMPNativeCoroutinesCore;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = F1465EF523AA94BF0055F7C3 /* Project object */;
}
2 changes: 1 addition & 1 deletion ios/KaMPKitiOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

startKoin()

let viewController = UIHostingController(rootView: BreedListScreen())
let viewController = UIHostingController(rootView: BreedsScreen())

self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = viewController
Expand Down
Loading

0 comments on commit 8e03092

Please sign in to comment.