Skip to content

Commit

Permalink
Re-enable option to post unlisted/"Quiet public" (#1271)
Browse files Browse the repository at this point in the history
* Add unlisted as option to post (#250)

* Replace menu-icons with SF Symbols to match other platforms (#250)

* Replace earth with SF-symbol (#250)

* Use SF Symbols for visibility (#250)
  • Loading branch information
zeitschlag authored Apr 12, 2024
1 parent a979287 commit 6b32e5e
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}()

Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
5 changes: 0 additions & 5 deletions MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,12 @@ public enum Asset {
public static let retry = ImageAsset(name: "Scene/Compose/Attachment/retry")
public static let stop = ImageAsset(name: "Scene/Compose/Attachment/stop")
}
public static let earth = ImageAsset(name: "Scene/Compose/Earth")
public static let mention = ImageAsset(name: "Scene/Compose/Mention")
public static let more = ImageAsset(name: "Scene/Compose/More")
public static let people = ImageAsset(name: "Scene/Compose/People")
public static let buttonTint = ColorAsset(name: "Scene/Compose/button.tint")
public static let chatWarningFill = ImageAsset(name: "Scene/Compose/chat.warning.fill")
public static let chatWarning = ImageAsset(name: "Scene/Compose/chat.warning")
public static let emojiFill = ImageAsset(name: "Scene/Compose/emoji.fill")
public static let emoji = ImageAsset(name: "Scene/Compose/emoji")
public static let media = ImageAsset(name: "Scene/Compose/media")
public static let peopleAdd = ImageAsset(name: "Scene/Compose/people.add")
public static let pollFill = ImageAsset(name: "Scene/Compose/poll.fill")
public static let poll = ImageAsset(name: "Scene/Compose/poll")
public static let questionmarkCircle = ImageAsset(name: "Scene/Compose/questionmark.circle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import Foundation
import UIKit
import MastodonLocalization

extension Mastodon.Entity {

Expand Down Expand Up @@ -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
Expand All @@ -121,7 +123,7 @@ extension Mastodon.Entity.Status {
default: self = ._other(rawValue)
}
}

public var rawValue: String {
switch self {
case .public: return "public"
Expand All @@ -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)
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Mastodon.Entity.Status.Visibility.unlisted.image
case .private: asset = Mastodon.Entity.Status.Visibility.private.image
case .direct: asset = Mastodon.Entity.Status.Visibility.direct.image
case ._other: asset = Mastodon.Entity.Status.Visibility._other("").image
}
return asset.image.withRenderingMode(.alwaysTemplate)
return asset.withRenderingMode(.alwaysTemplate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ extension ComposeContentToolbarView {
@Published var suggestedLanguages: [String] = []
@Published var highConfidenceSuggestedLanguage: String?
@Published var visibility: Mastodon.Entity.Status.Visibility = .public
var allVisibilities: [Mastodon.Entity.Status.Visibility] {
return [.public, .private, .direct]
}
let allVisibilities = [Mastodon.Entity.Status.Visibility.public, .unlisted, .private, .direct]
@Published var isVisibilityButtonEnabled = false
@Published var isPollActive = false
@Published var isEmojiActive = false
Expand Down Expand Up @@ -67,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")
}
Expand All @@ -84,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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import UIKit
import MastodonAsset
import MastodonLocalization
import MastodonSDK
Expand Down Expand Up @@ -219,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 Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate)
case .unlisted: return Asset.Scene.Compose.people.image.withRenderingMode(.alwaysTemplate)
case .private: return Asset.Scene.Compose.peopleAdd.image.withRenderingMode(.alwaysTemplate)
case .direct: return Asset.Scene.Compose.mention.image.withRenderingMode(.alwaysTemplate)
case ._other: return Asset.Scene.Compose.more.image.withRenderingMode(.alwaysTemplate)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MetaTextKit
import MastodonAsset
import MastodonCore
import MastodonLocalization
import MastodonSDK

public class StatusAuthorView: UIStackView {
private var _disposeBag = Set<AnyCancellable>() // which lifetime same to view scope
Expand Down Expand Up @@ -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
}()

Expand Down

0 comments on commit 6b32e5e

Please sign in to comment.