<commit_before>//
//  SettingsMainVC.swift
//  HTWDD
//
//  Created by <NAME> on 04.11.17.
//  Copyright © 2017 HTW Dresden. All rights reserved.
//

import UIKit
import MessageUI

protocol SettingsMainVCDelegate: class {
    func deleteAllData()
    func triggerScheduleOnboarding(completion: @escaping (ScheduleService.Auth) -> Void)
    func triggerGradeOnboarding(completion: @escaping (GradeService.Auth) -> Void)
    func showLectureManager(auth: ScheduleService.Auth?)
    
	func showLicense(name: String)
	func showGitHub()
    func composeMail()
}

class SettingsMainVC: TableViewController {
	
    var scheduleAuth: ScheduleService.Auth? {
        didSet {
            self.configure()
        }
    }
    
    var gradesAuth: GradeService.Auth? {
        didSet {
            self.configure()
        }
    }
	
	private var settings: [(String?, [SettingsItem])] {
		return [
			(nil, [
				SettingsItem(title: Loca.Settings.items.setSchedule.title,
							 subtitle: self.scheduleAuth.map { auth in Loca.Settings.items.setSchedule.subtitle(auth.year, auth.major, auth.group) },
                             thumbnail: #imageLiteral(resourceName: "Mail"),
							 action: self.showScheduleOnboarding()),
				SettingsItem(title: Loca.Settings.items.setGrades.title,
							 subtitle: self.gradesAuth.map { auth in Loca.Settings.items.setGrades.subtitle(auth.username) },
                             thumbnail: #imageLiteral(resourceName: "Mail"),
							 action: self.showGradeOnboarding())
			]),
            (Loca.Schedule.title, [
                SettingsItem(title: Loca.Schedule.Settings.Hide.title,
                             thumbnail: #imageLiteral(resourceName: "Mail"),
                             action: self.showLectureManager())
            ]),
            (Loca.Settings.sections.weAreOpenSource, [
				SettingsItem(title: Loca.Settings.items.github,
                             thumbnail: #imageLiteral(resourceName: "GitHub"),
                             action: self.showGitHub())
			]),
            (Loca.Settings.sections.contact, [
                SettingsItem(title: Loca.Settings.items.mail.title,
                             thumbnail: #imageLiteral(resourceName: "Mail"),
                             action: self.composeMail()),
                SettingsItem(title: Loca.Settings.items.legal.title,
                             thumbnail: #imageLiteral(resourceName: "Mail"),
                             action: self.showLicense(name: "HTW-Impressum.html"))
            ]),
            (Loca.Settings.sections.openSource, [<commit_msg>Use new assets<commit_after>//
//  SettingsMainVC.swift
//  HTWDD
//
//  Created by <NAME> on 04.11.17.
//  Copyright © 2017 HTW Dresden. All rights reserved.
//

import UIKit
import MessageUI

protocol SettingsMainVCDelegate: class {
    func deleteAllData()
    func triggerScheduleOnboarding(completion: @escaping (ScheduleService.Auth) -> Void)
    func triggerGradeOnboarding(completion: @escaping (GradeService.Auth) -> Void)
    func showLectureManager(auth: ScheduleService.Auth?)
    
	func showLicense(name: String)
	func showGitHub()
    func composeMail()
}

class SettingsMainVC: TableViewController {
	
    var scheduleAuth: ScheduleService.Auth? {
        didSet {
            self.configure()
        }
    }
    
    var gradesAuth: GradeService.Auth? {
        didSet {
            self.configure()
        }
    }
	
	private var settings: [(String?, [SettingsItem])] {
		return [
			(nil, [
				SettingsItem(title: Loca.Settings.items.setSchedule.title,
							 subtitle: self.scheduleAuth.map { auth in Loca.Settings.items.setSchedule.subtitle(auth.year, auth.major, auth.group) },
                             thumbnail: #imageLiteral(resourceName: "StudyGroup"),
							 action: self.showScheduleOnboarding()),
				SettingsItem(title: Loca.Settings.items.setGrades.title,
							 subtitle: self.gradesAuth.map { auth in Loca.Settings.items.setGrades.subtitle(auth.username) },
                             thumbnail: #imageLiteral(resourceName: "Credentials"),
							 action: self.showGradeOnboarding())
			]),
            (Loca.Schedule.title, [
                SettingsItem(title: Loca.Schedule.Settings.Hide.title,
                             thumbnail: #imageLiteral(resourceName: "ScheduleManager"),
                             action: self.showLectureManager())
            ]),
            (Loca.Settings.sections.weAreOpenSource, [
				SettingsItem(title: Loca.Settings.items.github,
                             thumbnail: #imageLiteral(resourceName: "GitHub"),
                             action: self.showGitHub())
			]),
            (Loca.Settings.sections.contact, [
                SettingsItem(title: Loca.Settings.items.mail.title,
                             thumbnail: #imageLiteral(resourceName: "Mail"),
                             action: self.composeMail()),
                SettingsItem(title: Loca.Settings.items.legal.title,
                             thumbnail: #imageLiteral(resourceName: "Impressum"),
                             action: self.showLicense(name: "HTW-Impressum.html"))
            ]),
            (Loca.Settings.sections.openSource, [
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.0038580246913580245, 'mean_word_length': 2.136721113127647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2362543', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1382, 'n_words': 250}