Comments (10)
I've updated to 0.0.9 and it's working now. Thanks, you can close the issue.
from calendar.
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.
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.
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.
Changes merged here and will be released with 0.0.9
from calendar.
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.
@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.
Awesome, thank you for update! :)
And if u migrate to Kotlin 2.0.0 you can use lib 1.0.0 π
from calendar.
@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.
@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)
- Customisation HOT 1
- WeekView centering. HOT 3
- [Feature] Items on every date HOT 4
- NoSuchMethodError: No static method HorizontalPager HOT 6
- Deploy sample to Github pages HOT 4
- Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed.
- Arrows for going backward/forward for year selection for desktop
- Scrolling not supported for horizontal view
- IOS 17.5 BUILD FAILURE with Failed to load native library:libjansi.jnilib. HOT 1
- It cause a Ρrash with compose multiplatform 1.7.x on iOS 17.5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calendar.