package com.example.shiftalarm

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class NoticeAdapter(private val notices: List<NoticeItem>) : RecyclerView.Adapter<NoticeAdapter.ViewHolder>() {

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val title: TextView = view.findViewById(R.id.noticeTitle)
        val date: TextView = view.findViewById(R.id.noticeDate)
        val content: TextView = view.findViewById(R.id.noticeContent)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_notice, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val item = notices[position]
        holder.title.text = item.title
        holder.date.text = item.date
        holder.content.text = item.content
    }

    override fun getItemCount(): Int = notices.size
}
