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

Add Golden Tiles samples #450

Merged
merged 20 commits into from
Jul 12, 2022
Merged

Add Golden Tiles samples #450

merged 20 commits into from
Jul 12, 2022

Conversation

ataulm
Copy link
Contributor

@ataulm ataulm commented Jul 10, 2022

Screen Shot 2022-07-11 at 05 35 22

This PR adds implementations for each of the Golden Tiles from the Wear Tiles Design Kit

  • Uses a snapshot of androidx tiles material components because of changes that aren't scheduled for new alphas
  • ComponentAudit.kt should only show individual components (e.g. Chip). Layouts will all be covered by GoldenTilesPreviews.kt
  • I've raised bugs for the ones for which I couldn't match the designs
  • I've left two unimplemented: Sleep Tracker and the graph in Heart Rate; they're not showcasing Tile Material Components so there's no rush on these.

image

image

image

image

image

Ataul Munim added 4 commits June 17, 2022 16:19
- replacing functions and utilities which are now in Horologist
- note: this is using a snapshot androidx repo so we can take advantage
  of changes in tiles-material-components
- TODO: add remaining Golden Tiles, and remove component audit
.setPrimaryChipContent(
CompactChip.Builder(context, "More", chipClickable, deviceParameters)
.setChipColors(
ChipColors(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bordering on the don't review for content, but would it be helpful to implement these designs using themes using Colors? then using primary or secondary ChipColors factories?

Copy link
Contributor Author

@ataulm ataulm Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment for this elsewhere. I'm not sure themes for tiles is worth it - as I was implementing all of these, I found it easier to specify colors explicitly.

In a real project, I imagine it'll be even less worth it:

  • a real project won't have many tiles
  • themes aren't directly reusable between Compose/this
  • even if they were reusable, it's not guaranteed that we'd want the same combination of colors
  • tiles (/wear?) is always dark mode and doesn't support dynamic theming (afaik)

I'm not sure what it provides.

Copy link
Contributor Author

@ataulm ataulm Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link you provided here to an example project does help show some utility - https://github.com/yschimke/rememberwear/blob/main/wear/src/main/kotlin/com/google/wear/soyted/tile/RememberWearTileRenderer.kt#L116


I think we should not introduce themes for the Golden Tiles from themes because it'll only serve to showcase the overhead without any of the benefit; unlike your RememberTheMilk project which is sharing a theme with the main app, each Golden Tile is distinct and has its own theme.

There's an example of a theme being created in ComponentAudit.kt which we can leave as-is / improve, since it's used throughout the whole file (there's no requirements/designs for different colors).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IF we want people to be able to take these tiles and copy and paste them, I think it's useful. Or maybe a library of reference tile designs, "templates" that we provide. But your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it for now and we'll revisit if there's feedback. I think these samples should facilitate understanding and we shouldn't necessarily be encouraging copy and pasting.

@yschimke
Copy link
Contributor

Direction looks, great. Would you consider using the Horologist TileRenderer abstraction, should give a nice clean separation for the data of each tile. But can understand why you may not.

fun Goal() {
val context = LocalContext.current
LayoutRootPreview(
Goal.layout(context, context.deviceParams(), steps = 5168, goal = 8000)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any parameter that could change if used as a real tile is exposed.

) {
addIdToImageMapping(
Workout.BUTTON_1_ICON_ID,
drawableResToImageResource(R.drawable.ic_run_24)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we add an ext function to whatever receiver this is?

Foo.addIdToImageMapping(String, @DrawableRes Int)

drawableResToImageResource(@DrawableRes Int) exists in Horologist already. Is the Foo only used for preview or is it the same code that would be used in a renderer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea.

~ limitations under the License.
-->
<resources>
<color name="yellow">#FFCF48</color>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will likely be deleted since we're moving away from color resources in Compose-era.

@ataulm
Copy link
Contributor Author

ataulm commented Jul 10, 2022

Direction looks, great. Would you consider using the Horologist TileRenderer abstraction, should give a nice clean separation for the data of each tile. But can understand why you may not.

Will be able to see when I move onto updating the samples themselves 👍


At the moment, we have 3 samples to showcase 3 layouts which seems like a lot of overhead for showcasing layouts.

When this is merged, we'll have all the Golden Tile layouts, so we can replace the samples so that they use the existing layouts. They can be used to demonstrate common/complex use cases around data stuff, not layouts.

@ataulm ataulm marked this pull request as ready for review July 11, 2022 04:01
@@ -63,29 +63,25 @@ android {
}

dependencies {
implementation libs.horologist.compose.layout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just alphabetized

@ataulm
Copy link
Contributor Author

ataulm commented Jul 12, 2022

Merging this for now so if people come looking for examples following our talk, there's something in the main repo. Will update as necessary following newer snapshots, and of course along with the beta/stable updates.

@ataulm ataulm merged commit b827dff into main Jul 12, 2022
@ataulm ataulm deleted the ataulm/component-audit branch July 12, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants