Re-add pointer effects to Compose toolbar buttons

This commit is contained in:
Shadowfacts 2022-11-13 14:15:44 -05:00
parent d4fa9c96e8
commit 220c8050b1
3 changed files with 14 additions and 4 deletions

View File

@ -120,6 +120,7 @@ struct ComposeEmojiTextField: UIViewRepresentable {
} }
func textFieldDidEndEditing(_ textField: UITextField) { func textFieldDidEndEditing(_ textField: UITextField) {
uiState.currentInput = nil
updateAutocompleteState(textField: textField) updateAutocompleteState(textField: textField)
didEndEditing?() didEndEditing?()
} }

View File

@ -26,22 +26,24 @@ struct ComposeToolbar: View {
var body: some View { var body: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 8) { HStack(spacing: 0) {
Button("CW") { Button("CW") {
draft.contentWarningEnabled.toggle() draft.contentWarningEnabled.toggle()
} }
.accessibilityLabel(draft.contentWarningEnabled ? "Remove content warning" : "Add content warning") .accessibilityLabel(draft.contentWarningEnabled ? "Remove content warning" : "Add content warning")
.padding(5)
.hoverEffect()
MenuPicker(selection: $draft.visibility, options: Self.visibilityOptions, buttonStyle: .iconOnly) MenuPicker(selection: $draft.visibility, options: Self.visibilityOptions, buttonStyle: .iconOnly)
// the button has a bunch of extra space by default, but combined with what we add it's too much // // the button has a bunch of extra space by default, but combined with what we add it's too much
.padding(.horizontal, -8) // .padding(.horizontal, -8)
if mastodonController.instanceFeatures.localOnlyPosts { if mastodonController.instanceFeatures.localOnlyPosts {
MenuPicker(selection: $draft.localOnly, options: [ MenuPicker(selection: $draft.localOnly, options: [
.init(value: true, title: "Local-only", subtitle: "Only \(mastodonController.accountInfo!.instanceURL.host!)", image: UIImage(named: "link.broken")), .init(value: true, title: "Local-only", subtitle: "Only \(mastodonController.accountInfo!.instanceURL.host!)", image: UIImage(named: "link.broken")),
.init(value: false, title: "Federated", image: UIImage(systemName: "link")) .init(value: false, title: "Federated", image: UIImage(systemName: "link"))
], buttonStyle: .iconOnly) ], buttonStyle: .iconOnly)
.padding(.horizontal, -8) // .padding(.horizontal, -8)
} }
if let currentInput = uiState.currentInput, currentInput.toolbarElements.contains(.emojiPicker) { if let currentInput = uiState.currentInput, currentInput.toolbarElements.contains(.emojiPicker) {
@ -50,6 +52,8 @@ struct ComposeToolbar: View {
} }
.labelStyle(.iconOnly) .labelStyle(.iconOnly)
.font(.system(size: imageSize)) .font(.system(size: imageSize))
.padding(5)
.hoverEffect()
} }
if let currentInput = uiState.currentInput, if let currentInput = uiState.currentInput,
@ -68,6 +72,8 @@ struct ComposeToolbar: View {
} }
} }
.accessibilityLabel(format.accessibilityLabel) .accessibilityLabel(format.accessibilityLabel)
.padding(5)
.hoverEffect()
} }
} }
@ -76,6 +82,8 @@ struct ComposeToolbar: View {
Button(action: self.draftsButtonPressed) { Button(action: self.draftsButtonPressed) {
Text("Drafts") Text("Drafts")
} }
.padding(5)
.hoverEffect()
} }
.padding(.horizontal, 16) .padding(.horizontal, 16)
.frame(minWidth: minWidth) .frame(minWidth: minWidth)

View File

@ -44,6 +44,7 @@ struct MenuPicker<Value: Hashable>: UIViewRepresentable {
} }
}) })
button.accessibilityLabel = selectedOption.accessibilityLabel ?? selectedOption.title button.accessibilityLabel = selectedOption.accessibilityLabel ?? selectedOption.title
button.isPointerInteractionEnabled = buttonStyle == .iconOnly
} }
struct Option { struct Option {