Commit
This commit is contained in:
68
Schedule ICTIS/Settings/SelectingGroupView.swift
Normal file
68
Schedule ICTIS/Settings/SelectingGroupView.swift
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// SelectedGroupView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 30.01.2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SelectingGroupView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@FocusState private var isFocused: Bool
|
||||
@State private var text: String = ""
|
||||
@Binding var group: String
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
HStack (spacing: 0) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
TextField("Поиск группы", text: $text)
|
||||
.disableAutocorrection(true)
|
||||
.focused($isFocused)
|
||||
.onSubmit {
|
||||
self.isFocused = false
|
||||
if (!text.isEmpty) {
|
||||
UserDefaults.standard.set(text, forKey: "group")
|
||||
group = text
|
||||
}
|
||||
self.text = ""
|
||||
dismiss()
|
||||
}
|
||||
.submitLabel(.done)
|
||||
if isFocused {
|
||||
Button {
|
||||
self.text = ""
|
||||
self.isFocused = false
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.padding(.trailing, 20)
|
||||
.offset(x: 10)
|
||||
.foregroundColor(.gray)
|
||||
.background(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 15)
|
||||
.fill(.white)
|
||||
)
|
||||
.padding(.horizontal, 10)
|
||||
Spacer()
|
||||
}
|
||||
.background(Color("background"))
|
||||
.onTapGesture {
|
||||
self.isFocused = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SelectingGroupView(group: .constant("КТбо2-6"))
|
||||
}
|
64
Schedule ICTIS/Settings/SelectingVPKView.swift
Normal file
64
Schedule ICTIS/Settings/SelectingVPKView.swift
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// SelectedVPKView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 30.01.2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SelectingVPKView: View {
|
||||
@FocusState private var isFocused: Bool
|
||||
@State private var text: String = ""
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
HStack (spacing: 0) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
TextField("Поиск ВПК", text: $text)
|
||||
.disableAutocorrection(true)
|
||||
.focused($isFocused)
|
||||
.onSubmit {
|
||||
self.isFocused = false
|
||||
if (!text.isEmpty) {
|
||||
UserDefaults.standard.set(text, forKey: "group")
|
||||
}
|
||||
self.text = ""
|
||||
}
|
||||
.submitLabel(.done)
|
||||
if isFocused {
|
||||
Button {
|
||||
self.text = ""
|
||||
self.isFocused = false
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.padding(.trailing, 20)
|
||||
.offset(x: 10)
|
||||
.foregroundColor(.gray)
|
||||
.background(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 15)
|
||||
.fill(.white)
|
||||
)
|
||||
.padding(.horizontal, 10)
|
||||
Spacer()
|
||||
}
|
||||
.background(Color("background"))
|
||||
.onTapGesture {
|
||||
self.isFocused = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SelectingVPKView()
|
||||
}
|
55
Schedule ICTIS/Settings/SettingsView.swift
Normal file
55
Schedule ICTIS/Settings/SettingsView.swift
Normal file
@ -0,0 +1,55 @@
|
||||
//
|
||||
// SettingsView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 30.01.2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsView: View {
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
@State private var selectedTheme = "Светлая"
|
||||
@State private var selectedLanguage = "Русский"
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
List {
|
||||
Section("Общие") {
|
||||
Picker("Тема", selection: $selectedTheme, content: {
|
||||
ForEach(MockData.themes, id: \.self) {
|
||||
Text($0)
|
||||
}
|
||||
})
|
||||
Picker("Язык", selection: $selectedLanguage, content: {
|
||||
ForEach(MockData.languages, id: \.self) {
|
||||
Text($0)
|
||||
}
|
||||
})
|
||||
}
|
||||
Section("Расписание") {
|
||||
NavigationLink(destination: SelectingGroupView(group: $vm.group)) {
|
||||
LabeledContent {
|
||||
Text(vm.group)
|
||||
} label: {
|
||||
Text("Избранное расписание")
|
||||
}
|
||||
}
|
||||
NavigationLink(destination: SelectingVPKView()) {
|
||||
LabeledContent {
|
||||
} label: {
|
||||
Text("ВПК")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Настройки")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
@Previewable @StateObject var vm = ScheduleViewModel()
|
||||
SettingsView(vm: vm)
|
||||
}
|
Reference in New Issue
Block a user