From 7a0ceb8fc4573381a8c1e716c365774a96032b5d Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 6 Jul 2021 19:32:11 +0800 Subject: [PATCH] fix: timeline gap not using theme color issue --- .../xcschemes/xcschememanagement.plist | 4 ++-- .../Share/View/Decoration/SawToothView.swift | 19 +++++++++++++++++-- .../TimelineLoaderTableViewCell.swift | 16 +++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index ecde1bcc..2fe36047 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ CoreDataStack.xcscheme_^#shared#^_ orderHint - 20 + 27 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -37,7 +37,7 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 21 + 26 SuppressBuildableAutocreation diff --git a/Mastodon/Scene/Share/View/Decoration/SawToothView.swift b/Mastodon/Scene/Share/View/Decoration/SawToothView.swift index 8f41abbb..94dab47f 100644 --- a/Mastodon/Scene/Share/View/Decoration/SawToothView.swift +++ b/Mastodon/Scene/Share/View/Decoration/SawToothView.swift @@ -7,10 +7,13 @@ import Foundation import UIKit +import Combine final class SawToothView: UIView { static let widthUint = 8 + var disposeBag = Set() + override init(frame: CGRect) { super.init(frame: frame) _init() @@ -22,7 +25,19 @@ final class SawToothView: UIView { } func _init() { - backgroundColor = Asset.Colors.Background.secondarySystemBackground.color + setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) + ThemeService.shared.currentTheme + .receive(on: RunLoop.main) + .sink { [weak self] theme in + guard let self = self else { return } + self.setupBackgroundColor(theme: theme) + } + .store(in: &disposeBag) + } + + private func setupBackgroundColor(theme: Theme) { + backgroundColor = theme.secondarySystemBackgroundColor + setNeedsDisplay() } override func draw(_ rect: CGRect) { @@ -37,7 +52,7 @@ final class SawToothView: UIView { } bezierPath.addLine(to: CGPoint(x: 0, y: bottomY)) bezierPath.close() - Asset.Colors.Background.systemBackground.color.setFill() + ThemeService.shared.currentTheme.value.systemBackgroundColor.setFill() bezierPath.fill() bezierPath.lineWidth = 0 bezierPath.stroke() diff --git a/Mastodon/Scene/Share/View/TableviewCell/TimelineLoaderTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/TimelineLoaderTableViewCell.swift index 271a08a6..b18314df 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/TimelineLoaderTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/TimelineLoaderTableViewCell.swift @@ -16,13 +16,14 @@ class TimelineLoaderTableViewCell: UITableViewCell { static let labelFont = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .medium)) var disposeBag = Set() + + private var _disposeBag = Set() let stackView = UIStackView() let loadMoreButton: UIButton = { let button = HighlightDimmableButton() button.titleLabel?.font = TimelineLoaderTableViewCell.labelFont - button.backgroundColor = Asset.Colors.Background.systemBackground.color button.setTitleColor(Asset.Colors.brandBlue.color, for: .normal) button.setTitle(L10n.Common.Controls.Timeline.Loader.loadMissingPosts, for: .normal) button.setTitle("", for: .disabled) @@ -114,6 +115,19 @@ class TimelineLoaderTableViewCell: UITableViewCell { loadMoreButton.isHidden = true loadMoreLabel.isHidden = true activityIndicatorView.isHidden = true + + setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) + ThemeService.shared.currentTheme + .receive(on: RunLoop.main) + .sink { [weak self] theme in + guard let self = self else { return } + self.setupBackgroundColor(theme: theme) + } + .store(in: &_disposeBag) + } + + private func setupBackgroundColor(theme: Theme) { + loadMoreButton.backgroundColor = theme.systemBackgroundColor } }