captains-log

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

commit 82b331e635c55b05e69fa05e33392bae2f24015f
parent a72930a3d91b925db9b1e1883617e30b7fdc51c8
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Fri,  8 Nov 2019 12:52:22 -0800

Implementing intro message iteration with a one second delay

Diffstat:
MGlobalVars.swift | 3+++
McaptainsLog/ContentView.swift | 15++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/GlobalVars.swift b/GlobalVars.swift @@ -39,6 +39,7 @@ class GlobalVars: ObservableObject { date = Date().stardate() } strDate = date.joined(separator: newValue == 0 ? " " : "") + iterateMessage = strDate.components(separatedBy: " ") messages[0] = "Captain’s log, \(strDate)" } } @@ -67,6 +68,7 @@ class GlobalVars: ObservableObject { @Published var messages: [String] = [""] @Published var date: [String] = [""] @Published var strDate: String = "" + @Published var iterateMessage: [String] = [""] init() { switch currentDateFormat { case 1: @@ -91,6 +93,7 @@ class GlobalVars: ObservableObject { date = Date().stardate() } strDate = date.joined(separator: currentDateFormat == 0 ? " " : "") + iterateMessage = strDate.components(separatedBy: " ") messages = [ "Captain’s log, \(strDate)", "A day in the life of \(name), entry \(1)", diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -14,6 +14,7 @@ struct ContentView: View { @State private var timeElapsed: Double = 0.00 @State private var timer:Timer? @State private var msg: String = "" + let timeBuffer: Double = 1 var body: some View { NavigationView { @@ -25,15 +26,14 @@ struct ContentView: View { self.audioRecorder.startRecording() self.timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { timer in self.timeElapsed += 0.01 - if (self.timeElapsed <= 0.75) { - self.msg = "Captain's" - } else if (self.timeElapsed <= 1.5) { - self.msg = "log" - } else { - self.msg = self.globalVars.date[self.globalVars.dateListPos] - if (self.globalVars.dateListPos+1 <= self.globalVars.date.count-1) { + if (self.globalVars.dateListPos < self.globalVars.iterateMessage.count) { + if (self.timeElapsed <= Double(self.globalVars.dateListPos+1)*self.timeBuffer) { + self.msg = self.globalVars.iterateMessage[self.globalVars.dateListPos] + } else { self.globalVars.dateListPos += 1 } + } else { + self.msg = "" } }) } else { @@ -69,6 +69,7 @@ struct ContentView: View { Button(action: { self.timeElapsed = 0.00 self.audioRecorder.endRecording() + self.globalVars.dateListPos = 0 }) { imgTextButtonStyle(sysImg: "waveform", imgSize: 15, buttonText: "Save") }