Making project ready with minimum deployment target >= 13.0 (#100)

* Making project ready with minimum deployment target >= 13.0

* Update .github/workflows/main.yml

Co-authored-by: Levin Li <linfel@microsoft.com>
This commit is contained in:
Levin Li 2021-03-11 13:57:07 +08:00 коммит произвёл GitHub
Родитель 9d4bcc781f
Коммит c370cb4f90
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 110 добавлений и 90 удалений

13
.github/workflows/main.yml поставляемый
Просмотреть файл

@ -1,6 +1,12 @@
name: CI
on: [push]
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
@ -9,10 +15,7 @@ jobs:
steps:
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_11.4.1.app
- name: Install SwiftLint
run: brew install swiftlint
run: sudo xcode-select -s /Applications/Xcode_12.4.app
- uses: actions/checkout@v1

Просмотреть файл

@ -29,8 +29,10 @@
}];
[self setNeedsLayout];
[self setNeedsDisplay];
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
[self dm_updateDynamicColors];
[self dm_updateDynamicImages];
#endif
}
// MARK: - Legacy Support

Просмотреть файл

@ -10,12 +10,13 @@ extension UIButton {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
[UIControl.State.normal, .highlighted, .disabled, .selected, .focused].forEach { state in
if let color = titleColor(for: state)?.copy() as? DynamicColor {
setTitleColor(color, for: state)
[UIControl.State.normal, .highlighted, .disabled, .selected, .focused].forEach { state in
if let color = titleColor(for: state)?.copy() as? DynamicColor {
setTitleColor(color, for: state)
}
}
}
}

Просмотреть файл

@ -10,11 +10,12 @@ extension UINavigationBar {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicBarTintColor = barTintColor?.copy() as? DynamicColor {
barTintColor = dynamicBarTintColor
if let dynamicBarTintColor = barTintColor?.copy() as? DynamicColor {
barTintColor = dynamicBarTintColor
}
}
}
}

Просмотреть файл

@ -10,14 +10,15 @@ extension UIPageControl {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicPageIndicatorTintColor = pageIndicatorTintColor?.copy() as? DynamicColor {
pageIndicatorTintColor = dynamicPageIndicatorTintColor
}
if let dynamicCurrentPageIndicatorTintColor = currentPageIndicatorTintColor?.copy() as? DynamicColor {
currentPageIndicatorTintColor = dynamicCurrentPageIndicatorTintColor
if let dynamicPageIndicatorTintColor = pageIndicatorTintColor?.copy() as? DynamicColor {
pageIndicatorTintColor = dynamicPageIndicatorTintColor
}
if let dynamicCurrentPageIndicatorTintColor = currentPageIndicatorTintColor?.copy() as? DynamicColor {
currentPageIndicatorTintColor = dynamicCurrentPageIndicatorTintColor
}
}
}
}

Просмотреть файл

@ -10,14 +10,15 @@ extension UIProgressView {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicProgressTintColor = progressTintColor?.copy() as? DynamicColor {
progressTintColor = dynamicProgressTintColor
}
if let dynamicTrackTintColor = trackTintColor?.copy() as? DynamicColor {
trackTintColor = dynamicTrackTintColor
if let dynamicProgressTintColor = progressTintColor?.copy() as? DynamicColor {
progressTintColor = dynamicProgressTintColor
}
if let dynamicTrackTintColor = trackTintColor?.copy() as? DynamicColor {
trackTintColor = dynamicTrackTintColor
}
}
}
}

Просмотреть файл

@ -10,16 +10,17 @@ extension UIScrollView {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
indicatorStyle = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .white
}
else {
return .default
}
}()
indicatorStyle = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .white
}
else {
return .default
}
}()
}
}
}

Просмотреть файл

