captains-log

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

commit a310b0a7e411a52d1a4a513a2607b441eb81d3f2
parent 1d32ad70f01d8fbdd953b882eab3d86af27348f7
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Fri, 18 Oct 2019 12:07:12 -0700

Adding additional formatting to the stardate

Diffstat:
McaptainsLog/ContentView.swift | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -8,6 +8,14 @@ import SwiftUI +extension Double { + func withCommas() -> String { + let numberFormatter = NumberFormatter() + numberFormatter.numberStyle = NumberFormatter.Style.decimal + return numberFormatter.string(from: NSNumber(value:self))! + } +} + struct ContentView: View { @State private var recording = false @State private var timeElapsed = 0.00 @@ -52,14 +60,14 @@ struct ContentView: View { if (self.recording) { self.timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { timer in self.timeElapsed += 0.01 - if (self.timeElapsed <= 1) { + if (self.timeElapsed <= 0.75) { self.msg = "Captain's" - } else if (self.timeElapsed <= 2) { + } else if (self.timeElapsed <= 1.5) { self.msg = "log" - } else if (self.timeElapsed <= 3) { + } else if (self.timeElapsed <= 2.25) { self.msg = "stardate" - } else if (self.timeElapsed <= 7) { - self.msg = "\(self.stardate)" + } else if (self.timeElapsed <= 5) { + self.msg = "\(self.stardate.withCommas())" } else { self.msg = "" }