package com.narutohuo.xindazhou.service.ui

import android.content.Intent
import android.os.Bundle
import android.widget.TextView
import com.narutohuo.xindazhou.R
import com.narutohuo.xindazhou.common.ui.BaseActivity
import com.narutohuo.xindazhou.databinding.ActivityServiceBinding
import com.narutohuo.xindazhou.community.ui.CommunityActivity
import com.narutohuo.xindazhou.shop.ui.ShopActivity
import com.narutohuo.xindazhou.user.ui.UserActivity
import com.narutohuo.xindazhou.vehicle.ui.VehicleActivity

/**
 * 服务 Activity
 * 
 * 架构A：每个页面一个Activity
 * 显示服务相关功能
 */
class ServiceActivity : BaseActivity<ActivityServiceBinding>() {
    
    override fun getViewBinding(): ActivityServiceBinding {
        return ActivityServiceBinding.inflate(layoutInflater)
    }
    
    override fun initView() {
        // 设置内容
        val textView = TextView(this)
        textView.text = "服务页面\n（待实现）"
        textView.textSize = 18f
        textView.gravity = android.view.Gravity.CENTER
        
        // 将内容添加到布局中
        binding.contentContainer.removeAllViews()
        binding.contentContainer.addView(textView)
        
        // 设置底部导航栏
        setupBottomNavigation()
    }
    
    private fun setupBottomNavigation() {
        binding.bottomNavView.selectedItemId = R.id.serviceFragment
        binding.bottomNavView.setOnItemSelectedListener { item ->
            when (item.itemId) {
                R.id.vehicleFragment -> {
                    startActivity(Intent(this, VehicleActivity::class.java))
                    finish()
                    true
                }
                R.id.communityFragment -> {
                    startActivity(Intent(this, CommunityActivity::class.java))
                    finish()
                    true
                }
                R.id.serviceFragment -> {
                    // 当前已在服务模块，不需要跳转
                    true
                }
                R.id.shopFragment -> {
                    startActivity(Intent(this, ShopActivity::class.java))
                    finish()
                    true
                }
                R.id.userFragment -> {
                    startActivity(Intent(this, UserActivity::class.java))
                    finish()
                    true
                }
                else -> false
            }
        }
    }
}

