<commit_before>//
//  BookCustomController.swift
//  MyReader
//
//  Created by RN-079 on 2017/02/22.
//  Copyright © 2017年 RN-079. All rights reserved.
//

import UIKit
import RxSwift


/**
 * TODO List.
 文字のサイズと文字色を変更する方法がわからない。
 
 **/
class BookCustomController: LeavesViewController {
    @IBOutlet weak var indicator : UIActivityIndicatorView!
    @IBOutlet weak var topView: UIView!
    @IBOutlet weak var backBtn: UIButton!
    @IBOutlet weak var titleLbl: UILabel!
    @IBOutlet weak var bottomView : UIView!
    @IBOutlet weak var chapterLbl: UILabel!
    @IBOutlet weak var preBtn: UIButton!
    @IBOutlet weak var nextBtn: UIButton!
    @IBOutlet weak var slider: UISlider!
    @IBOutlet weak var listBtn: UIButton!
    @IBOutlet weak var bookmarkBtn: UIButton!
    @IBOutlet weak var lightBtn: UIButton!
    @IBOutlet weak var fontBtn: UIButton!
    
    @IBOutlet weak var tapView: UIView!
    @IBOutlet weak var addBookmarkBtn: UIButton!
    
    var disposeBag = DisposeBag()
    var bookInfo : LocalBookInfo!
    let model = BookCustomModel()
    
    var lightMode = Variable(UserDefaults.standard.integer(forKey: UDKey.LightMode))
    
    @IBAction func addBookmark() {
        let storyboard = UIStoryboard(name: "AddBookmark", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? AddBookmarkController else {
            return
        }
        
        next.bookId = bookInfo.bookId
        let pageNumber = self.getCurrentPage()
        next.pageNumber = pageNumber
        next.content = self.model.pageContents[pageNumber].string
        
        next.modalPresentationStyle = .custom
        self.present(next, animated: true, completion: nil)
        
    }
    
    @IBAction func showList() {
        let storyboard = UIStoryboard(name: "Chapter", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? NavigationController else {
            return
        }
        guard let chapterController = next.viewControllers.first as? ChapterController else {
            return
        }
        chapterController.chapterInfos = model.chapterInfos
        
        self.present(next, animated: true, completion: nil)
    }
    
    @IBAction func showBookmarks() {
        // bookmark 画面を開く.
        let storyboard = UIStoryboard(name: "Bookmark", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? NavigationController else {
            return
        }
        
        guard let _ = next.viewControllers.first as? BookmarkController else {<commit_msg>add context<commit_after>//
//  BookCustomController.swift
//  MyReader
//
//  Created by RN-079 on 2017/02/22.
//  Copyright © 2017年 RN-079. All rights reserved.
//

import UIKit
import RxSwift


/**
 * TODO List.
 文字のサイズと文字色を変更する方法がわからない。
 
 **/
class BookCustomController: LeavesViewController {
    @IBOutlet weak var indicator : UIActivityIndicatorView!
    @IBOutlet weak var topView: UIView!
    @IBOutlet weak var backBtn: UIButton!
    @IBOutlet weak var titleLbl: UILabel!
    @IBOutlet weak var bottomView : UIView!
    @IBOutlet weak var chapterLbl: UILabel!
    @IBOutlet weak var preBtn: UIButton!
    @IBOutlet weak var nextBtn: UIButton!
    @IBOutlet weak var slider: UISlider!
    @IBOutlet weak var listBtn: UIButton!
    @IBOutlet weak var bookmarkBtn: UIButton!
    @IBOutlet weak var lightBtn: UIButton!
    @IBOutlet weak var fontBtn: UIButton!
    
    @IBOutlet weak var tapView: UIView!
    @IBOutlet weak var addBookmarkBtn: UIButton!
    
    var disposeBag = DisposeBag()
    var bookInfo : LocalBookInfo!
    let model = BookCustomModel()
    
    var lightMode = Variable(UserDefaults.standard.integer(forKey: UDKey.LightMode))
    
    @IBAction func addBookmark() {
        let storyboard = UIStoryboard(name: "AddBookmark", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? AddBookmarkController else {
            return
        }
        
        next.bookId = bookInfo.bookId
        let pageNumber = self.getCurrentPage()
        next.pageNumber = pageNumber
        next.content = self.model.pageContents[pageNumber].string
        
        next.modalPresentationStyle = .custom
        self.present(next, animated: true, completion: nil)
        
    }
    
    @IBAction func showList() {
        let storyboard = UIStoryboard(name: "Chapter", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? NavigationController else {
            return
        }
        
        guard let ChapterController = next.viewControllers.first as? ChapterController else {
            return
        }
        
        ChapterController.chapterInfos = model.chapterInfos
        self.present(next, animated: true, completion: nil)
        
        
        // second.
        
        
        
        
        let storyboard = UIStoryboard(name: "Chapter", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? NavigationController else {
            return
        }
        guard let chapterController = next.viewControllers.first as? ChapterController else {
            return
        }
        chapterController.chapterInfos = model.chapterInfos
        
        self.present(next, animated: true, completion: nil)
    }
    
    @IBAction func showBookmarks() {
        // bookmark 画面を開く.
        let storyboard = UIStoryboard(name: "Bookmark", bundle: nil)
        guard let next = storyboard.instantiateInitialViewController() as? NavigationController else {
            return
        }
        
        guard let _ = next.viewControllers.first as? BookmarkController else {
{'fraction_non_alphanumeric': 0.07891967730620834, 'fraction_numerical': 0.006313574184496668, 'mean_word_length': 2.546641791044776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4313822', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1626, 'n_words': 437}