parent
6988a8f429
commit
17983a43d4
@ -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)
|
||||||
|
}
|
||||||
|
}
|
@ -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…
Reference in new issue