From 66a0fcfd37ef827a42bc4eb46db448f719ff1e45 Mon Sep 17 00:00:00 2001 From: sajal Date: Thu, 12 Dec 2024 15:09:08 +0530 Subject: [PATCH] Some minor changes --- wallet_app/app/.gitignore | 3 +- .../com/example/walletapp/ui/WalletApp.kt | 4 +- .../walletapp/ui/account/WalletScreen.kt | 57 +++++++++-------- .../walletapp/ui/transfer/ReceiveScreen.kt | 61 ++++++++++++------- .../walletapp/ui/transfer/SendScreen.kt | 16 ++++- 5 files changed, 88 insertions(+), 53 deletions(-) diff --git a/wallet_app/app/.gitignore b/wallet_app/app/.gitignore index 591843f..3449035 100644 --- a/wallet_app/app/.gitignore +++ b/wallet_app/app/.gitignore @@ -1,2 +1,3 @@ android/app/build -build \ No newline at end of file +build +local.properties \ No newline at end of file diff --git a/wallet_app/app/src/main/java/com/example/walletapp/ui/WalletApp.kt b/wallet_app/app/src/main/java/com/example/walletapp/ui/WalletApp.kt index 8a26af1..51b4ed2 100644 --- a/wallet_app/app/src/main/java/com/example/walletapp/ui/WalletApp.kt +++ b/wallet_app/app/src/main/java/com/example/walletapp/ui/WalletApp.kt @@ -112,10 +112,10 @@ fun WalletApp(tokenViewModel: TokenViewModel) { } composable { - SendScreen(walletViewModel) + SendScreen(walletViewModel,navController) } composable { - ReceiveScreen(modifier = Modifier) + ReceiveScreen(modifier = Modifier,navController) } } } diff --git a/wallet_app/app/src/main/java/com/example/walletapp/ui/account/WalletScreen.kt b/wallet_app/app/src/main/java/com/example/walletapp/ui/account/WalletScreen.kt index 0de6367..b8d77a6 100644 --- a/wallet_app/app/src/main/java/com/example/walletapp/ui/account/WalletScreen.kt +++ b/wallet_app/app/src/main/java/com/example/walletapp/ui/account/WalletScreen.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -27,7 +26,6 @@ import androidx.compose.material3.Card import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext @@ -52,6 +50,8 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import android.content.ClipData +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.ui.Alignment import androidx.compose.ui.text.toUpperCase import androidx.compose.ui.window.Popup import androidx.compose.ui.window.PopupProperties @@ -174,35 +174,38 @@ fun Wallet(modifier: Modifier, onNewTokenPress: () -> Unit, onReceivePress: () - }.sum() val formatter = NumberFormat.getCurrencyInstance(Locale.US) - Text( - text = formatter.format(totalBalance), - fontFamily = FontFamily(Font(R.font.publicsans_bold)), - color = Color.White, - fontSize = 26.sp, - modifier = Modifier - .align(Alignment.CenterHorizontally) - .padding(top = 70.dp) - ) - Row( - modifier = Modifier.align(Alignment.CenterHorizontally)) { + Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxWidth()) { Text( - text = address.take(8) + "....", - fontFamily = FontFamily(Font(R.font.inter_regular)), + text = formatter.format(totalBalance), + fontFamily = FontFamily(Font(R.font.publicsans_bold)), color = Color.White, - fontSize = 12.sp, - ) - Icon( - painter = painterResource(R.drawable.copy),// replace with your Ethereum icon - contentDescription = null, - tint=Color.White, - modifier = Modifier.padding(start=5.dp) - .size(15.dp).clickable { - val clip = ClipEntry(ClipData.newPlainText("Wallet Address", address)) - clipboard.setClip(clip) - Toast.makeText(context, "Address Copied", Toast.LENGTH_LONG).show() - } + fontSize = 26.sp, + modifier = Modifier + .align(Alignment.CenterHorizontally) + .padding(top = 70.dp) ) + Row( + modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center + ) { + Text( + text = address.take(8) + "...", + fontFamily = FontFamily(Font(R.font.inter_regular)), + color = Color.White, + fontSize = 12.sp, + ) + Icon( + painter = painterResource(R.drawable.copy),// replace with your Ethereum icon + contentDescription = null, + tint = Color.White, + modifier = Modifier.padding(start = 5.dp) + .size(15.dp).clickable { + val clip = ClipEntry(ClipData.newPlainText("Wallet Address", address)) + clipboard.setClip(clip) + Toast.makeText(context, "Address Copied", Toast.LENGTH_LONG).show() + } + ) + } } Spacer(modifier = Modifier.height(32.dp)) diff --git a/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/ReceiveScreen.kt b/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/ReceiveScreen.kt index f579d65..63f7615 100644 --- a/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/ReceiveScreen.kt +++ b/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/ReceiveScreen.kt @@ -8,11 +8,17 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row 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.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -29,11 +35,12 @@ 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.navigation.NavController import com.example.walletapp.BuildConfig import com.example.walletapp.R @Composable -fun ReceiveScreen(modifier: Modifier) { +fun ReceiveScreen(modifier: Modifier,navController: NavController) { val clipboard: ClipboardManager = LocalClipboardManager.current val context= LocalContext.current val address= BuildConfig.ACCOUNT_ADDRESS @@ -45,8 +52,19 @@ fun ReceiveScreen(modifier: Modifier) { .background(Color("#0C0C4F".toColorInt())) // Your dark blue background color .padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center ) { + // Back Button + IconButton( + onClick = { navController.navigateUp() }, + modifier = Modifier.align(Alignment.Start) + ) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = "Back", + tint = Color.White + ) + } + Spacer(modifier = Modifier.height(40.dp)) // QR Code Image Box( modifier = Modifier @@ -62,28 +80,27 @@ fun ReceiveScreen(modifier: Modifier) { Spacer(modifier = Modifier.height(24.dp)) - // Wallet Address - Text( - text = address.take(8) + "....", - fontFamily = FontFamily(Font(R.font.publicsans_bold)), - color = Color.White, - fontSize = 40.sp - ) - Spacer(modifier = Modifier.height(8.dp)) + Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center) { + Text( + text = address.take(8) + "...", + fontFamily = FontFamily(Font(R.font.publicsans_bold)), + color = Color.White, + fontSize = 30.sp + ) + Icon( + painter = painterResource(R.drawable.copy),// replace with your Ethereum icon + contentDescription = null, + tint=Color.White, + modifier = Modifier.padding(start=5.dp) + .size(25.dp).clickable { + val clip = ClipEntry(ClipData.newPlainText("Wallet Address", address)) + clipboard.setClip(clip) + Toast.makeText(context, "Address Copied", Toast.LENGTH_LONG).show() + } + ) - // Clickable Text for Copy - Text( - text = "Click to copy address", - fontFamily = FontFamily(Font(R.font.publicsans_regular)), - color = Color.White, - fontSize = 15.sp, - modifier = Modifier.clickable { - val clip = ClipEntry(ClipData.newPlainText("Wallet Address", address)) - clipboard.setClip(clip) - Toast.makeText(context, "Address Copied", Toast.LENGTH_LONG).show() - } - ) + } } } diff --git a/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/SendScreen.kt b/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/SendScreen.kt index 3162557..e8d6a2c 100644 --- a/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/SendScreen.kt +++ b/wallet_app/app/src/main/java/com/example/walletapp/ui/transfer/SendScreen.kt @@ -44,12 +44,15 @@ import com.example.walletapp.R import com.example.walletapp.ui.account.WalletViewModel import android.widget.Toast import androidx.compose.foundation.layout.Box +import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.IconButton import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext +import androidx.navigation.NavController import com.example.walletapp.utils.etherToWei import com.example.walletapp.utils.isValidEthereumAddress import com.swmansion.starknet.account.StandardAccount @@ -63,7 +66,7 @@ import java.math.BigDecimal @Composable -fun SendScreen(walletViewModel: WalletViewModel) { +fun SendScreen(walletViewModel: WalletViewModel,navController: NavController) { val balances by walletViewModel.balances.collectAsState() val address= BuildConfig.ACCOUNT_ADDRESS @@ -143,6 +146,17 @@ fun SendScreen(walletViewModel: WalletViewModel) { horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { + // Back Button + IconButton( + onClick = { navController.navigateUp() }, + modifier = Modifier.align(Alignment.Start) + ) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = "Back", + tint = Color.White + ) + } Spacer(modifier = Modifier.height(40.dp)) // "From" label above the wallet address field (readonly)