Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ final class RootViewController: UIViewController {
let viewController = ResizeViewController(initialHeight: 300)
presentBottomSheetInsideNavigationController(
viewController: viewController,
configuration: .default
configuration: .default,
dismissCompletion: {
print("TWA: dismissCompletion")
}
Comment on lines +58 to +60
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this option is not needed let's just ignore it and remove dismissCompletion?

)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,33 @@ public extension UIViewController {
present(viewController, animated: true, completion: nil)
}

func presentBottomSheet(viewController: UIViewController, configuration: BottomSheetConfiguration, dissmisCompletion: @escaping (() -> Void)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this option optional and nil by default and delete function above presentBottomSheet(viewController:configuration:)? Then, we would have much less copy-paste

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can you please fix a typo?

Suggested change
func presentBottomSheet(viewController: UIViewController, configuration: BottomSheetConfiguration, dissmisCompletion: @escaping (() -> Void)) {
func presentBottomSheet(viewController: UIViewController, configuration: BottomSheetConfiguration, dismissCompletion: @escaping (() -> Void)) {

weak var presentingViewController = self
weak var currentBottomSheetTransitionDelegate: UIViewControllerTransitioningDelegate?
let presentationControllerFactory = DefaultBottomSheetPresentationControllerFactory(configuration: configuration) {
DefaultBottomSheetModalDismissalHandler(presentingViewController: presentingViewController) {
if currentBottomSheetTransitionDelegate === presentingViewController?.bottomSheetTransitionDelegate {
presentingViewController?.bottomSheetTransitionDelegate = nil
}
dissmisCompletion()
}
}
bottomSheetTransitionDelegate = BottomSheetTransitioningDelegate(
presentationControllerFactory: presentationControllerFactory
)
currentBottomSheetTransitionDelegate = bottomSheetTransitionDelegate
viewController.transitioningDelegate = bottomSheetTransitionDelegate
viewController.modalPresentationStyle = .custom
present(viewController, animated: true, completion: nil)
}

func presentBottomSheetInsideNavigationController(viewController: UIViewController, configuration: BottomSheetConfiguration) {
let navigationController = BottomSheetNavigationController(rootViewController: viewController, configuration: configuration)
presentBottomSheet(viewController: navigationController, configuration: configuration)
}

func presentBottomSheetInsideNavigationController(viewController: UIViewController, configuration: BottomSheetConfiguration, dismissCompletion: @escaping (() -> Void)) {
let navigationController = BottomSheetNavigationController(rootViewController: viewController, configuration: configuration)
presentBottomSheet(viewController: navigationController, configuration: configuration, dissmisCompletion: dismissCompletion)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public final class BottomSheetNavigationController: UINavigationController {
super.init(rootViewController: rootViewController)
}

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
self.configuration = .default
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand Down