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

#2208 Add interactive dragging to .anytypeSheet #2221

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
38 changes: 24 additions & 14 deletions Anytype/Sources/Design system/SheetView/SheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ struct SheetView<Content: View>: View {
private let dismissOnBackgroundView: Bool
private var content: Content
private let cancelAction: (() -> Void)?


@State private var spacerHeight: CGFloat = 0

init(
dismissOnBackgroundView: Bool,
content: () -> Content,
Expand Down Expand Up @@ -35,19 +37,27 @@ struct SheetView<Content: View>: View {
}

private var contentView: some View {
content
.cornerRadius(16, style: .continuous)
.shadow(radius: 20)
.padding(.horizontal, 8)
.gesture(
DragGesture()
.onEnded { value in
if value.translation.height > 0 {
dismiss()
cancelAction?()
}
VStack(spacing: 0) {
Spacer.fixedHeight(max(0, spacerHeight))
content
.fixedSize(horizontal: false, vertical: true)
.background(Color.Background.secondary)
.cornerRadius(16, style: .continuous)
.shadow(radius: 20)
.padding(.horizontal, 8)
}
.gesture(
DragGesture()
.onChanged { value in
spacerHeight = value.translation.height
}
.onEnded { value in
if value.translation.height > 0 {
dismiss()
cancelAction?()
}
)
.fitIPadToReadableContentGuide()
}
)
.fitIPadToReadableContentGuide()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct ObjectSettingsView: View {

private var settings: some View {
VStack(spacing: 0) {
DragIndicator()
Spacer.fixedHeight(Constants.dragIndicatorSpacing)

settingsList

ObjectActionsView(objectId: viewModel.objectId, output: viewModel)
Expand Down Expand Up @@ -58,5 +61,6 @@ struct ObjectSettingsView: View {
private enum Constants {
static let edgeInset: CGFloat = 16
static let dividerSpacing: CGFloat = 12
static let dragIndicatorSpacing: CGFloat = 12
}
}
Loading