captains-log

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

commit abff03fc686dfe9dc8a0882f7bac64c362a8b2a0
parent a310b0a7e411a52d1a4a513a2607b441eb81d3f2
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Fri, 18 Oct 2019 14:20:07 -0700

Small graphical changes

Diffstat:
McaptainsLog.xcodeproj/project.pbxproj | 4----
McaptainsLog/ContentView.swift | 82+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
DcaptainsLog/stardate_calc.swift | 34----------------------------------
3 files changed, 47 insertions(+), 73 deletions(-)

diff --git a/captainsLog.xcodeproj/project.pbxproj b/captainsLog.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 3A1F93A723598A41007C8885 /* stardate_calc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A1F93A623598A41007C8885 /* stardate_calc.swift */; }; 3A35D6E023579F7B005B7610 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A35D6DF23579F7B005B7610 /* AppDelegate.swift */; }; 3A35D6E223579F7B005B7610 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */; }; 3A35D6E423579F7B005B7610 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A35D6E323579F7B005B7610 /* ContentView.swift */; }; @@ -17,7 +16,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 3A1F93A623598A41007C8885 /* stardate_calc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = stardate_calc.swift; sourceTree = "<group>"; }; 3A35D6DC23579F7B005B7610 /* captainsLog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = captainsLog.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3A35D6DF23579F7B005B7610 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; }; @@ -58,7 +56,6 @@ 3A35D6DE23579F7B005B7610 /* captainsLog */ = { isa = PBXGroup; children = ( - 3A1F93A623598A41007C8885 /* stardate_calc.swift */, 3A35D6DF23579F7B005B7610 /* AppDelegate.swift */, 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */, 3A35D6E323579F7B005B7610 /* ContentView.swift */, @@ -149,7 +146,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A1F93A723598A41007C8885 /* stardate_calc.swift in Sources */, 3A35D6E023579F7B005B7610 /* AppDelegate.swift in Sources */, 3A35D6E223579F7B005B7610 /* SceneDelegate.swift in Sources */, 3A35D6E423579F7B005B7610 /* ContentView.swift in Sources */, diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -52,52 +52,64 @@ struct ContentView: View { }() var body: some View { - VStack { - Spacer() + NavigationView { VStack { - Button(action: { - self.recording.toggle() - if (self.recording) { - 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 if (self.timeElapsed <= 2.25) { - self.msg = "stardate" - } else if (self.timeElapsed <= 5) { - self.msg = "\(self.stardate.withCommas())" - } else { - self.msg = "" - } - }) - } else { - self.timer?.invalidate() + Spacer() + VStack { + Button(action: { + self.recording.toggle() + if (self.recording) { + 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 if (self.timeElapsed <= 2.25) { + self.msg = "stardate" + } else if (self.timeElapsed <= 5) { + self.msg = "\(self.stardate.withCommas())" + } else { + self.msg = "" + } + }) + } else { + self.timer?.invalidate() + } + }) { + Image( + uiImage: UIImage( + systemName: recording ? "mic.fill" : "mic", + withConfiguration: UIImage.SymbolConfiguration( + pointSize: CGFloat.init(100), + weight: .regular, + scale: .large + ) + )! + ) } - }) { + .foregroundColor(Color.primary) + .animation(.none) + Text("\(timeElapsed, specifier: "%.2f") sec") + } + Spacer() + VStack { + Text("\(self.msg)") + .font(.system(size: 24, weight: .regular, design: .rounded)) Image( uiImage: UIImage( - systemName: recording ? "mic.fill" : "mic", + systemName: "waveform", withConfiguration: UIImage.SymbolConfiguration( - pointSize: CGFloat.init(100), - weight: .regular, + pointSize: CGFloat.init(50), + weight: .medium, scale: .large ) )! ) + .foregroundColor(Color.primary) } - .foregroundColor(Color.primary) - .animation(.none) - Text("\(timeElapsed, specifier: "%.2f") sec") - } - Spacer() - VStack { - Text("\(self.msg)") - .font(.system(size: 24, weight: .regular, design: .rounded)) - Image(uiImage: UIImage(systemName: "waveform", withConfiguration: UIImage.SymbolConfiguration(pointSize: CGFloat.init(50), weight: .medium, scale: .large))!) + Spacer() } - Spacer() } } } diff --git a/captainsLog/stardate_calc.swift b/captainsLog/stardate_calc.swift @@ -1,34 +0,0 @@ -import Foundation - -let date = Date() -let calendar = Calendar.current -let year = calendar.component(.year, from: date) -let month = calendar.component(.month, from: date) -let day = calendar.component(.day, from: date) -let hour = calendar.component(.hour, from: date) -let minutes = calendar.component(.minute, from: date) -let seconds = calendar.component(.second, from: date) -let leapyear = !(year % 100 == 0) && year % 4 == 0 ? true : false - -let months = [ - 1: 0, - 2: 31, - 3: !leapyear ? 59 : 60, - 4: !leapyear ? 90 : 91, - 5: !leapyear ? 120 : 121, - 6: !leapyear ? 151 : 152, - 7: !leapyear ? 181 : 182, - 8: !leapyear ? 212 : 213, - 9: !leapyear ? 243 : 244, - 10: !leapyear ? 273 : 274, - 11: !leapyear ? 304 : 305, - 12: !leapyear ? 334 : 335 -] - -let n = !leapyear ? 365 : 366 -let b = 2005 -let c = 58000.0 -let monthValue = Double(months[month] ?? 0) -let stageOne = Double(1000*(year-b)) -let stageTwo = (1000.0/Double(n))*(monthValue + Double(day) - 1.0) -let stardate = Double(round(100*(c + stageOne + stageTwo))/100)