package com.za.sdk.demo

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.za.base.view.CommonButton
import com.za.common.log.LogUtil
import com.za.sdk.demo.ui.theme.Zd_sdk_demoTheme
import com.za.ui.main.ServiceLauncherActivity

class ActionActivity : ComponentActivity() {
	override fun onCreate(savedInstanceState : Bundle?) {
		super.onCreate(savedInstanceState)
		enableEdgeToEdge()
		setContent {
			Zd_sdk_demoTheme {
				Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
					Box(modifier = Modifier
						.fillMaxSize()
						.padding(innerPadding),
						contentAlignment = Alignment.Center) {
						CommonButton(text = "跳转到服务页") {
							val name = intent.data?.getQueryParameter("driverName")
							val phone = intent.data?.getQueryParameter("driverPhone")
							val taskCode = intent.data?.getQueryParameter("taskCode")
							val vehicleName = intent.data?.getQueryParameter("rescueVehicle")
							LogUtil.print("参数",
								"name:$name,phone:$phone,taskCode:$taskCode,vehicleName:$vehicleName")

							Log.e("ActionActivity",
								"name:$name,phone:$phone,taskCode:$taskCode,vehicleName:$vehicleName")
							val intent =
								Intent(this@ActionActivity, ServiceLauncherActivity::class.java)
							intent.putExtra("driverName", name)
							intent.putExtra("driverPhone", phone)
							intent.putExtra("taskCode", taskCode)
							intent.putExtra("rescueVehicle", vehicleName)
							startActivity(intent)
						}
					}
				}
			}
		}
	}
}
