captains-log

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

commit 13f158818ae5e751abc79d6a274f5eec73687a55
parent 5cb778fb649465b7af52b27e34d168a5248718d4
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Thu, 17 Oct 2019 23:05:29 -0700

First commit

Diffstat:
AcaptainsLog.xcodeproj/captains_log_stardate.playground/Contents.swift | 36++++++++++++++++++++++++++++++++++++
AcaptainsLog.xcodeproj/captains_log_stardate.playground/contents.xcplayground | 5+++++
AcaptainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/contents.xcworkspacedata | 7+++++++
AcaptainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist | 8++++++++
McaptainsLog.xcodeproj/project.pbxproj | 4++++
McaptainsLog.xcodeproj/project.xcworkspace/contents.xcworkspacedata | 5++++-
McaptainsLog/ContentView.swift | 40+++++++++++++++++++++++++++++++++++++++-
AcaptainsLog/stardate_calc.swift | 34++++++++++++++++++++++++++++++++++
8 files changed, 137 insertions(+), 2 deletions(-)

diff --git a/captainsLog.xcodeproj/captains_log_stardate.playground/Contents.swift b/captainsLog.xcodeproj/captains_log_stardate.playground/Contents.swift @@ -0,0 +1,36 @@ +import UIKit + + +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) +print(stardate) diff --git a/captainsLog.xcodeproj/captains_log_stardate.playground/contents.xcplayground b/captainsLog.xcodeproj/captains_log_stardate.playground/contents.xcplayground @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<playground version='5.0' target-platform='ios'> + <timeline fileName='timeline.xctimeline'/> +</playground> +\ No newline at end of file diff --git a/captainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/contents.xcworkspacedata b/captainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:"> + </FileRef> +</Workspace> diff --git a/captainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/captainsLog.xcodeproj/captains_log_stardate.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IDEDidComputeMac32BitWarning</key> + <true/> +</dict> +</plist> diff --git a/captainsLog.xcodeproj/project.pbxproj b/captainsLog.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ 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 */; }; @@ -16,6 +17,7 @@ /* 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>"; }; @@ -56,6 +58,7 @@ 3A35D6DE23579F7B005B7610 /* captainsLog */ = { isa = PBXGroup; children = ( + 3A1F93A623598A41007C8885 /* stardate_calc.swift */, 3A35D6DF23579F7B005B7610 /* AppDelegate.swift */, 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */, 3A35D6E323579F7B005B7610 /* ContentView.swift */, @@ -146,6 +149,7 @@ 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.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/captainsLog.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,9 @@ <Workspace version = "1.0"> <FileRef - location = "self:captainsLog.xcodeproj"> + location = "group:captains_log_stardate.playground"> + </FileRef> + <FileRef + location = "self:"> </FileRef> </Workspace> diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -9,8 +9,46 @@ import SwiftUI struct ContentView: View { + @State private var recording = false + @State private var timeElapsed = 0.00 + @State private var timer:Timer? + var body: some View { - Text("Hello World") + VStack { + 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 + }) + } else { + self.timer?.invalidate() + } + }) { + Image( + uiImage: UIImage( + systemName: recording ? "mic.fill" : "mic", + withConfiguration: UIImage.SymbolConfiguration( + pointSize: CGFloat.init(75), + weight: .regular, + scale: .large + ) + )! + ) + } + .foregroundColor(Color.primary) + .animation(.none) + Text("\(timeElapsed, specifier: "%.2f") sec") + } + Spacer() + VStack { + Text("Stardate") + Image(uiImage: UIImage(systemName: "waveform", withConfiguration: UIImage.SymbolConfiguration(pointSize: CGFloat.init(50), weight: .medium, scale: .large))!) + } + Spacer() + } } } diff --git a/captainsLog/stardate_calc.swift b/captainsLog/stardate_calc.swift @@ -0,0 +1,34 @@ +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)