Skip to content

Commit 46a896e

Browse files
committed
fix visibility cleanup items
1 parent 9680049 commit 46a896e

31 files changed

Lines changed: 230 additions & 59 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.auth0.android.sample.ui.components
2+
3+
import androidx.compose.foundation.BorderStroke
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Box
7+
import androidx.compose.foundation.layout.PaddingValues
8+
import androidx.compose.foundation.layout.Row
9+
import androidx.compose.foundation.layout.Spacer
10+
import androidx.compose.foundation.layout.size
11+
import androidx.compose.foundation.shape.RoundedCornerShape
12+
import androidx.compose.material3.Button
13+
import androidx.compose.material3.ButtonColors
14+
import androidx.compose.material3.ButtonDefaults
15+
import androidx.compose.material3.ButtonElevation
16+
import androidx.compose.material3.CircularProgressIndicator
17+
import androidx.compose.runtime.Composable
18+
import androidx.compose.ui.Alignment
19+
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.graphics.Brush
21+
import androidx.compose.ui.graphics.Color
22+
import androidx.compose.ui.unit.dp
23+
import com.auth0.universalcomponents.theme.Auth0Theme
24+
25+
@Composable
26+
fun SampleGradientButton(
27+
modifier: Modifier = Modifier,
28+
gradient: Brush = Brush.verticalGradient(
29+
colors = listOf(
30+
Color.White.copy(alpha = 0.15f),
31+
Color.Transparent
32+
)
33+
),
34+
buttonDefaultColor: ButtonColors? = null,
35+
shape: RoundedCornerShape? = null,
36+
elevation: ButtonElevation = ButtonDefaults.buttonElevation(
37+
defaultElevation = 0.dp,
38+
pressedElevation = 2.dp
39+
),
40+
isLoading: Boolean = false,
41+
enabled: Boolean = true,
42+
borderStroke: BorderStroke? = null,
43+
onClick: () -> Unit,
44+
content: @Composable () -> Unit,
45+
) {
46+
val colors = Auth0Theme.colors
47+
val dimensions = Auth0Theme.dimensions
48+
val resolvedShape = shape ?: Auth0Theme.shapes.large
49+
50+
val buttonColors = buttonDefaultColor ?: ButtonDefaults.buttonColors(
51+
containerColor = colors.backgroundPrimary,
52+
contentColor = colors.textOnPrimary,
53+
disabledContainerColor = colors.backgroundPrimary.copy(alpha = 0.38f),
54+
disabledContentColor = colors.textOnPrimary.copy(alpha = 0.38f)
55+
)
56+
57+
Button(
58+
modifier = modifier,
59+
colors = buttonColors,
60+
shape = resolvedShape,
61+
contentPadding = PaddingValues(),
62+
elevation = elevation,
63+
enabled = enabled && !isLoading,
64+
border = borderStroke,
65+
onClick = { onClick() },
66+
) {
67+
Box(
68+
modifier = Modifier
69+
.background(gradient)
70+
.then(modifier),
71+
contentAlignment = Alignment.Center,
72+
) {
73+
Row(
74+
horizontalArrangement = Arrangement.Center,
75+
verticalAlignment = Alignment.CenterVertically
76+
) {
77+
if (isLoading) {
78+
CircularProgressIndicator(
79+
modifier = Modifier.size(16.dp),
80+
color = Color.White.copy(alpha = 0.75f),
81+
strokeWidth = 2.dp
82+
)
83+
Spacer(modifier = Modifier.size(dimensions.spacingXs))
84+
} else {
85+
content()
86+
}
87+
}
88+
}
89+
}
90+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.auth0.android.sample.ui.components
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.fillMaxWidth
5+
import androidx.compose.material.icons.Icons
6+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
7+
import androidx.compose.material3.CenterAlignedTopAppBar
8+
import androidx.compose.material3.ExperimentalMaterial3Api
9+
import androidx.compose.material3.HorizontalDivider
10+
import androidx.compose.material3.Icon
11+
import androidx.compose.material3.IconButton
12+
import androidx.compose.material3.MaterialTheme
13+
import androidx.compose.material3.Text
14+
import androidx.compose.material3.TopAppBarDefaults
15+
import androidx.compose.runtime.Composable
16+
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.graphics.painter.Painter
19+
import androidx.compose.ui.text.TextStyle
20+
import androidx.compose.ui.unit.dp
21+
import com.auth0.universalcomponents.theme.Auth0Theme
22+
23+
@OptIn(ExperimentalMaterial3Api::class)
24+
@Composable
25+
fun SampleTopBar(
26+
title: String,
27+
modifier: Modifier = Modifier,
28+
topBarColor: Color = Color.Unspecified,
29+
showSeparator: Boolean = false,
30+
showBackNavigation: Boolean = true,
31+
trailingIcon: Painter? = null,
32+
titleTextStyle: TextStyle? = null,
33+
onBackClick: () -> Unit,
34+
trailingIconClick: () -> Unit = {}
35+
) {
36+
val colors = Auth0Theme.colors
37+
val typography = Auth0Theme.typography
38+
39+
val resolvedTopBarColor = if (topBarColor == Color.Unspecified) colors.backgroundLayerBase else topBarColor
40+
val titleStyle = titleTextStyle ?: typography.title
41+
42+
Column {
43+
CenterAlignedTopAppBar(
44+
title = {
45+
Text(
46+
text = title,
47+
style = titleStyle,
48+
color = colors.textBold
49+
)
50+
},
51+
navigationIcon = {
52+
if (showBackNavigation) {
53+
IconButton(onClick = onBackClick) {
54+
Icon(
55+
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
56+
contentDescription = "Navigate back",
57+
tint = MaterialTheme.colorScheme.onSurface
58+
)
59+
}
60+
}
61+
},
62+
actions = {
63+
if (trailingIcon != null) {
64+
IconButton(onClick = trailingIconClick) {
65+
Icon(
66+
painter = trailingIcon,
67+
contentDescription = "Action",
68+
tint = MaterialTheme.colorScheme.onSurface
69+
)
70+
}
71+
}
72+
},
73+
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
74+
containerColor = resolvedTopBarColor,
75+
),
76+
modifier = modifier
77+
)
78+
if (showSeparator) {
79+
HorizontalDivider(
80+
modifier = Modifier.fillMaxWidth(),
81+
thickness = 0.3.dp,
82+
color = colors.borderDefault
83+
)
84+
}
85+
}
86+
}

