Skip to content

Commit

Permalink
Fix drag gesture in HollowCommentInputView
Browse files Browse the repository at this point in the history
  • Loading branch information
liang2kl committed May 27, 2021
1 parent e6de27e commit 724adbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Source/Hollow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand All @@ -2078,7 +2078,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Hollow/Hollow.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = C5UH93T368;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Hollow/Info.plist;
Expand All @@ -2103,7 +2103,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = C5UH93T368;
INFOPLIST_FILE = HollowWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand Down Expand Up @@ -2131,7 +2131,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = HollowWidget/HollowWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = C5UH93T368;
INFOPLIST_FILE = HollowWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct HollowCommentInputView: View {
@State var showImagePicker = false
@State private var viewSize: CGSize = .zero

@State var dragOffset: CGFloat = 0
@GestureState var dragOffset: CGFloat = 0

@ScaledMetric var vstackSpacing: CGFloat = ViewConstants.inputViewVStackSpacing
@ScaledMetric(wrappedValue: ViewConstants.plainButtonFontSize) var buttonFontSize: CGFloat
@ScaledMetric var buttonWidth: CGFloat = 37
Expand Down Expand Up @@ -102,18 +102,16 @@ struct HollowCommentInputView: View {
.offset(y: dragOffset)
.gesture(
DragGesture()
.onChanged({ value in
.updating($dragOffset) { value, state, _ in
if value.translation.height > 0 {
dragOffset = value.translation.height
state = value.translation.height
}
})
}
.onEnded { value in
if value.predictedEndTranslation.height > viewSize.height * 2 / 3 {
withAnimation(transitionAnimation) {
store.replyToIndex = -2
}
} else {
dragOffset = 0
}
}
)
Expand Down

0 comments on commit 724adbc

Please sign in to comment.