Skip to content

Commit

Permalink
feat: UI for Home Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
anamansari062 committed Aug 19, 2023
1 parent cc14ce0 commit cf76fef
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class HomeFragment : Fragment() {
}
}

binding.gmButton.setOnClickListener {
// TODO: send gm using gm-maker program
}

binding.buildDappsBtn.setOnClickListener {
requireContext().openInBrowser(TWITTER_SHARE_URL)
}
Expand Down Expand Up @@ -145,6 +149,10 @@ class HomeFragment : Fragment() {
binding.airdropBtn.setBackgroundColor(
ContextCompat.getColor(requireContext(), R.drawable.text_background as Int),
)

binding.gmButton.setBackgroundColor(
ContextCompat.getColor(requireContext(), R.color.black as Int),
)
}

private fun disconnectWallet() {
Expand All @@ -156,7 +164,7 @@ class HomeFragment : Fragment() {
ContextCompat.getColor(requireContext(), R.color.white),
)
binding.walletBtn.setBackgroundColor(
ContextCompat.getColor(requireContext(), R.color.black),
ContextCompat.getColor(requireContext(), R.color.dark_gray),
)

binding.walletBtn.iconTint =
Expand All @@ -165,6 +173,10 @@ class HomeFragment : Fragment() {
binding.airdropBtn.setBackgroundColor(
ContextCompat.getColor(requireContext(), R.color.dark_gray),
)

binding.gmButton.setBackgroundColor(
ContextCompat.getColor(requireContext(), R.color.dark_gray as Int),
)
}

private val intentSender = object : StartActivityForResultSender {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_refresh_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FDFDFD"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_water_drop_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FDFDFD"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2c-5.33,4.55 -8,8.48 -8,11.8c0,4.98 3.8,8.2 8,8.2s8,-3.22 8,-8.2C20,10.48 17.33,6.55 12,2zM7.83,14c0.37,0 0.67,0.26 0.74,0.62c0.41,2.22 2.28,2.98 3.64,2.87c0.43,-0.02 0.79,0.32 0.79,0.75c0,0.4 -0.32,0.73 -0.72,0.75c-2.13,0.13 -4.62,-1.09 -5.19,-4.12C7.01,14.42 7.37,14 7.83,14z"/>
</vector>
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/screen_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:centerX="50%"
android:centerY="100%"
android:startColor="#010912"
android:endColor="#31125d"
android:centerColor="#010e1d"
android:endColor="#03A9F4"
android:centerColor="#3F51B5"
android:tileMode="clamp"/>
</shape>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/text_background.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<selector>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="135" android:endColor="#d946ef" android:startColor="#6366f1" />
<gradient android:angle="135" android:endColor="#3F51B5" android:startColor="#6366f1" />
</shape>
</item>
</selector>
Binary file added app/src/main/res/font/custom_font.otf
Binary file not shown.
166 changes: 104 additions & 62 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_animation"
tools:context=".presentation.ui.home.HomeFragment">
tools:context=".presentation.ui.home.HomeFragment"
android:orientation="vertical">

<TextView
android:id="@+id/heading"
Expand All @@ -14,95 +15,136 @@
android:layout_margin="16dp"
android:gravity="start"
android:text="@string/home_page_heading"
android:textColor="@drawable/text_background"
android:textSize="40sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:textColor="@color/white"
android:fontFamily="@font/custom_font"
android:textSize="40sp" />

<TextView
android:id="@+id/sub_heading"
style="@style/TextAppearance.AppCompat.Large"
android:fontFamily="@font/custom_font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="start"
android:text="@string/home_page_sub_heading"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/heading" />
android:textColor="@color/white" />

<com.google.android.material.button.MaterialButton
android:id="@+id/wallet_btn"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton.Icon"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/balance_tv"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:fontFamily="@font/custom_font"
android:textColor="@color/white"
android:textSize="20sp"
android:layout_weight="1"
tools:text="0 SOL" />

<com.google.android.material.button.MaterialButton
android:id="@+id/wallet_btn"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:backgroundTint="@color/dark_gray"
android:fontFamily="@font/custom_font"
android:gravity="center"
android:textColor="@color/white"
app:cornerRadius="10dp"
app:icon="@drawable/baseline_circle_24"
app:iconTint="@color/red"
tools:text="Select Wallet" />

<ImageView
android:id="@+id/copy_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:contentDescription="To copy wallet address"
android:src="@drawable/baseline_content_copy_24"
android:visibility="gone"
app:tint="@color/white" />

</LinearLayout>

<Button
android:id="@+id/gm_button"
android:layout_width="135dp"
android:layout_height="147dp"
android:backgroundTint="@color/dark_gray"
android:fontFamily="@font/custom_font"
android:gravity="center"
android:padding="16dp"
android:layout_marginTop="50dp"
android:text="@string/gm"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="24dp"
app:cornerRadius="1500dp"
android:layout_gravity="center_horizontal" />

<TextView
android:id="@+id/gm_count_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:backgroundTint="@color/black"
android:fontFamily="@font/custom_font"
android:gravity="center"
android:padding="16dp"
android:text="@string/_0_gm"
android:visibility="invisible"
android:textColor="@color/white"
app:cornerRadius="10dp"
app:icon="@drawable/baseline_circle_24"
app:iconTint="@color/red"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/copy_btn"
app:layout_constraintTop_toBottomOf="@id/sub_heading"
tools:text="Select Wallet" />
android:textSize="20sp"
android:layout_gravity="center_horizontal" />

<ImageView
android:id="@+id/copy_btn"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="16dp"
android:contentDescription="To copy wallet address"
android:src="@drawable/baseline_content_copy_24"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/wallet_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/wallet_btn"
app:tint="#14F195" />
android:id="@+id/refresh_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:visibility="invisible"
android:contentDescription="@string/to_refresh_gm_count"
android:src="@drawable/baseline_refresh_24" />

<com.google.android.material.button.MaterialButton
android:id="@+id/build_dapps_btn"
android:id="@+id/airdrop_btn"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="100dp"
android:backgroundTint="@drawable/text_background"
android:layout_marginBottom="20dp"
android:layout_gravity="center_horizontal"
android:backgroundTint="@color/dark_gray"
android:fontFamily="@font/custom_font"
android:gravity="center"
android:text="@string/build_mobile_dapps"
android:text="@string/airdrop_sol"
android:textColor="@color/white"
app:cornerRadius="10dp"
app:icon="@drawable/baseline_twitter_24"
app:iconTint="#00aced"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:icon="@drawable/baseline_water_drop_24"
app:iconTint="@color/white" />

<com.google.android.material.button.MaterialButton
android:id="@+id/airdrop_btn"
android:id="@+id/build_dapps_btn"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/gray"
android:layout_marginBottom="100dp"
android:layout_gravity="center_horizontal"
android:backgroundTint="@drawable/text_background"
android:fontFamily="@font/custom_font"
android:gravity="center"
android:text="@string/airdrop_sol"
android:text="@string/build_mobile_dapps"
android:textColor="@color/white"
app:cornerRadius="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:icon="@drawable/baseline_twitter_24"
app:iconTint="#00aced" />

<TextView
android:id="@+id/balance_tv"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/airdrop_btn"
tools:text="0 SOL" />

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<item name="colorPrimary">@color/white</item>
<item name="colorSecondary">@color/teal</item>
</style>

<style name="CustomFontTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">@font/custom_font</item>
</style>
</resources>
13 changes: 8 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<resources>
<string name="app_name">Solana Mobile Dapp Scaffold</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string>
<string name="app_name">gm</string>
<string name="title_home">GMs</string>
<string name="title_dashboard">NFTs</string>
<string name="title_settings">Settings</string>
<string name="home_page_heading">Solana Mobile Scaffold</string>
<string name="home_page_heading">gm</string>
<string name="airdrop_sol">Airdrop 1 SOL</string>
<string name="home_page_sub_heading">There is no better time to build consumer mobile dApps.</string>
<string name="home_page_sub_heading">There is no better time to say gm.</string>

<string name="wallet_balance">%1$s SOL</string>
<string name="select_wallet">Select Wallet</string>
Expand All @@ -17,4 +17,7 @@
<string name="send_transaction">Send Transaction</string>
<string name="send_versioned_transaction">Send Versioned Transaction</string>
<string name="build_mobile_dapps">Build mobile dApps</string>
<string name="gm">say gm.</string>
<string name="to_refresh_gm_count">To refresh gm count</string>
<string name="_0_gm">0 gm</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<item name="colorPrimary">@color/white</item>
<item name="colorSecondary">@color/teal</item>
</style>

<style name="CustomFontTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">@font/custom_font</item>
</style>
</resources>

0 comments on commit cf76fef

Please sign in to comment.