-
Notifications
You must be signed in to change notification settings - Fork 71
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
Spike compose support #177
base: displayable-generic
Are you sure you want to change the base?
Conversation
c9f26a2
to
0b4bf66
Compare
|
||
internal class IntroStep( | ||
private val goToLearnMore: () -> Unit | ||
) : Step<IntroBinding>(IntroBinding::inflate) { | ||
) : ComposeStep() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first ComposeStep
!
@Composable | ||
internal fun IntroStepContent(goToLearnMore: () -> Unit) { | ||
Button(onClick = goToLearnMore) { | ||
Text("Go to learn more") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, this probably belongs inside the Step
. That way, it can access the data inside the Step
, which we can fake for the previews.
class MyStep : ComposeStep() {
val myDataFlow = StateFlow<MyData>()
@Composable
override fun Compose() {
val myData = myDataFlow.collectAsState()
// Use myData here
}
}
public class SimpleComposeStep(public val Content: @Composable SimpleComposeStep.() -> Unit) : ComposeStep() { | ||
|
||
@Composable | ||
override fun Compose() { | ||
this.Content() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be useful for static content, but that doesn't happen often.
// See https://issuetracker.google.com/issues/176079157#comment11 | ||
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figuring this out took literally TWO AND A HALF MONTHS. Everything else worked from the start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty annoying.
@@ -9,18 +9,22 @@ repositories { | |||
} | |||
|
|||
dependencies { | |||
implementation "com.android.tools.build:gradle:4.1.1" | |||
implementation 'com.android.tools.build:gradle:7.0.0-beta05' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Since AS arctic fox has been released, we can bump this to the stable version. Same with compose 🥳
} | ||
|
||
compileOptions { | ||
setSourceCompatibility(JavaVersion.VERSION_1_8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to bump this to Java 11 for compatibility with arctic fox.
} | ||
} | ||
|
||
@Preview(device = Devices.PIXEL_3, name = "Intro step") | ||
@Composable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably encourage the pattern on annotating the compose function with the preview annotation so that you can look at how the entire step view will look like and if we want to look at other smaller functions we can do that too. Creating a separate method just for the preview might create misdirection when reading the code.
}) | ||
} | ||
|
||
public class ComposeStepWrapper( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the naming of the classes is a bit confusing. But I can't think of better names. Something we might want to revisit later.
This is the gist of my idea for supporting compose. Still a ways to go. :)
Done:
Navigator
andJourney
Not done:
minSdkLevel
low for non-compose packages