thasianx / elegantcalendar Goto Github PK
View Code? Open in Web Editor NEWThe elegant full screen calendar missed in SwiftUI.
License: MIT License
The elegant full screen calendar missed in SwiftUI.
License: MIT License
Very nice calendar... Wondering if I can replace the events on days (You have them as Apple) with a JSON Payload from an API?
Have you seen any issues when using 2 MonthlyCalendars in a single app? I am using one instance for schedule data and a separate instance with its own data and behavior for event data. When I do this both calendars disappear. As soon as I comment out one of the calendars, then the other works properly.
This is a really awesome and beautiful library for iOS. I'm wondering whether this have macOS support?
I can not figure out how to segue from the visit list cell to another view controller when I add a tap gesture recognizer to this part of the code. I would like to be able to go to another page on my app once the user selects a certain appointment on a date. Thank you
var visitsPreviewList: some View {
VStack(spacing: 0) {
ForEach(visits[range]) { visit in
VisitCell(visit: visit)
.gesture(TapGesture().onEnded {
//Would like to segue to another ViewController here
print(visit.uid)
})
}
}
}
It's the only SwiftUI calendar library of it's kind, very nice! Will you @ThasianX continue to maintain it?
Hi guys, I just got the code of the demo and customised as needed. Sent that code to another project and got that:
I can not find any reason for that. I am using the kiwiGreen theme.
`let configuration = CalendarConfiguration(
calendar: currentCalendar,
startDate: ascVisits.first!.theDate,
endDate: ascVisits.last!.theDate)
calendarManager = ElegantCalendarManager(
configuration: configuration,
initialMonth: initialMonth)
visitsByDay = Dictionary(
grouping: ascVisits,
by: { currentCalendar.startOfDay(for: $0.theDate) })
calendarManager.datasource = self
calendarManager.delegate = self
`
`
var body: some View {
VStack {
ElegantCalendarView(calendarManager: calendarManager)
.theme(calendarTheme).horizontal()
Spacer()
}
}
`
Maybe, the NavigationView?
Issue
When running the Example project with Xcode 13, I am getting warnings in the console log:
ForEach<Array<String>, String, ModifiedContent<ModifiedContent<Text, _FrameLayout>, _EnvironmentKeyWritingModifier<Optional<Color>>>>: the ID T occurs multiple times within the collection, this will give undefined results!
There are six of these in a series logged the calendar is displayed.
iOS Version
This only happens when running against iOS 15. When I run against a simulator in iOS 14, it is quiet and I only get the expected messages from the Example project.
(This too is happening from my app that uses this package, but was easier and cleaner to verify this behavior in the include Example here).
I will try to hunt this down, but maybe someone else already has a solution. The calendar does appear to be working iOS 15 despite these warnings, but worry something in SwitUI may break the cause of this in the future.
I am running into an issue where I have an app with a Navigation bar at the top and a toolbar at the bottom. When I put the calendar on the page it takes up a lot of the page. So If there were different options for spacing vertically that would be great!
I want to add a color code on important dates, both in month and whole year view. is it possible?
is it possible to have an array of dates to be colored on the calender differently? pls add if cant ty.
Is there any way to change startDate and endDate dynamically?
I was looking into the source code and found a line in CalendarConfiguration.swift: "/// Any changes to the configuration will reset the calendar based on its new settings"
But I didn't understand how to do it. First, the CalendarConfiguration have let property itself in MontlyCalendarManager and in the CalendarConfiguration struct the startDate and endDate properties are also have let
When I change them to var, the dates changes, but the months remain the same. In which direction should I move?
First, thank you for the beautiful calendar.
I have a @State variable declared as
@State var selectedDate : Date = Date()
I attempt to change that as follows
func calendar(didSelectDay date: Date) { self.selectedDate = date print(selectedDate) }
The variable is never updated even though it goes through the code and no error is reported. Any ideas?
Occurs whenever the calendar is opened
A example for swift playground would nice.
Hi, I am evaluating multiple SwiftUI Customizable calendar libraries to use with my new app. I would want to achieve something like this image below. Would it be possible to achieve this using ElegantCalendar? If yes, what's the path should I be taking to do this? Happy to contribute as well if something is missing.
Thanks in advance.
Thank you for the beautiful library. When you open the library for navigation, it shows the month, and when you press back, it returns to the year display and then goes to the other screen.
Great job on developing this project. The calendar looks wonderful!
I am experiencing a strange issue with the example project where the start of the month doesn't match up with the actual days of the week in the Monthly Calendar view.
Here is the screenshot from my simulator:
As you can see, today is Wednesday 3 March 2021 and the calendar view is aligned correctly with the days of the week.
However, when I run the example project on my iPhoneX it shows this:
As you can see, it aligns today's date(Wednesday 03 March 2021) with Tuesday rather than Wednesday.
I haven't changed any code yet the CalendarView displays differently on Simulator and device. What could be causing this?
Occurs when scrolling to new months
Hi ThasianX, I want to display event of EventKit with recurrence in calendar, can ElegantCalendar display recurrence event? how to implement recurrence event?
I am a new user user to ElegantCalendar, but I have noticed that the legend for week days don't match the actual week day of dates.
In my region monday is the first day of the week, but on top of the calendar it still shows "S M T W T F S", but it should show "M T W T F S S" as the days are shown in the correct "column" (monday is first in this case).
I imported library by using Swift packages. After add ElegantCalendarView to view's body, I received fatalError at Image+Custom.swift file at line 9. I found that "uturn.left" image is already existed in ElegantCalendar.xcassets. please tell me how can I fix this?
When I fetched data from server, what I should do to reload datasource
I used to reproduce the example but get unwanted behaviour, if anyone could help I will appreciate it!
The toy code is
import SwiftUI
import ElegantCalendar
struct TestCal: View {
@ObservedObject private var calendarManager: MonthlyCalendarManager
@State private var calendarTheme: CalendarTheme = .red
let currentCalendar = Calendar.current
init(startTime: Date, endTime: Date) {
let cfg = CalendarConfiguration(calendar: currentCalendar,
startDate: startTime,
endDate: endTime)
calendarManager = MonthlyCalendarManager(configuration: cfg, initialMonth: nil)
calendarManager.datasource = self
calendarManager.delegate = self
}
var body: some View {
VStack {
MonthlyCalendarView(calendarManager: calendarManager)
.theme(calendarTheme)
.axis(.horizontal)
}
}
}
extension TestCal: MonthlyCalendarDataSource {
func calendar(backgroundColorOpacityForDate date: Date) -> Double {
return 0.9
}
func calendar(canSelectDate date: Date) -> Bool {
let day = currentCalendar.dateComponents([.day], from: date).day!
return day != 4
}
func calendar(viewForSelectedDate date: Date, dimensions size: CGSize) -> AnyView {
return Text("Text").erased
}
}
extension TestCal: MonthlyCalendarDelegate {
func calendar(didSelectDay date: Date) {
print("Selected date: \(date)")
}
func calendar(willDisplayMonth date: Date) {
print("Will show month: \(date)")
}
}
func dateInit () -> DateFormatter {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyyMMdd"
dateFormatter.locale = Locale(identifier: "en_US")
dateFormatter.timeZone = TimeZone.current
return dateFormatter
}
let dateFormatter = dateInit()
let thisTime = "20221102"
let thatTime = "20230111"
struct TestCal_Previews: PreviewProvider {
static var previews: some View {
TestCal(
startTime: dateFormatter.date(from: thisTime)!, endTime: dateFormatter.date(from: thatTime)!
)
}
}
As shown in the preview, the protocol MonthlyCalendarDataSource
's func calendar(backgroundColorOpacityForDate date: Date)
not worked, or the theme is not loaded.
Would be nice to be able to set the size of the views instead of it always being full screen
I would like to tighten up some of the vertical whitespace between rows a bit, particularly for smaller devices. Its a beautiful layout as is, but on smaller devices, it does not leave much room for the aux view at the bottom.
Is there any programmatic way to do that? i tried changing the frame height of the MonthlyCalendar view, but that just gave me weird results.
What am I missing?
Hi,
I saw the horizontal monthly calendar scrolling was implemented recently which is cool. Although when you apply .frame() modifier to MonthlyCalendarView it is being shifted to the right. Please see the screenshot. I guess it is related to ElegantPages? Could you point me in the right direction and I would try to find the issue.
I am new to coding and it's the first time I submit an issue, please tell me if I did something wrong.
It's a very cool calendar library, trying to implement it in the habit tracker app I am working on.
How to append visit array when click on date. not on first show up.
I want to set null visit data on first. but when click specify date, i will request to server to get list of meeting.
Is it posible . . ?
Thanks..
why is at every 4th of every month, there's always problems?
date cannot be clicked and color same with day of other month
Thanks..
Body of view:
var body: some View { MonthlyCalendarView(calendarManager: calendarManager) .theme(CalendarTheme(primary: Color.mFoodColor)) .allowsHaptics(true) .horizontal() // .offset(x: 0.0, y: -50.0) .navigationTitle("Schedule") }
There is a big whitespace above the Month name. I have tried adding Spacer() in various places. The only way I have been able to change this is to use the .offset that is commented out in the above code.
Are there better ways to correct this?
Hi I'm not sure how I can implement the ElegantCalendar module to create the vertical scrolling CalendarView into my project? Thank you! Really like your side bar dates vertical scrolling calendar view!
Hi, I was worrying if there's a way to use this calendar for lower versions of iOS such as 11.4 or at least 12 instead of 13 (even though the major part of iOS user are above 13, there are some still in 12.
Thanks beforehand.
Hi, I'm trying to add ElegantCalendar as a Swift Package, but it keeps failing when it tries to resolve "Elegant Pages"
I have installed the package according to the ReadMe instructions, but when I create a new swift file containing the sample code, the default values for startDate and endDate throw errors.
Am I missing something in the instructions? It seems like according to the docs that just executing this should default the start and end dates to todays value. Is there something that needs to be done here that isn't explicitly shown in ReadMe?
Why every 4th of the month is frozen? Unable to click?
Hello, I am getting random crashes. They start in the setProperPage() where the class is called "UpdateUIViewControllerBugFixClass". Here's the code where it finally crashes:
func configureNewMonth(at page: Int) {
if months[page] != currentMonth {
currentMonth = months[page]
selectedDate = nil
delegate?.calendar(willDisplayMonth: currentMonth)
if allowsHaptics && isHapticActive {
UIImpactFeedbackGenerator.generateSelectionHaptic()
} else {
isHapticActive = true
}
}
}
For some reason the page passed is like 26,000. Any ideas on how to fix this? Apparently the creator was trying to solve a bug but it seems it is not resolved.
I run an example first time and this error produced. How to fix it ?
I'm stucking in swift PM fetching/resolving :(
I really need this package
I need you help
It would be nice to have buttons at either side on the month title in the MonthCalenderView so the header would look something like this:
< September >
Selecting the corresponding arrows would move between months accordingly.
How could I add these buttons so users don't have to swipe to move between months?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.