diff --git a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj index 62777f8..0a2a314 100644 --- a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj +++ b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj @@ -31,6 +31,9 @@ 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59AD2BF64EAB002BAE38 /* AppImages.swift */; }; 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B12BF65392002BAE38 /* TextStyles.swift */; }; 649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */; }; + 64D992722C06281B002ACBC6 /* SystemIcons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64D992712C06281B002ACBC6 /* SystemIcons.swift */; }; + EC05BFC42C04C3C4000F7B19 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */; }; + EC05BFC82C04D832000F7B19 /* CustomSwitchButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */; }; EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4F82C0371660048CD0B /* MusicPlayer.swift */; }; EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FA2C038BD20048CD0B /* PlayersView.swift */; }; EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */; }; @@ -40,7 +43,6 @@ EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5082C0467240048CD0B /* SplashScreenView.swift */; }; EC62C50D2C046D9E0048CD0B /* SplashScreenSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */; }; EC62C50F2C05D06A0048CD0B /* AddPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */; }; - EC62C5152C061C350048CD0B /* shrek.png in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5142C061C350048CD0B /* shrek.png */; }; EC62C5172C0620C00048CD0B /* rap.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5162C0620C00048CD0B /* rap.mp3 */; }; /* End PBXBuildFile section */ @@ -103,6 +105,9 @@ 649B59AD2BF64EAB002BAE38 /* AppImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppImages.swift; sourceTree = ""; }; 649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = ""; }; 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = ""; }; + 64D992712C06281B002ACBC6 /* SystemIcons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemIcons.swift; sourceTree = ""; }; + EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; + EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSwitchButton.swift; sourceTree = ""; }; EC62C4F82C0371660048CD0B /* MusicPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicPlayer.swift; sourceTree = ""; }; EC62C4FA2C038BD20048CD0B /* PlayersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersView.swift; sourceTree = ""; }; EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRow.swift; sourceTree = ""; }; @@ -112,7 +117,6 @@ EC62C5082C0467240048CD0B /* SplashScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenView.swift; sourceTree = ""; }; EC62C50C2C046D9E0048CD0B /* SplashScreenSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = SplashScreenSound.mp3; sourceTree = ""; }; EC62C50E2C05D06A0048CD0B /* AddPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPlayerView.swift; sourceTree = ""; }; - EC62C5142C061C350048CD0B /* shrek.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shrek.png; sourceTree = ""; }; EC62C5162C0620C00048CD0B /* rap.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = rap.mp3; sourceTree = ""; }; /* End PBXFileReference section */ @@ -252,6 +256,7 @@ children = ( 649ABF5A2BF60D78002E8894 /* MainMenuView.swift */, EC62C5082C0467240048CD0B /* SplashScreenView.swift */, + EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */, ); path = Menu; sourceTree = ""; @@ -269,6 +274,7 @@ 649ABF5E2BF60ED5002E8894 /* Components */ = { isa = PBXGroup; children = ( + EC05BFC62C04D7C2000F7B19 /* Settings */, 643AB6912BFCEFB70018DA73 /* Game */, 645B4C1C2BFCC95000FD658A /* Player */, 649ABF5F2BF60F2D002E8894 /* MainMenuButton.swift */, @@ -292,9 +298,9 @@ 649B59AA2BF64DF1002BAE38 /* Images */ = { isa = PBXGroup; children = ( - EC62C5142C061C350048CD0B /* shrek.png */, 649B59AB2BF64E12002BAE38 /* Images.xcassets */, 649B59AD2BF64EAB002BAE38 /* AppImages.swift */, + 64D992712C06281B002ACBC6 /* SystemIcons.swift */, ); path = Images; sourceTree = ""; @@ -319,6 +325,14 @@ path = TextStyles; sourceTree = ""; }; + EC05BFC62C04D7C2000F7B19 /* Settings */ = { + isa = PBXGroup; + children = ( + EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */, + ); + path = Settings; + sourceTree = ""; + }; EC62C5022C045BB90048CD0B /* SoundPlayerClass */ = { isa = PBXGroup; children = ( @@ -452,7 +466,6 @@ buildActionMask = 2147483647; files = ( 649B59A72BF64BA9002BAE38 /* Colors.xcassets in Resources */, - EC62C5152C061C350048CD0B /* shrek.png in Resources */, 6493C1C02C046BF900B5121D /* samurai.ttf in Resources */, EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */, EC62C5172C0620C00048CD0B /* rap.mp3 in Resources */, @@ -485,12 +498,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + EC05BFC42C04C3C4000F7B19 /* SettingsView.swift in Sources */, 643AB69B2BFCFB5C0018DA73 /* HistoricView.swift in Sources */, EC62C50F2C05D06A0048CD0B /* AddPlayerView.swift in Sources */, 6458345E2BF5F92300E18321 /* ContentView.swift in Sources */, 649B59A92BF64C6A002BAE38 /* Colors.swift in Sources */, 649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */, EC62C5012C045B590048CD0B /* SoundPlayer.swift in Sources */, + EC05BFC82C04D832000F7B19 /* CustomSwitchButton.swift in Sources */, + 64D992722C06281B002ACBC6 /* SystemIcons.swift in Sources */, 645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */, 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */, 649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */, diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/SystemIcons.swift b/DouShouQi_App/DouShouQi_App/Assets/Images/SystemIcons.swift new file mode 100644 index 0000000..c948321 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/SystemIcons.swift @@ -0,0 +1,15 @@ +// +// SystemIcons.swift +// DouShouQi_App +// +// Created by Rémi REGNAULT on 28/05/2024. +// + +import Foundation + +public struct SystemIcons { + static let DarkTheme = "moon" + static let LightTheme = "sun.max" + static let SoundOn = "speaker.2" + static let SoundOff = "speaker.slash" +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/shrek.png b/DouShouQi_App/DouShouQi_App/Assets/Images/shrek.png deleted file mode 100644 index 9479186..0000000 Binary files a/DouShouQi_App/DouShouQi_App/Assets/Images/shrek.png and /dev/null differ diff --git a/DouShouQi_App/DouShouQi_App/Components/Settings/CustomSwitchButton.swift b/DouShouQi_App/DouShouQi_App/Components/Settings/CustomSwitchButton.swift new file mode 100644 index 0000000..560ffd9 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Components/Settings/CustomSwitchButton.swift @@ -0,0 +1,56 @@ +// +// CustomSwitchButton.swift +// DouShouQi_App +// +// Created by etudiant on 27/05/2024. +// + +import SwiftUI + +struct CustomSwitchButton: View { + + // Boolean + @Binding var IsOn: Bool + + // Image when Off + var imgSystemNameIsOff: String + var imgIsOffWidth: CGFloat = 25 + var imgIsOffHeight: CGFloat = 25 + + // Image when Off + var imgSystemNameIsOn: String + var imgIsOnWidth: CGFloat = 25 + var imgIsOnHeight: CGFloat = 25 + + var body: some View { + HStack { + VStack { + if (!IsOn) { + Image(systemName: imgSystemNameIsOff) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: imgIsOffWidth, height: imgIsOffHeight) + } + }.frame(width: imgIsOffWidth, height: imgIsOffHeight) + + Toggle("isOn", isOn: $IsOn) + .labelsHidden() + + VStack { + if (IsOn) { + Image(systemName: imgSystemNameIsOn) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: imgIsOnWidth, height: imgIsOnHeight) + } + }.frame(width: imgIsOffWidth, height: imgIsOffHeight) + } + } +} + +//struct CustomSwitchButton_Previews: PreviewProvider { +// static var previews: some View { +// @State var isOn: Bool = false +// CustomSwitchButton(IsOn: $isOn, imgNameIsOff: AppImages.TitleImage, imgNameIsOn: AppImages.TitleImage) +// } +//} diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift index d0e7004..e23095d 100644 --- a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift +++ b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift @@ -40,6 +40,7 @@ struct MainMenuView: View { MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) + MainMenuButton(text: "Settings", destination: SettingsView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) } if let currentImage = currentImage { Image(currentImage) diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/SettingsView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/SettingsView.swift new file mode 100644 index 0000000..dcdb387 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Views/Menu/SettingsView.swift @@ -0,0 +1,76 @@ +// +// SettingsView.swift +// DouShouQi_App +// +// Created by etudiant on 27/05/2024. +// + +import SwiftUI + +extension String : Identifiable { + public var id: Self { return self } +} + +struct SettingsView: View { + + @State private var theme = false + @State private var choice = "English" + @State private var sound = true + + var body: some View { + VStack { + TitlePageFrame(Text: "Settings") + + VStack { + Divider() + + HStack { + Text("Theme") + .font(.headline) + + Spacer() + + CustomSwitchButton(IsOn: $theme, imgSystemNameIsOff: SystemIcons.LightTheme, imgSystemNameIsOn: SystemIcons.DarkTheme) + } + + Divider() + + HStack { + Text("Language") + .font(.headline) + + Spacer() + + Picker("Sort", selection: $choice) { + ForEach(["English", "Français", "Español"]) { + Text($0) + } + } + .pickerStyle(.menu) + } + + Divider() + + HStack { + Text("Theme") + .font(.headline) + + Spacer() + + CustomSwitchButton(IsOn: $sound, imgSystemNameIsOff: SystemIcons.SoundOff, imgSystemNameIsOn: SystemIcons.SoundOn) + } + + Divider() + } + .padding(20) + + Spacer() + } + } +} + +struct SettingsView_Previews: PreviewProvider { + static var previews: some View { + SettingsView() + } +}