diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 2eb48b787..2569ef03b 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -351,7 +351,6 @@ DB7A9F912818EAF10016AF98 /* MastodonRegisterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB7A9F902818EAF10016AF98 /* MastodonRegisterView.swift */; }; DB7A9F932818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB7A9F922818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift */; }; DB7F48452620241000796008 /* ProfileHeaderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB7F48442620241000796008 /* ProfileHeaderViewModel.swift */; }; - DB8190C62601FF0400020C08 /* AttachmentContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB8190C52601FF0400020C08 /* AttachmentContainerView.swift */; }; DB848E33282B62A800A302CC /* ReportResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB848E32282B62A800A302CC /* ReportResultView.swift */; }; DB852D1926FAEB6B00FC9D81 /* SidebarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB852D1826FAEB6B00FC9D81 /* SidebarViewController.swift */; }; DB852D1C26FB021500FC9D81 /* RootSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB852D1B26FB021500FC9D81 /* RootSplitViewController.swift */; }; @@ -386,7 +385,6 @@ DB98EB6527B216500082E365 /* ReportResultViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB98EB6427B216500082E365 /* ReportResultViewModel.swift */; }; DB98EB6927B21A7C0082E365 /* ReportResultActionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB98EB6827B21A7C0082E365 /* ReportResultActionTableViewCell.swift */; }; DB98EB6B27B243470082E365 /* SettingsAppearanceTableViewCell+ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB98EB6A27B243470082E365 /* SettingsAppearanceTableViewCell+ViewModel.swift */; }; - DB9A486C26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB9A486B26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift */; }; DB9D6BE925E4F5340051B173 /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB9D6BE825E4F5340051B173 /* SearchViewController.swift */; }; DB9D6BF825E4F5690051B173 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB9D6BF725E4F5690051B173 /* NotificationViewController.swift */; }; DB9D6BFF25E4F5940051B173 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB9D6BFE25E4F5940051B173 /* ProfileViewController.swift */; }; @@ -1041,7 +1039,6 @@ DB7A9F902818EAF10016AF98 /* MastodonRegisterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonRegisterView.swift; sourceTree = ""; }; DB7A9F922818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MastodonServerRulesViewController+Debug.swift"; sourceTree = ""; }; DB7F48442620241000796008 /* ProfileHeaderViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileHeaderViewModel.swift; sourceTree = ""; }; - DB8190C52601FF0400020C08 /* AttachmentContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentContainerView.swift; sourceTree = ""; }; DB848E32282B62A800A302CC /* ReportResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportResultView.swift; sourceTree = ""; }; DB852D1826FAEB6B00FC9D81 /* SidebarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarViewController.swift; sourceTree = ""; }; DB852D1B26FB021500FC9D81 /* RootSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootSplitViewController.swift; sourceTree = ""; }; @@ -1092,7 +1089,6 @@ DB98EB6427B216500082E365 /* ReportResultViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportResultViewModel.swift; sourceTree = ""; }; DB98EB6827B21A7C0082E365 /* ReportResultActionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportResultActionTableViewCell.swift; sourceTree = ""; }; DB98EB6A27B243470082E365 /* SettingsAppearanceTableViewCell+ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SettingsAppearanceTableViewCell+ViewModel.swift"; sourceTree = ""; }; - DB9A486B26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttachmentContainerView+EmptyStateView.swift"; sourceTree = ""; }; DB9D6BE825E4F5340051B173 /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = ""; }; DB9D6BF725E4F5690051B173 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = ""; }; DB9D6BFE25E4F5940051B173 /* ProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; @@ -2170,8 +2166,6 @@ DB55D32225FB4D320002F825 /* View */ = { isa = PBXGroup; children = ( - DB8190C52601FF0400020C08 /* AttachmentContainerView.swift */, - DB9A486B26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift */, DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */, ); path = View; @@ -3719,7 +3713,6 @@ 5B90C45F262599800002E742 /* SettingsToggleTableViewCell.swift in Sources */, 2D694A7425F9EB4E0038ADDC /* ContentWarningOverlayView.swift in Sources */, DB0FCB7827957678006C02E2 /* DataSourceProvider+UITableViewDelegate.swift in Sources */, - DB9A486C26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift in Sources */, 5D0393902612D259007FE196 /* WebViewController.swift in Sources */, DB98EB6227B215EB0082E365 /* ReportResultViewController.swift in Sources */, DB6B74F4272FBAE700C70B6E /* FollowerListViewModel+Diffable.swift in Sources */, @@ -3870,7 +3863,6 @@ DB697DDD278F521D004EF2F7 /* DataSourceFacade.swift in Sources */, DBCC3B30261440A50045B23D /* UITabBarController.swift in Sources */, DB3E6FE42806A5B800B035AE /* DiscoverySection.swift in Sources */, - DB8190C62601FF0400020C08 /* AttachmentContainerView.swift in Sources */, DB697DDB278F4DE3004EF2F7 /* DataSourceProvider+StatusTableViewCellDelegate.swift in Sources */, DB87D4512609CF1E00D12C0D /* ComposeStatusPollOptionAppendEntryCollectionViewCell.swift in Sources */, DBB45B5627B39FC9002DC5A7 /* MediaPreviewVideoViewController.swift in Sources */, diff --git a/Mastodon/Coordinator/SceneCoordinator.swift b/Mastodon/Coordinator/SceneCoordinator.swift index 4455e46d2..60c75226a 100644 --- a/Mastodon/Coordinator/SceneCoordinator.swift +++ b/Mastodon/Coordinator/SceneCoordinator.swift @@ -516,7 +516,7 @@ private extension SceneCoordinator { return nil } let _viewController = SFSafariViewController(url: url) - _viewController.preferredBarTintColor = ThemeService.shared.currentTheme.value.navigationBarBackgroundColor + _viewController.preferredBarTintColor = SystemTheme.navigationBarBackgroundColor _viewController.preferredControlTintColor = Asset.Colors.Brand.blurple.color viewController = _viewController diff --git a/Mastodon/Scene/Account/AccountViewController.swift b/Mastodon/Scene/Account/AccountViewController.swift index 475badab8..119ffa831 100644 --- a/Mastodon/Scene/Account/AccountViewController.swift +++ b/Mastodon/Scene/Account/AccountViewController.swift @@ -83,14 +83,7 @@ extension AccountListViewController { override func viewDidLoad() { super.viewDidLoad() - setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackgroundColor(theme: theme) - } - .store(in: &disposeBag) + setupBackgroundColor() navigationItem.rightBarButtonItem = addBarButtonItem dragIndicatorView.translatesAutoresizingMaskIntoConstraints = false @@ -134,13 +127,13 @@ extension AccountListViewController { .store(in: &disposeBag) } - private func setupBackgroundColor(theme: Theme) { + private func setupBackgroundColor() { let backgroundColor = UIColor { traitCollection in switch traitCollection.userInterfaceLevel { case .elevated where traitCollection.userInterfaceStyle == .dark: - return theme.systemElevatedBackgroundColor + return SystemTheme.systemElevatedBackgroundColor default: - return theme.systemBackgroundColor.withAlphaComponent(0.9) + return .systemBackground.withAlphaComponent(0.9) } } view.backgroundColor = backgroundColor diff --git a/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift b/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift index cd214f2c7..11569cdd3 100644 --- a/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift +++ b/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift @@ -50,14 +50,7 @@ final class AccountListTableViewCell: UITableViewCell { extension AccountListTableViewCell { private func _init() { - backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor - } - .store(in: &_disposeBag) + backgroundColor = .secondarySystemGroupedBackground avatarButton.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(avatarButton) diff --git a/Mastodon/Scene/Account/Cell/AddAccountTableViewCell.swift b/Mastodon/Scene/Account/Cell/AddAccountTableViewCell.swift index bc47aef43..c598ea96f 100644 --- a/Mastodon/Scene/Account/Cell/AddAccountTableViewCell.swift +++ b/Mastodon/Scene/Account/Cell/AddAccountTableViewCell.swift @@ -48,14 +48,7 @@ final class AddAccountTableViewCell: UITableViewCell { extension AddAccountTableViewCell { private func _init() { - backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor - } - .store(in: &_disposeBag) + backgroundColor = .secondarySystemGroupedBackground iconImageView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(iconImageView) diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift index e597fca45..d8c2d8727 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionAppendEntryCollectionViewCell.swift @@ -32,7 +32,7 @@ final class ComposeStatusPollOptionAppendEntryCollectionViewCell: UICollectionVi override var isHighlighted: Bool { didSet { - pollOptionView.roundedBackgroundView.backgroundColor = isHighlighted ? ThemeService.shared.currentTheme.value.tertiarySystemGroupedBackgroundColor.withAlphaComponent(0.6) : ThemeService.shared.currentTheme.value.tertiarySystemGroupedBackgroundColor + pollOptionView.roundedBackgroundView.backgroundColor = isHighlighted ? UIColor.tertiarySystemGroupedBackground.withAlphaComponent(0.6) : .tertiarySystemGroupedBackground pollOptionView.plusCircleImageView.tintColor = isHighlighted ? Asset.Colors.Brand.blurple.color.withAlphaComponent(0.5) : Asset.Colors.Brand.blurple.color } } @@ -85,7 +85,7 @@ extension ComposeStatusPollOptionAppendEntryCollectionViewCell { pollOptionView.optionTextField.isHidden = true pollOptionView.plusCircleImageView.isHidden = false - pollOptionView.roundedBackgroundView.backgroundColor = ThemeService.shared.currentTheme.value.tertiarySystemGroupedBackgroundColor + pollOptionView.roundedBackgroundView.backgroundColor = .tertiarySystemGroupedBackground setupBorderColor() pollOptionView.addGestureRecognizer(singleTagGestureRecognizer) @@ -96,7 +96,7 @@ extension ComposeStatusPollOptionAppendEntryCollectionViewCell { private func setupBorderColor() { pollOptionView.roundedBackgroundView.layer.borderWidth = 1 - pollOptionView.roundedBackgroundView.layer.borderColor = ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor + pollOptionView.roundedBackgroundView.layer.borderColor = SystemTheme.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift index 2bdf49707..0b1d8890d 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusPollOptionCollectionViewCell.swift @@ -87,9 +87,9 @@ extension ComposeStatusPollOptionCollectionViewCell { pollOptionView.optionPercentageLabel.isHidden = true pollOptionView.optionTextField.text = nil - pollOptionView.roundedBackgroundView.backgroundColor = ThemeService.shared.currentTheme.value.tertiarySystemGroupedBackgroundColor + pollOptionView.roundedBackgroundView.backgroundColor = .tertiarySystemGroupedBackground pollOptionView.checkmarkBackgroundView.backgroundColor = UIColor(dynamicProvider: { traitCollection in - return traitCollection.userInterfaceStyle == .light ? .white : ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor + return traitCollection.userInterfaceStyle == .light ? .white : SystemTheme.tableViewCellSelectionBackgroundColor }) setupBorderColor() @@ -109,9 +109,9 @@ extension ComposeStatusPollOptionCollectionViewCell { private func setupBorderColor() { pollOptionView.roundedBackgroundView.layer.borderWidth = 1 - pollOptionView.roundedBackgroundView.layer.borderColor = ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor + pollOptionView.roundedBackgroundView.layer.borderColor = SystemTheme.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor - pollOptionView.checkmarkBackgroundView.layer.borderColor = ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor + pollOptionView.checkmarkBackgroundView.layer.borderColor = SystemTheme.tableViewCellSelectionBackgroundColor.withAlphaComponent(0.3).cgColor pollOptionView.checkmarkBackgroundView.layer.borderWidth = 1 } diff --git a/Mastodon/Scene/Compose/View/AttachmentContainerView+EmptyStateView.swift b/Mastodon/Scene/Compose/View/AttachmentContainerView+EmptyStateView.swift deleted file mode 100644 index d976cbff7..000000000 --- a/Mastodon/Scene/Compose/View/AttachmentContainerView+EmptyStateView.swift +++ /dev/null @@ -1,137 +0,0 @@ -// -// AttachmentContainerView+EmptyStateView.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-3-18. -// - -import UIKit -import MastodonAsset -import MastodonCore -import MastodonUI -import MastodonLocalization - -//extension AttachmentContainerView { -// final class EmptyStateView: UIView { -// -// static let photoFillSplitImage = Asset.Connectivity.photoFillSplit.image.withRenderingMode(.alwaysTemplate) -// static let videoSplashImage: UIImage = { -// let image = UIImage(systemName: "video.slash")!.withConfiguration(UIImage.SymbolConfiguration(pointSize: 64)) -// return image -// }() -// -// let imageView: UIImageView = { -// let imageView = UIImageView() -// imageView.tintColor = Asset.Colors.Label.secondary.color -// imageView.image = AttachmentContainerView.EmptyStateView.photoFillSplitImage -// return imageView -// }() -// let label: UILabel = { -// let label = UILabel() -// label.font = .preferredFont(forTextStyle: .body) -// label.textColor = Asset.Colors.Label.secondary.color -// label.textAlignment = .center -// label.text = L10n.Scene.Compose.Attachment.attachmentBroken(L10n.Scene.Compose.Attachment.photo) -// label.numberOfLines = 2 -// label.adjustsFontSizeToFitWidth = true -// label.minimumScaleFactor = 0.3 -// return label -// }() -// -// override init(frame: CGRect) { -// super.init(frame: frame) -// _init() -// } -// -// required init?(coder: NSCoder) { -// super.init(coder: coder) -// _init() -// } -// -// } -//} - -//extension AttachmentContainerView.EmptyStateView { -// private func _init() { -// layer.masksToBounds = true -// layer.cornerRadius = AttachmentContainerView.containerViewCornerRadius -// layer.cornerCurve = .continuous -// backgroundColor = ThemeService.shared.currentTheme.value.systemGroupedBackgroundColor -// -// let stackView = UIStackView() -// stackView.axis = .vertical -// stackView.alignment = .center -// stackView.translatesAutoresizingMaskIntoConstraints = false -// addSubview(stackView) -// NSLayoutConstraint.activate([ -// stackView.topAnchor.constraint(equalTo: topAnchor), -// stackView.leadingAnchor.constraint(equalTo: leadingAnchor), -// stackView.trailingAnchor.constraint(equalTo: trailingAnchor), -// stackView.bottomAnchor.constraint(equalTo: bottomAnchor), -// ]) -// let topPaddingView = UIView() -// let middlePaddingView = UIView() -// let bottomPaddingView = UIView() -// -// topPaddingView.translatesAutoresizingMaskIntoConstraints = false -// stackView.addArrangedSubview(topPaddingView) -// imageView.translatesAutoresizingMaskIntoConstraints = false -// stackView.addArrangedSubview(imageView) -// NSLayoutConstraint.activate([ -// imageView.widthAnchor.constraint(equalToConstant: 92).priority(.defaultHigh), -// imageView.heightAnchor.constraint(equalToConstant: 76).priority(.defaultHigh), -// ]) -// imageView.setContentHuggingPriority(.required - 1, for: .vertical) -// middlePaddingView.translatesAutoresizingMaskIntoConstraints = false -// stackView.addArrangedSubview(middlePaddingView) -// stackView.addArrangedSubview(label) -// bottomPaddingView.translatesAutoresizingMaskIntoConstraints = false -// stackView.addArrangedSubview(bottomPaddingView) -// NSLayoutConstraint.activate([ -// topPaddingView.heightAnchor.constraint(equalTo: middlePaddingView.heightAnchor, multiplier: 1.5), -// bottomPaddingView.heightAnchor.constraint(equalTo: middlePaddingView.heightAnchor, multiplier: 1.5), -// ]) -// } -//} - -//#if canImport(SwiftUI) && DEBUG -//import SwiftUI -// -//struct AttachmentContainerView_EmptyStateView_Previews: PreviewProvider { -// -// static var previews: some View { -// Group { -// UIViewPreview(width: 375) { -// let emptyStateView = AttachmentContainerView.EmptyStateView() -// NSLayoutConstraint.activate([ -// emptyStateView.heightAnchor.constraint(equalToConstant: 205) -// ]) -// return emptyStateView -// } -// .previewLayout(.fixed(width: 375, height: 205)) -// UIViewPreview(width: 375) { -// let emptyStateView = AttachmentContainerView.EmptyStateView() -// NSLayoutConstraint.activate([ -// emptyStateView.heightAnchor.constraint(equalToConstant: 205) -// ]) -// return emptyStateView -// } -// .preferredColorScheme(.dark) -// .previewLayout(.fixed(width: 375, height: 205)) -// UIViewPreview(width: 375) { -// let emptyStateView = AttachmentContainerView.EmptyStateView() -// emptyStateView.imageView.image = AttachmentContainerView.EmptyStateView.videoSplashImage -// emptyStateView.label.text = L10n.Scene.Compose.Attachment.attachmentBroken(L10n.Scene.Compose.Attachment.video) -// -// NSLayoutConstraint.activate([ -// emptyStateView.heightAnchor.constraint(equalToConstant: 205) -// ]) -// return emptyStateView -// } -// .previewLayout(.fixed(width: 375, height: 205)) -// } -// } -// -//} -// -//#endif diff --git a/Mastodon/Scene/Compose/View/AttachmentContainerView.swift b/Mastodon/Scene/Compose/View/AttachmentContainerView.swift deleted file mode 100644 index 4e8fe4e7c..000000000 --- a/Mastodon/Scene/Compose/View/AttachmentContainerView.swift +++ /dev/null @@ -1,177 +0,0 @@ -// -// AttachmentContainerView.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-3-17. -// - -import UIKit -import SwiftUI -import MastodonUI - -//final class AttachmentContainerView: UIView { -// -// static let containerViewCornerRadius: CGFloat = 4 -// -// var descriptionBackgroundViewFrameObservation: NSKeyValueObservation? -// -// let activityIndicatorView: UIActivityIndicatorView = { -// let activityIndicatorView = UIActivityIndicatorView(style: .large) -// activityIndicatorView.color = UIColor.white.withAlphaComponent(0.8) -// return activityIndicatorView -// }() -// -// let previewImageView: UIImageView = { -// let imageView = UIImageView() -// imageView.contentMode = .scaleAspectFill -// imageView.layer.cornerRadius = AttachmentContainerView.containerViewCornerRadius -// imageView.layer.cornerCurve = .continuous -// imageView.layer.masksToBounds = true -// return imageView -// }() -// -// let emptyStateView = AttachmentContainerView.EmptyStateView() -// let descriptionBackgroundView: UIView = { -// let view = UIView() -// view.layer.masksToBounds = true -// view.layer.cornerRadius = AttachmentContainerView.containerViewCornerRadius -// view.layer.cornerCurve = .continuous -// view.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner] -// view.layoutMargins = UIEdgeInsets(top: 0, left: 8, bottom: 5, right: 8) -// return view -// }() -// let descriptionBackgroundGradientLayer: CAGradientLayer = { -// let gradientLayer = CAGradientLayer() -// gradientLayer.colors = [UIColor.black.withAlphaComponent(0.0).cgColor, UIColor.black.withAlphaComponent(0.69).cgColor] -// gradientLayer.locations = [0.0, 1.0] -// gradientLayer.startPoint = CGPoint(x: 0.5, y: 0) -// gradientLayer.endPoint = CGPoint(x: 0.5, y: 1) -// gradientLayer.frame = CGRect(x: 0, y: 0, width: 100, height: 100) -// return gradientLayer -// }() -// let descriptionTextView: UITextView = { -// let textView = UITextView() -// textView.showsVerticalScrollIndicator = false -// textView.backgroundColor = .clear -// textView.textColor = .white -// textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15), maximumPointSize: 20) -// textView.placeholder = L10n.Scene.Compose.Attachment.descriptionPhoto -// textView.placeholderColor = UIColor.white.withAlphaComponent(0.6) // force white with alpha for Light/Dark mode -// textView.returnKeyType = .done -// return textView -// }() -// -// private(set) lazy var contentView = AttachmentView(viewModel: viewModel) -// public var viewModel: AttachmentView.ViewModel! -// -// override init(frame: CGRect) { -// super.init(frame: frame) -// _init() -// } -// -// required init?(coder: NSCoder) { -// super.init(coder: coder) -// _init() -// } -// -//} - -//extension AttachmentContainerView { -// -// private func _init() { -// let hostingViewController = UIHostingController(rootView: contentView) -// hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false -// addSubview(hostingViewController.view) -// NSLayoutConstraint.activate([ -// hostingViewController.view.topAnchor.constraint(equalTo: topAnchor), -// hostingViewController.view.leadingAnchor.constraint(equalTo: leadingAnchor), -// hostingViewController.view.trailingAnchor.constraint(equalTo: trailingAnchor), -// hostingViewController.view.bottomAnchor.constraint(equalTo: bottomAnchor), -// ]) -// -// previewImageView.translatesAutoresizingMaskIntoConstraints = false -// addSubview(previewImageView) -// NSLayoutConstraint.activate([ -// previewImageView.topAnchor.constraint(equalTo: topAnchor), -// previewImageView.leadingAnchor.constraint(equalTo: leadingAnchor), -// previewImageView.trailingAnchor.constraint(equalTo: trailingAnchor), -// previewImageView.bottomAnchor.constraint(equalTo: bottomAnchor), -// ]) -// -// descriptionBackgroundView.translatesAutoresizingMaskIntoConstraints = false -// addSubview(descriptionBackgroundView) -// NSLayoutConstraint.activate([ -// descriptionBackgroundView.leadingAnchor.constraint(equalTo: leadingAnchor), -// descriptionBackgroundView.trailingAnchor.constraint(equalTo: trailingAnchor), -// descriptionBackgroundView.bottomAnchor.constraint(equalTo: bottomAnchor), -// descriptionBackgroundView.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.3), -// ]) -// descriptionBackgroundView.layer.addSublayer(descriptionBackgroundGradientLayer) -// descriptionBackgroundViewFrameObservation = descriptionBackgroundView.observe(\.bounds, options: [.initial, .new]) { [weak self] _, _ in -// guard let self = self else { return } -// self.descriptionBackgroundGradientLayer.frame = self.descriptionBackgroundView.bounds -// } -// -// descriptionTextView.translatesAutoresizingMaskIntoConstraints = false -// descriptionBackgroundView.addSubview(descriptionTextView) -// NSLayoutConstraint.activate([ -// descriptionTextView.leadingAnchor.constraint(equalTo: descriptionBackgroundView.layoutMarginsGuide.leadingAnchor), -// descriptionTextView.trailingAnchor.constraint(equalTo: descriptionBackgroundView.layoutMarginsGuide.trailingAnchor), -// descriptionBackgroundView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: descriptionTextView.bottomAnchor), -// descriptionTextView.heightAnchor.constraint(lessThanOrEqualToConstant: 36), -// ]) -// -// emptyStateView.translatesAutoresizingMaskIntoConstraints = false -// addSubview(emptyStateView) -// NSLayoutConstraint.activate([ -// emptyStateView.topAnchor.constraint(equalTo: topAnchor), -// emptyStateView.leadingAnchor.constraint(equalTo: leadingAnchor), -// emptyStateView.trailingAnchor.constraint(equalTo: trailingAnchor), -// emptyStateView.bottomAnchor.constraint(equalTo: bottomAnchor), -// ]) -// -// activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false -// addSubview(activityIndicatorView) -// NSLayoutConstraint.activate([ -// activityIndicatorView.centerXAnchor.constraint(equalTo: previewImageView.centerXAnchor), -// activityIndicatorView.centerYAnchor.constraint(equalTo: previewImageView.centerYAnchor), -// ]) -// -// setupBroader() -// -// emptyStateView.isHidden = true -// activityIndicatorView.hidesWhenStopped = true -// activityIndicatorView.startAnimating() -// -// descriptionTextView.delegate = self -// } -// -//// override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { -// super.traitCollectionDidChange(previousTraitCollection) -// -// setupBroader() -// } -// -//} -// -//extension AttachmentContainerView { -// -// private func setupBroader() { -// emptyStateView.layer.borderWidth = 1 -// emptyStateView.layer.borderColor = traitCollection.userInterfaceStyle == .dark ? ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor.cgColor : nil -// } -// -//} - -//// MARK: - UITextViewDelegate -//extension AttachmentContainerView: UITextViewDelegate { -// func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { -// // let keyboard dismiss when input description with "done" type return key -// if textView === descriptionTextView, text == "\n" { -// textView.resignFirstResponder() -// return false -// } -// -// return true -// } -//} diff --git a/Mastodon/Scene/Compose/View/StatusContentWarningEditorView.swift b/Mastodon/Scene/Compose/View/StatusContentWarningEditorView.swift index 80dd04d37..7030d0008 100644 --- a/Mastodon/Scene/Compose/View/StatusContentWarningEditorView.swift +++ b/Mastodon/Scene/Compose/View/StatusContentWarningEditorView.swift @@ -17,7 +17,7 @@ final class StatusContentWarningEditorView: UIView { // default hidden let containerBackgroundView: UIView = { let view = UIView() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor + view.backgroundColor = .secondarySystemBackground return view }() diff --git a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift index 6e28bbd18..ba2767f6b 100644 --- a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift +++ b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift @@ -37,14 +37,7 @@ extension DiscoveryCommunityViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Discovery/DiscoveryViewController.swift b/Mastodon/Scene/Discovery/DiscoveryViewController.swift index 027f1c216..9e9707d7d 100644 --- a/Mastodon/Scene/Discovery/DiscoveryViewController.swift +++ b/Mastodon/Scene/Discovery/DiscoveryViewController.swift @@ -80,14 +80,7 @@ extension DiscoveryViewController { public override func viewDidLoad() { super.viewDidLoad() - setupAppearance(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupAppearance(theme: theme) - } - .store(in: &disposeBag) + setupAppearance() dataSource = viewModel addBar( @@ -116,9 +109,9 @@ extension DiscoveryViewController { extension DiscoveryViewController { - private func setupAppearance(theme: Theme) { - view.backgroundColor = theme.secondarySystemBackgroundColor - buttonBarBackgroundView.backgroundColor = theme.systemBackgroundColor + private func setupAppearance() { + view.backgroundColor = .secondarySystemBackground + buttonBarBackgroundView.backgroundColor = .systemBackground } } diff --git a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift index 30865d1b5..952ba4937 100644 --- a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift +++ b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift @@ -37,14 +37,7 @@ extension DiscoveryForYouViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift index 304ea0e1c..4aa088c01 100644 --- a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift +++ b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift @@ -39,14 +39,7 @@ extension DiscoveryHashtagsViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift index 0d4331ddc..9f0e9bb03 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift @@ -37,14 +37,7 @@ extension DiscoveryNewsViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift index 6e1aa124d..ddf0997c0 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift @@ -38,14 +38,7 @@ extension DiscoveryPostsViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift index 65943d7d3..4f53f0f55 100644 --- a/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift +++ b/Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift @@ -53,14 +53,7 @@ extension DiscoveryIntroBannerView { private func _init() { preservesSuperviewLayoutMargins = true - setupAppearance(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupAppearance(theme: theme) - } - .store(in: &_disposeBag) + backgroundColor = .systemBackground closeButton.translatesAutoresizingMaskIntoConstraints = false addSubview(closeButton) @@ -89,11 +82,3 @@ extension DiscoveryIntroBannerView { delegate?.discoveryIntroBannerView(self, closeButtonDidPressed: sender) } } - -extension DiscoveryIntroBannerView { - - private func setupAppearance(theme: Theme) { - backgroundColor = theme.systemBackgroundColor - } - -} diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift index a387b99ea..5d88e9b43 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift @@ -70,14 +70,7 @@ extension HashtagTimelineViewController { titleView.update(title: _title, subtitle: nil) navigationItem.titleView = titleView - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground navigationItem.rightBarButtonItem = composeBarButtonItem composeBarButtonItem.target = self diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift index 4673f0b9f..11006ed9b 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift @@ -48,7 +48,7 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media let settingBarButtonItem: UIBarButtonItem = { let barButtonItem = UIBarButtonItem() - barButtonItem.tintColor = ThemeService.tintColor + barButtonItem.tintColor = SystemTheme.tintColor barButtonItem.image = Asset.ObjectsAndTools.gear.image.withRenderingMode(.alwaysTemplate) barButtonItem.accessibilityLabel = L10n.Common.Controls.Actions.settings return barButtonItem @@ -80,14 +80,8 @@ extension HomeTimelineViewController { super.viewDidLoad() title = L10n.Scene.HomeTimeline.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground + viewModel.$displaySettingBarButtonItem .receive(on: DispatchQueue.main) .sink { [weak self] displaySettingBarButtonItem in diff --git a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift index bce1ccf7a..41c044856 100644 --- a/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift +++ b/Mastodon/Scene/Notification/Cell/NotificationTableViewCell.swift @@ -64,13 +64,7 @@ extension NotificationTableViewCell { separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)).priority(.required - 1), ]) - notificationView.quoteBackgroundView.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .sink { [weak self] theme in - guard let self = self else { return } - self.notificationView.quoteBackgroundView.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &_disposeBag) + notificationView.quoteBackgroundView.backgroundColor = .secondarySystemBackground notificationView.delegate = self } diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 502e04b7c..a266049bd 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -47,14 +47,7 @@ extension NotificationViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground setupSegmentedControl(scopes: viewModel.scopes) pageSegmentedControl.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift index 1a1a1ac6c..8881f894e 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift @@ -43,14 +43,7 @@ extension ProfileAboutViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.systemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .systemBackground collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift index e4666ad28..47596e5ce 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift @@ -44,14 +44,7 @@ extension BookmarkViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground navigationItem.titleView = titleView titleView.update(title: L10n.Scene.Bookmark.title, subtitle: nil) diff --git a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift index c181f4e95..59de6d880 100644 --- a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift +++ b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift @@ -38,14 +38,7 @@ extension FamiliarFollowersViewController { title = L10n.Scene.Familiarfollowers.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift index 9c55f988f..1c557516c 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift @@ -47,14 +47,7 @@ extension FavoriteViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground navigationItem.titleView = titleView titleView.update(title: L10n.Scene.Favorite.title, subtitle: nil) diff --git a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift index 7839832bf..4edec01d9 100644 --- a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift +++ b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewController.swift @@ -43,14 +43,7 @@ extension FollowedTagsViewController { navigationItem.titleView = titleView - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift index 501267813..733bd1699 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift @@ -42,14 +42,7 @@ extension FollowerListViewController { title = L10n.Scene.Follower.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift index c80b3169b..b7fe7e0a2 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift @@ -42,14 +42,7 @@ extension FollowingListViewController { title = L10n.Scene.Following.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift index d912173be..bc3c1dfa8 100644 --- a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift +++ b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift @@ -91,14 +91,7 @@ extension ProfileHeaderViewController { view.setContentHuggingPriority(.required - 1, for: .vertical) - view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.systemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .systemBackground // profileHeaderView.preservesSuperviewLayoutMargins = true profileHeaderView.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift index 7a906c05c..92845fa4c 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift @@ -252,15 +252,7 @@ final class ProfileHeaderView: UIView { extension ProfileHeaderView { private func _init() { - let currentTheme = ThemeService.shared.currentTheme - setColors(from: currentTheme.value) - - currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - self?.setColors(from: theme) - } - .store(in: &_disposeBag) + setColors() // banner bannerContainerView.translatesAutoresizingMaskIntoConstraints = false @@ -469,10 +461,10 @@ extension ProfileHeaderView { updateLayoutMargins() } - private func setColors(from theme: Theme) { - backgroundColor = theme.systemBackgroundColor - avatarButton.backgroundColor = theme.secondarySystemBackgroundColor - avatarImageViewBackgroundView.layer.borderColor = theme.systemBackgroundColor.cgColor + private func setColors() { + backgroundColor = .systemBackground + avatarButton.backgroundColor = .secondarySystemBackground + avatarImageViewBackgroundView.layer.borderColor = UIColor.systemBackground.cgColor } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift index b01b69a1c..9b0e067f9 100644 --- a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift +++ b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift @@ -64,7 +64,7 @@ extension ProfilePagingViewController { override func viewDidLoad() { // configure style before viewDidLoad - settings.style.buttonBarBackgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor + settings.style.buttonBarBackgroundColor = .systemBackground settings.style.buttonBarItemBackgroundColor = .clear settings.style.buttonBarItemsShouldFillAvailableWidth = false // alignment from leading to trailing settings.style.selectedBarHeight = 3 @@ -80,21 +80,12 @@ extension ProfilePagingViewController { super.viewDidLoad() - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.settings.style.buttonBarBackgroundColor = theme.systemBackgroundColor - self.buttonBarView.backgroundColor = self.settings.style.buttonBarBackgroundColor - self.barButtonLayout?.invalidateLayout() - } - .store(in: &disposeBag) - updateBarButtonInsets() if let buttonBarView = self.buttonBarView { buttonBarShadowView.translatesAutoresizingMaskIntoConstraints = false view.insertSubview(buttonBarShadowView, belowSubview: buttonBarView) + buttonBarView.backgroundColor = .systemBackground buttonBarShadowView.pinTo(to: buttonBarView) viewModel.$needsSetupBottomShadow diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 15ef88033..db067f28a 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -168,15 +168,7 @@ extension ProfileViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) - + view.backgroundColor = .secondarySystemBackground let barAppearance = UINavigationBarAppearance() if isModal { barAppearance.configureWithDefaultBackground() diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift index fdb964b30..71261ca52 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift @@ -43,14 +43,7 @@ extension UserTimelineViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift index c9e88484c..c09aa0722 100644 --- a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift @@ -38,14 +38,7 @@ extension FavoritedByViewController { title = L10n.Scene.FavoritedBy.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift index 369128f3c..98c48b4e9 100644 --- a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift @@ -44,14 +44,7 @@ extension RebloggedByViewController { title = L10n.Scene.RebloggedBy.title - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index c41d2c19d..e00ffe584 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -167,14 +167,7 @@ extension MainTabBarController { delegate = self - view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.tabBarBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .systemBackground // seealso: `ThemeService.apply(theme:)` let tabs = Tab.allCases diff --git a/Mastodon/Scene/Root/RootSplitViewController.swift b/Mastodon/Scene/Root/RootSplitViewController.swift index dd8dd3a74..0ec7e9bb7 100644 --- a/Mastodon/Scene/Root/RootSplitViewController.swift +++ b/Mastodon/Scene/Root/RootSplitViewController.swift @@ -87,14 +87,7 @@ extension RootSplitViewController { updateBehavior(size: view.frame.size) - setupBackground(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackground(theme: theme) - } - .store(in: &disposeBag) + view.backgroundColor = .separator } override func viewWillAppear(_ animated: Bool) { @@ -112,13 +105,7 @@ extension RootSplitViewController { override var supportedInterfaceOrientations: UIInterfaceOrientationMask { .portraitOnPhone } - - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - - setupBackground(theme: ThemeService.shared.currentTheme.value) - } - + private func updateBehavior(size: CGSize) { if size.width > 960 { show(.primary) @@ -142,15 +129,6 @@ extension RootSplitViewController { } -extension RootSplitViewController { - - private func setupBackground(theme: Theme) { - // this set column separator line color - view.backgroundColor = theme.separator - } - -} - // MARK: - ContentSplitViewControllerDelegate extension RootSplitViewController: ContentSplitViewControllerDelegate { func contentSplitViewController(_ contentSplitViewController: ContentSplitViewController, sidebarViewController: SidebarViewController, didSelectTab tab: MainTabBarController.Tab) { diff --git a/Mastodon/Scene/Root/Sidebar/SecondaryPlaceholderViewController.swift b/Mastodon/Scene/Root/Sidebar/SecondaryPlaceholderViewController.swift index 6937f1a3f..74fa072b9 100644 --- a/Mastodon/Scene/Root/Sidebar/SecondaryPlaceholderViewController.swift +++ b/Mastodon/Scene/Root/Sidebar/SecondaryPlaceholderViewController.swift @@ -11,27 +11,11 @@ import MastodonCore final class SecondaryPlaceholderViewController: UIViewController { var disposeBag = Set() -} - -extension SecondaryPlaceholderViewController { override func viewDidLoad() { super.viewDidLoad() - setupBackground(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackground(theme: theme) - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground } } - -extension SecondaryPlaceholderViewController { - private func setupBackground(theme: Theme) { - view.backgroundColor = theme.secondarySystemBackgroundColor - } -} diff --git a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift index dab9f1af4..b64139a64 100644 --- a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift +++ b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift @@ -87,14 +87,7 @@ extension SidebarViewController { navigationController?.setNavigationBarHidden(true, animated: false) - setupBackground(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackground(theme: theme) - } - .store(in: &disposeBag) + view.backgroundColor = SystemTheme.sidebarBackgroundColor collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) @@ -145,11 +138,6 @@ extension SidebarViewController { } - private func setupBackground(theme: Theme) { - let color: UIColor = theme.sidebarBackgroundColor - view.backgroundColor = color - } - override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) diff --git a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift index fcd6f817c..fcc934c25 100644 --- a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift +++ b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift @@ -92,7 +92,7 @@ extension SidebarListContentView { guard let item = configuration.item else { return } // configure state - let tintColor = item.isHighlighted ? ThemeService.tintColor.withAlphaComponent(0.5) : ThemeService.tintColor + let tintColor = item.isHighlighted ? SystemTheme.tintColor.withAlphaComponent(0.5) : SystemTheme.tintColor imageView.tintColor = tintColor avatarButton.tintColor = tintColor diff --git a/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift b/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift index 4436459fb..c65a400c1 100644 --- a/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift +++ b/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift @@ -37,15 +37,6 @@ final class TrendCollectionViewCell: UICollectionViewCell { extension TrendCollectionViewCell { private func _init() { - ThemeService.shared.currentTheme - .map { $0.secondarySystemGroupedBackgroundColor } - .sink { [weak self] backgroundColor in - guard let self = self else { return } - self.backgroundColor = backgroundColor - self.setNeedsUpdateConfiguration() - } - .store(in: &_disposeBag) - trendView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(trendView) trendView.pinToParent() @@ -57,9 +48,9 @@ extension TrendCollectionViewCell { var backgroundConfiguration = UIBackgroundConfiguration.listGroupedCell() backgroundConfiguration.backgroundColorTransformer = .init { _ in if state.isHighlighted || state.isSelected { - return ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor + return SystemTheme.tableViewCellSelectionBackgroundColor } - return ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor + return .secondarySystemGroupedBackground } self.backgroundConfiguration = backgroundConfiguration } diff --git a/Mastodon/Scene/Search/Search/SearchViewController.swift b/Mastodon/Scene/Search/Search/SearchViewController.swift index 9f755cf15..0f2034a17 100644 --- a/Mastodon/Scene/Search/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/Search/SearchViewController.swift @@ -54,14 +54,7 @@ extension SearchViewController { override func viewDidLoad() { super.viewDidLoad() - setupAppearance(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupAppearance(theme: theme) - } - .store(in: &disposeBag) + setupAppearance() title = L10n.Scene.Search.title @@ -86,13 +79,13 @@ extension SearchViewController { } extension SearchViewController { - private func setupAppearance(theme: Theme) { - view.backgroundColor = theme.systemGroupedBackgroundColor + private func setupAppearance() { + view.backgroundColor = .systemGroupedBackground // Match the DiscoveryViewController tab color and remove the double separator. let navigationBarAppearance = UINavigationBarAppearance() navigationBarAppearance.configureWithOpaqueBackground() - navigationBarAppearance.backgroundColor = theme.systemBackgroundColor + navigationBarAppearance.backgroundColor = .systemBackground navigationBarAppearance.shadowColor = nil navigationItem.standardAppearance = navigationBarAppearance diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index da9771327..9b1491ed7 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -106,14 +106,7 @@ final class SearchDetailViewController: UIViewController, NeedsDependency { super.viewDidLoad() - 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) + setupBackgroundColor() setupSearchBar() @@ -246,8 +239,8 @@ extension SearchDetailViewController { searchBar.delegate = self } - private func setupBackgroundColor(theme: Theme) { - navigationBarBackgroundView.backgroundColor = theme.navigationBarBackgroundColor + private func setupBackgroundColor() { + navigationBarBackgroundView.backgroundColor = SystemTheme.navigationBarBackgroundColor navigationBar.tintColor = Asset.Colors.Brand.blurple.color } } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell.swift index db315b1d1..8dbedbc28 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell.swift @@ -32,7 +32,7 @@ class SearchHistoryUserCollectionViewCell: UICollectionViewCell { var backgroundConfiguration = UIBackgroundConfiguration.listGroupedCell() backgroundConfiguration.backgroundColorTransformer = .init { _ in if state.isHighlighted || state.isSelected { - return ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor + return SystemTheme.tableViewCellSelectionBackgroundColor } else { return .secondarySystemGroupedBackground } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift index 4269cdda7..b2dc5b8e4 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift @@ -52,7 +52,7 @@ extension SearchHistorySection { } if state.isHighlighted || state.isSelected { - return ThemeService.shared.currentTheme.value.tableViewCellSelectionBackgroundColor + return SystemTheme.tableViewCellSelectionBackgroundColor } return .secondarySystemGroupedBackground } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift index 9dbbe986e..156a25620 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift @@ -36,15 +36,7 @@ extension SearchHistoryViewController { override func viewDidLoad() { super.viewDidLoad() - setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackgroundColor(theme: theme) - } - .store(in: &disposeBag) - + view.backgroundColor = .systemGroupedBackground collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) collectionView.pinToParent() @@ -57,12 +49,6 @@ extension SearchHistoryViewController { } } -extension SearchHistoryViewController { - private func setupBackgroundColor(theme: Theme) { - view.backgroundColor = theme.systemGroupedBackgroundColor - } -} - // MARK: - UICollectionViewDelegate extension SearchHistoryViewController: UICollectionViewDelegate { diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift index 0fa2cd4bb..672c2c863 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift @@ -37,7 +37,7 @@ extension SearchResultViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Asset.Theme.System.systemGroupedBackground.color + view.backgroundColor = .systemGroupedBackground tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) diff --git a/Mastodon/Scene/Settings/SettingsViewController.swift b/Mastodon/Scene/Settings/SettingsViewController.swift index 910317b9f..ab3f2ceb1 100644 --- a/Mastodon/Scene/Settings/SettingsViewController.swift +++ b/Mastodon/Scene/Settings/SettingsViewController.swift @@ -106,7 +106,7 @@ class SettingsViewController: UIViewController, NeedsDependency { tableView.delegate = self tableView.rowHeight = UITableView.automaticDimension tableView.backgroundColor = .clear - tableView.separatorColor = ThemeService.shared.currentTheme.value.separator + tableView.separatorColor = SystemTheme.separator tableView.register(SettingsAppearanceTableViewCell.self, forCellReuseIdentifier: String(describing: SettingsAppearanceTableViewCell.self)) tableView.register(SettingsToggleTableViewCell.self, forCellReuseIdentifier: String(describing: SettingsToggleTableViewCell.self)) @@ -207,14 +207,7 @@ extension SettingsViewController { } private func setupView() { - setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackgroundColor(theme: theme) - } - .store(in: &disposeBag) + setupBackgroundColor() setupNavigation() view.addSubview(tableView) @@ -224,17 +217,17 @@ extension SettingsViewController { updateSectionHeaderStackViewLayout() } - private func setupBackgroundColor(theme: Theme) { + private func setupBackgroundColor() { view.backgroundColor = UIColor(dynamicProvider: { traitCollection in switch traitCollection.userInterfaceLevel { case .elevated where traitCollection.userInterfaceStyle == .dark: - return theme.systemElevatedBackgroundColor + return SystemTheme.systemElevatedBackgroundColor default: - return theme.secondarySystemBackgroundColor + return .secondarySystemBackground } }) - tableView.separatorColor = theme.separator + tableView.separatorColor = SystemTheme.separator } private func setupNavigation() { diff --git a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift index 34d5b3622..7ff0dfb6e 100644 --- a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift +++ b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift @@ -144,18 +144,7 @@ extension ContentWarningOverlayView { addGestureRecognizer(tapGestureRecognizer) configure(style: .media) - 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) { - contentOverlayView.backgroundColor = theme.contentWarningOverlayBackgroundColor + contentOverlayView.backgroundColor = SystemTheme.contentWarningOverlayBackgroundColor } } diff --git a/Mastodon/Scene/Share/View/Content/PollOptionView+Configuration.swift b/Mastodon/Scene/Share/View/Content/PollOptionView+Configuration.swift index 7f4192df5..0e3f07f66 100644 --- a/Mastodon/Scene/Share/View/Content/PollOptionView+Configuration.swift +++ b/Mastodon/Scene/Share/View/Content/PollOptionView+Configuration.swift @@ -21,14 +21,6 @@ extension PollOptionView { viewModel.objects.insert(option) - // background - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.viewModel.roundedBackgroundViewColor = theme.systemElevatedBackgroundColor - } - .store(in: &disposeBag) // metaContent option.publisher(for: \.title) .map { title -> MetaContent? in @@ -103,41 +95,24 @@ extension PollOptionView { } .store(in: &disposeBag) // appearance - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.checkmarkBackgroundView.backgroundColor = UIColor(dynamicProvider: { trailtCollection in - return trailtCollection.userInterfaceStyle == .light ? .white : theme.tableViewCellSelectionBackgroundColor - }) - } - .store(in: &disposeBag) + checkmarkBackgroundView.backgroundColor = UIColor(dynamicProvider: { trailtCollection in + return trailtCollection.userInterfaceStyle == .light ? .white : SystemTheme.tableViewCellSelectionBackgroundColor + }) + } } extension PollOptionView { public func configure(historyPollOption option: StatusEdit.Poll.Option) { // background - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.viewModel.roundedBackgroundViewColor = theme.systemElevatedBackgroundColor - } - .store(in: &disposeBag) + viewModel.roundedBackgroundViewColor = SystemTheme.systemElevatedBackgroundColor // metaContent viewModel.metaContent = PlaintextMetaContent(string: option.title) // show left-hand-side dots, otherwise view looks "incomplete" viewModel.selectState = .off // appearance - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.checkmarkBackgroundView.backgroundColor = UIColor(dynamicProvider: { trailtCollection in - return trailtCollection.userInterfaceStyle == .light ? .white : theme.tableViewCellSelectionBackgroundColor - }) - } - .store(in: &disposeBag) + checkmarkBackgroundView.backgroundColor = UIColor(dynamicProvider: { trailtCollection in + return trailtCollection.userInterfaceStyle == .light ? .white : SystemTheme.tableViewCellSelectionBackgroundColor + }) } } diff --git a/Mastodon/Scene/Share/View/Content/ThreadMetaView.swift b/Mastodon/Scene/Share/View/Content/ThreadMetaView.swift index 8d72d953e..aa35f556b 100644 --- a/Mastodon/Scene/Share/View/Content/ThreadMetaView.swift +++ b/Mastodon/Scene/Share/View/Content/ThreadMetaView.swift @@ -25,8 +25,8 @@ final class ThreadMetaView: UIView { let button = UIButton() button.titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold)) button.setTitle("0 reblog", for: .normal) - button.setTitleColor(ThemeService.tintColor, for: .normal) - button.setTitleColor(ThemeService.tintColor.withAlphaComponent(0.5), for: .highlighted) + button.setTitleColor(SystemTheme.tintColor, for: .normal) + button.setTitleColor(SystemTheme.tintColor.withAlphaComponent(0.5), for: .highlighted) return button }() @@ -34,8 +34,8 @@ final class ThreadMetaView: UIView { let button = UIButton() button.titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold)) button.setTitle("0 favorite", for: .normal) - button.setTitleColor(ThemeService.tintColor, for: .normal) - button.setTitleColor(ThemeService.tintColor.withAlphaComponent(0.5), for: .highlighted) + button.setTitleColor(SystemTheme.tintColor, for: .normal) + button.setTitleColor(SystemTheme.tintColor.withAlphaComponent(0.5), for: .highlighted) return button }() diff --git a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift index 13030122c..8e9573705 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift @@ -26,7 +26,7 @@ final class ThreadReplyLoaderTableViewCell: UITableViewCell { let loadMoreButton: UIButton = { let button = HighlightDimmableButton() button.titleLabel?.font = TimelineLoaderTableViewCell.labelFont - button.setTitleColor(ThemeService.tintColor, for: .normal) + button.setTitleColor(SystemTheme.tintColor, for: .normal) button.setTitle(L10n.Common.Controls.Timeline.Loader.showMoreReplies, for: .normal) return button }() @@ -86,14 +86,7 @@ extension ThreadReplyLoaderTableViewCell { loadMoreButton.addTarget(self, action: #selector(ThreadReplyLoaderTableViewCell.loadMoreButtonDidPressed(_:)), for: .touchUpInside) - 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) + backgroundColor = .systemGroupedBackground } private func resetSeparatorLineLayout() { @@ -124,11 +117,6 @@ extension ThreadReplyLoaderTableViewCell { } } } - - private func setupBackgroundColor(theme: Theme) { - backgroundColor = theme.systemGroupedBackgroundColor - } - } extension ThreadReplyLoaderTableViewCell { diff --git a/Mastodon/Scene/Thread/Edit History/StatusEditHistoryViewController.swift b/Mastodon/Scene/Thread/Edit History/StatusEditHistoryViewController.swift index c58ebc8d6..52dfd3cc2 100644 --- a/Mastodon/Scene/Thread/Edit History/StatusEditHistoryViewController.swift +++ b/Mastodon/Scene/Thread/Edit History/StatusEditHistoryViewController.swift @@ -49,13 +49,13 @@ class StatusEditHistoryViewController: UIViewController { } tableView.dataSource = tableViewDataSource - tableView.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor + tableView.backgroundColor = .secondarySystemBackground self.tableViewDataSource = tableViewDataSource view.addSubview(tableView) - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor + view.backgroundColor = .secondarySystemBackground setupConstraints() title = L10n.Common.Controls.Status.EditHistory.title diff --git a/Mastodon/Scene/Thread/ThreadViewController.swift b/Mastodon/Scene/Thread/ThreadViewController.swift index f8abc4c1f..584f60753 100644 --- a/Mastodon/Scene/Thread/ThreadViewController.swift +++ b/Mastodon/Scene/Thread/ThreadViewController.swift @@ -51,14 +51,7 @@ extension ThreadViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.view.backgroundColor = theme.secondarySystemBackgroundColor - } - .store(in: &disposeBag) + view.backgroundColor = .secondarySystemBackground navigationItem.title = L10n.Scene.Thread.backTitle navigationItem.titleView = titleView diff --git a/Mastodon/Supporting Files/AppDelegate.swift b/Mastodon/Supporting Files/AppDelegate.swift index 2e67532eb..9004ad8cd 100644 --- a/Mastodon/Supporting Files/AppDelegate.swift +++ b/Mastodon/Supporting Files/AppDelegate.swift @@ -21,7 +21,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { AppSecret.default.register() // configure appearance - ThemeService.shared.apply(theme: ThemeService.shared.currentTheme.value) + ThemeService.shared.apply() // configure AudioSession try? AVAudioSession.sharedInstance().setCategory(.ambient) diff --git a/Mastodon/Supporting Files/SceneDelegate.swift b/Mastodon/Supporting Files/SceneDelegate.swift index d844c82db..84d917eaf 100644 --- a/Mastodon/Supporting Files/SceneDelegate.swift +++ b/Mastodon/Supporting Files/SceneDelegate.swift @@ -37,19 +37,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // set tint color window.tintColor = UIColor.label - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .dropFirst() - .sink { [weak self] theme in - guard let self = self else { return } - guard let window = self.window else { return } - window.subviews.forEach { view in - view.removeFromSuperview() - window.addSubview(view) - } - } - .store(in: &disposeBag) - let appContext = AppContext.shared let sceneCoordinator = SceneCoordinator(scene: scene, sceneDelegate: self, appContext: appContext) self.coordinator = sceneCoordinator diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/Contents.json deleted file mode 100644 index 73c00596a..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json deleted file mode 100644 index bc3fb38b9..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json deleted file mode 100644 index 356b35510..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.871", - "green" : "0.847", - "red" : "0.839" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/content.warning.overlay.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/content.warning.overlay.background.colorset/Contents.json deleted file mode 100644 index 7d751f897..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/content.warning.overlay.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.922", - "green" : "0.898", - "red" : "0.867" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.431", - "green" : "0.341", - "red" : "0.310" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/navigation.bar.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/navigation.bar.background.colorset/Contents.json deleted file mode 100644 index e3ffa5a61..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/navigation.bar.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "0.940", - "blue" : "0.976", - "green" : "0.976", - "red" : "0.976" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/profile.field.collection.view.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/profile.field.collection.view.background.colorset/Contents.json deleted file mode 100644 index 5e9b0d486..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/profile.field.collection.view.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "0.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.grouped.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.grouped.system.background.colorset/Contents.json deleted file mode 100644 index ef6c7f7b1..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.grouped.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.996", - "green" : "1.000", - "red" : "0.996" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.system.background.colorset/Contents.json deleted file mode 100644 index 14b5119b8..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/secondary.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.133", - "green" : "0.106", - "red" : "0.098" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/sidebar.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/sidebar.background.colorset/Contents.json deleted file mode 100644 index bc3fb38b9..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/sidebar.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.background.colorset/Contents.json deleted file mode 100644 index 4572c2409..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.996", - "green" : "1.000", - "red" : "0.996" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.216", - "green" : "0.173", - "red" : "0.157" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.elevated.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.elevated.background.colorset/Contents.json deleted file mode 100644 index d47dc714f..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.elevated.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF2", - "green" : "0xED", - "red" : "0xE9" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.216", - "green" : "0.173", - "red" : "0.157" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.grouped.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.grouped.background.colorset/Contents.json deleted file mode 100644 index 14b5119b8..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.133", - "green" : "0.106", - "red" : "0.098" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tab.bar.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tab.bar.background.colorset/Contents.json deleted file mode 100644 index e3ffa5a61..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tab.bar.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "0.940", - "blue" : "0.976", - "green" : "0.976", - "red" : "0.976" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.background.colorset/Contents.json deleted file mode 100644 index e2f09e3c5..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.selection.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.selection.background.colorset/Contents.json deleted file mode 100644 index 7d751f897..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/table.view.cell.selection.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.922", - "green" : "0.898", - "red" : "0.867" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.431", - "green" : "0.341", - "red" : "0.310" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.background.colorset/Contents.json deleted file mode 100644 index 4572c2409..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.996", - "green" : "1.000", - "red" : "0.996" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.216", - "green" : "0.173", - "red" : "0.157" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.grouped.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.grouped.background.colorset/Contents.json deleted file mode 100644 index bc3fb38b9..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/tertiary.system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.263", - "green" : "0.208", - "red" : "0.192" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Contents.json deleted file mode 100644 index 6e965652d..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Contents.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "provides-namespace" : true - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/notification.status.border.color.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/notification.status.border.color.colorset/Contents.json deleted file mode 100644 index c04af0902..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/notification.status.border.color.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.910", - "green" : "0.882", - "red" : "0.851" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.431", - "green" : "0.341", - "red" : "0.310" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/separator.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/separator.colorset/Contents.json deleted file mode 100644 index 8ae75b24c..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/separator.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.839", - "green" : "0.820", - "red" : "0.820" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.431", - "green" : "0.341", - "red" : "0.310" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/tab.bar.item.inactive.icon.color.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/tab.bar.item.inactive.icon.color.colorset/Contents.json deleted file mode 100644 index baf4b4b42..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/tab.bar.item.inactive.icon.color.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.600", - "green" : "0.600", - "red" : "0.600" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.600", - "green" : "0.600", - "red" : "0.600" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/profile.field.collection.view.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/profile.field.collection.view.background.colorset/Contents.json deleted file mode 100644 index ca11ee759..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/profile.field.collection.view.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.118", - "green" : "0.110", - "red" : "0.110" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.grouped.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.grouped.system.background.colorset/Contents.json deleted file mode 100644 index b0a1b74fb..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.grouped.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "254", - "green" : "255", - "red" : "254" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x2D", - "green" : "0x2C", - "red" : "0x2C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.system.background.colorset/Contents.json deleted file mode 100644 index 8fd668a51..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/secondary.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x2D", - "green" : "0x2C", - "red" : "0x2C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.background.colorset/Contents.json deleted file mode 100644 index ab7d95395..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.996", - "green" : "1.000", - "red" : "0.996" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x00", - "green" : "0x00", - "red" : "0x00" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.grouped.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.grouped.background.colorset/Contents.json deleted file mode 100644 index 05051dc50..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.000", - "green" : "0.000", - "red" : "0.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.background.colorset/Contents.json deleted file mode 100644 index c752c3a5c..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.996", - "green" : "1.000", - "red" : "0.996" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.235", - "green" : "0.227", - "red" : "0.227" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.grouped.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.grouped.background.colorset/Contents.json deleted file mode 100644 index 30aadfbcb..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/tertiary.system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.235", - "green" : "0.227", - "red" : "0.227" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/notification.status.border.color.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/notification.status.border.color.colorset/Contents.json deleted file mode 100644 index c04af0902..000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/notification.status.border.color.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.910", - "green" : "0.882", - "red" : "0.851" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.431", - "green" : "0.341", - "red" : "0.310" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift index 8070a1349..8082fb32f 100644 --- a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift +++ b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift @@ -227,45 +227,16 @@ public enum Asset { public static let light = ImageAsset(name: "Settings/light") } public enum Theme { - public enum Mastodon { - public static let composePollRowBackground = ColorAsset(name: "Theme/Mastodon/compose.poll.row.background") - public static let composeToolbarBackground = ColorAsset(name: "Theme/Mastodon/compose.toolbar.background") - public static let contentWarningOverlayBackground = ColorAsset(name: "Theme/Mastodon/content.warning.overlay.background") - public static let navigationBarBackground = ColorAsset(name: "Theme/Mastodon/navigation.bar.background") - public static let profileFieldCollectionViewBackground = ColorAsset(name: "Theme/Mastodon/profile.field.collection.view.background") - public static let secondaryGroupedSystemBackground = ColorAsset(name: "Theme/Mastodon/secondary.grouped.system.background") - public static let secondarySystemBackground = ColorAsset(name: "Theme/Mastodon/secondary.system.background") - public static let sidebarBackground = ColorAsset(name: "Theme/Mastodon/sidebar.background") - public static let systemBackground = ColorAsset(name: "Theme/Mastodon/system.background") - public static let systemElevatedBackground = ColorAsset(name: "Theme/Mastodon/system.elevated.background") - public static let systemGroupedBackground = ColorAsset(name: "Theme/Mastodon/system.grouped.background") - public static let tabBarBackground = ColorAsset(name: "Theme/Mastodon/tab.bar.background") - public static let tableViewCellBackground = ColorAsset(name: "Theme/Mastodon/table.view.cell.background") - public static let tableViewCellSelectionBackground = ColorAsset(name: "Theme/Mastodon/table.view.cell.selection.background") - public static let tertiarySystemBackground = ColorAsset(name: "Theme/Mastodon/tertiary.system.background") - public static let tertiarySystemGroupedBackground = ColorAsset(name: "Theme/Mastodon/tertiary.system.grouped.background") - public static let notificationStatusBorderColor = ColorAsset(name: "Theme/Mastodon/notification.status.border.color") - public static let separator = ColorAsset(name: "Theme/Mastodon/separator") - public static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/Mastodon/tab.bar.item.inactive.icon.color") - } public enum System { public static let composePollRowBackground = ColorAsset(name: "Theme/system/compose.poll.row.background") public static let composeToolbarBackground = ColorAsset(name: "Theme/system/compose.toolbar.background") public static let contentWarningOverlayBackground = ColorAsset(name: "Theme/system/content.warning.overlay.background") public static let navigationBarBackground = ColorAsset(name: "Theme/system/navigation.bar.background") - public static let profileFieldCollectionViewBackground = ColorAsset(name: "Theme/system/profile.field.collection.view.background") - public static let secondaryGroupedSystemBackground = ColorAsset(name: "Theme/system/secondary.grouped.system.background") - public static let secondarySystemBackground = ColorAsset(name: "Theme/system/secondary.system.background") public static let sidebarBackground = ColorAsset(name: "Theme/system/sidebar.background") - public static let systemBackground = ColorAsset(name: "Theme/system/system.background") public static let systemElevatedBackground = ColorAsset(name: "Theme/system/system.elevated.background") - public static let systemGroupedBackground = ColorAsset(name: "Theme/system/system.grouped.background") public static let tabBarBackground = ColorAsset(name: "Theme/system/tab.bar.background") public static let tableViewCellBackground = ColorAsset(name: "Theme/system/table.view.cell.background") public static let tableViewCellSelectionBackground = ColorAsset(name: "Theme/system/table.view.cell.selection.background") - public static let tertiarySystemBackground = ColorAsset(name: "Theme/system/tertiary.system.background") - public static let tertiarySystemGroupedBackground = ColorAsset(name: "Theme/system/tertiary.system.grouped.background") - public static let notificationStatusBorderColor = ColorAsset(name: "Theme/system/notification.status.border.color") public static let separator = ColorAsset(name: "Theme/system/separator") public static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/system/tab.bar.item.inactive.icon.color") } diff --git a/MastodonSDK/Sources/MastodonCommon/Preference/Preference+Theme.swift b/MastodonSDK/Sources/MastodonCommon/Preference/Preference+Theme.swift deleted file mode 100644 index 3fc32da65..000000000 --- a/MastodonSDK/Sources/MastodonCommon/Preference/Preference+Theme.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Preference+Theme.swift -// -// -// Created by MainasuK on 2022-4-13. -// - -import UIKit -import MastodonExtension - -public enum ThemeName: String, CaseIterable { - case system -} - -extension UserDefaults { - - @objc public dynamic var currentThemeNameRawValue: String { - get { - register(defaults: [#function: ThemeName.system.rawValue]) - return string(forKey: #function) ?? ThemeName.system.rawValue - } - set { self[#function] = newValue } - } - -} diff --git a/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift b/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift index 3594ac8af..2288cd8d1 100644 --- a/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift +++ b/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift @@ -8,6 +8,7 @@ import UIKit import Combine import MastodonLocalization +import MastodonAsset public enum PollComposeItem: Hashable { case option(Option) @@ -24,16 +25,11 @@ extension PollComposeItem { // input @Published public var text = "" @Published public var shouldBecomeFirstResponder = false - - // output - @Published public var backgroundColor = ThemeService.shared.currentTheme.value.composePollRowBackgroundColor + + public let backgroundColor = SystemTheme.composePollRowBackgroundColor public override init() { super.init() - - ThemeService.shared.currentTheme - .map { $0.composePollRowBackgroundColor } - .assign(to: &$backgroundColor) } } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift b/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift index 3c74045d3..098827eb2 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/SettingService.swift @@ -177,12 +177,6 @@ extension SettingService { extension SettingService { static func updatePreference(setting: Setting) { - // set theme - let themeName: ThemeName = .system - if UserDefaults.shared.currentThemeNameRawValue != themeName.rawValue { - ThemeService.shared.set(themeName: themeName) - } - // set avatar mode if UserDefaults.shared.preferredStaticAvatar != setting.preferredStaticAvatar { UserDefaults.shared.preferredStaticAvatar = setting.preferredStaticAvatar diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift index 526491d78..dfbd86122 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift @@ -9,39 +9,27 @@ import UIKit import MastodonAsset import MastodonCommon -struct SystemTheme: Theme { +public enum SystemTheme { + public static let tintColor = UIColor.label - let themeName: ThemeName = .system + public static let systemElevatedBackgroundColor = Asset.Theme.System.systemElevatedBackground.color + public static let navigationBarBackgroundColor = Asset.Theme.System.navigationBarBackground.color - let systemBackgroundColor = Asset.Theme.System.systemBackground.color - let secondarySystemBackgroundColor = Asset.Theme.System.secondarySystemBackground.color - let tertiarySystemBackgroundColor = Asset.Theme.System.tertiarySystemBackground.color - - let systemElevatedBackgroundColor = Asset.Theme.System.systemElevatedBackground.color - - let systemGroupedBackgroundColor = Asset.Theme.System.systemGroupedBackground.color - let secondarySystemGroupedBackgroundColor = Asset.Theme.System.secondaryGroupedSystemBackground.color - let tertiarySystemGroupedBackgroundColor = Asset.Theme.System.tertiarySystemGroupedBackground.color - - let navigationBarBackgroundColor = Asset.Theme.System.navigationBarBackground.color - - let sidebarBackgroundColor = Asset.Theme.System.sidebarBackground.color + public static let sidebarBackgroundColor = Asset.Theme.System.sidebarBackground.color - let tabBarBackgroundColor = Asset.Theme.System.tabBarBackground.color - let tabBarItemSelectedIconColor = Asset.Colors.Brand.blurple.color - let tabBarItemFocusedIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color - let tabBarItemNormalIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color - let tabBarItemDisabledIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color + public static let tabBarBackgroundColor = Asset.Theme.System.tabBarBackground.color + public static let tabBarItemSelectedIconColor = Asset.Colors.Brand.blurple.color + public static let tabBarItemFocusedIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color + public static let tabBarItemNormalIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color + public static let tabBarItemDisabledIconColor = Asset.Theme.System.tabBarItemInactiveIconColor.color - let separator = Asset.Theme.System.separator.color + public static let separator = Asset.Theme.System.separator.color - let tableViewBackgroundColor: UIColor = .clear - let tableViewCellBackgroundColor = Asset.Theme.System.tableViewCellBackground.color - let tableViewCellSelectionBackgroundColor = Asset.Theme.System.tableViewCellSelectionBackground.color + public static let tableViewBackgroundColor: UIColor = .clear + public static let tableViewCellBackgroundColor = Asset.Theme.System.tableViewCellBackground.color + public static let tableViewCellSelectionBackgroundColor = Asset.Theme.System.tableViewCellSelectionBackground.color - let contentWarningOverlayBackgroundColor = Asset.Theme.System.contentWarningOverlayBackground.color - let profileFieldCollectionViewBackgroundColor = Asset.Theme.System.profileFieldCollectionViewBackground.color - let composeToolbarBackgroundColor = Asset.Theme.System.composeToolbarBackground.color - let composePollRowBackgroundColor = Asset.Theme.System.composePollRowBackground.color - let notificationStatusBorderColor = Asset.Theme.System.notificationStatusBorderColor.color + public static let contentWarningOverlayBackgroundColor = Asset.Theme.System.contentWarningOverlayBackground.color + public static let composeToolbarBackgroundColor = Asset.Theme.System.composeToolbarBackground.color + public static let composePollRowBackgroundColor = Asset.Theme.System.composePollRowBackground.color } diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift deleted file mode 100644 index b5bb00f44..000000000 --- a/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// Theme.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-7-5. -// - -import UIKit -import MastodonCommon - -public protocol Theme { - - var themeName: ThemeName { get } - - var systemBackgroundColor: UIColor { get } - var secondarySystemBackgroundColor: UIColor { get } - var tertiarySystemBackgroundColor: UIColor { get } - - var systemElevatedBackgroundColor: UIColor { get } - - var systemGroupedBackgroundColor: UIColor { get } - var secondarySystemGroupedBackgroundColor: UIColor { get } - var tertiarySystemGroupedBackgroundColor: UIColor { get } - - var navigationBarBackgroundColor: UIColor { get } - - var sidebarBackgroundColor: UIColor { get } - - var tabBarBackgroundColor: UIColor { get } - var tabBarItemSelectedIconColor: UIColor { get } - var tabBarItemFocusedIconColor: UIColor { get } - var tabBarItemNormalIconColor: UIColor { get } - var tabBarItemDisabledIconColor: UIColor { get } - - var separator: UIColor { get } - - var tableViewBackgroundColor: UIColor { get } - var tableViewCellBackgroundColor: UIColor { get } - var tableViewCellSelectionBackgroundColor: UIColor { get } - - var contentWarningOverlayBackgroundColor: UIColor { get } - var profileFieldCollectionViewBackgroundColor: UIColor { get } - var composeToolbarBackgroundColor: UIColor { get } - var composePollRowBackgroundColor: UIColor { get } - var notificationStatusBorderColor: UIColor { get } - -} diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/ThemeService.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/ThemeService.swift index a3316fe69..56843403c 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/Theme/ThemeService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/Theme/ThemeService.swift @@ -11,44 +11,14 @@ import MastodonCommon // ref: https://zamzam.io/protocol-oriented-themes-for-ios-apps/ public final class ThemeService { - - public static let tintColor: UIColor = .label - // MARK: - Singleton public static let shared = ThemeService() - public let currentTheme: CurrentValueSubject - - private init() { - let theme = ThemeName.system.theme - currentTheme = CurrentValueSubject(theme) - } - -} - -extension ThemeName { - public var theme: Theme { - switch self { - case .system: - return SystemTheme() - } - } -} - -extension ThemeService { - public func set(themeName: ThemeName) { - UserDefaults.shared.currentThemeNameRawValue = themeName.rawValue - - let theme = themeName.theme - apply(theme: theme) - currentTheme.value = theme - } - - public func apply(theme: Theme) { + public func apply() { // set navigation bar appearance let appearance = UINavigationBarAppearance() appearance.configureWithDefaultBackground() - appearance.backgroundColor = theme.navigationBarBackgroundColor + appearance.backgroundColor = SystemTheme.navigationBarBackgroundColor UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().compactAppearance = appearance UINavigationBar.appearance().scrollEdgeAppearance = appearance @@ -63,30 +33,30 @@ extension ThemeService { tabBarItemAppearance.focused.titleTextAttributes = [.foregroundColor: UIColor.clear] tabBarItemAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.clear] tabBarItemAppearance.disabled.titleTextAttributes = [.foregroundColor: UIColor.clear] - tabBarItemAppearance.selected.iconColor = theme.tabBarItemSelectedIconColor - tabBarItemAppearance.focused.iconColor = theme.tabBarItemFocusedIconColor - tabBarItemAppearance.normal.iconColor = theme.tabBarItemNormalIconColor - tabBarItemAppearance.disabled.iconColor = theme.tabBarItemDisabledIconColor + tabBarItemAppearance.selected.iconColor = SystemTheme.tabBarItemSelectedIconColor + tabBarItemAppearance.focused.iconColor = SystemTheme.tabBarItemFocusedIconColor + tabBarItemAppearance.normal.iconColor = SystemTheme.tabBarItemNormalIconColor + tabBarItemAppearance.disabled.iconColor = SystemTheme.tabBarItemDisabledIconColor tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance tabBarAppearance.inlineLayoutAppearance = tabBarItemAppearance tabBarAppearance.compactInlineLayoutAppearance = tabBarItemAppearance - tabBarAppearance.backgroundColor = theme.tabBarBackgroundColor + tabBarAppearance.backgroundColor = SystemTheme.tabBarBackgroundColor UITabBar.appearance().standardAppearance = tabBarAppearance UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance - UITabBar.appearance().barTintColor = theme.tabBarBackgroundColor + UITabBar.appearance().barTintColor = SystemTheme.tabBarBackgroundColor // set table view cell appearance - UITableView.appearance().backgroundColor = theme.tableViewBackgroundColor - UITableViewCell.appearance().backgroundColor = theme.tableViewCellBackgroundColor + UITableView.appearance().backgroundColor = SystemTheme.tableViewBackgroundColor + UITableViewCell.appearance().backgroundColor = SystemTheme.tableViewCellBackgroundColor // FIXME: refactor - // UITableViewCell.appearance(whenContainedInInstancesOf: [SettingsViewController.self]).backgroundColor = theme.secondarySystemGroupedBackgroundColor - // UITableViewCell.appearance().selectionColor = theme.tableViewCellSelectionBackgroundColor + // UITableViewCell.appearance(whenContainedInInstancesOf: [SettingsViewController.self]).backgroundColor = .secondarySystemGroupedBackground + // UITableViewCell.appearance().selectionColor = SystemTheme.tableViewCellSelectionBackgroundColor // set search bar appearance - UISearchBar.appearance().tintColor = ThemeService.tintColor - UISearchBar.appearance().barTintColor = theme.navigationBarBackgroundColor - let cancelButtonAttributes: [NSAttributedString.Key : Any] = [NSAttributedString.Key.foregroundColor: ThemeService.tintColor] + UISearchBar.appearance().tintColor = SystemTheme.tintColor + UISearchBar.appearance().barTintColor = SystemTheme.navigationBarBackgroundColor + let cancelButtonAttributes: [NSAttributedString.Key : Any] = [NSAttributedString.Key.foregroundColor: SystemTheme.tintColor] UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).setTitleTextAttributes(cancelButtonAttributes, for: .normal) } } diff --git a/MastodonSDK/Sources/MastodonUI/Extension/UIView.swift b/MastodonSDK/Sources/MastodonUI/Extension/UIView.swift index c66f111a0..93ca727a6 100644 --- a/MastodonSDK/Sources/MastodonUI/Extension/UIView.swift +++ b/MastodonSDK/Sources/MastodonUI/Extension/UIView.swift @@ -9,27 +9,13 @@ import UIKit import MastodonCore extension UIView { - - static let separatorColor: UIColor = { - UIColor(dynamicProvider: { collection in - switch collection.userInterfaceStyle { - case .dark: - return ThemeService.shared.currentTheme.value.separator - default: - return .separator - } - }) - }() - - public static var separatorLine: UIView { let line = UIView() - line.backgroundColor = UIView.separatorColor + line.backgroundColor = .separator return line } public static func separatorLineHeight(of view: UIView) -> CGFloat { return 1.0 / view.traitCollection.displayScale } - } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift index bfc1760fe..e42e7d8b5 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift @@ -25,7 +25,7 @@ final class AutoCompleteViewController: UIViewController { let chevronView = AutoCompleteTopChevronView() let containerBackgroundView: UIView = { let view = UIView() - view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor + view.backgroundColor = .systemBackground return view }() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift index 98690a3ce..437368e7f 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift @@ -20,12 +20,8 @@ final class AutoCompleteTopChevronView: UIView { private let maskLayer = CAShapeLayer() var chevronMinX: CGFloat = 0 - var topViewBackgroundColor = ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor { - didSet { setNeedsLayout() } - } - var bottomViewBackgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor { - didSet { setNeedsLayout() } - } + var topViewBackgroundColor = SystemTheme.systemElevatedBackgroundColor + var bottomViewBackgroundColor = UIColor.systemBackground override init(frame: CGRect) { super.init(frame: frame) @@ -69,15 +65,6 @@ extension AutoCompleteTopChevronView { shadowLayer.fillColor = topViewBackgroundColor.cgColor shadowView.layer.addSublayer(shadowLayer) - - setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackgroundColor(theme: theme) - } - .store(in: &disposeBag) } override func layoutSubviews() { @@ -122,13 +109,6 @@ extension AutoCompleteTopChevronView { } -extension AutoCompleteTopChevronView { - private func setupBackgroundColor(theme: Theme) { - topViewBackgroundColor = theme.systemElevatedBackgroundColor - bottomViewBackgroundColor = theme.systemBackgroundColor - } -} - extension AutoCompleteTopChevronView { func invertMask(in rect: CGRect) -> CAShapeLayer { let path = UIBezierPath() @@ -168,7 +148,7 @@ struct AutoCompleteTopChevronView_Previews: PreviewProvider { view.chevronMinX = 10 return view } - .background(Color(ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor)) + .background(Color(SystemTheme.systemElevatedBackgroundColor)) .padding(20) .previewLayout(.fixed(width: 375 + 40, height: 100 + 40)) UIViewPreview(width: 375) { @@ -181,7 +161,7 @@ struct AutoCompleteTopChevronView_Previews: PreviewProvider { view.chevronMinX = 10 return view } - .background(Color(ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor)) + .background(Color(SystemTheme.systemElevatedBackgroundColor)) .preferredColorScheme(.dark) .padding(20) .previewLayout(.fixed(width: 375 + 40, height: 100 + 40)) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift index c373a7a6f..864160e06 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift @@ -89,14 +89,7 @@ extension ComposeContentViewController { viewModel.delegate = self // setup view - self.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) + setupBackgroundColor() // setup tableView tableView.translatesAutoresizingMaskIntoConstraints = false @@ -311,16 +304,16 @@ extension ComposeContentViewController { } extension ComposeContentViewController { - private func setupBackgroundColor(theme: Theme) { + private func setupBackgroundColor() { let backgroundColor = UIColor(dynamicProvider: { traitCollection in switch traitCollection.userInterfaceStyle { case .light: return .systemBackground - default: return theme.systemElevatedBackgroundColor + default: return SystemTheme.systemElevatedBackgroundColor } }) view.backgroundColor = backgroundColor tableView.backgroundColor = backgroundColor - composeContentToolbarBackgroundView.backgroundColor = theme.composeToolbarBackgroundColor + composeContentToolbarBackgroundView.backgroundColor = SystemTheme.composeToolbarBackgroundColor } private func bindToolbarViewModel() { diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift index e2a916dd3..96efd3000 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift @@ -46,12 +46,6 @@ public struct PollAddOptionRow: View { extension PollAddOptionRow { public class ViewModel: ObservableObject { // output - @Published public var backgroundColor = ThemeService.shared.currentTheme.value.composePollRowBackgroundColor - - public init() { - ThemeService.shared.currentTheme - .map { $0.composePollRowBackgroundColor } - .assign(to: &$backgroundColor) - } + public var backgroundColor = SystemTheme.composePollRowBackgroundColor } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift index aaf2d2dca..2b25755b2 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift @@ -17,7 +17,7 @@ extension ComposeContentToolbarView { weak var delegate: ComposeContentToolbarViewDelegate? // input - @Published var backgroundColor = ThemeService.shared.currentTheme.value.composeToolbarBackgroundColor + @Published var backgroundColor = SystemTheme.composeToolbarBackgroundColor @Published var suggestedLanguages: [String] = [] @Published var highConfidenceSuggestedLanguage: String? @Published var visibility: Mastodon.Entity.Status.Visibility = .public @@ -43,13 +43,7 @@ extension ComposeContentToolbarView { init(delegate: ComposeContentToolbarViewDelegate) { self.delegate = delegate - // end init - - ThemeService.shared.currentTheme - .map { $0.composeToolbarBackgroundColor } - .assign(to: &$backgroundColor) } - } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift index 2266cc3f2..25b8fc653 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView+ViewModel.swift @@ -47,20 +47,14 @@ extension ProfileCardView { @Published public var familiarFollowers: Mastodon.Entity.FamiliarFollowers? init() { - backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor - Publishers.CombineLatest( - ThemeService.shared.currentTheme, - $userInterfaceStyle - ) - .sink { [weak self] theme, userInterfaceStyle in + backgroundColor = .systemBackground + $userInterfaceStyle + .sink { [weak self] userInterfaceStyle in guard let self = self else { return } guard let userInterfaceStyle = userInterfaceStyle else { return } switch userInterfaceStyle { case .dark: - switch theme.themeName { - case .system: - self.backgroundColor = theme.secondarySystemBackgroundColor - } + self.backgroundColor = .secondarySystemBackground case .light, .unspecified: self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color @unknown default: diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift index 90af468b6..5fead2f3c 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift @@ -69,11 +69,7 @@ public final class StatusCardControl: UIControl { public override init(frame: CGRect) { super.init(frame: frame) - apply(theme: ThemeService.shared.currentTheme.value) - - ThemeService.shared.currentTheme.sink { [weak self] theme in - self?.apply(theme: theme) - }.store(in: &disposeBag) + applyBranding() clipsToBounds = true layer.cornerCurve = .continuous @@ -234,9 +230,9 @@ public final class StatusCardControl: UIControl { } } - private func apply(theme: Theme) { - layer.borderColor = theme.separator.cgColor - dividerView.backgroundColor = theme.separator + private func applyBranding() { + layer.borderColor = SystemTheme.separator.cgColor + dividerView.backgroundColor = SystemTheme.separator imageView.backgroundColor = UIColor.tertiarySystemFill } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusMetricView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusMetricView.swift index 74b3e7125..7e85b8594 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusMetricView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusMetricView.swift @@ -38,7 +38,7 @@ public final class StatusMetricView: UIView { private let separator: UIView = { let view = UIView() - view.backgroundColor = Asset.Theme.Mastodon.separator.color + view.backgroundColor = .separator return view }() diff --git a/MastodonSDK/Sources/MastodonUI/View/Decoration/SawToothView.swift b/MastodonSDK/Sources/MastodonUI/View/Decoration/SawToothView.swift index 1a7a977e6..c5fb0320a 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Decoration/SawToothView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Decoration/SawToothView.swift @@ -26,19 +26,7 @@ public final class SawToothView: UIView { } func _init() { - 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() + backgroundColor = .secondarySystemBackground } public override func draw(_ rect: CGRect) { @@ -53,7 +41,7 @@ public final class SawToothView: UIView { } bezierPath.addLine(to: CGPoint(x: 0, y: bottomY)) bezierPath.close() - ThemeService.shared.currentTheme.value.tableViewCellBackgroundColor.setFill() + SystemTheme.tableViewCellBackgroundColor.setFill() bezierPath.fill() bezierPath.lineWidth = 0 bezierPath.stroke() diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift index 7f5b355d3..00ff5e8c4 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift @@ -27,7 +27,7 @@ open class TimelineLoaderTableViewCell: UITableViewCell { public let loadMoreButton: UIButton = { let button = HighlightDimmableButton() button.titleLabel?.font = TimelineLoaderTableViewCell.labelFont - button.setTitleColor(ThemeService.tintColor, for: .normal) + button.setTitleColor(SystemTheme.tintColor, for: .normal) button.setTitle(L10n.Common.Controls.Timeline.Loader.loadMissingPosts, for: .normal) button.setTitle("", for: .disabled) return button @@ -71,7 +71,7 @@ open class TimelineLoaderTableViewCell: UITableViewCell { public func stopAnimating() { activityIndicatorView.stopAnimating() self.loadMoreButton.isEnabled = true - self.loadMoreLabel.textColor = ThemeService.tintColor + self.loadMoreLabel.textColor = SystemTheme.tintColor self.loadMoreLabel.text = "" } @@ -114,18 +114,6 @@ open class TimelineLoaderTableViewCell: UITableViewCell { 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) + loadMoreButton.backgroundColor = SystemTheme.tableViewCellBackgroundColor } - - private func setupBackgroundColor(theme: Theme) { - loadMoreButton.backgroundColor = theme.tableViewCellBackgroundColor - } - } diff --git a/ShareActionExtension/Scene/ShareViewController.swift b/ShareActionExtension/Scene/ShareViewController.swift index 67a5eca14..26c2e872c 100644 --- a/ShareActionExtension/Scene/ShareViewController.swift +++ b/ShareActionExtension/Scene/ShareViewController.swift @@ -69,16 +69,9 @@ extension ShareViewController { override func viewDidLoad() { super.viewDidLoad() - setupTheme(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.apply(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: DispatchQueue.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupTheme(theme: theme) - } - .store(in: &disposeBag) - + setupTheme() + ThemeService.shared.apply() + view.backgroundColor = .systemBackground title = L10n.Scene.Compose.Title.newPost @@ -182,12 +175,12 @@ extension ShareViewController { ]) } - private func setupTheme(theme: Theme) { - view.backgroundColor = theme.systemElevatedBackgroundColor + private func setupTheme() { + view.backgroundColor = SystemTheme.systemElevatedBackgroundColor let barAppearance = UINavigationBarAppearance() barAppearance.configureWithDefaultBackground() - barAppearance.backgroundColor = theme.navigationBarBackgroundColor + barAppearance.backgroundColor = SystemTheme.navigationBarBackgroundColor navigationItem.standardAppearance = barAppearance navigationItem.compactAppearance = barAppearance navigationItem.scrollEdgeAppearance = barAppearance