🚧 working on settings page

dev_views_Settings
Rémi REGNAULT 11 months ago
parent 6988a8f429
commit 17983a43d4

@ -31,6 +31,8 @@
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 */; };
EC05BFC42C04C3C4000F7B19 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */; };
EC05BFC82C04D832000F7B19 /* CustomSwitchButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */; };
EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */; };
EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4F82C0371660048CD0B /* MusicPlayer.swift */; };
EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FA2C038BD20048CD0B /* PlayersView.swift */; };
@ -101,6 +103,8 @@
649B59AD2BF64EAB002BAE38 /* AppImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppImages.swift; sourceTree = "<group>"; };
649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = "<group>"; };
649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = "<group>"; };
EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSwitchButton.swift; sourceTree = "<group>"; };
EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
EC62C4F82C0371660048CD0B /* MusicPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicPlayer.swift; sourceTree = "<group>"; };
EC62C4FA2C038BD20048CD0B /* PlayersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersView.swift; sourceTree = "<group>"; };
@ -248,6 +252,7 @@
children = (
649ABF5A2BF60D78002E8894 /* MainMenuView.swift */,
EC62C5082C0467240048CD0B /* SplashScreenView.swift */,
EC05BFC32C04C3C4000F7B19 /* SettingsView.swift */,
);
path = Menu;
sourceTree = "<group>";
@ -265,6 +270,7 @@
649ABF5E2BF60ED5002E8894 /* Components */ = {
isa = PBXGroup;
children = (
EC05BFC62C04D7C2000F7B19 /* Settings */,
643AB6912BFCEFB70018DA73 /* Game */,
645B4C1C2BFCC95000FD658A /* Player */,
649ABF5F2BF60F2D002E8894 /* MainMenuButton.swift */,
@ -314,6 +320,14 @@
path = TextStyles;
sourceTree = "<group>";
};
EC05BFC62C04D7C2000F7B19 /* Settings */ = {
isa = PBXGroup;
children = (
EC05BFC72C04D832000F7B19 /* CustomSwitchButton.swift */,
);
path = Settings;
sourceTree = "<group>";
};
EC62C5022C045BB90048CD0B /* SoundPlayerClass */ = {
isa = PBXGroup;
children = (
@ -477,11 +491,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EC05BFC42C04C3C4000F7B19 /* SettingsView.swift in Sources */,
643AB69B2BFCFB5C0018DA73 /* HistoricView.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 */,
645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */,
649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */,
649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */,

@ -0,0 +1,48 @@
//
// 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 imgNameIsOff: String
var imgIsOffWidth: CGFloat = 50
var imgIsOffHeight: CGFloat = 50
// Image when Off
var imgNameIsOn: String
var imgIsOnWidth: CGFloat = 50
var imgIsOnHeight: CGFloat = 50
var body: some View {
HStack {
Image(imgNameIsOff)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: imgIsOffWidth, height: imgIsOffHeight)
Toggle("isOn", isOn: $IsOn)
.labelsHidden()
Image(imgNameIsOn)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: imgIsOnWidth, height: imgIsOnHeight)
}
}
}
struct CustomSwitchButton_Previews: PreviewProvider {
static var previews: some View {
@State var isOn: Bool = false
CustomSwitchButton(IsOn: $isOn, imgNameIsOff: AppImages.TitleImage, imgNameIsOn: AppImages.TitleImage)
}
}

@ -36,6 +36,7 @@ struct MainMenuView: View {
MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound")
MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound")
MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound")
MainMenuButton(text: "Settings", destination: SettingsView(), sound: "TitleScreenButtonSound")
}
Image(AppImages.SemiLion)
.resizable()

@ -0,0 +1,71 @@
//
// 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 = false
var body: some View {
VStack {
TitlePageFrame(Text: "Settings")
VStack {
Divider()
HStack {
Text("Theme")
.font(.headline)
Spacer()
CustomSwitchButton(IsOn: $theme, imgNameIsOff: AppImages.TitleImage, imgNameIsOn: AppImages.TitleImage)
}
Divider()
HStack {
Text("Language")
.font(.headline)
Spacer()
Picker("Sort", selection: $choice) {
ForEach(["English", "Français", "Español"]) {
Text($0)
}
}
.pickerStyle(.menu)
}
Divider()
VStack(alignment: .leading) {
Toggle("Sound", isOn: $sound)
.toggleStyle(.switch)
.font(.headline)
}
Divider()
}
.padding(20)
Spacer()
}
}
}
#Preview {
SettingsView()
}
Loading…
Cancel
Save