package com.aiosman.riderpro

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Preview
@Composable
fun CommentsScreen() {
    StatusBarMaskLayout(
        darkIcons = true,
        maskBoxBackgroundColor = Color(0xFFFFFFFF)
    ) {
        Column(
            modifier = Modifier
                .weight(1f)
                .background(color = Color(0xFFFFFFFF))
                .padding(horizontal = 16.dp)
        ) {
            NoticeScreenHeader("COMMENTS")
            Spacer(modifier = Modifier.height(28.dp))
            LazyColumn(
                modifier = Modifier.weight(1f)
            ) {
                item {
                    repeat(20) {
                        CommentsItem()
                    }
                    BottomNavigationPlaceholder()
                }
            }
        }
    }

}

@Composable
fun NoticeScreenHeader(
    title:String
) {
    val nav = LocalNavController.current
    Row(
        modifier = Modifier.fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Image(
            painter = painterResource(id = R.drawable.rider_pro_nav_back),
            contentDescription = title,
            modifier = Modifier.size(16.dp).clickable {
                nav.popBackStack()
            }
        )
        Spacer(modifier = Modifier.size(12.dp))
        Text(title, fontWeight = FontWeight.Bold, fontSize = 17.sp)
        Spacer(modifier = Modifier.weight(1f))
        Image(
            painter = painterResource(id = R.drawable.rider_pro_more_horizon),
            contentDescription = "More",
            modifier = Modifier.size(24.dp)
        )

    }
}

@Composable
fun CommentsItem() {
    Box(
        modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)
    ) {
        Row(
            modifier = Modifier.fillMaxWidth()
        ) {
            Image(
                painter = painterResource(id = R.drawable.default_avatar),
                contentDescription = "Avatar",
                modifier = Modifier
                    .size(40.dp)
            )
            Spacer(modifier = Modifier.size(12.dp))
            Column(
                modifier = Modifier.weight(1f)
            ) {
                Text("Username", fontWeight = FontWeight.Bold, fontSize = 16.sp)
                Spacer(modifier = Modifier.size(4.dp))
                Text("Content", color = Color(0x99000000), fontSize = 12.sp)
                Spacer(modifier = Modifier.size(4.dp))
                Text("Date", color = Color(0x99000000), fontSize = 12.sp)
                Spacer(modifier = Modifier.height(16.dp))
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                ) {
                    Image(
                        painter = painterResource(id = R.drawable.rider_pro_like),
                        contentDescription = "Like",
                        modifier = Modifier.size(16.dp),
                    )
                    Text(
                        "270",
                        color = Color(0x99000000),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(start = 4.dp)
                    )
                    Spacer(modifier = Modifier.width(45.dp))
                    Image(
                        painter = painterResource(id = R.drawable.rider_pro_comments),
                        contentDescription = "Comments",
                        modifier = Modifier.size(16.dp)
                    )
                    Text(
                        "270",
                        color = Color(0x99000000),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(start = 4.dp)
                    )
                }
            }
            Box {
                Image(
                    painter = painterResource(id = R.drawable.default_moment_img),
                    contentDescription = "More",
                    modifier = Modifier.size(64.dp)
                )
            }
        }
    }
}