Skip to content

Commit

Permalink
Bugfix/theme change (#3)
Browse files Browse the repository at this point in the history
* edited the configuration to only include properties that would cause a major reset to the calendar when changed. move properties like theme color and haptics that don't require a hard reset out of the configuration. finalized code regarding haptics. theme color needs to be worked on

* added new calendar theme model. everything works babyyyyyy

* fixed programmatic theme changing for the monthly calendar view

* fixed programmatic theme changing for the yearly calendar view

* wip programmatic app theme. not working when nested

* fixed the theme change for all views

* pointed elegantpages back to latest release

* reorganization

* added more themes and made the default theme royal blue

* added new dark demo gif

* added screenshots for new themes

* made calendartheme public

* Update README.md

* made public
  • Loading branch information
ThasianX authored Jul 15, 2020
1 parent c8a6e34 commit 8716d40
Show file tree
Hide file tree
Showing 40 changed files with 602 additions and 94 deletions.
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/brilliantViolet.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.573",
"green" : "0.227",
"red" : "0.271"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/craftBrown.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.388",
"green" : "0.533",
"red" : "0.659"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/fluorescentPink.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.302",
"green" : "0.086",
"red" : "0.725"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/kiwiGreen.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.161",
"green" : "0.557",
"red" : "0.459"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/mauvePurple.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.451",
"green" : "0.165",
"red" : "0.580"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/orangeYellow.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.161",
"green" : "0.529",
"red" : "0.859"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/red.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.110",
"green" : "0.125",
"red" : "0.694"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ElegantCalendar.xcassets/royalBlue.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.584",
"green" : "0.325",
"red" : "0.094"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
28 changes: 20 additions & 8 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
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 */; };
1E029D3424A44C3700A81FFD /* Color+BlackPearl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029D3324A44C3700A81FFD /* Color+BlackPearl.swift */; };
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 */; };
Expand Down Expand Up @@ -67,14 +70,17 @@
1E029CB024A4450200A81FFD /* ExampleCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCalendarView.swift; sourceTree = "<group>"; };
1E029CB124A4450200A81FFD /* ExampleMonthlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleMonthlyCalendarView.swift; sourceTree = "<group>"; };
1E029CB224A4450200A81FFD /* ExampleYearlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleYearlyCalendarView.swift; sourceTree = "<group>"; };
1E029D3324A44C3700A81FFD /* Color+BlackPearl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+BlackPearl.swift"; sourceTree = "<group>"; };
1E628BEC24A451B900DDD18E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
1E628BEE24A4528D00DDD18E /* ExampleSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleSelectionView.swift; sourceTree = "<group>"; };
1E628BF024A457C700DDD18E /* Date+FullDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+FullDate.swift"; sourceTree = "<group>"; };
1E995AF024A552BA00F436BE /* Visit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Visit.swift; sourceTree = "<group>"; };
1E995AF124A552BA00F436BE /* VisitsListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitsListView.swift; sourceTree = "<group>"; };
1E995AF224A552BA00F436BE /* VisitPreviewConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitPreviewConstants.swift; sourceTree = "<group>"; };
1E995AF324A552BA00F436BE /* VisitCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisitCell.swift; sourceTree = "<group>"; };
1EE7C01624BE8720000573A2 /* Calendar+Buildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+Buildable.swift"; sourceTree = "<group>"; };
1EE7C01824BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EnvironmentKey+CalendarTheme.swift"; sourceTree = "<group>"; };
1EE7C01A24BEA4B3000573A2 /* ChangeThemeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeThemeButton.swift; sourceTree = "<group>"; };
1EE7C01C24BEA55B000573A2 /* Color+Custom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Custom.swift"; sourceTree = "<group>"; };
1EE7DDB424BD6054008BA2EC /* ElegantCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElegantCalendarView.swift; sourceTree = "<group>"; };
1EE7DDB624BD6054008BA2EC /* ScrollBackToTodayButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollBackToTodayButton.swift; sourceTree = "<group>"; };
1EE7DDB824BD6054008BA2EC /* MonthlyCalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthlyCalendarView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,7 +151,7 @@
1E029D3624A44CBC00A81FFD /* Individual Views */,
1E029D3724A44CF700A81FFD /* Calendar with Accessory View */,
1E029D3524A44CA700A81FFD /* Selection and Exit */,
1E029D3824A44D2D00A81FFD /* Extensions */,
1E029D3824A44D2D00A81FFD /* Shared */,
1E029C7C24A4448A00A81FFD /* Assets.xcassets */,
1E029C8124A4448A00A81FFD /* LaunchScreen.storyboard */,
1E029C8424A4448A00A81FFD /* Info.plist */,
Expand Down Expand Up @@ -192,13 +198,14 @@
path = "Calendar with Accessory View";
sourceTree = "<group>";
};
1E029D3824A44D2D00A81FFD /* Extensions */ = {
1E029D3824A44D2D00A81FFD /* Shared */ = {
isa = PBXGroup;
children = (
1E029D3324A44C3700A81FFD /* Color+BlackPearl.swift */,
1E628BF024A457C700DDD18E /* Date+FullDate.swift */,
1EE7C01A24BEA4B3000573A2 /* ChangeThemeButton.swift */,
1EE7C01C24BEA55B000573A2 /* Color+Custom.swift */,
);
path = Extensions;
path = Shared;
sourceTree = "<group>";
};
1EE7DDB124BD6054008BA2EC /* Sources */ = {
Expand Down Expand Up @@ -296,6 +303,7 @@
1EE7DDCB24BD6054008BA2EC /* Protocols */ = {
isa = PBXGroup;
children = (
1EE7C01624BE8720000573A2 /* Calendar+Buildable.swift */,
1EE7DDCC24BD6054008BA2EC /* ElegantCalendarCommunicator.swift */,
1EE7DDCD24BD6054008BA2EC /* ElegantCalendarDataSource.swift */,
1EE7DDCE24BD6054008BA2EC /* ElegantCalendarDelegate.swift */,
Expand All @@ -314,6 +322,7 @@
1EE7DDD524BD6054008BA2EC /* Color+CustomColors.swift */,
1EE7DDD624BD6054008BA2EC /* Enumeration+Matching.swift */,
1EE7DDD724BD6054008BA2EC /* Calender+Dates.swift */,
1EE7C01824BE8EFD000573A2 /* EnvironmentKey+CalendarTheme.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -404,13 +413,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
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 */,
Expand All @@ -420,7 +432,6 @@
1EE7DDF624BD6054008BA2EC /* LightDarkThemePreview.swift in Sources */,
1EE7DDDE24BD6054008BA2EC /* WeekView.swift in Sources */,
1E029C7924A4448A00A81FFD /* SceneDelegate.swift in Sources */,
1E029D3424A44C3700A81FFD /* Color+BlackPearl.swift in Sources */,
1EE7DDEB24BD6054008BA2EC /* ElegantCalendarCommunicator.swift in Sources */,
1E995AF624A552BA00F436BE /* VisitPreviewConstants.swift in Sources */,
1EE7DDE424BD6054008BA2EC /* YearView.swift in Sources */,
Expand All @@ -442,6 +453,7 @@
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 */,
Expand Down Expand Up @@ -646,7 +658,7 @@
repositoryURL = "https://github.com/ThasianX/ElegantPages";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
minimumVersion = 1.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/ThasianX/ElegantPages",
"state": {
"branch": null,
"revision": "450ed57eed98174448929918342889b255c664d1",
"version": "1.1.0"
"revision": "6c356456458b7bf99472577d57cc2560fc3601e2",
"version": "1.2.0"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ struct ExampleCalendarView: View {

let visitsByDay: [Date: [Visit]]

@State private var calendarTheme: CalendarTheme = .royalBlue

init(ascVisits: [Visit]) {
let configuration = CalendarConfiguration(
calendar: currentCalendar,
startDate: ascVisits.first!.arrivalDate,
endDate: ascVisits.last!.arrivalDate,
themeColor: .blackPearl)
endDate: ascVisits.last!.arrivalDate)

calendarManager = ElegantCalendarManager(
configuration: configuration,
Expand All @@ -28,7 +29,19 @@ struct ExampleCalendarView: View {
}

var body: some View {
ElegantCalendarView(calendarManager: calendarManager)
ZStack {
ElegantCalendarView(calendarManager: calendarManager)
.theme(calendarTheme)
VStack {
Spacer()
changeThemeButton
.padding(.bottom, 50)
}
}
}

private var changeThemeButton: some View {
ChangeThemeButton(calendarTheme: $calendarTheme)
}

}
Expand Down
24 changes: 22 additions & 2 deletions Example/Example/Calendar with Accessory View/Visit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Visit {
extension Visit: Identifiable {

var id: Int {
locationName.hashValue
UUID().hashValue
}

}
Expand Down Expand Up @@ -69,7 +69,7 @@ private extension Calendar {

}

fileprivate let colorAssortment: [Color] = [.red, .green, .blue, .gray, .orange, .yellow]
fileprivate let colorAssortment: [Color] = [.turquoise, .forestGreen, .darkPink, .darkRed, .lightBlue, .salmon, .military]

private extension Color {

Expand All @@ -79,3 +79,23 @@ private extension Color {
}

}

private extension Color {

static let turquoise = Color(red: 24, green: 147, blue: 120)
static let forestGreen = Color(red: 22, green: 128, blue: 83)
static let darkPink = Color(red: 179, green: 102, blue: 159)
static let darkRed = Color(red: 185, green: 22, blue: 77)
static let lightBlue = Color(red: 72, green: 147, blue: 175)
static let salmon = Color(red: 219, green: 135, blue: 41)
static let military = Color(red: 117, green: 142, blue: 41)

}

fileprivate extension Color {

init(red: Int, green: Int, blue: Int) {
self.init(red: Double(red)/255, green: Double(green)/255, blue: Double(blue)/255)
}

}
Loading

0 comments on commit 8716d40

Please sign in to comment.