@ -10,14 +10,15 @@ extension UISlider {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicMinimumTrackTintColor = minimumTrackTintColor?.copy() as? DynamicColor {
minimumTrackTintColor = dynamicMinimumTrackTintColor
}
if let dynamicMaximumTrackTintColor = maximumTrackTintColor?.copy() as? DynamicColor {
maximumTrackTintColor = dynamicMaximumTrackTintColor
if let dynamicMinimumTrackTintColor = minimumTrackTintColor?.copy() as? DynamicColor {
minimumTrackTintColor = dynamicMinimumTrackTintColor
}
if let dynamicMaximumTrackTintColor = maximumTrackTintColor?.copy() as? DynamicColor {
maximumTrackTintColor = dynamicMaximumTrackTintColor
}
}
}
}

Просмотреть файл

@ -10,14 +10,15 @@ extension UITableView {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicSectionIndexColor = sectionIndexColor?.copy() as? DynamicColor {
sectionIndexColor = dynamicSectionIndexColor
}
if let dynamicSeparatorColor = separatorColor?.copy() as? DynamicColor {
separatorColor = dynamicSeparatorColor
if let dynamicSectionIndexColor = sectionIndexColor?.copy() as? DynamicColor {
sectionIndexColor = dynamicSectionIndexColor
}
if let dynamicSeparatorColor = separatorColor?.copy() as? DynamicColor {
separatorColor = dynamicSeparatorColor
}
}
}
}

Просмотреть файл

@ -10,21 +10,22 @@ extension UITextField {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicTextColor = textColor?.copy() as? DynamicColor {
textColor = dynamicTextColor
}
if let dynamicTextColor = textColor?.copy() as? DynamicColor {
textColor = dynamicTextColor
keyboardAppearance = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .dark
}
else {
return .default
}
}()
}
keyboardAppearance = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .dark
}
else {
return .default
}
}()
}
}

Просмотреть файл

@ -10,16 +10,17 @@ extension UITextView {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
keyboardAppearance = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .dark
}
else {
return .default
}
}()
keyboardAppearance = {
if DMTraitCollection.override.userInterfaceStyle == .dark {
return .dark
}
else {
return .default
}
}()
}
}
}

Просмотреть файл

@ -10,11 +10,12 @@ extension UIToolbar {
if #available(iOS 13.0, *) {
return
}
else {
dm_updateDynamicColors()
dm_updateDynamicColors()
if let dynamicBarTintColor = barTintColor?.copy() as? DynamicColor {
barTintColor = dynamicBarTintColor
if let dynamicBarTintColor = barTintColor?.copy() as? DynamicColor {
barTintColor = dynamicBarTintColor
}
}
}
}

Просмотреть файл

@ -5,20 +5,25 @@
extension UIView {
static let swizzleWillMoveToWindowOnce: Void = {
let selector = #selector(willMove(toWindow:))
guard let method = class_getInstanceMethod(UIView.self, selector) else {
assertionFailure(DarkModeManager.messageForSwizzlingFailed(class: UIView.self, selector: selector))
if #available(iOS 13.0, *) {
return
}
let imp = method_getImplementation(method)
class_replaceMethod(UIView.self, selector, imp_implementationWithBlock({ (self: UIView, window: UIWindow?) -> Void in
let oldIMP = unsafeBitCast(imp, to: (@convention(c) (UIView, Selector, UIWindow?) -> Void).self)
oldIMP(self, selector, window)
if window != nil {
self.dm_updateDynamicColors()
self.dm_updateDynamicImages()
else {
let selector = #selector(willMove(toWindow:))
guard let method = class_getInstanceMethod(UIView.self, selector) else {
assertionFailure(DarkModeManager.messageForSwizzlingFailed(class: UIView.self, selector: selector))
return
}
} as @convention(block) (UIView, UIWindow?) -> Void), method_getTypeEncoding(method))
let imp = method_getImplementation(method)
class_replaceMethod(UIView.self, selector, imp_implementationWithBlock({ (self: UIView, window: UIWindow?) -> Void in
let oldIMP = unsafeBitCast(imp, to: (@convention(c) (UIView, Selector, UIWindow?) -> Void).self)
oldIMP(self, selector, window)
if window != nil {
self.dm_updateDynamicColors()
self.dm_updateDynamicImages()
}
} as @convention(block) (UIView, UIWindow?) -> Void), method_getTypeEncoding(method))
}
}()
}