-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracts
ScreenViewFactory.map
from ScreenViewFactory.forWrapper
Coupling `Wrapper` to `ScreenViewFactory.forWrapper` was a mistake, made simple transformations that weren't in the strict `Wrapper` shape more difficult. Fixes #973
- Loading branch information
Showing
9 changed files
with
173 additions
and
124 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
11 changes: 5 additions & 6 deletions
11
samples/containers/common/src/main/java/com/squareup/sample/container/panel/ScrimScreen.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 |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package com.squareup.sample.container.panel | ||
|
||
import com.squareup.workflow1.ui.Compatible | ||
import com.squareup.workflow1.ui.Compatible.Companion.keyFor | ||
import com.squareup.workflow1.ui.Screen | ||
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
import com.squareup.workflow1.ui.Wrapper | ||
|
||
/** | ||
* Show a scrim over some [content], which is invisible if [dimmed] is false, | ||
* visible if it is true. | ||
*/ | ||
@OptIn(WorkflowUiExperimentalApi::class) | ||
class ScrimScreen<T : Screen>( | ||
val content: T, | ||
class ScrimScreen<C : Screen>( | ||
override val content: C, | ||
val dimmed: Boolean | ||
) : Screen, Compatible { | ||
override val compatibilityKey = keyFor(content, "ScrimScreen") | ||
) : Wrapper<Screen, C>, Screen { | ||
override fun <D : Screen> map(transform: (C) -> D) = ScrimScreen(transform(content), dimmed) | ||
} |
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
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
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
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
Oops, something went wrong.