update import screen

This commit is contained in:
2026-05-26 08:58:34 +07:00
parent c07c8a549c
commit e192ca6844
2 changed files with 155 additions and 127 deletions

View File

@@ -7,11 +7,14 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
@@ -40,7 +43,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@@ -58,6 +63,7 @@ import su.reya.coop.LocalNostrViewModel
import su.reya.coop.LocalSnackbarHostState import su.reya.coop.LocalSnackbarHostState
import su.reya.coop.Screen import su.reya.coop.Screen
import su.reya.coop.shared.Avatar import su.reya.coop.shared.Avatar
import su.reya.coop.shared.getExpressiveFontFamily
import su.reya.coop.short import su.reya.coop.short
@OptIn(ExperimentalMaterial3ExpressiveApi::class) @OptIn(ExperimentalMaterial3ExpressiveApi::class)
@@ -69,6 +75,7 @@ fun ImportScreen(
) { ) {
val snackbarHostState = LocalSnackbarHostState.current val snackbarHostState = LocalSnackbarHostState.current
val navController = LocalNavController.current val navController = LocalNavController.current
val focusManager = LocalFocusManager.current
val viewModel = LocalNostrViewModel.current val viewModel = LocalNostrViewModel.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
@@ -145,40 +152,44 @@ fun ImportScreen(
}, },
content = { innerPadding -> content = { innerPadding ->
Column( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier
.fillMaxSize()
.padding(top = innerPadding.calculateTopPadding())
.imePadding(),
) { ) {
Column( Column(
modifier = Modifier modifier = Modifier
.weight(1f)
.fillMaxWidth() .fillMaxWidth()
.padding(top = innerPadding.calculateTopPadding()), .weight(1f),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.size(120.dp) .size(120.dp)
.clip(MaterialShapes.Pentagon.toShape()), .clip(MaterialShapes.Cookie9Sided.toShape()),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Avatar( Avatar(
picture = picture, picture = picture,
description = "Profile picture", description = "Profile picture",
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
shape = MaterialShapes.Pentagon.toShape(), shape = MaterialShapes.Cookie9Sided.toShape(),
) )
} }
Spacer(modifier = Modifier.size(8.dp)) Spacer(modifier = Modifier.size(8.dp))
Text( Text(
text = displayName, text = displayName,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = MaterialTheme.typography.titleLargeEmphasized, style = MaterialTheme.typography.titleLargeEmphasized.copy(
fontFamily = getExpressiveFontFamily()
),
) )
} }
Surface( Surface(
modifier = Modifier modifier = Modifier
.weight(1f) .fillMaxWidth()
.fillMaxWidth(), .weight(1f, fill = false),
color = MaterialTheme.colorScheme.surface, color = MaterialTheme.colorScheme.surface,
shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp),
) { ) {
@@ -186,44 +197,57 @@ fun ImportScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.padding(24.dp) .padding(24.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)
) { ) {
Text( Column(
text = "Enter your Secret Key or Bunker URI:", modifier = Modifier
style = MaterialTheme.typography.titleMediumEmphasized.copy( .weight(1f)
fontWeight = FontWeight.SemiBold, .verticalScroll(rememberScrollState()),
), verticalArrangement = Arrangement.spacedBy(16.dp)
) ) {
BasicTextField( Text(
value = secret, text = "Enter your Secret Key or Bunker URI:",
onValueChange = { secret = it }, style = MaterialTheme.typography.titleMediumEmphasized.copy(
modifier = Modifier.fillMaxWidth(), fontWeight = FontWeight.SemiBold,
maxLines = 4, ),
visualTransformation = PasswordVisualTransformation('*'), )
textStyle = MaterialTheme.typography.bodyMediumEmphasized.copy( BasicTextField(
color = MaterialTheme.colorScheme.primaryFixed, value = secret,
fontWeight = FontWeight.SemiBold, onValueChange = { secret = it },
), modifier = Modifier.fillMaxWidth(),
cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary), maxLines = 4,
decorationBox = { innerTextField -> keyboardOptions = KeyboardOptions(
Box(contentAlignment = Alignment.CenterStart) { imeAction = ImeAction.Done,
if (secret.isEmpty()) { ),
Text( keyboardActions = KeyboardActions(
"bunker://", onDone = {
style = MaterialTheme.typography.bodyMediumEmphasized.copy( focusManager.clearFocus()
fontWeight = FontWeight.SemiBold, }
), ),
color = MaterialTheme.colorScheme.onSurfaceVariant.copy( visualTransformation = PasswordVisualTransformation('*'),
alpha = 0.5f textStyle = MaterialTheme.typography.bodyMediumEmphasized.copy(
) color = MaterialTheme.colorScheme.primaryFixed,
) fontWeight = FontWeight.SemiBold,
),
cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary),
decorationBox = { innerTextField ->
Box(contentAlignment = Alignment.CenterStart) {
if (secret.isEmpty()) {
Text(
"bunker://",
style = MaterialTheme.typography.bodyMediumEmphasized.copy(
fontWeight = FontWeight.SemiBold,
),
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(
alpha = 0.5f
)
)
}
innerTextField()
} }
innerTextField()
} }
} )
) }
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.size(16.dp))
Button( Button(
onClick = { onClick = {
if (pubkey == null) { if (pubkey == null) {

View File

@@ -148,7 +148,7 @@ fun NewIdentityScreen(
Surface( Surface(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.weight(1f, fill = false), .weight(1f, fill = true),
color = MaterialTheme.colorScheme.surface, color = MaterialTheme.colorScheme.surface,
shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp),
) { ) {
@@ -156,94 +156,98 @@ fun NewIdentityScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.padding(24.dp) .padding(24.dp)
.imePadding()
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)
) { ) {
Text( Column(
text = "What others should call you?", modifier = Modifier
style = MaterialTheme.typography.titleLargeEmphasized.copy( .weight(1f)
fontWeight = FontWeight.SemiBold, .verticalScroll(rememberScrollState()),
), verticalArrangement = Arrangement.spacedBy(16.dp)
) ) {
BasicTextField( Text(
value = name, text = "What others should call you?",
onValueChange = { name = it }, style = MaterialTheme.typography.titleLargeEmphasized.copy(
modifier = Modifier.fillMaxWidth(), fontWeight = FontWeight.SemiBold,
singleLine = true, ),
keyboardOptions = KeyboardOptions( )
imeAction = ImeAction.Done, BasicTextField(
), value = name,
keyboardActions = KeyboardActions( onValueChange = { name = it },
onDone = { modifier = Modifier.fillMaxWidth(),
focusManager.clearFocus() singleLine = true,
} keyboardOptions = KeyboardOptions(
), imeAction = ImeAction.Done,
textStyle = MaterialTheme.typography.headlineLargeEmphasized.copy( ),
color = MaterialTheme.colorScheme.primaryFixed, keyboardActions = KeyboardActions(
fontWeight = FontWeight.SemiBold, onDone = {
), focusManager.clearFocus()
cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary),
decorationBox = { innerTextField ->
Box(contentAlignment = Alignment.CenterStart) {
if (name.isEmpty()) {
Text(
"Alice",
style = MaterialTheme.typography.headlineLargeEmphasized.copy(
fontWeight = FontWeight.SemiBold,
),
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(
alpha = 0.5f
)
)
} }
innerTextField() ),
} textStyle = MaterialTheme.typography.headlineLargeEmphasized.copy(
} color = MaterialTheme.colorScheme.primaryFixed,
) fontWeight = FontWeight.SemiBold,
Spacer(modifier = Modifier.size(8.dp)) ),
Text( cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary),
text = "Your bio (optional)", decorationBox = { innerTextField ->
style = MaterialTheme.typography.titleLargeEmphasized.copy( Box(contentAlignment = Alignment.CenterStart) {
fontWeight = FontWeight.SemiBold, if (name.isEmpty()) {
), Text(
) "Alice",
BasicTextField( style = MaterialTheme.typography.headlineLargeEmphasized.copy(
value = bio, fontWeight = FontWeight.SemiBold,
onValueChange = { bio = it }, ),
modifier = Modifier.fillMaxWidth(), color = MaterialTheme.colorScheme.onSurfaceVariant.copy(
maxLines = 3, alpha = 0.5f
keyboardOptions = KeyboardOptions( )
imeAction = ImeAction.Done,
),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
}
),
textStyle = MaterialTheme.typography.bodyLarge.copy(
color = MaterialTheme.colorScheme.primaryFixed,
fontWeight = FontWeight.SemiBold,
),
cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary),
decorationBox = { innerTextField ->
Box(contentAlignment = Alignment.CenterStart) {
if (bio.isEmpty()) {
Text(
"I love cat",
style = MaterialTheme.typography.headlineLargeEmphasized.copy(
fontWeight = FontWeight.SemiBold,
),
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(
alpha = 0.5f
) )
) }
innerTextField()
} }
innerTextField()
} }
} )
) Spacer(modifier = Modifier.size(8.dp))
Spacer(modifier = Modifier.weight(1f)) Text(
text = "Your bio (optional)",
style = MaterialTheme.typography.titleLargeEmphasized.copy(
fontWeight = FontWeight.SemiBold,
),
)
BasicTextField(
value = bio,
onValueChange = { bio = it },
modifier = Modifier.fillMaxWidth(),
maxLines = 3,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
}
),
textStyle = MaterialTheme.typography.bodyLarge.copy(
color = MaterialTheme.colorScheme.primaryFixed,
fontWeight = FontWeight.SemiBold,
),
cursorBrush = SolidColor(MaterialTheme.colorScheme.secondary),
decorationBox = { innerTextField ->
Box(contentAlignment = Alignment.CenterStart) {
if (bio.isEmpty()) {
Text(
"I love cat",
style = MaterialTheme.typography.headlineLargeEmphasized.copy(
fontWeight = FontWeight.SemiBold,
),
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(
alpha = 0.5f
)
)
}
innerTextField()
}
}
)
}
Spacer(modifier = Modifier.size(16.dp))
Button( Button(
onClick = { onClick = {
onSave(name, bio, picture) onSave(name, bio, picture)