-
Notifications
You must be signed in to change notification settings - Fork 73
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
Convert STAR sample to KMP #1103
Conversation
It seems anvil doesn't support intermediate source sets
@@ -31,11 +31,17 @@ org.gradle.parallel=true | |||
org.gradle.configureondemand=true | |||
org.gradle.caching=true | |||
|
|||
# Disable noisy DAGP stability warning | |||
dependency.analysis.compatibility=NONE |
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.
Opportunistic noise cleanup
kct = "0.4.0" | ||
kotlin = "1.9.22" | ||
kotlinpoet = "1.15.3" | ||
kotlinx-coroutines = "1.7.3" | ||
ksp = "1.9.22-1.0.16" | ||
ktfmt = "0.46" | ||
ktor = "2.3.7" |
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.
Required for Coil 3, backed by OkHttp on JVM
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" } | ||
leakcanary-android-instrumentation = { module = "com.squareup.leakcanary:leakcanary-android-instrumentation", version.ref = "leakcanary" } | ||
|
||
lints-compose = "com.slack.lint.compose:compose-lint-checks:1.2.0" | ||
|
||
material = "com.google.android.material:material:1.11.0" |
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.
Required for M3 themes in themes.xml
@@ -1,12 +1,25 @@ | |||
// Copyright (C) 2022 Slack Technologies, LLC | |||
// SPDX-License-Identifier: Apache-2.0 | |||
/* |
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.
Fixed this header while I was at it
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.
These theme files are just moved from the star library, unchanged
|
||
@ContributesBinding(AppScope::class) | ||
@SingleIn(AppScope::class) | ||
class InjectedTokenStorage @Inject constructor(storage: Storage<Preferences>) : |
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.
Unfortunately it's not enough to just have one contributed binding in commonJvm
and instead needs to be duplicated in each target
fun ListBenchmarksItemPreview() { | ||
Box { ListBenchmarksItem(ListBenchmarksItemScreen.State(0)) } | ||
} | ||
// @Preview |
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.
Previews are annoyingly not multiplatform compatible. Need to figure out a good solution for these
@CircuitInject(screen = AboutScreen::class, scope = AppScope::class) | ||
@Composable | ||
fun About(modifier: Modifier = Modifier) { | ||
Scaffold( |
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 scaffold was redundant, removed opportunistically
*/ | ||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun HorizontalPagerIndicator( |
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.
Copied as accompanist isn't multiplatform
iconButtonContent: @Composable () -> Unit, | ||
) { | ||
// We do nothing on desktop | ||
// TODO maybe we do escaping? |
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'd need to do something that sends an escape event to the window, as that's sorta how I've implemented backstack popping here
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.
Think we'll have to create a back press local so that it can get triggered correctly on the window 🤔
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.
yeah, I think it's out of scope for this PR as a start anyway
This comment was marked as resolved.
This comment was marked as resolved.
} ?: Modifier | ||
} ?: Modifier | ||
} else { | ||
Modifier |
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.
Not sure whats needed but it'd be nice to swipe on the pager via mouse event, or have the little side arrows on desktop.
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.
fun fact that's already implemented, works on android too :P. You can see it in action in the video when the images stop scrolling and start snapping
iconButtonContent: @Composable () -> Unit, | ||
) { | ||
// We do nothing on desktop | ||
// TODO maybe we do escaping? |
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.
Think we'll have to create a back press local so that it can get triggered correctly on the window 🤔
Co-authored-by: Josh Stagg <[email protected]>
This PR converts the STAR sample into a multiplatform project!
The commits are a little winding, so I'd suggest looking at the files changed view for code and commits just for titles/story telling. The line diff is almost entirely just the updated baseline profile as I fixed the missing startup prof along the way.
Highlights
Platform.kt
pattern works well here.Rough edges
Strings.kt
file with our three strings.Map<Class, Provider<Activity>>
.actual
annotations 🤔. This resulted in my needing to support alenient
mode that allows for short name matching on the annotation rather than the fully qualified one. Filed KSP does not read actualized typealias declaration google/ksp#1676.FakeFileSystem
for token storage 🤷.TODO
check
invokes the double kapt jvm/android issue. Probably need to just disable the desktop target by default and make it opt-in for building locally.output.mp4