diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2f3ec6c..871f62d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ android:supportsRtl="true" android:theme="@style/Theme.GridFlow"> @@ -22,6 +22,11 @@ + \ No newline at end of file diff --git a/app/src/main/java/sh/sar/gridflow/LoginActivity.kt b/app/src/main/java/sh/sar/gridflow/LoginActivity.kt new file mode 100644 index 0000000..61c1ffb --- /dev/null +++ b/app/src/main/java/sh/sar/gridflow/LoginActivity.kt @@ -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 + } +} diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..647263c --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +