dbaroncelli / d-kmp-sample Goto Github PK
View Code? Open in Web Editor NEWD-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.
License: Apache License 2.0
D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.
License: Apache License 2.0
What went wrong:
Please initialize at least one Kotlin target in 'shared (:shared)'.
Read more https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is:
org.gradle.api.GradleException: Please initialize at least one Kotlin target in 'shared (:shared)'.
Read more https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets
How to solve this problem? i'm use AS Arctic Fox Canary 14.
Thank you
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.9")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// Flag to enable support for the new language APIs
isCoreLibraryDesugaringEnabled = true
}
This is necessary as the app crashes in lower API versions due to as per https://developer.android.com/studio/write/java8-support#library-desugaring
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Instant;
at kotlinx.datetime.Instant.<clinit>(Instant.kt:93)
at kotlinx.datetime.Clock$System.now(Clock.kt:17)
Due to GetCountriesList.kt
Line 13 -> val nowUnixtime = Clock.System.now().epochSeconds
When trying to build the Android app I get the following error:
Could not resolve io.ktor:ktor-client-js:1.6.0.
Required by:
project :shared
Android Studio Arctic Fox 2020.3.1, KMM Plugin 0.3.0
Thanks for this project - I love the idea of the business logic and view models in the Kotloin shared layer.
I am concerned about the iOS application - it does not feel like a native application due to the navigation style being employed. There are no animations. Is this by design? Can we use this architecture with the regular iOS Navigation, so it feels completely native?
Hi!
First, thank you for the huge amount of work you put in defining a neat and future-proof architecture, and for making it publicly available. I've been waiting for something like this for months.
I have several questions about it (some of it may be exclusively related to Compose/SwiftUI as I'm quite new to native development):
Navigation:
LaunchedEffect
hook calls a function defined in the shared moduleState:
runtimecache
or the localdb
directory?General:
If it helps, here's more information about what I'm trying to build: apollographql/apollo-kotlin#3106
Thanks in advance for your time!
Getting all kinds of issues after running for the first time. Is there a chance for this repo to be updated? It seems sooo nice!
Fantastic framework, loving it thanks!!
Could you include a sample on how to get result from another view?
E.g.: From the Country detail screen, I would have a button that navigates to a Friend Picker screen where I can select who of my friends were there. Now after selecting some friends, how do I get that information back into the Country Detail screen/state?
many thanks again!
if I just write a network request and update the UI. D-KMP has so many concepts:
and the relation between these concept is also complex. I think these are hard to maintain.
can you simple the architecture of D-KMP, make more less concepts, and less relationship between these concepts.
I have a problem when building, very similar to this one: https://stackoverflow.com/questions/66945802/installing-kotlin-jupyter-e-java-lang-noclassdeffounderror-could-not-initiali
I haven't been able to solve it yet.
I am running on 2020.3.1 Android Studio on a ARM Mac (M1), maybe that could cause the problem.
Hello, in your last commit f10531a of grouping modules, a new folder of composeApp/build is appeared, thinks that is more correct to add this folder to .gitignore.
> Task :shared:runCommonizer
Download https://github.com/yarnpkg/yarn/releases/download/v1.22.10/yarn-v1.22.10.tar.gz
Failed building KotlinMPPGradleModel
org.gradle.internal.operations.BuildOperationQueueFailure: There was a failure while
Really unsure this is my internet connection or not, but it already 1h and failing twice.
When trying to download the yarn
, does the project have pre-req setup that I'm not aware of? ๐
I am trying to get work the repo. It is OK for Android and desktop, but in IOS I couldnt get DKMPViewModel
by using getIosInstance()
function. When I try with another simple class, I could reach the class and its functions, but after using Factory, ios could not reach the content. Any idea?
in the example, there is only one AppState, any ScreeState change make AppState change, and make the top level widget recompute. may this cause performance issue?
Hey! ๐๐ป
First, thanks for your conf and blog posts regarding this architecture, they are really inspiring and I'm looking forward to having time and a project in which I can use this idea.
Do you have any plans to include the web version with Kotlin/React in this repo? In your posts you talked about being able to use Compose in web too. Do you know if this happening and how's that going?
Thanks!
When trying to run the Android project I get the following error
Could not HEAD 'https://kotlin.bintray.com/kotlinx/org/jetbrains/compose/runtime/runtime/1.0.1-rc2/runtime-1.0.1-rc2.pom'. Received status code 502 from server: Bad Gateway
When setting up Navigation deeper then Level 2 on iOS, it stops working. As soon as a Level 3 screen is opened, the Navigation jumps back to Level 1. On Android, this does not happen, the Level 3 screen is displayed correctly.
Steps to reproduce:
NEW file: TestScreenState.kt:
data class TestScreenState (
val isLoading: Boolean = false
): ScreenState
NEW file: TestScreenInit.kt:
data class TestScreenParams(val name: String) : ScreenParams
fun Navigation.initTestScreen(params: TestScreenParams) = ScreenInitSettings (
title = params.name,
initState = { TestScreenState(isLoading = true)},
callOnInit = {
stateManager.updateScreen(TestScreenState::class) {
it.copy(
isLoading = false
)
}
}
)
ScreenEnum.kt:
enum class Screen(
val asString: String,
val navigationLevel : Int = 1,
val initSettings: Navigation.(ScreenIdentifier) -> ScreenInitSettings,
val stackableInstances : Boolean = false,
) {
CountriesList("countrieslist", 1, { initCountriesList(it.params()) }, true),
CountryDetail("country", 2, { initCountryDetail(it.params()) }),
TestScreen("testscreen", 3, {initTestScreen(it.params())}),
}
NEW file: TestScreen,swift:
struct TestScreen: View {
var testScreenState: TestScreenState
var body: some View {
VStack {
if testScreenState.isLoading {
LoadingScreen()
} else {
Text("Hello, World!")
}
}
}
}
ScreenPicker.swift:
case .countrydetail:
CountryDetailScreen(
countryDetailState: self.stateProvider.getToCast(screenIdentifier: sId) as! CountryDetailState,
ontestScreenOpened: {name in self.navigate(.testscreen, TestScreenParams(name: name))}
)
case .testscreen:
TestScreen(
testScreenState: self.stateProvider.getToCast(screenIdentifier: sId) as! TestScreenState
)
CountryDetailScreen.swift:
NavLink(linkFunction: {ontestScreenOpened("population")}) {
DataElement(label: "total population", value: data.population)
}
JFrog announced JCenter's shutdown in February 2021. Use mavenCentral() instead.
After cloning the project, setting current java to version 18 and building it, I constantly get the error below. Any ideas what can cause it or what could be a solution for it?
* What went wrong:
Execution failed for task ':shared:compileDebugKotlinAndroid'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlinAndroid' task (current target is 18) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.