Giter Site home page Giter Site logo

freeletics / khonshu Goto Github PK

View Code? Open in Web Editor NEW
94.0 9.0 7.0 3.06 MB

Khonshu is the foundation of how we build apps at Freeletics. It provides the general set up for screens as well as navigation.

Home Page: https://freeletics.github.io/khonshu

License: Apache License 2.0

Kotlin 99.49% Shell 0.51%
android anvil architecture dagger mvi navigation

khonshu's Introduction

Khonshu

Khonshu is the foundation of how we build apps at Freeletics. It provides the general set up for screens and navigation. The project grew over time based on our needs, issues we ran into and common pitfalls we wanted to avoid.

Navigation

A navigation library that allows to separate navigation logic from the UI layer and provides a scalable approach to type safe navigation in a highly modularized code base.

For more information check out the docs.

Codegen

Codegen provides a plugin for Anvil that helps with generating dependency injection related code and common boilerplate for screens as well as handling most of the set up of the navigation library.

For more information check out the docs.

Helpers

Small libraries that provide utility functionality or a base for other libraries to build upon.

For more information check out the docs.

License

Copyright 2021 Freeletics GmbH.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

khonshu's People

Contributors

befrvnk avatar dependabot[bot] avatar dmo60 avatar gabrielittner avatar hoangchungk53qx1 avatar hoc081098 avatar josirichter avatar kboyarshinov avatar renovate[bot] avatar snappdevelopment avatar sockeqwe avatar thomaskioko avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

khonshu's Issues

Run whetstone tests with actual source files

Currently we are testing the codegen by using our abstracted models as input to see that the output matches what we expect. This means that the tests don't cover the conversion from getting KtFile instances to our model

Example / Demo

Hi, thanks for these interesting libraries.
Can you add an example app that uses libraries in this repo

Use `ImmutableSet` as NavHost parameter

This way the compose compiler can infer stability for it.

On the codegen side we should generate a @Provide fun provideImmutableDestinations(desintations: Set<NavDestination>): ImmutableSet<NavDestination> = this and the same for deeplink related sets as part of the Activity generation.

Deep link support: test facility to check that all supported deep links exist

Use the same toml file from #251 to validate that a given set of DeepLinkHandler contains all patterns from the yaml file and vice versa. This will ensure that the yaml file is up to date and that the generated intent filters match what the app can handle. It also serves as a test that the patterns in the handlers are correct.

Document `Closeable` support

Whetstone supports automatically closing contributes closeables when the destination is cleared from the back stack, but this feature isn't documented

Run kapt/dagger in whetstone tests

While the tests currently check that everything compiles it would be nice to additionally also run them with kapt and a fake component to see that it will work as expected with Dagger actually using the generated code.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/build-simple-sample.yml
  • actions/checkout v4
  • gradle/wrapper-validation-action v3
  • actions/setup-java v4
  • gradle/actions v4
.github/workflows/build.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
.github/workflows/publish-docs.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/setup-python v5
  • actions/upload-pages-artifact v3
  • actions/deploy-pages v4
.github/workflows/publish-release.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • softprops/action-gh-release v2
.github/workflows/publish-snapshot.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
gradle
gradle.properties
settings.gradle.kts
  • com.freeletics.gradle.settings 0.15.0
