GithubHelp home page GithubHelp logo

isabella232 / qvrweekview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trifork/qvrweekview

0.0 0.0 0.0 842 KB

QVRWeekView is a framework which provides a calendar view that can be customized to display between 1 to 7 days in both portrait and landscape mode. Includes customization features to customize colours, fonts and sizes.

License: MIT License

Ruby 0.83% Objective-C 0.41% Swift 98.75%

qvrweekview's Introduction

QVRWeekView

CI Status Version License Platform

About

QVRWeekView is a work in progress framework that contains a week/day view that allows you to display, add and remove events.

Features

  • Horizontal and vertical scrolling
  • Infinite horizontal scrolling
  • Zooming
  • Colour, size and font customization features
  • Day and hour label font resizing
  • Dynamic event adding and removing
  • Event tap, long press and event request callbacks
  • Number of visible days customizable

Example

To run the example project, clone the repo, and run pod install from the Example directory first. Most useful example code can be found in Example > QVRWeekView > CalendarViewController or StartViewController

Requirements

This pod requires a minimum deployment target of iOS 9.0.

Installation

QVRWeekView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "QVRWeekView"

Usage

Setup

Once the framework is installed, there are two ways you can incorporate the WeekView into your project:

1. Programatically

To add the WeekView programatically, simply import QVRWeekView into your code by adding:

import QVRWeekView

at the top of your source file containing your view controller. Then insert the WeekView into your view controller by adding:

let weekView = WeekView(frame: self.view.frame)
self.view.addSubview(weekView)

into either your viewDidLoad or viewWillAppear method.

2. Via the storyboard

To add the WeekView via the storyboard, simply add a View onto your View Controller and resize it or add constraints. Then go to the identity inspector of your view and select the Class to be WeekView and the module to be QVRWeekView (See image).

image

Then you should be all set!

Working with WeekView

WeekView Delegate

WeekView has a delegate called WeekViewDelegate. For now this delegate contains only three functions:

Function Parameters Behaviour Recommended use
didLongPressDayView weekView:WeekView, date:Date Called when a dayView column is long pressed. The passed date contains which time point was pressed Use this function to add individual user events
didTapEvent weekView:WeekView, eventId:Int Called when an event is tapped. eventId of the tapped event is passed Use this function to prompt event editing or removal
loadNewEvents weekView:WeekView, startDate:Date , endDate:Date Called when events are ready to be loaded. startDate and endDate indicate (inclusively) between which two dates events are required. Use this function to load in stored events

WeekView Public functions

Function Parameters Behaviour
updateTimeDisplayed \ Updates the time displayed by the hour indicator
showDay date:Date Scrolls the week view to the day passed by date
showToday \ Scrolls the week view to today
loadEvents eventsData:[EventData] Loads, processes and displays the events provided by the eventsData array of EventData1 objects.

EventData1

EventData is the main object used to communicate events between the WeekView and your code. EventData can be overriden.

Variable/Function Purpose
id:String A unique identifier for this event
title:String A title that will be displayed for this event
startDate:Date The start date for this event
endDate:Date The end date for this event
color:UIColor The main color for this event
allDay:Bool Indicates if this event is an all day event, all day events are displayed along the top bar
configureGradient() Used to configure a gradient that will be used to render your event instead of just a solid color

Customizing WeekView

Below is a table of all customizable properties of the WeekView

Property Description
mainBackgroundColor:UIColor
defaultTopBarHeight:CGFloat
topBarColor:UIColor
sideBarWidth:CGFloat
dayLabelDefaultFont:UIFont
dayLabelTextColor:UIColor
dayLabelMinimumFontSize:CGFloat
hourLabelFont:UIFont
hourLabelTextColor:UIColor
hourLabelMinimumFontSize:CGFloat
allDayEventHeight:CGFloat
allDayEventVerticalSpacing:CGFloat
visibleDaysInPortraitMode:Int
visibleDaysInLandscapeMode:Int
eventLabelFont:UIFont
eventLabelTextColor:UIColor
eventLabelMinimumFontSize:CGFloat
eventShowTimeOfEvent:Bool Should time of events be shown
eventsDataInOneLine:Bool Compressed in one line all event's data
defaultDayViewColor:UIColor
weekendDayViewColor:UIColor
passedDayViewColor:UIColor
passedWeekendDayViewColor:UIColor
todayViewColor:UIColor
dayViewHourIndicatorColor:UIColor
dayViewHourIndicatorThickness:CGFloat
dayViewMainSeparatorColor:UIColor
dayViewMainSeparatorThickness:CGFloat
dayViewDashedSeparatorColor:UIColor
dayViewDashedSeparatorThickness:CGFloat
dayViewDashedSeparatorPattern:[NSNumber]
dayViewCellHeight:CGFloat
portraitDayViewSideSpacing:CGFloat
landscapeDayViewSideSpacing:CGFloat
portraitDayViewVerticalSpacing:CGFloat
landscapeDayViewVerticalSpacing:CGFloat
velocityOffsetMultiplier:CGFloat
showPreviewOnLongPress: Bool
allDayEventsSpreadOnX: Bool Sets spread all day events on x axis, if not true than spread will be made on y axis.
eventsSmallestHeight: CGFloat smalles heigh for an event.

How it works

The main WeekView view is a subclass of UIView. The view layout is retrieved from the WeekView xib file. WeekView contains a top and side bar sub view. The side bar contains an HourSideBarView which displays the hours. WeekView also contains a DayScrollView (UIScrollView subclass) which controls vertical scrolling and also delegates and contains a DayCollectionView (UICollectionView subclass) which controls the horizontal scrolling. DayCollectionView cells are DayViewCells, whose view is generated programtically (due to inefficiencies caused by auto-layout).

WeekView handles all top level operations such as pinch gestures and orientation change. Scrolling of the top and side bar is handled by a function inside of WeekView which is called by the DayScrollView when scrolling. Top bar day labels are generated, displayed and discarded simulaneously with DayCollectionView cells by the WeekView.

Upcoming features

  • Ability to add and remove events
  • Event color customization
  • Extra customization features
  • Improved UI features
  • Increased event processing efficiency
  • Add: testing project, where pod can be tested
  • Clean: remove useless folders and unify the naming across them
  • Re-write: how all day events are added to the view using autolayout
  • Add: CI for building/testing
  • Add: tests
  • Add: scroll to all day events
  • Move: eventsSmallestHeight to LayoutsVariables, from TextVariables

Author

Reinert Lemmens, [email protected]

License

QVRWeekView is available under the MIT license. See the LICENSE file for more info.

qvrweekview's People

Contributors

lesyk avatar mlepicki avatar pwetrifork avatar reilem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.