app/src/main/java/com/auth0/android/sample/ui/screens/AppearanceScreen.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.unit.dp
2222
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2323
import com.auth0.android.sample.ui.viewmodels.AppearanceViewModel
24-
import com.auth0.universalcomponents.presentation.ui.components.GradientButton
25-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
24+
import com.auth0.android.sample.ui.components.SampleGradientButton
25+
import com.auth0.android.sample.ui.components.SampleTopBar
2626
import com.auth0.android.sample.ui.theme.isAuth0DarkTheme
2727
import com.auth0.universalcomponents.theme.Auth0Theme
2828

@@ -60,7 +60,7 @@ fun AppearanceScreen(
6060

6161
Scaffold(
6262
topBar = {
63-
TopBar(title = "", showBackNavigation = true, onBackClick = onBack)
63+
SampleTopBar(title = "", showBackNavigation = true, onBackClick = onBack)
6464
},
6565
containerColor = colors.backgroundLayerBase
6666
) { padding ->
@@ -137,7 +137,7 @@ fun AppearanceScreen(
137137

138138
Spacer(modifier = Modifier.height(dimensions.spacingLg))
139139

140-
GradientButton(
140+
SampleGradientButton(
141141
modifier = Modifier
142142
.fillMaxWidth()
143143
.height(sizes.buttonHeight),

app/src/main/java/com/auth0/android/sample/ui/screens/DocsScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.material3.Text
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Alignment
1111
import androidx.compose.ui.Modifier
12-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
12+
import com.auth0.android.sample.ui.components.SampleTopBar
1313
import com.auth0.universalcomponents.theme.Auth0Theme
1414

1515
@Composable
@@ -19,7 +19,7 @@ fun DocsScreen(onBack: () -> Unit) {
1919

2020
Scaffold(
2121
topBar = {
22-
TopBar(title = "Docs", onBackClick = onBack)
22+
SampleTopBar(title = "Docs", onBackClick = onBack)
2323
},
2424
containerColor = colors.backgroundLayerBase
2525
) { padding ->

app/src/main/java/com/auth0/android/sample/ui/screens/EmbeddedLoginScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import com.auth0.android.sample.ui.components.Auth0LogoHeader
4040
import com.auth0.android.sample.ui.components.OrDivider
4141
import com.auth0.android.sample.ui.theme.auth0ScreenBackground
4242
import com.auth0.android.sample.ui.theme.isAuth0DarkTheme
43-
import com.auth0.universalcomponents.presentation.ui.components.GradientButton
43+
import com.auth0.android.sample.ui.components.SampleGradientButton
4444
import com.auth0.universalcomponents.theme.Auth0Theme
4545

4646
/**
@@ -222,7 +222,7 @@ fun EmbeddedLoginScreen(
222222
Spacer(modifier = Modifier.height(dimensions.spacingLg))
223223

224224
// Continue button
225-
GradientButton(
225+
SampleGradientButton(
226226
modifier = Modifier
227227
.fillMaxWidth()
228228
.height(sizes.buttonHeight),

app/src/main/java/com/auth0/android/sample/ui/screens/FavoritesScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.material3.Text
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Alignment
1111
import androidx.compose.ui.Modifier
12-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
12+
import com.auth0.android.sample.ui.components.SampleTopBar
1313
import com.auth0.universalcomponents.theme.Auth0Theme
1414

1515
@Composable
@@ -19,7 +19,7 @@ fun FavoritesScreen(onBack: () -> Unit) {
1919

2020
Scaffold(
2121
topBar = {
22-
TopBar(title = "Favorites", onBackClick = onBack)
22+
SampleTopBar(title = "Favorites", onBackClick = onBack)
2323
},
2424
containerColor = colors.backgroundLayerBase
2525
) { padding ->

app/src/main/java/com/auth0/android/sample/ui/screens/ProfileScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import androidx.compose.ui.Modifier
2828
import androidx.compose.ui.graphics.vector.ImageVector
2929
import androidx.compose.ui.text.style.TextAlign
3030
import androidx.compose.ui.unit.dp
31-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
31+
import com.auth0.android.sample.ui.components.SampleTopBar
3232
import com.auth0.universalcomponents.theme.Auth0Theme
3333

3434
/**
@@ -61,7 +61,7 @@ fun ProfileScreen(
6161

6262
Scaffold(
6363
topBar = {
64-
TopBar(title = "", showBackNavigation = true, onBackClick = onBack)
64+
SampleTopBar(title = "", showBackNavigation = true, onBackClick = onBack)
6565
},
6666
containerColor = colors.backgroundLayerBase
6767
) { padding ->

app/src/main/java/com/auth0/android/sample/ui/screens/SessionsScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.material3.Text
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Alignment
1111
import androidx.compose.ui.Modifier
12-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
12+
import com.auth0.android.sample.ui.components.SampleTopBar
1313
import com.auth0.universalcomponents.theme.Auth0Theme
1414

1515
@Composable
@@ -19,7 +19,7 @@ fun SessionsScreen(onBack: () -> Unit) {
1919

2020
Scaffold(
2121
topBar = {
22-
TopBar(title = "Sessions", onBackClick = onBack)
22+
SampleTopBar(title = "Sessions", onBackClick = onBack)
2323
},
2424
containerColor = colors.backgroundLayerBase
2525
) { padding ->

app/src/main/java/com/auth0/android/sample/ui/screens/TokensScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.material3.Text
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Alignment
1111
import androidx.compose.ui.Modifier
12-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
12+
import com.auth0.android.sample.ui.components.SampleTopBar
1313
import com.auth0.universalcomponents.theme.Auth0Theme
1414

1515
@Composable
@@ -19,7 +19,7 @@ fun TokensScreen(onBack: () -> Unit) {
1919

2020
Scaffold(
2121
topBar = {
22-
TopBar(title = "Tokens", onBackClick = onBack)
22+
SampleTopBar(title = "Tokens", onBackClick = onBack)
2323
},
2424
containerColor = colors.backgroundLayerBase
2525
) { padding ->

app/src/main/java/com/auth0/android/sample/ui/screens/UpdateFullNameScreen.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import androidx.compose.runtime.mutableStateOf
1616
import androidx.compose.runtime.saveable.rememberSaveable
1717
import androidx.compose.runtime.setValue
1818
import androidx.compose.ui.Modifier
19-
import com.auth0.universalcomponents.presentation.ui.components.GradientButton
20-
import com.auth0.universalcomponents.presentation.ui.components.TopBar
19+
import com.auth0.android.sample.ui.components.SampleGradientButton
20+
import com.auth0.android.sample.ui.components.SampleTopBar
2121
import com.auth0.universalcomponents.theme.Auth0Theme
2222

2323
/**
@@ -48,7 +48,7 @@ fun UpdateFullNameScreen(
4848

4949
Scaffold(
5050
topBar = {
51-
TopBar(title = "", showBackNavigation = true, onBackClick = onBack)
51+
SampleTopBar(title = "", showBackNavigation = true, onBackClick = onBack)
5252
},
5353
containerColor = colors.backgroundLayerBase
5454
) { padding ->
@@ -114,7 +114,7 @@ fun UpdateFullNameScreen(
114114

115115
Spacer(modifier = Modifier.height(dimensions.spacingXl))
116116

117-
GradientButton(
117+
SampleGradientButton(
118118
modifier = Modifier
119119
.fillMaxWidth()
120120
.height(sizes.buttonHeight),

0 commit comments

Comments
 (0)