tuiBuild method

  1. @override
Widget tuiBuild(
  1. BuildContext context,
  2. TUIKitBuildValue value
)
override

Implementation

@override
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
  final TUITheme theme = value.theme;

  final isDesktopScreen =
      TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;

  Widget messageListPage() {
    return messageList.isEmpty
        ? Row(
            children: [
              Expanded(
                  child: Column(
                mainAxisSize: MainAxisSize.max,
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  LoadingAnimationWidget.staggeredDotsWave(
                    color: theme.weakTextColor ?? Colors.grey,
                    size: 48,
                  ),
                  const SizedBox(height: 20),
                  Text(TIM_t("消息列表加载中"))
                ],
              ))
            ],
          )
        : Container(
            padding: isDesktopScreen ? null : const EdgeInsets.all(16),
            child: ListView.builder(
              shrinkWrap: true,
              itemCount: messageList.length,
              itemBuilder: (context, index) {
                final message = messageList[index];
                return _itemBuilder(message, context);
              },
            ),
          );
  }

  return TUIKitScreenUtils.getDeviceWidget(
      context: context,
      desktopWidget: Container(
        padding: const EdgeInsets.symmetric(horizontal: 16),
        child: messageListPage(),
      ),
      defaultWidget: Scaffold(
        appBar: AppBar(
            title: Text(
              TIM_t("聊天记录"),
              style: TextStyle(color: theme.appbarTextColor, fontSize: 17),
            ),
            shadowColor: theme.weakDividerColor,
            backgroundColor: theme.appbarBgColor ??
                theme.primaryColor,
            iconTheme: IconThemeData(
              color: theme.appbarTextColor,
            )),
        body: messageListPage(),
      ));
}