-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
652 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
app/src/main/java/com/nqmgaming/shoseshop/ui/activities/checkout/CheckoutActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package com.nqmgaming.shoseshop.ui.activities.checkout | ||
|
||
import android.os.Bundle | ||
import android.text.InputType | ||
import android.widget.Toast | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.activity.viewModels | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import com.maxkeppeler.sheets.input.InputSheet | ||
import com.maxkeppeler.sheets.input.ValidationResult | ||
import com.maxkeppeler.sheets.input.type.InputEditText | ||
import com.nqmgaming.shoseshop.R | ||
import com.nqmgaming.shoseshop.databinding.ActivityCheckoutBinding | ||
import com.nqmgaming.shoseshop.util.SharedPrefUtils | ||
import com.wajahatkarim3.easyvalidation.core.view_ktx.validEmail | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class CheckoutActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityCheckoutBinding | ||
private val viewModel: CheckoutViewModel by viewModels() | ||
private lateinit var email: String | ||
private lateinit var phoneNumber: String | ||
private lateinit var address: String | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
enableEdgeToEdge() | ||
binding = ActivityCheckoutBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
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 | ||
} | ||
|
||
email = SharedPrefUtils.getString(this, "email") ?: "" | ||
phoneNumber = SharedPrefUtils.getString(this, "phoneNumber") ?: "" | ||
address = SharedPrefUtils.getString(this, "address") ?: "" | ||
binding.apply { | ||
emailTv.text = email | ||
phoneTv.text = phoneNumber | ||
addressTv.text = address | ||
editEmailIv.setOnClickListener { | ||
var isEmailValid = false | ||
val oldEmail: String = email | ||
InputSheet().show(this@CheckoutActivity) { | ||
title("Edit Email") | ||
with(InputEditText { | ||
required() | ||
label("Email") | ||
hint("Enter your email") | ||
defaultValue(email) | ||
inputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) | ||
maxLines(1) | ||
startIconDrawable(R.drawable.ic_email) | ||
validationListener { value -> | ||
isEmailValid = value.toString().validEmail() | ||
ValidationResult(isEmailValid, "Invalid email") | ||
} | ||
changeListener { value -> | ||
email = value.toString() | ||
} | ||
resultListener { | ||
emailTv.text = email | ||
} | ||
onPositive { | ||
if (isEmailValid) { | ||
SharedPrefUtils.saveString(this@CheckoutActivity, "email", email) | ||
} else { | ||
email = oldEmail | ||
Toast.makeText( | ||
this@CheckoutActivity, | ||
"Invalid email", | ||
Toast.LENGTH_SHORT | ||
).show() | ||
} | ||
} | ||
onNegative { | ||
email = oldEmail | ||
emailTv.text = email | ||
} | ||
}) | ||
} | ||
} | ||
|
||
editAddressIv.setOnClickListener { | ||
var isAddressValid = false | ||
val oldAddress: String = address | ||
InputSheet().show(this@CheckoutActivity) { | ||
title("Edit Address") | ||
with(InputEditText { | ||
required() | ||
label("Address") | ||
hint("Enter your address") | ||
defaultValue(address) | ||
maxLines(1) | ||
startIconDrawable(R.drawable.ic_location) | ||
validationListener { value -> | ||
isAddressValid = value.toString().isNotEmpty() | ||
ValidationResult(isAddressValid, "Address cannot be empty") | ||
} | ||
changeListener { value -> | ||
address = value.toString() | ||
} | ||
resultListener { | ||
addressTv.text = address | ||
} | ||
onPositive { | ||
SharedPrefUtils.saveString(this@CheckoutActivity, "address", address) | ||
} | ||
onNegative { | ||
address = oldAddress | ||
addressTv.text = address | ||
} | ||
}) | ||
} | ||
} | ||
|
||
editPhoneIv.setOnClickListener { | ||
var isPhoneValid = false | ||
val oldPhone: String = phoneNumber | ||
InputSheet().show(this@CheckoutActivity) { | ||
title("Edit Phone Number") | ||
with(InputEditText { | ||
required() | ||
label("Phone Number") | ||
hint("Enter your phone number") | ||
defaultValue(phoneNumber) | ||
maxLines(1) | ||
startIconDrawable(R.drawable.ic_telephone) | ||
validationListener { value -> | ||
isPhoneValid = value.toString().isNotEmpty() | ||
ValidationResult(isPhoneValid, "Phone number cannot be empty") | ||
} | ||
changeListener { value -> | ||
phoneNumber = value.toString() | ||
} | ||
resultListener { | ||
phoneTv.text = phoneNumber | ||
} | ||
onPositive { | ||
SharedPrefUtils.saveString( | ||
this@CheckoutActivity, | ||
"phoneNumber", | ||
phoneNumber | ||
) | ||
} | ||
onNegative { | ||
phoneNumber = oldPhone | ||
phoneTv.text = phoneNumber | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/nqmgaming/shoseshop/ui/activities/checkout/CheckoutViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.nqmgaming.shoseshop.ui.activities.checkout | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.nqmgaming.shoseshop.data.repository.ShoesRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
@HiltViewModel | ||
class CheckoutViewModel @Inject constructor( | ||
private val shoesRepository: ShoesRepository | ||
):ViewModel(){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="m4.76,18.81s0.08,0 0.11,0l2.93,-0.27c0.41,-0.04 0.79,-0.22 1.08,-0.51l11.06,-11.06c0.52,-0.52 0.81,-1.21 0.81,-1.94s-0.29,-1.42 -0.81,-1.94l-0.71,-0.71c-1.04,-1.04 -2.85,-1.04 -3.89,0l-1.41,1.41s0,0 0,0l-9.64,9.64c-0.29,0.29 -0.47,0.67 -0.5,1.08l-0.27,2.93c-0.03,0.37 0.1,0.73 0.36,1 0.24,0.24 0.55,0.37 0.88,0.37zM17.29,3.07c0.32,0 0.64,0.12 0.88,0.37l0.71,0.71c0.24,0.24 0.37,0.55 0.37,0.88s-0.13,0.65 -0.37,0.88l-0.88,0.88 -2.47,-2.47 0.88,-0.88c0.24,-0.24 0.56,-0.37 0.88,-0.37zM5.28,14.65c0,-0.06 0.03,-0.11 0.07,-0.15l9.11,-9.12 2.47,2.47 -9.11,9.11s-0.1,0.07 -0.15,0.07l-2.63,0.24 0.24,-2.63zM22.75,22c0,0.41 -0.34,0.75 -0.75,0.75h-20c-0.41,0 -0.75,-0.34 -0.75,-0.75s0.34,-0.75 0.75,-0.75h20c0.41,0 0.75,0.34 0.75,0.75z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/colorWhite" /> | ||
<stroke | ||
android:width="1dp" | ||
android:color="@color/colorGrey" /> | ||
<corners android:radius="8dp" /> | ||
<padding | ||
android:left="0dp" | ||
android:top="0dp" | ||
android:right="0dp" | ||
android:bottom="0dp" /> | ||
</shape> |
Oops, something went wrong.