toChatPage static method
- BuildContext context, {
- required Map<
String, dynamic> conversationData, - Map<
String, dynamic> ? arguments, - String? pageTitle,
- String? subTitle,
- Color? subTitleFontColor,
- double? pageBarHeight,
- bool pageTitleIsCenter = false,
- Widget? popLeadWidget,
- bool isReplacementPush = false,
- Color? appBarBackground,
- Color? appBarForegroundColor,
- SystemUiOverlayStyle? systemOverlayStyle,
- Color? pageBackground,
- List<
MoreToolItem> ? morePanelToolList, - List<
Widget> ? appBarActions, - Widget? appBarBelowWidget,
- double showTimeIntervalSecond = 2 * 60,
- AvatarBorderMode avatarBorderMode = AvatarBorderMode.rect,
- double messageDirectDistance = 18,
- double fixedAutoScrollBottomThreshold = 50,
- Widget? bottomInputAreaHeaderWidget,
- BottomPanelConfig? bottomPanelConfig,
- bool? showMessageItemNickName,
- BuildMessageItemResult? messageItemBuilder()?,
- Widget? avatarBuilder()?,
- dynamic onReceiveNewMessage()?,
跳转到聊天页面
conversationData 会话数据
arguments 可选,传入你的业务相关参数
pageTitle 页面标题栏文本
subTitle 页面副标题
subTitleFontColor 页面副标题文字颜色
pageBarHeight 页面标题栏高度。默认:54
pageTitleIsCenter 页面标题栏文本是否居中显示,否则靠左。默认:false
popLeadWidget 页面标题栏左侧显示的返回按钮组件。默认:Icons.arrow_back_ios_new_sharp
isReplacementPush 是否替换当前页 pushReplacement,默认:false
appBarBackground 页面标题栏部分背景颜色。默认:Colors.white
appBarForegroundColor 页面标题栏部分背景颜色。默认:Colors.black
systemOverlayStyle 页面顶部状态栏中文字颜色风格。默认:SystemUiOverlayStyle.dark
pageBackground 页面背景颜色。默认:Color(0xFFF0F4F9)
bottomInputAreaBackground 底部输入框以及更多操作面板的背景色。默认:Colors.grey.shade100
morePanelToolList 更多操作面板,操作项列表。默认操作项列表为空,需要你自己实现
morePanelLines 更多操作面板,每页展示行数。默认:2
morePanelOneLineCount 更多操作面板,每行的个数。默认:4
appBarActions 标题栏右侧的自定义操作组
appBarBelowWidget 可增加在页面标题栏下方显示的 widget
bottomInputAreaHeaderWidget 可增加在底部输入区域上方显示的 widget
bottomInputAreaFooterWidget 可增加在底部输入区域下方显示的 widget
showTimeIntervalSecond 显示聊天消息的时间信息的间隔秒数,每隔多久再次显示时间信息。默认:2 * 60 秒
avatarBorderMode 显示头像的模式。圆心 / 圆角。默认:AvatarBorderMode.rect
messageDirectDistance 每条消息之间的距离。默认:18
fixedAutoScrollBottomThreshold 认为距离底部的滚动距离超过多少后,就要定格滚动了,不再允许执行自动滚动了。且底部输入法区域弹起时不会一并顶起聊天消息列表区域。默认:50
bottomPanelConfig 底部输入面板各项参数配置
chatInputMaxLines 聊天底部输入框最大可输入的行数,超出行数将显示为滚动。默认:8
chatInputHintText 聊天底部输入框提示文本
chatInputHintStyle 聊天底部输入框提示文本样式
showMessageItemNickName 是否显示消息上的用户昵称。默认情况下,c2c会话不会显示、群聊会显示其他人的昵称,自己的不显示。设置为 true 后,还是以默认行为执行,设置为 false 后,将不显示昵称
messageItemBuilder 消息项构建器,返回 null,则展示默认
avatarBuilder 用户默认头像构建器。正常情况下聊天会加载你设置给腾讯IM的用户的头像信息,如果未设置或加载失败的时候,将展示这个构建进去的默认头像
示例:
import 'package:im_plugin_tencent/im_plugin_tencent.dart';
await ImPluginTencentUiTool.toChatPage(
context,
conversationData: 会话 item 数据,
arguments: {},
isReplacementPush: false,
);
Implementation
static Future<void> toChatPage(BuildContext context, {
required Map<String, dynamic> conversationData,
Map<String, dynamic>? arguments,
String? pageTitle,
String? subTitle,
Color? subTitleFontColor,
double? pageBarHeight,
bool pageTitleIsCenter = false,
Widget? popLeadWidget,
bool isReplacementPush = false,
Color? appBarBackground,
Color? appBarForegroundColor,
SystemUiOverlayStyle? systemOverlayStyle,
Color? pageBackground,
List<MoreToolItem>? morePanelToolList,
List<Widget>? appBarActions,
Widget? appBarBelowWidget,
double showTimeIntervalSecond = 2 * 60,
AvatarBorderMode avatarBorderMode = AvatarBorderMode.rect,
double messageDirectDistance = 18,
double fixedAutoScrollBottomThreshold = 50,
Widget? bottomInputAreaHeaderWidget,
Widget? bottomInputAreaFooterWidget,
BottomPanelConfig? bottomPanelConfig,
bool? showMessageItemNickName,
BuildMessageItemResult? Function(Map<String, dynamic> messageData, List<Map<String, dynamic>> messageList, bool isSelf)? messageItemBuilder,
Widget? Function(Map<String, dynamic> userProfile, bool isSelf)? avatarBuilder,
Function(Map<String, dynamic> message)? onReceiveNewMessage,
}) async {
ImState.setCurrentFocusConversationNative(conversationData);
final route = MaterialPageRoute(
builder: (_) => ChatPage(
yourContext: context,
arguments: arguments,
pageTitle: pageTitle,
subTitle: subTitle,
subTitleFontColor: subTitleFontColor,
pageBarHeight: pageBarHeight,
pageTitleIsCenter: pageTitleIsCenter,
popLeadWidget: popLeadWidget,
appBarBackground: appBarBackground,
appBarForegroundColor: appBarForegroundColor,
systemOverlayStyle: systemOverlayStyle,
pageBackground: pageBackground,
morePanelToolList: morePanelToolList,
appBarActions: appBarActions,
appBarBelowWidget: appBarBelowWidget,
showTimeIntervalSecond: showTimeIntervalSecond,
avatarBorderMode: avatarBorderMode,
messageDirectDistance: messageDirectDistance,
fixedAutoScrollBottomThreshold: fixedAutoScrollBottomThreshold,
bottomInputAreaHeaderWidget: bottomInputAreaHeaderWidget,
bottomInputAreaFooterWidget: bottomInputAreaFooterWidget,
bottomPanelConfig: bottomPanelConfig,
showMessageItemNickName: showMessageItemNickName,
messageItemBuilder: messageItemBuilder,
avatarBuilder: avatarBuilder,
onReceiveNewMessage: onReceiveNewMessage,
),
);
if (isReplacementPush) {
Navigator.of(context).pushReplacement(route);
} else {
Navigator.of(context).push(route);
}
}