From c0d9436c89cd7a5dc0d22c177cecb3d8cf135030 Mon Sep 17 00:00:00 2001
From: Oliver Wiese <oliver.wiese@fu-berlin.de>
Date: Thu, 19 Mar 2020 16:27:54 +0100
Subject: [PATCH] add Auth.View and fix cancelable error

---
 enzevalos_iphone.xcodeproj/project.pbxproj    |  4 ++
 enzevalos_iphone/AuthenticationScreen.swift   | 40 -------------------
 .../AuthenticationViewModel.swift             |  1 +
 3 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj
index f4911b90..df2f5df7 100644
--- a/enzevalos_iphone.xcodeproj/project.pbxproj
+++ b/enzevalos_iphone.xcodeproj/project.pbxproj
@@ -147,6 +147,7 @@
 		47EABF272423BFDD00774A93 /* AuthenticationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF262423BFDD00774A93 /* AuthenticationScreen.swift */; };
 		47EABF292423C1FB00774A93 /* KeyboardChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF282423C1FB00774A93 /* KeyboardChecker.swift */; };
 		47EABF2B2423C20C00774A93 /* LoadingBlocker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF2A2423C20C00774A93 /* LoadingBlocker.swift */; };
+		47EABF2D2423C65F00774A93 /* AuthenticationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF2C2423C65F00774A93 /* AuthenticationView.swift */; };
 		47F0376E22A7278A0005C9DE /* accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 47F0376D22A7278A0005C9DE /* accounts.json */; };
 		47F79240203492E3005E7DB6 /* KeyRecord+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F7923E203492E3005E7DB6 /* KeyRecord+CoreDataClass.swift */; };
 		47F79241203492E3005E7DB6 /* KeyRecord+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F7923F203492E3005E7DB6 /* KeyRecord+CoreDataProperties.swift */; };
@@ -545,6 +546,7 @@
 		47EABF262423BFDD00774A93 /* AuthenticationScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationScreen.swift; sourceTree = "<group>"; };
 		47EABF282423C1FB00774A93 /* KeyboardChecker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardChecker.swift; sourceTree = "<group>"; };
 		47EABF2A2423C20C00774A93 /* LoadingBlocker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingBlocker.swift; sourceTree = "<group>"; };
+		47EABF2C2423C65F00774A93 /* AuthenticationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationView.swift; sourceTree = "<group>"; };
 		47F0376D22A7278A0005C9DE /* accounts.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = accounts.json; sourceTree = "<group>"; };
 		47F7923E203492E3005E7DB6 /* KeyRecord+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KeyRecord+CoreDataClass.swift"; sourceTree = "<group>"; };
 		47F7923F203492E3005E7DB6 /* KeyRecord+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KeyRecord+CoreDataProperties.swift"; sourceTree = "<group>"; };
@@ -1153,6 +1155,7 @@
 				47EABF0C241A9CA800774A93 /* MailAccount.swift */,
 				47EABF06241A9C8700774A93 /* AuthenticationModel.swift */,
 				47EABF262423BFDD00774A93 /* AuthenticationScreen.swift */,
+				47EABF2C2423C65F00774A93 /* AuthenticationView.swift */,
 				47EABF2A2423C20C00774A93 /* LoadingBlocker.swift */,
 				47EABF07241A9C8700774A93 /* AuthenticationViewModel.swift */,
 			);
@@ -2107,6 +2110,7 @@
 				0E6551A72406A42300DE30FC /* SearchHelper.swift in Sources */,
 				472F398E1E251B8D009260FB /* MailAddress.swift in Sources */,
 				A198D2292056B384004CC838 /* SendViewDelegate.swift in Sources */,
+				47EABF2D2423C65F00774A93 /* AuthenticationView.swift in Sources */,
 				479011492289975D0057AB04 /* NoSecIconStyleKit.swift in Sources */,
 				F12060821DA552FC00F6EF37 /* MailHandlerDelegator.swift in Sources */,
 				474994022261E4E6000F8DA5 /* SimpleSendIcon.swift in Sources */,
diff --git a/enzevalos_iphone/AuthenticationScreen.swift b/enzevalos_iphone/AuthenticationScreen.swift
index b4945a7f..2a65105e 100644
--- a/enzevalos_iphone/AuthenticationScreen.swift
+++ b/enzevalos_iphone/AuthenticationScreen.swift
@@ -106,43 +106,3 @@ struct AuthenticationScreen: View {
         return (self.viewModel.errorMessage != nil) && (!self.viewModel.errorMessage!.isEmpty)
     }
 }
-
-struct ActivityIndicator: UIViewRepresentable {
-    
-    @Binding var isAnimating: Bool
-    let style: UIActivityIndicatorView.Style
-    
-    func makeUIView(context: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
-        return UIActivityIndicatorView(style: style)
-    }
-    
-    func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext<ActivityIndicator>) {
-        isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
-    }
-}
-
-struct LoadingView<Content>: View where Content: View {
-    
-    @Binding var isShowing: Bool
-    var content: () -> Content
-    
-    var body: some View {
-        ZStack(alignment: .center) {
-            
-            self.content()
-                .disabled(self.isShowing)
-                .blur(radius: self.isShowing ? 3 : 0)
-            
-            VStack {
-                Text("Loading...")
-                ActivityIndicator(isAnimating: .constant(true), style: .large)
-            }
-            .frame(width: UIScreen.main.bounds.size.width / 2,
-                   height: UIScreen.main.bounds.size.height / 5)
-                .background(Color.secondary.colorInvert())
-                .foregroundColor(Color.primary)
-                .cornerRadius(20)
-                .opacity(self.isShowing ? 1 : 0) 
-        }
-    }
-}
diff --git a/enzevalos_iphone/AuthenticationViewModel.swift b/enzevalos_iphone/AuthenticationViewModel.swift
index e6fc4ea8..fb17e551 100644
--- a/enzevalos_iphone/AuthenticationViewModel.swift
+++ b/enzevalos_iphone/AuthenticationViewModel.swift
@@ -7,6 +7,7 @@
 //
 
 import Foundation
+import Combine
 
 class AuthenticationViewModel : ObservableObject {
 
-- 
GitLab