Share Username dialog body; make BasicTextField cursor visible in dark mode
- New: shared/ui/UsernameDialogContent.kt (material-free) - Android: use UsernameDialogContent for title/message/input; keep platform buttons - Fix: pass cursorColor (Material color) to shared content so caret is visible in dark theme
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package app.klottr.ui
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.text.BasicText
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* Material-fri dialogkropp för "Välj användarnamn".
|
||||
* - Android/iOS skickar in färger/typografi via TextStyle så natt/dag blir rätt.
|
||||
* - Knappar (Spara/Logga ut) ligger kvar i plattformslagret.
|
||||
*/
|
||||
@Composable
|
||||
fun UsernameDialogContent(
|
||||
titleText: String,
|
||||
messageText: String,
|
||||
input: String,
|
||||
onInputChange: (String) -> Unit,
|
||||
placeholder: String,
|
||||
titleStyle: TextStyle,
|
||||
messageStyle: TextStyle,
|
||||
inputTextStyle: TextStyle,
|
||||
statusText: String?, // "Kontrollerar …" eller fel/OK-rad
|
||||
statusStyle: TextStyle, // Färg väljs av plattformen (error/neutral)
|
||||
cursorColor: Color // Markörfärg (dag/natt från plattform)
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
BasicText(titleText, style = titleStyle)
|
||||
BasicText(messageText, style = messageStyle)
|
||||
|
||||
// Enkel material-fri textinmatning
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
// Etikett
|
||||
BasicText(placeholder, style = messageStyle)
|
||||
// Fält
|
||||
BasicTextField(
|
||||
value = input,
|
||||
onValueChange = onInputChange,
|
||||
textStyle = inputTextStyle,
|
||||
cursorBrush = SolidColor(cursorColor), // Gör markören synlig i mörkt läge
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 2.dp)
|
||||
)
|
||||
}
|
||||
|
||||
if (!statusText.isNullOrBlank()) {
|
||||
BasicText(statusText, style = statusStyle)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user