Skip to content

Commit

Permalink
추가 디테일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KimTaeHyeong17 committed Jul 1, 2024
1 parent 244b093 commit eb12807
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Sources/Controller/SheetContentsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ open class SheetContentsViewController: UICollectionViewController, SheetContent
public var topMargin: CGFloat = 0

public var sheetTopGradientViewHeight: CGFloat {
guard options.useSheetTopGradientView else { return 0 }
return 56.0 + statusBarHeight
}

Expand Down Expand Up @@ -89,21 +90,23 @@ open class SheetContentsViewController: UICollectionViewController, SheetContent
let yOffset = scrollView.contentOffset.y
topMargin = max(layout.settings.topMargin - yOffset, 0)

guard !isSheetTopGradientViewAnimating, let sheetTopGradientView else { return }
if yOffset > statusBarHeight && sheetTopGradientView.isHidden == true {
guard !isSheetTopGradientViewAnimating, let sheetTopGradientView = sheetTopGradientView else { return }
if topMargin < statusBarHeight && sheetTopGradientView.isHidden == true {
isSheetTopGradientViewAnimating = true
UIView.animate(withDuration: 0.3, animations: { [weak self] in
guard let self else { return }
sheetTopGradientView.isHidden = false
self.view.bringSubviewToFront(sheetTopGradientView)
sheetTopGradientView.alpha = 0.0
sheetTopGradientView.isHidden = false
UIView.animate(withDuration: 0.2, animations: { [weak self] in
sheetTopGradientView.alpha = 1.0
self?.view.bringSubviewToFront(sheetTopGradientView)
}, completion: { [weak self] _ in
self?.isSheetTopGradientViewAnimating = false
})
} else if yOffset <= statusBarHeight && sheetTopGradientView.isHidden == false {
} else if topMargin >= statusBarHeight && sheetTopGradientView.isHidden == false {
isSheetTopGradientViewAnimating = true
UIView.animate(withDuration: 0.3, animations: {
sheetTopGradientView.isHidden = true
UIView.animate(withDuration: 0.2, animations: {
sheetTopGradientView.alpha = 0.0
}, completion: { [weak self] _ in
sheetTopGradientView.isHidden = true
self?.isSheetTopGradientViewAnimating = false
})
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/Manager/SheetOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public struct SheetOptions {

/// sheet background color
public var sheetBackgroundColor: UIColor = .white

/// sheet top area gradient background view
public var useSheetTopGradientView = true
}

public struct SheetAnimationOption {
Expand Down

0 comments on commit eb12807

Please sign in to comment.