Skip to content

Commit

Permalink
Use ResponsiveAlertContent for SignInScreen (#2302)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Jul 18, 2024
1 parent 674a287 commit 7564cbb
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,19 @@

package com.google.android.horologist.auth.ui.common.screens.prompt

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.wear.compose.foundation.lazy.ScalingLazyListScope
import androidx.wear.compose.material.MaterialTheme
import androidx.wear.compose.material.Text
import com.google.android.horologist.auth.composables.R
import com.google.android.horologist.auth.composables.model.AccountUiModel
import com.google.android.horologist.auth.composables.screens.SignInPlaceholderScreen
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults.ItemType
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults.listTextPadding
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults.padding
import com.google.android.horologist.compose.layout.ScreenScaffold
import com.google.android.horologist.compose.layout.rememberResponsiveColumnState
import com.google.android.horologist.compose.material.ListHeaderDefaults.firstItemPadding
import com.google.android.horologist.compose.material.ResponsiveListHeader
import com.google.android.horologist.compose.material.AlertContent

/**
* A screen to prompt users to sign in.
Expand Down Expand Up @@ -93,14 +82,7 @@ public fun SignInPromptScreen(
loadingContent: @Composable () -> Unit = { SignInPlaceholderScreen(modifier = modifier) },
content: ScalingLazyListScope.() -> Unit,
) {
val columnState = rememberResponsiveColumnState(
contentPadding = padding(
first = ItemType.Text,
last = ItemType.Chip,
),
)

ScreenScaffold(timeText = {}, scrollState = columnState) {
ScreenScaffold(timeText = {}) {
when (state) {
SignInPromptScreenState.Idle -> {
SideEffect {
Expand All @@ -121,32 +103,12 @@ public fun SignInPromptScreen(
}

SignInPromptScreenState.SignedOut -> {
ScalingLazyColumn(
columnState = columnState,
AlertContent(
title = title,
message = message,
content = content,
modifier = modifier,
) {
item {
ResponsiveListHeader(contentPadding = firstItemPadding()) {
Text(
text = title,
modifier = Modifier.listTextPadding(),
style = MaterialTheme.typography.button,
overflow = TextOverflow.Ellipsis,
maxLines = 3,
)
}
}
item {
Text(
text = message,
modifier = Modifier.listTextPadding(),
color = MaterialTheme.colors.onBackground,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.body2,
)
}
apply(content)
}
)
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion compose-material/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package com.google.android.horologist.compose.material {

public final class AlertDialogKt {
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void AlertContent(optional kotlin.jvm.functions.Function0<kotlin.Unit>? onCancel, optional kotlin.jvm.functions.Function0<kotlin.Unit>? onOk, optional kotlin.jvm.functions.Function0<kotlin.Unit>? icon, optional String? title, optional String? message, optional String okButtonContentDescription, optional String cancelButtonContentDescription, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState state, optional boolean showPositionIndicator, optional kotlin.jvm.functions.Function1<? super androidx.wear.compose.foundation.lazy.ScalingLazyListScope,kotlin.Unit>? content);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void AlertContent(optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit>? onCancel, optional kotlin.jvm.functions.Function0<kotlin.Unit>? onOk, optional kotlin.jvm.functions.Function0<kotlin.Unit>? icon, optional String? title, optional String? message, optional String okButtonContentDescription, optional String cancelButtonContentDescription, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState state, optional boolean showPositionIndicator, optional kotlin.jvm.functions.Function1<? super androidx.wear.compose.foundation.lazy.ScalingLazyListScope,kotlin.Unit>? content);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void AlertDialog(boolean showDialog, kotlin.jvm.functions.Function0<kotlin.Unit> onDismiss, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit>? icon, optional String? title, optional String? message, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState state, optional kotlin.jvm.functions.Function1<? super androidx.wear.compose.foundation.lazy.ScalingLazyListScope,kotlin.Unit>? content);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void AlertDialog(boolean showDialog, kotlin.jvm.functions.Function0<kotlin.Unit> onCancel, kotlin.jvm.functions.Function0<kotlin.Unit> onOk, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function0<kotlin.Unit>? icon, optional String? title, optional String? message, optional String okButtonContentDescription, optional String cancelButtonContentDescription, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState state, optional kotlin.jvm.functions.Function1<? super androidx.wear.compose.foundation.lazy.ScalingLazyListScope,kotlin.Unit>? content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public fun AlertDialog(
@ExperimentalHorologistApi
@Composable
public fun AlertContent(
modifier: Modifier = Modifier,
onCancel: (() -> Unit)? = null,
onOk: (() -> Unit)? = null,
icon: @Composable (() -> Unit)? = null,
Expand All @@ -144,6 +145,7 @@ public fun AlertContent(
}

ResponsiveDialogContent(
modifier = modifier,
icon = icon,
title = title?.let {
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7564cbb

Please sign in to comment.