Giter VIP home page Giter VIP logo

dbaroncelli / d-kmp-sample Goto Github PK

View Code? Open in Web Editor NEW
749.0 30.0 86.0 109.92 MB

D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.

License: Apache License 2.0

Kotlin 76.17% Swift 23.83%
kotlin kotlin-multiplatform android ios swiftui kmp-viewmodel jetpack-compose kotlin-multiplatform-mobile kmp kmm d-kmp mvi declarative-ui stateflow sqldelight ktor-client multiplatform-settings compose-desktop

d-kmp-sample's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

d-kmp-sample's Issues

FAILURE: Build failed with an exception.

How to solve this problem? i'm use AS Arctic Fox Canary 14.

Thank you

App not working for android < 26.

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

Some doubts

Hello, excellent initiative.

Could you give me any tips?, I have the following problems:

When I click on run desktop, nothing happens
image

Codes are hidden after gradlew sync
image

Could not resolve ktor-client-js

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

iOS Native App

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?

[Question] Architecture and implementation details

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:

    • How would you implement a second layer of navigation? e.g. A layer for onboarding unauthenticated users and another for logged-in users.
    • How would you handle actions depending on a screen's lifecycle? e.g. Doing something when the screen is rendered. Should lifecycle hooks be part of the architecture or should Compose/SwiftUI hooks be used to achieve this kind of action? e.g. A LaunchedEffect hook calls a function defined in the shared module
  • State:

    • Do you think this architecture is compatible with any kind of local cache as a single source of truth for the state? e.g. Apollo HTTP/Normalized GraphQL cache
    • If so, would you implement the caching behaviour inside the runtimecache or the localdb directory?
  • General:

    • Don't you think some of the unchanged files included in the sample should be upstreamed and packaged in a multiplatform library or some kind of DSL?

If it helps, here's more information about what I'm trying to build: apollographql/apollo-kotlin#3106

Thanks in advance for your time!

First run not working

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!

Result from other view/state

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!

the architecture of D-KMP may be too complex?

if I just write a network request and update the UI. D-KMP has so many concepts:

  1. Events.kt
  2. KMPViewModel.kt
  3. StateManager.kt
  4. StateProviders.kt
  5. StateReducers.kt
  6. Repository.kt

and the relation between these concept is also complex. I think these are hard to maintain.

image

can you simple the architecture of D-KMP, make more less concepts, and less relationship between these concepts.

Error SockeTimeout when building `shared:runCommonizer` task

> 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? ๐Ÿ™

Ios could not see getIosInstance()

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?

Plans to include web version

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!

Bad Gateway trying to get compose runtime

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

Navigation appears to be broken on iOS

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:

  1. Create a basic new screen in the shared library

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())}),
}
  1. Add the screen to the iOS App, so that it can be navigated to from within CountryDetailScreen

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)
}
  1. Start App and navigate to the newly created screen

"Jvm target compatibility should be set to the same Java version" build error

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.