Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Token Import Implementation #68

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion wallet_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
android:name=".ReceiverActivity"
android:exported="true"
android:theme="@style/Theme.Walletapp"/>
<activity android:name=".AddTokenActivity"
android:exported="true"
android:theme="@style/Theme.Walletapp"/>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -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)
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down