Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 0.0.3 #8

Merged
merged 29 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9aabacd
0.0.2 update scratch
funriser Oct 24, 2022
5dcf90e
0.0.2 fix conflicts
funriser Oct 26, 2022
8aa665d
0.0.2 fix conflicts
funriser Oct 26, 2022
43969f2
0.0.2 fix sample app
funriser Oct 26, 2022
8102371
0.0.2 add replaceable dispatchers to the sample app
funriser Oct 26, 2022
8c2e184
0.0.2 remove scroller flow experimental state warnings
funriser Oct 26, 2022
8794e79
update build_first_screen app to match a new kompot version
funriser Oct 27, 2022
65a8caf
update build_first_flow app to match a new kompot version
funriser Oct 27, 2022
7669671
0.0.2 migrate build first screen demo app to remote kompot dependency
funriser Oct 28, 2022
50b61a5
update build_first_flow app to match a new kompot version
funriser Oct 28, 2022
6065a99
migrate messenger sample to 0.0.2 kompot remote dependency
funriser Oct 28, 2022
025c420
0.0.2 code clean up
funriser Oct 30, 2022
fc3c638
0.0.2 remove unnecessary gradle config from lib modules
funriser Oct 30, 2022
201a3cf
Update README.md
funriser Oct 30, 2022
0f6e113
Update README.md
funriser Oct 30, 2022
bc6ef64
0.0.2 provide default value for the root dialog displayer
funriser Oct 30, 2022
39d4498
0.0.2 use default dialog displayer in sample apps
funriser Oct 30, 2022
7df0753
Merge remote-tracking branch 'origin/pr/update_to_0_0_2' into pr/upda…
funriser Oct 30, 2022
ad60194
0.0.2 fix unresolved dependencies
funriser Oct 31, 2022
372fb8d
0.0.2 revert sample app updates
funriser Oct 31, 2022
f241e30
Revert "0.0.2 revert sample app updates"
funriser Nov 9, 2022
84546e4
Merge branch 'main' into pr/update_to_0_0_2_sample_app
funriser Nov 9, 2022
2eabb22
import 0.0.3 changes
funriser Nov 15, 2023
e193afe
Merge branch 'main' into pr/update_to_0_0_3
funriser Nov 15, 2023
071bdb1
clean up sample app
funriser Nov 15, 2023
2a02c95
modals saved state
funriser Mar 21, 2024
eb501c5
sample app updates
funriser Mar 21, 2024
c2cdce7
non-mandatory dialog displayer in the root flow
funriser Mar 21, 2024
8dbb192
clean up remaining rx dependencies
funriser Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

3 changes: 1 addition & 2 deletions .idea/misc.xml

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

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 30 19:20:45 BST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
11 changes: 10 additions & 1 deletion kompot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ android {
buildToolsVersion androidBuildToolsVersion
targetSdkVersion androidTargetSdkVersion
minSdkVersion androidMinSdkVersion

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

sourceSets {
Expand All @@ -39,10 +41,15 @@ android {
}
}

tasks.withType(Test) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}

dependencies {
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api "com.google.dagger:dagger:$daggerVersion"
api "com.revolut.recyclerkit:rxdiffadapter:$recyclerKitRxDiffAdapterVersion"
api "com.revolut.recyclerkit:delegates:$recyclerKitDelegatesVersion"
api "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
api "androidx.coordinatorlayout:coordinatorlayout:$coordinatorLayoutVersion"
Expand All @@ -66,6 +73,8 @@ dependencies {
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
testImplementation "junit:junit:$junitVersion"
testImplementation "androidx.test:core-ktx:$androidxTestVersion"
testImplementation project(':kompot_coroutines_test')

testImplementation("org.robolectric:robolectric:$robolectricVersion") {
exclude group: "com.google.auto.service", module: "auto-service"
Expand Down
18 changes: 1 addition & 17 deletions kompot/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
#
# Copyright (C) 2022 Revolut
#
# 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.
#

POM_ARTIFACT_ID=kompot
VERSION_NAME=0.0.2
VERSION_NAME=0.0.3
POM_NAME=kompot
POM_PACKAGING=aar
GROUP=com.revolut.kompot
16 changes: 8 additions & 8 deletions kompot/kompot_dependencies_versions.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
ext {
androidBuildToolsVersion = '30.0.3'
androidMinSdkVersion = 23
androidBuildToolsVersion = '33.0.2'
androidMinSdkVersion = 24
androidTargetSdkVersion = 31
androidCompileSdkVersion = 31
androidCompileSdkVersion = 33

kotlinVersion = '1.6.10'

coroutinesVersion = '1.6.0'

daggerVersion = '2.35.1'

recyclerKitRxDiffAdapterVersion = '1.0.7'
recyclerKitDecorationsVersion = '1.0.8'
recyclerKitDelegatesVersion = '1.0.10'
recyclerKitDecorationsVersion = '1.1.0'
recyclerKitDelegatesVersion = '1.1.2'

timberVersion = '4.7.1'
timberVersion = '5.0.1'

androidxCoreVersion = '1.7.0'
appCompatVersion = '1.1.0'
recyclerVersion = '1.1.0'
androidxTestVersion = '1.5.0'
constraintLayoutVersion = '1.1.3'
coordinatorLayoutVersion = '1.1.0'

Expand All @@ -27,7 +27,7 @@ ext {
junitVersion = '4.12'
junitJupiterVersion = '5.4.2'
junitVintageVersion = '5.4.2'
mockitoVersion = '3.9.0'
mockitoVersion = '5.1.1'
mockitoKotlinVersion = '2.2.0'

robolectricVersion = '4.5'
Expand Down
52 changes: 33 additions & 19 deletions kompot/src/main/kotlin/com/revolut/kompot/FeaturesRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package com.revolut.kompot

import android.content.Context
import com.revolut.kompot.common.ControllerDescriptor
import com.revolut.kompot.common.ControllerHolder
import com.revolut.kompot.common.IOData
import com.revolut.kompot.common.NavigationDestination
import com.revolut.kompot.common.NavigationRequest
import com.revolut.kompot.navigable.Controller
import com.revolut.kompot.navigable.flow.BaseFlowModel
import javax.inject.Inject

interface FeaturesRegistry {
fun clearFeatures(context: Context, signOut: Boolean)
Expand All @@ -37,9 +40,17 @@ interface FeaturesRegistry {
destination: NavigationDestination,
flowModel: BaseFlowModel<*, *, *>
): Controller

fun provideControllerOrThrow(
descriptor: ControllerDescriptor<*>,
): ControllerHolder

suspend fun getDestinationOrThrow(
request: NavigationRequest
): NavigationDestination
}

class DefaultFeaturesRegistry @Inject constructor() : FeaturesRegistry {
class DefaultFeaturesRegistry : FeaturesRegistry {
private val featureGateways: MutableList<FeatureGateway> = mutableListOf()
private val featureHolders: MutableList<FeatureHolder> = mutableListOf()

Expand Down Expand Up @@ -74,25 +85,25 @@ class DefaultFeaturesRegistry @Inject constructor() : FeaturesRegistry {
override fun getControllerOrThrow(
destination: NavigationDestination,
flowModel: BaseFlowModel<*, *, *>
): Controller {
featureGateways.forEach { gateway ->
val controller = gateway.getController(destination, flowModel)
if (controller != null) {
return controller
}
): Controller =
featureGateways.firstNotNullOfOrNull { gateway ->
gateway.getController(destination, flowModel)
} ?: error("Controller for $destination not found")

override fun provideControllerOrThrow(descriptor: ControllerDescriptor<*>): ControllerHolder =
featureGateways.firstNotNullOfOrNull { gateway ->
gateway.provideController(descriptor)
} ?: error("Controller for $descriptor not found")

override fun interceptDestination(destination: NavigationDestination): NavigationDestination? =
featureGateways.firstNotNullOfOrNull { gateway ->
gateway.interceptDestination(destination)
}
throw IllegalStateException("Controller for $destination not found")
}

override fun interceptDestination(destination: NavigationDestination): NavigationDestination? {
featureGateways.forEach { gateway ->
val replacedDestination = gateway.interceptDestination(destination)
if (replacedDestination != null) {
return replacedDestination
}
}
return null
}
override suspend fun getDestinationOrThrow(request: NavigationRequest): NavigationDestination =
featureGateways.firstNotNullOfOrNull { gateway ->
gateway.getDestination(request)
} ?: error("Destination for $request not found")
}

interface FeatureApi
Expand All @@ -106,6 +117,9 @@ interface FeatureGateway : FeatureHolder {

fun interceptDestination(destination: NavigationDestination): NavigationDestination? = null

fun <T : IOData.Output> provideController(descriptor: ControllerDescriptor<T>): ControllerHolder? = null

suspend fun getDestination(request: NavigationRequest): NavigationDestination? = null
}

interface FeatureHolder {
Expand Down
16 changes: 15 additions & 1 deletion kompot/src/main/kotlin/com/revolut/kompot/KompotPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@

package com.revolut.kompot

import com.revolut.kompot.lifecycle.ControllerLifecycleCallbacks
import com.revolut.kompot.navigable.Controller
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import java.util.concurrent.CopyOnWriteArrayList

object KompotPlugin {

internal val controllerShownSharedFlow = MutableSharedFlow<Controller>(extraBufferCapacity = 16, onBufferOverflow = BufferOverflow.DROP_OLDEST)
internal val controllerLifecycleCallbacks = CopyOnWriteArrayList<ControllerLifecycleCallbacks>()

@Deprecated("Use registerControllerLifecycleCallbacks with ControllerLifecycleCallbacks.onControllerAttached")
fun controllerShowingStream(): Flow<Controller> = controllerShownSharedFlow.distinctUntilChanged()

fun registerControllerLifecycleCallbacks(callbacks: ControllerLifecycleCallbacks) {
controllerLifecycleCallbacks.add(callbacks)
}

fun controllerShowingStream(): Flow<Controller> = controllerShownSharedFlow
fun unregisterControllerLifecycleCallbacks(callbacks: ControllerLifecycleCallbacks) {
controllerLifecycleCallbacks.remove(callbacks)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2022 Revolut
*
* 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.
*/

package com.revolut.kompot.common

import com.revolut.kompot.navigable.vc.ViewController

interface ControllerDescriptor<Out : IOData.Output> {

fun resolve(viewController: ViewController<Out>): ControllerHolder = ControllerHolder(viewController)
}

data class ControllerRequest(val descriptor: ControllerDescriptor<*>) : Event()
data class ControllerHolder internal constructor(val controller: ViewController<*>) : EventResult
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 Revolut
*
* 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.
*/

package com.revolut.kompot.common

import com.revolut.kompot.navigable.screen.BaseScreenModel
import com.revolut.kompot.navigable.screen.ScreenStates
import com.revolut.kompot.navigable.screen.StateMapper

class EmptyStateMapper : StateMapper<ScreenStates.EmptyDomain, ScreenStates.EmptyUI> {
override fun mapState(domainState: ScreenStates.EmptyDomain) = ScreenStates.EmptyUI
}

class EmptyListStateMapper : StateMapper<ScreenStates.EmptyDomain, ScreenStates.EmptyUIList> {
override fun mapState(domainState: ScreenStates.EmptyDomain) = ScreenStates.EmptyUIList
}

class EmptyScreenModel<Output : IOData.Output> : BaseScreenModel<ScreenStates.EmptyDomain, ScreenStates.EmptyUI, Output>(EmptyStateMapper()) {
override val initialState = ScreenStates.EmptyDomain
}

class EmptyListScreenModel : BaseScreenModel<ScreenStates.EmptyDomain, ScreenStates.EmptyUIList, IOData.EmptyOutput>(EmptyListStateMapper()) {
override val initialState = ScreenStates.EmptyDomain
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2022 Revolut
*
* 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.
*/

package com.revolut.kompot.common

data class ErrorInterceptionEvent(val cause: Throwable): Event()

object ErrorInterceptedEventResult : EventResult
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import android.content.Intent
import android.net.Uri
import android.os.Parcelable
import com.revolut.kompot.ExperimentalBottomDialogStyle
import com.revolut.kompot.ExperimentalKompotApi
import com.revolut.kompot.navigable.Controller
import com.revolut.kompot.navigable.TransitionAnimation
import com.revolut.kompot.navigable.flow.Flow
import com.revolut.kompot.navigable.flow.scroller.ScrollerFlow
import com.revolut.kompot.navigable.screen.Screen
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.RawValue

interface NavigationDestination
Expand All @@ -43,26 +45,41 @@ abstract class InternalDestination<INPUT : IOData.Input>(
) : NavigationDestination, Parcelable {
@IgnoredOnParcel
open val animation: TransitionAnimation? = null

@IgnoredOnParcel
open val addCurrentStepToBackStack: Boolean = true
}

sealed class ModalDestination : NavigationDestination {
data class ExplicitScreen<T : IOData.Output>(
val screen: Screen<T>,
val style: Style = Style.FULLSCREEN,
val style: Style = Style.FULLSCREEN_FADE,
val onResult: ((T) -> Unit)? = null
) : ModalDestination()

data class ExplicitFlow<T : IOData.Output>(
val flow: Flow<T>,
val style: Style = Style.FULLSCREEN,
val style: Style = Style.FULLSCREEN_FADE,
val onResult: ((T) -> Unit)? = null
) : ModalDestination()

@OptIn(ExperimentalKompotApi::class)
data class ExplicitScrollerFlow<T : IOData.Output>(
val flow: ScrollerFlow<T>,
val style: Style = Style.FULLSCREEN_FADE,
val onResult: ((T) -> Unit)? = null
) : ModalDestination()

data class CallbackController(
val controller: Controller,
val style: Style = Style.FULLSCREEN_FADE,
) : ModalDestination()

enum class Style {
FULLSCREEN,
FULLSCREEN_FADE,
FULLSCREEN_IMMEDIATE,
POPUP,
FULLSCREEN_SLIDE_FROM_BOTTOM,

@ExperimentalBottomDialogStyle
BOTTOM_DIALOG,
Expand Down
Loading
Loading