<commit_before>import KsApi
import Library
import Prelude
import UIKit

public protocol ProjectPamphletViewControllerDelegate: class {
  func projectPamphlet(_ controller: ProjectPamphletViewController,
                       panGestureRecognizerDidChange recognizer: UIPanGestureRecognizer)
}

public final class ProjectPamphletViewController: UIViewController {
  internal weak var delegate: ProjectPamphletViewControllerDelegate?
  fileprivate let viewModel: ProjectPamphletViewModelType = ProjectPamphletViewModel()

  fileprivate var navBarController: ProjectNavBarViewController!
  fileprivate var contentController: ProjectPamphletContentViewController!

  @IBOutlet weak private var navBarTopConstraint: NSLayoutConstraint!
  @IBOutlet weak private var projectPamphletTopConstraint: NSLayoutConstraint!

  public static func configuredWith(projectOrParam: Either<Project, Param>,
                                    refTag: RefTag?) -> ProjectPamphletViewController {

    let vc = Storyboard.ProjectPamphlet.instantiate(ProjectPamphletViewController.self)
    vc.viewModel.inputs.configureWith(projectOrParam: projectOrParam, refTag: refTag)
    return vc
  }

  public override var prefersStatusBarHidden: Bool {
    return UIApplication.shared.statusBarOrientation.isLandscape
  }

  public override func viewDidLoad() {
    super.viewDidLoad()

    self.edgesForExtendedLayout = [.left, .bottom, .right]

    self.navBarController = self.childViewControllers
      .flatMap { $0 as? ProjectNavBarViewController }.first
    self.navBarController.delegate = self

    self.contentController = self.childViewControllers
      .flatMap { $0 as? ProjectPamphletContentViewController }.first
    self.contentController.delegate = self

    self.viewModel.inputs.initial(topConstraint: initialTopConstraint)

    self.viewModel.inputs.viewDidLoad()
  }

  public override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.viewModel.inputs.viewWillAppear(animated: animated)
    self.setInitial(constraints: [navBarTopConstraint, projectPamphletTopConstraint],
                    constant: initialTopConstraint)
  }

  public override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    self.viewModel.inputs.viewDidAppear(animated: animated)
  }

  private var initialTopConstraint: CGFloat {
    if #available(iOS 11.0, *) {
      return parent?.view.safeAreaInsets.top ?? 0.0
    } else {
      return UIApplication.shared.statusBarFrame.size.height
    }
  }

  public override func bindViewModel() {
    super.bindViewModel()
<commit_msg>Fixed project layout when page opens from deeplink (#266)<commit_after>import KsApi
import Library
import Prelude
import UIKit

public protocol ProjectPamphletViewControllerDelegate: class {
  func projectPamphlet(_ controller: ProjectPamphletViewController,
                       panGestureRecognizerDidChange recognizer: UIPanGestureRecognizer)
}

public final class ProjectPamphletViewController: UIViewController {
  internal weak var delegate: ProjectPamphletViewControllerDelegate?
  fileprivate let viewModel: ProjectPamphletViewModelType = ProjectPamphletViewModel()

  fileprivate var navBarController: ProjectNavBarViewController!
  fileprivate var contentController: ProjectPamphletContentViewController!

  @IBOutlet weak private var navBarTopConstraint: NSLayoutConstraint!
  @IBOutlet weak private var projectPamphletTopConstraint: NSLayoutConstraint!

  public static func configuredWith(projectOrParam: Either<Project, Param>,
                                    refTag: RefTag?) -> ProjectPamphletViewController {

    let vc = Storyboard.ProjectPamphlet.instantiate(ProjectPamphletViewController.self)
    vc.viewModel.inputs.configureWith(projectOrParam: projectOrParam, refTag: refTag)
    return vc
  }

  public override var prefersStatusBarHidden: Bool {
    return UIApplication.shared.statusBarOrientation.isLandscape
  }

  public override func viewDidLoad() {
    super.viewDidLoad()

    self.edgesForExtendedLayout = [.left, .bottom, .right]

    self.navBarController = self.childViewControllers
      .flatMap { $0 as? ProjectNavBarViewController }.first
    self.navBarController.delegate = self

    self.contentController = self.childViewControllers
      .flatMap { $0 as? ProjectPamphletContentViewController }.first
    self.contentController.delegate = self

    self.viewModel.inputs.initial(topConstraint: initialTopConstraint)

    self.viewModel.inputs.viewDidLoad()
  }

  public override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.viewModel.inputs.viewWillAppear(animated: animated)
  }

  public override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.setInitial(constraints: [navBarTopConstraint, projectPamphletTopConstraint],
                    constant: initialTopConstraint)
  }

  public override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    self.viewModel.inputs.viewDidAppear(animated: animated)
  }

  private var initialTopConstraint: CGFloat {
    if #available(iOS 11.0, *) {
      return parent?.view.safeAreaInsets.top ?? 0.0
    } else {
      return UIApplication.shared.statusBarFrame.size.height
    }
  }

  public override func bindViewModel() {
    super.bindViewModel()

{'fraction_non_alphanumeric': 0.06921062476618033, 'fraction_numerical': 0.0031799476243920687, 'mean_word_length': 4.445010183299389, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6346894', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1433, 'n_words': 313}