forked from RaffiKian/RKCalendar
-
Notifications
You must be signed in to change notification settings - Fork 2
/
RKCell.swift
49 lines (41 loc) · 2.5 KB
/
RKCell.swift
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
//
// RKCell.swift
// RKCalendar
//
// Created by Raffi Kian on 7/14/19.
// Copyright © 2019 Raffi Kian. All rights reserved.
//
import SwiftUI
struct RKCell: View {
var rkDate: RKDate
var cellWidth: CGFloat
var body: some View {
Text(rkDate.getText())
.fontWeight(rkDate.getFontWeight())
.foregroundColor(rkDate.getTextColor())
.frame(width: cellWidth, height: cellWidth)
.font(.system(size: 20))
.background(rkDate.getBackgroundColor())
.cornerRadius(cellWidth/2)
}
}
#if DEBUG
struct RKCell_Previews : PreviewProvider {
static var previews: some View {
Group {
RKCell(rkDate: RKDate(date: Date(), rkManager: RKManager(calendar: Calendar.current, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60*60*24*365), mode: 0), isDisabled: false, isToday: false, isSelected: false, isBetweenStartAndEnd: false), cellWidth: CGFloat(32))
.previewDisplayName("Control")
RKCell(rkDate: RKDate(date: Date(), rkManager: RKManager(calendar: Calendar.current, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60*60*24*365), mode: 0), isDisabled: true, isToday: false, isSelected: false, isBetweenStartAndEnd: false), cellWidth: CGFloat(32))
.previewDisplayName("Disabled Date")
RKCell(rkDate: RKDate(date: Date(), rkManager: RKManager(calendar: Calendar.current, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60*60*24*365), mode: 0), isDisabled: false, isToday: true, isSelected: false, isBetweenStartAndEnd: false), cellWidth: CGFloat(32))
.previewDisplayName("Today")
RKCell(rkDate: RKDate(date: Date(), rkManager: RKManager(calendar: Calendar.current, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60*60*24*365), mode: 0), isDisabled: false, isToday: false, isSelected: true, isBetweenStartAndEnd: false), cellWidth: CGFloat(32))
.previewDisplayName("Selected Date")
RKCell(rkDate: RKDate(date: Date(), rkManager: RKManager(calendar: Calendar.current, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60*60*24*365), mode: 0), isDisabled: false, isToday: false, isSelected: false, isBetweenStartAndEnd: true), cellWidth: CGFloat(32))
.previewDisplayName("Between Two Dates")
}
.previewLayout(.fixed(width: 300, height: 70))
.environment(\.sizeCategory, .accessibilityExtraExtraExtraLarge)
}
}
#endif