Skip to content
Snippets Groups Projects
Commit 0587d681 authored by Taras's avatar Taras
Browse files

Remove username from select signup type

parent 9a39f59b
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ package org.futo.circles.feature.sign_up.sign_up_type ...@@ -2,7 +2,6 @@ package org.futo.circles.feature.sign_up.sign_up_type
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import by.kirich1409.viewbindingdelegate.viewBinding import by.kirich1409.viewbindingdelegate.viewBinding
import org.futo.circles.BuildConfig import org.futo.circles.BuildConfig
...@@ -43,30 +42,16 @@ class SelectSignUpTypeFragment : Fragment(R.layout.fragment_select_sign_up_type) ...@@ -43,30 +42,16 @@ class SelectSignUpTypeFragment : Fragment(R.layout.fragment_select_sign_up_type)
private fun setupViews() { private fun setupViews() {
with(binding) { with(binding) {
groupSubscription.setIsVisible(BuildConfig.IS_SUBSCRIPTIONS_ENABLED) groupSubscription.setIsVisible(BuildConfig.IS_SUBSCRIPTIONS_ENABLED)
tilUserName.editText?.doAfterTextChanged { setSignupButtonsEnabled() } btnEU.text = getString(R.string.eu_server_format, BuildConfig.EU_SERVER_DOMAIN)
btnUS.text = getString(R.string.us_server_format, BuildConfig.EU_SERVER_DOMAIN)
btnToken.setOnClickListener { btnToken.setOnClickListener {
startLoading(btnToken) startLoading(btnToken)
viewModel.startSignUp( viewModel.startSignUp(getDomain())
tilUserName.getText(),
tvServerDomain.text.toString()
)
} }
btnSubscription.setOnClickListener { btnSubscription.setOnClickListener {
startLoading(btnSubscription) startLoading(btnSubscription)
viewModel.startSignUp( viewModel.startSignUp(getDomain(), true)
tilUserName.getText(),
tvServerDomain.text.toString(),
true
)
}
serverLocationGroup.setOnCheckedChangeListener { _, checkedId ->
tvServerDomain.text = when (checkedId) {
btnUS.id -> BuildConfig.US_SERVER_DOMAIN
btnEU.id -> BuildConfig.EU_SERVER_DOMAIN
else -> BuildConfig.US_SERVER_DOMAIN
}
} }
serverLocationGroup.check(btnUS.id)
} }
} }
...@@ -84,9 +69,9 @@ class SelectSignUpTypeFragment : Fragment(R.layout.fragment_select_sign_up_type) ...@@ -84,9 +69,9 @@ class SelectSignUpTypeFragment : Fragment(R.layout.fragment_select_sign_up_type)
} }
} }
private fun setSignupButtonsEnabled() { private fun getDomain() = when (binding.serverLocationGroup.checkedRadioButtonId) {
val isEnabled = binding.tilUserName.getText().isNotEmpty() binding.btnUS.id -> BuildConfig.US_SERVER_DOMAIN
binding.btnToken.isEnabled = isEnabled binding.btnEU.id -> BuildConfig.EU_SERVER_DOMAIN
binding.btnSubscription.isEnabled = isEnabled else -> BuildConfig.US_SERVER_DOMAIN
} }
} }
\ No newline at end of file
...@@ -29,100 +29,58 @@ ...@@ -29,100 +29,58 @@
style="@style/headline" style="@style/headline"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginTop="8dp"
android:text="@string/server_location" android:text="@string/server_location"
app:layout_constraintBottom_toBottomOf="@id/serverLocationGroup" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/serverLocationGroup"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/serverLocationGroup" /> app:layout_constraintTop_toBottomOf="@id/guidelineLogo" />
<RadioGroup <RadioGroup
android:id="@+id/serverLocationGroup" android:id="@+id/serverLocationGroup"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@id/tvServerLocationTitle" app:layout_constraintTop_toBottomOf="@id/tvServerLocationTitle">
app:layout_constraintTop_toBottomOf="@id/guidelineLogo">
<com.google.android.material.radiobutton.MaterialRadioButton <com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/btnUS" android:id="@+id/btnUS"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true"
android:paddingHorizontal="8dp" android:paddingHorizontal="8dp"
android:text="@string/us" android:textAppearance="@style/headline"
android:textAppearance="@style/headline" /> tools:text="US some.server.domain" />
<com.google.android.material.radiobutton.MaterialRadioButton <com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/btnEU" android:id="@+id/btnEU"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="8dp" android:paddingHorizontal="8dp"
android:text="@string/eu" android:textAppearance="@style/headline"
android:textAppearance="@style/headline" /> tools:text="EU - (some.server.domain)" />
</RadioGroup> </RadioGroup>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilUserName"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:hint="@string/username"
app:layout_constraintEnd_toStartOf="@id/tvServerDomain"
app:layout_constraintHorizontal_weight="0.6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/serverLocationGroup">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:padding="12dp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/tvServerDomain"
style="@style/footNote"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
app:layout_constraintBottom_toBottomOf="@id/tilUserName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="0.4"
app:layout_constraintStart_toEndOf="@id/tilUserName"
app:layout_constraintTop_toTopOf="@id/tilUserName"
tools:text="eu.kombucha.social" />
<TextView <TextView
android:id="@+id/tvTokenTitle" android:id="@+id/tvTokenTitle"
style="@style/headline" style="@style/headline"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center" android:gravity="center"
android:text="@string/already_have_a_token" android:text="@string/already_have_a_token"
app:layout_constraintBottom_toTopOf="@id/btnToken" app:layout_constraintBottom_toTopOf="@id/btnToken"
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/tilUserName" app:layout_constraintTop_toBottomOf="@id/serverLocationGroup" />
app:layout_constraintVertical_bias="0.2"
app:layout_constraintVertical_chainStyle="packed" />
<org.futo.circles.view.LoadingButton <org.futo.circles.view.LoadingButton
android:id="@+id/btnToken" android:id="@+id/btnToken"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:enabled="false"
android:text="@string/sign_up_with_token" android:text="@string/sign_up_with_token"
app:layout_constraintBottom_toTopOf="@id/tvOr"
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/tvTokenTitle" /> app:layout_constraintTop_toBottomOf="@id/tvTokenTitle" />
...@@ -133,20 +91,18 @@ ...@@ -133,20 +91,18 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center" android:gravity="center"
android:text="@string/or" android:text="@string/or"
app:layout_constraintBottom_toTopOf="@id/tvSubscriptionTitle"
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/btnToken" /> app:layout_constraintTop_toBottomOf="@id/btnToken" />
<TextView <TextView
android:id="@+id/tvSubscriptionTitle" android:id="@+id/tvSubscriptionTitle"
style="@style/headline" style="@style/headline"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center" android:gravity="center"
android:text="@string/create_a_subscription" android:text="@string/create_a_subscription"
app:layout_constraintBottom_toTopOf="@id/btnSubscription" app:layout_constraintBottom_toTopOf="@id/btnSubscription"
...@@ -159,9 +115,7 @@ ...@@ -159,9 +115,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:enabled="false"
android:text="@string/choose_a_subscription" android:text="@string/choose_a_subscription"
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/tvSubscriptionTitle" /> app:layout_constraintTop_toBottomOf="@id/tvSubscriptionTitle" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment