-
Notifications
You must be signed in to change notification settings - Fork 581
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
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7eb2e10
Add component audit previews
37dda0d
Merge branch 'main' into ataulm/component-audit
0b28918
Add 3 golden tiles
bbc1842
Spotless checks
a94f21b
Add TODOs for the remaining tiles
6ee6acf
Add run tile
c5540f6
Add Ski layout
57610fe
Add simple heart rate tile layout
b324e27
Add meditation chips layout
1ed0bc9
Add meditation buttons Golden Tile layout
3a571f6
Add timer golden tile
481509f
Add Alarm tile
0a8eb41
Add alarm, news and weather tiles
4add77d
Add Calendar tile
9f2caa7
Add social tile
9531106
Add media tile
0a7c3aa
Remove color file
42188bd
Remove unused import
85933b9
Split GoldenTiles into separate files to make it easier for AS RAM
0322bfa
Fix incorrect colors for MeditationChips tile
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
215 changes: 215 additions & 0 deletions
215
WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/components/ComponentAudit.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,215 @@ | ||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.wear.tiles.components | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.wear.tiles.material.Button | ||
import androidx.wear.tiles.material.ButtonColors | ||
import androidx.wear.tiles.material.ButtonDefaults | ||
import androidx.wear.tiles.material.Chip | ||
import androidx.wear.tiles.material.ChipColors | ||
import androidx.wear.tiles.material.Colors | ||
import androidx.wear.tiles.material.CompactChip | ||
import androidx.wear.tiles.material.TitleChip | ||
import com.example.wear.tiles.R | ||
import com.example.wear.tiles.emptyClickable | ||
import com.example.wear.tiles.tools.WearSmallRoundDevicePreview | ||
import com.google.android.horologist.compose.tools.LayoutElementPreview | ||
import com.google.android.horologist.compose.tools.buildDeviceParameters | ||
import com.google.android.horologist.tiles.images.drawableResToImageResource | ||
|
||
private const val ICON_CHECK = "check" | ||
private const val IMAGE_AVATAR = "avatar" | ||
|
||
private fun debugTheme(context: Context) = Colors( | ||
/* primary = */ android.graphics.Color.parseColor("#FFCF48"), | ||
/* onPrimary = */ android.graphics.Color.parseColor("#000000"), | ||
/* surface = */ android.graphics.Color.parseColor("#414A4C"), | ||
/* onSurface = */ android.graphics.Color.parseColor("#FFFFFF") | ||
) | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ButtonDefaultPrimary() { | ||
val context = LocalContext.current | ||
LayoutElementPreview( | ||
Button.Builder(context, emptyClickable) | ||
.setIconContent(ICON_CHECK) | ||
.build() | ||
) { | ||
addIdToImageMapping(ICON_CHECK, drawableResToImageResource(R.drawable.ic_baseline_check_24)) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ButtonLargeSecondary() { | ||
val context = LocalContext.current | ||
LayoutElementPreview( | ||
Button.Builder(context, emptyClickable) | ||
.setIconContent(ICON_CHECK) | ||
.setSize(ButtonDefaults.LARGE_SIZE) | ||
// secondary colors from our debug theme | ||
.setButtonColors(ButtonColors.secondaryButtonColors(debugTheme(context))) | ||
.build() | ||
) { | ||
addIdToImageMapping(ICON_CHECK, drawableResToImageResource(R.drawable.ic_baseline_check_24)) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ButtonDefaultImage() { | ||
val context = LocalContext.current | ||
LayoutElementPreview( | ||
Button.Builder(context, emptyClickable) | ||
.setImageContent(IMAGE_AVATAR) | ||
.build() | ||
) { | ||
addIdToImageMapping(IMAGE_AVATAR, drawableResToImageResource(R.drawable.avatar)) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun TextButtonDefault() { | ||
val context = LocalContext.current | ||
LayoutElementPreview( | ||
Button.Builder(context, emptyClickable) | ||
.setTextContent("AZ") | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun TextButtonExtraLarge() { | ||
val context = LocalContext.current | ||
LayoutElementPreview( | ||
Button.Builder(context, emptyClickable) | ||
.setTextContent("AZ") | ||
// default secondary colors (not our theme) | ||
.setButtonColors(ButtonDefaults.SECONDARY_COLORS) | ||
.setSize(ButtonDefaults.EXTRA_LARGE_SIZE) | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ChipOneLine() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
Chip.Builder(context, emptyClickable, deviceParameters) | ||
.setPrimaryLabelContent("Primary label") | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ChipTwoLineLabel() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
Chip.Builder(context, emptyClickable, deviceParameters) | ||
.setChipColors(ChipColors.secondaryChipColors(debugTheme(context))) | ||
.setPrimaryLabelContent("Primary label") | ||
.setSecondaryLabelContent("Secondary label") | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ChipIconOneLine() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
Chip.Builder(context, emptyClickable, deviceParameters) | ||
.setIconContent(ICON_CHECK) | ||
.setPrimaryLabelContent("Primary label") | ||
.build() | ||
) { | ||
addIdToImageMapping(ICON_CHECK, drawableResToImageResource(R.drawable.ic_baseline_check_24)) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun ChipTwoLineIcon() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
Chip.Builder(context, emptyClickable, deviceParameters) | ||
.setIconContent(ICON_CHECK) | ||
.setPrimaryLabelContent("Primary label") | ||
.setSecondaryLabelContent("Secondary label") | ||
.build() | ||
) { | ||
addIdToImageMapping(ICON_CHECK, drawableResToImageResource(R.drawable.ic_baseline_check_24)) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun CompactChip() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
CompactChip.Builder(context, "Primary label", emptyClickable, deviceParameters) | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun CompactChipSecondaryColors() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
CompactChip.Builder(context, "Primary label", emptyClickable, deviceParameters) | ||
.setChipColors(ChipColors.secondaryChipColors(debugTheme(context))) | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun TitleChip() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
TitleChip.Builder(context, "Action", emptyClickable, deviceParameters) | ||
.setChipColors(ChipColors.primaryChipColors(debugTheme(context))) | ||
.build() | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@Composable | ||
fun TitleChipSecondaryColors() { | ||
val context = LocalContext.current | ||
val deviceParameters = buildDeviceParameters(context.resources) | ||
LayoutElementPreview( | ||
TitleChip.Builder(context, "Action", emptyClickable, deviceParameters) | ||
.setChipColors(ChipColors.secondaryChipColors(debugTheme(context))) | ||
.build() | ||
) | ||
} |
122 changes: 122 additions & 0 deletions
122
WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow1.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,122 @@ | ||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.wear.tiles.golden | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import com.example.wear.tiles.R | ||
import com.example.wear.tiles.emptyClickable | ||
import com.example.wear.tiles.tools.WearLargeRoundDevicePreview | ||
import com.example.wear.tiles.tools.WearSmallRoundDevicePreview | ||
import com.google.android.horologist.compose.tools.LayoutRootPreview | ||
import com.google.android.horologist.compose.tools.buildDeviceParameters | ||
import com.google.android.horologist.tiles.images.drawableResToImageResource | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun Goal() { | ||
val context = LocalContext.current | ||
LayoutRootPreview( | ||
Goal.layout(context, context.deviceParams(), steps = 5168, goal = 8000) | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun WorkoutButtons() { | ||
val context = LocalContext.current | ||
LayoutRootPreview( | ||
Workout.buttonsLayout( | ||
context, | ||
context.deviceParams(), | ||
weekSummary = "1 run this week", | ||
button1Clickable = emptyClickable, | ||
button2Clickable = emptyClickable, | ||
button3Clickable = emptyClickable, | ||
chipClickable = emptyClickable, | ||
) | ||
) { | ||
addIdToImageMapping( | ||
Workout.BUTTON_1_ICON_ID, | ||
drawableResToImageResource(R.drawable.ic_run_24) | ||
) | ||
addIdToImageMapping( | ||
Workout.BUTTON_2_ICON_ID, | ||
drawableResToImageResource(R.drawable.ic_yoga_24) | ||
) | ||
addIdToImageMapping( | ||
Workout.BUTTON_3_ICON_ID, | ||
drawableResToImageResource(R.drawable.ic_cycling_24) | ||
) | ||
} | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun WorkoutLargeChip() { | ||
val context = LocalContext.current | ||
LayoutRootPreview( | ||
Workout.largeChipLayout( | ||
context, | ||
context.deviceParams(), | ||
clickable = emptyClickable, | ||
lastWorkoutSummary = "Last session 45m" | ||
) | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun Run() { | ||
val context = LocalContext.current | ||
LayoutRootPreview( | ||
Run.layout( | ||
context, | ||
context.deviceParams(), | ||
lastRunText = "2 days ago", | ||
startRunClickable = emptyClickable, | ||
moreChipClickable = emptyClickable | ||
) | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun Ski() { | ||
val context = LocalContext.current | ||
LayoutRootPreview( | ||
Ski.layout( | ||
context, | ||
stat1 = Ski.Stat("Max Spd", "46.5", "mph"), | ||
stat2 = Ski.Stat("Distance", "21.8", "mile") | ||
) | ||
) | ||
} | ||
|
||
@WearSmallRoundDevicePreview | ||
@WearLargeRoundDevicePreview | ||
@Composable | ||
fun SleepTracker() { | ||
// TODO: yuri has an example of this one | ||
} | ||
|
||
private fun Context.deviceParams() = buildDeviceParameters(resources) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
just alphabetized