-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from zsoltk/full-screen-portal
Add support for full screen portals
- Loading branch information
Showing
55 changed files
with
1,156 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/Big.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.badoo.ribs.example.rib.big | ||
|
||
import com.badoo.ribs.core.Rib | ||
import com.badoo.ribs.customisation.CanProvidePortal | ||
import com.badoo.ribs.customisation.CanProvideRibCustomisation | ||
import com.badoo.ribs.customisation.RibCustomisation | ||
|
||
interface Big : Rib { | ||
|
||
interface Dependency : | ||
CanProvideRibCustomisation, | ||
CanProvidePortal | ||
|
||
class Customisation( | ||
val viewFactory: BigView.Factory = BigViewImpl.Factory() | ||
) : RibCustomisation | ||
|
||
interface Workflow | ||
} |
23 changes: 23 additions & 0 deletions
23
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/BigInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.badoo.ribs.example.rib.big | ||
|
||
import android.arch.lifecycle.Lifecycle | ||
import android.os.Bundle | ||
import com.badoo.ribs.core.Interactor | ||
import com.badoo.ribs.core.Router | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration.Content | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration.Overlay | ||
|
||
class BigInteractor( | ||
savedInstanceState: Bundle?, | ||
router: Router<Configuration, *, Content, Overlay, BigView> | ||
) : Interactor<Configuration, Content, Overlay, BigView>( | ||
savedInstanceState = savedInstanceState, | ||
router = router, | ||
disposables = null | ||
) { | ||
|
||
override fun onViewCreated(view: BigView, viewLifecycle: Lifecycle) { | ||
view.accept(BigView.ViewModel("My id: " + id.replace("${BigInteractor::class.java.name}.", ""))) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/BigNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.badoo.ribs.example.rib.big | ||
|
||
import android.os.Bundle | ||
import android.view.ViewGroup | ||
import com.badoo.ribs.core.Node | ||
|
||
class BigNode( | ||
savedInstanceState: Bundle?, | ||
viewFactory: ((ViewGroup) -> BigView?)?, | ||
private val router: BigRouter, | ||
private val interactor: BigInteractor | ||
) : Node<BigView>( | ||
savedInstanceState = savedInstanceState, | ||
identifier = object : Big {}, | ||
viewFactory = viewFactory, | ||
router = router, | ||
interactor = interactor | ||
), Big.Workflow |
39 changes: 39 additions & 0 deletions
39
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/BigRouter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.badoo.ribs.example.rib.big | ||
|
||
import android.os.Bundle | ||
import android.os.Parcelable | ||
import com.badoo.ribs.core.Router | ||
import com.badoo.ribs.core.routing.action.AttachRibRoutingAction.Companion.attach | ||
import com.badoo.ribs.core.routing.action.RoutingAction | ||
import com.badoo.ribs.core.routing.action.RoutingAction.Companion.noop | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration.Content | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration.Overlay | ||
import com.badoo.ribs.example.rib.big.BigRouter.Configuration.Permanent | ||
import com.badoo.ribs.example.rib.small.builder.SmallBuilder | ||
import kotlinx.android.parcel.Parcelize | ||
|
||
class BigRouter( | ||
savedInstanceState: Bundle?, | ||
private val smallBuilder: SmallBuilder | ||
): Router<Configuration, Permanent, Content, Overlay, BigView>( | ||
savedInstanceState = savedInstanceState, | ||
initialConfiguration = Content.Default, | ||
permanentParts = listOf(Permanent.Small) | ||
) { | ||
sealed class Configuration : Parcelable { | ||
sealed class Permanent : Configuration() { | ||
@Parcelize object Small : Permanent() | ||
} | ||
sealed class Content : Configuration() { | ||
@Parcelize object Default : Content() | ||
} | ||
sealed class Overlay : Configuration() | ||
} | ||
|
||
override fun resolveConfiguration(configuration: Configuration): RoutingAction<BigView> = | ||
when (configuration) { | ||
Permanent.Small -> attach { smallBuilder.build(it) } | ||
Content.Default -> noop() | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/BigView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.badoo.ribs.example.rib.big | ||
|
||
import android.support.annotation.LayoutRes | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import com.badoo.ribs.core.Rib | ||
import com.badoo.ribs.core.view.RibView | ||
import com.badoo.ribs.core.view.ViewFactory | ||
import com.badoo.ribs.customisation.inflate | ||
import com.badoo.ribs.example.R | ||
import com.badoo.ribs.example.rib.big.BigView.Event | ||
import com.badoo.ribs.example.rib.big.BigView.ViewModel | ||
import com.badoo.ribs.example.rib.small.Small | ||
import com.jakewharton.rxrelay2.PublishRelay | ||
import io.reactivex.ObservableSource | ||
import io.reactivex.functions.Consumer | ||
|
||
interface BigView : RibView, | ||
ObservableSource<Event>, | ||
Consumer<ViewModel> { | ||
|
||
sealed class Event | ||
|
||
data class ViewModel( | ||
val text: String | ||
) | ||
|
||
interface Factory : ViewFactory<Nothing?, BigView> | ||
} | ||
|
||
|
||
class BigViewImpl private constructor( | ||
override val androidView: ViewGroup, | ||
private val events: PublishRelay<Event> = PublishRelay.create() | ||
) : BigView, | ||
ObservableSource<Event> by events, | ||
Consumer<ViewModel> { | ||
|
||
class Factory( | ||
@LayoutRes private val layoutRes: Int = R.layout.rib_big | ||
) : BigView.Factory { | ||
override fun invoke(deps: Nothing?): (ViewGroup) -> BigView = { | ||
BigViewImpl( | ||
inflate(it, layoutRes) | ||
) | ||
} | ||
} | ||
|
||
private val idText = androidView.findViewById<TextView>(R.id.big_id) | ||
private val smallContainer = androidView.findViewById<ViewGroup>(R.id.small_container) | ||
|
||
override fun accept(vm: ViewModel) { | ||
idText.text = vm.text | ||
} | ||
|
||
override fun getParentViewForChild(child: Rib): ViewGroup? = | ||
when (child) { | ||
is Small -> smallContainer | ||
else -> null | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/builder/BigBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.badoo.ribs.example.rib.big.builder | ||
|
||
import android.os.Bundle | ||
import com.badoo.ribs.core.Builder | ||
import com.badoo.ribs.customisation.customisationsBranchFor | ||
import com.badoo.ribs.customisation.getOrDefault | ||
import com.badoo.ribs.example.rib.big.Big | ||
import com.badoo.ribs.example.rib.big.BigNode | ||
|
||
class BigBuilder( | ||
dependency: Big.Dependency | ||
) : Builder<Big.Dependency>() { | ||
|
||
override val dependency : Big.Dependency = object : Big.Dependency by dependency { | ||
override fun ribCustomisation() = dependency.customisationsBranchFor(Big::class) | ||
} | ||
|
||
fun build(savedInstanceState: Bundle?): BigNode = | ||
DaggerBigComponent | ||
.factory() | ||
.create( | ||
dependency = dependency, | ||
customisation = dependency.getOrDefault(Big.Customisation()), | ||
savedInstanceState = savedInstanceState | ||
) | ||
.node() | ||
} |
26 changes: 26 additions & 0 deletions
26
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/builder/BigComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.badoo.ribs.example.rib.big.builder | ||
|
||
import android.os.Bundle | ||
import com.badoo.ribs.example.rib.big.Big | ||
import com.badoo.ribs.example.rib.big.BigNode | ||
import com.badoo.ribs.example.rib.small.Small | ||
import dagger.BindsInstance | ||
|
||
@BigScope | ||
@dagger.Component( | ||
modules = [BigModule::class], | ||
dependencies = [Big.Dependency::class] | ||
) | ||
internal interface BigComponent : Small.Dependency { | ||
|
||
@dagger.Component.Factory | ||
interface Factory { | ||
fun create( | ||
dependency: Big.Dependency, | ||
@BindsInstance customisation: Big.Customisation, | ||
@BindsInstance savedInstanceState: Bundle? | ||
): BigComponent | ||
} | ||
|
||
fun node(): BigNode | ||
} |
54 changes: 54 additions & 0 deletions
54
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/builder/BigModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@file:SuppressWarnings("LongParameterList", "LongMethod") | ||
package com.badoo.ribs.example.rib.big.builder | ||
|
||
import android.os.Bundle | ||
import com.badoo.ribs.example.rib.big.Big | ||
import com.badoo.ribs.example.rib.big.BigInteractor | ||
import com.badoo.ribs.example.rib.big.BigNode | ||
import com.badoo.ribs.example.rib.big.BigRouter | ||
import com.badoo.ribs.example.rib.small.builder.SmallBuilder | ||
import dagger.Provides | ||
|
||
@dagger.Module | ||
internal object BigModule { | ||
|
||
@BigScope | ||
@Provides | ||
@JvmStatic | ||
internal fun router( | ||
// pass component to child rib builders, or remove if there are none | ||
component: BigComponent, | ||
savedInstanceState: Bundle? | ||
): BigRouter = | ||
BigRouter( | ||
savedInstanceState = savedInstanceState, | ||
smallBuilder = SmallBuilder(component) | ||
) | ||
|
||
@BigScope | ||
@Provides | ||
@JvmStatic | ||
internal fun interactor( | ||
savedInstanceState: Bundle?, | ||
router: BigRouter | ||
): BigInteractor = | ||
BigInteractor( | ||
savedInstanceState = savedInstanceState, | ||
router = router | ||
) | ||
|
||
@BigScope | ||
@Provides | ||
@JvmStatic | ||
internal fun node( | ||
savedInstanceState: Bundle?, | ||
customisation: Big.Customisation, | ||
router: BigRouter, | ||
interactor: BigInteractor | ||
) : BigNode = BigNode( | ||
savedInstanceState = savedInstanceState, | ||
viewFactory = customisation.viewFactory(null), | ||
router = router, | ||
interactor = interactor | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
android/app-example/src/main/java/com/badoo/ribs/example/rib/big/builder/BigScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.badoo.ribs.example.rib.big.builder | ||
|
||
import javax.inject.Scope | ||
|
||
@Scope | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class BigScope |
Oops, something went wrong.