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 androidx.core.view.isVisible
|
||||
import butterknife.OnClick
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.withState
|
||||
import im.vector.riotx.R
|
||||
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
|
||||
|
||||
private var isSsoSignIn: Boolean = false
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
isSsoSignIn = withState(loginViewModel) { it.asyncHomeServerLoginFlowRequest.invoke() } == LoginMode.Sso
|
||||
|
||||
setupUi()
|
||||
setupButtons()
|
||||
}
|
||||
|
||||
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() {
|
||||
if (isSsoSignIn) {
|
||||
signIn()
|
||||
} else {
|
||||
loginViewModel.handle(LoginAction.UpdateSignMode(SignMode.SignUp))
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.loginSignupSigninSignIn)
|
||||
fun signIn() {
|
||||
|
@ -76,15 +95,4 @@ class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFr
|
|||
override fun resetViewModel() {
|
||||
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"
|
||||
tools:text="@string/login_server_matrix_org_text" />
|
||||
|
||||
<!-- Sign up or sign in SSO -->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/loginSignupSigninSignUp"
|
||||
android:id="@+id/loginSignupSigninSubmit"
|
||||
style="@style/Style.Vector.Login.Button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="38dp"
|
||||
android:text="@string/login_signup"
|
||||
app:layout_constraintEnd_toEndOf="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
|
||||
android:id="@+id/loginSignupSigninSignIn"
|
||||
style="@style/Style.Vector.Login.Button.Outlined"
|
||||
|
@ -74,10 +76,12 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:text="@string/login_signin"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue