|
|
@@ -12,6 +12,7 @@ import '../../resource/colors.gen.dart';
|
|
|
import '../../resource/string.gen.dart';
|
|
|
import '../../utils/clipboard_util.dart';
|
|
|
import '../../utils/url_launcher_util.dart';
|
|
|
+import '../../widget/delegate_lifecycle_widget.dart';
|
|
|
import 'enums/keyboard_guide_msg_type.dart';
|
|
|
|
|
|
/// 键盘引导页面
|
|
|
@@ -31,26 +32,32 @@ class KeyboardGuidePage extends BasePage<KeyboardGuidePageController> {
|
|
|
Widget buildBody(BuildContext context) {
|
|
|
return Scaffold(
|
|
|
backgroundColor: backgroundColor(),
|
|
|
- body: Column(
|
|
|
- children: [
|
|
|
- // 标题栏
|
|
|
- _buildTitleBar(),
|
|
|
- // 消息列表
|
|
|
- Expanded(
|
|
|
- flex: 1,
|
|
|
- child: Obx(() {
|
|
|
- return ListView.builder(
|
|
|
- controller: controller.scrollController,
|
|
|
- itemCount: controller.msgList.length,
|
|
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
- return _buildMsgItem(controller.msgList[index]);
|
|
|
- },
|
|
|
- );
|
|
|
- }),
|
|
|
- ),
|
|
|
- // 底部输入栏
|
|
|
- _buildBottomInput(),
|
|
|
- ],
|
|
|
+ body: DelegateLifecycleWidget(
|
|
|
+ onCreateCallback: () {
|
|
|
+ controller.showGuideOverlayDialog();
|
|
|
+ },
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ // 标题栏
|
|
|
+ _buildTitleBar(),
|
|
|
+ // 消息列表
|
|
|
+ Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: Obx(() {
|
|
|
+ return ListView.builder(
|
|
|
+ controller: controller.scrollController,
|
|
|
+ itemCount: controller.msgList.length,
|
|
|
+ itemBuilder: (BuildContext context, int index) {
|
|
|
+ KeyboardGuideMsg msg = controller.msgList[index];
|
|
|
+ return _buildMsgItem(msg, index);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ // 底部输入栏
|
|
|
+ _buildBottomInput(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
@@ -291,45 +298,56 @@ class KeyboardGuidePage extends BasePage<KeyboardGuidePageController> {
|
|
|
}
|
|
|
|
|
|
/// 构建聊天消息列表项
|
|
|
- Widget _buildMsgItem(KeyboardGuideMsg msg) {
|
|
|
- Widget content;
|
|
|
- // 自己发的
|
|
|
- if (msg.isMe) {
|
|
|
- content = Row(
|
|
|
- // 如果是自己发的,则在右边
|
|
|
- mainAxisAlignment: MainAxisAlignment.end,
|
|
|
- // 顶部对齐
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- // 聊天气泡
|
|
|
- _buildMsgBubble(msg),
|
|
|
- // 头像
|
|
|
- _buildAvatar(msg),
|
|
|
- ],
|
|
|
- );
|
|
|
- } else {
|
|
|
- // 对方发的
|
|
|
- content = Row(
|
|
|
- // 如果是自己发的,则在右边
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
- // 顶部对齐
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- // 头像
|
|
|
- _buildAvatar(msg),
|
|
|
- // 聊天气泡
|
|
|
- _buildMsgBubble(msg),
|
|
|
- ],
|
|
|
+ Widget _buildMsgItem(KeyboardGuideMsg msg, int index) {
|
|
|
+ return Obx(() {
|
|
|
+ Widget content;
|
|
|
+ // 自己发的
|
|
|
+ if (msg.isMe) {
|
|
|
+ content = Row(
|
|
|
+ // 如果是自己发的,则在右边
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
+ // 顶部对齐
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ // 聊天气泡
|
|
|
+ _buildMsgBubble(msg),
|
|
|
+ // 头像
|
|
|
+ _buildAvatar(msg),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ // 对方发的
|
|
|
+ content = Row(
|
|
|
+ // 如果是自己发的,则在右边
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ // 顶部对齐
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ // 头像
|
|
|
+ _buildAvatar(msg),
|
|
|
+ // 聊天气泡
|
|
|
+ _buildMsgBubble(msg),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ bool isTargetGuildMsg = controller.guideMsgIndex.value == index;
|
|
|
+
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.0.h),
|
|
|
+ child:
|
|
|
+ isTargetGuildMsg
|
|
|
+ ? Container(key: controller.guideMsgGlobalKey, child: content)
|
|
|
+ : content,
|
|
|
);
|
|
|
- }
|
|
|
- return Container(padding: const EdgeInsets.all(8.0), child: content);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/// 构建头像
|
|
|
Widget _buildAvatar(KeyboardGuideMsg msg) {
|
|
|
double avatarSize = 36.0;
|
|
|
return Container(
|
|
|
- margin: const EdgeInsets.symmetric(horizontal: 9.0),
|
|
|
+ margin: const EdgeInsets.only(right: 9.0),
|
|
|
child: CircleAvatar(
|
|
|
radius: 20,
|
|
|
child:
|