Skip to content

Commit

Permalink
Merge pull request #7 from croquiscom/feature/APP-7541-talk-lounge
Browse files Browse the repository at this point in the history
APP-7541 바텀시트 상단 indicator 색상 컨트롤 기능 추가 및 백그라운드 터치 조절 비활성화 추가
  • Loading branch information
Raymond-Sik authored Sep 11, 2023
2 parents c9fb501 + 772dc7e commit cdb381d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion PanModal/Controller/PanModalPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public class PanModalPresentationController: UIPresentationController {
view = DimmedView()
}
view.didTap = { [weak self] _ in
self?.dismissPresentedViewController()
if self?.presentable?.allowsTapToDismiss == true {
self?.dismissPresentedViewController()
}

}
return view
}()
Expand Down Expand Up @@ -401,6 +404,7 @@ private extension PanModalPresentationController {
*/
func addDragIndicatorView(to view: UIView) {
view.addSubview(dragIndicatorView)
dragIndicatorView.indicator.backgroundColor = presentable?.indicatorColor
dragIndicatorView.backgroundColor = presentable?.dragIndicatorBackgroundColor
dragIndicatorView.translatesAutoresizingMaskIntoConstraints = false
dragIndicatorView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: 0.5).isActive = true
Expand Down
1 change: 1 addition & 0 deletions PanModal/Controller/PanModalWrappedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ private extension PanModalWrappedViewController {
*/
func addDragIndicatorView(to view: UIView) {
view.addSubview(dragIndicatorView)
dragIndicatorView.indicator.backgroundColor = presentable?.dragIndicatorBackgroundColor
dragIndicatorView.backgroundColor = presentable?.dragIndicatorBackgroundColor
dragIndicatorView.translatesAutoresizingMaskIntoConstraints = false
dragIndicatorView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: 0.5).isActive = true
Expand Down
8 changes: 8 additions & 0 deletions PanModal/Presentable/PanModalPresentable+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public extension PanModalPresentable where Self: UIViewController {
return true
}

var allowsTapToDismiss: Bool {
return true
}

var allowScrollViewDragToDismiss: Bool {
return true
}
Expand All @@ -81,6 +85,10 @@ public extension PanModalPresentable where Self: UIViewController {
var panCustomTopView: PanCustomTopView? {
return nil
}

var indicatorColor: UIColor {
return UIColor(red: 241/255.0, green: 243/255.0, blue: 245/255.0, alpha: 1)
}

func shouldRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool {
return true
Expand Down
9 changes: 9 additions & 0 deletions PanModal/Presentable/PanModalPresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ public protocol PanModalPresentable {
Default value is true.
*/
var allowsDragToDismiss: Bool { get }

/**
A flag to determine if dismissal should be initiated when tapping on the dimmed background view.

Default value is true.
*/
var allowsTapToDismiss: Bool { get }

/**
Default value is true
Expand All @@ -133,6 +140,8 @@ public protocol PanModalPresentable {
Default value is true.
*/
var showDragIndicator: Bool { get }

var indicatorColor: UIColor { get }

var panCustomTopView: PanCustomTopView? { get }

Expand Down
4 changes: 2 additions & 2 deletions PanModal/View/IndicatorView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import UIKit

class IndicatorView: UIView {
let indicator = UIView()

override init(frame: CGRect) {
super.init(frame: frame)

Expand All @@ -23,8 +25,6 @@ class IndicatorView: UIView {
}

private func addIndicatorView() {
let indicator = UIView()
indicator.backgroundColor = UIColor(red: 241/255.0, green: 243/255.0, blue: 245/255.0, alpha: 1)
indicator.layer.cornerRadius = 2
indicator.translatesAutoresizingMaskIntoConstraints = false
indicator.widthAnchor.constraint(equalToConstant: 40).isActive = true
Expand Down
8 changes: 8 additions & 0 deletions Sample/View Controllers/BasicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ extension BasicViewController: PanModalPresentable {
var panCustomTopView: PanCustomTopView? {
return topView
}

var indicatorColor: UIColor {
return .red
}

var allowsTapToDismiss: Bool {
return false
}
}

extension BasicViewController {
Expand Down

0 comments on commit cdb381d

Please sign in to comment.