Skip to content

Commit

Permalink
Fix month select logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia3546 committed Nov 20, 2020
1 parent c3e627c commit be7c3b8
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Pods/

# Add this line if you want to avoid checking in source code from the Xcode workspace
#
# *.xcworkspace
*.xcworkspace

# Carthage
#
Expand Down
6 changes: 5 additions & 1 deletion Example/FastisExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1140;
LastUpgradeCheck = 1140;
LastUpgradeCheck = 1220;
ORGANIZATIONNAME = "RetailDriver LLC";
TargetAttributes = {
F3FCEE42244780FE000F966E = {
Expand Down Expand Up @@ -244,6 +244,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -304,6 +305,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -340,6 +342,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 48KFD5698Q;
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -359,6 +362,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 48KFD5698Q;
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
10 changes: 0 additions & 10 deletions Example/FastisExample.xcworkspace/contents.xcworkspacedata

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://github.com/CocoaPods/Specs.git'
source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
use_frameworks!

Expand Down
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Fastis (1.0.3):
- Fastis (1.0.12):
- JTAppleCalendar (~> 8.0.0)
- PrettyCards (~> 1.0.0)
- SnapKit (~> 5.0.0)
Expand All @@ -11,7 +11,7 @@ DEPENDENCIES:
- Fastis (from `../`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
trunk:
- JTAppleCalendar
- PrettyCards
- SnapKit
Expand All @@ -21,11 +21,11 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Fastis: 329990407f2477b7b5a15fe6ae0f9485350fdd8d
Fastis: f403980b285b38e2930b2473c4c4e3bfbb0e898c
JTAppleCalendar: 932cadea40b1051beab10f67843451d48ba16c99
PrettyCards: 14d7c36a286cbd25ba29d351e9c5473f8c94ca6f
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

PODFILE CHECKSUM: 3ca7a87691df1672969eb39bf0af8564af33681d
PODFILE CHECKSUM: 1535660f8291b9f9d6e4c9762a7e5e6aa4397ec6

COCOAPODS: 1.9.1
COCOAPODS: 1.10.0
4 changes: 2 additions & 2 deletions Example/Source/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class ViewController: UIViewController {
let fastisController = FastisController(mode: .range)
fastisController.title = "Choose range"
fastisController.initialValue = self.currentValue as? FastisRange
fastisController.minimumDate = Calendar.current.date(byAdding: .month, value: -1, to: Date())
fastisController.maximumDate = Date()
fastisController.minimumDate = Calendar.current.date(byAdding: .month, value: -2, to: Date())
fastisController.maximumDate = Calendar.current.date(byAdding: .month, value: 3, to: Date())
fastisController.allowToChooseNilDate = true
fastisController.shortcuts = [.today, .lastWeek, .lastMonth]
fastisController.doneHandler = { newValue in
Expand Down
2 changes: 1 addition & 1 deletion Source/Extensions/Date + Utilits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
extension Date {

internal func startOfMonth(in calendar: Calendar = .current) -> Date {
return calendar.date(from: calendar.dateComponents([.year, .month], from: calendar.startOfDay(for: self)))!
return calendar.date(from: calendar.dateComponents([.year, .month], from: calendar.startOfDay(for: self)))!.startOfDay(in: calendar)
}

internal func endOfMonth(in calendar: Calendar = .current) -> Date {
Expand Down
2 changes: 1 addition & 1 deletion Source/Views/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public class FastisController<Value: FastisValue>: UIViewController, JTACMonthVi
if self.privateSelectMonthOnHeaderTap, Value.mode == .range {
header.tapHandler = {
var fromDate = range.start.startOfMonth(in: self.currentCalendar)
var toDate = range.end.endOfMonth(in: self.currentCalendar)
var toDate = range.start.endOfMonth(in: self.currentCalendar)
if let minDate = self.minimumDate {
if toDate < minDate { return }
else if fromDate < minDate {
Expand Down
4 changes: 3 additions & 1 deletion Source/Views/DayCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class DayCell: JTACDayCell {
if let cornerRadius = config.customSelectionViewCornerRadius {
self.selectionBackgroundView.layer.cornerRadius = cornerRadius
}
rangedBackgroundViewTopBootomConstraints.map{ $0.update(inset: config.rangedBackgroundViewInset)}
self.rangedBackgroundViewTopBootomConstraints.forEach({
$0.update(inset: config.rangedBackgroundViewInset)
})
}

public func configureSubviews() {
Expand Down

0 comments on commit be7c3b8

Please sign in to comment.