|
@@ -1,10 +1,13 @@
|
|
package com.sambath.sbc.screen.register
|
|
package com.sambath.sbc.screen.register
|
|
|
|
|
|
|
|
+import android.content.Intent
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
|
+import android.view.MenuItem
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.widget.ArrayAdapter
|
|
import android.widget.ArrayAdapter
|
|
import com.sambath.sbc.R
|
|
import com.sambath.sbc.R
|
|
|
|
+import com.sambath.sbc.screen.login.LoginActivity
|
|
import kotlinx.android.synthetic.main.activity_register.et_gender
|
|
import kotlinx.android.synthetic.main.activity_register.et_gender
|
|
import kotlinx.android.synthetic.main.activity_register.radioButtonEmail
|
|
import kotlinx.android.synthetic.main.activity_register.radioButtonEmail
|
|
import kotlinx.android.synthetic.main.activity_register.radioButtonPhone
|
|
import kotlinx.android.synthetic.main.activity_register.radioButtonPhone
|
|
@@ -16,6 +19,7 @@ class RegisterActivity : AppCompatActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_register)
|
|
setContentView(R.layout.activity_register)
|
|
|
|
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
|
|
val spinnerData = listOf("Select Gender", "Female", "Male", "Other")
|
|
val spinnerData = listOf("Select Gender", "Female", "Male", "Other")
|
|
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, spinnerData)
|
|
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, spinnerData)
|
|
@@ -26,6 +30,27 @@ class RegisterActivity : AppCompatActivity() {
|
|
setGender()
|
|
setGender()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
+ when (item.itemId) {
|
|
|
|
+ android.R.id.home -> {
|
|
|
|
+ onBackPressed() // Navigate back when the back button (up button) is pressed
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ else -> return super.onOptionsItemSelected(item)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onBackPressed() {
|
|
|
|
+ super.onBackPressed()
|
|
|
|
+
|
|
|
|
+ // Start the LoginActivity
|
|
|
|
+ val intent = Intent(this, LoginActivity::class.java)
|
|
|
|
+ startActivity(intent)
|
|
|
|
+
|
|
|
|
+ // Finish the RegisterActivity to prevent it from going back to the RegisterActivity
|
|
|
|
+ finish()
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun setGender() {
|
|
private fun setGender() {
|
|
if (radioGroup.checkedRadioButtonId == R.id.radioButtonEmail) {
|
|
if (radioGroup.checkedRadioButtonId == R.id.radioButtonEmail) {
|
|
til_email.visibility = View.VISIBLE
|
|
til_email.visibility = View.VISIBLE
|