mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-16 18:40:08 +08:00
37 lines
922 B
Swift
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
|
|
}
|
|
|
|
}
|