Skip to content

Commit

Permalink
Revert "Fix button tap events from bleeding through to container"
Browse files Browse the repository at this point in the history
This reverts commit c81b08f.
  • Loading branch information
crow committed Sep 19, 2024
1 parent c81b08f commit 8a595cc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 37 deletions.
24 changes: 1 addition & 23 deletions Airship/AirshipCore/Source/AirshipButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ struct AirshipButton<Label> : View where Label : View {
let reportingMetadata: AirshipJSON?
let description: String
let clickBehaviors:[ButtonClickBehavior]?
let eventHandlers: [EventHandler]?
let actions: ActionsPayload?
let label: () -> Label


var body: some View {

Button(
Expand Down Expand Up @@ -111,28 +111,6 @@ struct AirshipButton<Label> : View where Label : View {
if let actions = actions {
thomasEnvironment.runActions(actions, layoutState: layoutState)
}

applyEventHandlers(type: .tap)
}

private func applyEventHandlers(type: EventHandlerType) {
self.eventHandlers?.forEach { eventHandler in
if eventHandler.type == type {
eventHandler.stateActions.forEach { action in
switch action {
case .setState(let details):
viewState.updateState(
key: details.key,
value: details.value?.unWrap()
)
case .clearState:
viewState.clearState()
case .formValue(_):
AirshipLogger.error("Unable to process form value")
}
}
}
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions Airship/AirshipCore/Source/ImageButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct ImageButton : View {
reportingMetadata: self.model.reportingMetadata,
description: self.model.contentDescription ?? self.model.identifier,
clickBehaviors: self.model.clickBehaviors,
eventHandlers: self.model.eventHandlers,
actions: self.model.actions
) {
makeInnerButton()
Expand All @@ -33,7 +32,7 @@ struct ImageButton : View {
.border(self.model.border)
.accessible(self.model)
}
.commonButton(self.model)
.common(self.model)
.environment(
\.layoutState,
layoutState.override(
Expand Down
3 changes: 1 addition & 2 deletions Airship/AirshipCore/Source/LabelButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct LabelButton : View {
reportingMetadata: self.model.reportingMetadata,
description: self.model.contentDescription ?? self.model.label.text,
clickBehaviors: self.model.clickBehaviors,
eventHandlers: self.model.eventHandlers,
actions: self.model.actions
) {
Label(model: self.model.label, constraints: constraints)
Expand All @@ -37,7 +36,7 @@ struct LabelButton : View {
.border(self.model.border)
.accessible(self.model)
}
.commonButton(self.model)
.common(self.model)
.buttonStyle(PlainButtonStyle())
.environment(
\.layoutState,
Expand Down
11 changes: 1 addition & 10 deletions Airship/AirshipCore/Source/ViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension View {
// broken on tvOS for now
self
#else
self.gesture(TapGesture().onEnded(action))
self.simultaneousGesture(TapGesture().onEnded(action))
.accessibilityAction(.default) {
action()
}
Expand All @@ -44,15 +44,6 @@ public extension View {
}
}

/// Common modifier for buttons so event handlers can be added separately to prevent tap issues
@ViewBuilder
internal func commonButton<Content: BaseModel>(
_ model: Content
) -> some View {
self.enableBehaviors(model.enableBehaviors)
.visibility(model.visibility)
}

@ViewBuilder
internal func common<Content: BaseModel>(
_ model: Content,
Expand Down

0 comments on commit 8a595cc

Please sign in to comment.