Skip to content

Commit

Permalink
Refactor FXIOS-10205 [Swiftlint] Resolve 1 implicitly_unwrapped_optio…
Browse files Browse the repository at this point in the history
…nal violations in BottomSheetViewController (#23795)

* Resolve warnings in BottomSheetViewController

* Initialise and activate constraint in place

---------

Co-authored-by: Marceau Tonelli <[email protected]>
  • Loading branch information
tonell-m and tonelli-m authored Dec 30, 2024
1 parent 7ebd50b commit b044306
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class BottomSheetViewController: UIViewController,
private lazy var sheetView: UIView = .build { _ in }
private lazy var contentView: UIView = .build { _ in }
private lazy var scrollContentView: UIView = .build { _ in }
private var contentViewBottomConstraint: NSLayoutConstraint!
private var contentViewBottomConstraint: NSLayoutConstraint?
private var viewTranslation = CGPoint(x: 0, y: 0)
private let windowUUID: WindowUUID

Expand Down Expand Up @@ -103,7 +103,7 @@ public class BottomSheetViewController: UIViewController,
listenForThemeChange(view)
setupView()

contentViewBottomConstraint.constant = childViewController.view.frame.height
contentViewBottomConstraint?.constant = childViewController.view.frame.height
view.layoutIfNeeded()
}

Expand All @@ -114,7 +114,7 @@ public class BottomSheetViewController: UIViewController,

override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
contentViewBottomConstraint.constant = 0
contentViewBottomConstraint?.constant = 0
UIView.animate(withDuration: viewModel.animationTransitionDuration) {
self.view.backgroundColor = self.viewModel.backgroundColor
self.view.layoutIfNeeded()
Expand Down Expand Up @@ -176,6 +176,8 @@ public class BottomSheetViewController: UIViewController,
view.accessibilityElements = [closeButton, sheetView]

contentViewBottomConstraint = sheetView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
contentViewBottomConstraint?.isActive = true

let scrollViewHeightConstraint = scrollView.heightAnchor.constraint(
greaterThanOrEqualTo: scrollContentView.heightAnchor)

Expand All @@ -193,7 +195,6 @@ public class BottomSheetViewController: UIViewController,
sheetView.topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor,
constant: BottomSheetViewController.UX.minVisibleTopSpace),
sheetView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
contentViewBottomConstraint,
sheetView.trailingAnchor.constraint(equalTo: view.trailingAnchor),

contentView.topAnchor.constraint(equalTo: sheetView.topAnchor),
Expand Down Expand Up @@ -284,7 +285,7 @@ public class BottomSheetViewController: UIViewController,

public func dismissSheetViewController(completion: (() -> Void)? = nil) {
childViewController.willDismiss()
contentViewBottomConstraint.constant = childViewController.view.frame.height
contentViewBottomConstraint?.constant = childViewController.view.frame.height
UIView.animate(
withDuration: viewModel.animationTransitionDuration,
animations: {
Expand Down

0 comments on commit b044306

Please sign in to comment.