Files
GitHawk/Classes/Systems/Signature.swift
2018-07-29 19:29:49 -04:00

37 lines
922 B
Swift

//
// Signature.swift
// Freetime
//
// Created by Ryan Nystrom on 9/12/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
enum Signature {
private static let key = "com.freetime.Signature.enabled"
static var enabled: Bool {
get {
// using the object API allows us to return true for init state
return UserDefaults.standard.object(forKey: key) as? Bool ?? true
}
set {
UserDefaults.standard.set(newValue, forKey: key)
}
}
static var signature: String {
let format = NSLocalizedString("Sent with %@", comment: "")
let signature = String(format: format, "<a href=\"http://githawk.com\">GitHawk</a>")
return "\n\n<sub>\(signature)</sub>"
}
static func signed(text: String) -> String {
guard enabled else { return text }
return text + signature
}
}