package com.sp365.calendar import android.content.Context import android.util.AttributeSet import android.widget.LinearLayout import androidx.compose.ui.platform.ComposeView import com.sp365.calendar.model.EventDayItem import com.sp365.calendar.model.ViewType import java.time.LocalDate class RtnCalendarView : LinearLayout { private var initDate: LocalDate = LocalDate.now() private var events: MutableList = mutableListOf(); private var viewType: ViewType = ViewType.Day; constructor(context: Context) : super(context) { configureComponent(context) } constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { configureComponent(context) } constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( context, attrs, defStyleAttr ) { configureComponent(context) } fun setInitDate(date: LocalDate) { this.initDate = date } fun setEvents(events: MutableList) { this.events = events } fun setViewType(viewType: ViewType) { this.viewType = viewType }; private fun configureComponent(context: Context) { layoutParams = LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ) ComposeView(context).also { it.layoutParams = LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ) it.setContent { CalendarComponent(initDate, viewType, events) } addView(it) } } }