Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Add dimention , closed #23 , change showing timer like design , closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Miladsalimiiiii committed Jul 28, 2019
1 parent 7b093c9 commit 0bf664f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class CodeVerificationFragment : BaseFragment() {

private val mCodeVerificationViewModel: CodeVerificationViewModel by viewModel()

private val mTextViewIn by lazy { textView_codeVerification_in }
private val mTextViewResendCode by lazy { textView_codeVerification_resendTitle }
private val mPinEntryEditText by lazy { pinEntryEditText_codeVerification_setPin }
private val mButton by lazy { button_codeVerification_continue }
private val mTextViewTimer by lazy { textView_codeVerification_resendTime }
Expand All @@ -45,27 +47,26 @@ class CodeVerificationFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)


setTimer()
disableButton()

}


override fun initUiListener() {

mButton.setOnClickListener { bind() }

mTextViewTimer.setOnClickListener {
mTextViewResendCode.setOnClickListener {

if (!mIsRunning) {
setTimer()
mTextViewTimer.visibility = View.VISIBLE
mTextViewIn.visibility = View.VISIBLE
//We have to call claim here

}
}


mPinEntryEditText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(p0: Editable?) {

Expand All @@ -77,7 +78,6 @@ class CodeVerificationFragment : BaseFragment() {

override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {


if (p0!!.length == 6) {

enableButton()
Expand All @@ -104,7 +104,16 @@ class CodeVerificationFragment : BaseFragment() {
"D89707AC55BAED9E8F23B826FB2A28E96095A190",
"salimi",
"android",
"eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJSUzI1NiIsICJraWQiOiAiODk0NTkyNzQzMzlkMzNlZmNmNTE3MDc4NGM5ZGU1MjUzMjEyOWVmZiJ9.eyJpc3MiOiAiZmlyZWJhc2UtYWRtaW5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nb" +
"29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsICJ1aWQiOiAiKzk4OTIxMTQ5OTM" +
"wMiIsICJpYXQiOiAxNTYzOTYwNDU3LCAiZXhwIjogMTU2Mzk2NDA1N30.HOUVBzwbmGwsglQHukGwrijlUuSZ241KdN2Eo" +
"l3Gy80mmd4Kxoc58m3VhL71AWv3WS99eE7uz6xctl--yLPilhN3WJ_z2nxySqkhxiZ9OtaH_U8sTek63SJgfINeTFzJFp" +
"WHkT_DlQNPTVoH_AqbXjh0gZwdpVdMyoLmmuJf-WIqx2y7BdwudCTiAqY_RoK7DdDwS8Jf28J-czpWi7Q4neUo1pC0WLi" +
"986u9n0mZcfIhWoVB_fV0A2-fWRV6yhT647sfHntC2eSg-OJZKO-MAyBsgKDIZm_ubX7m3LHD6rahpnUHtY8m33eJyD-" +
"EfZcKboRWalJkmje69abirvep1A",
"082016"
)
)
Expand All @@ -129,7 +138,6 @@ class CodeVerificationFragment : BaseFragment() {

private fun setTimer() {


mCountDownTimer = object : CountDownTimer(sTimer.toLong(), 1000) {
override fun onTick(millisUntilFinished: Long) {

Expand All @@ -138,22 +146,28 @@ class CodeVerificationFragment : BaseFragment() {
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)
)
mTextViewTimer.text = String.format("%02d:%02d ", minuteTimer, secondTimer)
mTextViewTimer.isEnabled = false
mTextViewTimer.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorText))
mTextViewResendCode.isEnabled = false
mTextViewResendCode.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorText))

}

override fun onFinish() {

mTextViewTimer.isEnabled = true
mTextViewResendCode.isEnabled = true
mIsRunning = false
if (context != null) {
mTextViewTimer.text = getString(R.string.codeVerification_resendCode)
mTextViewTimer.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorTertiaryDark))

mTextViewResendCode.setTextColor(
ContextCompat.getColor(
requireContext(),
R.color.colorTertiaryDark
)
)
mTextViewIn.visibility = View.GONE
mTextViewTimer.visibility = View.GONE
}
}
}.start()

}

