diff --git a/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml b/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml index b87d9441..868a067b 100644 --- a/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml +++ b/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml @@ -11,7 +11,7 @@ + android:name="com.kizitonwose.calendar.compose.multiplatform.MainActivity"> diff --git a/compose-multiplatform/sample/src/commonMain/kotlin/App.kt b/compose-multiplatform/sample/src/commonMain/kotlin/App.kt index abcc1230..8cbda441 100644 --- a/compose-multiplatform/sample/src/commonMain/kotlin/App.kt +++ b/compose-multiplatform/sample/src/commonMain/kotlin/App.kt @@ -1,3 +1,4 @@ + import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column @@ -47,9 +48,11 @@ fun App() { val widthPx = maxWidth.value.roundToInt() val count = if (widthPx in 650..800) 2 else widthPx / 400 Row { - repeat(count) { - VerticalDivider() + repeat(count) { index -> Demo(modifier = Modifier.weight(1f)) + if (index < count - 1) { + VerticalDivider() + } } } } else { diff --git a/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt b/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt index 9322c986..81b2edc6 100644 --- a/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt +++ b/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt @@ -10,8 +10,10 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.lazy.LazyListState @@ -105,7 +107,16 @@ fun Example10Page(adjacentYears: Int = 50) { } HorizontalYearCalendar( modifier = Modifier - .fillMaxSize() + .fillMaxWidth() + .then( + if (isMobile()) { + Modifier.fillMaxHeight() + } else { + // Don't stretch vertically on very + // large displays (web+desktop) + Modifier.heightIn(max = 920.dp) + }, + ) .testTag("Calendar"), state = state, monthColumns = if (isPortrait) { diff --git a/compose-multiplatform/sample/src/commonMain/kotlin/Example11Page.kt b/compose-multiplatform/sample/src/commonMain/kotlin/Example11Page.kt index a526d1d7..2c70c18d 100644 --- a/compose-multiplatform/sample/src/commonMain/kotlin/Example11Page.kt +++ b/compose-multiplatform/sample/src/commonMain/kotlin/Example11Page.kt @@ -47,54 +47,50 @@ fun Example11Page(adjacentYears: Int = 50) { val selections = remember { mutableStateListOf() } val daysOfWeek = remember { daysOfWeek() } BoxWithConstraints( - modifier = Modifier.fillMaxSize(), + modifier = Modifier + .fillMaxSize() + .background(Color.White), ) { val isTablet = maxWidth >= 600.dp - Column( + val state = rememberYearCalendarState( + startYear = currentYear, + endYear = endYear, + firstVisibleYear = currentYear, + firstDayOfWeek = daysOfWeek.first(), + ) + VerticalYearCalendar( modifier = Modifier .fillMaxSize() - .background(Color.White), - ) { - val state = rememberYearCalendarState( - startYear = currentYear, - endYear = endYear, - firstVisibleYear = currentYear, - firstDayOfWeek = daysOfWeek.first(), - ) - VerticalYearCalendar( - modifier = Modifier - .fillMaxSize() - .testTag("Calendar"), - state = state, - dayContent = { day -> - Day( - day = day, - isSelected = selections.contains(day), - isTablet = isTablet, - ) { clicked -> - if (selections.contains(clicked)) { - selections.remove(clicked) - } else { - selections.add(clicked) - } + .testTag("Calendar"), + state = state, + dayContent = { day -> + Day( + day = day, + isSelected = selections.contains(day), + isTablet = isTablet, + ) { clicked -> + if (selections.contains(clicked)) { + selections.remove(clicked) + } else { + selections.add(clicked) } - }, - calendarScrollPaged = false, - contentHeightMode = YearContentHeightMode.Wrap, - monthVerticalSpacing = 20.dp, - monthHorizontalSpacing = if (isTablet) 52.dp else 10.dp, - contentPadding = PaddingValues(horizontal = if (isTablet) 52.dp else 10.dp), - isMonthVisible = { - it.yearMonth >= currentMonth - }, - yearHeader = { - YearHeader(it.year) - }, - monthHeader = { - MonthHeader(it) - }, - ) - } + } + }, + calendarScrollPaged = false, + contentHeightMode = YearContentHeightMode.Wrap, + monthVerticalSpacing = 20.dp, + monthHorizontalSpacing = if (isTablet) 52.dp else 10.dp, + contentPadding = PaddingValues(horizontal = if (isTablet) 52.dp else 10.dp), + isMonthVisible = { + it.yearMonth >= currentMonth + }, + yearHeader = { + YearHeader(it.year) + }, + monthHeader = { + MonthHeader(it) + }, + ) } } diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example11Page.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example11Page.kt index 6cdea3b5..ea915fd4 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example11Page.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example11Page.kt @@ -54,7 +54,7 @@ fun Example11Page(adjacentYears: Long = 50) { val daysOfWeek = remember { daysOfWeek() } val config = LocalConfiguration.current val isTablet = config.smallestScreenWidthDp >= 600 - Column( + Box( modifier = Modifier .fillMaxSize() .background(Color.White), diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example3Fragment.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example3Fragment.kt index 69b04004..a3123440 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example3Fragment.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example3Fragment.kt @@ -273,7 +273,7 @@ class Example3Fragment : BaseFragment(R.layout.example_3_fragment), HasBackButto override fun bind(container: MonthViewContainer, data: CalendarMonth) { // Setup each header day text if we have not done that already. if (container.legendLayout.tag == null) { - container.legendLayout.tag = data.yearMonth + container.legendLayout.tag = true container.legendLayout.children.map { it as TextView } .forEachIndexed { index, tv -> tv.text = daysOfWeek[index].name.first().toString() diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example5Fragment.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example5Fragment.kt index f8739cc2..127388a1 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example5Fragment.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example5Fragment.kt @@ -192,7 +192,7 @@ class Example5Fragment : BaseFragment(R.layout.example_5_fragment), HasToolbar { override fun bind(container: MonthViewContainer, data: CalendarMonth) { // Setup each header day text if we have not done that already. if (container.legendLayout.tag == null) { - container.legendLayout.tag = data.yearMonth + container.legendLayout.tag = true container.legendLayout.children.map { it as TextView } .forEachIndexed { index, tv -> tv.text = daysOfWeek[index].displayText(uppercase = true) diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example6Fragment.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example6Fragment.kt index 7095711d..2e30aeb9 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example6Fragment.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example6Fragment.kt @@ -128,7 +128,7 @@ class Example6Fragment : BaseFragment(R.layout.example_6_fragment), HasBackButto container.textView.text = data.yearMonth.displayText(short = true) // Setup each header day text if we have not done that already. if (container.legendLayout.tag == null) { - container.legendLayout.tag = data.yearMonth + container.legendLayout.tag = true container.legendLayout.children.map { it as TextView } .forEachIndexed { index, tv -> tv.text = daysOfWeek[index].name.first().toString() diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example8Fragment.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example8Fragment.kt index abb9adbd..067e90fb 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example8Fragment.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/view/Example8Fragment.kt @@ -73,8 +73,8 @@ class Example8Fragment : BaseFragment(R.layout.example_8_fragment), HasToolbar { override fun create(view: View) = MonthHeaderViewContainer(view) override fun bind(container: MonthHeaderViewContainer, data: CalendarMonth) { // Setup each header day text if we have not done that already. - if (container.binding.root.tag == null) { - container.binding.root.tag = data.yearMonth + if (container.binding.legendLayout.root.tag == null) { + container.binding.legendLayout.root.tag = true container.binding.legendLayout.root.children .map { it as TextView } .forEachIndexed { index, tv ->