Skip to content

Commit

Permalink
Set max width for RA login dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelvcaetano committed Dec 2, 2024
1 parent 106521b commit 48bddfc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.magnum.melonds.ui.romdetails.ui
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
Expand All @@ -13,6 +14,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import me.magnum.melonds.R
import me.magnum.melonds.ui.common.autofill
import me.magnum.melonds.ui.common.melonOutlinedTextFieldColors
Expand All @@ -24,22 +26,23 @@ fun RetroAchievementsLoginDialog(
onDismiss: () -> Unit,
onLogin: (username: String, password: String) -> Unit,
) {
var username by remember {
var username by rememberSaveable {
mutableStateOf("")
}
var password by remember {
mutableStateOf("")
}

Dialog(onDismissRequest = onDismiss) {
Card(
modifier = Modifier.fillMaxWidth()
) {
Column(Modifier.fillMaxWidth()) {
Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(usePlatformDefaultWidth = false),
) {
Card(Modifier.widthIn(max = 450.dp).fillMaxWidth(0.85f)) {
Column {
Box(
modifier = Modifier
.heightIn(min = 64.dp)
.padding(start = 24.dp, end = 24.dp),
.padding(horizontal = 24.dp),
contentAlignment = Alignment.CenterStart,
) {
Text(
Expand All @@ -57,10 +60,12 @@ fun RetroAchievementsLoginDialog(
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
OutlinedTextField(
modifier = Modifier.autofill(
autofillTypes = listOf(AutofillType.Username),
onFill = { username = it },
),
modifier = Modifier
.fillMaxWidth()
.autofill(
autofillTypes = listOf(AutofillType.Username),
onFill = { username = it },
),
value = username,
onValueChange = { username = it },
colors = melonOutlinedTextFieldColors(),
Expand All @@ -70,10 +75,12 @@ fun RetroAchievementsLoginDialog(
)

OutlinedTextField(
modifier = Modifier.autofill(
autofillTypes = listOf(AutofillType.Password),
onFill = { password = it },
),
modifier = Modifier
.fillMaxWidth()
.autofill(
autofillTypes = listOf(AutofillType.Password),
onFill = { password = it },
),
value = password,
onValueChange = { password = it },
visualTransformation = PasswordVisualTransformation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -66,7 +67,7 @@ private fun LoggedOut(
modifier: Modifier,
onLogin: (username: String, password: String) -> Unit,
) {
var showLoginPopup by remember {
var showLoginPopup by rememberSaveable {
mutableStateOf(false)
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commonsCompress = "1.21"
composeBom = "2024.11.00"
constraintLayout = "2.2.0"
core = "1.13.1"
desugaring = "1.1.8"
desugaring = "2.1.3"
documentFile = "1.0.1"
flexbox = "3.0.0"
fragment = "1.8.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import me.magnum.rcheevosapi.dto.AchievementDto
import me.magnum.rcheevosapi.model.RAAchievement
import me.magnum.rcheevosapi.model.RAGameId
import java.net.URI
import java.net.URL

internal fun AchievementDto.mapToModel(gameId: RAGameId): RAAchievement {
return RAAchievement(
Expand Down

0 comments on commit 48bddfc

Please sign in to comment.