<commit_before>//
//  SettingsViewModel.swift
//  DesignStudioExpress
//
//  Created by <NAME> on 12/10/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import SafariServices
import AcknowList

struct Setting {
    let title: String
    let description: String?
    let icon: String?
    // this feels icky FIXME
    let action: (UIViewController) -> ()
    
    init (title: String, description: String? = nil, icon: String? = nil, action: (UIViewController) -> ()) {
        self.title = title
        self.description = description
        self.icon = icon
        self.action = action
    }
}

class SettingsViewModel {
    private var data: [Setting]!
    
    init () {
        data = self.loadStaticSettings()
    }
    
    private func loadStaticSettings() -> [Setting] {
        return [
            // TODO images
            Setting(title: "Who Made This?", action:  { vc in
                let svc = SFSafariViewController(URL: NSURL(string: "http://www.alexanderinteractive.com/company/")!)
                vc.presentViewController(svc, animated: true, completion: nil)
            }),
            
            Setting(title: "Legal", action: { vc in
                let legalController = AcknowListViewController()
                if let navigationController = vc.navigationController {
                    navigationController.pushViewController(legalController, animated: true)
                }
            }),
            
            Setting(title: "Contact Us", action: { vc in
                if MFMailComposeViewController.canSendMail() {
                    // https://github.com/monkeymike/MPFeedbackMailComposeViewController
                    
                    let feedbackController = MPFeedbackMailComposeViewController()
                    
                    feedbackController.mailComposeDelegate = vc as! SettingsViewController
                    
                    // TODO update with real email
                    feedbackController.setToRecipients(["<EMAIL>"])
                    
                    feedbackController.setSubject("Design Studio Express Feedback")
                    feedbackController.setMessageBody("Feedback:\n\n\n\n\n\n\n\n\n--------\nDeveloper Information:", isHTML:false)
                    
                    if let navigationController = vc.navigationController {
                        navigationController.presentViewController(feedbackController, animated: true, completion:nil)
                    }
                } else {
                    // show the alert if we can send the email
                    let alertController = UIAlertController(title: "Preparing email failed", message: "Please configure your device to send email", preferredStyle: .Alert)
                    let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
                    alertController.addAction(okAction)
                    
                    if let navigationController = vc.navigationController {
                        navigationController.presentViewController(alertController, animated: true, completion: nil)
                    }
                }
            }),
            
            Setting(title: "Review on App Store", action: { vc in
                // https://itunes.apple.com/us/app/whackjob/id1054379438?at=11laRZ&ct=pro&ls=1&mt=8
                UIApplication.sharedApplication().openURL(NSURL(string : "itms-apps://itunes.apple.com/app/id1054379438")!)
            }),
            
            Setting(title: "Share this app", action: { vc in
                
                //text lives in DesignStudioActivityItemSource.swift
                
                let activityController = UIActivityViewController(activityItems: [DesignStudioActivityItemSource()], applicationActivities: nil)
                if let navigationController = vc.navigationController {
                    navigationController.presentViewController(activityController, animated: true, completion:nil)
                }
            })
                //Setting(title: "The team", icon: "Clock"), // Github pod?
        ]
    }<commit_msg>Minor cleanup<commit_after>//
//  SettingsViewModel.swift
//  DesignStudioExpress
//
//  Created by <NAME> on 12/10/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import SafariServices
import AcknowList

struct Setting {
    let title: String
    let description: String?
    let icon: String?
    // this feels icky FIXME
    let action: (UIViewController) -> ()
    
    init (title: String, description: String? = nil, icon: String? = nil, action: (UIViewController) -> ()) {
        self.title = title
        self.description = description
        self.icon = icon
        self.action = action
    }
}

class SettingsViewModel {
    private var data: [Setting]!
    
    let emailErrorMessageTitleText = "Preparing email failed"
    let emailErrorMessageMessageText = "Please configure your device to send email"
    
    init () {
        data = self.loadStaticSettings()
    }
    
    private func loadStaticSettings() -> [Setting] {
        return [
            // TODO images
            Setting(title: "Who Made This?", action:  { vc in
                let svc = SFSafariViewController(URL: NSURL(string: "http://www.alexanderinteractive.com/company/")!)
                vc.presentViewController(svc, animated: true, completion: nil)
            }),
            
            Setting(title: "Legal", action: { vc in
                let legalController = AcknowListViewController()
                if let navigationController = vc.navigationController {
                    navigationController.pushViewController(legalController, animated: true)
                }
            }),
            
            Setting(title: "Contact Us", action: { vc in
                if MFMailComposeViewController.canSendMail() {
                    // https://github.com/monkeymike/MPFeedbackMailComposeViewController
                    
                    let feedbackController = MPFeedbackMailComposeViewController()
                    
                    feedbackController.mailComposeDelegate = vc as! SettingsViewController
                    
                    // TODO update with real email
                    feedbackController.setToRecipients(["<EMAIL>"])
                    
                    feedbackController.setSubject("Design Studio Express Feedback")
                    feedbackController.setMessageBody("Feedback:\n\n\n\n\n\n\n\n\n--------\nDeveloper Information:", isHTML:false)
                    
                    if let navigationController = vc.navigationController {
                        navigationController.presentViewController(feedbackController, animated: true, completion:nil)
                    }
                } else {
                    // show the alert if we can send the email
                    let alertController = UIAlertController(title: self.emailErrorMessageTitleText, message: self.emailErrorMessageMessageText, preferredStyle: .Alert)
                    let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
                    alertController.addAction(okAction)
                    
                    if let navigationController = vc.navigationController {
                        navigationController.presentViewController(alertController, animated: true, completion: nil)
                    }
                }
            }),
            
            Setting(title: "Review on App Store", action: { vc in
                // https://itunes.apple.com/us/app/whackjob/id1054379438?at=11laRZ&ct=pro&ls=1&mt=8
                UIApplication.sharedApplication().openURL(NSURL(string : "itms-apps://itunes.apple.com/app/id1054379438")!)
            }),
            
            Setting(title: "Share this app", action: { vc in
                
                //text lives in DesignStudioActivityItemSource.swift
                
                let activityController = UIActivityViewController(activityItems: [DesignStudioActivityItemSource()], applicationActivities: nil)
                if let navigationController = vc.navigationController {
                    navigationController.presentViewController(activityController, animated: true, completion:nil)
                }
            })
                //Setting(title: "The team", icon: "Clock"), // Github pod?
        ]
    }
{'fraction_non_alphanumeric': 0.08971475914309386, 'fraction_numerical': 0.008048289738430584, 'mean_word_length': 1.7768649359185016, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6811685', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1935, 'n_words': 467}