Comments (9)
Are you using the compose library or view?
from calendar.
i use view 👍
from calendar.
Unfortunately, this is not possible at the moment and I do not think it is worth adding to the core library as the use case is too specific. However, you can fork the library and add these changes for personal use. I tried to see if I could add it but found myself rewriting more things than I wanted.
Here's what it looks like just by changing this and this from dayHolders.count()
to 5 and setting the views with Saturday and Sunday to View.GONE
(of course you would need to update the weekday header too):
from calendar.
Closing this as there is no plan to implement it in the library
from calendar.
Hey ! I tested your solution look at my code it doesn't really work from my fork :
If I take Example2Fragment :
calendarView.dayBinder = object : MonthDayBinder<DayViewContainer> {
override fun create(view: View) = DayViewContainer(view)
override fun bind(container: DayViewContainer, data: CalendarDay) {
container.day = data
val textView = container.textView
if (isWeekend(data.date)) {
// Masquer la vue du jour si c'est un week-end
textView.makeInVisible()
} else {
textView.makeVisible()
textView.text = data.date.dayOfMonth.toString()
if (data.position == DayPosition.MonthDate) {
when (data.date) {
selectedDate -> {
textView.setTextColorRes(R.color.example_2_white)
textView.setBackgroundResource(R.drawable.example_2_selected_bg)
}
today -> {
textView.setTextColorRes(R.color.example_2_red)
textView.background = null
}
else -> {
textView.setTextColorRes(R.color.example_2_black)
textView.background = null
}
}
} else {
textView.makeInVisible()
}
}
}
// Fonction pour vérifier si une date est un jour de week-end
private fun isWeekend(date: LocalDate): Boolean {
val dayOfWeek = date.dayOfWeek
return dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY
}
}
This modification allows me to hide weekends.
and I've also modified the WeekHolder code:
fun inflateWeekView(parent: LinearLayout): View {
return WidthDivisorLinearLayout(parent.context).apply {
weekContainer = this
val width = if (daySize.parentDecidesWidth) MATCH_PARENT else WRAP_CONTENT
val height = if (daySize.parentDecidesHeight) MATCH_PARENT else WRAP_CONTENT
val weight = if (daySize.parentDecidesHeight) 1f else 0f
layoutParams = LinearLayout.LayoutParams(width, height, weight)
orientation = LinearLayout.HORIZONTAL
weightSum = 5.toFloat()
widthDivisorForHeight = if (daySize == DaySize.Square) 5 else 0
for (holder in dayHolders) {
addView(holder.inflateDayView(this))
}
}
}
But with these changes I've got an empty page!
from calendar.
widthDivisorForHeight = if (daySize == DaySize.Square) 5 else 0
for (holder in dayHolders) { // This is a loop of 7 items, you need to add 5 items
addView(holder.inflateDayView(this))
}
from calendar.
It was the same problem look the screenshot
from calendar.
And I did modify the code though :
fun inflateWeekView(parent: LinearLayout): View {
return WidthDivisorLinearLayout(parent.context).apply {
weekContainer = this
val width = if (daySize.parentDecidesWidth) MATCH_PARENT else WRAP_CONTENT
val height = if (daySize.parentDecidesHeight) MATCH_PARENT else WRAP_CONTENT
val weight = if (daySize.parentDecidesHeight) 1f else 0f
layoutParams = LinearLayout.LayoutParams(width, height, weight)
orientation = LinearLayout.HORIZONTAL
weightSum = 5.toFloat()
widthDivisorForHeight = if (daySize == DaySize.Square) 5 else 0
for (holder in dayHolders) { // This is a loop of 7 items, you need to add 5 items
addView(holder.inflateDayView(this))
}
}
}
from calendar.
The worst thing is when I put the code like this I get one result out of 4 which is really good! but for 5 impossible ...
fun inflateWeekView(parent: LinearLayout): View {
return WidthDivisorLinearLayout(parent.context).apply {
weekContainer = this
val width = if (daySize.parentDecidesWidth) MATCH_PARENT else WRAP_CONTENT
val height = if (daySize.parentDecidesHeight) MATCH_PARENT else WRAP_CONTENT
val weight = if (daySize.parentDecidesHeight) 1f else 0f
layoutParams = LinearLayout.LayoutParams(width, height, weight)
orientation = LinearLayout.HORIZONTAL
weightSum = 8.toFloat()
widthDivisorForHeight = if (daySize == DaySize.Square) 4 else 0
for (holder in dayHolders) {
addView(holder.inflateDayView(this))
}
}
}
from calendar.
Related Issues (20)
- Month selection triggers multiple times and with invalid data as well HOT 6
- Exception occurs with material3-window-size-class HOT 1
- Crash using Compose BOM 2024-02-00 HOT 1
- Don't want to show extra adjusted start and end dates in WeekCalender HOT 1
- Range Date Picker selector in WeekCalendar HOT 1
- Add Grid Calendar
- Preload view in MonthDayBinder HOT 3
- Home Sample Sample Inquiry HOT 1
- Calendar DaysView
- Single Selection in Vertical Calendar HOT 1
- can not implement single selection HOT 1
- Consider turning off corelibrarydesugaring for this lib HOT 4
- Show week numbers HOT 1
- from example1 to exapmle8,i can't find this example HOT 1
- help HOT 1
- how can i show the lunar calendar's bellow the number? HOT 2
- Consider multiple platforms?
- Exception after updating dependencies Compose 1.7.0-beta01 Kotlin 1.9.24 HOT 2
- Bug with WeekCalendar
- Desugaring required even if the min sdk is set to 28 (MultiModule project) HOT 3
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.