@@ -20,11 +20,12 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
2020
2121 public init (
2222 factory: Factory = DefaultViewFactory . shared,
23+ viewModel: ChatChannelInfoViewModel ? = nil ,
2324 channel: ChatChannel ,
2425 shownFromMessageList: Bool = false
2526 ) {
2627 _viewModel = StateObject (
27- wrappedValue: ChatChannelInfoViewModel ( channel: channel)
28+ wrappedValue: viewModel ?? ChatChannelInfoViewModel ( channel: channel)
2829 )
2930 self . factory = factory
3031 self . shownFromMessageList = shownFromMessageList
@@ -52,7 +53,8 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
5253 ChatInfoParticipantsView (
5354 factory: factory,
5455 participants: viewModel. displayedParticipants,
55- onItemAppear: viewModel. onParticipantAppear ( _: )
56+ onItemAppear: viewModel. onParticipantAppear ( _: ) ,
57+ selectedParticipant: $viewModel. selectedParticipant
5658 )
5759 }
5860
@@ -84,14 +86,10 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
8486 viewModel. leaveGroupAlertShown = true
8587 }
8688 . alert ( isPresented: $viewModel. leaveGroupAlertShown) {
87- let title = viewModel. leaveButtonTitle
88- let message = viewModel. leaveConversationDescription
89- let buttonTitle = viewModel. leaveButtonTitle
90-
91- return Alert (
92- title: Text ( title) ,
93- message: Text ( message) ,
94- primaryButton: . destructive( Text ( buttonTitle) ) {
89+ Alert (
90+ title: Text ( viewModel. leaveButtonTitle) ,
91+ message: Text ( viewModel. leaveConversationDescription) ,
92+ primaryButton: . destructive( Text ( viewModel. leaveButtonTitle) ) {
9593 viewModel. leaveConversationTapped {
9694 presentationMode. wrappedValue. dismiss ( )
9795 if shownFromMessageList {
@@ -106,11 +104,11 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
106104 }
107105 }
108106 . overlay (
109- viewModel . addUsersShown ?
107+ popupShown ?
110108 Color . black. opacity ( 0.3 ) . edgesIgnoringSafeArea ( . all) : nil
111109 )
112- . blur ( radius: viewModel . addUsersShown ? 6 : 0 )
113- . allowsHitTesting ( !viewModel . addUsersShown )
110+ . blur ( radius: popupShown ? 6 : 0 )
111+ . allowsHitTesting ( !popupShown )
114112
115113 if viewModel. addUsersShown {
116114 VStack {
@@ -131,6 +129,17 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
131129 )
132130 }
133131 }
132+
133+ if let selectedParticipant = viewModel. selectedParticipant {
134+ ParticipantInfoView (
135+ participant: selectedParticipant,
136+ actions: viewModel. participantActions ( for: selectedParticipant)
137+ ) {
138+ withAnimation {
139+ viewModel. selectedParticipant = nil
140+ }
141+ }
142+ }
134143 }
135144 . toolbarThemed {
136145 ToolbarItem ( placement: . principal) {
@@ -170,4 +179,8 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
170179 . dismissKeyboardOnTap ( enabled: viewModel. keyboardShown)
171180 . background ( Color ( colors. background) . edgesIgnoringSafeArea ( . bottom) )
172181 }
182+
183+ private var popupShown : Bool {
184+ viewModel. addUsersShown || viewModel. selectedParticipant != nil
185+ }
173186}
0 commit comments