captains-log

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

commit d63835c508f9961f1794fad3646f9218bbf8c41e
parent 7fcdc1fb6a0edd4ec675241169744f1576b79ffd
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Sun, 20 Oct 2019 16:25:05 -0700

Refining homescreen/settings interface

Diffstat:
MSettings.swift | 46++++++++++++++++++++++------------------------
McaptainsLog.xcodeproj/project.pbxproj | 8++++----
McaptainsLog/ContentView.swift | 42+++++-------------------------------------
AcaptainsLog/Elements.swift | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DcaptainsLog/Extensions.swift | 49-------------------------------------------------
5 files changed, 106 insertions(+), 114 deletions(-)

diff --git a/Settings.swift b/Settings.swift @@ -32,37 +32,35 @@ struct Settings: View { "Rise and grind, gamers" ] var body: some View { - NavigationView{ - Form { - Section(header: Text("Save")) { - Toggle(isOn: $saveLocally) { - Text("Save on device") - } - Toggle(isOn: $saveICloud) { - Text("Save to iCloud") - } + Form { + Section(header: Text("Save")) { + Toggle(isOn: $saveLocally) { + Text("Save on device") } - Section(header: Text("Name")) { - TextField("Name", text: $name) + Toggle(isOn: $saveICloud) { + Text("Save to iCloud") } - Section(header: Text("Prompt")) { - Picker("Date format", selection: $currentDateFormat) { - ForEach(0 ..< dateFormats.count) { - Text("\(self.dateFormats[$0])") - } + } + Section(header: Text("Name")) { + TextField("Name", text: $name) + } + Section(header: Text("Prompt")) { + Picker("Date format", selection: $currentDateFormat) { + ForEach(0 ..< dateFormats.count) { + Text("\(self.dateFormats[$0])") } - Picker("Intro message", selection: $currentMessage) { - ForEach(0 ..< messages.count) { - Text("\(self.messages[$0])") - } + } + Picker("Intro message", selection: $currentMessage) { + ForEach(0 ..< messages.count) { + Text("\(self.messages[$0])") } } } - .navigationBarTitle( - Text("Captain's Log Settings"), - displayMode: .inline - ) } + .navigationBarTitle( + Text("Captain's Log Settings"), + displayMode: .inline + ) } } diff --git a/captainsLog.xcodeproj/project.pbxproj b/captainsLog.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ 3A35D6E923579F7C005B7610 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3A35D6E823579F7C005B7610 /* Preview Assets.xcassets */; }; 3A35D6EC23579F7C005B7610 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3A35D6EA23579F7C005B7610 /* LaunchScreen.storyboard */; }; 3A76A1E8235AD08C00964901 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E7235AD08C00964901 /* Settings.swift */; }; - 3A76A1EA235AE6D500964901 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E9235AE6D500964901 /* Extensions.swift */; }; + 3A76A1EA235AE6D500964901 /* Elements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E9235AE6D500964901 /* Elements.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -27,7 +27,7 @@ 3A35D6EB23579F7C005B7610 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 3A35D6ED23579F7C005B7610 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 3A76A1E7235AD08C00964901 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = SOURCE_ROOT; }; - 3A76A1E9235AE6D500964901 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; }; + 3A76A1E9235AE6D500964901 /* Elements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Elements.swift; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -64,7 +64,7 @@ 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */, 3A35D6E323579F7B005B7610 /* ContentView.swift */, 3A76A1E7235AD08C00964901 /* Settings.swift */, - 3A76A1E9235AE6D500964901 /* Extensions.swift */, + 3A76A1E9235AE6D500964901 /* Elements.swift */, 3A35D6E523579F7C005B7610 /* Assets.xcassets */, 3A35D6EA23579F7C005B7610 /* LaunchScreen.storyboard */, 3A35D6ED23579F7C005B7610 /* Info.plist */, @@ -156,7 +156,7 @@ 3A35D6E223579F7B005B7610 /* SceneDelegate.swift in Sources */, 3A35D6E423579F7B005B7610 /* ContentView.swift in Sources */, 3A76A1E8235AD08C00964901 /* Settings.swift in Sources */, - 3A76A1EA235AE6D500964901 /* Extensions.swift in Sources */, + 3A76A1EA235AE6D500964901 /* Elements.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -58,9 +58,9 @@ struct ContentView: View { } Spacer() VStack { - Text("\(self.msg)") - .font(.system(size: 24, weight: .regular, design: .rounded)) if (self.recording) { + Text("\(self.msg)") + .font(.system(size: 24, weight: .regular, design: .rounded)) Image( uiImage: UIImage( systemName: "waveform", @@ -74,44 +74,12 @@ struct ContentView: View { .foregroundColor(Color.primary) } else { Button(action: { - print("Test") + print("TODO") }) { - HStack { - Image( - uiImage: UIImage( - systemName: "waveform", - withConfiguration: UIImage.SymbolConfiguration( - pointSize: CGFloat.init(15), - weight: .medium, - scale: .large - ) - )! - ) - Text("Save") - } - .padding() - .background(Color.primary) - .foregroundColor(Color.white) - .cornerRadius(50) + imgTextButtonStyle(sysImg: "waveform", imgSize: 15, buttonText: "Save") } NavigationLink(destination: Settings()) { - HStack { - Image( - uiImage: UIImage( - systemName: "gear", - withConfiguration: UIImage.SymbolConfiguration( - pointSize: CGFloat.init(15), - weight: .medium, - scale: .large - ) - )! - ) - Text("Settings") - } - .padding() - .background(Color.primary) - .foregroundColor(Color.white) - .cornerRadius(50) + imgTextButtonStyle(sysImg: "gear", imgSize: 15, buttonText: "Settings") } } } diff --git a/captainsLog/Elements.swift b/captainsLog/Elements.swift @@ -0,0 +1,75 @@ +// +// extensions.swift +// captainsLog +// +// Created by Benjamin Welner on 10/18/19. +// Copyright © 2019 FIGBERT Industries. All rights reserved. +// + +import Foundation +import SwiftUI + +extension Double { + func withCommas() -> String { + let numberFormatter = NumberFormatter() + numberFormatter.numberStyle = NumberFormatter.Style.decimal + return numberFormatter.string(from: NSNumber(value:self))! + } +} +extension Date { + func stardate() -> Double { + let calendar = Calendar.current + let year = calendar.component(.year, from: self) + let month = calendar.component(.month, from: self) + let day = calendar.component(.day, from: self) + let leapyear = !(year % 100 == 0) && year % 4 == 0 + 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 stageThree = c + stageOne + stageTwo + return Double(round(100*stageThree)/100) + } +} + +struct imgTextButtonStyle: View { + var sysImg: String + var imgSize: Int + var buttonText: String + + var body: some View { + HStack { + Image( + uiImage: UIImage( + systemName: sysImg, + withConfiguration: UIImage.SymbolConfiguration( + pointSize: CGFloat.init(imgSize), + weight: .medium, + scale: .large + ) + )! + ) + Text(buttonText) + } + .padding() + .background(Color.primary) + .foregroundColor(Color.white) + .cornerRadius(50) + } +} diff --git a/captainsLog/Extensions.swift b/captainsLog/Extensions.swift @@ -1,49 +0,0 @@ -// -// extensions.swift -// captainsLog -// -// Created by Benjamin Welner on 10/18/19. -// Copyright © 2019 FIGBERT Industries. All rights reserved. -// - -import Foundation -import SwiftUI - -extension Double { - func withCommas() -> String { - let numberFormatter = NumberFormatter() - numberFormatter.numberStyle = NumberFormatter.Style.decimal - return numberFormatter.string(from: NSNumber(value:self))! - } -} -extension Date { - func stardate() -> Double { - let calendar = Calendar.current - let year = calendar.component(.year, from: self) - let month = calendar.component(.month, from: self) - let day = calendar.component(.day, from: self) - let leapyear = !(year % 100 == 0) && year % 4 == 0 - 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 stageThree = c + stageOne + stageTwo - return Double(round(100*stageThree)/100) - } -}