1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;
use crate::*;
/// Describes how the extension is presented in Messages.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapppresentationstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MSMessagesAppPresentationStyle(pub NSUInteger);
impl MSMessagesAppPresentationStyle {
#[doc(alias = "MSMessagesAppPresentationStyleCompact")]
pub const Compact: Self = Self(0);
#[doc(alias = "MSMessagesAppPresentationStyleExpanded")]
pub const Expanded: Self = Self(1);
#[doc(alias = "MSMessagesAppPresentationStyleTranscript")]
pub const Transcript: Self = Self(2);
}
unsafe impl Encode for MSMessagesAppPresentationStyle {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MSMessagesAppPresentationStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Describes the context for which the extension was launched
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapppresentationcontext?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MSMessagesAppPresentationContext(pub NSUInteger);
impl MSMessagesAppPresentationContext {
#[doc(alias = "MSMessagesAppPresentationContextMessages")]
pub const Messages: Self = Self(0);
#[doc(alias = "MSMessagesAppPresentationContextMedia")]
pub const Media: Self = Self(1);
}
unsafe impl Encode for MSMessagesAppPresentationContext {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MSMessagesAppPresentationContext {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapptranscriptpresentation?language=objc)
pub unsafe trait MSMessagesAppTranscriptPresentation {
#[cfg(feature = "objc2-core-foundation")]
/// The content size of the view controller's view fitting the constraining size.
///
/// This method will only be called if the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
///
/// Parameter `size`: The maximum size the view will be displayed at.
#[unsafe(method(contentSizeThatFits:))]
#[unsafe(method_family = none)]
unsafe fn contentSizeThatFits(&self, size: CGSize) -> CGSize;
#[cfg(feature = "objc2-ui-kit")]
/// Override to provide a message tint color, e.g. to match the content of the message, or your app's brand color.
///
/// This color will be drawn either in a material or as a solid color, depending on transcript context. The default value is nil, which renders the plugin balloon with the system standard background color. This must be a simple RGB color - other color types such as displayP3 or pattern images are not supported. This also does not support dynamic colors. If your color needs to be dynamic, you must call `invalidateMessageTintColor` when the dynamic conditions change.
#[unsafe(method(messageTintColor))]
#[unsafe(method_family = none)]
unsafe fn messageTintColor(&self) -> Option<Retained<UIColor>>;
#[cfg(feature = "objc2-core-foundation")]
/// The corner radius of the message when presented in the transcript. Use this value to create concentric rounded subviews inside your view. Use continuous corners (kCACornerCurveContinuous) on your view.
///
/// This property varies with dynamic type size. Use trait collection registration to trigger an updated layout when dynamic type size changes. To avoid the edges of the transcript view, use `layoutMargins`. This value is only valid when `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
#[unsafe(method(messageCornerRadius))]
#[unsafe(method_family = none)]
unsafe fn messageCornerRadius(&self) -> CGFloat;
/// Call this when `messageTintColor` changes, e.g. due to change in app state or trait collection.
///
/// The message will be updated to reflect the new color. This method will only work if the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
#[unsafe(method(invalidateMessageTintColor))]
#[unsafe(method_family = none)]
unsafe fn invalidateMessageTintColor(&self);
}
);
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesappviewcontroller?language=objc)
#[unsafe(super(UIViewController, UIResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "objc2-ui-kit")]
pub struct MSMessagesAppViewController;
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl MSMessagesAppTranscriptPresentation for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl NSCoding for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl NSObjectProtocol for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIAppearanceContainer for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIContentContainer for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIFocusEnvironment for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIResponderStandardEditActions for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UITraitEnvironment for MSMessagesAppViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
extern_methods!(
#[cfg(feature = "MSConversation")]
/// Current active conversation.
#[unsafe(method(activeConversation))]
#[unsafe(method_family = none)]
pub unsafe fn activeConversation(&self) -> Option<Retained<MSConversation>>;
/// Get the presentation extension's current presentation style.
#[unsafe(method(presentationStyle))]
#[unsafe(method_family = none)]
pub unsafe fn presentationStyle(&self) -> MSMessagesAppPresentationStyle;
/// The context for which the extension was launched
#[unsafe(method(presentationContext))]
#[unsafe(method_family = none)]
pub unsafe fn presentationContext(&self) -> MSMessagesAppPresentationContext;
/// Requests that Messages transition the extension to the specified presentation style.
///
/// When the current `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`, a new instance of `MSMessagesAppViewController` will be instantiated with the requested presentation style if needed.
///
/// Parameter `presentationStyle`: The presentation style to transition to. `MSMessagesAppPresentationStyleTranscript` is not a valid presentation style to request.
#[unsafe(method(requestPresentationStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn requestPresentationStyle(
&self,
presentation_style: MSMessagesAppPresentationStyle,
);
#[cfg(feature = "MSConversation")]
/// Called when the extension is about to become active.
///
/// Parameter `conversation`: The current conversation.
#[unsafe(method(willBecomeActiveWithConversation:))]
#[unsafe(method_family = none)]
pub unsafe fn willBecomeActiveWithConversation(&self, conversation: &MSConversation);
#[cfg(feature = "MSConversation")]
/// Called when the extension has become active.
///
/// Parameter `conversation`: The current conversation.
#[unsafe(method(didBecomeActiveWithConversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didBecomeActiveWithConversation(&self, conversation: &MSConversation);
#[cfg(feature = "MSConversation")]
/// Called when the extension will resign active.
///
/// Parameter `conversation`: The current conversation.
#[unsafe(method(willResignActiveWithConversation:))]
#[unsafe(method_family = none)]
pub unsafe fn willResignActiveWithConversation(&self, conversation: &MSConversation);
#[cfg(feature = "MSConversation")]
/// Called when the extension has resigned active.
///
/// Parameter `conversation`: The current conversation.
#[unsafe(method(didResignActiveWithConversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didResignActiveWithConversation(&self, conversation: &MSConversation);
);
}
/// Methods declared on superclass `UIViewController`.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
extern_methods!(
#[unsafe(method(initWithNibName:bundle:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithNibName_bundle(
this: Allocated<Self>,
nib_name_or_nil: Option<&NSString>,
nib_bundle_or_nil: Option<&NSBundle>,
) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
/// CompactOrExpandedPresentation.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
extern_methods!(
/// Tells Messages to dismiss the extension and present the keyboard.
///
/// Calling this method does nothing when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
#[unsafe(method(dismiss))]
#[unsafe(method_family = none)]
pub unsafe fn dismiss(&self);
#[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
/// Informs the extension that a new message will be selected in the conversation.
///
/// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
///
/// Parameter `message`: The message selected.
///
/// Parameter `conversation`: The conversation.
#[unsafe(method(willSelectMessage:conversation:))]
#[unsafe(method_family = none)]
pub unsafe fn willSelectMessage_conversation(
&self,
message: &MSMessage,
conversation: &MSConversation,
);
#[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
/// Informs the extension that a new message has been selected in the conversation.
///
/// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
///
/// Parameter `message`: The message selected.
///
/// Parameter `conversation`: The conversation.
#[unsafe(method(didSelectMessage:conversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didSelectMessage_conversation(
&self,
message: &MSMessage,
conversation: &MSConversation,
);
#[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
/// Informs the extension that a new message has arrived.
///
/// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
///
/// Parameter `message`: The message received.
///
/// Parameter `conversation`: The conversation.
#[unsafe(method(didReceiveMessage:conversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didReceiveMessage_conversation(
&self,
message: &MSMessage,
conversation: &MSConversation,
);
#[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
/// Informs the extension that the message send has been triggered.
///
/// This is called when a user interaction with Messages start the message send process. It does not guarantee the message will be successfully sent or delivered. This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
///
/// Parameter `message`: The message being sent.
///
/// Parameter `conversation`: The conversation the message belongs to.
#[unsafe(method(didStartSendingMessage:conversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didStartSendingMessage_conversation(
&self,
message: &MSMessage,
conversation: &MSConversation,
);
#[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
/// Informs the extension that the user has removed the message from the input field.
///
/// This method will not be called when the `presentationStyle` is MSMessagesAppPresentationStyleTranscript or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
///
/// Parameter `message`: The message sent.
///
/// Parameter `conversation`: The conversation.
#[unsafe(method(didCancelSendingMessage:conversation:))]
#[unsafe(method_family = none)]
pub unsafe fn didCancelSendingMessage_conversation(
&self,
message: &MSMessage,
conversation: &MSConversation,
);
/// Called when the extension is about to transition to a new presentation style.
///
/// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
///
/// Parameter `presentationStyle`: The new presentation style.
#[unsafe(method(willTransitionToPresentationStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn willTransitionToPresentationStyle(
&self,
presentation_style: MSMessagesAppPresentationStyle,
);
/// Called when the extension finished transitioning to a presentation style.
///
/// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
///
/// Parameter `presentationStyle`: The new presentation style.
#[unsafe(method(didTransitionToPresentationStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn didTransitionToPresentationStyle(
&self,
presentation_style: MSMessagesAppPresentationStyle,
);
);
}