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/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() { 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.