package com.dong.maxhap.nestedlib1

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Stable
data class StableData1_1(
    val id: Int = 1001,
    val name: String = "Stable_1_1",
    val value: Double = 1.1,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_1? = null
)

@Stable
data class NestedStableData1_1(
    val subId: Int = 101,
    val description: String = "Nested stable data for page 1, item 1",
    val count: Int = 100,
    val isEnabled: Boolean = false
)

@Stable
data class StableData1_2(
    val id: Int = 1002,
    val name: String = "Stable_1_2",
    val value: Double = 1.2,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_2? = null
)

@Stable
data class NestedStableData1_2(
    val subId: Int = 102,
    val description: String = "Nested stable data for page 1, item 2",
    val count: Int = 200,
    val isEnabled: Boolean = true
)

@Stable
data class StableData1_3(
    val id: Int = 1003,
    val name: String = "Stable_1_3",
    val value: Double = 1.3,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_3? = null
)

@Stable
data class NestedStableData1_3(
    val subId: Int = 103,
    val description: String = "Nested stable data for page 1, item 3",
    val count: Int = 300,
    val isEnabled: Boolean = false
)

@Stable
data class StableData1_4(
    val id: Int = 1004,
    val name: String = "Stable_1_4",
    val value: Double = 1.4,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_4? = null
)

@Stable
data class NestedStableData1_4(
    val subId: Int = 104,
    val description: String = "Nested stable data for page 1, item 4",
    val count: Int = 400,
    val isEnabled: Boolean = true
)

@Stable
data class StableData1_5(
    val id: Int = 1005,
    val name: String = "Stable_1_5",
    val value: Double = 1.5,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_5? = null
)

@Stable
data class NestedStableData1_5(
    val subId: Int = 105,
    val description: String = "Nested stable data for page 1, item 5",
    val count: Int = 500,
    val isEnabled: Boolean = false
)

@Stable
data class StableData1_6(
    val id: Int = 1006,
    val name: String = "Stable_1_6",
    val value: Double = 1.6,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_6? = null
)

@Stable
data class NestedStableData1_6(
    val subId: Int = 106,
    val description: String = "Nested stable data for page 1, item 6",
    val count: Int = 600,
    val isEnabled: Boolean = true
)

@Stable
data class StableData1_7(
    val id: Int = 1007,
    val name: String = "Stable_1_7",
    val value: Double = 1.7,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_7? = null
)

@Stable
data class NestedStableData1_7(
    val subId: Int = 107,
    val description: String = "Nested stable data for page 1, item 7",
    val count: Int = 700,
    val isEnabled: Boolean = false
)

@Stable
data class StableData1_8(
    val id: Int = 1008,
    val name: String = "Stable_1_8",
    val value: Double = 1.8,
    val isActive: Boolean = true,
    val tags: List<String> = listOf("tag1", "tag2", "tag3"),
    val metadata: Map<String, String> = mapOf("key1" to "value1", "key2" to "value2"),
    val nestedData: NestedStableData1_8? = null
)

@Stable
data class NestedStableData1_8(
    val subId: Int = 108,
    val description: String = "Nested stable data for page 1, item 8",
    val count: Int = 800,
    val isEnabled: Boolean = true
)

@Composable
fun NestedPage1() {
    var showNextPage by remember { mutableStateOf(false) }
    val stableData1 by remember { mutableStateOf(StableData1_1()) }
    val stableData2 by remember { mutableStateOf(StableData1_2()) }
    val stableData3 by remember { mutableStateOf(StableData1_3()) }
    val stableData4 by remember { mutableStateOf(StableData1_4()) }

    
    
    

    var showNextPage1 by remember { mutableStateOf(false) }

    if (showNextPage1) {
        NestedPage2()
        return
    }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(16.dp),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        Text(
            text = "第1层页面 (nestedlib1)",
            fontSize = 24.sp,
            fontWeight = FontWeight.Bold,
            color = Color(0xFF00000),
            modifier = Modifier.padding(bottom = 20.dp)
        )
        Text(
            text = "这是第1行内容",
            fontSize = 14.sp,
            color = Color(17, 31, 47),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第2行内容",
            fontSize = 14.sp,
            color = Color(34, 62, 94),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第3行内容",
            fontSize = 14.sp,
            color = Color(51, 93, 141),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第4行内容",
            fontSize = 14.sp,
            color = Color(68, 124, 188),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第5行内容",
            fontSize = 14.sp,
            color = Color(85, 155, 235),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第6行内容",
            fontSize = 14.sp,
            color = Color(102, 186, 26),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第7行内容",
            fontSize = 14.sp,
            color = Color(119, 217, 73),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第8行内容",
            fontSize = 14.sp,
            color = Color(136, 248, 120),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第9行内容",
            fontSize = 14.sp,
            color = Color(153, 23, 167),
            modifier = Modifier.padding(vertical = 3.dp)
        )
        Text(
            text = "这是第10行内容",
            fontSize = 14.sp,
            color = Color(170, 54, 214),
            modifier = Modifier.padding(vertical = 3.dp)
        )

        Spacer(modifier = Modifier.height(25.dp))
        // 显示@Stable数据信息
        Text(
            text = "StableData1_1: ID=${stableData1.id}, Name=${stableData1.name}",
            fontSize = 12.sp,
            color = Color.Gray,
            modifier = Modifier.padding(vertical = 2.dp)
        )
        Text(
            text = "StableData1_2: ID=${stableData2.id}, Name=${stableData2.name}",
            fontSize = 12.sp,
            color = Color.Gray,
            modifier = Modifier.padding(vertical = 2.dp)
        )
        Text(
            text = "StableData1_3: ID=${stableData3.id}, Name=${stableData3.name}",
            fontSize = 12.sp,
            color = Color.Gray,
            modifier = Modifier.padding(vertical = 2.dp)
        )

        Button(
            onClick = { showNextPage1 = true },
            modifier = Modifier
                .fillMaxWidth()
                .height(45.dp),
            colors = ButtonDefaults.buttonColors(
                backgroundColor = Color(0xFF2196F3)
            )
        ) {
            Text(
                text = "进入同库第2层",
                fontSize = 16.sp,
                fontWeight = FontWeight.Medium,
                color = Color.White
            )
        }
    }
}
