From 112afd0e1c81edc3d4cc222e237359250548eaa0 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Sat, 1 Aug 2020 12:15:45 -0700 Subject: [PATCH] Bugfix/callback (#5) * updated elegantpages to fix bug with willdisplaymonth being called multiple times at calendar creation * fixed bug where a month wouldn't show if the end date was exactly the start of that month * updated the examples * lowered the swift tools version * updated the examples --- Example/Example.xcodeproj/project.pbxproj | 266 ++---------------- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../ExampleCalendarView.swift | 7 +- .../Calendar with Accessory View/Visit.swift | 9 + Example/Example/ContentView.swift | 9 +- .../ExampleMonthlyCalendarView.swift | 7 +- .../ExampleYearlyCalendarView.swift | 7 +- .../ExampleSelectionView.swift | 1 + .../Example/Shared/ChangeThemeButton.swift | 1 + Example/Example/Shared/Date+Additions.swift | 39 +++ Example/Example/Shared/Date+FullDate.swift | 21 -- .../Shared/LightDarkThemePreview.swift | 58 ++++ Package.resolved | 4 +- Package.swift | 4 +- .../Helpers/Extensions/Calender+Dates.swift | 7 + .../MonthlyCalendarManager.swift | 2 +- 16 files changed, 164 insertions(+), 282 deletions(-) create mode 100644 Example/Example/Shared/Date+Additions.swift delete mode 100644 Example/Example/Shared/Date+FullDate.swift create mode 100644 Example/Example/Shared/LightDarkThemePreview.swift diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index d9b5275..70efdd9 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -15,48 +15,18 @@ 1E029CB324A4450200A81FFD /* ExampleCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029CB024A4450200A81FFD /* ExampleCalendarView.swift */; }; 1E029CB424A4450200A81FFD /* ExampleMonthlyCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029CB124A4450200A81FFD /* ExampleMonthlyCalendarView.swift */; }; 1E029CB524A4450200A81FFD /* ExampleYearlyCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029CB224A4450200A81FFD /* ExampleYearlyCalendarView.swift */; }; - 1E029D3224A4492B00A81FFD /* ElegantPages in Frameworks */ = {isa = PBXBuildFile; productRef = 1E029D3124A4492B00A81FFD /* ElegantPages */; }; + 1E161AF724D5F46200CA2B7F /* Date+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E161AF624D5F46200CA2B7F /* Date+Additions.swift */; }; + 1E161AFA24D5F47D00CA2B7F /* ElegantCalendar in Frameworks */ = {isa = PBXBuildFile; productRef = 1E161AF924D5F47D00CA2B7F /* ElegantCalendar */; }; + 1E161AFC24D5F51000CA2B7F /* LightDarkThemePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E161AFB24D5F51000CA2B7F /* LightDarkThemePreview.swift */; }; + 1E161AFE24D5F59500CA2B7F /* ElegantCalendar.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1E161AFD24D5F59500CA2B7F /* ElegantCalendar.xcassets */; }; 1E628BED24A451B900DDD18E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E628BEC24A451B900DDD18E /* ContentView.swift */; }; 1E628BEF24A4528D00DDD18E /* ExampleSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E628BEE24A4528D00DDD18E /* ExampleSelectionView.swift */; }; - 1E628BF124A457C700DDD18E /* Date+FullDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E628BF024A457C700DDD18E /* Date+FullDate.swift */; }; 1E995AF424A552BA00F436BE /* Visit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E995AF024A552BA00F436BE /* Visit.swift */; }; 1E995AF524A552BA00F436BE /* VisitsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E995AF124A552BA00F436BE /* VisitsListView.swift */; }; 1E995AF624A552BA00F436BE /* VisitPreviewConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E995AF224A552BA00F436BE /* VisitPreviewConstants.swift */; }; 1E995AF724A552BA00F436BE /* VisitCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E995AF324A552BA00F436BE /* VisitCell.swift */; }; - 1EE7C01724BE8720000573A2 /* Calendar+Buildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7C01624BE8720000573A2 /* Calendar+Buildable.swift */; }; - 1EE7C01924BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7C01824BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift */; }; 1EE7C01B24BEA4B3000573A2 /* ChangeThemeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7C01A24BEA4B3000573A2 /* ChangeThemeButton.swift */; }; 1EE7C01D24BEA55B000573A2 /* Color+Custom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7C01C24BEA55B000573A2 /* Color+Custom.swift */; }; - 1EE7DDDA24BD6054008BA2EC /* ElegantCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDB424BD6054008BA2EC /* ElegantCalendarView.swift */; }; - 1EE7DDDB24BD6054008BA2EC /* ScrollBackToTodayButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDB624BD6054008BA2EC /* ScrollBackToTodayButton.swift */; }; - 1EE7DDDC24BD6054008BA2EC /* MonthlyCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDB824BD6054008BA2EC /* MonthlyCalendarView.swift */; }; - 1EE7DDDD24BD6054008BA2EC /* MonthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDB924BD6054008BA2EC /* MonthView.swift */; }; - 1EE7DDDE24BD6054008BA2EC /* WeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDBA24BD6054008BA2EC /* WeekView.swift */; }; - 1EE7DDDF24BD6054008BA2EC /* DayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDBB24BD6054008BA2EC /* DayView.swift */; }; - 1EE7DDE024BD6054008BA2EC /* SmallMonthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDBD24BD6054008BA2EC /* SmallMonthView.swift */; }; - 1EE7DDE124BD6054008BA2EC /* YearlyCalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDBE24BD6054008BA2EC /* YearlyCalendarView.swift */; }; - 1EE7DDE224BD6054008BA2EC /* SmallDayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDBF24BD6054008BA2EC /* SmallDayView.swift */; }; - 1EE7DDE324BD6054008BA2EC /* SmallWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC024BD6054008BA2EC /* SmallWeekView.swift */; }; - 1EE7DDE424BD6054008BA2EC /* YearView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC124BD6054008BA2EC /* YearView.swift */; }; - 1EE7DDE524BD6054008BA2EC /* CalenderConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC424BD6054008BA2EC /* CalenderConstants.swift */; }; - 1EE7DDE624BD6054008BA2EC /* CalendarConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC524BD6054008BA2EC /* CalendarConfiguration.swift */; }; - 1EE7DDE724BD6054008BA2EC /* YearlyCalendarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC724BD6054008BA2EC /* YearlyCalendarManager.swift */; }; - 1EE7DDE824BD6054008BA2EC /* ElegantCalendarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC824BD6054008BA2EC /* ElegantCalendarManager.swift */; }; - 1EE7DDE924BD6054008BA2EC /* PagerState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDC924BD6054008BA2EC /* PagerState.swift */; }; - 1EE7DDEA24BD6054008BA2EC /* MonthlyCalendarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDCA24BD6054008BA2EC /* MonthlyCalendarManager.swift */; }; - 1EE7DDEB24BD6054008BA2EC /* ElegantCalendarCommunicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDCC24BD6054008BA2EC /* ElegantCalendarCommunicator.swift */; }; - 1EE7DDEC24BD6054008BA2EC /* ElegantCalendarDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDCD24BD6054008BA2EC /* ElegantCalendarDataSource.swift */; }; - 1EE7DDED24BD6054008BA2EC /* ElegantCalendarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDCE24BD6054008BA2EC /* ElegantCalendarDelegate.swift */; }; - 1EE7DDEE24BD6054008BA2EC /* UIImpactFeedbackGenerator+Haptic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD024BD6054008BA2EC /* UIImpactFeedbackGenerator+Haptic.swift */; }; - 1EE7DDEF24BD6054008BA2EC /* Date+DaysFromToday.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD124BD6054008BA2EC /* Date+DaysFromToday.swift */; }; - 1EE7DDF024BD6054008BA2EC /* UIImage+BundleInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD224BD6054008BA2EC /* UIImage+BundleInit.swift */; }; - 1EE7DDF124BD6054008BA2EC /* Image+Custom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD324BD6054008BA2EC /* Image+Custom.swift */; }; - 1EE7DDF224BD6054008BA2EC /* Date+toString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD424BD6054008BA2EC /* Date+toString.swift */; }; - 1EE7DDF324BD6054008BA2EC /* Color+CustomColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD524BD6054008BA2EC /* Color+CustomColors.swift */; }; - 1EE7DDF424BD6054008BA2EC /* Enumeration+Matching.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD624BD6054008BA2EC /* Enumeration+Matching.swift */; }; - 1EE7DDF524BD6054008BA2EC /* Calender+Dates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD724BD6054008BA2EC /* Calender+Dates.swift */; }; - 1EE7DDF624BD6054008BA2EC /* LightDarkThemePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE7DDD924BD6054008BA2EC /* LightDarkThemePreview.swift */; }; - 1EE7DDF824BD6064008BA2EC /* ElegantCalendar.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1EE7DDF724BD6064008BA2EC /* ElegantCalendar.xcassets */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -70,47 +40,18 @@ 1E029CB024A4450200A81FFD /* ExampleCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCalendarView.swift; sourceTree = ""; }; 1E029CB124A4450200A81FFD /* ExampleMonthlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleMonthlyCalendarView.swift; sourceTree = ""; }; 1E029CB224A4450200A81FFD /* ExampleYearlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleYearlyCalendarView.swift; sourceTree = ""; }; + 1E161AF524D5F43C00CA2B7F /* ElegantCalendar */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ElegantCalendar; path = ../..; sourceTree = ""; }; + 1E161AF624D5F46200CA2B7F /* Date+Additions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Additions.swift"; sourceTree = ""; }; + 1E161AFB24D5F51000CA2B7F /* LightDarkThemePreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightDarkThemePreview.swift; sourceTree = ""; }; + 1E161AFD24D5F59500CA2B7F /* ElegantCalendar.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = ElegantCalendar.xcassets; path = ../ElegantCalendar.xcassets; sourceTree = ""; }; 1E628BEC24A451B900DDD18E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 1E628BEE24A4528D00DDD18E /* ExampleSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleSelectionView.swift; sourceTree = ""; }; - 1E628BF024A457C700DDD18E /* Date+FullDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+FullDate.swift"; sourceTree = ""; }; 1E995AF024A552BA00F436BE /* Visit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Visit.swift; sourceTree = ""; }; 1E995AF124A552BA00F436BE /* VisitsListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitsListView.swift; sourceTree = ""; }; 1E995AF224A552BA00F436BE /* VisitPreviewConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitPreviewConstants.swift; sourceTree = ""; }; 1E995AF324A552BA00F436BE /* VisitCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitCell.swift; sourceTree = ""; }; - 1EE7C01624BE8720000573A2 /* Calendar+Buildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+Buildable.swift"; sourceTree = ""; }; - 1EE7C01824BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EnvironmentKey+CalendarTheme.swift"; sourceTree = ""; }; 1EE7C01A24BEA4B3000573A2 /* ChangeThemeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeThemeButton.swift; sourceTree = ""; }; 1EE7C01C24BEA55B000573A2 /* Color+Custom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Custom.swift"; sourceTree = ""; }; - 1EE7DDB424BD6054008BA2EC /* ElegantCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarView.swift; sourceTree = ""; }; - 1EE7DDB624BD6054008BA2EC /* ScrollBackToTodayButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollBackToTodayButton.swift; sourceTree = ""; }; - 1EE7DDB824BD6054008BA2EC /* MonthlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthlyCalendarView.swift; sourceTree = ""; }; - 1EE7DDB924BD6054008BA2EC /* MonthView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthView.swift; sourceTree = ""; }; - 1EE7DDBA24BD6054008BA2EC /* WeekView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeekView.swift; sourceTree = ""; }; - 1EE7DDBB24BD6054008BA2EC /* DayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DayView.swift; sourceTree = ""; }; - 1EE7DDBD24BD6054008BA2EC /* SmallMonthView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SmallMonthView.swift; sourceTree = ""; }; - 1EE7DDBE24BD6054008BA2EC /* YearlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YearlyCalendarView.swift; sourceTree = ""; }; - 1EE7DDBF24BD6054008BA2EC /* SmallDayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SmallDayView.swift; sourceTree = ""; }; - 1EE7DDC024BD6054008BA2EC /* SmallWeekView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SmallWeekView.swift; sourceTree = ""; }; - 1EE7DDC124BD6054008BA2EC /* YearView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YearView.swift; sourceTree = ""; }; - 1EE7DDC424BD6054008BA2EC /* CalenderConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalenderConstants.swift; sourceTree = ""; }; - 1EE7DDC524BD6054008BA2EC /* CalendarConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarConfiguration.swift; sourceTree = ""; }; - 1EE7DDC724BD6054008BA2EC /* YearlyCalendarManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YearlyCalendarManager.swift; sourceTree = ""; }; - 1EE7DDC824BD6054008BA2EC /* ElegantCalendarManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarManager.swift; sourceTree = ""; }; - 1EE7DDC924BD6054008BA2EC /* PagerState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerState.swift; sourceTree = ""; }; - 1EE7DDCA24BD6054008BA2EC /* MonthlyCalendarManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthlyCalendarManager.swift; sourceTree = ""; }; - 1EE7DDCC24BD6054008BA2EC /* ElegantCalendarCommunicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarCommunicator.swift; sourceTree = ""; }; - 1EE7DDCD24BD6054008BA2EC /* ElegantCalendarDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarDataSource.swift; sourceTree = ""; }; - 1EE7DDCE24BD6054008BA2EC /* ElegantCalendarDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarDelegate.swift; sourceTree = ""; }; - 1EE7DDD024BD6054008BA2EC /* UIImpactFeedbackGenerator+Haptic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImpactFeedbackGenerator+Haptic.swift"; sourceTree = ""; }; - 1EE7DDD124BD6054008BA2EC /* Date+DaysFromToday.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Date+DaysFromToday.swift"; sourceTree = ""; }; - 1EE7DDD224BD6054008BA2EC /* UIImage+BundleInit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+BundleInit.swift"; sourceTree = ""; }; - 1EE7DDD324BD6054008BA2EC /* Image+Custom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Image+Custom.swift"; sourceTree = ""; }; - 1EE7DDD424BD6054008BA2EC /* Date+toString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Date+toString.swift"; sourceTree = ""; }; - 1EE7DDD524BD6054008BA2EC /* Color+CustomColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Color+CustomColors.swift"; sourceTree = ""; }; - 1EE7DDD624BD6054008BA2EC /* Enumeration+Matching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Enumeration+Matching.swift"; sourceTree = ""; }; - 1EE7DDD724BD6054008BA2EC /* Calender+Dates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Calender+Dates.swift"; sourceTree = ""; }; - 1EE7DDD924BD6054008BA2EC /* LightDarkThemePreview.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LightDarkThemePreview.swift; sourceTree = ""; }; - 1EE7DDF724BD6064008BA2EC /* ElegantCalendar.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = ElegantCalendar.xcassets; path = ../ElegantCalendar.xcassets; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -118,7 +59,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1E029D3224A4492B00A81FFD /* ElegantPages in Frameworks */, + 1E161AFA24D5F47D00CA2B7F /* ElegantCalendar in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -128,9 +69,10 @@ 1E029C6A24A4448A00A81FFD = { isa = PBXGroup; children = ( - 1EE7DDF724BD6064008BA2EC /* ElegantCalendar.xcassets */, + 1E161AFD24D5F59500CA2B7F /* ElegantCalendar.xcassets */, 1E029C7524A4448A00A81FFD /* Example */, 1E029C7424A4448A00A81FFD /* Products */, + 1E161AF824D5F47D00CA2B7F /* Frameworks */, ); sourceTree = ""; }; @@ -155,7 +97,7 @@ 1E029C7C24A4448A00A81FFD /* Assets.xcassets */, 1E029C8124A4448A00A81FFD /* LaunchScreen.storyboard */, 1E029C8424A4448A00A81FFD /* Info.plist */, - 1EE7DDB124BD6054008BA2EC /* Sources */, + 1E161AF524D5F43C00CA2B7F /* ElegantCalendar */, 1E029C7E24A4448A00A81FFD /* Preview Content */, ); path = Example; @@ -201,138 +143,19 @@ 1E029D3824A44D2D00A81FFD /* Shared */ = { isa = PBXGroup; children = ( - 1E628BF024A457C700DDD18E /* Date+FullDate.swift */, 1EE7C01A24BEA4B3000573A2 /* ChangeThemeButton.swift */, 1EE7C01C24BEA55B000573A2 /* Color+Custom.swift */, + 1E161AF624D5F46200CA2B7F /* Date+Additions.swift */, + 1E161AFB24D5F51000CA2B7F /* LightDarkThemePreview.swift */, ); path = Shared; sourceTree = ""; }; - 1EE7DDB124BD6054008BA2EC /* Sources */ = { + 1E161AF824D5F47D00CA2B7F /* Frameworks */ = { isa = PBXGroup; children = ( - 1EE7DDB224BD6054008BA2EC /* ElegantCalendar */, ); - name = Sources; - path = ../../Sources; - sourceTree = ""; - }; - 1EE7DDB224BD6054008BA2EC /* ElegantCalendar */ = { - isa = PBXGroup; - children = ( - 1EE7DDB324BD6054008BA2EC /* Views */, - 1EE7DDC224BD6054008BA2EC /* Helpers */, - ); - path = ElegantCalendar; - sourceTree = ""; - }; - 1EE7DDB324BD6054008BA2EC /* Views */ = { - isa = PBXGroup; - children = ( - 1EE7DDB424BD6054008BA2EC /* ElegantCalendarView.swift */, - 1EE7DDB524BD6054008BA2EC /* Shared */, - 1EE7DDB724BD6054008BA2EC /* Monthly */, - 1EE7DDBC24BD6054008BA2EC /* Yearly */, - ); - path = Views; - sourceTree = ""; - }; - 1EE7DDB524BD6054008BA2EC /* Shared */ = { - isa = PBXGroup; - children = ( - 1EE7DDB624BD6054008BA2EC /* ScrollBackToTodayButton.swift */, - ); - path = Shared; - sourceTree = ""; - }; - 1EE7DDB724BD6054008BA2EC /* Monthly */ = { - isa = PBXGroup; - children = ( - 1EE7DDB824BD6054008BA2EC /* MonthlyCalendarView.swift */, - 1EE7DDB924BD6054008BA2EC /* MonthView.swift */, - 1EE7DDBA24BD6054008BA2EC /* WeekView.swift */, - 1EE7DDBB24BD6054008BA2EC /* DayView.swift */, - ); - path = Monthly; - sourceTree = ""; - }; - 1EE7DDBC24BD6054008BA2EC /* Yearly */ = { - isa = PBXGroup; - children = ( - 1EE7DDBD24BD6054008BA2EC /* SmallMonthView.swift */, - 1EE7DDBE24BD6054008BA2EC /* YearlyCalendarView.swift */, - 1EE7DDBF24BD6054008BA2EC /* SmallDayView.swift */, - 1EE7DDC024BD6054008BA2EC /* SmallWeekView.swift */, - 1EE7DDC124BD6054008BA2EC /* YearView.swift */, - ); - path = Yearly; - sourceTree = ""; - }; - 1EE7DDC224BD6054008BA2EC /* Helpers */ = { - isa = PBXGroup; - children = ( - 1EE7DDC324BD6054008BA2EC /* Models */, - 1EE7DDCF24BD6054008BA2EC /* Extensions */, - 1EE7DDD824BD6054008BA2EC /* Previews */, - ); - path = Helpers; - sourceTree = ""; - }; - 1EE7DDC324BD6054008BA2EC /* Models */ = { - isa = PBXGroup; - children = ( - 1EE7DDC424BD6054008BA2EC /* CalenderConstants.swift */, - 1EE7DDC524BD6054008BA2EC /* CalendarConfiguration.swift */, - 1EE7DDC624BD6054008BA2EC /* ObservableObjects */, - 1EE7DDCB24BD6054008BA2EC /* Protocols */, - ); - path = Models; - sourceTree = ""; - }; - 1EE7DDC624BD6054008BA2EC /* ObservableObjects */ = { - isa = PBXGroup; - children = ( - 1EE7DDC724BD6054008BA2EC /* YearlyCalendarManager.swift */, - 1EE7DDC824BD6054008BA2EC /* ElegantCalendarManager.swift */, - 1EE7DDC924BD6054008BA2EC /* PagerState.swift */, - 1EE7DDCA24BD6054008BA2EC /* MonthlyCalendarManager.swift */, - ); - path = ObservableObjects; - sourceTree = ""; - }; - 1EE7DDCB24BD6054008BA2EC /* Protocols */ = { - isa = PBXGroup; - children = ( - 1EE7C01624BE8720000573A2 /* Calendar+Buildable.swift */, - 1EE7DDCC24BD6054008BA2EC /* ElegantCalendarCommunicator.swift */, - 1EE7DDCD24BD6054008BA2EC /* ElegantCalendarDataSource.swift */, - 1EE7DDCE24BD6054008BA2EC /* ElegantCalendarDelegate.swift */, - ); - path = Protocols; - sourceTree = ""; - }; - 1EE7DDCF24BD6054008BA2EC /* Extensions */ = { - isa = PBXGroup; - children = ( - 1EE7DDD024BD6054008BA2EC /* UIImpactFeedbackGenerator+Haptic.swift */, - 1EE7DDD124BD6054008BA2EC /* Date+DaysFromToday.swift */, - 1EE7DDD224BD6054008BA2EC /* UIImage+BundleInit.swift */, - 1EE7DDD324BD6054008BA2EC /* Image+Custom.swift */, - 1EE7DDD424BD6054008BA2EC /* Date+toString.swift */, - 1EE7DDD524BD6054008BA2EC /* Color+CustomColors.swift */, - 1EE7DDD624BD6054008BA2EC /* Enumeration+Matching.swift */, - 1EE7DDD724BD6054008BA2EC /* Calender+Dates.swift */, - 1EE7C01824BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift */, - ); - path = Extensions; - sourceTree = ""; - }; - 1EE7DDD824BD6054008BA2EC /* Previews */ = { - isa = PBXGroup; - children = ( - 1EE7DDD924BD6054008BA2EC /* LightDarkThemePreview.swift */, - ); - path = Previews; + name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ @@ -352,7 +175,7 @@ ); name = Example; packageProductDependencies = ( - 1E029D3124A4492B00A81FFD /* ElegantPages */, + 1E161AF924D5F47D00CA2B7F /* ElegantCalendar */, ); productName = Example; productReference = 1E029C7324A4448A00A81FFD /* Example.app */; @@ -383,7 +206,6 @@ ); mainGroup = 1E029C6A24A4448A00A81FFD; packageReferences = ( - 1E029D3024A4492B00A81FFD /* XCRemoteSwiftPackageReference "ElegantPages" */, ); productRefGroup = 1E029C7424A4448A00A81FFD /* Products */; projectDirPath = ""; @@ -402,7 +224,7 @@ 1E029C8324A4448A00A81FFD /* LaunchScreen.storyboard in Resources */, 1E029C8024A4448A00A81FFD /* Preview Assets.xcassets in Resources */, 1E029C7D24A4448A00A81FFD /* Assets.xcassets in Resources */, - 1EE7DDF824BD6064008BA2EC /* ElegantCalendar.xcassets in Resources */, + 1E161AFE24D5F59500CA2B7F /* ElegantCalendar.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -415,49 +237,19 @@ files = ( 1EE7C01D24BEA55B000573A2 /* Color+Custom.swift in Sources */, 1E029CB424A4450200A81FFD /* ExampleMonthlyCalendarView.swift in Sources */, - 1EE7DDE024BD6054008BA2EC /* SmallMonthView.swift in Sources */, - 1EE7DDE624BD6054008BA2EC /* CalendarConfiguration.swift in Sources */, 1E995AF424A552BA00F436BE /* Visit.swift in Sources */, - 1EE7DDE224BD6054008BA2EC /* SmallDayView.swift in Sources */, 1E029C7724A4448A00A81FFD /* AppDelegate.swift in Sources */, - 1EE7C01724BE8720000573A2 /* Calendar+Buildable.swift in Sources */, - 1EE7DDDA24BD6054008BA2EC /* ElegantCalendarView.swift in Sources */, 1EE7C01B24BEA4B3000573A2 /* ChangeThemeButton.swift in Sources */, - 1EE7DDEA24BD6054008BA2EC /* MonthlyCalendarManager.swift in Sources */, - 1EE7DDDC24BD6054008BA2EC /* MonthlyCalendarView.swift in Sources */, - 1EE7DDE924BD6054008BA2EC /* PagerState.swift in Sources */, - 1EE7DDF424BD6054008BA2EC /* Enumeration+Matching.swift in Sources */, + 1E161AFC24D5F51000CA2B7F /* LightDarkThemePreview.swift in Sources */, 1E995AF724A552BA00F436BE /* VisitCell.swift in Sources */, - 1EE7DDE124BD6054008BA2EC /* YearlyCalendarView.swift in Sources */, - 1EE7DDF624BD6054008BA2EC /* LightDarkThemePreview.swift in Sources */, - 1EE7DDDE24BD6054008BA2EC /* WeekView.swift in Sources */, 1E029C7924A4448A00A81FFD /* SceneDelegate.swift in Sources */, - 1EE7DDEB24BD6054008BA2EC /* ElegantCalendarCommunicator.swift in Sources */, 1E995AF624A552BA00F436BE /* VisitPreviewConstants.swift in Sources */, - 1EE7DDE424BD6054008BA2EC /* YearView.swift in Sources */, 1E628BED24A451B900DDD18E /* ContentView.swift in Sources */, - 1EE7DDE824BD6054008BA2EC /* ElegantCalendarManager.swift in Sources */, + 1E161AF724D5F46200CA2B7F /* Date+Additions.swift in Sources */, 1E995AF524A552BA00F436BE /* VisitsListView.swift in Sources */, - 1EE7DDDD24BD6054008BA2EC /* MonthView.swift in Sources */, - 1EE7DDF524BD6054008BA2EC /* Calender+Dates.swift in Sources */, 1E628BEF24A4528D00DDD18E /* ExampleSelectionView.swift in Sources */, - 1EE7DDF124BD6054008BA2EC /* Image+Custom.swift in Sources */, - 1E628BF124A457C700DDD18E /* Date+FullDate.swift in Sources */, - 1EE7DDEF24BD6054008BA2EC /* Date+DaysFromToday.swift in Sources */, - 1EE7DDE324BD6054008BA2EC /* SmallWeekView.swift in Sources */, - 1EE7DDE724BD6054008BA2EC /* YearlyCalendarManager.swift in Sources */, - 1EE7DDED24BD6054008BA2EC /* ElegantCalendarDelegate.swift in Sources */, 1E029CB324A4450200A81FFD /* ExampleCalendarView.swift in Sources */, 1E029CB524A4450200A81FFD /* ExampleYearlyCalendarView.swift in Sources */, - 1EE7DDE524BD6054008BA2EC /* CalenderConstants.swift in Sources */, - 1EE7DDF324BD6054008BA2EC /* Color+CustomColors.swift in Sources */, - 1EE7DDDB24BD6054008BA2EC /* ScrollBackToTodayButton.swift in Sources */, - 1EE7DDF224BD6054008BA2EC /* Date+toString.swift in Sources */, - 1EE7C01924BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift in Sources */, - 1EE7DDDF24BD6054008BA2EC /* DayView.swift in Sources */, - 1EE7DDF024BD6054008BA2EC /* UIImage+BundleInit.swift in Sources */, - 1EE7DDEC24BD6054008BA2EC /* ElegantCalendarDataSource.swift in Sources */, - 1EE7DDEE24BD6054008BA2EC /* UIImpactFeedbackGenerator+Haptic.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -598,6 +390,7 @@ DEVELOPMENT_TEAM = 75H2NCGMKS; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Example/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -618,6 +411,7 @@ DEVELOPMENT_TEAM = 75H2NCGMKS; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Example/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -652,22 +446,10 @@ }; /* End XCConfigurationList section */ -/* Begin XCRemoteSwiftPackageReference section */ - 1E029D3024A4492B00A81FFD /* XCRemoteSwiftPackageReference "ElegantPages" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/ThasianX/ElegantPages"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.4.0; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - /* Begin XCSwiftPackageProductDependency section */ - 1E029D3124A4492B00A81FFD /* ElegantPages */ = { + 1E161AF924D5F47D00CA2B7F /* ElegantCalendar */ = { isa = XCSwiftPackageProductDependency; - package = 1E029D3024A4492B00A81FFD /* XCRemoteSwiftPackageReference "ElegantPages" */; - productName = ElegantPages; + productName = ElegantCalendar; }; /* End XCSwiftPackageProductDependency section */ }; diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 51140d5..ac1cec3 100644 --- a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ThasianX/ElegantPages", "state": { "branch": null, - "revision": "7eb457484e04375d7e6a3ca442a98cbe75ead7b0", - "version": "1.4.0" + "revision": "47d166799f2313ad9e47c9c22687021d396d940f", + "version": "1.4.1" } } ] diff --git a/Example/Example/Calendar with Accessory View/ExampleCalendarView.swift b/Example/Example/Calendar with Accessory View/ExampleCalendarView.swift index d77af6e..f864ed0 100644 --- a/Example/Example/Calendar with Accessory View/ExampleCalendarView.swift +++ b/Example/Example/Calendar with Accessory View/ExampleCalendarView.swift @@ -1,5 +1,6 @@ // Kevin Li - 11:47 AM - 6/13/20 +import ElegantCalendar import SwiftUI struct ExampleCalendarView: View { @@ -10,7 +11,7 @@ struct ExampleCalendarView: View { @State private var calendarTheme: CalendarTheme = .royalBlue - init(ascVisits: [Visit]) { + init(ascVisits: [Visit], initialMonth: Date?) { let configuration = CalendarConfiguration( calendar: currentCalendar, startDate: ascVisits.first!.arrivalDate, @@ -18,7 +19,7 @@ struct ExampleCalendarView: View { calendarManager = ElegantCalendarManager( configuration: configuration, - initialMonth: .daysFromToday(30)) + initialMonth: initialMonth) visitsByDay = Dictionary( grouping: ascVisits, @@ -87,6 +88,6 @@ extension ExampleCalendarView: ElegantCalendarDelegate { struct ExampleCalendarView_Previews: PreviewProvider { static var previews: some View { - ExampleCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2))) + ExampleCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2)), initialMonth: nil) } } diff --git a/Example/Example/Calendar with Accessory View/Visit.swift b/Example/Example/Calendar with Accessory View/Visit.swift index 07035d3..75ad100 100644 --- a/Example/Example/Calendar with Accessory View/Visit.swift +++ b/Example/Example/Calendar with Accessory View/Visit.swift @@ -3,6 +3,7 @@ import SwiftUI let currentCalendar = Calendar.current +let screen = UIScreen.main.bounds struct Visit { @@ -99,3 +100,11 @@ fileprivate extension Color { } } + +fileprivate extension DateComponents { + + static var everyDay: DateComponents { + DateComponents(hour: 0, minute: 0, second: 0) + } + +} diff --git a/Example/Example/ContentView.swift b/Example/Example/ContentView.swift index 9ec1fad..468d347 100644 --- a/Example/Example/ContentView.swift +++ b/Example/Example/ContentView.swift @@ -9,17 +9,20 @@ struct ContentView: View { // ExampleYearlyCalendarView( // ascVisits: Visit.mocks( // start: .daysFromToday(-30*36), -// end: .daysFromToday(30*36))) +// end: .daysFromToday(30*36)), +// initialYear: .daysFromToday(365)) // ExampleMonthlyCalendarView( // ascVisits: Visit.mocks( // start: .daysFromToday(-30*36), -// end: .daysFromToday(30*36))) +// end: .daysFromToday(30*36)), +// initialMonth: .daysFromToday(30)) ExampleCalendarView( ascVisits: Visit.mocks( start: .daysFromToday(-30*36), - end: .daysFromToday(30*36))) + end: .daysFromToday(30*36)), + initialMonth: Date()) // ExampleSelectionView() } diff --git a/Example/Example/Individual Views/ExampleMonthlyCalendarView.swift b/Example/Example/Individual Views/ExampleMonthlyCalendarView.swift index 5700c18..dec73c7 100644 --- a/Example/Example/Individual Views/ExampleMonthlyCalendarView.swift +++ b/Example/Example/Individual Views/ExampleMonthlyCalendarView.swift @@ -1,5 +1,6 @@ // Kevin Li - 5:51 PM - 6/14/20 +import ElegantCalendar import SwiftUI struct ExampleMonthlyCalendarView: View { @@ -10,12 +11,12 @@ struct ExampleMonthlyCalendarView: View { @State private var calendarTheme: CalendarTheme = .royalBlue - init(ascVisits: [Visit]) { + init(ascVisits: [Visit], initialMonth: Date?) { let configuration = CalendarConfiguration(calendar: currentCalendar, startDate: ascVisits.first!.arrivalDate, endDate: ascVisits.last!.arrivalDate) calendarManager = MonthlyCalendarManager(configuration: configuration, - initialMonth: .daysFromToday(30)) + initialMonth: initialMonth) visitsByDay = Dictionary(grouping: ascVisits, by: { currentCalendar.startOfDay(for: $0.arrivalDate) }) calendarManager.datasource = self @@ -73,6 +74,6 @@ extension ExampleMonthlyCalendarView: MonthlyCalendarDelegate { struct ExampleMonthlyCalendarView_Previews: PreviewProvider { static var previews: some View { - ExampleYearlyCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2))) + ExampleYearlyCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2)), initialYear: nil) } } diff --git a/Example/Example/Individual Views/ExampleYearlyCalendarView.swift b/Example/Example/Individual Views/ExampleYearlyCalendarView.swift index af049b1..0e52d3d 100644 --- a/Example/Example/Individual Views/ExampleYearlyCalendarView.swift +++ b/Example/Example/Individual Views/ExampleYearlyCalendarView.swift @@ -1,5 +1,6 @@ // Kevin Li - 4:49 PM - 6/14/20 +import ElegantCalendar import SwiftUI struct ExampleYearlyCalendarView: View { @@ -10,12 +11,12 @@ struct ExampleYearlyCalendarView: View { @State private var calendarTheme: CalendarTheme = .royalBlue - init(ascVisits: [Visit]) { + init(ascVisits: [Visit], initialYear: Date?) { let configuration = CalendarConfiguration(calendar: currentCalendar, startDate: ascVisits.first!.arrivalDate, endDate: ascVisits.last!.arrivalDate) calendarManager = YearlyCalendarManager(configuration: configuration, - initialYear: .daysFromToday(365)) + initialYear: initialYear) visitsByDay = Dictionary(grouping: ascVisits, by: { currentCalendar.startOfDay(for: $0.arrivalDate) }) calendarManager.delegate = self @@ -53,6 +54,6 @@ extension ExampleYearlyCalendarView: YearlyCalendarDelegate { struct ExampleYearlyCalendarView_Previews: PreviewProvider { static var previews: some View { - ExampleYearlyCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2))) + ExampleYearlyCalendarView(ascVisits: Visit.mocks(start: .daysFromToday(-365*2), end: .daysFromToday(365*2)), initialYear: nil) } } diff --git a/Example/Example/Selection and Exit/ExampleSelectionView.swift b/Example/Example/Selection and Exit/ExampleSelectionView.swift index 3af70d2..55d8b6a 100644 --- a/Example/Example/Selection and Exit/ExampleSelectionView.swift +++ b/Example/Example/Selection and Exit/ExampleSelectionView.swift @@ -1,6 +1,7 @@ // Kevin Li - 8:33 PM - 6/24/20 import ElegantPages +import ElegantCalendar import SwiftUI fileprivate let turnAnimation: Animation = .spring(response: 0.4, dampingFraction: 0.95) diff --git a/Example/Example/Shared/ChangeThemeButton.swift b/Example/Example/Shared/ChangeThemeButton.swift index 39eb2ef..9590ff4 100644 --- a/Example/Example/Shared/ChangeThemeButton.swift +++ b/Example/Example/Shared/ChangeThemeButton.swift @@ -1,5 +1,6 @@ // Kevin Li - 7:42 PM - 7/14/20 +import ElegantCalendar import SwiftUI struct ChangeThemeButton: View { diff --git a/Example/Example/Shared/Date+Additions.swift b/Example/Example/Shared/Date+Additions.swift new file mode 100644 index 0000000..4be4b8e --- /dev/null +++ b/Example/Example/Shared/Date+Additions.swift @@ -0,0 +1,39 @@ +// Kevin Li - 12:05 PM - 8/1/20 + +import Foundation + +extension Date { + + static func daysFromToday(_ days: Int) -> Date { + Date().addingTimeInterval(TimeInterval(60*60*24*days)) + } + +} + +extension Date { + + var fullDate: String { + DateFormatter.fullDate.string(from: self) + } + + var timeOnlyWithPadding: String { + DateFormatter.timeOnlyWithPadding.string(from: self) + } + +} + +extension DateFormatter { + + static var fullDate: DateFormatter { + let formatter = DateFormatter() + formatter.dateFormat = "EEEE, MMM d, yyyy" + return formatter + } + + static let timeOnlyWithPadding: DateFormatter = { + let formatter = DateFormatter() + formatter.dateFormat = "h:mm a" + return formatter + }() + +} diff --git a/Example/Example/Shared/Date+FullDate.swift b/Example/Example/Shared/Date+FullDate.swift deleted file mode 100644 index 8182868..0000000 --- a/Example/Example/Shared/Date+FullDate.swift +++ /dev/null @@ -1,21 +0,0 @@ -// Kevin Li - 8:55 PM - 6/24/20 - -import SwiftUI - -extension Date { - - var fullDate: String { - DateFormatter.fullDate.string(from: self) - } - -} - -extension DateFormatter { - - static var fullDate: DateFormatter { - let formatter = DateFormatter() - formatter.dateFormat = "EEEE, MMM d, yyyy" - return formatter - } - -} diff --git a/Example/Example/Shared/LightDarkThemePreview.swift b/Example/Example/Shared/LightDarkThemePreview.swift new file mode 100644 index 0000000..542c560 --- /dev/null +++ b/Example/Example/Shared/LightDarkThemePreview.swift @@ -0,0 +1,58 @@ +// Kevin Li - 12:08 PM - 8/1/20 + +import SwiftUI + +struct LightDarkThemePreview: View { + + let preview: Preview + + var body: some View { + Group { + LightThemePreview { + self.preview + } + + DarkThemePreview { + self.preview + } + } + } + + init(@ViewBuilder preview: @escaping () -> Preview) { + self.preview = preview() + } + +} + +struct LightThemePreview: View { + + let preview: Preview + + var body: some View { + preview + .previewLayout(.sizeThatFits) + .colorScheme(.light) + } + + init(@ViewBuilder preview: @escaping () -> Preview) { + self.preview = preview() + } + +} + +struct DarkThemePreview: View { + + let preview: Preview + + var body: some View { + preview + .previewLayout(.sizeThatFits) + .colorScheme(.dark) + .background(Color.black.edgesIgnoringSafeArea(.all)) + } + + init(@ViewBuilder preview: @escaping () -> Preview) { + self.preview = preview() + } + +} diff --git a/Package.resolved b/Package.resolved index 51140d5..ac1cec3 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ThasianX/ElegantPages", "state": { "branch": null, - "revision": "7eb457484e04375d7e6a3ca442a98cbe75ead7b0", - "version": "1.4.0" + "revision": "47d166799f2313ad9e47c9c22687021d396d940f", + "version": "1.4.1" } } ] diff --git a/Package.swift b/Package.swift index db4d05d..dbdaad8 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.1 import PackageDescription @@ -13,7 +13,7 @@ let package = Package( targets: ["ElegantCalendar"]), ], dependencies: [ - .package(url: "https://github.com/ThasianX/ElegantPages", from: "1.4.0") + .package(url: "https://github.com/ThasianX/ElegantPages", from: "1.4.1") ], targets: [ .target( diff --git a/Sources/ElegantCalendar/Helpers/Extensions/Calender+Dates.swift b/Sources/ElegantCalendar/Helpers/Extensions/Calender+Dates.swift index a7dc641..3c9fb35 100644 --- a/Sources/ElegantCalendar/Helpers/Extensions/Calender+Dates.swift +++ b/Sources/ElegantCalendar/Helpers/Extensions/Calender+Dates.swift @@ -4,6 +4,13 @@ import SwiftUI extension Calendar { + func endOfDay(for date: Date) -> Date { + var components = DateComponents() + components.day = 1 + components.second = -1 + return self.date(byAdding: components, to: startOfDay(for: date))! + } + func isDate(_ date1: Date, equalTo date2: Date, toGranularities components: Set) -> Bool { components.reduce(into: true) { isEqual, component in isEqual = isEqual && isDate(date1, equalTo: date2, toGranularity: component) diff --git a/Sources/ElegantCalendar/Helpers/Models/ObservableObjects/MonthlyCalendarManager.swift b/Sources/ElegantCalendar/Helpers/Models/ObservableObjects/MonthlyCalendarManager.swift index e2d079f..3e73d68 100644 --- a/Sources/ElegantCalendar/Helpers/Models/ObservableObjects/MonthlyCalendarManager.swift +++ b/Sources/ElegantCalendar/Helpers/Models/ObservableObjects/MonthlyCalendarManager.swift @@ -29,7 +29,7 @@ public class MonthlyCalendarManager: ObservableObject, ConfigurationDirectAccess let months = configuration.calendar.generateDates( inside: DateInterval(start: configuration.startDate, - end: configuration.endDate), + end: configuration.calendar.endOfDay(for: configuration.endDate)), matching: .firstDayOfEveryMonth) self.months = configuration.ascending ? months : months.reversed()