Login screens: sigin button for SSO
This commit is contained in:
parent
7caa8ce3bc
commit
f12e6c941d
|
@ -20,7 +20,6 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import butterknife.OnClick
|
import butterknife.OnClick
|
||||||
import com.airbnb.mvrx.Fail
|
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import kotlinx.android.synthetic.main.fragment_login_signup_signin_selection.*
|
import kotlinx.android.synthetic.main.fragment_login_signup_signin_selection.*
|
||||||
|
@ -33,10 +32,15 @@ class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFr
|
||||||
|
|
||||||
override fun getLayoutResId() = R.layout.fragment_login_signup_signin_selection
|
override fun getLayoutResId() = R.layout.fragment_login_signup_signin_selection
|
||||||
|
|
||||||
|
private var isSsoSignIn: Boolean = false
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
isSsoSignIn = withState(loginViewModel) { it.asyncHomeServerLoginFlowRequest.invoke() } == LoginMode.Sso
|
||||||
|
|
||||||
setupUi()
|
setupUi()
|
||||||
|
setupButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUi() {
|
private fun setupUi() {
|
||||||
|
@ -62,10 +66,25 @@ class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.loginSignupSigninSignUp)
|
private fun setupButtons() {
|
||||||
|
if (isSsoSignIn) {
|
||||||
|
loginSignupSigninSubmit.text = getString(R.string.login_signin_sso)
|
||||||
|
loginSignupSigninSignIn.isVisible = false
|
||||||
|
} else {
|
||||||
|
loginSignupSigninSubmit.text = getString(R.string.login_signup)
|
||||||
|
loginSignupSigninSignIn.isVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick(R.id.loginSignupSigninSubmit)
|
||||||
fun signUp() {
|
fun signUp() {
|
||||||
|
if (isSsoSignIn) {
|
||||||
|
signIn()
|
||||||
|
} else {
|
||||||
loginViewModel.handle(LoginAction.UpdateSignMode(SignMode.SignUp))
|
loginViewModel.handle(LoginAction.UpdateSignMode(SignMode.SignUp))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.loginSignupSigninSignIn)
|
@OnClick(R.id.loginSignupSigninSignIn)
|
||||||
fun signIn() {
|
fun signIn() {
|
||||||
|
@ -76,15 +95,4 @@ class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFr
|
||||||
override fun resetViewModel() {
|
override fun resetViewModel() {
|
||||||
loginViewModel.handle(LoginAction.ResetSignMode)
|
loginViewModel.handle(LoginAction.ResetSignMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invalidate() = withState(loginViewModel) {
|
|
||||||
when (it.asyncRegistration) {
|
|
||||||
is Fail -> {
|
|
||||||
// TODO Registration disabled, (move to Activity?)
|
|
||||||
when (it.asyncRegistration.error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,17 +56,19 @@
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninTitle"
|
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninTitle"
|
||||||
tools:text="@string/login_server_matrix_org_text" />
|
tools:text="@string/login_server_matrix_org_text" />
|
||||||
|
|
||||||
|
<!-- Sign up or sign in SSO -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/loginSignupSigninSignUp"
|
android:id="@+id/loginSignupSigninSubmit"
|
||||||
style="@style/Style.Vector.Login.Button"
|
style="@style/Style.Vector.Login.Button"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="38dp"
|
android:layout_marginTop="38dp"
|
||||||
android:text="@string/login_signup"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninText" />
|
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninText"
|
||||||
|
tools:text="@string/login_signup" />
|
||||||
|
|
||||||
|
<!-- Sign in or gone -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/loginSignupSigninSignIn"
|
android:id="@+id/loginSignupSigninSignIn"
|
||||||
style="@style/Style.Vector.Login.Button.Outlined"
|
style="@style/Style.Vector.Login.Button.Outlined"
|
||||||
|
@ -74,10 +76,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="14dp"
|
android:layout_marginTop="14dp"
|
||||||
android:text="@string/login_signin"
|
android:text="@string/login_signin"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninSignUp" />
|
app:layout_constraintTop_toBottomOf="@+id/loginSignupSigninSubmit"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue