Skip to content

Has isThumbVisible bug when change dynamically #38

@ElonPark

Description

@ElonPark

While checking the demo, if the value is dynamically changed to false as ʻisThumbVisible, it was confirmed that the layout of MainMenuViewController` behaves strangely.

Below is the full code I tested.

import UIKit

import Rideau

final class ViewController: UIViewController {

  @IBOutlet weak var box1: UIView!
  
  @IBOutlet weak var box2: UIView!
  
  private let rideauView = RideauView(frame: .zero) { (config) in
    config.topMarginOption = .fromSafeArea(0)
    config.snapPoints = [.pointsFromBottom(150), .pointsFromBottom(250), .pointsFromBottom(700), .full]
  }

  let container = RideauMaskedCornerRoundedViewController()
  lazy var defaultCornerRadius = container.contentView.cornerRadius
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    view.addSubview(rideauView)

    rideauView.frame = view.bounds
    rideauView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    let controller = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainMenuViewController") as! MainMenuViewController

    container.isThumbVisible = true
    container.setBodyViewController(controller)
    container.willMove(toParent: self)
    addChild(container)
    
    rideauView.containerView.set(bodyView: container.view, resizingOption: .resizeToVisibleArea)
    rideauView.isTrackingKeyboard = false
    rideauView.delegate = self
  }
  
  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    print("viewDidAppear")
  }
  
  @IBAction func didTapChangeButton(_ sender: Any) {
    self.box1.backgroundColor = .blue
    self.box2.backgroundColor = .blue
  }
}

extension ViewController : RideauViewDelegate {
  func rideauView(_ rideauView: RideauView, animatorsAlongsideMovingIn range: ResolvedSnapPointRange) -> [UIViewPropertyAnimator] {
    
    switch (range.start.source, range.end.source) {
    case (.fraction(1), .fraction(0.7)):
      
      let animator1 = UIViewPropertyAnimator(duration: 0.3, curve: .easeInOut) {
        self.box1.alpha = 0.3
      }
      
      let animator2 = UIViewPropertyAnimator(duration: 0.3, curve: .easeInOut) {
        rideauView.backgroundColor = UIColor(white: 0, alpha: 0.3)
      }
      
      return [animator1, animator2]
      
    case (.fraction(0.7), .autoPointsFromBottom):
      let animator = UIViewPropertyAnimator(duration: 0.3, curve: .easeInOut) {
        self.box2.alpha = 0.3
      }
      return [animator]
      
    default:
      return []
    }
  }
  
  func rideauView(_ rideauView: RideauView, willMoveTo snapPoint: RideauSnapPoint) {
    switch snapPoint {
    case .full:
      container.contentView.cornerRadius = 0
      container.isThumbVisible = false // This case has layout bug
    default:
      container.contentView.cornerRadius = defaultCornerRadius
      container.isThumbVisible = true
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions