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

Better AuthorizeGoogleTasksButton layout #77

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MainActivity : AppCompatActivity() {
when (userState) {
null -> LoadingPane()

is UserState.Unsigned,
UserState.Unsigned,
is UserState.SignedIn -> {
val aboutApp = AboutApp(
name = getString(R.string.app_name),
Expand All @@ -77,7 +77,7 @@ class MainActivity : AppCompatActivity() {
TasksApp(aboutApp, userViewModel, tasksViewModel)
}

is UserState.Newcomer -> AuthorizationScreen(
UserState.Newcomer -> AuthorizationScreen(
onSkip = userViewModel::skipSignIn,
onSuccess = userViewModel::signIn,
)
Expand Down
4 changes: 2 additions & 2 deletions tasks-app-desktop/src/main/kotlin/mainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fun main() {
when (userState) {
null -> LoadingPane()

is UserState.Unsigned,
UserState.Unsigned,
is UserState.SignedIn -> {
val aboutApp = AboutApp(
name = appName,
Expand All @@ -136,7 +136,7 @@ fun main() {
TasksApp(aboutApp, userViewModel, tasksViewModel)
}

is UserState.Newcomer -> AuthorizationScreen(
UserState.Newcomer -> AuthorizationScreen(
onSkip = userViewModel::skipSignIn,
onSuccess = userViewModel::signIn,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -95,12 +96,7 @@ actual fun AuthorizeGoogleTasksButton(
}
}

Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
if (ongoingAuth) {
CircularProgressIndicator(Modifier.size(24.dp), strokeWidth = 1.dp)
} else {
Spacer(Modifier.size(24.dp))
}
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
Button(
onClick = {
ongoingAuth = true
Expand All @@ -127,11 +123,20 @@ actual fun AuthorizeGoogleTasksButton(
},
enabled = !ongoingAuth
) {
Text(stringResource(Res.string.onboarding_screen_authorize_cta))
Box(modifier, contentAlignment = Alignment.Center) {
AnimatedContent(ongoingAuth, label = "authorize_button_content") { ongoing ->
if (ongoing) {
CircularProgressIndicator(Modifier.size(24.dp), strokeWidth = 1.dp)
} else {
Text(stringResource(Res.string.onboarding_screen_authorize_cta))
}
}
}
}

AnimatedContent(error, label = "authorize_error_message") { message ->
Text(message ?: "", color = MaterialTheme.colorScheme.error)
}
}
AnimatedContent(error, label = "authorize_error_message") {
Text(it ?: "")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ package net.opatry.tasks.app.ui.component

import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -60,12 +61,7 @@ actual fun AuthorizeGoogleTasksButton(
var ongoingAuth by remember { mutableStateOf(false) }
var error by remember { mutableStateOf<String?>(null) }

Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
if (ongoingAuth) {
CircularProgressIndicator(Modifier.size(24.dp), strokeWidth = 1.dp)
} else {
Spacer(Modifier.size(24.dp))
}
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
Button(
onClick = {
ongoingAuth = true
Expand All @@ -88,10 +84,19 @@ actual fun AuthorizeGoogleTasksButton(
},
enabled = !ongoingAuth
) {
Text(stringResource(Res.string.onboarding_screen_authorize_cta))
Box(modifier, contentAlignment = Alignment.Center) {
AnimatedContent(ongoingAuth, label = "authorize_button_content") { ongoing ->
if (ongoing) {
CircularProgressIndicator(Modifier.size(24.dp), strokeWidth = 1.dp)
} else {
Text(stringResource(Res.string.onboarding_screen_authorize_cta))
}
}
}
}

AnimatedContent(error, label = "authorize_error_message") { message ->
Text(message ?: "", color = MaterialTheme.colorScheme.error)
}
}
AnimatedContent(error, label = "authorize_error_message") {
Text(it ?: "")
}
}