Git Product home page Git Product logo

Comments (10)

s-septimiu avatar s-septimiu commented on July 24, 2024 1

I've updated to 0.0.9 and it's working now. Thanks, you can close the issue.

from calendar.

s-septimiu avatar s-septimiu commented on July 24, 2024

Initially, I wanted to use the CalendarView alone, and have my own header with left-right arrows so I can change the month in the view, but that doesn't work.

If you help me using only the calendarview, as I don't need the sliding animation, I just need to swap months in the calendarView.. that would be great! @WojciechOsak

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

Hey @s-septimiu, I can not reproduce it, but I've found similar issue in jetpack compose, could you try this: https://stackoverflow.com/questions/76865105/jetpack-compose-horizontalpager-exception in your project?

Anyway if you don't want to use swipe animation you can use pagerState like this:

val pagerState = rememberPagerState(
			initialPage = 100000 / 2,
			pageCount = { 100000 },
		)
		val scope = rememberCoroutineScope()
		Column {
			Row {
				Button(onClick = {
					scope.launch { pagerState.scrollToPage(pagerState.currentPage - 1) }
				}) {
					Text("LEFT")
				}
				Button(onClick = {
					scope.launch {
						pagerState.scrollToPage(pagerState.currentPage + 1)
					}
				}) {
					Text("RIGHT")
				}
			}
			HorizontalCalendarView(
				startDate = LocalDate.today(),
				pagerState = pagerState
			) { monthOffset ->
				CalendarView(
					config = rememberCalendarState(
						startDate = LocalDate.today(),
						monthOffset = monthOffset,
						showNextMonthDays = true,
						showPreviousMonthDays = true,
						showHeader = true,
						showWeekdays = true,
					),
				)
			}
		}

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

To use it only with CalendarView you need something like this:

val config = rememberCalendarState(
			startDate = LocalDate.today(),
			monthOffset = 0,
			showNextMonthDays = true,
			showPreviousMonthDays = true,
			showHeader = true,
			showWeekdays = true,
		)

		Column {
			Row {
				Button(onClick = {
					val currentConfig = config.value
					config.value = config.value.copy(
						monthYear = currentConfig.monthYear.toLocalDate()
							.minus(1, DateTimeUnit.MONTH).toMonthYear()
					)
				}) {
					Text("LEFT")
				}
				Button(onClick = {
					val currentConfig = config.value
					config.value = config.value.copy(
						monthYear = currentConfig.monthYear.toLocalDate()
							.plus(1, DateTimeUnit.MONTH).toMonthYear()
					)
				}) {
					Text("RIGHT")
				}
			}
			CalendarView(
				config = config,
			)
		}

but it looks like I've made mistake in the code of CalendarView, and I should not use remember for yearMonth - I am sorry for that! So above example will not work without lib update / fork.

I got some bugs to fix and update compose and kotlin to 2.0, soooo I am going to release new version of the lib so you can use CalendarView without HorizontalCalendarView.

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

Changes merged here and will be released with 0.0.9

from calendar.

s-septimiu avatar s-septimiu commented on July 24, 2024

I agree with you that the remember made this impossible. Thanks a lot for the quick reply and fix, looking forward for the 0.0.9

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

@s-septimiu lib is released πŸš€
Try 0.0.9 (Compose 1.6.1) or lib 1.0.0 (it supports Compose 2.0.0).

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

Awesome, thank you for update! :)
And if u migrate to Kotlin 2.0.0 you can use lib 1.0.0 πŸš€

from calendar.

WojciechOsak avatar WojciechOsak commented on July 24, 2024

@s-septimiu hey, update about "No static method HorizontalPager" issue, I think I have find the root of the problem, and fix will be delivered in next couple hours in 1.0.1 version, please try and let me know if it helps if u still got that error.

from calendar.

s-septimiu avatar s-septimiu commented on July 24, 2024

@WojciechOsak unfortunately I don't have kotlin 2+ in my project so 1.0.1 won't run... If I update and I still see that issue open I will give you an update.

from calendar.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.