From 42d0d8608f4179e31fc0a0c0a71c993097b8a779 Mon Sep 17 00:00:00 2001 From: Daniel Kloeck Date: Sat, 16 May 2020 14:32:54 +0200 Subject: [PATCH 1/4] fixes #162: Wrong color after switching between dark and light mode --- Cosmos/CosmosView.swift | 16 ++++++++++++++++ Distrib/CosmosDistrib.swift | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Cosmos/CosmosView.swift b/Cosmos/CosmosView.swift index a07e993..aec8f50 100644 --- a/Cosmos/CosmosView.swift +++ b/Cosmos/CosmosView.swift @@ -219,6 +219,22 @@ Shows: ★★★★☆ (123) previousRatingForDidTouchCallback = -123.192 } + /** + + Makes sure that the right colors are used when the user switches between Light and Dark mode + while the app is running + + */ + open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + if #available(iOS 13.0, *) { + if self.traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle { + update() + } + } + } + // MARK: - Accessibility private func updateAccessibility() { diff --git a/Distrib/CosmosDistrib.swift b/Distrib/CosmosDistrib.swift index 33c49f3..49bbfa1 100644 --- a/Distrib/CosmosDistrib.swift +++ b/Distrib/CosmosDistrib.swift @@ -1386,6 +1386,22 @@ Shows: ★★★★☆ (123) previousRatingForDidTouchCallback = -123.192 } + /** + + Makes sure that the right colors are used when the user switches between Light and Dark mode + while the app is running + + */ + open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + if #available(iOS 13.0, *) { + if self.traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle { + update() + } + } + } + // MARK: - Accessibility private func updateAccessibility() { From ff1aa6b2a9a21df28032904da4f8e3eb2b076c00 Mon Sep 17 00:00:00 2001 From: Daniel Kloeck Date: Sat, 16 May 2020 14:33:31 +0200 Subject: [PATCH 2/4] Fixed the storyboard errors in the example project --- Demo/Base.lproj/Main.storyboard | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Demo/Base.lproj/Main.storyboard b/Demo/Base.lproj/Main.storyboard index cd42114..dd34deb 100644 --- a/Demo/Base.lproj/Main.storyboard +++ b/Demo/Base.lproj/Main.storyboard @@ -1,13 +1,9 @@ - - - - + + - - - + @@ -24,19 +20,19 @@ - + - + @@ -46,25 +42,25 @@ - + @@ -99,7 +95,10 @@ - + + + + @@ -128,7 +127,7 @@ - + @@ -218,6 +217,9 @@ + + + @@ -285,6 +287,9 @@ + + + @@ -331,7 +336,7 @@ - + From 8635f4fa034d933e97edd3d2d814bdd7fd572572 Mon Sep 17 00:00:00 2001 From: Daniel Kloeck Date: Sun, 17 May 2020 09:37:15 +0200 Subject: [PATCH 3/4] Revert "Fixed the storyboard errors in the example project" This reverts commit ff1aa6b2a9a21df28032904da4f8e3eb2b076c00. --- Demo/Base.lproj/Main.storyboard | 39 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/Demo/Base.lproj/Main.storyboard b/Demo/Base.lproj/Main.storyboard index dd34deb..cd42114 100644 --- a/Demo/Base.lproj/Main.storyboard +++ b/Demo/Base.lproj/Main.storyboard @@ -1,9 +1,13 @@ - - + + + + - + + + @@ -20,19 +24,19 @@ - + - + @@ -42,25 +46,25 @@ - + @@ -95,10 +99,7 @@ - - - - + @@ -127,7 +128,7 @@ - + @@ -217,9 +218,6 @@ - - - @@ -287,9 +285,6 @@ - - - @@ -336,7 +331,7 @@ - + From bd2e61317c634b8bd7e4f5eb065362972e8ec3c4 Mon Sep 17 00:00:00 2001 From: Evgenii Neumerzhitckii Date: Sat, 23 May 2020 12:23:37 +1000 Subject: [PATCH 4/4] Dark mode update --- CHANGELOG.md | 5 +++++ Cosmos.podspec | 2 +- README.md | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5c830..430f7a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Cosmos version history +## 22.0.0 (2020-05-23) + +* Allow switching between light/dark modes without restarting (https://github.com/evgenyneu/Cosmos/issues/162). + + ## 21.0.0 (2020-01-20) * Set `APPLICATION_EXTENSION_API_ONLY` to `Yes` (https://github.com/evgenyneu/Cosmos/pull/155). diff --git a/Cosmos.podspec b/Cosmos.podspec index 8b5b1d2..5ff2ef4 100644 --- a/Cosmos.podspec +++ b/Cosmos.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Cosmos" - s.version = "21.0.0" + s.version = "22.0.0" s.license = { :type => "MIT" } s.homepage = "https://github.com/evgenyneu/Cosmos" s.summary = "5-star rating control written in Swift" diff --git a/README.md b/README.md index 008779c..0ae5e08 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Simply add [CosmosDistrib.swift](https://github.com/evgenyneu/Cosmos/blob/master #### Setup with Carthage (iOS 8+) -Alternatively, add `github "evgenyneu/Cosmos" ~> 21.0` to your Cartfile and run `carthage update`. +Alternatively, add `github "evgenyneu/Cosmos" ~> 22.0` to your Cartfile and run `carthage update`. #### Setup with CocoaPods (iOS 8+) @@ -48,7 +48,7 @@ If you are using CocoaPods add this text to your Podfile and run `pod install`. use_frameworks! target 'Your target name' - pod 'Cosmos', '~> 21.0' + pod 'Cosmos', '~> 22.0' #### Setup with Swift Package Manager @@ -232,6 +232,7 @@ We would like to thank the following people for their valuable contributions. * [yuravake](https://github.com/yuravake) for adding `passTouchesToSuperview` setting. * [gcharita](https://github.com/gcharita) for adding Swift Package Manager support. * [benpackard](https://github.com/benpackard) for fixing Cosmos when used in a modal screen on iOS 13. +* [dkk](https://github.com/dkk) for the dark mode update.