Skip to content

Commit

Permalink
current timeline view redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
zjfjack authored Aug 28, 2018
1 parent 7d1e8ad commit 5193513
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 85 deletions.
4 changes: 4 additions & 0 deletions Example/JZCalendarWeekViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
8E7263DF2074B55300ECF7CD /* EventCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E7263DC2074B55300ECF7CD /* EventCell.swift */; };
8E7263E02074B55300ECF7CD /* EventCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8E7263DD2074B55300ECF7CD /* EventCell.xib */; };
8E7263E32074B73300ECF7CD /* DefaultWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E7263E22074B73300ECF7CD /* DefaultWeekView.swift */; };
8E99A0A4213523C400415071 /* CurrentTimelineAll.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E99A0A3213523C400415071 /* CurrentTimelineAll.swift */; };
8E9A7DF520969919009AEB6E /* LongPressWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A7DF420969919009AEB6E /* LongPressWeekView.swift */; };
8E9AE75B20773F3500B7004E /* ExampleOptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E9AE75A20773F3500B7004E /* ExampleOptionsViewController.swift */; };
8EBD62EA2096F8AD00520E58 /* LongPressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EBD62E92096F8AD00520E58 /* LongPressViewController.swift */; };
Expand Down Expand Up @@ -103,6 +104,7 @@
8E7263DC2074B55300ECF7CD /* EventCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventCell.swift; sourceTree = "<group>"; };
8E7263DD2074B55300ECF7CD /* EventCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EventCell.xib; sourceTree = "<group>"; };
8E7263E22074B73300ECF7CD /* DefaultWeekView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultWeekView.swift; sourceTree = "<group>"; };
8E99A0A3213523C400415071 /* CurrentTimelineAll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentTimelineAll.swift; sourceTree = "<group>"; };
8E9A7DF420969919009AEB6E /* LongPressWeekView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongPressWeekView.swift; sourceTree = "<group>"; };
8E9AE75A20773F3500B7004E /* ExampleOptionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleOptionsViewController.swift; sourceTree = "<group>"; };
8EBD62E92096F8AD00520E58 /* LongPressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongPressViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,6 +154,7 @@
8E54D53A208D6997007DD5FE /* CustomWeekView.swift */,
8E2E6566208D5F3600FB2CE4 /* BlackGridLine.swift */,
8E54D53C208D6A2B007DD5FE /* HourRowHeader.swift */,
8E99A0A3213523C400415071 /* CurrentTimelineAll.swift */,
);
path = CustomViews;
sourceTree = "<group>";
Expand Down Expand Up @@ -346,6 +349,7 @@
8E5BB407207325AB00FA853F /* Extensions.swift in Sources */,
8E5BB3D42072F4A000FA853F /* DefaultViewController.swift in Sources */,
8E5BB4022073226100FA853F /* DefaultViewModel.swift in Sources */,
8E99A0A4213523C400415071 /* CurrentTimelineAll.swift in Sources */,
8E2E6567208D5F3600FB2CE4 /* BlackGridLine.swift in Sources */,
8E5BB404207322BA00FA853F /* AllDayEvent.swift in Sources */,
8EBD62EA2096F8AD00520E58 /* LongPressViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ciV-hx-0O7">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ciV-hx-0O7">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
Expand Down Expand Up @@ -119,7 +119,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Guo-t0-ufM" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="717.60000000000002" y="805.54722638680664"/>
<point key="canvasLocation" x="718" y="836"/>
</scene>
<!--Example Options View Controller-->
<scene sceneID="A1o-p0-qFd">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// CurrentTimelineAll.swift
// JZCalendarWeekViewExample
//
// Created by Jeff Zhang on 28/8/18.
// Copyright © 2018 Jeff Zhang. All rights reserved.
//

import UIKit

class CurrentTimelineAll: UICollectionReusableView {

public var ballView = UIView()
public var lineView = UIView()
let ballSize: CGFloat = 6

public override init(frame: CGRect) {
super.init(frame: .zero)

setupUI()
}

open func setupUI() {
self.addSubviews([ballView, lineView])
ballView.setAnchorCenterVerticallyTo(view: self, widthAnchor: ballSize, heightAnchor: ballSize, leadingAnchor: (leadingAnchor, 2))
lineView.setAnchorCenterVerticallyTo(view: self, heightAnchor: 1, leadingAnchor: (leadingAnchor, 0), trailingAnchor: (trailingAnchor, 0))

ballView.backgroundColor = .purple
ballView.layer.cornerRadius = ballSize/2
ballView.isHidden = true
lineView.backgroundColor = .purple
}

open func updateView(needShowBallView: Bool) {
ballView.isHidden = !needShowBallView
}

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CustomWeekView: JZBaseWeekView {
self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.verticalGridline)
self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.horizontalGridline)
self.collectionView.register(HourRowHeader.self, forSupplementaryViewOfKind: JZSupplementaryViewKinds.rowHeader, withReuseIdentifier: HourRowHeader.className)
self.collectionView.register(CurrentTimelineAll.self, forSupplementaryViewOfKind: JZSupplementaryViewKinds.currentTimeline, withReuseIdentifier: CurrentTimelineAll.className)
}

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
Expand All @@ -30,9 +31,16 @@ class CustomWeekView: JZBaseWeekView {

override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == JZSupplementaryViewKinds.rowHeader {

let rowHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: HourRowHeader.className, for: indexPath) as! HourRowHeader
rowHeader.updateView(date: flowLayout.timeForRowHeader(at: indexPath))
return rowHeader
} else if kind == JZSupplementaryViewKinds.currentTimeline {

let currentTimeline = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CurrentTimelineAll.className, for: indexPath) as! CurrentTimelineAll
let isToday = Calendar.current.isDateInToday(flowLayout.dateForColumnHeader(at: indexPath))
currentTimeline.updateView(needShowBallView: isToday)
return currentTimeline
}
return super.collectionView(collectionView, viewForSupplementaryElementOfKind: kind, at: indexPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extension ExampleOptionsViewController: UITableViewDelegate, UITableViewDataSour

if section == 2 {
if viewModel.optionsData[2].selectedIndex == 6 && viewModel.optionsData[3].subject != .firstDayOfWeek {
viewModel.insertDayOfWeekToData(firstDayOfWeek: .sunday)
viewModel.insertDayOfWeekToData(firstDayOfWeek: .Sunday)
tableView.reloadData()
}
if viewModel.optionsData[2].selectedIndex != 6 && viewModel.optionsData[3].subject == .firstDayOfWeek {
Expand Down
16 changes: 8 additions & 8 deletions Example/JZCalendarWeekViewExample/Source/Utils/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ extension JZHourGridDivision {
extension DayOfWeek {
var dayName: String {
switch self {
case .sunday: return "Sunday"
case .monday: return "Monday"
case .tuesday: return "Tuesday"
case .wednesday: return "Wednesday"
case .thursday: return "Thursday"
case .friday: return "Friday"
case .saturday: return "Saturday"
case .Sunday: return "Sunday"
case .Monday: return "Monday"
case .Tuesday: return "Tuesday"
case .Wednesday: return "Wednesday"
case .Thursday: return "Thursday"
case .Friday: return "Friday"
case .Saturday: return "Saturday"
}
}

static var dayOfWeekList: [DayOfWeek] {
return [.sunday, .monday, .tuesday, .wednesday, .thursday, .friday, .saturday]
return [.Sunday, .Monday, .Tuesday, .Wednesday, .Thursday, .Friday, .Saturday]
}
}

Expand Down
4 changes: 2 additions & 2 deletions Example/JZCalendarWeekViewExample/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.4.3</string>
<string>0.5.0</string>
<key>CFBundleVersion</key>
<string>18061501</string>
<string>18082801</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
2 changes: 1 addition & 1 deletion JZCalendarWeekView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JZCalendarWeekView"
s.version = "0.4.3"
s.version = "0.5.0"
s.summary = "Calendar Week & Day View in iOS Swift"
s.homepage = "https://github.com/zjfjack/JZCalendarWeekView"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
16 changes: 12 additions & 4 deletions JZCalendarWeekView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1FB6140D2130FE7400F08ACD /* JZCurrentTimelinePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB6140C2130FE7400F08ACD /* JZCurrentTimelinePage.swift */; };
8E023C78206C6E4B00C523BE /* JZWeekViewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E023C77206C6E4B00C523BE /* JZWeekViewTest.swift */; };
8E023C7A206C6E4B00C523BE /* JZCalendarWeekView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E1BA94A206B4329007BE13C /* JZCalendarWeekView.framework */; };
8E023C84206C732300C523BE /* JZBaseEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E023C83206C732300C523BE /* JZBaseEvent.swift */; };
Expand All @@ -18,7 +19,7 @@
8E1BA962206B4B99007BE13C /* JZRowHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA961206B4B99007BE13C /* JZRowHeader.swift */; };
8E1BA964206B4E82007BE13C /* JZCornerHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA963206B4E82007BE13C /* JZCornerHeader.swift */; };
8E1BA966206B4F0B007BE13C /* JZGridLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA965206B4F0B007BE13C /* JZGridLine.swift */; };
8E1BA968206B4F40007BE13C /* JZCurrentTimeIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA967206B4F40007BE13C /* JZCurrentTimeIndicator.swift */; };
8E1BA968206B4F40007BE13C /* JZCurrentTimelineSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA967206B4F40007BE13C /* JZCurrentTimelineSection.swift */; };
8E1BA96A206B5350007BE13C /* JZWeekViewHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA969206B5350007BE13C /* JZWeekViewHelper.swift */; };
8E1BA96C206B5B3F007BE13C /* JZColumnHeaderBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA96B206B5B3F007BE13C /* JZColumnHeaderBackground.swift */; };
8E1BA96E206B5B55007BE13C /* JZRowHeaderBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E1BA96D206B5B55007BE13C /* JZRowHeaderBackground.swift */; };
Expand All @@ -27,6 +28,7 @@
8E40B2E020B65C4600FFEB68 /* JZAllDayEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E40B2DF20B65C4600FFEB68 /* JZAllDayEvent.swift */; };
8E478FA320846A8000668F05 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E478FA220846A8000668F05 /* Extensions.swift */; };
8E5BB3FB2073154F00FA853F /* WeekViewHelperTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E5BB3FA2073154F00FA853F /* WeekViewHelperTest.swift */; };
8E99A0A22134E84800415071 /* JZCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E99A0A12134E84800415071 /* JZCollectionView.swift */; };
8EF7EBCD20A55C8E00D5CEEA /* JZAllDayCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EF7EBCC20A55C8E00D5CEEA /* JZAllDayCorner.swift */; };
8EF7EBCF20A55CF900D5CEEA /* JZAllDayHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EF7EBCE20A55CF900D5CEEA /* JZAllDayHeader.swift */; };
8EF7EBD120A55D1000D5CEEA /* JZAllDayHeaderBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EF7EBD020A55D1000D5CEEA /* JZAllDayHeaderBackground.swift */; };
Expand All @@ -43,6 +45,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1FB6140C2130FE7400F08ACD /* JZCurrentTimelinePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZCurrentTimelinePage.swift; sourceTree = "<group>"; };
8E023C75206C6E4B00C523BE /* JZCalendarWeekViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JZCalendarWeekViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8E023C77206C6E4B00C523BE /* JZWeekViewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZWeekViewTest.swift; sourceTree = "<group>"; };
8E023C79206C6E4B00C523BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -57,7 +60,7 @@
8E1BA961206B4B99007BE13C /* JZRowHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZRowHeader.swift; sourceTree = "<group>"; };
8E1BA963206B4E82007BE13C /* JZCornerHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZCornerHeader.swift; sourceTree = "<group>"; };
8E1BA965206B4F0B007BE13C /* JZGridLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZGridLine.swift; sourceTree = "<group>"; };
8E1BA967206B4F40007BE13C /* JZCurrentTimeIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZCurrentTimeIndicator.swift; sourceTree = "<group>"; };
8E1BA967206B4F40007BE13C /* JZCurrentTimelineSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZCurrentTimelineSection.swift; sourceTree = "<group>"; };
8E1BA969206B5350007BE13C /* JZWeekViewHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZWeekViewHelper.swift; sourceTree = "<group>"; };
8E1BA96B206B5B3F007BE13C /* JZColumnHeaderBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZColumnHeaderBackground.swift; sourceTree = "<group>"; };
8E1BA96D206B5B55007BE13C /* JZRowHeaderBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZRowHeaderBackground.swift; sourceTree = "<group>"; };
Expand All @@ -66,6 +69,7 @@
8E40B2DF20B65C4600FFEB68 /* JZAllDayEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZAllDayEvent.swift; sourceTree = "<group>"; };
8E478FA220846A8000668F05 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
8E5BB3FA2073154F00FA853F /* WeekViewHelperTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekViewHelperTest.swift; sourceTree = "<group>"; };
8E99A0A12134E84800415071 /* JZCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZCollectionView.swift; sourceTree = "<group>"; };
8EF7EBCC20A55C8E00D5CEEA /* JZAllDayCorner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZAllDayCorner.swift; sourceTree = "<group>"; };
8EF7EBCE20A55CF900D5CEEA /* JZAllDayHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZAllDayHeader.swift; sourceTree = "<group>"; };
8EF7EBD020A55D1000D5CEEA /* JZAllDayHeaderBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZAllDayHeaderBackground.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -122,6 +126,7 @@
isa = PBXGroup;
children = (
8E1BA95A206B4826007BE13C /* JZWeekViewFlowLayout.swift */,
8E99A0A12134E84800415071 /* JZCollectionView.swift */,
8E1BA956206B47DA007BE13C /* JZBaseWeekView.swift */,
8E21E8AF20916A96002D72D0 /* JZLongPressWeekView.swift */,
8E1BA971206B61B7007BE13C /* JZLongPressEventCell.swift */,
Expand Down Expand Up @@ -152,7 +157,8 @@
8E1BA961206B4B99007BE13C /* JZRowHeader.swift */,
8E1BA963206B4E82007BE13C /* JZCornerHeader.swift */,
8E1BA965206B4F0B007BE13C /* JZGridLine.swift */,
8E1BA967206B4F40007BE13C /* JZCurrentTimeIndicator.swift */,
1FB6140C2130FE7400F08ACD /* JZCurrentTimelinePage.swift */,
8E1BA967206B4F40007BE13C /* JZCurrentTimelineSection.swift */,
8E1BA96B206B5B3F007BE13C /* JZColumnHeaderBackground.swift */,
8E1BA96D206B5B55007BE13C /* JZRowHeaderBackground.swift */,
8EF7EBCC20A55C8E00D5CEEA /* JZAllDayCorner.swift */,
Expand Down Expand Up @@ -282,12 +288,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8E99A0A22134E84800415071 /* JZCollectionView.swift in Sources */,
8E1BA96C206B5B3F007BE13C /* JZColumnHeaderBackground.swift in Sources */,
8E478FA320846A8000668F05 /* Extensions.swift in Sources */,
1FB6140D2130FE7400F08ACD /* JZCurrentTimelinePage.swift in Sources */,
8EF7EBCF20A55CF900D5CEEA /* JZAllDayHeader.swift in Sources */,
8E1BA95B206B4826007BE13C /* JZWeekViewFlowLayout.swift in Sources */,
8E40B2E020B65C4600FFEB68 /* JZAllDayEvent.swift in Sources */,
8E1BA968206B4F40007BE13C /* JZCurrentTimeIndicator.swift in Sources */,
8E1BA968206B4F40007BE13C /* JZCurrentTimelineSection.swift in Sources */,
8E1BA960206B4B84007BE13C /* JZColumnHeader.swift in Sources */,
8E023C84206C732300C523BE /* JZBaseEvent.swift in Sources */,
8E1BA964206B4E82007BE13C /* JZCornerHeader.swift in Sources */,
Expand Down
Loading

0 comments on commit 5193513

Please sign in to comment.