UIKIT allows the default behaviour to be overridden by custom logic.
This setting allows you to control where a post can be shared to based on the post origin.
My feed - The post can be shared to my feed. This option will enable "Share to my timeline" menu when user clicks share button.
Public community - The post can be shared to any public community. This option will enable "Share to group" menu when user clicks share button.
Private community - The post can be shared to any private community. This option will enable "Share to group" menu when user clicks share button.
External - The post can be shared externally. This option will enable "More options" menu when user clicks share button.
Origin - The post can be shared within the community feed that it was created. If the post was created in either public or private community, this option will enable "Share to group" menu when user clicks share button.
My feed post - Posts that were created on my feed. By default, possible sharing targets are My feed, Public community, and Private community.
User feed post - Posts that were created on any other users' feed. By default, possible sharing targets are My feed, Public community, and Private community.
Public community feed post - Posts that were created on any public community. By default, possible sharing targets are My feed, Public community, and Private community.
Private community feed post - Posts that were created on any private community. By default, possible sharing target is Origin.
You can select a set of targets for each post origin.
Based on Post sharing settings, there are up to three post sharing events that can be emitted by UIKit.
Share to my timeline - an event emitted when a user clicks on "Share to my timeline" button.
Share to group - an event emitted when a user clicks on "Share to group" button.
Share externally - an event emitted when a user clicks "More options" button.
You can choose to intercept one or all of the events and apply your custom behavior.
There are many pages and actions on AmityUIKit. Pages can be nested inside others and it would be hard for overriding events on the nested pages. In order to solve this problem, we provide EkoEventHandler
which is a behavior controller for actions that happen in UIKit.
When a user clicks on the user profile avatar at the post creator area, UIKit will open User profile page
However, you can intercept the event and define your own logic following the example below.
To customize message cell layouts, please follow these instructions:
Create a subclass of UITableViewCell
and conform it to AmityMessageCellProtocol
To bind message data to UI, implement display(message:)
. You can also implement height(for message:boundingWidth:)
to specify the cell height. We've included some examples below for static-height calculation and dynamic-height calculation as reference
Subclass AmityEventHandler,
and override its default functions channelDidTap(from:channelId:)
and conform to AmityMessageListDataSource
.
4. Assign a class instance through a set function of AmityUIKitManager
Static-Height Cell Layout
You can use static-height cell layout types for static content, where the cell height is fixed and will not be scaled regardless of the data being received.
Below is an example of how you can configure a static-height cell layout. In this example, we're assuming that the image message is a class named StaticHeightMessageCell
.
Dynamic-Height Cell Layout
You can use dynamic-height cell layout when you require your cell height to expand dynamically according to the data (e.g. label expands upon strings).
Dynamic-height cell layouts require more complexity in height calculation. Let's look at a text message as an example, where the height of the cell needs to expand dynamically to display the full content.
UIKit provides default renderers for the core data types: text
, image
, and file
. It also provides a way to render your own UI for your custom post.
A single post UI is composed of 1 or more UITableViewCell. This allows reusability of cell components such as header or footer which can be shared by different kinds of posts.
This is an example of simple text post which contains 3 tableview cell. Top cell represents the header, middle cell contains text content and bottom cell is footer cell.
There are 3 steps involved in creating custom post renderer.
Step 1: Create your UI using UITableView cells.
Step 2: Compose a post UI component. For this create a component which conforms to AmityPostComposable
protocol.
You can also use our default header cell AmityPostHeaderTableViewCell
& default footer cell AmityPostFooterTableViewCell
in your custom post component.
Step 3: Register your custom cell & implement datasource.
Event
Parameter
Condition
communityDidTap
communityId
community avatar or community display name is tapped
userDidTap
userId
user avatar or user display name is tapped
editUserDidTap
userId
edit user button is tapped
postDidtap
postId
post or comment on social feed is tapped
editPostDidTap
postId
edit post button is tapped
channelDidTap
channelId
user channel list or user chat button is tapped
communityChannelDidTap
channelId
n/a