<commit_before>//
// Created by <NAME> on 2019-06-06.
// Copyright (c) 2019 Particle. All rights reserved.
//

import Foundation

protocol DeviceInspectorInfoSliderViewDelegate: class {
    func infoSliderDidUpdateDevice()
    func infoSliderDidExpand()
    func infoSliderDidCollapse()
}

class DeviceInspectorInfoSliderViewController: UIViewController, UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate {
    @IBOutlet weak var yConstraint: NSLayoutConstraint?
    @IBOutlet weak var heightConstraint: NSLayoutConstraint?
    
    @IBOutlet weak var collapsedContent: UIView!
    @IBOutlet weak var collapsedDeviceImageView: ScaledHeightImageView!
    @IBOutlet weak var collapsedDeviceStateImageView: UIImageView!
    @IBOutlet weak var collapsedDeviceNameLabel: ParticleLabel!
    @IBOutlet weak var collapsedDeviceTypeLabel: ParticleLabel!
    @IBOutlet weak var collapsedDeviceIconImage: DeviceTypeIcon!
    
    
    @IBOutlet weak var expandedContent: UIView!
    @IBOutlet weak var expandedDeviceImageView: ScaledHeightImageView!
    @IBOutlet weak var expandedDeviceImageViewHeightConstraint: NSLayoutConstraint!
    @IBOutlet weak var expandedDeviceStateImageView: UIImageView!
    @IBOutlet weak var expandedDeviceNameLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceStateLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceSignalLabel: ParticleLabel!
    @IBOutlet weak var expandedTableView: UITableView!
    @IBOutlet weak var expandedTableViewHeightConstraint: NSLayoutConstraint!
    @IBOutlet weak var expandedDeviceNotesTitleLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceNotesLabel: ParticleLabel!
    @IBOutlet weak var expandedPingButton: ParticleAlternativeButton!
    @IBOutlet weak var expandedPingActivityIndicator: UIActivityIndicatorView!
    @IBOutlet weak var expandedSignalToggle: UISwitch!
    
    @IBOutlet var constraintsToShrinkOnSmallScreens: [NSLayoutConstraint]?

    weak var delegate: DeviceInspectorInfoSliderViewDelegate?

    let contentSwitchDistanceInPixels: CGFloat = 180
    let contentSwitchDelayInPixels: CGFloat = 100

    var device: ParticleDevice!
    var collapsedPosConstraint: CGFloat!
    var collapsedPosFrame: CGFloat!


    var panGestureRecognizer: UIPanGestureRecognizer!
    var startY: CGFloat = 0
    var collapsed: Bool = true
    var animating: Bool = false
    var beingDragged: Bool = false
    var displayLink: CADisplayLink!

    var details: [String: Any]!
    var detailsOrder: [String]!

    func setup(_ device: ParticleDevice!, yConstraint: NSLayoutConstraint, heightConstraint: NSLayoutConstraint) {
        self.yConstraint = yConstraint
        self.heightConstraint = heightConstraint

        self.device = device
        self.details = device.getInfoDetails()
        self.detailsOrder = device.getInfoDetailsOrder()

        internalInit()
    }

    private func internalInit() {
        self.view.layer.borderWidth = 1
        self.view.layer.borderColor = UIColor(rgb: 0xD9D8D6).cgColor

        self.adjustConstraintPositions()
        self.yConstraint!.constant = collapsedPosConstraint

        self.setStyle()
        self.setContent()

        panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panGestureTriggered))
        panGestureRecognizer.delegate = self
        panGestureRecognizer.isEnabled = true
        self.view.addGestureRecognizer(panGestureRecognizer)
    }<commit_msg>fix device info slider appearance on iOS 13<commit_after>//
// Created by <NAME> on 2019-06-06.
// Copyright (c) 2019 Particle. All rights reserved.
//

import Foundation

protocol DeviceInspectorInfoSliderViewDelegate: class {
    func infoSliderDidUpdateDevice()
    func infoSliderDidExpand()
    func infoSliderDidCollapse()
}

