<commit_before>//
//  TripsView.swift
//  SmartReceipts
//
//  Created by <NAME> on 11/06/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import Viperit
import RxSwift
import MKDropdownMenu

//MARK: - Public Interface Protocol
protocol TripsViewInterface {
    var settingsTap: Observable<Void> { get }
    var autoScansTap: Observable<Void> { get }
    var addButton: UIButton { get }
    var debugButton: UIBarButtonItem { get }
}

//MARK: Trips View
final class TripsView: FetchedTableViewController {
    
    @IBOutlet fileprivate weak var menuButton: UIBarButtonItem!
    @IBOutlet fileprivate weak var _debugButton: UIBarButtonItem!
    @IBOutlet fileprivate weak var _addButton: UIButton!
    @IBOutlet fileprivate weak var editItem: UIBarButtonItem!
    
    private var priceWidth: CGFloat = 0
    private let dateFormatter = WBDateFormatter()
    private var lastDateSeparator: String!
    private let bag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        AppTheme.customizeOnViewDidLoad(self)
        setPresentationCellNib(WBCellWithPriceNameDate.viewNib())
        navigationController?.setToolbarHidden(true, animated: false)
        
        NotificationCenter.default.addObserver(self, selector: #selector(settingsSaved),
                        name: NSNotification.Name.SmartReceiptsSettingsSaved, object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(fetchObjects),
                        name: NSNotification.Name.SmartReceiptsImport, object: nil)
        
        lastDateSeparator = WBPreferences.dateSeparator()
        
        editItem.rx.tap.subscribe(onNext: { [unowned self] in
            self.setEditing(!self.isEditing, animated: true)
        }).disposed(by: bag)
        
        configureDebug()
    }
    
    deinit {
        NotificationCenter.default.removeObserver(self)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        title = AppTheme.appTitle
        //configureMenu()
        view.layoutIfNeeded()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        title = String()<commit_msg>Added comment for Menu Button<commit_after>//
//  TripsView.swift
//  SmartReceipts
//
//  Created by <NAME> on 11/06/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import Viperit
import RxSwift
import MKDropdownMenu

//MARK: - Public Interface Protocol
protocol TripsViewInterface {
    var settingsTap: Observable<Void> { get }
    var autoScansTap: Observable<Void> { get }
    var addButton: UIButton { get }
    var debugButton: UIBarButtonItem { get }
}

//MARK: Trips View
final class TripsView: FetchedTableViewController {
    
    @IBOutlet fileprivate weak var menuButton: UIBarButtonItem!
    @IBOutlet fileprivate weak var _debugButton: UIBarButtonItem!
    @IBOutlet fileprivate weak var _addButton: UIButton!
    @IBOutlet fileprivate weak var editItem: UIBarButtonItem!
    
    private var priceWidth: CGFloat = 0
    private let dateFormatter = WBDateFormatter()
    private var lastDateSeparator: String!
    private let bag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        AppTheme.customizeOnViewDidLoad(self)
        setPresentationCellNib(WBCellWithPriceNameDate.viewNib())
        navigationController?.setToolbarHidden(true, animated: false)
        
        NotificationCenter.default.addObserver(self, selector: #selector(settingsSaved),
                        name: NSNotification.Name.SmartReceiptsSettingsSaved, object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(fetchObjects),
                        name: NSNotification.Name.SmartReceiptsImport, object: nil)
        
        lastDateSeparator = WBPreferences.dateSeparator()
        
        editItem.rx.tap.subscribe(onNext: { [unowned self] in
            self.setEditing(!self.isEditing, animated: true)
        }).disposed(by: bag)
        
        configureDebug()
    }
    
    deinit {
        NotificationCenter.default.removeObserver(self)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        title = AppTheme.appTitle
        
        // Commented, until fix it https://github.com/maxkonovalov/MKDropdownMenu/issues/43
        //configureMenu()
        
        view.layoutIfNeeded()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        title = String()
{'fraction_non_alphanumeric': 0.0838025119099177, 'fraction_numerical': 0.006063230835859679, 'mean_word_length': 2.85559265442404, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '1203971', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1316, 'n_words': 304}