Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add a custom event in calendar lib #109

Open
kiranjammigumpula opened this issue Jul 20, 2018 · 6 comments
Open

how to add a custom event in calendar lib #109

kiranjammigumpula opened this issue Jul 20, 2018 · 6 comments

Comments

@kiranjammigumpula
Copy link

I want to add a custom event by changing some fields. I want to add my own fields in the event view

@iOSDevGarg
Copy link

Are you using this lib in Swift ? Not related to your question

@kiranjammigumpula
Copy link
Author

yes i am using this in swift

@iOSDevGarg
Copy link

if possible can you please share code for that ?, Thanks

@fukemy
Copy link

fukemy commented Jan 17, 2019

i am trying to find swift version too

@shraddha-patel-1891
Copy link

hello fukemy,
can you please share your code for add custom event in calender lib

@fukemy
Copy link

fukemy commented Aug 23, 2019

ok bro, just use EAEvent class

let url = "\(self.BASED_URL)\(GET_REPORT_LIST_FROM_DATE_TO_DATE)?BeginDate=\(fromDate)&EndDate=\(toDate)"
        NWUtil.shared.getData(url: url, params: nil, success: { (response) in
            print("report data: \(response)")
            
            self.progressBar.stopAnimating()
            if let array = response as? NSArray{
                if array.count > 0 {
                    array.forEach({ (item) in
                        
                        let dFormatter = DateFormatter()
                        dFormatter.timeZone = .current
                        dFormatter.locale = .current
                        dFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
                        
                        if let dict = item as? NSDictionary{
                            let day = dict["day"] as! String
                            if let dateFromDay = dFormatter.date(from: day){
                                let event = EAEvent()
                                event.startDate = Calendar.current.date(bySetting: .minute, value: 1, of: dateFromDay)
                                event.endDate = Calendar.current.date(bySetting: .minute, value: 59, of: dateFromDay)
                                event.riseDateUtc = dateFromDay.millisecondsSince1970
                                event.type = EventType.TimedEventType
                                event.count = dict["totalCount"] as? Int ?? 1
                                self.datasource?.append(event)
                            }else{
                                print("Date is invalid")
                            }
                        }
                    })
                    
                    if let _ = self.yearViewController{
//                        self.yearViewController!.data = self.datasource!
//                        self.yearViewController?.reloadEvent()
                    }
                    
                    if let _ = self.monthViewController{
                        self.monthViewController?.data = self.datasource
                        self.monthViewController?.reloadEvents()
                    }
                }else{
                    self.view.makeToast(Language.get("No data"))
                }
            }
            
            
        }) { (error) in
            self.progressBar.stopAnimating()
            print("loadReportDataYear error: \(error)")
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants