From af1c8e7cd233ab0546ff6f91036a455e4efaf974 Mon Sep 17 00:00:00 2001
From: Bruno Muniz Azevedo Filho <bruno@elixxir.io>
Date: Thu, 15 Dec 2022 15:20:53 -0300
Subject: [PATCH] Fix create group subdrawer

---
 .../Resources/en.lproj/Localizable.strings    |  4 ++
 Sources/AppResources/Strings.swift            |  4 ++
 .../CreateGroupController.swift               | 47 ++++++++++++++++++-
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/Sources/AppResources/Resources/en.lproj/Localizable.strings b/Sources/AppResources/Resources/en.lproj/Localizable.strings
index e7a3f383..dfbda6df 100644
--- a/Sources/AppResources/Resources/en.lproj/Localizable.strings
+++ b/Sources/AppResources/Resources/en.lproj/Localizable.strings
@@ -994,6 +994,10 @@
 = "Create Group";
 "createGroup.drawer.subtitle"
 = "You are about to create a group message with other %@ users. The information below will be visible to all members of the group.";
+"createGroup.drawer.otherSubtitle"
+= "A group request will be sent to every user who can choose to join or not. Group chat requests are secured and sent via the xx network cMix protocol. However, due to the inherent batching associated with communicating with many people and current implementation details, it should not be considered as private as a standard, peer-to-peer chat.";
+"createGroup.drawer.gotit"
+= "Got it";
 "createGroup.drawer.input"
 = "Group Name";
 "createGroup.drawer.otherInput"
diff --git a/Sources/AppResources/Strings.swift b/Sources/AppResources/Strings.swift
index c04bc997..32f63865 100644
--- a/Sources/AppResources/Strings.swift
+++ b/Sources/AppResources/Strings.swift
@@ -613,6 +613,8 @@ public enum Localized {
       public static let action = Localized.tr("Localizable", "createGroup.drawer.action")
       /// Cancel
       public static let cancel = Localized.tr("Localizable", "createGroup.drawer.cancel")
+      /// Got it
+      public static let gotit = Localized.tr("Localizable", "createGroup.drawer.gotit")
       /// Group Name
       public static let input = Localized.tr("Localizable", "createGroup.drawer.input")
       /// Needs to be 20 chars max or 256 bytes
@@ -623,6 +625,8 @@ public enum Localized {
       public static let otherInput = Localized.tr("Localizable", "createGroup.drawer.otherInput")
       /// Say hi to your friends!
       public static let otherPlaceholder = Localized.tr("Localizable", "createGroup.drawer.otherPlaceholder")
+      /// A group request will be sent to every user who can choose to join or not. Group chat requests are secured and sent via the xx network cMix protocol. However, due to the inherent batching associated with communicating with many people and current implementation details, it should not be considered as private as a standard, peer-to-peer chat.
+      public static let otherSubtitle = Localized.tr("Localizable", "createGroup.drawer.otherSubtitle")
       /// Secret Family
       public static let placeholder = Localized.tr("Localizable", "createGroup.drawer.placeholder")
       /// You are about to create a group message with other %@ users. The information below will be visible to all members of the group.
diff --git a/Sources/CreateGroupFeature/CreateGroupController.swift b/Sources/CreateGroupFeature/CreateGroupController.swift
index ad730336..d7f68171 100644
--- a/Sources/CreateGroupFeature/CreateGroupController.swift
+++ b/Sources/CreateGroupFeature/CreateGroupController.swift
@@ -1,13 +1,21 @@
 import UIKit
+import Shared
 import Combine
 import XXModels
+import Dependencies
+import AppResources
+import AppNavigation
+import DrawerFeature
 
 public final class CreateGroupController: UIViewController {
+  @Dependency(\.navigator) var navigator
+
   private lazy var screenView = CreateGroupView()
 
   private let groupMembers: [Contact]
   private let viewModel = CreateGroupViewModel()
   private var cancellables = Set<AnyCancellable>()
+  private var drawerCancellables = Set<AnyCancellable>()
 
   public init(_ groupMembers: [Contact]) {
     self.groupMembers = groupMembers
@@ -22,7 +30,44 @@ public final class CreateGroupController: UIViewController {
 
   public override func viewDidLoad() {
     super.viewDidLoad()
-    screenView.set(count: groupMembers.count, didTap: {})
+    screenView.set(count: groupMembers.count, didTap: { [weak self] in
+      guard let self else { return }
+
+      let actionButton = CapsuleButton()
+      actionButton.setStyle(.seeThrough)
+      actionButton.setTitle(Localized.CreateGroup.Drawer.gotit, for: .normal)
+
+      actionButton
+        .publisher(for: .touchUpInside)
+        .receive(on: DispatchQueue.main)
+        .sink { [unowned self] in
+          self.navigator.perform(DismissModal(from: self)) { [weak self] in
+            guard let self else { return }
+            self.drawerCancellables.removeAll()
+          }
+        }.store(in: &self.drawerCancellables)
+
+      self.navigator.perform(PresentDrawer(items: [
+        DrawerText(
+          font: Fonts.Mulish.bold.font(size: 26.0),
+          text: Localized.CreateGroup.Drawer.title,
+          color: Asset.neutralActive.color,
+          alignment: .left,
+          spacingAfter: 19
+        ),
+        DrawerText(
+          font: Fonts.Mulish.regular.font(size: 16.0),
+          text: Localized.CreateGroup.Drawer.otherSubtitle,
+          color: Asset.neutralDark.color,
+          alignment: .left,
+          spacingAfter: 20
+        ),
+        DrawerStack(views: [
+          actionButton,
+          FlexibleSpace()
+        ])
+      ], isDismissable: true, from: self))
+    })
 
     viewModel
       .statePublisher
-- 
GitLab