build.gradle.kts
codegen/gradle.properties
codegen/codegen.gradle.kts
codegen-compiler/gradle.properties
codegen-compiler/codegen-compiler.gradle.kts
codegen-compiler-test/codegen-compiler-test.gradle.kts
deeplinks-plugin/gradle.properties
deeplinks-plugin/deeplinks-plugin.gradle.kts
gradle/libs.versions.toml
  • com.android.tools.build:gradle-api 8.5.2
  • org.jetbrains.kotlin:kotlin-parcelize-runtime 2.0.10
  • org.jetbrains.kotlin:kotlin-compiler-embeddable 2.0.10
  • org.jetbrains.kotlin:kotlin-test 2.0.10
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.8.1
  • org.jetbrains.kotlinx:kotlinx-coroutines-test 1.8.1
  • org.jetbrains.kotlinx:kotlinx-collections-immutable 0.3.7
  • org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable 2.0.10
  • androidx.compose.runtime:runtime 1.6.8
  • androidx.compose.ui:ui 1.6.8
  • androidx.compose.foundation:foundation 1.6.8
  • org.jetbrains.compose.runtime:runtime 1.6.11
  • org.jetbrains.compose.ui:ui 1.6.11
  • androidx.activity:activity 1.9.1
  • androidx.activity:activity-compose 1.9.1
  • androidx.annotation:annotation 1.5.0
  • androidx.core:core-ktx 1.13.1
  • androidx.lifecycle:lifecycle-common 2.8.4
  • androidx.lifecycle:lifecycle-runtime-ktx 2.8.4
  • androidx.lifecycle:lifecycle-runtime-testing 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel-ktx 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel-compose 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel-savedstate 2.8.4
  • com.eygraber:uri-kmp 0.0.18
  • net.peanuuutz.tomlkt:tomlkt 0.4.0
  • org.jetbrains.kotlinx:kotlinx-serialization-core 1.7.1
  • javax.inject:javax.inject 1
  • com.squareup.anvil:annotations 2.5.0-beta11
  • com.squareup.anvil:annotations-optional 2.5.0-beta11
  • com.squareup.anvil:compiler-api 2.5.0-beta11
  • com.squareup.anvil:compiler-utils 2.5.0-beta11
  • com.google.devtools.ksp:symbol-processing-api 2.0.10-1.0.24
  • com.squareup:kotlinpoet 1.18.1
  • com.squareup:kotlinpoet-ksp 1.18.1
  • com.google.auto.service:auto-service-annotations 1.1.1
  • dev.zacsweers.autoservice:auto-service-ksp 1.2.0
  • com.freeletics.flowredux:flowredux 1.2.2
  • junit:junit 4.13.2
  • com.google.truth:truth 1.4.4
  • app.cash.turbine:turbine 1.1.0
  • dev.zacsweers.kctfork:core 0.5.1
  • dev.zacsweers.kctfork:ksp 0.5.1
  • com.google.devtools.ksp:symbol-processing 2.0.10-1.0.24
  • com.google.devtools.ksp:symbol-processing-common-deps 2.0.10-1.0.24
  • com.google.devtools.ksp:symbol-processing-aa-embeddable 2.0.10-1.0.24
  • com.freeletics.gradle.android 0.15.0
  • com.freeletics.gradle.jvm 0.15.0
  • com.freeletics.gradle.multiplatform 0.15.0
  • com.freeletics.gradle.gradle 0.15.0
  • com.freeletics.gradle.publish.oss 0.15.0
  • com.freeletics.gradle.root 0.15.0
  • com.freeletics.gradle.settings 0.15.0
  • com.android.library 8.5.2
  • org.jetbrains.kotlin.multiplatform 2.0.10
  • org.jetbrains.kotlin.android 2.0.10
  • org.jetbrains.kotlin.jvm 2.0.10
  • org.jetbrains.kotlin.plugin.parcelize 2.0.10
  • org.jetbrains.kotlin.plugin.serialization 2.0.10
  • org.jetbrains.kotlin.plugin.compose 2.0.10
  • com.google.devtools.ksp 2.0.10-1.0.24
  • com.vanniktech.maven.publish 0.29.0
  • org.jetbrains.dokka 1.9.20
  • org.jetbrains.kotlinx.binary-compatibility-validator 0.16.3
  • com.autonomousapps.dependency-analysis 1.28.0
  • dev.drewhamilton.poko 0.16.0
navigation/gradle.properties
navigation/navigation.gradle.kts
navigation-testing/gradle.properties
navigation-testing/navigation-testing.gradle.kts
sample/simple/gradle.properties
sample/simple/settings.gradle.kts
  • com.freeletics.gradle.settings 0.15.0
sample/simple/build.gradle.kts
sample/simple/app/simple/app-simple.gradle.kts
sample/simple/feature/bottom-sheet/implementation/feature-bottom-sheet-implementation.gradle.kts
sample/simple/feature/bottom-sheet/nav/feature-bottom-sheet-nav.gradle.kts
sample/simple/feature/dialog/implementation/feature-dialog-implementation.gradle.kts
sample/simple/feature/dialog/nav/feature-dialog-nav.gradle.kts
sample/simple/feature/main/feature-main.gradle.kts
sample/simple/feature/new-root/implementation/feature-new-root-implementation.gradle.kts
sample/simple/feature/new-root/nav/feature-new-root-nav.gradle.kts
sample/simple/feature/root/implementation/feature-root-implementation.gradle.kts
sample/simple/feature/root/nav/feature-root-nav.gradle.kts
sample/simple/feature/screen-with-result/implementation/feature-screen-with-result-implementation.gradle.kts
sample/simple/feature/screen-with-result/nav/feature-screen-with-result-nav.gradle.kts
sample/simple/feature/screen/implementation/feature-screen-implementation.gradle.kts
sample/simple/feature/screen/nav/feature-screen-nav.gradle.kts
sample/simple/gradle/libs.versions.toml
  • com.android.tools:desugar_jdk_libs 2.0.4
  • androidx.activity:activity 1.9.1
  • androidx.activity:activity-compose 1.9.1
  • androidx.annotation:annotation 1.6.0
  • androidx.compose.runtime:runtime 1.6.8
  • androidx.compose.ui:ui 1.6.8
  • androidx.compose.foundation:foundation 1.6.8
  • androidx.compose.material3:material3 1.2.1
  • androidx.core:core-ktx 1.13.1
  • androidx.lifecycle:lifecycle-common 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel-compose 2.8.4
  • androidx.lifecycle:lifecycle-viewmodel-savedstate 2.8.4
  • com.squareup.anvil:annotations 2.5.0-beta11
  • com.squareup.anvil:annotations-optional 2.5.0-beta11
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.8.1
  • com.google.dagger:dagger 2.52
  • com.google.dagger:dagger-compiler 2.52
  • javax.inject:javax.inject 1
  • com.freeletics.khonshu:navigation 0.28.3
  • com.freeletics.khonshu:codegen-compiler 0.28.3
  • com.freeletics.khonshu:codegen-runtime 0.28.3
  • com.freeletics.khonshu:state-machine 0.28.3
  • com.jakewharton.timber:timber 5.0.1
  • com.android.application 8.5.2
  • com.squareup.anvil 2.5.0-beta11
  • com.autonomousapps.dependency-analysis 1.33.0
  • com.freeletics.gradle.app 0.15.0
  • com.freeletics.gradle.feature 0.15.0
  • com.freeletics.gradle.nav 0.15.0
  • com.freeletics.gradle.root 0.15.0
  • org.jetbrains.kotlin.android 2.0.10
  • org.jetbrains.kotlin.plugin.compose 2.0.10
  • com.google.devtools.ksp 2.0.10-1.0.24
