Skip to content

Commit

Permalink
FIX: Account information clipboard icons do nothing (#115)
Browse files Browse the repository at this point in the history
Fix clipboard copy

Co-authored-by: lauchaves <[email protected]>
  • Loading branch information
lauchaves and lauchaves authored Oct 29, 2024
1 parent 3fadffd commit e68ef7d
Showing 1 changed file with 60 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import android.content.ClipboardManager
import android.content.ClipData
import android.widget.Toast
import androidx.compose.ui.graphics.painter.Painter
import androidx.core.graphics.toColorInt
import com.example.walletapp.R

Expand Down Expand Up @@ -87,24 +91,28 @@ fun FinalizeAccountCreationScreen(onContinue: () -> Unit) {

@Composable
fun AccountInfoView(onContinue: () -> Unit) {

val context = (LocalContext.current as Activity)
val context = LocalContext.current as Activity
val clipboardManager = LocalContext.current.getSystemService(ClipboardManager::class.java)

var checked by remember { mutableStateOf(true) }
val accountName = "Starknet"
val privateKey = "q78ggh277ibckewjtnM"


Column (
Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier.padding(16.dp)

) {

Text(text= "Account Information", style = TextStyle(color = Color.White, fontWeight = FontWeight.ExtraBold, fontSize = 22.sp))
Text(
text = "Account Information",
style = TextStyle(color = Color.White, fontWeight = FontWeight.ExtraBold, fontSize = 22.sp)
)
Spacer(modifier = Modifier.height(10.dp))
Card (

Card(
backgroundColor = Color("#141462".toColorInt()),
shape = RoundedCornerShape(size = 8.dp),
modifier = Modifier.fillMaxWidth()
modifier = Modifier
.fillMaxWidth()
.background(color = Color("#141462".toColorInt()))
.padding(top = 15.dp, start = 15.dp, end = 15.dp, bottom = 15.dp)
) {
Expand All @@ -113,31 +121,27 @@ fun AccountInfoView(onContinue: () -> Unit) {
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Box(){
Column {
Text(text= "Account name", style = TextStyle(color = Color("#8D8DBB".toColorInt()), fontWeight = FontWeight.Medium, fontSize = 15.sp))
Spacer(modifier = Modifier.height(4.dp))
Text(text= "Starknet", style = TextStyle(color = Color.White, fontWeight = FontWeight.Medium, fontSize = 15.sp))

}
Column {
Text(
text = "Account name",
style = TextStyle(color = Color("#8D8DBB".toColorInt()), fontWeight = FontWeight.Medium, fontSize = 15.sp)
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = accountName,
style = TextStyle(color = Color.White, fontWeight = FontWeight.Medium, fontSize = 15.sp)
)
}

Box(
modifier = Modifier
.width(30.dp)
.height(30.dp)
.background(color = Color.Transparent)
.border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(4.dp))
.padding(4.dp),
) {
IconButton(onClick = {
clipboardManager.setPrimaryClip(ClipData.newPlainText("Account Name", accountName))
Toast.makeText(context, "Account name copied", Toast.LENGTH_SHORT).show()
}) {
Image(
painter = painterResource(id = R.drawable.content_copy),
contentDescription = "Copy",
modifier = Modifier.size(20.dp)
)
}


}

Spacer(modifier = Modifier.height(30.dp))
Expand All @@ -146,167 +150,126 @@ fun AccountInfoView(onContinue: () -> Unit) {
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Box(){
Column {
Text(text= "Private key", style = TextStyle(color = Color("#8D8DBB".toColorInt()), fontWeight = FontWeight.Medium, fontSize = 15.sp))
Spacer(modifier = Modifier.height(4.dp))
Text(text= "q78ggh277ibckewjtnM", style = TextStyle(color = Color.White, fontWeight = FontWeight.Medium, fontSize = 15.sp))

}
Column {
Text(
text = "Private key",
style = TextStyle(color = Color("#8D8DBB".toColorInt()), fontWeight = FontWeight.Medium, fontSize = 15.sp)
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = privateKey,
style = TextStyle(color = Color.White, fontWeight = FontWeight.Medium, fontSize = 15.sp)
)
}


Box(
modifier = Modifier
.width(30.dp)
.height(30.dp)
.background(color = Color.Transparent)
.border(width = 1.dp, color = Color.White, shape = RoundedCornerShape(4.dp))
.padding(4.dp),
) {
IconButton(onClick = {
clipboardManager.setPrimaryClip(ClipData.newPlainText("Private Key", privateKey))
Toast.makeText(context, "Private key copied", Toast.LENGTH_SHORT).show()
}) {
Image(
painter = painterResource(id = R.drawable.content_copy),
contentDescription = "Copy",
modifier = Modifier
.size(20.dp)
modifier = Modifier.size(20.dp)
)
}



}
}
}

Spacer(modifier = Modifier.height(30.dp))

Button(
onClick = {},
colors = ButtonDefaults.buttonColors(backgroundColor = Color("#1B1B76".toColorInt()), contentColor = Color.White),
modifier = Modifier.fillMaxWidth()
.background(color = Color("#141462".toColorInt()))
.height(51.dp)
.border(width = 1.dp, color = Color("#1B1B76".toColorInt()), shape = RoundedCornerShape(8.dp))

) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center


){

) {
Icon(
imageVector = Icons.Filled.Refresh,
contentDescription = "Backward Arrow",
contentDescription = "Generate new key",
modifier = Modifier.padding(start = 8.dp),
tint = Color.White
)

Spacer(modifier = Modifier.width(10.dp))

Text(text = "Generate new private key", style = TextStyle(color = Color("#A3A3C1".toColorInt()), fontSize = 16.sp, fontWeight = FontWeight.Medium))
Text(text = "Generate new private key", style = TextStyle(color = Color("#A3A3C1".toColorInt()), fontSize = 16.sp, fontWeight = FontWeight.Medium))
}
}


Spacer(modifier = Modifier.height(8.dp))



Button(
onClick = { /* TOOD */ },
onClick = { /* TODO */ },
colors = ButtonDefaults.buttonColors(backgroundColor = Color("#1B1B76".toColorInt()), contentColor = Color.White),
modifier = Modifier.fillMaxWidth()
.background(color = Color("#1B1B76".toColorInt()))
.height(51.dp)
.border(width = 1.dp, color = Color("#CBC5C5".toColorInt()), shape = RoundedCornerShape(8.dp))


) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
){

) {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = "Backward Arrow",
contentDescription = "Use existing key",
modifier = Modifier.padding(start = 8.dp),
tint = Color.White
)

Spacer(modifier = Modifier.width(10.dp))

Text(text = "Use existing private key", style = TextStyle(color = Color.White, fontSize = 16.sp,
fontWeight = FontWeight.Medium))
Text(text = "Use existing private key", style = TextStyle(color = Color.White, fontSize = 16.sp, fontWeight = FontWeight.Medium))
}
}

Spacer(modifier = Modifier.height(13.dp))

Box(
modifier = Modifier
.background(color = Color("#221451".toColorInt(), ))
.background(color = Color("#221451".toColorInt()))
.height(74.dp)
.border(width = 1.dp, color = Color("#221451".toColorInt()), shape = RoundedCornerShape(16.dp))
.padding(16.dp)

){
Row(){


) {
Row {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = "Info",
tint = Color("#E45F61".toColorInt())
)


Spacer(modifier = Modifier.width(10.dp))



Text(
text = "Store your private key securely. In case of its lost or stolen, access to funds will be lost without the possibility of recovery",
style = TextStyle(color = Color("#E45F61".toColorInt()), fontSize = 14.sp)
)
}
}


Spacer(modifier = Modifier.height(20.dp))



Row(
verticalAlignment = Alignment.CenterVertically,

) {

Row(verticalAlignment = Alignment.CenterVertically) {
Checkbox(
modifier = Modifier.border(width = 1.dp, color = Color("#54DC84".toColorInt()), shape = RoundedCornerShape(30.dp))
.height(25.dp)
.width(25.dp),
checked = checked,
onCheckedChange = { checked = it },
colors = CheckboxDefaults.colors(checkedColor = Color.Transparent, checkmarkColor = Color("#54DC84".toColorInt())),

)


Spacer(modifier = Modifier.width(10.dp))
Text(
"I have read the information and saved the private key",
style = TextStyle(color = Color.White, fontWeight = FontWeight.Medium, fontSize = 15.sp)
)
}


Spacer(modifier = Modifier.weight(1f))

// TODO(#109): pressing continue on this screen should save the account information to the device
Button(
onClick = onContinue,
contentPadding = ButtonDefaults.ContentPadding,
Expand All @@ -316,9 +279,7 @@ fun AccountInfoView(onContinue: () -> Unit) {
.fillMaxWidth()
.height(49.dp)
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text("Continue")
Icon(
imageVector = Icons.Filled.ArrowForward,
Expand All @@ -329,17 +290,6 @@ fun AccountInfoView(onContinue: () -> Unit) {
}
}


Spacer(modifier = Modifier.height(20.dp))


}

}







0 comments on commit e68ef7d

Please sign in to comment.