@@ -21,7 +21,7 @@ struct DemoAppSwiftUIApp: App {
2121// } else {
2222// ChatChannelListView()
2323// }
24- ChatChannelListView ( )
24+ ChatChannelListView ( viewFactory : DemoAppFactory . shared )
2525 /*
2626 //Example of custom query filters.
2727 ChatChannelListView(
@@ -48,134 +48,3 @@ struct DemoAppSwiftUIApp: App {
4848 return controller
4949 }
5050}
51-
52- struct CustomChannelDestination : View {
53-
54- var channel : ChatChannel
55-
56- var body : some View {
57- VStack {
58- Text ( " This is the channel \( channel. name ?? " " ) " )
59- }
60- }
61-
62- }
63-
64- class CustomFactory : ViewFactory {
65-
66- @Injected ( \. chatClient) public var chatClient
67-
68- private init ( ) { }
69-
70- public static let shared = CustomFactory ( )
71-
72- func makeGiphyBadgeViewType( for message: ChatMessage , availableWidth: CGFloat ) -> some View {
73- EmptyView ( )
74- }
75-
76- func makeLoadingView( ) -> some View {
77- VStack {
78- Text ( " This is custom loading view " )
79- ProgressView ( )
80- }
81- }
82-
83- func makeNoChannelsView( ) -> some View {
84- VStack {
85- Spacer ( )
86- Text ( " This is our own custom no channels view. " )
87- Spacer ( )
88- }
89- }
90-
91- func makeChannelListHeaderViewModifier( title: String ) -> some ChannelListHeaderViewModifier {
92- CustomChannelModifier ( title: title)
93- }
94-
95-
96- // Example for an injected action. Uncomment to see it in action.
97- func suppotedMoreChannelActions(
98- for channel: ChatChannel ,
99- onDismiss: @escaping ( ) -> Void ,
100- onError: @escaping ( Error ) -> Void
101- ) -> [ ChannelAction ] {
102- var defaultActions = ChannelAction . defaultActions (
103- for: channel,
104- chatClient: chatClient,
105- onDismiss: onDismiss,
106- onError: onError
107- )
108-
109- let freeze = {
110- let controller = self . chatClient. channelController ( for: channel. cid)
111- controller. freezeChannel { error in
112- if let error = error {
113- onError ( error)
114- } else {
115- onDismiss ( )
116- }
117- }
118- }
119-
120- let confirmationPopup = ConfirmationPopup (
121- title: " Freeze channel " ,
122- message: " Are you sure you want to freeze this channel? " ,
123- buttonTitle: " Freeze "
124- )
125-
126- let channelAction = ChannelAction (
127- title: " Freeze channel " ,
128- iconName: " person.crop.circle.badge.minus " ,
129- action: freeze,
130- confirmationPopup: confirmationPopup,
131- isDestructive: false
132- )
133-
134- defaultActions. insert ( channelAction, at: 0 )
135- return defaultActions
136- }
137-
138- func makeMoreChannelActionsView(
139- for channel: ChatChannel ,
140- onDismiss: @escaping ( ) -> Void ,
141- onError: @escaping ( Error ) -> Void ) -> some View {
142- VStack {
143- Text ( " This is our custom view " )
144- Spacer ( )
145- HStack {
146- Button {
147- onDismiss ( )
148- } label: {
149- Text ( " Action " )
150- }
151-
152- }
153- . padding ( )
154- }
155- }
156-
157- func makeMessageTextView(
158- for message: ChatMessage ,
159- isFirst: Bool ,
160- availableWidth: CGFloat
161- ) -> some View {
162- CustomMessageTextView (
163- message: message,
164- isFirst: isFirst
165- )
166- }
167-
168- func makeCustomAttachmentViewType(
169- for message: ChatMessage ,
170- isFirst: Bool ,
171- availableWidth: CGFloat
172- ) -> some View {
173- CustomAttachmentView (
174- message: message,
175- width: availableWidth,
176- isFirst: isFirst
177- )
178- }
179-
180-
181- }
0 commit comments