Skip to content

Commit

Permalink
Fixed bottom sheet rubber band effect (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
almazrafi authored Jan 29, 2024
1 parent 3a10209 commit bf745d9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
15 changes: 14 additions & 1 deletion Nivelir.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2444,8 +2444,9 @@
C057F00523CB8EEB00C2D895 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1130;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = HeadHunter;
TargetAttributes = {
C057F00D23CB8EEB00C2D895 = {
Expand Down Expand Up @@ -3380,6 +3381,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -3388,6 +3390,8 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.6.3;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = ru.hh.Nivelir;
PRODUCT_NAME = Nivelir;
SKIP_INSTALL = YES;
Expand All @@ -3408,6 +3412,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -3416,6 +3421,8 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.6.3;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = ru.hh.Nivelir;
PRODUCT_NAME = Nivelir;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -3473,6 +3480,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -3481,6 +3489,8 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.6.3;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = ru.hh.Nivelir;
PRODUCT_NAME = Nivelir;
SDKROOT = appletvos;
Expand All @@ -3502,6 +3512,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -3510,6 +3521,8 @@
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.6.3;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = ru.hh.Nivelir;
PRODUCT_NAME = Nivelir;
SDKROOT = appletvos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 5 additions & 5 deletions Sources/Addons/BottomSheet/BottomSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public struct BottomSheet {
public let prefersWidthFollowsPreferredContentSize: Bool
public let prefersEdgeAttachedInCompactHeight: Bool

public let rubberBandEffect: BottomSheetRubberBandEffect?

public let changesAnimationOptions: BottomSheetAnimationOptions
public let presentAnimationOptions: BottomSheetAnimationOptions
public let dismissAnimationOptions: BottomSheetAnimationOptions

public let rubberBandEffect: BottomSheetRubberBandEffect?

public let canEndEditing: (() -> Bool)?
public let shouldDismiss: (() -> Bool)?

Expand All @@ -43,10 +43,10 @@ public struct BottomSheet {
prefersScrollingExpandsHeight: Bool = true,
prefersWidthFollowsPreferredContentSize: Bool = false,
prefersEdgeAttachedInCompactHeight: Bool = false,
rubberBandEffect: BottomSheetRubberBandEffect? = .default,
changesAnimationOptions: BottomSheetAnimationOptions = .changes,
presentAnimationOptions: BottomSheetAnimationOptions = .transition,
dismissAnimationOptions: BottomSheetAnimationOptions = .transition,
rubberBandEffect: BottomSheetRubberBandEffect? = .default,
canEndEditing: (() -> Bool)? = nil,
shouldDismiss: (() -> Bool)? = nil,
didAttemptToDismiss: (() -> Void)? = nil,
Expand All @@ -66,12 +66,12 @@ public struct BottomSheet {
self.prefersWidthFollowsPreferredContentSize = prefersWidthFollowsPreferredContentSize
self.prefersEdgeAttachedInCompactHeight = prefersEdgeAttachedInCompactHeight

self.rubberBandEffect = rubberBandEffect

self.changesAnimationOptions = changesAnimationOptions
self.presentAnimationOptions = presentAnimationOptions
self.dismissAnimationOptions = dismissAnimationOptions

self.rubberBandEffect = rubberBandEffect

self.canEndEditing = canEndEditing
self.shouldDismiss = shouldDismiss

Expand Down
6 changes: 4 additions & 2 deletions Sources/Addons/BottomSheet/BottomSheetController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public class BottomSheetController: NSObject {
}
}

public var rubberBandEffect: BottomSheetRubberBandEffect? {
didSet { presentation?.rubberBandEffect = rubberBandEffect }
}

public var changesAnimationOptions: BottomSheetAnimationOptions {
didSet {
if presentation?.changesAnimationOptions != changesAnimationOptions {
Expand All @@ -88,8 +92,6 @@ public class BottomSheetController: NSObject {
public var presentAnimationOptions: BottomSheetAnimationOptions
public var dismissAnimationOptions: BottomSheetAnimationOptions

public var rubberBandEffect: BottomSheetRubberBandEffect?

public var canEndEditing: (() -> Bool)?
public var shouldDismiss: (() -> Bool)?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ internal final class BottomSheetPresentationController: UIPresentationController
}
}

internal var rubberBandEffect: BottomSheetRubberBandEffect? = .default {
didSet {
layoutTransitionSubviews()
updateDimmingViewRatio()
}
}

internal var changesAnimationOptions: BottomSheetAnimationOptions = .changes {
didSet { transition.completionCurve = changesAnimationOptions.curve }
}

internal var rubberBandEffect: BottomSheetRubberBandEffect? = .default

internal var isEdgeAttached: Bool {
prefersEdgeAttachedInCompactHeight || (traitCollection.verticalSizeClass != .compact)
}
Expand Down

0 comments on commit bf745d9

Please sign in to comment.