Blame view

Pods/JTAppleCalendar/Sources/CalendarEnums.swift 5.52 KB
75d24c15   yangbin   123
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  //
  //  CalendarEnums.swift
  //
  //  Copyright (c) 2016-2017 JTAppleCalendar (https://github.com/patchthecode/JTAppleCalendar)
  //
  //  Permission is hereby granted, free of charge, to any person obtaining a copy
  //  of this software and associated documentation files (the "Software"), to deal
  //  in the Software without restriction, including without limitation the rights
  //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  //  copies of the Software, and to permit persons to whom the Software is
  //  furnished to do so, subject to the following conditions:
  //
  //  The above copyright notice and this permission notice shall be included in
  //  all copies or substantial portions of the Software.
  //
  //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  //  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  //  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  //  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  //  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  //  THE SOFTWARE.
  //
  
  /// Describes a scroll destination
  public enum SegmentDestination {
      /// next the destination is the following segment
      case next
      /// previous the destination is the previous segment
      case previous
      /// start the destination is the start segment
      case start
      /// end the destination is the end segment
      case end
  }
  /// Describes the types of out-date cells to be generated.
  public enum OutDateCellGeneration {
      /// tillEndOfRow will generate dates till it reaches the end of a row.
      /// endOfGrid will continue generating until it has filled a 6x7 grid.
      /// Off-mode will generate no postdates
      case tillEndOfRow, tillEndOfGrid, off
  }
  
  /// Describes the types of out-date cells to be generated.
  public enum InDateCellGeneration {
      /// forFirstMonthOnly will generate dates for the first month only
      /// forAllMonths will generate dates for all months
      /// off setting wilil generate no dates
      case forFirstMonthOnly, forAllMonths, off
  }
  
  /// Describes the calendar reading direction
  /// Useful for regions that read text from right to left
  public enum ReadingOrientation {
      /// Reading orientation is from right to left
      case rightToLeft
      /// Reading orientation is from left to right
      case leftToRight
  }
  
  /// Configures the behavior of the scrolling mode of the calendar
  public enum ScrollingMode: Equatable {
      /// stopAtEachCalendarFrame - non-continuous scrolling that will stop at each frame
      case stopAtEachCalendarFrame
      /// stopAtEachSection - non-continuous scrolling that will stop at each section
      case stopAtEachSection
      /// stopAtEach - non-continuous scrolling that will stop at each custom interval
      case stopAtEach(customInterval: CGFloat)
      /// nonStopToSection - continuous scrolling that will stop at a section
      case nonStopToSection(withResistance: CGFloat)
      /// nonStopToCell - continuous scrolling that will stop at a cell
      case nonStopToCell(withResistance: CGFloat)
      /// nonStopTo - continuous scrolling that will stop at acustom interval
      case nonStopTo(customInterval: CGFloat, withResistance: CGFloat)
      /// none - continuous scrolling that will eventually stop at a point
      case none
      
      func pagingIsEnabled() -> Bool {
          switch self {
          case .stopAtEachCalendarFrame: return true
          default: return false
          }
      }
      
      public static func ==(lhs: ScrollingMode, rhs: ScrollingMode) -> Bool {
          switch (lhs, rhs) {
          case (.none, .none),
               (.stopAtEachCalendarFrame, .stopAtEachCalendarFrame),
               (.stopAtEachSection, .stopAtEachSection): return true
          case (let .stopAtEach(customInterval: v1), let .stopAtEach(customInterval: v2)): return v1 == v2
          case (let .nonStopToSection(withResistance: v1), let .nonStopToSection(withResistance: v2)): return v1 == v2
          case (let .nonStopToCell(withResistance: v1), let .nonStopToCell(withResistance: v2)): return v1 == v2
          case (let .nonStopTo(customInterval: v1, withResistance: x1), let .nonStopTo(customInterval: v2, withResistance: x2)): return v1 == v2 && x1 == x2
          default: return false
          }
      }
  }
  
  /// Describes which month owns the date
  public enum DateOwner: Int {
      /// Describes which month owns the date
      case thisMonth = 0,
          previousMonthWithinBoundary,
          previousMonthOutsideBoundary,
          followingMonthWithinBoundary,
          followingMonthOutsideBoundary
  }
  /// Months of the year
  public enum MonthsOfYear: Int {
      case jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
  }
  
  /// Selection position of a range-selected date cell
  public enum SelectionRangePosition: Int {
      /// Selection position
      case left = 1, middle, right, full, none
  }
  
  /// Signifies whether or not a selection was done programatically or by the user
  public enum SelectionType: String {
      /// Selection type
      case programatic, userInitiated
  }
  
  /// Days of the week. By setting you calandar's first day of week,
  /// you can change which day is the first for the week. Sunday is by default.
  public enum DaysOfWeek: Int {
      /// Days of the week.
      case sunday = 1, monday, tuesday, wednesday, thursday, friday, saturday
  }
  
  internal enum DelayedTaskType {
      case scroll, general
  }
  
  internal enum SelectionAction {
      case didSelect, didDeselect
  }
  
  internal enum ShouldSelectionAction {
      case shouldSelect, shouldDeselect
  }