From 2797bde11e43b3e7a40ae55da28457e056ab8175 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Thu, 8 Sep 2022 12:21:26 +0200
Subject: [PATCH] Extract ContactAuthStatusView

---
 .../SharedUI/ContactAuthStatusView.swift      | 94 +++++++++++++++++++
 .../Sources/ContactFeature/ContactView.swift  | 82 +---------------
 2 files changed, 95 insertions(+), 81 deletions(-)
 create mode 100644 Examples/xx-messenger/Sources/AppCore/SharedUI/ContactAuthStatusView.swift

diff --git a/Examples/xx-messenger/Sources/AppCore/SharedUI/ContactAuthStatusView.swift b/Examples/xx-messenger/Sources/AppCore/SharedUI/ContactAuthStatusView.swift
new file mode 100644
index 00000000..355749c2
--- /dev/null
+++ b/Examples/xx-messenger/Sources/AppCore/SharedUI/ContactAuthStatusView.swift
@@ -0,0 +1,94 @@
+import SwiftUI
+import XXModels
+
+public struct ContactAuthStatusView: View {
+  public init(_ authStatus: Contact.AuthStatus) {
+    self.authStatus = authStatus
+  }
+
+  public var authStatus: Contact.AuthStatus
+
+  public var body: some View {
+    switch authStatus {
+    case .stranger:
+      HStack {
+        Text("Stranger")
+        Spacer()
+        Image(systemName: "person.fill.questionmark")
+      }
+
+    case .requesting:
+      HStack {
+        Text("Sending auth request")
+        Spacer()
+        ProgressView()
+      }
+
+    case .requested:
+      HStack {
+        Text("Request sent")
+        Spacer()
+        Image(systemName: "paperplane")
+      }
+
+    case .requestFailed:
+      HStack {
+        Text("Sending request failed")
+        Spacer()
+        Image(systemName: "xmark.diamond.fill")
+          .foregroundColor(.red)
+      }
+
+    case .verificationInProgress:
+      HStack {
+        Text("Verification is progress")
+        Spacer()
+        ProgressView()
+      }
+
+    case .verified:
+      HStack {
+        Text("Verified")
+        Spacer()
+        Image(systemName: "person.fill.checkmark")
+      }
+
+    case .verificationFailed:
+      HStack {
+        Text("Verification failed")
+        Spacer()
+        Image(systemName: "xmark.diamond.fill")
+          .foregroundColor(.red)
+      }
+
+    case .confirming:
+      HStack {
+        Text("Confirming auth request")
+        Spacer()
+        ProgressView()
+      }
+
+    case .confirmationFailed:
+      HStack {
+        Text("Confirmation failed")
+        Spacer()
+        Image(systemName: "xmark.diamond.fill")
+          .foregroundColor(.red)
+      }
+
+    case .friend:
+      HStack {
+        Text("Friend")
+        Spacer()
+        Image(systemName: "person.fill.checkmark")
+      }
+
+    case .hidden:
+      HStack {
+        Text("Hidden")
+        Spacer()
+        Image(systemName: "eye.slash")
+      }
+    }
+  }
+}
diff --git a/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift b/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift
index 48743b07..252a1fd1 100644
--- a/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift
+++ b/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift
@@ -100,87 +100,7 @@ public struct ContactView: View {
           }
 
           Section {
-            switch dbContact.authStatus {
-            case .stranger:
-              HStack {
-                Text("Stranger")
-                Spacer()
-                Image(systemName: "person.fill.questionmark")
-              }
-
-            case .requesting:
-              HStack {
-                Text("Sending auth request")
-                Spacer()
-                ProgressView()
-              }
-
-            case .requested:
-              HStack {
-                Text("Request sent")
-                Spacer()
-                Image(systemName: "paperplane")
-              }
-
-            case .requestFailed:
-              HStack {
-                Text("Sending request failed")
-                Spacer()
-                Image(systemName: "xmark.diamond.fill")
-                  .foregroundColor(.red)
-              }
-
-            case .verificationInProgress:
-              HStack {
-                Text("Verification is progress")
-                Spacer()
-                ProgressView()
-              }
-
-            case .verified:
-              HStack {
-                Text("Verified")
-                Spacer()
-                Image(systemName: "person.fill.checkmark")
-              }
-
-            case .verificationFailed:
-              HStack {
-                Text("Verification failed")
-                Spacer()
-                Image(systemName: "xmark.diamond.fill")
-                  .foregroundColor(.red)
-              }
-
-            case .confirming:
-              HStack {
-                Text("Confirming auth request")
-                Spacer()
-                ProgressView()
-              }
-
-            case .confirmationFailed:
-              HStack {
-                Text("Confirmation failed")
-                Spacer()
-                Image(systemName: "xmark.diamond.fill")
-                  .foregroundColor(.red)
-              }
-
-            case .friend:
-              HStack {
-                Text("Friend")
-                Spacer()
-                Image(systemName: "person.fill.checkmark")
-              }
-
-            case .hidden:
-              HStack {
-                Text("Hidden")
-                Spacer()
-                Image(systemName: "eye.slash")
-              }
-            }
+            ContactAuthStatusView(dbContact.authStatus)
             Button {
               viewStore.send(.sendRequestTapped)
             } label: {
-- 
GitLab