-
Notifications
You must be signed in to change notification settings - Fork 0
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
Lee Jun Kit
committed
Jun 3, 2021
1 parent
b315146
commit 066142d
Showing
10 changed files
with
174 additions
and
58 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
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,16 @@ | ||
// | ||
// WebAPIDeviceObject.swift | ||
// Spottie | ||
// | ||
// Created by Lee Jun Kit on 3/6/21. | ||
// | ||
|
||
import Foundation | ||
|
||
struct WebAPIDeviceObject: Codable { | ||
var id: String | ||
var isActive: Bool | ||
var name: String | ||
var type: String | ||
var volumePercent: Float | ||
} |
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
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
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,51 @@ | ||
// | ||
// VolumeSlider.swift | ||
// Spottie | ||
// | ||
// Created by Lee Jun Kit on 3/6/21. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct VolumeSlider: View { | ||
var volumePercent: Float | ||
var onVolumeChanged: (Float) -> Void | ||
|
||
var imageName: String { | ||
get { | ||
if (volumePercent > 0.8) { | ||
return "speaker.wave.3.fill" | ||
} else if (volumePercent > 0.5) { | ||
return "speaker.wave.2.fill" | ||
} else if (volumePercent > 0.3) { | ||
return "speaker.wave.1.fill" | ||
} else { | ||
return "speaker.fill" | ||
} | ||
} | ||
} | ||
|
||
var body: some View { | ||
Slider(value: Binding(get: { | ||
self.volumePercent | ||
}, set: { newVolumePercent in | ||
self.onVolumeChanged(newVolumePercent) | ||
}), in: 0...1) { | ||
VStack(alignment: .trailing) { | ||
Image(systemName: imageName) | ||
.foregroundColor(.secondary) | ||
} | ||
.frame(width: 26, height: 26) | ||
} | ||
} | ||
} | ||
|
||
struct VolumeSlider_Previews: PreviewProvider { | ||
static func onVolumeChanged(volumePercent: Float) { | ||
print("new volume: \(volumePercent)") | ||
} | ||
|
||
static var previews: some View { | ||
VolumeSlider(volumePercent: Float(0.5), onVolumeChanged: onVolumeChanged) | ||
} | ||
} |