Skip to content

Commit

Permalink
Merge pull request #1 from WenchaoD/master
Browse files Browse the repository at this point in the history
合并原库代码
  • Loading branch information
mg459046365 authored Jan 10, 2020
2 parents fb0910f + ee0a887 commit dcaa322
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 17 deletions.
5 changes: 4 additions & 1 deletion Example-Objc/FSCalendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
30A495521DCAD9E6000B2F31 /* FSCalendarWeekdayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarWeekdayView.h; sourceTree = "<group>"; };
30A495531DCAD9E6000B2F31 /* FSCalendarWeekdayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarWeekdayView.m; sourceTree = "<group>"; };
30B0BABF1B8D8E22004B9476 /* FSCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendar.h; sourceTree = "<group>"; };
30B0BAC01B8D8E22004B9476 /* FSCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = FSCalendar.m; sourceTree = "<group>"; };
30B0BAC01B8D8E22004B9476 /* FSCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = FSCalendar.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
30B0BAC11B8D8E22004B9476 /* FSCalendarAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarAppearance.h; sourceTree = "<group>"; };
30B0BAC21B8D8E22004B9476 /* FSCalendarAppearance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarAppearance.m; sourceTree = "<group>"; };
30B0BAC31B8D8E22004B9476 /* FSCalendarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = FSCalendarCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
Expand Down Expand Up @@ -591,6 +591,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
ja,
Expand Down Expand Up @@ -933,6 +934,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSCalendar;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -955,6 +957,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSCalendar;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ - (void)testPrevNextButtons
{
XCUIApplication *application = [[XCUIApplication alloc] init];
[[application.tables elementBoundByIndex:0].cells[@"Prev-Next Buttons"] tap];
XCUIElement *prevButton = [application.buttons elementBoundByIndex:2];
XCUIElement *nextButton = [application.buttons elementBoundByIndex:3];
XCUIElement *prevButton = [application.buttons elementBoundByIndex:1];
XCUIElement *nextButton = [application.buttons elementBoundByIndex:2];
NSInteger count = 3;
for (int i = 0; i < count; i++) {
[prevButton tap];
Expand Down Expand Up @@ -199,7 +199,7 @@ - (void)testStoryboard
CGVector vector1 = CGVectorMake(columnWidth * 3.5, cellStart + rowHeight * 2.5);
CGVector vector2 = CGVectorMake(columnWidth * 4.5, cellStart + rowHeight * 2.5);

XCUIElement *configureButton = [application.buttons elementBoundByIndex:2];
XCUIElement *configureButton = [application.buttons elementBoundByIndex:1];

[NSThread sleepForTimeInterval:0.5];
[configureButton tap];
Expand Down
3 changes: 2 additions & 1 deletion Example-Objc/FSCalendarScopeExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ - (void)viewDidLoad
if ([[UIDevice currentDevice].model hasPrefix:@"iPad"]) {
self.calendarHeightConstraint.constant = 400;
}
[self.calendar selectDate:[NSDate date] scrollToDate:YES];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.calendar action:@selector(handleScopeGesture:)];
panGesture.delegate = self;
Expand All @@ -65,6 +64,8 @@ - (void)viewDidLoad
self.calendar.placeholderType = FSCalendarPlaceholderTypeNone;
self.calendar.scope = FSCalendarScopeWeek;

[self.calendar selectDate:[NSDate date] scrollToDate:YES];

// For UITest
self.calendar.accessibilityIdentifier = @"calendar";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
30F4C91E1E07C3AD00D2EC4D /* FSCalendarAppearance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarAppearance.m; sourceTree = "<group>"; };
30F4C91F1E07C3AD00D2EC4D /* FSCalendarCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarCalculator.h; sourceTree = "<group>"; };
30F4C9201E07C3AD00D2EC4D /* FSCalendarCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarCalculator.m; sourceTree = "<group>"; };
30F4C9211E07C3AD00D2EC4D /* FSCalendarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
30F4C9211E07C3AD00D2EC4D /* FSCalendarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarCell.h; sourceTree = "<group>"; };
30F4C9221E07C3AD00D2EC4D /* FSCalendarCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarCell.m; sourceTree = "<group>"; };
30F4C9231E07C3AD00D2EC4D /* FSCalendarCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarCollectionView.h; sourceTree = "<group>"; };
30F4C9241E07C3AD00D2EC4D /* FSCalendarCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarCollectionView.m; sourceTree = "<group>"; };
Expand Down
2 changes: 1 addition & 1 deletion FSCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "FSCalendar"
s.version = "2.8.0"
s.version = "2.8.1"
s.summary = "A superiorly awesome iOS7+ calendar control, compatible with Objective-C and Swift."

s.homepage = "https://github.com/WenchaoD/FSCalendar"
Expand Down
2 changes: 1 addition & 1 deletion FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ - (void)initialize
_formatter = [[NSDateFormatter alloc] init];
_formatter.dateFormat = @"yyyy-MM-dd";
_locale = [NSLocale currentLocale];
_timeZone = [NSTimeZone localTimeZone];
_timeZone = [NSTimeZone defaultTimeZone];
_firstWeekday = 1;
[self invalidateDateTools];

Expand Down
2 changes: 1 addition & 1 deletion FSCalendar/FSCalendarCalculator.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ - (NSInteger)numberOfRowsInMonth:(NSDate *)month
if (self.calendar.placeholderType == FSCalendarPlaceholderTypeFillSixRows) return 6;

NSNumber *rowCount = self.rowCounts[month];
if (!rowCount) {
if (rowCount == nil) {
NSDate *firstDayOfMonth = [self.gregorian fs_firstDayOfMonth:month];
NSInteger weekdayOfFirstDay = [self.gregorian component:NSCalendarUnitWeekday fromDate:firstDayOfMonth];
NSInteger numberOfDaysInMonth = [self.gregorian fs_numberOfDaysInMonth:month];
Expand Down
4 changes: 2 additions & 2 deletions FSCalendar/FSCalendarCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ - (instancetype)initWithFrame:(CGRect)frame
self.contentView = view;

self.eventLayers = [NSPointerArray weakObjectsPointerArray];
for (int i = 0; i < 3; i++) {
for (int i = 0; i < FSCalendarMaximumNumberOfEvents; i++) {
CALayer *layer = [CALayer layer];
layer.backgroundColor = [UIColor clearColor].CGColor;
[self.contentView.layer addSublayer:layer];
Expand Down Expand Up @@ -450,7 +450,7 @@ - (void)setColor:(id)color
- (void)setNumberOfEvents:(NSInteger)numberOfEvents
{
if (_numberOfEvents != numberOfEvents) {
_numberOfEvents = MIN(MAX(numberOfEvents,0),3);
_numberOfEvents = MIN(MAX(numberOfEvents,0),FSCalendarMaximumNumberOfEvents);
[self setNeedsLayout];
}
}
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendarConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CG_EXTERN CGFloat const FSCalendarStandardHeaderTextSize;
CG_EXTERN CGFloat const FSCalendarMaximumEventDotDiameter;

UIKIT_EXTERN NSInteger const FSCalendarDefaultHourComponent;
UIKIT_EXTERN NSInteger const FSCalendarMaximumNumberOfEvents;

UIKIT_EXTERN NSString * const FSCalendarDefaultCellReuseIdentifier;
UIKIT_EXTERN NSString * const FSCalendarBlankCellReuseIdentifier;
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendarConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CGFloat const FSCalendarMaximumEventDotDiameter = 4.8;

NSInteger const FSCalendarDefaultHourComponent = 0;
NSInteger const FSCalendarMaximumNumberOfEvents = 3;

NSString * const FSCalendarDefaultCellReuseIdentifier = @"_FSCalendarDefaultCellReuseIdentifier";
NSString * const FSCalendarBlankCellReuseIdentifier = @"_FSCalendarBlankCellReuseIdentifier";
Expand Down
5 changes: 0 additions & 5 deletions FSCalendar/FSCalendarDynamicHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@property (readonly, nonatomic) NSArray *visibleStickyHeaders;
@property (readonly, nonatomic) CGFloat preferredHeaderHeight;
@property (readonly, nonatomic) CGFloat preferredWeekdayHeight;
@property (readonly, nonatomic) UIView *bottomBorder;

@property (readonly, nonatomic) NSCalendar *gregorian;
@property (readonly, nonatomic) NSDateFormatter *formatter;
Expand All @@ -41,13 +40,9 @@

@property (assign, nonatomic) BOOL needsAdjustingViewFrame;

- (void)invalidateHeaders;
- (void)adjustMonthPosition;
- (void)configureAppearance;

- (BOOL)isPageInRange:(NSDate *)page;
- (BOOL)isDateInRange:(NSDate *)date;

- (CGSize)sizeThatFits:(CGSize)size scope:(FSCalendarScope)scope;

@end
Expand Down
5 changes: 5 additions & 0 deletions FSCalendar/FSCalendarExtensions.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ - (nullable NSDate *)fs_middleDayOfWeek:(NSDate *)week
NSDateComponents *weekdayComponents = [self components:NSCalendarUnitWeekday fromDate:week];
NSDateComponents *componentsToSubtract = self.fs_privateComponents;
componentsToSubtract.day = - (weekdayComponents.weekday - self.firstWeekday) + 3;
// Fix https://github.com/WenchaoD/FSCalendar/issues/1100 and https://github.com/WenchaoD/FSCalendar/issues/1102
// If firstWeekday is not 1, and weekday is less than firstWeekday, the middleDayOfWeek will be the middle day of next week
if (weekdayComponents.weekday < self.firstWeekday) {
componentsToSubtract.day = componentsToSubtract.day - 7;
}
NSDate *middleDayOfWeek = [self dateByAddingComponents:componentsToSubtract toDate:week options:0];
NSDateComponents *components = [self components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour fromDate:middleDayOfWeek];
middleDayOfWeek = [self dateFromComponents:components];
Expand Down
2 changes: 1 addition & 1 deletion FSCalendar/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.8.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit dcaa322

Please sign in to comment.