commit
002b3ec04a
@ -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"
|
||||||
|
}
|
Before Width: | Height: | Size: 326 KiB |
@ -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)
|
||||||
|
// }
|
||||||
|
//}
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue