Skygear Chat iOS UIKit
About UIKit
UIKit provides the SKYChatConversationViewController
, the main UI of a conversation.
The view of SKYChatConversationViewController
is SKYChatConversationView
. The view consists of the following components.
- Title Bar
- Avatar (Outgoing)
- Message (Outgoing)
- Avatar (Incoming)
- Message (Incoming)
- Camera Button
- Text Input
- Voice Button
Prerequisite
Step 1: Add Skygear and Skygear Chat to your project
Please follow the steps at Quick Start.
Step 2: Add Skygear Chat UIKit to your project
- add
pod 'SKYKitChat/UI', '~> 1.5'
inPodfile
.
pod 'SKYKitChat/UI', '~> 1.5'
- Save your
Podfile
and run pod install in the terminal.
pod install
- Import UIKit in your source code as follows
Creating a conversation UI
The following code block creates a SKYChatConversationViewController
of a conversation c
.
Customizations
SKYChatConversationView
can be customized via
- setting properties of
SKYChatConversationView.UICustomization()
SKYChatUIModelCustomization.default()
SKYChatConversationViewController
- implementing delegates.
UICustomization
You can customize SKYChatConversationView
properties in the following way.
The following properties are supported.
Avatar
Attribute | Description |
Type |
---|---|---|
avatarBackgroundColor |
Background color of the avatar | Color |
avatarTextColor |
Text color of the avatar | Color |
avatarType |
Avatar Type, either showing initial of the username field or image | SKYChatConversationViewUserAvatarType , "initial " or "image " |
avatarHiddenForIncomingMessages |
Hide incoming message avatar if true | Boolean, default False |
avatarHiddenForOutgoingMessages |
Hide outgoing message avatar if true | Boolean, default False |
Background
Attribute | Description |
Type |
---|---|---|
backgroundColor |
Background color of the conversation view | Color |
backgroundImage |
Background image of the conversation view | UIImage |
backgroundImageURL |
Remote background image of the conversation view | NSURL |
Title
Attribute | Description |
Type |
---|---|---|
titleDisplayType |
See below | SKYChatConversationViewTitleOptions |
If default
is set, then the title bar displays title
field value of the conversation record. If otherParticipants
is set,
then the title bar displays participants' usernames (excluding the current user) in the title bar.
Date
Attribute | Description |
Type |
---|---|---|
messageDateFormatter |
Message delivery time date formatter | DateFormatter |
Message
attribute |
description | type |
---|---|---|
messageSenderTextColor |
text color of the message sender | Color |
incomingMessageBubbleColor |
Incoming messages background color | Color |
outgoingMessageBubbleColor |
Outgoing messages background color | Color |
Feature On/Off
Attribute | Description |
Type |
---|---|---|
cameraButtonShouldShow |
Show camera button if true | Bool, default: true |
voiceMessageButtonShouldShow |
Show voice message button if true | Bool, default: true |
typingIndicatorShouldShow |
Show typing indicators if true | Bool, default: true |
messageStatusShouldShow |
Show message status if true | Bool, default: true |
accessoryButtonShouldShow |
Show accessory button if true | Bool, default: true |
TextCustomization
Texts such as message delivery status, date format and button label can be customized via textCustomization
.
Supported attributes:
Attribute | Description |
Type |
---|---|---|
messageStatusDelivering |
Delivering text | String, default "Delivering" |
messageStatusDelivered |
Delivered text | String, default "Delivered" |
messageStatusSomeRead |
Some read text | String, default "Some Read" |
messageStatusAllRead |
All read text | String, default "All Read" |
messageSentFailed |
Failed text | String, default "Failed" |
sendButton |
Send Button Text | String, default "Send" |
SKYChatUIModelCustomization
You can change userNameField
and userAvatarField
via SKYChatUIModelCustomization.default()
.
Attribute | Description |
Type |
---|---|---|
userNameField |
Field name of the username in user table |
String, default "username" |
userAvatarField |
Field name of the avatar image in user table |
String, default "avatar" |
Delegates
You may also implement functions in SKYChatConversationViewControllerDelegate
Message Date
- To customize date format
- Example Code
- To enable or disable date
Feature On/Off
- Accessory button
- Camera button
- Voice message button
- Typing indicator
- Message status
Background Image
- Background color
- Background image
- Remote background image