diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index d5b0a1e96..e474e61cc 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,12 +7,12 @@ AppShared.xcscheme_^#shared#^_ orderHint - 31 + 35 CoreDataStack.xcscheme_^#shared#^_ orderHint - 30 + 36 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -37,7 +37,7 @@ MastodonIntent.xcscheme_^#shared#^_ orderHint - 29 + 38 MastodonIntents.xcscheme_^#shared#^_ @@ -52,12 +52,12 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 3 + 4 ShareActionExtension.xcscheme_^#shared#^_ orderHint - 28 + 37 SuppressBuildableAutocreation diff --git a/Mastodon/Generated/Assets.swift b/Mastodon/Generated/Assets.swift index 0fe48777f..f3ef1088e 100644 --- a/Mastodon/Generated/Assets.swift +++ b/Mastodon/Generated/Assets.swift @@ -111,9 +111,11 @@ internal enum Asset { } } internal enum Settings { - internal static let appearanceAutomatic = ImageAsset(name: "Settings/appearance.automatic") - internal static let appearanceDark = ImageAsset(name: "Settings/appearance.dark") - internal static let appearanceLight = ImageAsset(name: "Settings/appearance.light") + internal static let blackAuto = ImageAsset(name: "Settings/black.auto") + internal static let black = ImageAsset(name: "Settings/black") + internal static let darkAuto = ImageAsset(name: "Settings/dark.auto") + internal static let dark = ImageAsset(name: "Settings/dark") + internal static let light = ImageAsset(name: "Settings/light") } internal enum Theme { internal enum Mastodon { diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/iPhone 11 Pro _ X - 1.pdf b/Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/iPhone 11 Pro _ X - 1.pdf deleted file mode 100644 index 868d8d8b9..000000000 Binary files a/Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/iPhone 11 Pro _ X - 1.pdf and /dev/null differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/iPhone 11 Pro _ X - 1 (2).pdf b/Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/iPhone 11 Pro _ X - 1 (2).pdf deleted file mode 100644 index a214d2853..000000000 Binary files a/Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/iPhone 11 Pro _ X - 1 (2).pdf and /dev/null differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/iPhone 11 Pro _ X - 1 (1).pdf b/Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/iPhone 11 Pro _ X - 1 (1).pdf deleted file mode 100644 index 2b8b869b0..000000000 Binary files a/Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/iPhone 11 Pro _ X - 1 (1).pdf and /dev/null differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Contents.json similarity index 71% rename from Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Contents.json index 75da4a571..909d1ad2b 100644 --- a/Mastodon/Resources/Assets.xcassets/Settings/appearance.automatic.imageset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "iPhone 11 Pro _ X - 1.pdf", + "filename" : "Mixed_Black_Light.png", "idiom" : "universal" } ], diff --git a/Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Mixed_Black_Light.png b/Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Mixed_Black_Light.png new file mode 100644 index 000000000..d27078d5d Binary files /dev/null and b/Mastodon/Resources/Assets.xcassets/Settings/black.auto.imageset/Mixed_Black_Light.png differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Contents.json similarity index 70% rename from Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Contents.json index 86e635c39..23975c38d 100644 --- a/Mastodon/Resources/Assets.xcassets/Settings/appearance.light.imageset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "iPhone 11 Pro _ X - 1 (1).pdf", + "filename" : "Home Black.png", "idiom" : "universal" } ], diff --git a/Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Home Black.png b/Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Home Black.png new file mode 100644 index 000000000..b7348ae9b Binary files /dev/null and b/Mastodon/Resources/Assets.xcassets/Settings/black.imageset/Home Black.png differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Contents.json similarity index 70% rename from Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/Contents.json rename to Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Contents.json index 6ca47e403..3b7f153c7 100644 --- a/Mastodon/Resources/Assets.xcassets/Settings/appearance.dark.imageset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "iPhone 11 Pro _ X - 1 (2).pdf", + "filename" : "Mixed_Dark_Light.png", "idiom" : "universal" } ], diff --git a/Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Mixed_Dark_Light.png b/Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Mixed_Dark_Light.png new file mode 100644 index 000000000..450675915 Binary files /dev/null and b/Mastodon/Resources/Assets.xcassets/Settings/dark.auto.imageset/Mixed_Dark_Light.png differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Contents.json new file mode 100644 index 000000000..01bdd059f --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Home Dark.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Home Dark.png b/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Home Dark.png new file mode 100644 index 000000000..46926d865 Binary files /dev/null and b/Mastodon/Resources/Assets.xcassets/Settings/dark.imageset/Home Dark.png differ diff --git a/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Contents.json new file mode 100644 index 000000000..beb5cfcfd --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Home Light.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Home Light.png b/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Home Light.png new file mode 100644 index 000000000..cafff0bb5 Binary files /dev/null and b/Mastodon/Resources/Assets.xcassets/Settings/light.imageset/Home Light.png differ diff --git a/Mastodon/Scene/Settings/View/AppearanceView.swift b/Mastodon/Scene/Settings/View/AppearanceView.swift index dfac265cd..e761d46e7 100644 --- a/Mastodon/Scene/Settings/View/AppearanceView.swift +++ b/Mastodon/Scene/Settings/View/AppearanceView.swift @@ -10,6 +10,9 @@ import UIKit class AppearanceView: UIView { lazy var imageView: UIImageView = { let view = UIImageView() + view.layer.masksToBounds = true + view.layer.cornerRadius = 14 + view.layer.cornerCurve = .continuous // accessibility view.accessibilityIgnoresInvertColors = true return view diff --git a/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift b/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift index d1785b7b5..c4eb998e4 100644 --- a/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift +++ b/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift @@ -15,26 +15,26 @@ protocol SettingsAppearanceTableViewCellDelegate: AnyObject { class SettingsAppearanceTableViewCell: UITableViewCell { var disposeBag = Set() + + static let spacing: CGFloat = 18 weak var delegate: SettingsAppearanceTableViewCellDelegate? var appearance: SettingsItem.AppearanceMode = .automatic lazy var stackView: UIStackView = { let view = UIStackView() - view.isLayoutMarginsRelativeArrangement = true - view.layoutMargins = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) view.axis = .horizontal view.distribution = .fillEqually - view.spacing = 18 + view.spacing = SettingsAppearanceTableViewCell.spacing view.translatesAutoresizingMaskIntoConstraints = false return view }() - let automatic = AppearanceView(image: Asset.Settings.appearanceAutomatic.image, + let automatic = AppearanceView(image: Asset.Settings.darkAuto.image, title: L10n.Scene.Settings.Section.Appearance.automatic) - let light = AppearanceView(image: Asset.Settings.appearanceLight.image, + let light = AppearanceView(image: Asset.Settings.light.image, title: L10n.Scene.Settings.Section.Appearance.light) - let dark = AppearanceView(image: Asset.Settings.appearanceDark.image, + let dark = AppearanceView(image: Asset.Settings.dark.image, title: L10n.Scene.Settings.Section.Appearance.dark) lazy var automaticTap: UITapGestureRecognizer = { @@ -80,6 +80,8 @@ class SettingsAppearanceTableViewCell: UITableViewCell { subview.removeFromSuperview() } } + + setupAsset(theme: ThemeService.shared.currentTheme.value) } func update(with data: SettingsItem.AppearanceMode) { @@ -115,10 +117,36 @@ class SettingsAppearanceTableViewCell: UITableViewCell { NSLayoutConstraint.activate([ stackView.topAnchor.constraint(equalTo: contentView.topAnchor), - stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + stackView.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor), stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + stackView.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor), ]) + + setupAsset(theme: ThemeService.shared.currentTheme.value) + ThemeService.shared.currentTheme + .receive(on: DispatchQueue.main) + .sink { [weak self] theme in + guard let self = self else { return } + self.setupAsset(theme: theme) + } + .store(in: &disposeBag) + } + + private func setupAsset(theme: Theme) { + let aspectRatio = Asset.Settings.light.image.size + let width = floor(frame.width - 2 * SettingsAppearanceTableViewCell.spacing) / 3 + let height = width / aspectRatio.width * aspectRatio.height + let size = CGSize(width: width, height: height) + + light.imageView.image = Asset.Settings.light.image.af.imageAspectScaled(toFill: size, scale: UIScreen.main.scale) + switch theme.themeName { + case .mastodon: + automatic.imageView.image = Asset.Settings.darkAuto.image.af.imageAspectScaled(toFill: size, scale: UIScreen.main.scale) + dark.imageView.image = Asset.Settings.dark.image.af.imageAspectScaled(toFill: size, scale: UIScreen.main.scale) + case .system: + automatic.imageView.image = Asset.Settings.blackAuto.image.af.imageAspectScaled(toFill: size, scale: UIScreen.main.scale) + dark.imageView.image = Asset.Settings.black.image.af.imageAspectScaled(toFill: size, scale: UIScreen.main.scale) + } } // MARK: - Actions diff --git a/Mastodon/Service/ThemeService/MastodonTheme.swift b/Mastodon/Service/ThemeService/MastodonTheme.swift index 60093f04d..dbf2324cd 100644 --- a/Mastodon/Service/ThemeService/MastodonTheme.swift +++ b/Mastodon/Service/ThemeService/MastodonTheme.swift @@ -8,6 +8,9 @@ import UIKit struct MastodonTheme: Theme { + + let themeName: ThemeName = .mastodon + let systemBackgroundColor = Asset.Theme.Mastodon.systemBackground.color let secondarySystemBackgroundColor = Asset.Theme.Mastodon.secondarySystemBackground.color let tertiarySystemBackgroundColor = Asset.Theme.Mastodon.tertiarySystemBackground.color diff --git a/Mastodon/Service/ThemeService/SystemTheme.swift b/Mastodon/Service/ThemeService/SystemTheme.swift index 0be42c6ed..3a8ddd2d8 100644 --- a/Mastodon/Service/ThemeService/SystemTheme.swift +++ b/Mastodon/Service/ThemeService/SystemTheme.swift @@ -8,6 +8,9 @@ import UIKit struct SystemTheme: Theme { + + let themeName: ThemeName = .system + let systemBackgroundColor = Asset.Theme.System.systemBackground.color let secondarySystemBackgroundColor = Asset.Theme.System.secondarySystemBackground.color let tertiarySystemBackgroundColor = Asset.Theme.System.tertiarySystemBackground.color diff --git a/Mastodon/Service/ThemeService/Theme.swift b/Mastodon/Service/ThemeService/Theme.swift index 15def6f53..4074e0904 100644 --- a/Mastodon/Service/ThemeService/Theme.swift +++ b/Mastodon/Service/ThemeService/Theme.swift @@ -8,6 +8,8 @@ import UIKit public protocol Theme { + + var themeName: ThemeName { get } var systemBackgroundColor: UIColor { get } var secondarySystemBackgroundColor: UIColor { get }