Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix long press on rubric #3138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 6 additions & 8 deletions Teacher/Teacher/SpeedGrader/RubricAssessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct RubricAssessor: View {
private let tooltip: String
private let content: Content

@GestureState private var showTooltip = false
@State private var showTooltip = false
private let containerFrame: CGRect

init(isOn: Binding<Bool>, tooltip: String = "", containerFrame: CGRect = .null, @ViewBuilder content: () -> Content) {
Expand All @@ -258,12 +258,11 @@ struct RubricAssessor: View {
)
.accessibility(addTraits: isOn ? [.isButton, .isSelected] : .isButton)
.onTapGesture { isOn.toggle() }
.gesture(LongPressGesture(minimumDuration: .infinity)
.updating($showTooltip) { _, state, transation in
transation.animation = .spring(response: 0.2, dampingFraction: 0.6)
state = true
.onLongPressGesture(perform: {}, onPressingChanged: { isLongPressing in
withAnimation(.spring(response: 0.2, dampingFraction: 0.6)) {
showTooltip = isLongPressing
}
)
})
.overlay(!showTooltip || tooltip.isEmpty ? nil :
GeometryReader { geometry in
let bubbleToCircleOffset: CGFloat = 16
Expand Down Expand Up @@ -301,8 +300,7 @@ struct RubricAssessor: View {
// Alignment must match the guides we use above otherwise they don't get called
.frame(width: maxWidth, height: maxHeight, alignment: .bottomLeading)
}
.transition(.scale),
alignment: .bottomLeading)
.transition(.scale.combined(with: .opacity)), alignment: .bottomLeading)
}
}

Expand Down