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

fix: toast to snackbar for signup work #809

Merged
merged 5 commits into from Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,15 +2,16 @@ package org.fossasia.openevent.general.auth

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_signup.confirmPasswords
import kotlinx.android.synthetic.main.fragment_signup.firstNameText
import kotlinx.android.synthetic.main.fragment_signup.lastNameText
Expand All @@ -21,6 +22,7 @@ import kotlinx.android.synthetic.main.fragment_signup.usernameSignUp
import kotlinx.android.synthetic.main.fragment_signup.view.passwordSignUp
import kotlinx.android.synthetic.main.fragment_signup.view.progressBarSignUp
import kotlinx.android.synthetic.main.fragment_signup.view.signUpButton
import kotlinx.android.synthetic.main.fragment_signup.view.signupCoordinatorLayout
import org.fossasia.openevent.general.MainActivity
import org.fossasia.openevent.general.R
import org.fossasia.openevent.general.utils.Utils
Expand Down Expand Up @@ -68,21 +70,27 @@ class SignUpFragment : Fragment() {
signUpViewModel.error
.nonNull()
.observe(this, Observer {
Toast.makeText(context, it, Toast.LENGTH_LONG).show()
Snackbar.make(rootView.signupCoordinatorLayout, it, Snackbar.LENGTH_LONG).show()
})

signUpViewModel.signedUp
.nonNull()
.observe(this, Observer {
Toast.makeText(context, "Sign Up Success!", Toast.LENGTH_LONG).show()
Snackbar.make(
rootView.signupCoordinatorLayout, "Sign Up Success!", Snackbar.LENGTH_SHORT
).show()
GOVINDDIXIT marked this conversation as resolved.
Show resolved Hide resolved
signUpViewModel.login(signUp)
})

signUpViewModel.loggedIn
.nonNull()
.observe(this, Observer {
Toast.makeText(context, "Logged in Automatically!", Toast.LENGTH_LONG).show()
redirectToMain()
Snackbar.make(
rootView.signupCoordinatorLayout, "Logged in Automatically!", Snackbar.LENGTH_SHORT
).show()
Handler().postDelayed({
redirectToMain()
}, 1000)
})

rootView.passwordSignUp.addTextChangedListener(object : TextWatcher {
Expand All @@ -96,6 +104,7 @@ class SignUpFragment : Fragment() {
}

override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { /*Implement here*/ }

override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { /*Implement here*/ }
})

Expand Down
11 changes: 9 additions & 2 deletions app/src/main/res/layout/fragment_signup.xml
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/signupCoordinatorLayout"
android:fitsSystemWindows="true">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -129,4 +133,7 @@
android:visibility="gone" />

</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

GOVINDDIXIT marked this conversation as resolved.
Show resolved Hide resolved