-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
925 additions
and
869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// AppDelegate.swift | ||
// SwiftUI Example | ||
// | ||
// Created by Engin BULANIK on 26.08.2020. | ||
// Copyright © 2020 William Entriken. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
|
||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
// Override point for customization after application launch. | ||
return true | ||
} | ||
|
||
// MARK: UISceneSession Lifecycle | ||
|
||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
// Called when a new scene session is being created. | ||
// Use this method to select a configuration to create the new scene with. | ||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
} | ||
|
||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { | ||
// Called when the user discards a scene session. | ||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | ||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return. | ||
} | ||
|
||
|
||
} | ||
|
98 changes: 98 additions & 0 deletions
98
SwiftUI Example/Sources/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
20 changes: 7 additions & 13 deletions
20
iOS Example/Sources/LaunchScreen.storyboard → ...ources/Base.lproj/LaunchScreen.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// | ||
// ContentView.swift | ||
// FDSoundActivatedRecorder-SwiftUI | ||
// | ||
// Created by Engin BULANIK on 25.08.2020. | ||
// Copyright © 2020 William Entriken. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
@EnvironmentObject var viewModel: FDSoundActivatedRecorderViewModel | ||
|
||
var body: some View { | ||
|
||
VStack(spacing: 10){ | ||
Text("Recording times out after 10 seconds") | ||
Button(action: self.viewModel.pressedStartListening) { | ||
Text("startListening") | ||
.frame(width: viewModel.menuWidth) | ||
.padding() | ||
.background(Color.yellow) | ||
.foregroundColor(Color.white) | ||
.cornerRadius(20) | ||
} | ||
|
||
Button(action: self.viewModel.pressedStartRecording) { | ||
Text("startRecording") | ||
.frame(width: viewModel.menuWidth) | ||
.padding() | ||
.background(Color.red) | ||
.foregroundColor(Color.white) | ||
.cornerRadius(20) | ||
} | ||
|
||
Button(action: self.viewModel.pressedStopAndSaveRecording) { | ||
Text("stopAndSaveRecording") | ||
.frame(width: viewModel.menuWidth) | ||
.padding() | ||
.background(Color.blue) | ||
.foregroundColor(Color.white) | ||
.cornerRadius(20) | ||
} | ||
|
||
Button(action: self.viewModel.pressedAbort) { | ||
Text("abort") | ||
.frame(width: viewModel.menuWidth) | ||
.padding() | ||
.background(Color.black) | ||
.foregroundColor(Color.white) | ||
.cornerRadius(20) | ||
} | ||
|
||
// Mic level | ||
Text("Microphone level") | ||
Rectangle() | ||
.fill(Color.gray) | ||
.frame(width: self.viewModel.menuWidth, height: 10) | ||
.overlay(Rectangle() | ||
.fill(Color.red) | ||
.frame(width: self.viewModel.progressBarLevel * self.viewModel.menuWidth, height: 10)) | ||
.frame(height: 20) | ||
|
||
Text(viewModel.microphoneLevel) | ||
|
||
Button(action: { | ||
// What to perform | ||
self.viewModel.pressedPlay() | ||
}) { | ||
// How the button looks like | ||
Text("play") | ||
.frame(width: viewModel.menuWidth) | ||
.padding() | ||
.background(Color.green) | ||
.foregroundColor(Color.white) | ||
.cornerRadius(20) | ||
}.disabled(self.viewModel.savedURL == nil) | ||
|
||
// Graph Animation | ||
GeometryReader { geometry in | ||
HStack(spacing: 0) { | ||
Spacer() | ||
ForEach(self.viewModel.sampleSquares, id: \.id) { sample in | ||
VStack { | ||
Spacer() | ||
Rectangle() | ||
.fill(sample.color) | ||
.frame(width: self.viewModel.graphSampleSize, height: self.viewModel.graphSampleSize) | ||
Spacer() | ||
.frame(height: sample.value * geometry.size.height) | ||
}.overlay( | ||
VStack { | ||
Spacer() | ||
Rectangle() | ||
.fill(sample.thresholdColor) | ||
.frame(width: self.viewModel.graphSampleSize, height: self.viewModel.graphSampleSize) | ||
Spacer() | ||
.frame(height: sample.thresholdValue * geometry.size.height) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} |
Oops, something went wrong.