diff --git a/.DS_Store b/.DS_Store index 82bed42..4eefd66 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/VolumeVibe.xcodeproj/project.pbxproj b/VolumeVibe.xcodeproj/project.pbxproj index 1f56a25..f249be7 100644 --- a/VolumeVibe.xcodeproj/project.pbxproj +++ b/VolumeVibe.xcodeproj/project.pbxproj @@ -62,6 +62,7 @@ FF856BE52BDA939B00A7BC33 /* Simulation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Simulation.swift; sourceTree = ""; }; FF856BE72BDA93A500A7BC33 /* Privacy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Privacy.swift; sourceTree = ""; }; FF856BE92BDA96B000A7BC33 /* About.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = About.swift; sourceTree = ""; }; + FFE19CF12C1C727E0034FDE4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; FFF5D2182C1C3E1B00DDCF45 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = ""; }; FFF5D21B2C1C413500DDCF45 /* QuickVolumeValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickVolumeValue.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -114,6 +115,7 @@ FF80590E2BD62EAE009E601B /* VolumeVibe */ = { isa = PBXGroup; children = ( + FFE19CF12C1C727E0034FDE4 /* Info.plist */, FF80590F2BD62EAE009E601B /* VolumeVibeApp.swift */, FF8059112BD62EAE009E601B /* ContentView.swift */, FF58260D2BDA02D300DFD619 /* More.swift */, @@ -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; @@ -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; diff --git a/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/IDEFindNavigatorScopes.plist b/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/IDEFindNavigatorScopes.plist new file mode 100644 index 0000000..5dd5da8 --- /dev/null +++ b/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/IDEFindNavigatorScopes.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/UserInterfaceState.xcuserstate b/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/UserInterfaceState.xcuserstate index 82c4b8f..3deb1b2 100644 Binary files a/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/UserInterfaceState.xcuserstate and b/VolumeVibe.xcodeproj/project.xcworkspace/xcuserdata/xiezeyu.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/VolumeVibe/Home.swift b/VolumeVibe/Home.swift index 802d7c2..58d90e6 100644 --- a/VolumeVibe/Home.swift +++ b/VolumeVibe/Home.swift @@ -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) @@ -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") @@ -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) diff --git a/VolumeVibe/Info.plist b/VolumeVibe/Info.plist new file mode 100644 index 0000000..ef571c6 --- /dev/null +++ b/VolumeVibe/Info.plist @@ -0,0 +1,13 @@ + + + + + CFBundleGetInfoString + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + + diff --git a/VolumeVibe/More.swift b/VolumeVibe/More.swift index 0d71a9b..6845814 100644 --- a/VolumeVibe/More.swift +++ b/VolumeVibe/More.swift @@ -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 { @@ -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)) { @@ -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) + } } diff --git a/VolumeVibe/More/Settings.swift b/VolumeVibe/More/Settings.swift index ba72e26..ce067ca 100644 --- a/VolumeVibe/More/Settings.swift +++ b/VolumeVibe/More/Settings.swift @@ -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") } } } } diff --git a/VolumeVibe/More/Settings/QuickVolumeValue.swift b/VolumeVibe/More/Settings/QuickVolumeValue.swift index c6f8b35..b3afa3e 100644 --- a/VolumeVibe/More/Settings/QuickVolumeValue.swift +++ b/VolumeVibe/More/Settings/QuickVolumeValue.swift @@ -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( - 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) @@ -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() @@ -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")) + ) } }