<commit_before>/*
Copyright 2015 BuddyHopp, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

//
//  TisprCardStackViewLayout.swift
//
//  Created by <NAME> on 07/12/15.
//

import UIKit

public class TisprCardStackViewLayout: UICollectionViewLayout, UIGestureRecognizerDelegate {
    
    // MARK: - Properties
    
    /// The index of the card that is currently on top of the stack. The index 0 represents the oldest card of the stack.
    var index: Int = 0 {
        didSet {
            //workaround for zIndex
            draggedCellPath = oldValue > index ? NSIndexPath(forItem: index, inSection: 0) : NSIndexPath(forItem: oldValue, inSection: 0)
            let cell = collectionView!.cellForItemAtIndexPath(draggedCellPath!)
            collectionView?.bringSubviewToFront(cell!)

            collectionView?.performBatchUpdates({
                    _ = self.invalidateLayout()
                }, completion: { (Bool) in
                    _ = self.delegate?.cardDidChangeState(self.index)
            })<commit_msg>Fix for fatal error: unexpectedly found nil while unwrapping an Optional value on line 35 of TisprCardStackViewLayout<commit_after>/*
Copyright 2015 BuddyHopp, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

//
//  TisprCardStackViewLayout.swift
//
//  Created by <NAME> on 07/12/15.
//

import UIKit

public class TisprCardStackViewLayout: UICollectionViewLayout, UIGestureRecognizerDelegate {
    
    // MARK: - Properties
    
    /// The index of the card that is currently on top of the stack. The index 0 represents the oldest card of the stack.
    var index: Int = 0 {
        didSet {
            //workaround for zIndex
            draggedCellPath = oldValue > index ? NSIndexPath(forItem: index, inSection: 0) : NSIndexPath(forItem: oldValue, inSection: 0)
            let cell = collectionView!.cellForItemAtIndexPath(draggedCellPath!)
            if (cell != nil) {
                collectionView?.bringSubviewToFront(cell!)
            }

            collectionView?.performBatchUpdates({
                    _ = self.invalidateLayout()
                }, completion: { (Bool) in
                    _ = self.delegate?.cardDidChangeState(self.index)
            })
{'fraction_non_alphanumeric': 0.07478699905332913, 'fraction_numerical': 0.011991164405175133, 'mean_word_length': 2.8424242424242423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1790001', 'n_tokens_mistral': 876, 'n_tokens_neox': 823, 'n_words': 319}