<commit_before>//
//  GoalieTableView.swift
//  Goalie
//
//  Created by <NAME> on 12/28/15.
//  Copyright © 2015 Incipia. All rights reserved.
//

import UIKit

let _defaultHeaderHeight: CGFloat = floor(UIScreen.mainScreen().bounds.height / 3.0)
let _minimumHeaderHeight: CGFloat = floor(UIScreen.mainScreen().bounds.height / 5.1)
let _maximumHeaderHeight: CGFloat = _defaultHeaderHeight + 50

class GoalieTableView: LPRTableView
{
   @IBOutlet private var _firstTaskFooterViewArrow: UIImageView!
   @IBOutlet private var _firstTaskFooterView: UIView!
   @IBOutlet private var _normalGoalieFooterView: UIView!
   
   @IBOutlet private var _currentCompletedSoundName: GoalieKerningLabel!
   @IBAction private func _advanceCompletedSound()
   {
      SFXPlayer.advanceCompletedSound()
      SFXPlayer.playCurrentCompletedSound()
      _currentCompletedSoundName.updateText(SFXPlayer.currentCompletedSoundName()!, color: UIColor.whiteColor())
   }
   @IBAction private func _decrementCompletedSound()
   {
      SFXPlayer.decrementCompletedSound()
      SFXPlayer.playCurrentCompletedSound()
      _currentCompletedSoundName.updateText(SFXPlayer.currentCompletedSoundName()!, color: UIColor.whiteColor())
   }
   
   @IBOutlet private var _goalieHeaderView: UIView!
   
   private var _goalieMovementAnimator: GoalieMovementAnimator!
   @IBOutlet private weak var _goalieFaceView: CharacterView! {
      didSet {
         _goalieMovementAnimator = GoalieMovementAnimator(view: _goalieFaceView)
      }
   }
   
   @IBOutlet private weak var _rightSpeechBubble: GoalieSpeechBubble!
   @IBOutlet private weak var _leftSpeechBubble: GoalieSpeechBubble! {
      didSet {
         _leftSpeechBubble.tailDirection = .Right
      }
   }
   
   @IBOutlet private weak var _settingsButton: UIButton!
   
   // For testing
   @IBAction private func _swap()
   {
      var newCharacter: GoalieCharacter = .Goalie
      if _goalieFaceView.character == .Goalie {
         newCharacter = .Unknown
      }
      _goalieFaceView.updateCharacter(newCharacter)
   }
   
   private var _shouldShowSpeechBubble = false
   private var _currentPriority = TaskPriority.Unknown
   
   private let _tapGestureRecognizer = UITapGestureRecognizer()
   
   // MARK: - Lifecycle
   deinit {
      NSNotificationCenter.defaultCenter().removeObserver(self)
   }
   
   override func awakeFromNib()
   {
      super.awakeFromNib()
      
      _setupHeaderView()
      _setupContentOffsetAndInset()
      _setupUIForFirstTime()
      _setupKeyboardObserving()
      
      decelerationRate = UIScrollViewDecelerationRateFast
      _tapGestureRecognizer.addTarget(self, action: "goalieTapped")
      _goalieFaceView.addGestureRecognizer(_tapGestureRecognizer)
   }
   
   func goalieTapped()
   {
      print("tapped!")
   }
   
   // MARK: - Setup
   private func _setupKeyboardObserving()
   {
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)
   }
   
   private func _setupHeaderView()
   {
      tableHeaderView = nil
      superview?.addSubview(_goalieHeaderView)
   }
   <commit_msg>Swapping between bee and goalie, and calling update character in awakeFromNib<commit_after>//
//  GoalieTableView.swift
//  Goalie
//
//  Created by <NAME> on 12/28/15.
//  Copyright © 2015 Incipia. All rights reserved.
//

import UIKit

let _defaultHeaderHeight: CGFloat = floor(UIScreen.mainScreen().bounds.height / 3.0)
let _minimumHeaderHeight: CGFloat = floor(UIScreen.mainScreen().bounds.height / 5.1)
let _maximumHeaderHeight: CGFloat = _defaultHeaderHeight + 50

class GoalieTableView: LPRTableView
{
   @IBOutlet private var _firstTaskFooterViewArrow: UIImageView!
   @IBOutlet private var _firstTaskFooterView: UIView!
   @IBOutlet private var _normalGoalieFooterView: UIView!
   
   @IBOutlet private var _currentCompletedSoundName: GoalieKerningLabel!
   @IBAction private func _advanceCompletedSound()
   {
      SFXPlayer.advanceCompletedSound()
      SFXPlayer.playCurrentCompletedSound()
      _currentCompletedSoundName.updateText(SFXPlayer.currentCompletedSoundName()!, color: UIColor.whiteColor())
   }
   @IBAction private func _decrementCompletedSound()
   {
      SFXPlayer.decrementCompletedSound()
      SFXPlayer.playCurrentCompletedSound()
      _currentCompletedSoundName.updateText(SFXPlayer.currentCompletedSoundName()!, color: UIColor.whiteColor())
   }
   
   @IBOutlet private var _goalieHeaderView: UIView!
   
   private var _goalieMovementAnimator: GoalieMovementAnimator!
   @IBOutlet private weak var _goalieFaceView: CharacterView! {
      didSet {
         _goalieMovementAnimator = GoalieMovementAnimator(view: _goalieFaceView)
      }
   }
   
   @IBOutlet private weak var _rightSpeechBubble: GoalieSpeechBubble!
   @IBOutlet private weak var _leftSpeechBubble: GoalieSpeechBubble! {
      didSet {
         _leftSpeechBubble.tailDirection = .Right
      }
   }
   
   @IBOutlet private weak var _settingsButton: UIButton!
   
   // For testing
   @IBAction private func _swap()
   {
      var newCharacter: GoalieCharacter = .Goalie
      if _goalieFaceView.character == .Goalie {
         newCharacter = .BizeeBee
      }
      _goalieFaceView.updateCharacter(newCharacter)
   }
   
   private var _shouldShowSpeechBubble = false
   private var _currentPriority = TaskPriority.Unknown
   
   private let _tapGestureRecognizer = UITapGestureRecognizer()
   
   // MARK: - Lifecycle
   deinit {
      NSNotificationCenter.defaultCenter().removeObserver(self)
   }
   
   override func awakeFromNib()
   {
      super.awakeFromNib()
      
      _setupHeaderView()
      _setupContentOffsetAndInset()
      _setupUIForFirstTime()
      _setupKeyboardObserving()
      
      decelerationRate = UIScrollViewDecelerationRateFast
      _tapGestureRecognizer.addTarget(self, action: "goalieTapped")
      _goalieFaceView.addGestureRecognizer(_tapGestureRecognizer)
      
      _goalieFaceView.updateCharacter(.BizeeBee)
   }
   
   func goalieTapped()
   {
      print("tapped!")
   }
   
   // MARK: - Setup
   private func _setupKeyboardObserving()
   {
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)
   }
   
   private func _setupHeaderView()
   {
      tableHeaderView = nil
      superview?.addSubview(_goalieHeaderView)
   }
   
{'fraction_non_alphanumeric': 0.0796381432596767, 'fraction_numerical': 0.004745662168174403, 'mean_word_length': 3.7193841847445768, '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': '941157', 'n_tokens_mistral': 2102, 'n_tokens_neox': 2065, 'n_words': 385}