Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has isThumbVisible bug when change dynamically #38

Open
ElonPark opened this issue Oct 17, 2020 · 0 comments
Open

Has isThumbVisible bug when change dynamically #38

ElonPark opened this issue Oct 17, 2020 · 0 comments

Comments

@ElonPark
Copy link

ElonPark commented Oct 17, 2020

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
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant