Skip to content

Commit

Permalink
Add material components to the sample application (#1844)
Browse files Browse the repository at this point in the history
  • Loading branch information
oas004 committed Dec 5, 2023
1 parent a5ace3a commit b0a20b1
Show file tree
Hide file tree
Showing 17 changed files with 1,171 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright 2023 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.google.android.horologist.materialcomponents

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.wear.compose.material.ButtonDefaults
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.material.Button
import com.google.android.horologist.compose.material.ButtonSize

@Composable
internal fun SampleButtonScreen(
modifier: Modifier = Modifier,
columnState: ScalingLazyColumnState,
) {
ScalingLazyColumn(
columnState = columnState,
modifier = modifier.fillMaxSize(),
) {
item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
colors = ButtonDefaults.iconButtonColors(),
)
}
item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
colors = ButtonDefaults.secondaryButtonColors(),
)
}
item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
enabled = false,
)
}

item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
buttonSize = ButtonSize.Custom(
customIconSize = ButtonDefaults.SmallIconSize,
customTapTargetSize = ButtonDefaults.LargeButtonSize,
),
)
}

item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
buttonSize = ButtonSize.Small,
)
}

item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
buttonSize = ButtonSize.Large,
)
}

item {
Button(
imageVector = Icons.Default.Check,
contentDescription = "contentDescription",
onClick = { },
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023 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.google.android.horologist.materialcomponents

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.material.ChipIconWithProgress

@Composable
internal fun SampleChipIconWithProgressScreen(
modifier: Modifier = Modifier,
columnState: ScalingLazyColumnState,
) {
ScalingLazyColumn(
columnState = columnState,
modifier = modifier.fillMaxSize(),
) {
item {
ChipIconWithProgress()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright 2023 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.google.android.horologist.materialcomponents

import android.R
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.materialPath
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.ChipDefaults
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.material.Chip

@Composable
internal fun SampleChipScreen(
modifier: Modifier = Modifier,
columnState: ScalingLazyColumnState,
) {
ScalingLazyColumn(
columnState = columnState,
modifier = modifier.fillMaxSize(),
) {
item {
Chip(
label = "Primary label",
onClick = { },
)
}
item {
Chip(
label = "Primary label",
onClick = { },
icon = Icons.Default.Image,
)
}
item {
Chip(
label = "Primary label",
onClick = { },
icon = Icon32dp,
largeIcon = true,
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icons.Default.Image,
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icon32dp,
largeIcon = true,
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icons.Default.Image,
enabled = false,
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icons.Default.Image,
colors = ChipDefaults.secondaryChipColors(),
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icons.Default.Image,
colors = ChipDefaults.gradientBackgroundChipColors(),
)
}
item {
Chip(
label = "Primary label",
onClick = { },
secondaryLabel = "Secondary label",
icon = Icons.Default.Image,
colors = ChipDefaults.imageBackgroundChipColors(
backgroundImagePainter = painterResource(id = R.drawable.ic_dialog_alert),
),
)
}
}
}

private val Icon32dp: ImageVector
get() = ImageVector.Builder(
name = "Icon Large",
defaultWidth = 32f.dp,
defaultHeight = 32f.dp,
viewportWidth = 32f,
viewportHeight = 32f,
)
.materialPath {
horizontalLineToRelative(32.0f)
verticalLineToRelative(32.0f)
horizontalLineTo(0.0f)
close()
}
.build()
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2023 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.google.android.horologist.materialcomponents

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.material.CompactChip

@Composable
internal fun SampleCompactChipScreen(
modifier: Modifier = Modifier,
columnState: ScalingLazyColumnState,
) {
ScalingLazyColumn(
columnState = columnState,
modifier = modifier.fillMaxSize(),
) {
item {
CompactChip(
label = "Primary label",
onClick = { },
)
}
item {
CompactChip(
label = "Primary label",
onClick = { },
icon = Icons.Filled.Add,
)
}
item {
CompactChip(
onClick = { },
icon = Icons.Filled.Add,
contentDescription = "contentDescription",
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2023 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.google.android.horologist.materialcomponents

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.wear.compose.material.Text
import com.google.android.horologist.compose.material.Confirmation

@Composable
internal fun SampleConfirmationScreen(
modifier: Modifier = Modifier,
) {
Confirmation(
modifier = modifier.fillMaxSize(),
onTimeout = {},
) {
ConfirmationContent()
}
}

@Composable
private fun ConfirmationContent() {
Text(text = "Confirmation Content")
}
Loading

0 comments on commit b0a20b1

Please sign in to comment.