Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyu-Xie committed Jun 14, 2024
1 parent 4be732e commit a0be71c
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 45 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions VolumeVibe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
FF856BE52BDA939B00A7BC33 /* Simulation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Simulation.swift; sourceTree = "<group>"; };
FF856BE72BDA93A500A7BC33 /* Privacy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Privacy.swift; sourceTree = "<group>"; };
FF856BE92BDA96B000A7BC33 /* About.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = About.swift; sourceTree = "<group>"; };
FFE19CF12C1C727E0034FDE4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
FFF5D2182C1C3E1B00DDCF45 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
FFF5D21B2C1C413500DDCF45 /* QuickVolumeValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickVolumeValue.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -114,6 +115,7 @@
FF80590E2BD62EAE009E601B /* VolumeVibe */ = {
isa = PBXGroup;
children = (
FFE19CF12C1C727E0034FDE4 /* Info.plist */,
FF80590F2BD62EAE009E601B /* VolumeVibeApp.swift */,
FF8059112BD62EAE009E601B /* ContentView.swift */,
FF58260D2BDA02D300DFD619 /* More.swift */,
Expand Down Expand Up @@ -481,6 +483,7 @@
DEVELOPMENT_TEAM = ZR59599HJV;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VolumeVibe/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = VolumeVibe;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down Expand Up @@ -516,6 +519,7 @@
DEVELOPMENT_TEAM = ZR59599HJV;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VolumeVibe/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = VolumeVibe;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?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">
<array/>
</plist>
Binary file not shown.
17 changes: 10 additions & 7 deletions VolumeVibe/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import Foundation
import SwiftUI

struct Home: View {

@StateObject private var viewModel = VolumeViewModel()
@State private var showAlert_1 = false

@AppStorage("quickVolumeValue") var quickVolumeValue : Double?

var body: some View {

VStack {
Image(systemName: "speaker.wave.2.circle").font(.system(size: 60)).foregroundStyle(.blue)
Spacer().frame(maxHeight: 20)
Expand All @@ -23,12 +26,12 @@ struct Home: View {
Text("Version \((Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String)!)").foregroundStyle(.secondary)
Text("iOS" + " " + UIDevice.current.systemVersion).foregroundStyle(.secondary)
Spacer().frame(maxHeight: 30)
Text("Press and Set Volume as 0.1.").foregroundStyle(.secondary)
Text("Press and Set Volume as \(formattedValue(value: quickVolumeValue ?? 0.1)).").foregroundStyle(.secondary)

Spacer().frame(maxHeight: 20)

Button(action: {
setSysVolum(0.001)
setSysVolum(Float(0.01*(quickVolumeValue ?? 0.1)))
}) {
if #available(iOS 16.0, *) {
Text("Set Volume")
Expand All @@ -54,11 +57,11 @@ struct Home: View {
showAlert_1 = true
}.alert(isPresented: $showAlert_1) {
Alert(
title: Text("Attention"),
message: Text("Due to Apple's API limitations, it is not possible to display precise volume numbers in this context."),
dismissButton: .default(Text("Got It"))
title: Text("Attention"),
message: Text("Due to Apple's API limitations, it is not possible to display precise volume numbers in this context."),
dismissButton: .default(Text("Got It"))
)
}
}

}).padding(0)

Expand Down
13 changes: 13 additions & 0 deletions VolumeVibe/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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>CFBundleGetInfoString</key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
24 changes: 23 additions & 1 deletion VolumeVibe/More.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@

import Foundation
import SwiftUI
import WebKit

struct WebView: UIViewRepresentable {
let url: URL

func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}

func updateUIView(_ uiView: WKWebView, context: Context) {
let request = URLRequest(url: url)
uiView.load(request)
}
}

struct More: View {

Expand Down Expand Up @@ -35,7 +49,10 @@ struct More: View {
NavigationLink(destination: Settings().navigationBarTitle("Settings", displayMode: .inline)) {
Label("Settings", systemImage: "gear")
}
NavigationLink(destination: Privacy().navigationBarTitle("Privacy Policy", displayMode: .inline)) {
NavigationLink(destination: appStoreRatingView().navigationBarTitle("Ratings", displayMode: .inline)) {
Label("Ratings", systemImage: "trophy")
}
NavigationLink(destination: About().navigationBarTitle("Privacy", displayMode: .inline)) {
Label("Privacy", systemImage: "hand.raised")
}
NavigationLink(destination: About().navigationBarTitle("About", displayMode: .inline)) {
Expand All @@ -45,4 +62,9 @@ struct More: View {

}
}

func appStoreRatingView() -> some View {
let appStoreURL = URL(string: "itms-apps://itunes.apple.com/app/id6499372355")!
return WebView(url: appStoreURL)
}
}
4 changes: 2 additions & 2 deletions VolumeVibe/More/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ struct Settings: View {
var body: some View {
List {
Section {
NavigationLink(destination: QuickVolumeValue().navigationBarTitle("About", displayMode: .inline)) {
Label("About", systemImage: "info.circle")
NavigationLink(destination: QuickVolumeValue().navigationBarTitle("Quick Volume Value", displayMode: .inline)) {
Label("Quick Volume Value", systemImage: "speaker.wave.2")
} }
}
}
Expand Down
62 changes: 27 additions & 35 deletions VolumeVibe/More/Settings/QuickVolumeValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,19 @@ import SwiftUI
struct QuickVolumeValue: View {

@State private var volumeInput: String = ""
@State private var showAlert_2: Bool = false
@State private var alert_title: String = ""
@State private var alert_content: String = ""

@AppStorage("quickVolumeValue") var quickVolumeValue : Double?

var body: some View {

let quickVolumeValueString = Binding<String>(
get: { String(format: "%.2f", quickVolumeValue ?? 0.1) },
set: { newValue in
if let value = Double(newValue) {
quickVolumeValue = value
}
}
)

VStack(spacing: 20) {
Image(systemName: "speaker.wave.2.circle")
.font(.system(size: 60))
.foregroundColor(.blue)

Text("VolumeVibe")
.font(.title3)
.bold()

Text("Acan Xie")
.foregroundColor(.secondary)
Text("Set the volume value that can be quickly adjusted on the homepage.").foregroundStyle(.secondary).multilineTextAlignment(.leading).font(.subheadline)

VStack(alignment: .leading, content: {
Text("On Apple devices, the volume value typically ranges from 0 to 1. However, in this app the range is 0.0 to 100.0, which is believed to be more intuitive.").foregroundStyle(.secondary).multilineTextAlignment(.leading)
Spacer().frame(maxHeight: 20)
Text("This range allows for precise control over the audio output level. It's important to note that values outside this range might not have any effect on the actual volume level.").foregroundStyle(.secondary).multilineTextAlignment(.leading)
Spacer().frame(maxHeight: 20)
Text("Additionally, some devices might have slightly different behavior or additional features related to volume control.")
.foregroundColor(.secondary).multilineTextAlignment(.leading)
})

TextField("Set Volume 0.0 - 100.0", text: quickVolumeValueString)
TextField("Set Volume 0.0 - 100.0", text: $volumeInput)
.padding(12)
.background(Color(UIColor.systemBackground))
.cornerRadius(10)
Expand All @@ -56,16 +33,25 @@ struct QuickVolumeValue: View {

Button(action: {
if let volume = Float(volumeInput.replacingOccurrences(of: ",", with: ".")) {
let sysVolume = volume * 0.01
setSysVolum(sysVolume)
if(volume >= 0.0 && volume <= 100.0) {
quickVolumeValue = Double(volume)
showAlert_2 = true
alert_title = "Success"
alert_content = "Volume Successfully Set to \(formattedValue(value: Double(volume)))"
}
else {
showAlert_2 = true
alert_title = "Failed"
alert_content = "Only Support Volume with Value 0.0 to 100.0"
}
}
else {
showAlert_2 = true
alert_title = "Failed"
alert_content = "Wrong Format"
}
}) {
Text("Set Volume")
.foregroundColor(.white)
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue)
.cornerRadius(10)
}

Spacer()
Expand All @@ -76,6 +62,12 @@ struct QuickVolumeValue: View {
.background(Color(UIColor.systemGray6).ignoresSafeArea())
.onTapGesture {
hideKeyboard()
}.alert(isPresented: $showAlert_2) {
Alert(
title: Text(alert_title),
message: Text(alert_content),
dismissButton: .default(Text("Got It"))
)
}
}

Expand Down

0 comments on commit a0be71c

Please sign in to comment.