captains-log

[TO-FIX] audiojournaling app
git clone git://git.figbert.com/captains-log.git
Log | Files | Refs

GlobalVars.swift (3570B)


      1 //
      2 //  GlobalVars.swift
      3 //  captainsLog
      4 //
      5 //  Created by Benjamin Welner on 10/25/19.
      6 //  Copyright © 2019 FIGBERT Industries. All rights reserved.
      7 //
      8 
      9 import Foundation
     10 import Combine
     11 import SwiftUI
     12 
     13 class GlobalVars: ObservableObject {
     14     @Published var saveLocally: Bool = true
     15     @Published var saveICloud: Bool = true
     16     @Published var currentDateFormat: Int = 0 {
     17         willSet {
     18             switch newValue {
     19             case 1:
     20                 date = Date().multi(type: "Jewish")
     21             case 2:
     22                 date = Date().multi(type: "Islamic")
     23             case 3:
     24                 date = Date().multi(type: "Persian")
     25             case 4:
     26                 date = Date().multi(type: "Indian")
     27             case 5:
     28                 date = Date().multi(type: "Coptic")
     29             case 6:
     30                 date = Date().multi(type: "Chinese")
     31             case 7:
     32                 date = Date().multi(type: "Japanese")
     33             case 8:
     34                 date = Date().multi(type: "Ethiopian")
     35             case 9:
     36                 date = Date().multi(type: "Gregorian")
     37             default:
     38                 date = Date().stardate()
     39             }
     40             strDate = date.joined(separator: newValue == 0 ? " " : "")
     41             messages[0] = "Captain’s log, \(strDate)"
     42             iterateMessage = messages[currentMessage].components(separatedBy: " ")
     43         }
     44     }
     45     @Published var dateListPos: Int = 0
     46     @Published var currentMessage: Int = 0 {
     47         willSet {
     48             iterateMessage = messages[newValue].components(separatedBy: " ")
     49         }
     50     }
     51     @Published var name: String = "Unknown" {
     52         willSet {
     53             messages[1] = "A day in the life of \(newValue), entry \(1)"
     54             messages[2] = "\(newValue)'s audio journal, day \(1)"
     55             messages[3] = "Hi, I'm \(newValue)"
     56             messages[4] = "\(newValue)'s audio journal, for your ears only."
     57         }
     58     }
     59     let dateFormats = [
     60         "Stardate",
     61         "Jewish",
     62         "Islamic",
     63         "Persian",
     64         "Indian",
     65         "Coptic",
     66         "Chinese",
     67         "Japanese",
     68         "Ethiopian",
     69         "Gregorian"
     70     ]
     71     @Published var messages: [String] = [""]
     72     @Published var date: [String] = [""]
     73     @Published var strDate: String = ""
     74     @Published var iterateMessage: [String] = [""]
     75     init() {
     76         switch currentDateFormat {
     77         case 1:
     78             date = Date().multi(type: "Jewish")
     79         case 2:
     80             date = Date().multi(type: "Islamic")
     81         case 3:
     82             date = Date().multi(type: "Persian")
     83         case 4:
     84             date = Date().multi(type: "Indian")
     85         case 5:
     86             date = Date().multi(type: "Coptic")
     87         case 6:
     88             date = Date().multi(type: "Chinese")
     89         case 7:
     90             date = Date().multi(type: "Japanese")
     91         case 8:
     92             date = Date().multi(type: "Ethiopian")
     93         case 9:
     94             date = Date().multi(type: "Gregorian")
     95         default:
     96             date = Date().stardate()
     97         }
     98         strDate = date.joined(separator: currentDateFormat == 0 ? " " : "")
     99         messages = [
    100             "Captain’s log, \(strDate)",
    101             "A day in the life of \(name), entry \(1)",
    102             "\(name)'s audio journal, day \(1)",
    103             "Hi, I'm \(name)",
    104             "\(name)'s audio journal, for your ears only.",
    105             "Random thoughts, entry \(1)",
    106             "Here's the tea, sis",
    107             "Rise and grind, gamers"
    108         ]
    109         iterateMessage = messages[currentMessage].components(separatedBy: " ")
    110     }
    111 }