From 7b8500e1200797d4820f2cb804d9c18c1d651a00 Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 20 Jul 2021 19:24:24 +0800 Subject: [PATCH] feat: set theme color for share action extension --- Localization/app.json | 2 +- .../Onboarding/CategoryPickerSection.swift | 2 +- .../Section/Search/SearchResultSection.swift | 12 ---- .../Section/Status/PollSection.swift | 2 +- Mastodon/Generated/Assets.swift | 46 +++++++------ Mastodon/Generated/Strings.swift | 2 +- .../Contents.json | 20 ------ .../Contents.json | 38 ----------- .../Contents.json | 38 ----------- .../Contents.json | 38 ----------- .../Colors/{Background => Poll}/Contents.json | 0 .../Poll/disabled.colorset/Contents.json | 0 .../alert.yellow.colorset/Contents.json | 0 .../danger.border.colorset/Contents.json | 6 +- .../Contents.json | 6 +- .../toolbar.background.colorset/Contents.json | 38 ----------- .../Contents.json | 12 ++-- .../Contents.json | 38 +++++++++++ .../Background}/Contents.json | 0 .../Background/danger.colorset/Contents.json | 6 +- .../Contents.json | 20 ++++++ .../Contents.json | 12 ++-- .../Contents.json | 12 ++-- .../system.background.colorset/Contents.json | 38 +++++++++++ .../Contents.json | 6 +- .../Contents.json | 38 +++++++++++ .../Contents.json | 38 +++++++++++ .../Contents.json | 38 +++++++++++ .../Compose/Contents.json | 0 .../background.colorset}/Contents.json | 6 +- .../toolbar.background.colorset/Contents.json | 38 +++++++++++ .../Assets.xcassets/_Deprecated/Contents.json | 9 +++ .../Resources/ar.lproj/Localizable.strings | 2 +- .../Resources/en.lproj/Localizable.strings | 2 +- .../View/AutoCompleteTopChevronView.swift | 27 ++++++-- ...seStatusAttachmentCollectionViewCell.swift | 4 +- .../Scene/Compose/ComposeViewController.swift | 7 +- ...ComposeStatusAttachmentTableViewCell.swift | 2 +- .../Compose/View/ComposeToolbarView.swift | 15 ++++- .../HomeTimelineNavigationBarTitleView.swift | 2 +- .../NotificationStatusTableViewCell.swift | 6 +- .../MastodonPickServerViewController.swift | 4 +- .../PickServerCategoriesCell.swift | 2 +- .../TableViewCell/PickServerCell.swift | 4 +- .../PickServerLoaderTableViewCell.swift | 4 +- .../TableViewCell/PickServerSearchCell.swift | 4 +- .../TableViewCell/PickServerTitleCell.swift | 2 +- .../View/PickServerCategoryView.swift | 2 +- .../View/PickServerEmptyStateView.swift | 2 +- .../MastodonRegisterViewController.swift | 14 ++-- .../MastodonServerRulesViewController.swift | 4 +- .../OnboardingViewControllerAppearance.swift | 4 +- .../Header/View/ProfileHeaderView.swift | 2 +- Mastodon/Scene/Profile/ProfileViewModel.swift | 4 +- ...ContainerView+MediaTypeIndicotorView.swift | 2 +- .../Share/View/Content/PollOptionView.swift | 3 +- .../ThreadReplyLoaderTableViewCell.swift | 3 +- .../SuggestionAccountViewController.swift | 11 +++- .../Service/ThemeService/MastodonTheme.swift | 1 + .../Service/ThemeService/SystemTheme.swift | 1 + Mastodon/Service/ThemeService/Theme.swift | 2 + .../Scene/ShareViewController.swift | 64 +++++++++++++++++-- .../Scene/ShareViewModel.swift | 6 ++ .../Scene/View/ComposeToolbarView.swift | 15 ++++- .../Scene/View/ComposeView.swift | 24 ++++--- .../Scene/View/ComposeViewModel.swift | 1 + .../Scene/View/StatusEditorView.swift | 1 + 67 files changed, 501 insertions(+), 313 deletions(-) delete mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/onboarding.background.colorset/Contents.json delete mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/system.grouped.background.colorset/Contents.json delete mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json delete mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/Colors/{Background => Poll}/Contents.json (100%) rename Mastodon/Resources/Assets.xcassets/Colors/{Background => }/Poll/disabled.colorset/Contents.json (100%) rename Mastodon/Resources/Assets.xcassets/Colors/{Background => }/alert.yellow.colorset/Contents.json (100%) rename Mastodon/Resources/Assets.xcassets/Colors/{Background => }/danger.border.colorset/Contents.json (74%) rename Mastodon/Resources/Assets.xcassets/Colors/{Background => }/media.type.indicotor.colorset/Contents.json (74%) delete mode 100644 Mastodon/Resources/Assets.xcassets/Scene/Compose/toolbar.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/{Colors/Background/secondary.grouped.system.background.colorset => Theme/Mastodon/Background/compose.toolbar.background.colorset}/Contents.json (76%) create mode 100644 Mastodon/Resources/Assets.xcassets/Theme/system/Background/compose.toolbar.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/{Colors/Background/Poll => _Deprecated/Background}/Contents.json (100%) rename Mastodon/Resources/Assets.xcassets/{Colors => _Deprecated}/Background/danger.colorset/Contents.json (74%) create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Background/onboarding.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/{Colors/Background/secondary.system.background.colorset => _Deprecated/Background/secondary.grouped.system.background.colorset}/Contents.json (76%) rename Mastodon/Resources/Assets.xcassets/{Colors/Background/system.background.colorset => _Deprecated/Background/secondary.system.background.colorset}/Contents.json (76%) create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/{Scene/Compose/background.colorset => _Deprecated/Background/system.elevated.background.colorset}/Contents.json (88%) create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.grouped.background.colorset/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.background.colorset/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.grouped.background.colorset/Contents.json rename Mastodon/Resources/Assets.xcassets/{Scene => _Deprecated}/Compose/Contents.json (100%) rename Mastodon/Resources/Assets.xcassets/{Colors/Background/system.elevated.background.colorset => _Deprecated/Compose/background.colorset}/Contents.json (88%) create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/toolbar.background.colorset/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/_Deprecated/Contents.json diff --git a/Localization/app.json b/Localization/app.json index f1024620c..049094d4f 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -524,7 +524,7 @@ }, "boring_zone": { "title": "The Boring Zone", - "account_settings": "Account settings", + "account_settings": "Account Settings", "terms": "Terms of Service", "privacy": "Privacy Policy" }, diff --git a/Mastodon/Diffiable/Section/Onboarding/CategoryPickerSection.swift b/Mastodon/Diffiable/Section/Onboarding/CategoryPickerSection.swift index 7ab93cc5e..732813c0a 100644 --- a/Mastodon/Diffiable/Section/Onboarding/CategoryPickerSection.swift +++ b/Mastodon/Diffiable/Section/Onboarding/CategoryPickerSection.swift @@ -34,7 +34,7 @@ extension CategoryPickerSection { cell.categoryView.titleLabel.textColor = .white } } else { - cell.categoryView.bgView.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + cell.categoryView.bgView.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color cell.categoryView.bgView.applyShadow(color: Asset.Colors.brandBlue.color, alpha: 0, x: 0, y: 0, blur: 0.0) if case .all = item { cell.categoryView.titleLabel.textColor = Asset.Colors.brandBlue.color diff --git a/Mastodon/Diffiable/Section/Search/SearchResultSection.swift b/Mastodon/Diffiable/Section/Search/SearchResultSection.swift index 5d26a6828..dcc52e15b 100644 --- a/Mastodon/Diffiable/Section/Search/SearchResultSection.swift +++ b/Mastodon/Diffiable/Section/Search/SearchResultSection.swift @@ -33,16 +33,6 @@ extension SearchResultSection { let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchResultTableViewCell.self), for: indexPath) as! SearchResultTableViewCell cell.config(with: tag) return cell -// case .hashtagObjectID(let hashtagObjectID): -// let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchingTableViewCell.self), for: indexPath) as! SearchingTableViewCell -// let tag = dependency.context.managedObjectContext.object(with: hashtagObjectID) as! Tag -// cell.config(with: tag) -// return cell -// case .accountObjectID(let accountObjectID): -// let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchingTableViewCell.self), for: indexPath) as! SearchingTableViewCell -// let user = dependency.context.managedObjectContext.object(with: accountObjectID) as! MastodonUser -// cell.config(with: user) -// return cell case .status(let statusObjectID, let attribute): let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: StatusTableViewCell.self), for: indexPath) as! StatusTableViewCell if let status = try? dependency.context.managedObjectContext.existingObject(with: statusObjectID) as? Status { @@ -73,8 +63,6 @@ extension SearchResultSection { cell.loadMoreLabel.isHidden = true } return cell - default: - fatalError() } // end switch } // end UITableViewDiffableDataSource } // end func diff --git a/Mastodon/Diffiable/Section/Status/PollSection.swift b/Mastodon/Diffiable/Section/Status/PollSection.swift index 79ecd415d..add2a79b2 100644 --- a/Mastodon/Diffiable/Section/Status/PollSection.swift +++ b/Mastodon/Diffiable/Section/Status/PollSection.swift @@ -103,7 +103,7 @@ extension PollSection { cell.pollOptionView.optionPercentageLabel.isHidden = false cell.pollOptionView.optionPercentageLabel.text = String(Int(100 * percentage)) + "%" cell.pollOptionView.voteProgressStripView.isHidden = false - cell.pollOptionView.voteProgressStripView.tintColor = voted ? Asset.Colors.brandBlue.color : Asset.Colors.Background.Poll.disabled.color + cell.pollOptionView.voteProgressStripView.tintColor = voted ? Asset.Colors.brandBlue.color : Asset.Colors.Poll.disabled.color cell.pollOptionView.voteProgressStripView.setProgress(CGFloat(percentage), animated: animated) } } diff --git a/Mastodon/Generated/Assets.swift b/Mastodon/Generated/Assets.swift index 294a3c6aa..0f405ef05 100644 --- a/Mastodon/Generated/Assets.swift +++ b/Mastodon/Generated/Assets.swift @@ -32,23 +32,6 @@ internal enum Asset { internal static let plusCircle = ImageAsset(name: "Circles/plus.circle") } internal enum Colors { - internal enum Background { - internal enum Poll { - internal static let disabled = ColorAsset(name: "Colors/Background/Poll/disabled") - } - internal static let alertYellow = ColorAsset(name: "Colors/Background/alert.yellow") - internal static let dangerBorder = ColorAsset(name: "Colors/Background/danger.border") - internal static let danger = ColorAsset(name: "Colors/Background/danger") - internal static let mediaTypeIndicotor = ColorAsset(name: "Colors/Background/media.type.indicotor") - internal static let onboardingBackground = ColorAsset(name: "Colors/Background/onboarding.background") - internal static let secondaryGroupedSystemBackground = ColorAsset(name: "Colors/Background/secondary.grouped.system.background") - internal static let secondarySystemBackground = ColorAsset(name: "Colors/Background/secondary.system.background") - internal static let systemBackground = ColorAsset(name: "Colors/Background/system.background") - internal static let systemElevatedBackground = ColorAsset(name: "Colors/Background/system.elevated.background") - internal static let systemGroupedBackground = ColorAsset(name: "Colors/Background/system.grouped.background") - internal static let tertiarySystemBackground = ColorAsset(name: "Colors/Background/tertiary.system.background") - internal static let tertiarySystemGroupedBackground = ColorAsset(name: "Colors/Background/tertiary.system.grouped.background") - } internal enum Border { internal static let composePoll = ColorAsset(name: "Colors/Border/compose.poll") internal static let notificationStatus = ColorAsset(name: "Colors/Border/notification.status") @@ -73,6 +56,9 @@ internal enum Asset { internal static let mention = ColorAsset(name: "Colors/Notification/mention") internal static let reblog = ColorAsset(name: "Colors/Notification/reblog") } + internal enum Poll { + internal static let disabled = ColorAsset(name: "Colors/Poll/disabled") + } internal enum Shadow { internal static let searchCard = ColorAsset(name: "Colors/Shadow/SearchCard") } @@ -87,12 +73,15 @@ internal enum Asset { internal static let invalid = ColorAsset(name: "Colors/TextField/invalid") internal static let valid = ColorAsset(name: "Colors/TextField/valid") } + internal static let alertYellow = ColorAsset(name: "Colors/alert.yellow") internal static let battleshipGrey = ColorAsset(name: "Colors/battleshipGrey") internal static let brandBlue = ColorAsset(name: "Colors/brand.blue") internal static let brandBlueDarken20 = ColorAsset(name: "Colors/brand.blue.darken.20") + internal static let dangerBorder = ColorAsset(name: "Colors/danger.border") internal static let danger = ColorAsset(name: "Colors/danger") internal static let disabled = ColorAsset(name: "Colors/disabled") internal static let inactive = ColorAsset(name: "Colors/inactive") + internal static let mediaTypeIndicotor = ColorAsset(name: "Colors/media.type.indicotor") internal static let successGreen = ColorAsset(name: "Colors/success.green") internal static let systemOrange = ColorAsset(name: "Colors/system.orange") } @@ -103,10 +92,6 @@ internal enum Asset { internal static let faceSmilingAdaptive = ImageAsset(name: "Human/face.smiling.adaptive") } internal enum Scene { - internal enum Compose { - internal static let background = ColorAsset(name: "Scene/Compose/background") - internal static let toolbarBackground = ColorAsset(name: "Scene/Compose/toolbar.background") - } internal enum Profile { internal enum Banner { internal static let bioEditBackgroundGray = ColorAsset(name: "Scene/Profile/Banner/bio.edit.background.gray") @@ -136,6 +121,7 @@ internal enum Asset { } internal enum Theme { internal enum Mastodon { + internal static let composeToolbarBackground = ColorAsset(name: "Theme/Mastodon/compose.toolbar.background") internal static let contentWarningOverlayBackground = ColorAsset(name: "Theme/Mastodon/content.warning.overlay.background") internal static let navigationBarBackground = ColorAsset(name: "Theme/Mastodon/navigation.bar.background") internal static let profileFieldCollectionViewBackground = ColorAsset(name: "Theme/Mastodon/profile.field.collection.view.background") @@ -153,6 +139,7 @@ internal enum Asset { internal static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/Mastodon/tab.bar.item.inactive.icon.color") } internal enum System { + internal static let composeToolbarBackground = ColorAsset(name: "Theme/system/compose.toolbar.background") internal static let contentWarningOverlayBackground = ColorAsset(name: "Theme/system/content.warning.overlay.background") internal static let navigationBarBackground = ColorAsset(name: "Theme/system/navigation.bar.background") internal static let profileFieldCollectionViewBackground = ColorAsset(name: "Theme/system/profile.field.collection.view.background") @@ -170,6 +157,23 @@ internal enum Asset { internal static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/system/tab.bar.item.inactive.icon.color") } } + internal enum Deprecated { + internal enum Background { + internal static let danger = ColorAsset(name: "_Deprecated/Background/danger") + internal static let onboardingBackground = ColorAsset(name: "_Deprecated/Background/onboarding.background") + internal static let secondaryGroupedSystemBackground = ColorAsset(name: "_Deprecated/Background/secondary.grouped.system.background") + internal static let secondarySystemBackground = ColorAsset(name: "_Deprecated/Background/secondary.system.background") + internal static let systemBackground = ColorAsset(name: "_Deprecated/Background/system.background") + internal static let systemElevatedBackground = ColorAsset(name: "_Deprecated/Background/system.elevated.background") + internal static let systemGroupedBackground = ColorAsset(name: "_Deprecated/Background/system.grouped.background") + internal static let tertiarySystemBackground = ColorAsset(name: "_Deprecated/Background/tertiary.system.background") + internal static let tertiarySystemGroupedBackground = ColorAsset(name: "_Deprecated/Background/tertiary.system.grouped.background") + } + internal enum Compose { + internal static let background = ColorAsset(name: "_Deprecated/Compose/background") + internal static let toolbarBackground = ColorAsset(name: "_Deprecated/Compose/toolbar.background") + } + } } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index d8b32458b..8d5443abb 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -950,7 +950,7 @@ internal enum L10n { internal static let trueBlackDarkMode = L10n.tr("Localizable", "Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode") } internal enum BoringZone { - /// Account settings + /// Account Settings internal static let accountSettings = L10n.tr("Localizable", "Scene.Settings.Section.BoringZone.AccountSettings") /// Privacy Policy internal static let privacy = L10n.tr("Localizable", "Scene.Settings.Section.BoringZone.Privacy") diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/onboarding.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/onboarding.background.colorset/Contents.json deleted file mode 100644 index 838e44e44..000000000 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/onboarding.background.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "232", - "green" : "225", - "red" : "217" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.grouped.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/system.grouped.background.colorset/Contents.json deleted file mode 100644 index 6ea6c820e..000000000 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE8", - "green" : "0xE1", - "red" : "0xD9" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "34", - "green" : "27", - "red" : "25" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json deleted file mode 100644 index c19f25c82..000000000 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xFE", - "green" : "0xFF", - "red" : "0xFE" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "55", - "green" : "44", - "red" : "40" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json deleted file mode 100644 index 66083b137..000000000 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE8", - "green" : "0xE1", - "red" : "0xD9" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "67", - "green" : "53", - "red" : "49" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Poll/Contents.json similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/Contents.json rename to Mastodon/Resources/Assets.xcassets/Colors/Poll/Contents.json diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Poll/disabled.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Poll/disabled.colorset/Contents.json similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/Poll/disabled.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Colors/Poll/disabled.colorset/Contents.json diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/alert.yellow.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/alert.yellow.colorset/Contents.json similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/alert.yellow.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Colors/alert.yellow.colorset/Contents.json diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/danger.border.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/danger.border.colorset/Contents.json similarity index 74% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/danger.border.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Colors/danger.border.colorset/Contents.json index bc9f94fcc..144f8376b 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/danger.border.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/danger.border.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "66", - "green" : "46", - "red" : "163" + "blue" : "0.259", + "green" : "0.180", + "red" : "0.639" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/media.type.indicotor.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/media.type.indicotor.colorset/Contents.json similarity index 74% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/media.type.indicotor.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Colors/media.type.indicotor.colorset/Contents.json index e9c583c0d..13d9ecffe 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/media.type.indicotor.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/media.type.indicotor.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "0.600", - "blue" : "0", - "green" : "0", - "red" : "0" + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Scene/Compose/toolbar.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Scene/Compose/toolbar.background.colorset/Contents.json deleted file mode 100644 index 9fba7740c..000000000 --- a/Mastodon/Resources/Assets.xcassets/Scene/Compose/toolbar.background.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "222", - "green" : "216", - "red" : "214" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "32", - "green" : "32", - "red" : "32" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json similarity index 76% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json index acd80352b..356b35510 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Theme/Mastodon/Background/compose.toolbar.background.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "254", - "green" : "255", - "red" : "254" + "blue" : "0.871", + "green" : "0.847", + "red" : "0.839" } }, "idiom" : "universal" @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "67", - "green" : "53", - "red" : "49" + "blue" : "0.263", + "green" : "0.208", + "red" : "0.192" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Theme/system/Background/compose.toolbar.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Theme/system/Background/compose.toolbar.background.colorset/Contents.json new file mode 100644 index 000000000..da7b76069 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Theme/system/Background/compose.toolbar.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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" : "0.920", + "blue" : "0.125", + "green" : "0.125", + "red" : "0.125" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Poll/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/Contents.json similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/Poll/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Background/Contents.json diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/danger.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/danger.colorset/Contents.json similarity index 74% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/danger.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Background/danger.colorset/Contents.json index b77cb3c75..dabccc33e 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/danger.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/danger.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "90", - "green" : "64", - "red" : "223" + "blue" : "0.353", + "green" : "0.251", + "red" : "0.875" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/onboarding.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/onboarding.background.colorset/Contents.json new file mode 100644 index 000000000..0e4687fb4 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/onboarding.background.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.910", + "green" : "0.882", + "red" : "0.851" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.grouped.system.background.colorset/Contents.json similarity index 76% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.system.background.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.grouped.system.background.colorset/Contents.json index e4dc3161f..ef6c7f7b1 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.grouped.system.background.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "232", - "green" : "225", - "red" : "217" + "blue" : "0.996", + "green" : "1.000", + "red" : "0.996" } }, "idiom" : "universal" @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "34", - "green" : "27", - "red" : "25" + "blue" : "0.263", + "green" : "0.208", + "red" : "0.192" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.system.background.colorset/Contents.json similarity index 76% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.system.background.colorset/Contents.json index f09411b71..c915c8911 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/secondary.system.background.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "254", - "green" : "255", - "red" : "254" + "blue" : "0.910", + "green" : "0.882", + "red" : "0.851" } }, "idiom" : "universal" @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x37", - "green" : "0x2C", - "red" : "0x28" + "blue" : "0.133", + "green" : "0.106", + "red" : "0.098" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.background.colorset/Contents.json new file mode 100644 index 000000000..4572c2409 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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/Mastodon/Resources/Assets.xcassets/Scene/Compose/background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.elevated.background.colorset/Contents.json similarity index 88% rename from Mastodon/Resources/Assets.xcassets/Scene/Compose/background.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.elevated.background.colorset/Contents.json index dd6cbfd91..33b71ef90 100644 --- a/Mastodon/Resources/Assets.xcassets/Scene/Compose/background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.elevated.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "55", - "green" : "44", - "red" : "40" + "blue" : "0.216", + "green" : "0.173", + "red" : "0.157" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.grouped.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.grouped.background.colorset/Contents.json new file mode 100644 index 000000000..c915c8911 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/system.grouped.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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.133", + "green" : "0.106", + "red" : "0.098" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.background.colorset/Contents.json new file mode 100644 index 000000000..4572c2409 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.grouped.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.grouped.background.colorset/Contents.json new file mode 100644 index 000000000..98dd7bbde --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Background/tertiary.system.grouped.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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.263", + "green" : "0.208", + "red" : "0.192" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Scene/Compose/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/Contents.json similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Scene/Compose/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/Contents.json diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/background.colorset/Contents.json similarity index 88% rename from Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json rename to Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/background.colorset/Contents.json index 147cca83c..33b71ef90 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x37", - "green" : "0x2C", - "red" : "0x28" + "blue" : "0.216", + "green" : "0.173", + "red" : "0.157" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/toolbar.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/toolbar.background.colorset/Contents.json new file mode 100644 index 000000000..da7b76069 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Compose/toolbar.background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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" : "0.920", + "blue" : "0.125", + "green" : "0.125", + "red" : "0.125" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/_Deprecated/Contents.json b/Mastodon/Resources/Assets.xcassets/_Deprecated/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/_Deprecated/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/Mastodon/Resources/ar.lproj/Localizable.strings b/Mastodon/Resources/ar.lproj/Localizable.strings index e7369046a..99babb0bf 100644 --- a/Mastodon/Resources/ar.lproj/Localizable.strings +++ b/Mastodon/Resources/ar.lproj/Localizable.strings @@ -323,7 +323,7 @@ any server."; "Scene.Settings.Section.Appearance.Title" = "Appearance"; "Scene.Settings.Section.AppearanceSettings.DisableAvatarAnimation" = "Disable animated avatars"; "Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode" = "True black dark mode"; -"Scene.Settings.Section.BoringZone.AccountSettings" = "Account settings"; +"Scene.Settings.Section.BoringZone.AccountSettings" = "Account Settings"; "Scene.Settings.Section.BoringZone.Privacy" = "Privacy Policy"; "Scene.Settings.Section.BoringZone.Terms" = "Terms of Service"; "Scene.Settings.Section.BoringZone.Title" = "The Boring Zone"; diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index e7369046a..99babb0bf 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -323,7 +323,7 @@ any server."; "Scene.Settings.Section.Appearance.Title" = "Appearance"; "Scene.Settings.Section.AppearanceSettings.DisableAvatarAnimation" = "Disable animated avatars"; "Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode" = "True black dark mode"; -"Scene.Settings.Section.BoringZone.AccountSettings" = "Account settings"; +"Scene.Settings.Section.BoringZone.AccountSettings" = "Account Settings"; "Scene.Settings.Section.BoringZone.Privacy" = "Privacy Policy"; "Scene.Settings.Section.BoringZone.Terms" = "Terms of Service"; "Scene.Settings.Section.BoringZone.Title" = "The Boring Zone"; diff --git a/Mastodon/Scene/Compose/AutoComplete/View/AutoCompleteTopChevronView.swift b/Mastodon/Scene/Compose/AutoComplete/View/AutoCompleteTopChevronView.swift index de409dfc9..9c3c81c3a 100644 --- a/Mastodon/Scene/Compose/AutoComplete/View/AutoCompleteTopChevronView.swift +++ b/Mastodon/Scene/Compose/AutoComplete/View/AutoCompleteTopChevronView.swift @@ -6,8 +6,11 @@ // import UIKit +import Combine final class AutoCompleteTopChevronView: UIView { + + var disposeBag = Set() static let chevronSize = CGSize(width: 20, height: 12) @@ -16,10 +19,10 @@ final class AutoCompleteTopChevronView: UIView { private let maskLayer = CAShapeLayer() var chevronMinX: CGFloat = 0 - var topViewBackgroundColor = Asset.Scene.Compose.background.color { + var topViewBackgroundColor = ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor { didSet { setNeedsLayout() } } - var bottomViewBackgroundColor = Asset.Colors.Background.systemBackground.color { + var bottomViewBackgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor { didSet { setNeedsLayout() } } @@ -70,6 +73,15 @@ 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() { @@ -114,6 +126,13 @@ 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() @@ -153,7 +172,7 @@ struct AutoCompleteTopChevronView_Previews: PreviewProvider { view.chevronMinX = 10 return view } - .background(Color(Asset.Scene.Compose.background.color)) + .background(Color(ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor)) .padding(20) .previewLayout(.fixed(width: 375 + 40, height: 100 + 40)) UIViewPreview(width: 375) { @@ -166,7 +185,7 @@ struct AutoCompleteTopChevronView_Previews: PreviewProvider { view.chevronMinX = 10 return view } - .background(Color(Asset.Scene.Compose.background.color)) + .background(Color(ThemeService.shared.currentTheme.value.systemElevatedBackgroundColor)) .preferredColorScheme(.dark) .padding(20) .previewLayout(.fixed(width: 375 + 40, height: 100 + 40)) diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift index 8d8cabcf6..fee6ce753 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusAttachmentCollectionViewCell.swift @@ -32,10 +32,10 @@ final class ComposeStatusAttachmentCollectionViewCell: UICollectionViewCell { let image = UIImage(systemName: "minus")!.withConfiguration(UIImage.SymbolConfiguration(pointSize: 14, weight: .bold)) button.tintColor = .white button.setImage(image, for: .normal) - button.setBackgroundImage(.placeholder(color: Asset.Colors.Background.danger.color), for: .normal) + button.setBackgroundImage(.placeholder(color: Asset.Colors.danger.color), for: .normal) button.layer.masksToBounds = true button.layer.cornerRadius = ComposeStatusAttachmentCollectionViewCell.removeButtonSize.width * 0.5 - button.layer.borderColor = Asset.Colors.Background.dangerBorder.color.cgColor + button.layer.borderColor = Asset.Colors.dangerBorder.color.cgColor button.layer.borderWidth = 1 return button }() diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index b48bcc631..eb3b95c98 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -76,11 +76,7 @@ final class ComposeViewController: UIViewController, NeedsDependency { let composeToolbarView = ComposeToolbarView() var composeToolbarViewBottomLayoutConstraint: NSLayoutConstraint! - let composeToolbarBackgroundView: UIView = { - let view = UIView() - view.backgroundColor = Asset.Scene.Compose.toolbarBackground.color - return view - }() + let composeToolbarBackgroundView = UIView() static func createPhotoLibraryPickerConfiguration(selectionLimit: Int = 4) -> PHPickerConfiguration { var configuration = PHPickerConfiguration() @@ -591,6 +587,7 @@ extension ComposeViewController { private func setupBackgroundColor(theme: Theme) { view.backgroundColor = theme.systemElevatedBackgroundColor tableView.backgroundColor = theme.systemElevatedBackgroundColor + composeToolbarBackgroundView.backgroundColor = theme.composeToolbarBackgroundColor } } diff --git a/Mastodon/Scene/Compose/TableViewCell/ComposeStatusAttachmentTableViewCell.swift b/Mastodon/Scene/Compose/TableViewCell/ComposeStatusAttachmentTableViewCell.swift index 623ec7178..561c6c3ba 100644 --- a/Mastodon/Scene/Compose/TableViewCell/ComposeStatusAttachmentTableViewCell.swift +++ b/Mastodon/Scene/Compose/TableViewCell/ComposeStatusAttachmentTableViewCell.swift @@ -88,7 +88,7 @@ extension ComposeStatusAttachmentTableViewCell { guard let image = thumbnailImage else { let placeholder = UIImage.placeholder( size: size, - color: Asset.Colors.Background.systemGroupedBackground.color + color: ThemeService.shared.currentTheme.value.systemGroupedBackgroundColor ) .af.imageRounded( withCornerRadius: AttachmentContainerView.containerViewCornerRadius diff --git a/Mastodon/Scene/Compose/View/ComposeToolbarView.swift b/Mastodon/Scene/Compose/View/ComposeToolbarView.swift index aecd5d063..c1cda22a6 100644 --- a/Mastodon/Scene/Compose/View/ComposeToolbarView.swift +++ b/Mastodon/Scene/Compose/View/ComposeToolbarView.swift @@ -96,8 +96,15 @@ final class ComposeToolbarView: UIView { extension ComposeToolbarView { private func _init() { - backgroundColor = Asset.Scene.Compose.toolbarBackground.color - + 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) + let stackView = UIStackView() stackView.axis = .horizontal stackView.spacing = 0 @@ -212,6 +219,10 @@ extension ComposeToolbarView { extension ComposeToolbarView { + private func setupBackgroundColor(theme: Theme) { + backgroundColor = theme.composeToolbarBackgroundColor + } + private static func configureToolbarButtonAppearance(button: UIButton) { button.tintColor = Asset.Colors.brandBlue.color button.setBackgroundImage(.placeholder(size: ComposeToolbarView.toolbarButtonSize, color: .systemFill), for: .highlighted) diff --git a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift index caa2fbe05..1e9c020c5 100644 --- a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift +++ b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift @@ -114,7 +114,7 @@ extension HomeTimelineNavigationBarTitleView { configureButton( title: L10n.Scene.HomeTimeline.NavigationBarState.offline, textColor: .white, - backgroundColor: Asset.Colors.Background.danger.color + backgroundColor: Asset.Colors.danger.color ) button.isHidden = false case .publishingPostLabel: diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift index f4987dc45..9c3558eaf 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift @@ -54,13 +54,13 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell { let actionImageView: UIImageView = { let imageView = UIImageView() imageView.contentMode = .center - imageView.tintColor = Asset.Colors.Background.systemBackground.color + imageView.tintColor = Asset.Theme.Mastodon.systemBackground.color imageView.isOpaque = true imageView.layer.masksToBounds = true imageView.layer.cornerRadius = NotificationStatusTableViewCell.actionImageViewSize.width * 0.5 imageView.layer.cornerCurve = .circular imageView.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth - imageView.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor + imageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor imageView.layer.shouldRasterize = true imageView.layer.rasterizationScale = UIScreen.main.scale return imageView @@ -288,7 +288,7 @@ extension NotificationStatusTableViewCell { super.traitCollectionDidChange(previousTraitCollection) resetSeparatorLineLayout() - avatarImageView.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor + avatarImageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor } diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index 012f173d9..70c1067f9 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -115,7 +115,7 @@ extension MastodonPickServerViewController { tableViewTopPaddingView.trailingAnchor.constraint(equalTo: view.trailingAnchor), tableViewTopPaddingViewHeightLayoutConstraint, ]) - tableViewTopPaddingView.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + tableViewTopPaddingView.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color view.addSubview(tableView) NSLayoutConstraint.activate([ @@ -422,7 +422,7 @@ extension MastodonPickServerViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let headerView = UIView() - headerView.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + headerView.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color return headerView } diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCategoriesCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCategoriesCell.swift index 373a90ddf..8207ccdb9 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCategoriesCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCategoriesCell.swift @@ -55,7 +55,7 @@ extension PickServerCategoriesCell { private func _init() { selectionStyle = .none - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color metricView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(metricView) diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift index ca69aef29..41cf8d38b 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift @@ -27,7 +27,7 @@ class PickServerCell: UITableViewCell { let containerView: UIView = { let view = UIView() view.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 10, right: 16) - view.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + view.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color view.translatesAutoresizingMaskIntoConstraints = false return view }() @@ -101,7 +101,7 @@ class PickServerCell: UITableViewCell { let separator: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color view.translatesAutoresizingMaskIntoConstraints = false return view }() diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerLoaderTableViewCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerLoaderTableViewCell.swift index 37135fa9b..1b8264ec3 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerLoaderTableViewCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerLoaderTableViewCell.swift @@ -13,14 +13,14 @@ final class PickServerLoaderTableViewCell: TimelineLoaderTableViewCell { let containerView: UIView = { let view = UIView() view.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 10, right: 16) - view.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + view.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color view.translatesAutoresizingMaskIntoConstraints = false return view }() let seperator: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color view.translatesAutoresizingMaskIntoConstraints = false return view }() diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerSearchCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerSearchCell.swift index 61330452a..fa3e3ae27 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerSearchCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerSearchCell.swift @@ -17,7 +17,7 @@ class PickServerSearchCell: UITableViewCell { private var bgView: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + view.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color view.translatesAutoresizingMaskIntoConstraints = false view.layer.maskedCorners = [ .layerMinXMinYCorner, @@ -108,7 +108,7 @@ class PickServerSearchCell: UITableViewCell { extension PickServerSearchCell { private func _init() { selectionStyle = .none - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color searchTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged) searchTextField.delegate = self diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerTitleCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerTitleCell.swift index 30d24ddc0..2cfd5ec3f 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerTitleCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerTitleCell.swift @@ -35,7 +35,7 @@ extension PickServerTitleCell { private func _init() { selectionStyle = .none - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + backgroundColor = Asset.Theme.Mastodon.systemBackground.color contentView.addSubview(titleLabel) NSLayoutConstraint.activate([ diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift index fd1a3ea6d..6565fbcfa 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift @@ -48,7 +48,7 @@ extension PickServerCategoryView { addSubview(bgView) addSubview(titleLabel) - bgView.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + bgView.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color NSLayoutConstraint.activate([ bgView.leadingAnchor.constraint(equalTo: self.leadingAnchor), diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerEmptyStateView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerEmptyStateView.swift index 6a30751a9..1d2c17c76 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerEmptyStateView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerEmptyStateView.swift @@ -44,7 +44,7 @@ final class PickServerEmptyStateView: UIView { extension PickServerEmptyStateView { private func _init() { - backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift index 1a9043ef2..5ea418e45 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift @@ -84,7 +84,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O button.setImage(image?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate), for: UIControl.State.normal) button.imageView?.tintColor = Asset.Colors.Label.secondary.color - button.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + button.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color button.layer.cornerRadius = 10 button.clipsToBounds = true @@ -99,7 +99,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O icon.backgroundColor = UIColor(dynamicProvider: { collection in switch collection.userInterfaceStyle { case .dark: - return Asset.Colors.Background.secondaryGroupedSystemBackground.color + return Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color default: return .white } @@ -119,7 +119,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O textField.returnKeyType = .next textField.autocapitalizationType = .none textField.autocorrectionType = .no - textField.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + textField.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color textField.textColor = Asset.Colors.Label.primary.color textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Username.placeholder, attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color, @@ -170,7 +170,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O textField.returnKeyType = .next textField.autocapitalizationType = .none textField.autocorrectionType = .no - textField.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + textField.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color textField.textColor = Asset.Colors.Label.primary.color textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.DisplayName.placeholder, attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color, @@ -189,7 +189,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O textField.autocapitalizationType = .none textField.autocorrectionType = .no textField.keyboardType = .emailAddress - textField.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + textField.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color textField.textColor = Asset.Colors.Label.primary.color textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Email.placeholder, attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color, @@ -216,7 +216,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O textField.autocorrectionType = .no textField.keyboardType = .asciiCapable textField.isSecureTextEntry = true - textField.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + textField.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color textField.textColor = Asset.Colors.Label.primary.color textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Password.placeholder, attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color, @@ -248,7 +248,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O textField.returnKeyType = .next // set to "Return" depends on if the last input field or not textField.autocapitalizationType = .none textField.autocorrectionType = .no - textField.backgroundColor = Asset.Colors.Background.secondaryGroupedSystemBackground.color + textField.backgroundColor = Asset.Theme.Mastodon.secondaryGroupedSystemBackground.color textField.textColor = Asset.Colors.Label.primary.color textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Invite.registrationUserInviteRequest, attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color, diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift index fda790913..3faa3a83b 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift @@ -49,7 +49,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency let bottomContainerView: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color return view }() @@ -60,7 +60,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency textView.isSelectable = true textView.isEditable = false textView.isScrollEnabled = false - textView.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + textView.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color return textView }() diff --git a/Mastodon/Scene/Onboarding/Share/OnboardingViewControllerAppearance.swift b/Mastodon/Scene/Onboarding/Share/OnboardingViewControllerAppearance.swift index 0784b51ea..d93c677f8 100644 --- a/Mastodon/Scene/Onboarding/Share/OnboardingViewControllerAppearance.swift +++ b/Mastodon/Scene/Onboarding/Share/OnboardingViewControllerAppearance.swift @@ -20,7 +20,7 @@ extension OnboardingViewControllerAppearance { static var viewBottomPaddingHeight: CGFloat { return 11 } func setupOnboardingAppearance() { - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color setupNavigationBarAppearance() @@ -42,7 +42,7 @@ extension OnboardingViewControllerAppearance { func setupNavigationBarBackgroundView() { let navigationBarBackgroundView: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color return view }() diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift index 509e6739d..86975a8de 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift @@ -76,7 +76,7 @@ final class ProfileHeaderView: UIView { let avatarImageView: UIImageView = { let imageView = FLAnimatedImageView() let placeholderImage = UIImage - .placeholder(size: ProfileHeaderView.avatarImageViewSize, color: Asset.Colors.Background.systemGroupedBackground.color) + .placeholder(size: ProfileHeaderView.avatarImageViewSize, color: Asset.Theme.Mastodon.systemGroupedBackground.color) .af.imageRounded(withCornerRadius: ProfileHeaderView.avatarImageViewCornerRadius, divideRadiusByImageScale: false) imageView.image = placeholderImage return imageView diff --git a/Mastodon/Scene/Profile/ProfileViewModel.swift b/Mastodon/Scene/Profile/ProfileViewModel.swift index 05db1a880..4b2809a3a 100644 --- a/Mastodon/Scene/Profile/ProfileViewModel.swift +++ b/Mastodon/Scene/Profile/ProfileViewModel.swift @@ -441,9 +441,9 @@ extension ProfileViewModel { case .request: return Asset.Colors.brandBlue.color case .pending: return Asset.Colors.brandBlue.color case .following: return Asset.Colors.brandBlue.color - case .muting: return Asset.Colors.Background.alertYellow.color + case .muting: return Asset.Colors.alertYellow.color case .blocked: return Asset.Colors.brandBlue.color - case .blocking: return Asset.Colors.Background.danger.color + case .blocking: return Asset.Colors.danger.color case .suspended: return Asset.Colors.brandBlue.color case .edit: return Asset.Colors.brandBlue.color case .editing: return Asset.Colors.brandBlue.color diff --git a/Mastodon/Scene/Share/View/Container/PlayerContainerView+MediaTypeIndicotorView.swift b/Mastodon/Scene/Share/View/Container/PlayerContainerView+MediaTypeIndicotorView.swift index 3210fadf7..2c0298146 100644 --- a/Mastodon/Scene/Share/View/Container/PlayerContainerView+MediaTypeIndicotorView.swift +++ b/Mastodon/Scene/Share/View/Container/PlayerContainerView+MediaTypeIndicotorView.swift @@ -63,7 +63,7 @@ extension PlayerContainerView { extension PlayerContainerView.MediaTypeIndicatorView { private func _init() { - backgroundColor = Asset.Colors.Background.mediaTypeIndicotor.color + backgroundColor = Asset.Colors.mediaTypeIndicotor.color layoutMargins = UIEdgeInsets(top: 3, left: 13, bottom: 0, right: 6) addSubview(label) diff --git a/Mastodon/Scene/Share/View/Content/PollOptionView.swift b/Mastodon/Scene/Share/View/Content/PollOptionView.swift index 6dcbcd617..db84b95df 100644 --- a/Mastodon/Scene/Share/View/Content/PollOptionView.swift +++ b/Mastodon/Scene/Share/View/Content/PollOptionView.swift @@ -29,7 +29,8 @@ final class PollOptionView: UIView { let checkmarkBackgroundView: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.tertiarySystemBackground.color + // FIXME: missing update trigger + view.backgroundColor = ThemeService.shared.currentTheme.value.tertiarySystemBackgroundColor return view }() diff --git a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift index ee9ac3438..5e5ac88d7 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/ThreadReplyLoaderTableViewCell.swift @@ -58,7 +58,6 @@ extension ThreadReplyLoaderTableViewCell { func _init() { selectionStyle = .none - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color loadMoreButton.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(loadMoreButton) @@ -124,7 +123,7 @@ extension ThreadReplyLoaderTableViewCell { } private func setupBackgroundColor(theme: Theme) { - loadMoreButton.backgroundColor = theme.secondarySystemGroupedBackgroundColor + backgroundColor = theme.systemGroupedBackgroundColor } } diff --git a/Mastodon/Scene/SuggestionAccount/SuggestionAccountViewController.swift b/Mastodon/Scene/SuggestionAccount/SuggestionAccountViewController.swift index 3d66aed33..d27c1fbe5 100644 --- a/Mastodon/Scene/SuggestionAccount/SuggestionAccountViewController.swift +++ b/Mastodon/Scene/SuggestionAccount/SuggestionAccountViewController.swift @@ -32,7 +32,7 @@ class SuggestionAccountViewController: UIViewController, NeedsDependency { lazy var tableHeader: UIView = { let view = UIView() - view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + view.backgroundColor = ThemeService.shared.currentTheme.value.systemGroupedBackgroundColor view.frame = CGRect(origin: .zero, size: CGSize(width: tableView.frame.width, height: 156)) return view }() @@ -67,12 +67,12 @@ extension SuggestionAccountViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor + 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.view.backgroundColor = theme.systemBackgroundColor + self.setupBackgroundColor(theme: theme) } .store(in: &disposeBag) @@ -146,6 +146,11 @@ extension SuggestionAccountViewController { tableView.tableHeaderView = tableHeader } + + private func setupBackgroundColor(theme: Theme) { + view.backgroundColor = theme.systemBackgroundColor + tableHeader.backgroundColor = theme.systemGroupedBackgroundColor + } } extension SuggestionAccountViewController: UICollectionViewDelegateFlowLayout { diff --git a/Mastodon/Service/ThemeService/MastodonTheme.swift b/Mastodon/Service/ThemeService/MastodonTheme.swift index 6476d5a74..2418877ff 100644 --- a/Mastodon/Service/ThemeService/MastodonTheme.swift +++ b/Mastodon/Service/ThemeService/MastodonTheme.swift @@ -33,4 +33,5 @@ struct MastodonTheme: Theme { let contentWarningOverlayBackgroundColor = Asset.Theme.Mastodon.contentWarningOverlayBackground.color let profileFieldCollectionViewBackgroundColor = Asset.Theme.Mastodon.profileFieldCollectionViewBackground.color + let composeToolbarBackgroundColor = Asset.Theme.Mastodon.composeToolbarBackground.color } diff --git a/Mastodon/Service/ThemeService/SystemTheme.swift b/Mastodon/Service/ThemeService/SystemTheme.swift index 4a7a1f963..b91ba1caf 100644 --- a/Mastodon/Service/ThemeService/SystemTheme.swift +++ b/Mastodon/Service/ThemeService/SystemTheme.swift @@ -33,4 +33,5 @@ struct SystemTheme: Theme { let contentWarningOverlayBackgroundColor = Asset.Theme.System.contentWarningOverlayBackground.color let profileFieldCollectionViewBackgroundColor = Asset.Theme.System.profileFieldCollectionViewBackground.color + let composeToolbarBackgroundColor = Asset.Theme.System.composeToolbarBackground.color } diff --git a/Mastodon/Service/ThemeService/Theme.swift b/Mastodon/Service/ThemeService/Theme.swift index c9378e878..29f90db8d 100644 --- a/Mastodon/Service/ThemeService/Theme.swift +++ b/Mastodon/Service/ThemeService/Theme.swift @@ -8,6 +8,7 @@ import UIKit public protocol Theme { + var systemBackgroundColor: UIColor { get } var secondarySystemBackgroundColor: UIColor { get } var tertiarySystemBackgroundColor: UIColor { get } @@ -33,6 +34,7 @@ public protocol Theme { var contentWarningOverlayBackgroundColor: UIColor { get } var profileFieldCollectionViewBackgroundColor: UIColor { get } + var composeToolbarBackgroundColor: UIColor { get } } diff --git a/ShareActionExtension/Scene/ShareViewController.swift b/ShareActionExtension/Scene/ShareViewController.swift index a3cef66d7..e72c46196 100644 --- a/ShareActionExtension/Scene/ShareViewController.swift +++ b/ShareActionExtension/Scene/ShareViewController.swift @@ -49,11 +49,7 @@ class ShareViewController: UIViewController { let viewSafeAreaDidChange = PassthroughSubject() let composeToolbarView = ComposeToolbarView() var composeToolbarViewBottomLayoutConstraint: NSLayoutConstraint! - let composeToolbarBackgroundView: UIView = { - let view = UIView() - view.backgroundColor = Asset.Scene.Compose.toolbarBackground.color - return view - }() + let composeToolbarBackgroundView = UIView() } extension ShareViewController { @@ -61,7 +57,16 @@ extension ShareViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Asset.Colors.Background.systemBackground.color + navigationController?.presentationController?.delegate = self + + 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) navigationItem.leftBarButtonItem = cancelBarButtonItem viewModel.isBusy @@ -203,10 +208,37 @@ extension ShareViewController { } +extension ShareViewController { + private func setupBackgroundColor(theme: Theme) { + view.backgroundColor = theme.systemElevatedBackgroundColor + viewModel.composeViewModel.backgroundColor = theme.systemElevatedBackgroundColor + composeToolbarBackgroundView.backgroundColor = theme.composeToolbarBackgroundColor + + let barAppearance = UINavigationBarAppearance() + barAppearance.configureWithDefaultBackground() + barAppearance.backgroundColor = theme.navigationBarBackgroundColor + navigationItem.standardAppearance = barAppearance + navigationItem.compactAppearance = barAppearance + navigationItem.scrollEdgeAppearance = barAppearance + } + + private func showDismissConfirmAlertController() { + let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) // can not use alert in extension + let discardAction = UIAlertAction(title: L10n.Common.Controls.Actions.discard, style: .destructive) { _ in + self.extensionContext?.cancelRequest(withError: ShareViewModel.ShareError.userCancelShare) + } + alertController.addAction(discardAction) + let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .cancel, handler: nil) + alertController.addAction(okAction) + self.present(alertController, animated: true, completion: nil) + } +} + extension ShareViewController { @objc private func cancelBarButtonItemPressed(_ sender: UIBarButtonItem) { logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - extensionContext?.cancelRequest(withError: ShareViewModel.ShareError.userCancelShare) + + showDismissConfirmAlertController() } @objc private func publishBarButtonItemPressed(_ sender: UIBarButtonItem) { @@ -267,5 +299,23 @@ extension ShareViewController: ComposeToolbarViewDelegate { viewModel.selectedStatusVisibility.value = type } +} + +// MARK: - UIAdaptivePresentationControllerDelegate +extension ShareViewController: UIAdaptivePresentationControllerDelegate { + + func presentationControllerShouldDismiss(_ presentationController: UIPresentationController) -> Bool { + return viewModel.shouldDismiss.value + } + + func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) { + os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) + showDismissConfirmAlertController() + + } + + func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { + os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) + } } diff --git a/ShareActionExtension/Scene/ShareViewModel.swift b/ShareActionExtension/Scene/ShareViewModel.swift index 060181ae5..62102e660 100644 --- a/ShareActionExtension/Scene/ShareViewModel.swift +++ b/ShareActionExtension/Scene/ShareViewModel.swift @@ -37,6 +37,7 @@ final class ShareViewModel { let isPublishing = CurrentValueSubject(false) let isBusy = CurrentValueSubject(true) let isValid = CurrentValueSubject(false) + let shouldDismiss = CurrentValueSubject(true) let composeViewModel = ComposeViewModel() let characterCount = CurrentValueSubject(0) @@ -134,6 +135,11 @@ final class ShareViewModel { // bind compose bar button item UI state let isComposeContentEmpty = composeViewModel.$statusContent .map { $0.isEmpty } + + isComposeContentEmpty + .assign(to: \.value, on: shouldDismiss) + .store(in: &disposeBag) + let isComposeContentValid = composeViewModel.$characterCount .map { characterCount -> Bool in return characterCount <= ShareViewModel.composeContentLimit diff --git a/ShareActionExtension/Scene/View/ComposeToolbarView.swift b/ShareActionExtension/Scene/View/ComposeToolbarView.swift index e938ebfa2..d161e96fe 100644 --- a/ShareActionExtension/Scene/View/ComposeToolbarView.swift +++ b/ShareActionExtension/Scene/View/ComposeToolbarView.swift @@ -67,7 +67,14 @@ final class ComposeToolbarView: UIView { extension ComposeToolbarView { private func _init() { - backgroundColor = Asset.Scene.Compose.toolbarBackground.color + 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) let stackView = UIStackView() stackView.axis = .horizontal @@ -127,6 +134,12 @@ extension ComposeToolbarView { } +extension ComposeToolbarView { + private func setupBackgroundColor(theme: Theme) { + backgroundColor = theme.composeToolbarBackgroundColor + } +} + extension ComposeToolbarView { enum MediaSelectionType: String { case camera diff --git a/ShareActionExtension/Scene/View/ComposeView.swift b/ShareActionExtension/Scene/View/ComposeView.swift index f65e35b45..25adf4c5a 100644 --- a/ShareActionExtension/Scene/View/ComposeView.swift +++ b/ShareActionExtension/Scene/View/ComposeView.swift @@ -29,7 +29,7 @@ public struct ComposeView: View { .padding(EdgeInsets(top: 6, leading: horizontalMargin, bottom: 6, trailing: horizontalMargin)) .background(viewModel.contentWarningBackgroundColor) .transition(.opacity) - .listRow() + .listRow(backgroundColor: Color(viewModel.backgroundColor)) } // Author @@ -39,7 +39,7 @@ public struct ComposeView: View { username: viewModel.authorUsername ) .padding(EdgeInsets(top: 20, leading: horizontalMargin, bottom: 16, trailing: horizontalMargin)) - .listRow() + .listRow(backgroundColor: Color(viewModel.backgroundColor)) // Editor StatusEditorView( @@ -53,7 +53,7 @@ public struct ComposeView: View { .frame(width: statusEditorViewWidth) .frame(minHeight: 100) .padding(EdgeInsets(top: 0, leading: horizontalMargin, bottom: 0, trailing: horizontalMargin)) - .listRow() + .listRow(backgroundColor: Color(viewModel.backgroundColor)) // Attachments ForEach(viewModel.attachmentViewModels) { attachmentViewModel in @@ -78,12 +78,12 @@ public struct ComposeView: View { } .padding(EdgeInsets(top: 16, leading: horizontalMargin, bottom: 0, trailing: horizontalMargin)) .fixedSize(horizontal: false, vertical: true) - .listRow() + .listRow(backgroundColor: Color(viewModel.backgroundColor)) // bottom padding Color.clear .frame(height: viewModel.toolbarHeight + 20) - .listRow() + .listRow(backgroundColor: Color(viewModel.backgroundColor)) } // end List .introspectTableView(customize: { tableView in // tableView.keyboardDismissMode = .onDrag @@ -97,9 +97,13 @@ public struct ComposeView: View { var frame = frame frame.size.width = frame.width - 2 * horizontalMargin statusEditorViewWidth = frame.width - } - } - } + } // end List + .introspectTableView(customize: { tableView in + tableView.backgroundColor = .clear + }) + .background(Color(viewModel.backgroundColor).ignoresSafeArea()) + } // end GeometryReader + } // end body } struct ComposeListViewFramePreferenceKey: PreferenceKey { @@ -108,10 +112,10 @@ struct ComposeListViewFramePreferenceKey: PreferenceKey { } extension View { - func listRow() -> some View { + func listRow(backgroundColor: Color) -> some View { self.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) .listRowInsets(EdgeInsets(top: -1, leading: -1, bottom: -1, trailing: -1)) - .background(Color(.systemBackground)) + .background(backgroundColor) } } diff --git a/ShareActionExtension/Scene/View/ComposeViewModel.swift b/ShareActionExtension/Scene/View/ComposeViewModel.swift index 8d60481dd..88c2b896f 100644 --- a/ShareActionExtension/Scene/View/ComposeViewModel.swift +++ b/ShareActionExtension/Scene/View/ComposeViewModel.swift @@ -16,6 +16,7 @@ class ComposeViewModel: ObservableObject { @Published var authentication: MastodonAuthentication? + @Published var backgroundColor: UIColor = .clear @Published var toolbarHeight: CGFloat = 0 @Published var viewDidAppear = false diff --git a/ShareActionExtension/Scene/View/StatusEditorView.swift b/ShareActionExtension/Scene/View/StatusEditorView.swift index 79fedc00a..c945874e6 100644 --- a/ShareActionExtension/Scene/View/StatusEditorView.swift +++ b/ShareActionExtension/Scene/View/StatusEditorView.swift @@ -43,6 +43,7 @@ public struct StatusEditorView: UIViewRepresentable { textView.textColor = .label textView.keyboardType = keyboardType textView.delegate = context.coordinator + textView.backgroundColor = .clear textView.translatesAutoresizingMaskIntoConstraints = false let widthLayoutConstraint = textView.widthAnchor.constraint(equalToConstant: 100)