Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,6 @@ extension ComposeContentViewController: ComposeContentToolbarViewDelegate {
toolbarItemDidPressed action: ComposeContentToolbarView.ViewModel.Action
) {
switch action {
case .attachment:
assertionFailure()
case .poll:
self.viewModel.isPollActive.toggle()
case .emoji:
Expand All @@ -549,8 +547,6 @@ extension ComposeContentViewController: ComposeContentToolbarViewDelegate {
self.viewModel.setContentTextViewFirstResponderIfNeeds()
}
}
case .visibility, .language:
assertionFailure()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,9 @@ extension ComposeContentToolbarView {

extension ComposeContentToolbarView.ViewModel {
enum Action: CaseIterable {
case attachment
case poll
case emoji
case contentWarning
case visibility
case language

var activeImage: UIImage {
switch self {
case .attachment:
return Asset.Scene.Compose.media.image.withRenderingMode(.alwaysTemplate)
case .poll:
return Asset.Scene.Compose.pollFill.image.withRenderingMode(.alwaysTemplate)
case .emoji:
return Asset.Scene.Compose.emojiFill.image.withRenderingMode(.alwaysTemplate)
case .contentWarning:
return Asset.Scene.Compose.chatWarningFill.image.withRenderingMode(.alwaysTemplate)
case .visibility:
return Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate)
case .language:
fatalError("Language’s active image is never accessed")
}
}

var inactiveImage: UIImage {
switch self {
case .attachment:
return Asset.Scene.Compose.media.image.withRenderingMode(.alwaysTemplate)
case .poll:
return Asset.Scene.Compose.poll.image.withRenderingMode(.alwaysTemplate)
case .emoji:
return Asset.Scene.Compose.emoji.image.withRenderingMode(.alwaysTemplate)
case .contentWarning:
return Asset.Scene.Compose.chatWarning.image.withRenderingMode(.alwaysTemplate)
case .visibility:
return Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate)
case .language:
fatalError("Language’s inactive image is never accessed")
}
}
}

enum AttachmentAction: CaseIterable {
Expand All @@ -119,37 +82,3 @@ extension ComposeContentToolbarView.ViewModel {
}
}
}

extension ComposeContentToolbarView.ViewModel {
func image(for action: Action) -> UIImage {
switch action {
case .poll:
return isPollActive ? action.activeImage : action.inactiveImage
case .emoji:
return isEmojiActive ? action.activeImage : action.inactiveImage
case .contentWarning:
return isContentWarningActive ? action.activeImage : action.inactiveImage
case .language:
fatalError("Language’s image is never accessed")
default:
return action.inactiveImage
}
}

func label(for action: Action) -> String {
switch action {
case .attachment:
return L10n.Scene.Compose.Accessibility.appendAttachment
case .poll:
return isPollActive ? L10n.Scene.Compose.Accessibility.removePoll : L10n.Scene.Compose.Accessibility.appendPoll
case .emoji:
return L10n.Scene.Compose.Accessibility.customEmojiPicker
case .contentWarning:
return isContentWarningActive ? L10n.Scene.Compose.Accessibility.disableContentWarning : L10n.Scene.Compose.Accessibility.enableContentWarning
case .visibility:
return L10n.Scene.Compose.Accessibility.postVisibilityMenu
case .language:
return "[[language]]"
}
}
}
Loading