class DeviceInspectorInfoSliderViewController: UIViewController, UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate {
    @IBOutlet weak var yConstraint: NSLayoutConstraint?
    @IBOutlet weak var heightConstraint: NSLayoutConstraint?
    
    @IBOutlet weak var collapsedContent: UIView!
    @IBOutlet weak var collapsedDeviceImageView: ScaledHeightImageView!
    @IBOutlet weak var collapsedDeviceStateImageView: UIImageView!
    @IBOutlet weak var collapsedDeviceNameLabel: ParticleLabel!
    @IBOutlet weak var collapsedDeviceTypeLabel: ParticleLabel!
    @IBOutlet weak var collapsedDeviceIconImage: DeviceTypeIcon!
    
    
    @IBOutlet weak var expandedContent: UIView!
    @IBOutlet weak var expandedDeviceImageView: ScaledHeightImageView!
    @IBOutlet weak var expandedDeviceImageViewHeightConstraint: NSLayoutConstraint!
    @IBOutlet weak var expandedDeviceStateImageView: UIImageView!
    @IBOutlet weak var expandedDeviceNameLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceStateLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceSignalLabel: ParticleLabel!
    @IBOutlet weak var expandedTableView: UITableView!
    @IBOutlet weak var expandedTableViewHeightConstraint: NSLayoutConstraint!
    @IBOutlet weak var expandedDeviceNotesTitleLabel: ParticleLabel!
    @IBOutlet weak var expandedDeviceNotesLabel: ParticleLabel!
    @IBOutlet weak var expandedPingButton: ParticleAlternativeButton!
    @IBOutlet weak var expandedPingActivityIndicator: UIActivityIndicatorView!
    @IBOutlet weak var expandedSignalToggle: UISwitch!
    
    @IBOutlet var constraintsToShrinkOnSmallScreens: [NSLayoutConstraint]?

    weak var delegate: DeviceInspectorInfoSliderViewDelegate?

    let contentSwitchDistanceInPixels: CGFloat = 180
    let contentSwitchDelayInPixels: CGFloat = 100

    var device: ParticleDevice!
    var collapsedPosConstraint: CGFloat!
    var collapsedPosFrame: CGFloat!


    var panGestureRecognizer: UIPanGestureRecognizer!
    var startY: CGFloat = 0
    var collapsed: Bool = true
    var animating: Bool = false
    var beingDragged: Bool = false
    var displayLink: CADisplayLink!

    var details: [String: Any]!
    var detailsOrder: [String]!

    func setup(_ device: ParticleDevice!, yConstraint: NSLayoutConstraint, heightConstraint: NSLayoutConstraint) {
        self.yConstraint = yConstraint
        self.heightConstraint = heightConstraint

        self.device = device
        self.details = device.getInfoDetails()
        self.detailsOrder = device.getInfoDetailsOrder()

        internalInit()
    }

    override func awakeFromNib() {
        super.awakeFromNib()

        if #available(iOS 13.0, *) {
            if self.responds(to: Selector("overrideUserInterfaceStyle")) {
                self.setValue(UIUserInterfaceStyle.light.rawValue, forKey: "overrideUserInterfaceStyle")
            }
        }
    }

    private func internalInit() {
        self.view.layer.borderWidth = 1
        self.view.layer.borderColor = UIColor(rgb: 0xD9D8D6).cgColor

        self.adjustConstraintPositions()
        self.yConstraint!.constant = collapsedPosConstraint

        self.setStyle()
        self.setContent()

        panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panGestureTriggered))
        panGestureRecognizer.delegate = self
        panGestureRecognizer.isEnabled = true
        self.view.addGestureRecognizer(panGestureRecognizer)
    }
{'fraction_non_alphanumeric': 0.06312887663680221, 'fraction_numerical': 0.007305306685044797, 'mean_word_length': 4.242774566473988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3630594', 'n_tokens_mistral': 2087, 'n_tokens_neox': 1949, 'n_words': 492}