package org.tensorflow.lite.examples.poseestimation

import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

class SignupActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_signup)

        // 绑定控件
        val usernameEdit = findViewById<EditText>(R.id.editUsername)
        val passwordEdit = findViewById<EditText>(R.id.editPassword)
        val passwordAgainEdit = findViewById<EditText>(R.id.editPasswordAgain)
        val signupBtn = findViewById<Button>(R.id.btnSignup)
        val loginTab = findViewById<TextView>(R.id.tabLogin)

        // 注册按钮点击事件
        signupBtn.setOnClickListener {
            val username = usernameEdit.text.toString().trim()
            val password = passwordEdit.text.toString().trim()
            val passwordAgain = passwordAgainEdit.text.toString().trim()

            // 表单验证
            if (username.isEmpty()) {
                usernameEdit.error = "请输入用户名"
                return@setOnClickListener
            }
            if (password.isEmpty()) {
                passwordEdit.error = "请输入密码"
                return@setOnClickListener
            }
            if (passwordAgain.isEmpty()) {
                passwordAgainEdit.error = "请确认密码"
                return@setOnClickListener
            }

            // 验证两次密码是否一致
            if (password != passwordAgain) {
                passwordAgainEdit.error = "请确认密码"
                Toast.makeText(this, "两次输入的密码不一致", Toast.LENGTH_SHORT).show()
                return@setOnClickListener
            }

            // TODO: 这里添加实际的注册逻辑
            Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show()
            finish()
        }

        // Login Tab点击事件
        loginTab.setOnClickListener {
            finish()
        }
    }
} 