Merge 'Fix sensitive chat bubble on iOS 18'
This commit is contained in:
@@ -5570,10 +5570,10 @@
|
|||||||
};
|
};
|
||||||
D78DB8572C1CE9CA00F0AB12 /* XCRemoteSwiftPackageReference "SwipeActions" */ = {
|
D78DB8572C1CE9CA00F0AB12 /* XCRemoteSwiftPackageReference "SwipeActions" */ = {
|
||||||
isa = XCRemoteSwiftPackageReference;
|
isa = XCRemoteSwiftPackageReference;
|
||||||
repositoryURL = "https://github.com/aheze/SwipeActions";
|
repositoryURL = "https://github.com/damus-io/SwipeActions.git";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = revision;
|
||||||
version = 1.1.0;
|
revision = 33d99756c3112e1a07c1732e3cddc5ad5bd0c5f4;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
D7A343EC2AD0D77C00CED48B /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
|
D7A343EC2AD0D77C00CED48B /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "babaf4d5748afecf49bbb702530d8e9576460692f478b0a50ee43195dd4440e2",
|
"originHash" : "1b14e62192b3fa4b04a57cb4601d175b325dc16cb5f22c4c8eb975a675328637",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "emojikit",
|
"identity" : "emojikit",
|
||||||
@@ -92,10 +92,9 @@
|
|||||||
{
|
{
|
||||||
"identity" : "swipeactions",
|
"identity" : "swipeactions",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/aheze/SwipeActions",
|
"location" : "https://github.com/damus-io/SwipeActions.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "41e6f6dce02d8cfa164f8c5461a41340850ca3ab",
|
"revision" : "33d99756c3112e1a07c1732e3cddc5ad5bd0c5f4"
|
||||||
"version" : "1.1.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ struct ChatEventView: View {
|
|||||||
// MARK: long-press reaction control objects
|
// MARK: long-press reaction control objects
|
||||||
/// Whether the user is actively pressing the view
|
/// Whether the user is actively pressing the view
|
||||||
@State var is_pressing = false
|
@State var is_pressing = false
|
||||||
/// The dispatched work item scheduled by a timer to bounce the event bubble and show the emoji selector
|
|
||||||
@State var long_press_bounce_work_item: DispatchWorkItem?
|
|
||||||
@State var popover_state: PopoverState = .closed {
|
@State var popover_state: PopoverState = .closed {
|
||||||
didSet {
|
didSet {
|
||||||
let generator = UIImpactFeedbackGenerator(style: popover_state.some_sheet_open() ? .heavy : .light)
|
let generator = UIImpactFeedbackGenerator(style: popover_state.some_sheet_open() ? .heavy : .light)
|
||||||
@@ -39,6 +37,7 @@ struct ChatEventView: View {
|
|||||||
|
|
||||||
@State private var isOnTopHalfOfScreen: Bool = false
|
@State private var isOnTopHalfOfScreen: Bool = false
|
||||||
@ObservedObject var bar: ActionBarModel
|
@ObservedObject var bar: ActionBarModel
|
||||||
|
@Environment(\.swipeViewGroupSelection) var swipeViewGroupSelection
|
||||||
|
|
||||||
enum PopoverState: String {
|
enum PopoverState: String {
|
||||||
case closed
|
case closed
|
||||||
@@ -206,28 +205,18 @@ struct ChatEventView: View {
|
|||||||
.scaleEffect(self.popover_state.some_sheet_open() ? 1.08 : is_pressing ? 1.02 : 1)
|
.scaleEffect(self.popover_state.some_sheet_open() ? 1.08 : is_pressing ? 1.02 : 1)
|
||||||
.shadow(color: (is_pressing || self.popover_state.some_sheet_open()) ? .black.opacity(0.1) : .black.opacity(0.3), radius: (is_pressing || self.popover_state.some_sheet_open()) ? 8 : 0, y: (is_pressing || self.popover_state.some_sheet_open()) ? 15 : 0)
|
.shadow(color: (is_pressing || self.popover_state.some_sheet_open()) ? .black.opacity(0.1) : .black.opacity(0.3), radius: (is_pressing || self.popover_state.some_sheet_open()) ? 8 : 0, y: (is_pressing || self.popover_state.some_sheet_open()) ? 15 : 0)
|
||||||
.onLongPressGesture(minimumDuration: 0.5, maximumDistance: 10, perform: {
|
.onLongPressGesture(minimumDuration: 0.5, maximumDistance: 10, perform: {
|
||||||
long_press_bounce_work_item?.cancel()
|
|
||||||
}, onPressingChanged: { is_pressing in
|
|
||||||
withAnimation(is_pressing ? .easeIn(duration: 0.5) : .easeOut(duration: 0.1)) {
|
|
||||||
self.is_pressing = is_pressing
|
|
||||||
if popover_state != .closed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if self.is_pressing {
|
|
||||||
let item = DispatchWorkItem {
|
|
||||||
// Ensure the action is performed only if the condition is still valid
|
|
||||||
if self.is_pressing {
|
|
||||||
withAnimation(.bouncy(duration: 0.2, extraBounce: 0.35)) {
|
withAnimation(.bouncy(duration: 0.2, extraBounce: 0.35)) {
|
||||||
let should_show_zap_sheet = !damus_state.settings.nozaps && damus_state.settings.onlyzaps_mode
|
let should_show_zap_sheet = !damus_state.settings.nozaps && damus_state.settings.onlyzaps_mode
|
||||||
popover_state = should_show_zap_sheet ? .open_zap_sheet : .open_emoji_selector
|
popover_state = should_show_zap_sheet ? .open_zap_sheet : .open_emoji_selector
|
||||||
}
|
}
|
||||||
}
|
}, onPressingChanged: { is_pressing in
|
||||||
}
|
withAnimation(is_pressing ? .easeIn(duration: 0.5) : .easeOut(duration: 0.1)) {
|
||||||
long_press_bounce_work_item = item
|
self.is_pressing = is_pressing
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.onChange(of: swipeViewGroupSelection.wrappedValue) { newValue in
|
||||||
|
self.is_pressing = false
|
||||||
|
}
|
||||||
.background(
|
.background(
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
EmptyView()
|
EmptyView()
|
||||||
@@ -310,6 +299,7 @@ struct ChatEventView: View {
|
|||||||
.swipeSpacing(-20)
|
.swipeSpacing(-20)
|
||||||
.swipeActionsStyle(.mask)
|
.swipeActionsStyle(.mask)
|
||||||
.swipeMinimumDistance(20)
|
.swipeMinimumDistance(20)
|
||||||
|
.swipeDragGesturePriority(.normal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user