captains-log

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

commit 7fcdc1fb6a0edd4ec675241169744f1576b79ffd
parent 312e3876d71309eed8597ce37b3a644a7aae2822
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Sun, 20 Oct 2019 12:17:46 -0700

Restructuring the views, adding settings and save buttons to homepage

Diffstat:
DHomepage.swift | 85-------------------------------------------------------------------------------
MSettings.swift | 8++++----
McaptainsLog.xcodeproj/project.pbxproj | 6+-----
McaptainsLog/ContentView.swift | 114++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
McaptainsLog/Extensions.swift | 1+
5 files changed, 114 insertions(+), 100 deletions(-)

diff --git a/Homepage.swift b/Homepage.swift @@ -1,85 +0,0 @@ -// -// Homepage.swift -// captainsLog -// -// Created by Benjamin Welner on 10/18/19. -// Copyright © 2019 FIGBERT Industries. All rights reserved. -// - -import SwiftUI - -struct Homepage: View { - @State private var recording: Bool = false - @State private var timeElapsed: Double = 0.00 - @State private var timer:Timer? - @State private var msg: String = "" - @State private var date = Date() - - var body: some View { - NavigationView { - 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 - 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.date.stardate())" - } 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: "waveform", - withConfiguration: UIImage.SymbolConfiguration( - pointSize: CGFloat.init(50), - weight: .medium, - scale: .large - ) - )! - ) - .foregroundColor(Color.primary) - } - Spacer() - } - } - } -} - -struct Homepage_Previews: PreviewProvider { - static var previews: some View { - Homepage() - } -} diff --git a/Settings.swift b/Settings.swift @@ -58,10 +58,10 @@ struct Settings: View { } } } - .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 @@ -13,7 +13,6 @@ 3A35D6E623579F7C005B7610 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3A35D6E523579F7C005B7610 /* Assets.xcassets */; }; 3A35D6E923579F7C005B7610 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3A35D6E823579F7C005B7610 /* Preview Assets.xcassets */; }; 3A35D6EC23579F7C005B7610 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3A35D6EA23579F7C005B7610 /* LaunchScreen.storyboard */; }; - 3A76A1E6235AD06C00964901 /* Homepage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E5235AD06C00964901 /* Homepage.swift */; }; 3A76A1E8235AD08C00964901 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E7235AD08C00964901 /* Settings.swift */; }; 3A76A1EA235AE6D500964901 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A76A1E9235AE6D500964901 /* Extensions.swift */; }; /* End PBXBuildFile section */ @@ -27,7 +26,6 @@ 3A35D6E823579F7C005B7610 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 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>"; }; - 3A76A1E5235AD06C00964901 /* Homepage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Homepage.swift; sourceTree = SOURCE_ROOT; }; 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>"; }; /* End PBXFileReference section */ @@ -65,9 +63,8 @@ 3A35D6DF23579F7B005B7610 /* AppDelegate.swift */, 3A35D6E123579F7B005B7610 /* SceneDelegate.swift */, 3A35D6E323579F7B005B7610 /* ContentView.swift */, - 3A76A1E9235AE6D500964901 /* Extensions.swift */, - 3A76A1E5235AD06C00964901 /* Homepage.swift */, 3A76A1E7235AD08C00964901 /* Settings.swift */, + 3A76A1E9235AE6D500964901 /* Extensions.swift */, 3A35D6E523579F7C005B7610 /* Assets.xcassets */, 3A35D6EA23579F7C005B7610 /* LaunchScreen.storyboard */, 3A35D6ED23579F7C005B7610 /* Info.plist */, @@ -158,7 +155,6 @@ 3A35D6E023579F7B005B7610 /* AppDelegate.swift in Sources */, 3A35D6E223579F7B005B7610 /* SceneDelegate.swift in Sources */, 3A35D6E423579F7B005B7610 /* ContentView.swift in Sources */, - 3A76A1E6235AD06C00964901 /* Homepage.swift in Sources */, 3A76A1E8235AD08C00964901 /* Settings.swift in Sources */, 3A76A1EA235AE6D500964901 /* Extensions.swift in Sources */, ); diff --git a/captainsLog/ContentView.swift b/captainsLog/ContentView.swift @@ -9,14 +9,116 @@ import SwiftUI struct ContentView: View { - @State private var homePage = true + @State private var recording: Bool = false + @State private var timeElapsed: Double = 0.00 + @State private var timer:Timer? + @State private var msg: String = "" + @State private var date = Date() + var body: some View { - VStack { - if (homePage) { - Homepage() - } else { - Settings() + NavigationView { + 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 + 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.date.stardate())" + } 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)) + if (self.recording) { + Image( + uiImage: UIImage( + systemName: "waveform", + withConfiguration: UIImage.SymbolConfiguration( + pointSize: CGFloat.init(50), + weight: .medium, + scale: .large + ) + )! + ) + .foregroundColor(Color.primary) + } else { + Button(action: { + print("Test") + }) { + 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) + } + 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) + } + } + } + Spacer() } + //Does this look good? I don't know + .navigationBarTitle(Text("Home")) } } } diff --git a/captainsLog/Extensions.swift b/captainsLog/Extensions.swift @@ -7,6 +7,7 @@ // import Foundation +import SwiftUI extension Double { func withCommas() -> String {