Skip to content
Snippets Groups Projects
Commit a2d70799 authored by cpilaszewicz's avatar cpilaszewicz
Browse files

Add description of the MVVM elements ot the corresponding classes. Also some doc for methods

parent 1e02b5b2
No related branches found
No related tags found
4 merge requests!58Onboarding screens swift ui merge dev,!55WIP: Resolve "UI for gamifcation & stats",!47Provisional fix for OpenSSL 1.1+, needs testing,!39Resolve "Restructure Authentication"
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
import Foundation import Foundation
import Combine import Combine
/**
Model of the Authentication according to MVVP pattern. Performs all the necessary server calls according to the data provided by the ViewModel
*/
class AuthenticationModel: NSObject { class AuthenticationModel: NSObject {
enum AuthenticationResult {case Success, Timeout, Error(value: MailServerConnectionError)} enum AuthenticationResult {case Success, Timeout, Error(value: MailServerConnectionError)}
...@@ -29,6 +32,12 @@ class AuthenticationModel: NSObject { ...@@ -29,6 +32,12 @@ class AuthenticationModel: NSObject {
/** /**
Start asynchronous tasks for checking IMAP and SMTP configuration with a *timeoutDelay* after which the tasks are not getting consumed anymore. Start asynchronous tasks for checking IMAP and SMTP configuration with a *timeoutDelay* after which the tasks are not getting consumed anymore.
- Parameters:
- mailAccount: data class that holds the properties used for establishing the connection
- extendedValidation: indicates whether the imap/smtp configuration got specified by the user or should use default values
- Returns: a Future that produces an AuthenticationResult once the server calls are done
*/ */
func checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never> { func checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never> {
self.extendedValidation = extendedValidation self.extendedValidation = extendedValidation
...@@ -152,9 +161,11 @@ class AuthenticationModel: NSObject { ...@@ -152,9 +161,11 @@ class AuthenticationModel: NSObject {
smtpConfigurationSuccessful = false smtpConfigurationSuccessful = false
} }
dispatchGroup.leave() dispatchGroup.leave()
return
} }
/**
A listner class that notifies the AuthenticationCallback's about the result once the server call is done
*/
class Listener: MailSessionListener { class Listener: MailSessionListener {
let callback: AuthenticationCallback let callback: AuthenticationCallback
let mailAccount: MailAccount let mailAccount: MailAccount
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
import SwiftUI import SwiftUI
/**
View of the Authentication according to MVVP pattern. Observes the AuthenticationViewModel and adjusts the displayed data accordingly
*/
struct AuthenticationScreen: View { struct AuthenticationScreen: View {
@State private var login: String = "" @State private var login: String = ""
@State private var password: String = "" @State private var password: String = ""
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
import Foundation import Foundation
import Combine import Combine
/**
ViewModel of the Authentication according to MVVP pattern. Uses AuthenticationModel to get the result of the authentication.
*/
class AuthenticationViewModel : ObservableObject { class AuthenticationViewModel : ObservableObject {
@Published var errorMessage: String? @Published var errorMessage: String?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment