Skip to content

Commit

Permalink
update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vodolazkyi committed Mar 2, 2020
1 parent b0b0a0c commit 9d6d677
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion YACalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "YACalendar"
spec.version = "0.0.2"
spec.version = "0.0.3"
spec.summary = "iOS Calendar"

spec.description = <<-DESC
Expand Down
13 changes: 12 additions & 1 deletion YACalendar/YACalendar/Configs/DayConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public class DayConfig {
open class DayConfig {

public var textAlignment: NSTextAlignment = .center

Expand All @@ -30,6 +30,17 @@ public class DayConfig {
}
}

public func borderColor(for state: DayState, indicator: DayIndicator) -> UIColor? {
switch (state, indicator) {
case (.today, _): return UIColor(displayP3Red: 247 / 255, green: 101 / 255, blue: 48 / 255, alpha: 1.0)
default: return nil
}
}

public func borderWidth(for state: DayState, indicator: DayIndicator) -> CGFloat {
return 0
}

public func indicatorColor(for state: DayState, indicator: DayIndicator) -> UIColor {
switch (state, indicator) {
case (_, .selected): return UIColor(displayP3Red: 247 / 255, green: 101 / 255, blue: 48 / 255, alpha: 1.0)
Expand Down
2 changes: 1 addition & 1 deletion YACalendar/YACalendar/Configs/DaySymbolsConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public class DaySymbolsConfig {
open class DaySymbolsConfig {

public var isEnabled: Bool = true
public var type: DaySymbols = .short
Expand Down
2 changes: 1 addition & 1 deletion YACalendar/YACalendar/Configs/MonthConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public class MonthConfig {
open class MonthConfig {

public var showTitle: Bool = true
public var showDaysOut: Bool = false
Expand Down
2 changes: 1 addition & 1 deletion YACalendar/YACalendar/Configs/MonthHeaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public class MonthHeaderConfig {
open class MonthHeaderConfig {

public var textColor: UIColor = .black
public var currentTextColor: UIColor = UIColor(displayP3Red: 255 / 255, green: 99 / 255, blue: 0 / 255, alpha: 1.0)
Expand Down
2 changes: 1 addition & 1 deletion YACalendar/YACalendar/Configs/YearHeaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

public class YearHeaderConfig {
open class YearHeaderConfig {

public var textColor: UIColor = .black
public var currentTextColor: UIColor = UIColor(displayP3Red: 247 / 255, green: 101 / 255, blue: 48 / 255, alpha: 1.0)
Expand Down
9 changes: 3 additions & 6 deletions YACalendar/YACalendar/Views/DayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public final class DayView: UIView {
view.layer.cornerRadius = view.frame.height / 2
view.tag = dayIndicatorViewTag
view.backgroundColor = config.indicatorColor(for: day.state, indicator: day.indicator)
view.layer.borderColor = config.borderColor(for: day.state, indicator: day.indicator)?.cgColor
view.layer.borderWidth = config.borderWidth(for: day.state, indicator: day.indicator)
insertSubview(view, at: 0)

switch (day.state, day.indicator) {
Expand All @@ -65,7 +67,7 @@ public final class DayView: UIView {
height: bounds.height - (inset.top + inset.bottom)
)
backView.tag = dayIndicatorViewTag
backView.backgroundColor = UIColor.black.withAlphaComponent(0.15)
backView.backgroundColor = config.indicatorColor(for: day.state, indicator: .inRange)
insertSubview(backView, at: 1)
break

Expand All @@ -87,11 +89,6 @@ public final class DayView: UIView {
view.layer.addSublayer(disableLayer)
break

case (.today, _):
view.layer.borderWidth = 1
view.layer.borderColor = UIColor(displayP3Red: 247 / 255, green: 101 / 255, blue: 48 / 255, alpha: 1.0).cgColor
break

default: break
}
}
Expand Down

0 comments on commit 9d6d677

Please sign in to comment.