Skip to content

Commit

Permalink
Fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Cay-Zhang committed Feb 9, 2024
1 parent 1961eae commit ce0e147
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
17 changes: 12 additions & 5 deletions Shared/BottomBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ struct BottomBar: View {
isTextFieldFocused = false
assert(viewModel.dragTranslationYDelta == 0, "dragTranslationYDelta should not accumulate.")
viewModel.dragTranslationYDelta = -rawTranslation.height - 45
// Self.feedbackGenerator.selectionChanged()
Self.playSensoryFeedback()
}
} else if translation.height < -50 {
if !viewModel.isEditing {
viewModel.isEditing = true
// Self.feedbackGenerator.selectionChanged()
Self.playSensoryFeedback()
}
} else if translation.height > 15 {
if !viewModel.isEditing {
viewModel._isEditing = true
viewModel.editingText = ""
// Self.feedbackGenerator.selectionChanged()
Self.playSensoryFeedback()
}
} else if viewModel.isEditing && viewModel.linkURL != nil {
viewModel.isEditing = false
// Self.feedbackGenerator.selectionChanged()
Self.playSensoryFeedback()
}
}
}
Expand Down Expand Up @@ -299,7 +299,14 @@ extension BottomBar {
}

extension BottomBar {
// static let feedbackGenerator: UISelectionFeedbackGenerator = UISelectionFeedbackGenerator()
#if os(visionOS)
static func playSensoryFeedback() { }
#else
static let sensoryFeedbackGenerator: UISelectionFeedbackGenerator = UISelectionFeedbackGenerator()
static func playSensoryFeedback() {
sensoryFeedbackGenerator.selectionChanged()
}
#endif
static var transitionAnimation: Animation { Animation.interpolatingSpring(mass: 3, stiffness: 1000, damping: 500, initialVelocity: 0) }
static var contentTransition: AnyTransition {
AnyTransition.offset(y: 25).combined(with: AnyTransition.opacity)
Expand Down
10 changes: 6 additions & 4 deletions Shared/Extensions/ButtonStyling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ struct CayMenuStyle: MenuStyle {
}
}

//extension UIImpactFeedbackGenerator {
// static let light: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)
//}
#if os(visionOS)
fileprivate func playButtonSensoryFeedback() { }
#else
fileprivate let buttonSensoryFeedbackGenerator: UIImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)

fileprivate func playButtonSensoryFeedback() {
// UIImpactFeedbackGenerator.light.impactOccurred(intensity: 0.5)
buttonSensoryFeedbackGenerator.impactOccurred(intensity: 0.5)
}
#endif

struct WideButtonContainerModifier: ViewModifier {
@ScaledMetric var height: CGFloat = 42
Expand Down
5 changes: 4 additions & 1 deletion Shared/Extensions/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,11 @@ extension LPLinkMetadata {
if let provider = self.iconProvider {
var data = try? await provider.loadDataRepresentation(forTypeIdentifier: UTType.image.identifier)
if data == nil { data = try? await provider.loadDataRepresentation(forTypeIdentifier: "dyn.agq80w5pbq7ww88brrfv085u") }
// let scale = await UIScreen.main.scale
#if os(visionOS)
let scale = 3.0
#else
let scale = await UIScreen.main.scale
#endif
return data
.flatMap { UIImage(data: $0, scale: scale) }
} else {
Expand Down

0 comments on commit ce0e147

Please sign in to comment.