mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2026-04-28 18:30:09 +00:00
✨ Fixing small issue, adding Settings, adding Acknowledgements, adding logout functionality
This commit is contained in:
@@ -19,8 +19,9 @@ struct FirstOpeningSettings: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("welcomeText".localized(tableName: "General", plural: false))
|
||||
|
||||
TextField("name".localized(tableName: "General", plural: false), text: self.$name)
|
||||
.overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputCourse ? Color.red : Color.secondary, lineWidth: 1))
|
||||
.overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputName ? Color.red : Color.secondary, lineWidth: 1))
|
||||
.foregroundColor(invalidInputName ? .red : .primary)
|
||||
.textContentType(.name)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
@@ -56,6 +57,7 @@ struct FirstOpeningSettings: View {
|
||||
.background(Color.blue)
|
||||
.cornerRadius(15)
|
||||
}
|
||||
//.disabled() //TODO: Check all inputs before enabling the button
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,45 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsMain: View {
|
||||
@EnvironmentObject var settings: LocalSettings
|
||||
@State private var showLogoutConfirmationAlert = false
|
||||
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
NavigationView {
|
||||
List {
|
||||
Section(header: Text("other".localized(tableName: "General", plural: false))) {
|
||||
NavigationLink(
|
||||
destination: SettingsAcknowledgements(),
|
||||
label: {
|
||||
Text("Acknowledgements")
|
||||
})
|
||||
Button(action: {
|
||||
self.showLogoutConfirmationAlert = true
|
||||
}, label: {
|
||||
Text("logoutClearData".localized(tableName: "General", plural: false))
|
||||
})
|
||||
}
|
||||
}
|
||||
.navigationTitle("settings".localized(tableName: "General", plural: false))
|
||||
.listStyle(GroupedListStyle())
|
||||
}
|
||||
.alert(isPresented: $showLogoutConfirmationAlert, content: {
|
||||
Alert(
|
||||
title: Text("logout".localized(tableName: "General", plural: false)),
|
||||
message: Text("confirmLogoutMessage".localized(tableName: "General", plural: false)),
|
||||
primaryButton: .cancel(),
|
||||
secondaryButton: .destructive(Text("Ok")){
|
||||
self.logoutAndClearData()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
extension SettingsMain {
|
||||
private func logoutAndClearData() {
|
||||
// TODO: Adjust before release!
|
||||
UtilityFunctions.deleteAllData()
|
||||
self.settings.isFirstOpening = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// SettingsAcknowledgements.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 28.12.20.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsAcknowledgements: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("Contributors")
|
||||
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
|
||||
Spacer()
|
||||
Text("David Huh")
|
||||
Text("Patrick Müller")
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SettingsAcknowledgements_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsAcknowledgements()
|
||||
.preferredColorScheme(.dark)
|
||||
.environmentObject(getFirstOpening())
|
||||
.environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
|
||||
}
|
||||
|
||||
static func getFirstOpening() -> LocalSettings {
|
||||
let settings = LocalSettings();
|
||||
settings.isFirstOpening = false;
|
||||
return settings
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user