chat_room.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. import 'package:flutter/material.dart';
  2. class ChatRoom extends StatelessWidget {
  3. final List<Map<String, dynamic>> messages = [
  4. {
  5. 'sender': 'system',
  6. 'text': '尊敬的经纪:您好,欢迎来到《名媛汇》高端外围服务平台。您可以通过下方的介绍简单的了解一下平台介绍、客服服务、交易流程、常见问题',
  7. 'time': '14:20'
  8. },
  9. {'sender': 'system', 'text': '商务客服24小时在线,如有疑问请及时沟通', 'time': '14:20'},
  10. {
  11. 'sender': 'user',
  12. 'text': 'Proin gravida dolor sit amet lacus accumsan et viverra.',
  13. 'time': '14:22'
  14. },
  15. {
  16. 'sender': 'system',
  17. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  18. 'time': '14:21'
  19. },
  20. {
  21. 'sender': 'system',
  22. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  23. 'time': '14:21'
  24. },
  25. {
  26. 'sender': 'system',
  27. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  28. 'time': '14:21'
  29. },
  30. {
  31. 'sender': 'system',
  32. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  33. 'time': '14:21'
  34. },
  35. {
  36. 'sender': 'system',
  37. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  38. 'time': '14:21'
  39. },
  40. {
  41. 'sender': 'system',
  42. 'text': '订单号:100000001,尾款已交收,请及时退款,谢谢配合!',
  43. 'time': '14:22'
  44. },
  45. ];
  46. final List<Map<String, String>> avatars = [
  47. {
  48. 'name': '北京XX',
  49. 'image': 'https://picsum.photos/80/100',
  50. },
  51. {
  52. 'name': '上海XX',
  53. 'image': 'https://picsum.photos/80/100',
  54. },
  55. {
  56. 'name': '校花XX',
  57. 'image': 'https://picsum.photos/80/100',
  58. },
  59. {
  60. 'name': '嫩模XX',
  61. 'image': 'https://picsum.photos/80/100',
  62. },
  63. {
  64. 'name': '空姐XX',
  65. 'image': 'https://picsum.photos/80/100',
  66. },
  67. ];
  68. final List<String> quickReplies = ['名媛汇', '交易流程', '常见问题'];
  69. final List<String> paymentReplies = ['支付回款', '订单群'];
  70. ChatRoom({super.key});
  71. @override
  72. Widget build(BuildContext context) {
  73. return Scaffold(
  74. appBar: PreferredSize(
  75. preferredSize: Size(double.infinity, 64),
  76. child: AppBar(
  77. centerTitle: true,
  78. title: const Column(children: <Widget>[
  79. Text('选妃助手'),
  80. Row(
  81. mainAxisAlignment: MainAxisAlignment.center,
  82. crossAxisAlignment: CrossAxisAlignment.center,
  83. children: [
  84. Icon(Icons.circle, color: Colors.blue, size: 10),
  85. SizedBox(width: 4),
  86. Text("机器人",
  87. style: TextStyle(fontSize: 14, color: Colors.blue)),
  88. ],
  89. )
  90. ])),
  91. ),
  92. // AppBar(
  93. // leading: const BackButton(),
  94. // title: const Text('选妃助手'),
  95. // centerTitle: true,
  96. // bottom: const PreferredSize(
  97. // preferredSize: const Size.fromHeight(32),
  98. // child: Column(
  99. // children: [
  100. // const Text(
  101. // '机器人',
  102. // style: TextStyle(color: Colors.blue, fontSize: 14),
  103. // ),
  104. // const SizedBox(height: 8),
  105. // ],
  106. // ),
  107. // ),
  108. // ),
  109. body: Column(
  110. children: [
  111. SingleChildScrollView(
  112. scrollDirection: Axis.horizontal,
  113. padding: const EdgeInsets.symmetric(horizontal: 12),
  114. child: Row(
  115. children: avatars.map((item) {
  116. return Padding(
  117. padding: const EdgeInsets.symmetric(horizontal: 6.0),
  118. child: Column(
  119. children: [
  120. ClipRRect(
  121. borderRadius: BorderRadius.circular(8),
  122. child: Image.network(
  123. item['image']!,
  124. width: 80,
  125. height: 100,
  126. fit: BoxFit.cover,
  127. ),
  128. ),
  129. Container(
  130. width: 80,
  131. alignment: Alignment.center,
  132. padding: const EdgeInsets.symmetric(vertical: 4),
  133. decoration: BoxDecoration(
  134. color: Colors.black54,
  135. borderRadius:
  136. BorderRadius.vertical(bottom: Radius.circular(8)),
  137. ),
  138. child: Text(
  139. item['name']!,
  140. style: const TextStyle(
  141. color: Colors.white, fontSize: 14),
  142. ),
  143. )
  144. ],
  145. ),
  146. );
  147. }).toList(),
  148. ),
  149. ),
  150. Expanded(
  151. child: ListView.builder(
  152. padding: const EdgeInsets.all(16),
  153. itemCount: messages.length,
  154. itemBuilder: (context, index) {
  155. final msg = messages[index];
  156. final isUser = msg['sender'] == 'user';
  157. return Align(
  158. alignment:
  159. isUser ? Alignment.centerRight : Alignment.centerLeft,
  160. child: Container(
  161. padding: const EdgeInsets.all(12),
  162. margin: const EdgeInsets.symmetric(vertical: 4),
  163. constraints: const BoxConstraints(maxWidth: 300),
  164. decoration: BoxDecoration(
  165. color: isUser ? Colors.lightBlueAccent : Colors.grey[200],
  166. borderRadius: BorderRadius.circular(12),
  167. ),
  168. child: Column(
  169. crossAxisAlignment: isUser
  170. ? CrossAxisAlignment.end
  171. : CrossAxisAlignment.start,
  172. children: [
  173. Text(
  174. msg['text'],
  175. style: const TextStyle(fontSize: 14),
  176. ),
  177. const SizedBox(height: 4),
  178. Text(
  179. msg['time'],
  180. style: const TextStyle(
  181. fontSize: 10, color: Colors.black45),
  182. ),
  183. ],
  184. ),
  185. ),
  186. );
  187. },
  188. ),
  189. ),
  190. // Quick Reply Section
  191. // Padding(
  192. // padding: const EdgeInsets.symmetric(horizontal: 8),
  193. // child: Wrap(
  194. // spacing: 8,
  195. // runSpacing: 8,
  196. // children: quickReplies
  197. // .map((reply) => OutlinedButton(
  198. // onPressed: () {},
  199. // child: Text(reply),
  200. // ))
  201. // .toList(),
  202. // ),
  203. // ),
  204. // const SizedBox(height: 8),
  205. // Padding(
  206. // padding: const EdgeInsets.symmetric(horizontal: 8),
  207. // child: Wrap(
  208. // spacing: 8,
  209. // runSpacing: 8,
  210. // children: paymentReplies
  211. // .map((reply) => OutlinedButton(
  212. // onPressed: () {},
  213. // child: Text(reply),
  214. // ))
  215. // .toList(),
  216. // ),
  217. // ),
  218. // Bottom sticky button
  219. Container(
  220. width: double.infinity,
  221. margin: const EdgeInsets.all(16),
  222. child: ElevatedButton(
  223. style: ElevatedButton.styleFrom(
  224. backgroundColor: Colors.lightBlue,
  225. padding: const EdgeInsets.symmetric(vertical: 16),
  226. ),
  227. onPressed: () {},
  228. child: const Text('开始服务',
  229. style: TextStyle(fontSize: 16, color: Colors.white)),
  230. ),
  231. ),
  232. ],
  233. ),
  234. );
  235. }
  236. }