willard1218 / wlapplecalendar Goto Github PK
View Code? Open in Web Editor NEWMake AppleCalendar using JTAppleCalendar library.๐
License: MIT License
Make AppleCalendar using JTAppleCalendar library.๐
License: MIT License
Can u please make a yearly view?
I know that the pod doesn't support it.
Hello! I love your calendar and I have one question for you. I am trying to use the Google Calendar API to sync your calendar with a Google Calendar. Would you have any idea on how to do this?
This is the google calendar api code I'm trying to get to work with your schedule page.
import GoogleAPIClientForREST
import GoogleSignIn
import UIKit
class ViewController: UIViewController, GIDSignInDelegate, GIDSignInUIDelegate {
// If modifying these scopes, delete your previously saved credentials by
// resetting the iOS simulator or uninstall the app.
private let scopes = [kGTLRAuthScopeCalendarReadonly]
private let service = GTLRCalendarService()
let signInButton = GIDSignInButton()
let output = UITextView()
override func viewDidLoad() {
super.viewDidLoad()
// Configure Google Sign-in.
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().scopes = scopes
GIDSignIn.sharedInstance().signInSilently()
// Add the sign-in button.
view.addSubview(signInButton)
// Add a UITextView to display output.
output.frame = view.bounds
output.isEditable = false
output.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0)
output.autoresizingMask = [.flexibleHeight, .flexibleWidth]
output.isHidden = true
view.addSubview(output);
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if let error = error {
showAlert(title: "Authentication Error", message: error.localizedDescription)
self.service.authorizer = nil
} else {
self.signInButton.isHidden = true
self.output.isHidden = false
self.service.authorizer = user.authentication.fetcherAuthorizer()
fetchEvents()
}
}
// Construct a query and get a list of upcoming events from the user calendar
func fetchEvents() {
let query = GTLRCalendarQuery_EventsList.query(withCalendarId: "primary")
query.maxResults = 10
query.timeMin = GTLRDateTime(date: Date())
query.singleEvents = true
query.orderBy = kGTLRCalendarOrderByStartTime
service.executeQuery(
query,
delegate: self,
didFinish: #selector(displayResultWithTicket(ticket:finishedWithObject:error:)))
}
// Display the start dates and event summaries in the UITextView
func displayResultWithTicket(
ticket: GTLRServiceTicket,
finishedWithObject response : GTLRCalendar_Events,
error : NSError?) {
if let error = error {
showAlert(title: "Error", message: error.localizedDescription)
return
}
var outputText = ""
if let events = response.items, !events.isEmpty {
for event in events {
let start = event.start!.dateTime ?? event.start!.date!
let startString = DateFormatter.localizedString(
from: start.date,
dateStyle: .short,
timeStyle: .short)
outputText += "\(startString) - \(event.summary!)\n"
}
} else {
outputText = "No upcoming events found."
}
output.text = outputText
}
// Helper for showing an alert
func showAlert(title : String, message: String) {
let alert = UIAlertController(
title: title,
message: message,
preferredStyle: UIAlertControllerStyle.alert
)
let ok = UIAlertAction(
title: "OK",
style: UIAlertActionStyle.default,
handler: nil
)
alert.addAction(ok)
present(alert, animated: true, completion: nil)
}
}
This is the code from your schedule page I'm trying to get Google to work with
//
// Schedule.swift
// WLAppleCalendar
//
// Created by willard on 2017/9/15.
// Copyright ยฉ 2017ๅนด willard. All rights reserved.
//
import UIKit
struct Schedule {
var title: String
var note: String
var startTime: Date
var endTime: Date
var categoryColor: UIColor
}
// random events
extension Schedule {
init(fromStartDate: Date) {
title = ["Meet Willard", "Buy a milk", "Read a book"].randomValue()
note = ["hurry", "In office", "In New york city"].randomValue()
categoryColor = [.red, .orange, .purple, .blue, .black].randomValue()
let day = [Int](0...27).randomValue()
let hour = [Int](0...23).randomValue()
let startDate = Calendar.current.date(byAdding: .day, value: day, to: fromStartDate)!
startTime = Calendar.current.date(byAdding: .hour, value: hour, to: startDate)!
endTime = Calendar.current.date(byAdding: .hour, value: 1, to: startTime)!
}
}
extension Schedule : Equatable {
static func ==(lhs: Schedule, rhs: Schedule) -> Bool {
return lhs.startTime == rhs.startTime
}
}
extension Schedule : Comparable {
static func <(lhs: Schedule, rhs: Schedule) -> Bool {
return lhs.startTime < rhs.startTime
}
}
Hi! I have a question. How to remove outside dates in collection view?
This is my parameter
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 6, calendar: Calendar.current, generateInDates: .forAllMonths, generateOutDates: .off, firstDayOfWeek: .sunday, hasStrictBoundaries: true)
I want to remove the outside dates before the 1st day of the month
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.