private fun disableButton() {
Expand Down
62 changes: 35 additions & 27 deletions app/src/main/res/layout/fragment_codeverification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
android:layout_marginTop="@dimen/margin_all_8dp">

<TextView
android:id="@+id/textView_codeVerification_steps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/codeVerification_steps"
android:layout_marginEnd="5dp"
android:layout_marginEnd="@dimen/margin_all_5dp"
style="@style/TextAppearanceBaseMediumTitleTextDark"/>

<TextView
Expand All @@ -26,16 +26,16 @@
android:layout_height="wrap_content"
android:text="@string/codeVerification_stepsValue"
android:layout_toEndOf="@+id/textView_codeVerification_steps"
android:layout_marginStart="5dp"
android:layout_marginStart="@dimen/margin_all_5dp"
style="@style/TextAppearanceBaseMediumTitleTextDark"/>

</RelativeLayout>

<ImageView
android:id="@+id/imageView_codeVerification_icon"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="28dp"
android:layout_width="@dimen/margin_all_100dp"
android:layout_height="@dimen/margin_all_100dp"
android:layout_marginTop="@dimen/margin_all_28dp"
android:layout_below="@+id/relativeLayout_codeVerification_title"
android:src="@drawable/everywhere_icon"
android:layout_centerInParent="true"/>
Expand All @@ -47,7 +47,7 @@
android:text="@string/codeVerification_codeVerification"
android:layout_below="@+id/imageView_codeVerification_icon"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginTop="@dimen/margin_all_20dp"
style="@style/TextAppearanceBaseBold"/>
<TextView
android:id="@+id/textView_codeVerification_enterFourDigits"
Expand All @@ -56,7 +56,7 @@
android:layout_below="@+id/textView_codeVerification_codeVerification"
android:text="@string/codeVerification_enterFourDigit"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginTop="@dimen/margin_all_10dp"
style="@style/TextAppearanceRegularUnderTitle"/>
<TextView
android:id="@+id/textView_codeVerification_phoneNumber"
Expand All @@ -65,7 +65,7 @@
android:layout_below="@+id/textView_codeVerification_enterFourDigits"
android:text="@string/everywhere_value"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginTop="@dimen/margin_all_10dp"
style="@style/TextAppearanceRegularUnderTitle"/>

<RelativeLayout
Expand All @@ -74,9 +74,9 @@
android:layout_height="wrap_content"
android:background="@drawable/everywhere_whitbackgroundwithcornerradius"
android:layout_below="@+id/textView_codeVerification_phoneNumber"
android:layout_marginTop="20dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
android:layout_marginTop="@dimen/margin_all_20dp"
android:layout_marginStart="@dimen/margin_all_16dp"
android:layout_marginEnd="@dimen/margin_all_16dp">

<com.alimuzaffar.lib.pin.PinEntryEditText
android:id="@+id/pinEntryEditText_codeVerification_setPin"
Expand All @@ -87,52 +87,60 @@
android:inputType="number"
android:maxLength="6"
android:textIsSelectable="true"
android:textSize="20sp"
android:textSize="@dimen/textSize_all_20sp"
app:pinAnimationType="popIn"
app:pinTextBottomPadding="10dp"
app:pinLineStroke="2dp"
app:pinLineStrokeSelected="4dp"
app:pinTextBottomPadding="@dimen/padding_all_10dp"
app:pinLineStroke="@dimen/margin_all_2dp"
app:pinLineStrokeSelected="@dimen/margin_all_4dp"
app:pinLineColors="@color/colorPrimaryDark"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="30dp"/>
android:layout_marginStart="@dimen/margin_all_16dp"
android:layout_marginEnd="@dimen/margin_all_16dp"
android:layout_marginTop="@dimen/margin_all_30dp"/>

<Button
android:id="@+id/button_codeVerification_continue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pinEntryEditText_codeVerification_setPin"
android:background="@drawable/codeverification_buttonselector"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="20dp"
android:layout_marginStart="@dimen/margin_all_16dp"
android:layout_marginEnd="@dimen/margin_all_16dp"
android:layout_marginBottom="@dimen/margin_all_20dp"
android:text="@string/codeVerification_textButton"
android:layout_marginTop="30dp"/>
android:layout_marginTop="@dimen/margin_all_30dp"/>

</RelativeLayout>

<RelativeLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginTop="@dimen/margin_all_30dp"
android:layout_below="@+id/relativeLayout_codeVerification_middle">

<TextView
android:id="@+id/textView_codeVerification_resendTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/codeVerification_resend"
android:layout_marginEnd="5dp"
android:layout_marginEnd="@dimen/margin_all_5dp"
style="@style/TextAppearanceBaseMediumTitleText"/>

<TextView
android:id="@+id/textView_codeVerification_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/codeVerification_in"
android:layout_toEndOf="@+id/textView_codeVerification_resendTitle"
style="@style/TextAppearanceBaseMediumTitleText"/>

<TextView
android:id="@+id/textView_codeVerification_resendTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/everywhere_value"
android:layout_toEndOf="@+id/textView_codeVerification_resendTitle"
android:layout_marginStart="5dp"
android:layout_toEndOf="@+id/textView_codeVerification_in"
android:layout_marginStart="@dimen/margin_all_5dp"
style="@style/TextAppearanceBaseMediumTitleText"/>

</RelativeLayout>
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<dimen name="margin_all_8dp">8dp</dimen>
<dimen name="margin_all_5dp">5dp</dimen>
<dimen name="margin_all_100dp">100dp</dimen>
<dimen name="margin_all_28dp">28dp</dimen>
<dimen name="margin_all_20dp">20dp</dimen>
<dimen name="margin_all_10dp">10dp</dimen>
<dimen name="margin_all_16dp">16dp</dimen>
<dimen name="margin_all_30dp">30dp</dimen>
<dimen name="margin_all_2dp">2dp</dimen>
<dimen name="margin_all_4dp">4dp</dimen>

<dimen name="padding_all_10dp">10dp</dimen>

<dimen name="textSize_all_20sp">20sp</dimen>


</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<string name="codeVerification_codeVerification">Code Verification</string>
<string name="codeVerification_enterFourDigit">Enter 6 digit number that sent to</string>
<string name="codeVerification_textButton">Continue</string>
<string name="codeVerification_resend">Re_Send code in</string>
<string name="codeVerification_resend">Re_Send code </string>
<string name="codeVerification_stepsValue">3/4</string>
<string name="codeVerification_resendCode">RESEND</string>
<string name="codeVerification_in">in</string>
</resources>

0 comments on commit 0bf664f

Please sign in to comment.