GiftSendWidget
: send gift message view, clicking it can bring up the gift panel.GiftDisplayWidget
: receive gift message view, it will display gift messages on this view.Gift Display Panel | Normal Gift Playing Effect | Full-Screen Gift Playing Effect |
| | |
TUIGiftListView
: A gift panel displaying the gift list, sending gifts, and recharging.TUIGiftPlayView
: A panel for playing gifts, automatically listens for gift messages.Gift Display Panel | Normal Gift Playing Effect | Full-Screen Gift Playing Effect |
| | |
TUIGiftListView
: A gift panel displaying the gift list, sending gifts, and recharging.TUIGiftPlayView
: A panel for playing gifts, automatically listens for gift messages.Gift Display Panel | Normal Gift Playing Effect | Full-Screen Gift Playing Effect |
| | |
dependencies
section in your project's pubspec.yaml
file.dependencies:flutter:sdk: flutterflutter_localizations:sdk: flutterintl: ^0.19.0# Add gift local dependencygift:path: ../gift
localizationsDelegates
and supportedLocales
properties of your MaterialApp
.MaterialApp(localizationsDelegates: const [...GiftLocalizations.localizationsDelegates,], supportedLocales: const [...GiftLocalizations.supportedLocales,], theme: ThemeData.dark(), home: const HomeScreen());
GiftSendController
and GiftSendWidget
objects where you need to integrate the gift sending message, and add the constructed GiftSendWidget
object to your Widget
tree. Example code is as follows:GiftSendController _giftSendController = GiftSendController(roomId: "liveRoomId", /// liveRoomId Replace with your live room IDowner: ownerInfo, /// ownerInfo Replace with your live room host informationself: selfInfo, /// selfInfo Replace with your login user information);GiftSendWidget(controller: _giftSendController);
OnGiftListener
in TUIGiftListView
, handling the onSendGift
callback, to obtain the number and information of gifts. After preprocessing, you can call the sendGift
function of TUIGiftListView
for the actual sending of gifts.public void onSendGift(TUIGiftListView giftListView, TUIGift gift, int giftCount) {//... Preprocessing here, such as verifying the current user's balanceTUIGiftUser receiver = new TUIGiftUser();//... Set gift recipient information heregiftListView.sendGift(gift, giftCount, receiver);}
OnGiftListener
in TUIGiftListView
, handling the onSendGift
callback, to obtain the number and information of gifts. After preprocessing, you can call the sendGift
function of TUIGiftListView
for the actual sending of gifts.func onSendGift(giftListView view: TUIGiftListView, giftModel: TUIGift, giftCount: Int) {//... Preprocessing here, such as verifying the current user's balancelet receiver = TUIGiftUser()//... Set gift recipient information hereview.sendGift(giftModel: giftModel, giftCount: giftCount, receiver: receiver)}
GiftDisplayController
and GiftDisplayWidget
objects where you need to integrate the gift display message, and add the constructed GiftDisplayWidget
object to your Widget
tree. Example code is as follows:GiftDisplayController _giftDisplayController = GiftDisplayController(rroomId: "liveRoomId", /// liveRoomId Replace with your live room IDowner: ownerInfo, /// ownerInfo Replace with your live room host informationself: selfInfo, /// selfInfo Replace with your login user information);GiftDisplayWidget(controller: _giftDisplayController!);
TUIGiftPlayView
will receive and display gift messages on its own.// File location:tuilivekit/src/main/java/com/trtc/uikit/livekit/common/uicomponent/gift/
TUIGiftPlayView.javaTUIGiftPlayView giftPlayView = new TUIGiftPlayView(mContext, roomId);
TUIGiftPlayView
will receive and display gift messages on its own.let giftPlayView = GiftPlayView(groupId: roomId)
GiftDisplayController
's setGiftCallback
method. Example code is as follows:_giftDisplayController?.setGiftCallback(onReceiveGiftCallback: _onReceiveGiftCallback, /// _onReceiveGiftCallback can be replaced with your custom handling methodonSendGiftCallback: _onSendGiftCallback, /// _onSendGiftCallback can be replaced with your custom handling method);
TUIGiftPlayView
's TUIGiftPlayViewListener
's onReceiveGift
function.public
interface
TUIGiftPlayViewListener
{
void
onReceiveGift
(
TUIGift
gift
,
int
giftCount
,
TUIGiftUser
sender
,
TUIGiftUser
receiver
)
;
//...
}
GiftPlayView
's delegate GiftPlayViewDelegate
's giftPlayView:onReceiveGift:gift:giftCount:sender:receiver
function.func giftPlayView(_ giftPlayView: TUIGiftPlayView, onReceiveGift gift: TUIGift, giftCount: Int, sender: TUIGiftUser, receiver: TUIGiftUser) {// Custom Processing}
GiftSendController
's setGiftList
method, as shown below: List<GiftModel> giftList = [ /// Customize your gift list data sourceGiftModel(giftId: "1", giftName: "Egg", imageUrl: "giftImageUrl", price: 10),GiftModel(giftId: "2", giftName: "Star", imageUrl: "giftImageUrl", price: 10),];_giftSendController.setGiftList(giftList);
// File location:tuilivekit/src/main/java/com/trtc/uikit/livekit/liveroom/view/audience/component/AudienceFunctionView.java
mGiftCloudServer.queryGiftInfoList((error, result) -> post(() -> {if (error == Error.NO_ERROR) {mGiftListView.setGiftList(result);} else {ToastUtil.toastLongMessage("query gift list error, code = " + error);}}));
queryGiftInfoList
method themselves to obtain a custom gift list List<TUIGift>
, and set the gift list through GiftListView.setGiftList
.animationUrl
of the gift requires an SVGA animation.// File location: iOS/TUILiveKit/Sources/Component/Gift/Store/TUIGiftStore.swiftclass TUIGiftStore {static let shared = TUIGiftStore()private init() {giftCloudServer.queryGiftInfoList { [weak self] error, giftList inguard let self = self else { return }if error == .noError {self.giftList = giftList}}}var giftList: [TUIGift] = []let giftCloudServer: IGiftCloudServer = GiftCloudServer()}// File location: iOS/TUILiveKit/Sources/LiveStream/Main/Audience/AudienceView.swiftfunc getRouteView(route: Route) -> UIView? {if route == .giftView {giftPanelView.setGiftList(TUIGiftStore.shared.giftList)return giftPanelView} else {return nil}}
queryGiftInfoList
method themselves to obtain a custom gift list List<TUIGift>
, and set the gift list through GiftListView.setGiftList
.animationUrl
of the gift requires an SVGA animation.queryGiftInfoList
method themselves to obtain a custom gift list List<TUIGift>
, and set the gift list through GiftListView.setGiftList
.animationUrl requires an SVGA animation
.controller
needs to integrate some live room information parameters and user information, it should be loaded after the audience enters the live broadcast room or the anchor creates a live streaming room.
Was this page helpful?