Skip to content

Commit

Permalink
Wallet Ui (#39)
Browse files Browse the repository at this point in the history
* Wallet Ui

* Updated dependencies

---------

Co-authored-by: Sajal Bansal <[email protected]>
  • Loading branch information
sajalbnl and sajalbnl authored Aug 13, 2024
1 parent 96ee9a8 commit ff85a27
Show file tree
Hide file tree
Showing 25 changed files with 601 additions and 13 deletions.
1 change: 1 addition & 0 deletions wallet_app/android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion wallet_app/android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions wallet_app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ android {
namespace = "com.example.walletapp"
compileSdk = 34

buildFeatures {
compose = true
buildConfig = true
}

defaultConfig {
applicationId = "com.example.walletapp"
minSdk = 24
Expand All @@ -33,6 +38,14 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
Expand All @@ -45,4 +58,47 @@ dependencies {
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

val composeBom = platform("androidx.compose:compose-bom:2024.06.00")
implementation(composeBom)
androidTestImplementation(composeBom)

// Material Design 3
implementation(libs.androidx.material3)
// or Material Design 2
implementation(libs.androidx.material)

// Retrofit for network requests
implementation(libs.retrofit)
implementation(libs.converter.gson)
implementation(libs.logging.interceptor)
implementation(libs.androidx.hilt.navigation.compose)

//dagger
implementation(libs.hilt.android)
implementation(libs.androidx.hilt.navigation.fragment)
implementation (libs.androidx.hilt.navigation.compose.v100alpha03)

implementation(libs.androidx.ui.tooling.preview)
debugImplementation(libs.androidx.ui.tooling)

// Optional - Integration with activities
implementation(libs.androidx.activity.compose)
// Optional - Integration with ViewModels
implementation(libs.androidx.lifecycle.viewmodel.compose)
// Optional - Integration with LiveData
implementation(libs.androidx.runtime.livedata)

implementation(libs.androidx.navigation.compose)


implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation(kotlin("script-runtime"))
}
8 changes: 8 additions & 0 deletions wallet_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SendActivity"
android:exported="true"
android:theme="@style/Theme.Walletapp"/>
<activity
android:name=".ReceiverActivity"
android:exported="true"
android:theme="@style/Theme.Walletapp"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,20 +1,174 @@
package com.example.walletapp

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
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.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.Surface
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
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.graphics.painter.Painter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
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 MainActivity : AppCompatActivity() {
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
WindowCompat.setDecorFitsSystemWindows(window, true)
setContent {
WalletappTheme {
Surface(modifier = Modifier.fillMaxSize()) {
Wallet(
modifier = Modifier.padding(10.dp)
)
}
}
}
}
}
}

@Composable
fun Wallet( modifier: Modifier) {
val context = (LocalContext.current as Activity)

Column(
modifier = Modifier
.fillMaxSize()
.background(Color("#0C0C4F".toColorInt()))
.padding(20.dp)
) {
Text(
text = "$11,625.48",
fontFamily = FontFamily(Font(R.font.inter_regular)),
color = Color.White,
fontSize = 28.sp,
modifier = Modifier
.align(Alignment.CenterHorizontally)
.padding(top = 70.dp)
)
Text(
text = "0xfoo...123",
fontFamily = FontFamily(Font(R.font.inter_regular)),
color = Color.White,
fontSize = 16.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)

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

WalletCard(icon = painterResource(id = R.drawable.ic_ethereum), amount = "$11,625.7", exchange = 4.44 , type ="ETH" )

WalletCard(icon = painterResource(id = R.drawable.token2), amount = "$1.78", exchange = 4.44 , type ="STRK" )


Spacer(modifier = Modifier.weight(1f))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
) {
Button(
onClick = { val i = Intent(context,ReceiverActivity::class.java)
context.startActivity(i) },
colors = ButtonDefaults.buttonColors(backgroundColor = Color("#1B1B76".toColorInt())),
shape = RoundedCornerShape(15.dp),
) {
Text(
text = "Receive", fontFamily = FontFamily(Font(R.font.publicsans_bold)),
color = Color.White,
fontSize = 14.sp
)
}
Button(
onClick = {val i = Intent(context,SendActivity::class.java)
context.startActivity(i)},
colors = ButtonDefaults.buttonColors(backgroundColor = Color("#1B1B76".toColorInt())),
shape = RoundedCornerShape(15.dp),
) {
Text(text = "Send", fontFamily = FontFamily(Font(R.font.publicsans_bold)),
color = Color.White,
fontSize = 14.sp)
}
}
Spacer(modifier = Modifier.height(15.dp))
}
}

@Composable
fun WalletCard(icon: Painter,amount:String,exchange:Double,type:String){
Card(
backgroundColor = Color(0xFF1E1E96),
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
) {
Image(
painter = icon, // replace with your Ethereum icon
contentDescription = null,
)
Spacer(modifier = Modifier.weight(1f))
Column(modifier = Modifier, horizontalAlignment = Alignment.End) {
Text(
text = amount,
fontFamily = FontFamily(Font(R.font.inter_regular)),
color = Color.White,
fontSize = 18.sp
)
Row {
Text(
text = exchange.toString(),
fontFamily = FontFamily(Font(R.font.inter_regular)),
color = Color.White,
fontSize = 10.sp
)
Text(
text = type,
fontFamily = FontFamily(Font(R.font.publicsans_bold)),
color = Color.White,
fontSize = 10.sp
)

}

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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.Image
import androidx.compose.foundation.background
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.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Surface
import androidx.compose.material.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.res.painterResource
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 ReceiverActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
WindowCompat.setDecorFitsSystemWindows(window, true)
setContent {
WalletappTheme {
Surface(modifier = Modifier.fillMaxSize()) {
ReceiverScreenView(
modifier = Modifier.padding(10.dp)
)
}
}
}
}

@Composable
fun ReceiverScreenView(modifier: Modifier){
Column(
modifier = Modifier
.fillMaxSize()
.background(Color("#0C0C4F".toColorInt())) // Your dark blue background color
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// QR Code Image
Box(
modifier = Modifier
.size(300.dp)
.background(Color.White) // White background for QR code
) {
Image(
painter = painterResource(id = R.drawable.scanner), // Replace with actual QR code resource
contentDescription = "QR Code",
modifier = Modifier.fillMaxSize()
)
}

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

// Wallet Address
Text(
text = "0xfoo...123", // Replace with actual wallet address
fontFamily = FontFamily(Font(R.font.publicsans_bold)),
color = Color.White,
fontSize = 40.sp
)

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

// 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 {
// TODO: Copy address to clipboard
}
)
}

}
}
Loading

0 comments on commit ff85a27

Please sign in to comment.