state-machine/gradle.properties
state-machine/state-machine.gradle.kts
state-machine-legacy/gradle.properties
state-machine-legacy/state-machine-legacy.gradle.kts
state-machine-testing/gradle.properties
state-machine-testing/state-machine-testing.gradle.kts
text-resource/gradle.properties
text-resource/text-resource.gradle.kts
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.9
sample/simple/gradle/wrapper/gradle-wrapper.properties
  • gradle 8.9
kotlin-script
.kts/ktlint.main.kts
  • com.freeletics.gradle:scripts-formatting 0.15.0

  • Check this box to trigger a request for Renovate to run again on this repository

Document NavEntryComponent

Whetstone has a mechanism to generate a component that is tied to a back stack entry and can be used as shared component for screens of a flow but this is not documented.

Support generics for objects injected into composables

This would be a follow up to #224 which generally supports adding more parameters to a @ComposeScreen or @ComposeFragment composable to get an instance of them injected. This initial support does not handle generics on the injected parameters, so it is for example not possible to inject a Set<Foo>

Make compose parameters optional

Right now each annotated composable is forced to have a state parameter and a sendAction parameter. This sometimes leads to unused parameter warnings in simple screens that only show static information or have no interactions. Recognize the parameters not being present and then adapt the generated code to not pass on these parameters.

navigation-experimental: LocalViewModelStoreOwner, LocalLifecycleOwner, LocalSavedStateRegistryOwner

Hi, first of all, thanks for your awesome library ๐Ÿ’ฏ

In androidx compose navigation, I see saveableStateHolder.SaveableStateProvider(content) is in CompositionLocalProvider that provides ViewModelStoreOwner, LifecycleOwner and SavedStateRegistryOwner.

https://github.com/androidx/androidx/blob/4b85e9bb64eb4026256d6a39837fe89722fac220/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavBackStackEntryProvider.kt#L43

What about adding that to navigation-experimental @Composable fun Show(...)?
This issue is just my thought/question about it ๐Ÿ˜„

Add an `AppScope` marker class to the library

We can provide this and have it as the default value for both destinationScope and parentScope. That way the standard case only needs to pass the route and the stateMachine as parameters

[navigation] pop all stack (clear stack), then navigating to new `NavRoot`

Hi, I have a use case

  • When launching my app, I will check whether the user is logged in or not
    • if logged in -> startRoute is LoginScreenRoute (a NavRoot) (1).
    • otherwise -> startRoute is HomeScreenRoute (a NavRoot) (2).
  • In the login screen, after the successful login, my expected behavior is popping all stack (clear stack), then navigating to HomeScreenRoute (3). After that, the back stack should contain only an entry, which is HomeScreenRoute, and the user cannot navigate to back LoginScreenRoute.
Back stack:
LOGGED IN:        [ HomeScreenRoute  ] (1)
NOT LOGGED IN:    [ LoginScreenRoute ] (2)
SUCCESSFUL LOGIN: [ HomeScreenRoute. ] (3)

Currently, I implement this by changing the startRoute to reset the NavGraph of the NavController (related to #580).
I have also used NavEventNavigator.resetToRoot(HomeScreenRoute) but I could navigate to back the LoginScreenRoute.

Is there a better approach to achieve this behavior, maybe using the NavEventNavigator? Many thanks ๐Ÿ™

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json5
Error type: Invalid JSON5 (parsing failed)
Message: JSON5.parse error: JSON5: invalid character 'g' at 47:7

Bottom sheet back navigation from scrim area

The back navigation from a bottom sheet feature by clicking on the scrim area (greyed out area) prevents further navigation afterwards.
The simple sample can be used to demonstrate and debug the issue.

Issue:

  • Open the bottom sheet by clicking on the "Bottom Sheet" text
  • Dismiss the bottom sheet by clicking on the grey scrim area
  • Try to open the bottom sheet again by clicking on the text

=> The bottom sheet doesn't open again. It continues working if you press the back button.

Assumption: The bottom sheet is not cleared from the backstack if you click on the scrim area.

Replace NavDestination annotations

Instead add separate versions of the regular @Compose... and @Renderer... annotations where

  • scope has KClass<out NavRoute> as type (with this the route class will be used as a scope marker, so there is no need to create an extra marker class)
  • add destinationType: DestinationType parameter that defaults to DestinationType.Screen
  • add destinationScope: KClass<*> parameter

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.