fix: pick server scene Dark Mode

This commit is contained in:
sunxiaojian 2021-04-25 00:44:38 -07:00
parent 078c89adc7
commit 00794a259a
8 changed files with 65 additions and 11 deletions

View File

@ -34,7 +34,7 @@ extension CategoryPickerSection {
cell.categoryView.titleLabel.textColor = .white
}
} else {
cell.categoryView.bgView.backgroundColor = Asset.Colors.Background.systemBackground.color
cell.categoryView.bgView.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color
cell.categoryView.bgView.applyShadow(color: Asset.Colors.brandBlue.color, alpha: 0, x: 0, y: 0, blur: 0.0)
if case .all = item {
cell.categoryView.titleLabel.textColor = Asset.Colors.brandBlue.color

View File

@ -84,6 +84,7 @@ internal enum Asset {
internal static let bar = ColorAsset(name: "Colors/Slider/bar")
}
internal enum TextField {
internal static let background = ColorAsset(name: "Colors/TextField/background")
internal static let highlight = ColorAsset(name: "Colors/TextField/highlight")
internal static let invalid = ColorAsset(name: "Colors/TextField/invalid")
internal static let valid = ColorAsset(name: "Colors/TextField/valid")

View File

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.600",
"blue" : "213",
"green" : "212",
"red" : "212"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.240",
"blue" : "128",
"green" : "118",
"red" : "118"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -27,7 +27,7 @@ class PickServerCell: UITableViewCell {
let containerView: UIView = {
let view = UIView()
view.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 10, right: 16)
view.backgroundColor = Asset.Colors.Background.systemBackground.color
view.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

View File

@ -17,7 +17,7 @@ class PickServerSearchCell: UITableViewCell {
private var bgView: UIView = {
let view = UIView()
view.backgroundColor = Asset.Colors.Background.systemBackground.color
view.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.maskedCorners = [
.layerMinXMinYCorner,
@ -30,7 +30,7 @@ class PickServerSearchCell: UITableViewCell {
private var textFieldBgView: UIView = {
let view = UIView()
view.backgroundColor = Asset.Colors.Background.secondarySystemBackground.color.withAlphaComponent(0.6)
view.backgroundColor = Asset.Colors.TextField.background.color
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.masksToBounds = true
view.layer.cornerRadius = 6

View File

@ -48,7 +48,7 @@ extension PickServerCategoryView {
addSubview(bgView)
addSubview(titleLabel)
bgView.backgroundColor = Asset.Colors.Background.systemBackground.color
bgView.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color
NSLayoutConstraint.activate([
bgView.leadingAnchor.constraint(equalTo: self.leadingAnchor),

View File

@ -20,8 +20,7 @@ extension OnboardingViewControllerAppearance {
static var viewBottomPaddingHeight: CGFloat { return 11 }
func setupOnboardingAppearance() {
overrideUserInterfaceStyle = .light
view.backgroundColor = Asset.Colors.Background.onboardingBackground.color
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
setupNavigationBarAppearance()
@ -43,7 +42,7 @@ extension OnboardingViewControllerAppearance {
func setupNavigationBarBackgroundView() {
let navigationBarBackgroundView: UIView = {
let view = UIView()
view.backgroundColor = Asset.Colors.Background.onboardingBackground.color
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
return view
}()

View File

@ -38,9 +38,8 @@ extension PrimaryActionButton {
private func _init() {
titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold))
setTitleColor(.white, for: .normal)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.normal.color), for: .normal)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.normal.color.withAlphaComponent(0.5)), for: .highlighted)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.disabled.color), for: .disabled)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color), for: .normal)
setupButtonBackground()
applyCornerRadius(radius: 10)
}
@ -68,4 +67,21 @@ extension PrimaryActionButton {
isEnabled = true
self.setTitle(originalButtonTitle, for: .disabled)
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
setupButtonBackground()
}
func setupButtonBackground() {
if UIScreen.main.traitCollection.userInterfaceStyle == .light {
setTitleColor(.white, for: .disabled)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.normal.color.withAlphaComponent(0.5)), for: .highlighted)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.disabled.color), for: .disabled)
} else {
setTitleColor(UIColor.white.withAlphaComponent(0.5), for: .disabled)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color.withAlphaComponent(0.5)), for: .highlighted)
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color.withAlphaComponent(0.5)), for: .disabled)
}
}
}