Skip to content

Commit

Permalink
Fix issue lucaszischka#101
Browse files Browse the repository at this point in the history
  • Loading branch information
grandsir committed Mar 11, 2023
1 parent 37f4d16 commit 0f86a6e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ public extension BottomSheet {
self.configuration.dragIndicatorAction = action
return self
}

/// Enables the animations on drag indicator
///
/// - Parameters:
/// - bool: A boolean to decide whether or not animations should be discarded.
///
/// - Returns: A BottomSheet with animations on drag indicator enabled
func enableAnimationsOnDragIndicator(_ bool: Bool = true) -> BottomSheet {
self.configuration.enableAnimationsOnDragIndicator = bool
return self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal extension BottomSheetView {
Capsule()
// Design of the drag indicator
.fill(self.configuration.dragIndicatorColor)
.frame(
.frame(
width: 36,
height: 5
)
Expand All @@ -105,9 +105,19 @@ internal extension BottomSheetView {
.gesture(
self.dragGesture(with: geometry)
)

})
// Make it borderless for Mac
// Make it borderless for Mac
.buttonStyle(.borderless)

// Disable animations
.if(!configuration.enableAnimationsOnDragIndicator) { view in
view
.transaction { t in
t.disablesAnimations = true

}
}
}

func bottomSheetContent(with geometry: GeometryProxy) -> some View {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ConditionalViewModifier.swift
//
// Created by GrandSir on 10.03.2023.
//

import SwiftUI

extension View {
/// Applies the given transform if the given condition evaluates to `true`.
/// - Parameters:
/// - condition: The condition to evaluate.
/// - transform: The transform to apply to the source `View`.
/// - Returns: Either the original `View` or the modified `View` if the condition is `true`.
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
if condition {
transform(self)
} else {
self
}
}
}
1 change: 1 addition & 0 deletions Sources/BottomSheet/Models/BottomSheetConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ internal class BottomSheetConfiguration: Equatable {
var iPadFloatingSheet: Bool = true
var sheetWidth: BottomSheetWidth = .platformDefault
var accountForKeyboardHeight: Bool = false
var enableAnimationsOnDragIndicator = false
}

0 comments on commit 0f86a6e

Please sign in to comment.