diff --git a/Mastodon/Scene/Notification/NotificationView/NotificationView.swift b/Mastodon/Scene/Notification/NotificationView/NotificationView.swift index a4ccb2dd34..04bb07078b 100644 --- a/Mastodon/Scene/Notification/NotificationView/NotificationView.swift +++ b/Mastodon/Scene/Notification/NotificationView/NotificationView.swift @@ -13,6 +13,7 @@ import MastodonCore import MastodonAsset import MastodonLocalization import MastodonUI +import MastodonSDK public protocol NotificationViewDelegate: AnyObject { func notificationView(_ notificationView: NotificationView, authorAvatarButtonDidPressed button: AvatarButton) @@ -93,7 +94,7 @@ public final class NotificationView: UIView { let imageView = UIImageView() imageView.tintColor = Asset.Colors.Label.secondary.color imageView.contentMode = .scaleAspectFit - imageView.image = Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate) + imageView.image = Mastodon.Entity.Status.Visibility.public.image.withRenderingMode(.alwaysTemplate) return imageView }() diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Contents.json deleted file mode 100644 index 04f310f98c..0000000000 --- a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "Earth.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "preserves-vector-representation" : true - } -} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Earth.pdf b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Earth.pdf deleted file mode 100644 index 4f6b948a30..0000000000 Binary files a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/Earth.imageset/Earth.pdf and /dev/null differ diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift index cf401e9607..7c9edcb16d 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift @@ -6,6 +6,8 @@ // import Foundation +import UIKit +import MastodonLocalization extension Mastodon.Entity { @@ -109,9 +111,9 @@ extension Mastodon.Entity.Status { case unlisted case `private` case direct - + case _other(String) - + public init?(rawValue: String) { switch rawValue { case "public": self = .public @@ -121,7 +123,7 @@ extension Mastodon.Entity.Status { default: self = ._other(rawValue) } } - + public var rawValue: String { switch self { case .public: return "public" @@ -131,6 +133,27 @@ extension Mastodon.Entity.Status { case ._other(let value): return value } } + + public var title: String { + switch self { + case .public: return L10n.Scene.Compose.Visibility.public + case .unlisted: return L10n.Scene.Compose.Visibility.unlisted + case .private: return L10n.Scene.Compose.Visibility.private + case .direct: return L10n.Scene.Compose.Visibility.direct + case ._other(let value): return value + } + } + + public var image: UIImage { + switch self { + case .public: return UIImage(systemName: "globe.europe.africa")!.withRenderingMode(.alwaysTemplate) + case .unlisted: return UIImage(systemName: "moon")!.withRenderingMode(.alwaysTemplate) + case .private: return UIImage(systemName: "lock")!.withRenderingMode(.alwaysTemplate) + case .direct: return UIImage(systemName: "at")!.withRenderingMode(.alwaysTemplate) + case ._other: return UIImage(systemName: "ellipsis")!.withRenderingMode(.alwaysTemplate) + } + } + } } diff --git a/MastodonSDK/Sources/MastodonUI/Extension/MastodonVisibility+Image.swift b/MastodonSDK/Sources/MastodonUI/Extension/MastodonVisibility+Image.swift index 05dcd5e18e..ce5ecc3b01 100644 --- a/MastodonSDK/Sources/MastodonUI/Extension/MastodonVisibility+Image.swift +++ b/MastodonSDK/Sources/MastodonUI/Extension/MastodonVisibility+Image.swift @@ -3,18 +3,19 @@ import UIKit import CoreDataStack import MastodonAsset +import MastodonSDK extension MastodonVisibility { public var image: UIImage { - let asset: ImageAsset + let asset: UIImage switch self { - case .public: asset = Asset.Scene.Compose.earth - case .unlisted: asset = Asset.Scene.Compose.people - case .private: asset = Asset.Scene.Compose.peopleAdd - case .direct: asset = Asset.Scene.Compose.mention - case ._other: asset = Asset.Scene.Compose.questionmarkCircle + case .public: asset = Mastodon.Entity.Status.Visibility.public.image + case .unlisted: asset = Asset.Scene.Compose.people.image + case .private: asset = Asset.Scene.Compose.peopleAdd.image + case .direct: asset = Asset.Scene.Compose.mention.image + case ._other: asset = Asset.Scene.Compose.questionmarkCircle.image } - return asset.image.withRenderingMode(.alwaysTemplate) + return asset.withRenderingMode(.alwaysTemplate) } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift index 9fec77eae2..e35ad7b774 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView+ViewModel.swift @@ -65,7 +65,7 @@ extension ComposeContentToolbarView.ViewModel { case .contentWarning: return Asset.Scene.Compose.chatWarningFill.image.withRenderingMode(.alwaysTemplate) case .visibility: - return Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate) + return Mastodon.Entity.Status.Visibility.public.image.withRenderingMode(.alwaysTemplate) case .language: fatalError("Language’s active image is never accessed") } @@ -82,7 +82,7 @@ extension ComposeContentToolbarView.ViewModel { case .contentWarning: return Asset.Scene.Compose.chatWarning.image.withRenderingMode(.alwaysTemplate) case .visibility: - return Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate) + return Mastodon.Entity.Status.Visibility.public.image case .language: fatalError("Language’s inactive image is never accessed") } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift index 107d2484d1..5ed966d029 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Toolbar/ComposeContentToolbarView.swift @@ -220,23 +220,4 @@ extension ComposeContentToolbarView { } extension Mastodon.Entity.Status.Visibility { - fileprivate var title: String { - switch self { - case .public: return L10n.Scene.Compose.Visibility.public - case .unlisted: return L10n.Scene.Compose.Visibility.unlisted - case .private: return L10n.Scene.Compose.Visibility.private - case .direct: return L10n.Scene.Compose.Visibility.direct - case ._other(let value): return value - } - } - - fileprivate var image: UIImage { - switch self { - case .public: return UIImage(systemName: "globe.europe.africa")!.withRenderingMode(.alwaysTemplate) - case .unlisted: return UIImage(systemName: "moon")!.withRenderingMode(.alwaysTemplate) - case .private: return UIImage(systemName: "lock")!.withRenderingMode(.alwaysTemplate) - case .direct: return UIImage(systemName: "at")!.withRenderingMode(.alwaysTemplate) - case ._other: return UIImage(systemName: "ellipsis")!.withRenderingMode(.alwaysTemplate) - } - } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift index db34f081cb..f5944c3ae9 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift @@ -12,6 +12,7 @@ import MetaTextKit import MastodonAsset import MastodonCore import MastodonLocalization +import MastodonSDK public class StatusAuthorView: UIStackView { private var _disposeBag = Set() // which lifetime same to view scope @@ -49,7 +50,7 @@ public class StatusAuthorView: UIStackView { let imageView = UIImageView() imageView.tintColor = Asset.Colors.Label.secondary.color imageView.contentMode = .scaleAspectFit - imageView.image = Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate) + imageView.image = Mastodon.Entity.Status.Visibility.public.image return imageView }()