From 133958982734b5901d101dea3e2cc91affd0481b Mon Sep 17 00:00:00 2001 From: lauchaves Date: Thu, 29 Aug 2024 23:03:52 -0600 Subject: [PATCH] Feat: Add new tokens - Wallet app --- .../android/app/src/main/AndroidManifest.xml | 5 +- .../com/example/walletapp/AddTokenActivity.kt | 163 ++++++++++++++++++ .../com/example/walletapp/MainActivity.kt | 18 ++ 3 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 wallet_app/android/app/src/main/java/com/example/walletapp/AddTokenActivity.kt diff --git a/wallet_app/android/app/src/main/AndroidManifest.xml b/wallet_app/android/app/src/main/AndroidManifest.xml index b994d79..e6da76a 100644 --- a/wallet_app/android/app/src/main/AndroidManifest.xml +++ b/wallet_app/android/app/src/main/AndroidManifest.xml @@ -29,6 +29,9 @@ android:name=".ReceiverActivity" android:exported="true" android:theme="@style/Theme.Walletapp"/> + - \ No newline at end of file + diff --git a/wallet_app/android/app/src/main/java/com/example/walletapp/AddTokenActivity.kt b/wallet_app/android/app/src/main/java/com/example/walletapp/AddTokenActivity.kt new file mode 100644 index 0000000..4877667 --- /dev/null +++ b/wallet_app/android/app/src/main/java/com/example/walletapp/AddTokenActivity.kt @@ -0,0 +1,163 @@ +package com.example.walletapp + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.material.TextField +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.core.graphics.toColorInt +import androidx.core.view.WindowCompat +import com.example.walletapp.ui.theme.WalletappTheme + +class AddTokenActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + WindowCompat.setDecorFitsSystemWindows(window, true) + setContent { + WalletappTheme { + Surface(modifier = Modifier.fillMaxSize()) { + AddTokenScreenView(modifier = Modifier.padding(10.dp)) + } + + } + } + } +} + +@Composable +fun SimpleTextField( + value: String, + onValueChange: (String) -> Unit, + label: String, + placeholder: String +) { + Column( + modifier = Modifier.fillMaxWidth() + ) { + Text( + text = label, + color = Color.White, + fontFamily = FontFamily(Font(R.font.publicsans_regular)), + fontSize = 16.sp, + modifier = Modifier.padding(bottom = 10.dp) + ) + TextField( + value = value, + onValueChange = onValueChange, + placeholder = { Text(text = placeholder) }, + colors = TextFieldDefaults.outlinedTextFieldColors( + backgroundColor = Color("#1B1B76".toColorInt()), + focusedBorderColor = Color.Transparent, + unfocusedBorderColor = Color.Transparent, + textColor = Color.Black, + placeholderColor = Color("#A9A9A9".toColorInt()) + ), + shape = RoundedCornerShape(15.dp), + modifier = Modifier.fillMaxWidth(), + textStyle = TextStyle( + color = Color.Black, + fontSize = 16.sp + ) + ) + } +} + +@Composable +fun AddTokenScreenView(modifier: Modifier) { + val contactAddress = rememberSaveable { mutableStateOf("") } + val name = rememberSaveable { mutableStateOf("") } + val symbol = rememberSaveable { mutableStateOf("") } + val decimals = rememberSaveable { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .background(Color("#0C0C4F".toColorInt())) + .padding(horizontal = 16.dp, vertical = 24.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Top + ) { + Text( + text = "Add Token", + fontFamily = FontFamily(Font(R.font.publicsans_bold)), + color = Color.White, + fontSize = 28.sp + ) + + Spacer(modifier = Modifier.height(40.dp)) + + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + SimpleTextField( + value = contactAddress.value, + onValueChange = { contactAddress.value = it }, + label = "Contact Address", + placeholder = "0x123" + ) + Spacer(modifier = Modifier.height(16.dp)) + SimpleTextField( + value = name.value, + onValueChange = { name.value = it }, + label = "Name", + placeholder = "Name" + ) + Spacer(modifier = Modifier.height(16.dp)) + SimpleTextField( + value = symbol.value, + onValueChange = { symbol.value = it }, + label = "Symbol", + placeholder = "TOK" + ) + Spacer(modifier = Modifier.height(16.dp)) + SimpleTextField( + value = decimals.value, + onValueChange = { decimals.value = it }, + label = "Decimals", + placeholder = "18" + ) + } + + Spacer(modifier = Modifier.weight(1f)) + + Button( + onClick = { /* Handle confirm action */ }, + colors = ButtonDefaults.buttonColors(backgroundColor = Color("#1B1B76".toColorInt())), + modifier = Modifier + .fillMaxWidth() + .padding(start = 30.dp, end = 30.dp) + ) { + Text(text = "Confirm", color = Color.White) + } + } +} + + diff --git a/wallet_app/android/app/src/main/java/com/example/walletapp/MainActivity.kt b/wallet_app/android/app/src/main/java/com/example/walletapp/MainActivity.kt index 19dff99..8513206 100644 --- a/wallet_app/android/app/src/main/java/com/example/walletapp/MainActivity.kt +++ b/wallet_app/android/app/src/main/java/com/example/walletapp/MainActivity.kt @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.Image import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -93,6 +94,23 @@ fun Wallet( modifier: Modifier) { WalletCard(icon = painterResource(id = R.drawable.token2), amount = "$1.78", exchange = 4.44 , type ="STRK" ) + Spacer(modifier = Modifier.height(32.dp)) + + Text( + text = "+ New Token", + fontFamily = FontFamily(Font(R.font.publicsans_bold)), + color = Color.White, + fontSize = 14.sp, + modifier = Modifier + .clickable { + val intent = Intent(context, AddTokenActivity::class.java) + context.startActivity(intent) + } + .background(Color.Transparent) + .padding(10.dp) + .align(Alignment.CenterHorizontally) + ) + Spacer(modifier = Modifier.weight(1f)) Row(