forked from LibreMV/GridFlow
login ui test
This commit is contained in:
89
app/src/main/java/sh/sar/gridflow/LoginActivity.kt
Normal file
89
app/src/main/java/sh/sar/gridflow/LoginActivity.kt
Normal file
@@ -0,0 +1,89 @@
|
||||
package sh.sar.gridflow
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import sh.sar.gridflow.databinding.ActivityLoginBinding
|
||||
|
||||
class LoginActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityLoginBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
setupClickListeners()
|
||||
}
|
||||
|
||||
private fun setupClickListeners() {
|
||||
binding.btnSignIn.setOnClickListener {
|
||||
handleSignIn()
|
||||
}
|
||||
|
||||
binding.btnRegister.setOnClickListener {
|
||||
handleRegister()
|
||||
}
|
||||
|
||||
binding.btnForgotPassword.setOnClickListener {
|
||||
handleForgotPassword()
|
||||
}
|
||||
|
||||
binding.btnPayWithoutAccount.setOnClickListener {
|
||||
handlePayWithoutAccount()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSignIn() {
|
||||
val mobileNumber = binding.etMobileNumber.text.toString().trim()
|
||||
val password = binding.etPassword.text.toString().trim()
|
||||
|
||||
if (validateInput(mobileNumber, password)) {
|
||||
// TODO: Implement actual authentication logic
|
||||
// For now, just navigate to main activity
|
||||
Toast.makeText(this, "Signing in...", Toast.LENGTH_SHORT).show()
|
||||
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleRegister() {
|
||||
Toast.makeText(this, "Register functionality coming soon", Toast.LENGTH_SHORT).show()
|
||||
// TODO: Navigate to registration screen
|
||||
}
|
||||
|
||||
private fun handleForgotPassword() {
|
||||
Toast.makeText(this, "Forgot password functionality coming soon", Toast.LENGTH_SHORT).show()
|
||||
// TODO: Navigate to forgot password screen
|
||||
}
|
||||
|
||||
private fun handlePayWithoutAccount() {
|
||||
Toast.makeText(this, "Guest payment functionality coming soon", Toast.LENGTH_SHORT).show()
|
||||
// TODO: Navigate to guest payment flow
|
||||
}
|
||||
|
||||
private fun validateInput(mobileNumber: String, password: String): Boolean {
|
||||
if (mobileNumber.isEmpty()) {
|
||||
binding.etMobileNumber.error = "Mobile number is required"
|
||||
return false
|
||||
}
|
||||
|
||||
if (password.isEmpty()) {
|
||||
binding.etPassword.error = "Password is required"
|
||||
return false
|
||||
}
|
||||
|
||||
// Basic Maldives mobile number validation (7xxxxxx format)
|
||||
if (!mobileNumber.matches(Regex("^[79]\\d{6}$"))) {
|
||||
binding.etMobileNumber.error = "Enter a valid Maldives mobile number"
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user