view.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/module/chat/controller.dart';
  3. import 'package:electronic_assistant/module/chat/start/view.dart';
  4. import 'package:electronic_assistant/resource/colors.gen.dart';
  5. import 'package:electronic_assistant/utils/expand.dart';
  6. import 'package:flutter/cupertino.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:flutter/services.dart';
  9. import 'package:flutter_screenutil/flutter_screenutil.dart';
  10. import '../../resource/assets.gen.dart';
  11. class ChatPage extends BasePage<ChatController> {
  12. const ChatPage({super.key});
  13. @override
  14. bool immersive() {
  15. return true;
  16. }
  17. @override
  18. Widget buildBody(BuildContext context) {
  19. var controller = this.controller;
  20. // 第一次启动时弹出定制窗口
  21. controller.showStartSheet(context);
  22. return Stack(
  23. children: [
  24. buildBackgroundGradient(),
  25. buildTopGradient(),
  26. Scaffold(
  27. backgroundColor: Colors.transparent,
  28. appBar: AppBar(
  29. leading: IconButton(
  30. icon: const Icon(Icons.arrow_back_ios),
  31. onPressed: () {
  32. Navigator.pop(context);
  33. },
  34. ),
  35. scrolledUnderElevation: 0,
  36. backgroundColor: Colors.transparent,
  37. systemOverlayStyle: SystemUiOverlayStyle.dark,
  38. centerTitle: true,
  39. title: IntrinsicWidth(
  40. child: Row(
  41. mainAxisAlignment: MainAxisAlignment.center,
  42. children: [
  43. Image(
  44. image: Assets.images.iconChatXiaoTin.provider(),
  45. width: 28.w,
  46. height: 28.w),
  47. Container(
  48. margin: EdgeInsets.only(left: 6.w),
  49. child: Text('聊天',
  50. style: TextStyle(
  51. fontSize: 16.w,
  52. fontWeight: FontWeight.bold,
  53. color: ColorName.primaryTextColor))),
  54. ],
  55. ),
  56. ),
  57. ),
  58. body: buildBodyContent(),
  59. )
  60. ],
  61. );
  62. }
  63. Widget buildBodyContent() {
  64. return Column(
  65. children: [
  66. Expanded(
  67. child: Padding(
  68. padding: EdgeInsets.symmetric(horizontal: 12.w),
  69. child: AnimatedList(
  70. itemBuilder: _chatItemBuilder,
  71. initialItemCount: 20,
  72. ),
  73. )),
  74. Container(
  75. margin: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.h),
  76. width: 1.sw,
  77. decoration: BoxDecoration(
  78. color: Colors.white,
  79. borderRadius: BorderRadius.circular(24.w),
  80. boxShadow: const [
  81. BoxShadow(
  82. color: Color(0x4CDDDEE8),
  83. blurRadius: 10,
  84. offset: Offset(0, 4),
  85. spreadRadius: 0,
  86. )
  87. ]),
  88. child: Padding(
  89. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
  90. child: Column(
  91. children: [
  92. Row(
  93. crossAxisAlignment: CrossAxisAlignment.end,
  94. children: [
  95. Expanded(
  96. child: Container(
  97. margin: EdgeInsets.only(right: 6.w),
  98. child: CupertinoTextField(
  99. padding: EdgeInsets.symmetric(vertical: 3.w),
  100. style: TextStyle(
  101. fontSize: 14.w, color: ColorName.primaryTextColor),
  102. placeholder: '有问题尽管问我~',
  103. placeholderStyle: TextStyle(
  104. fontSize: 14.w, color: const Color(0xFFAFAFAF)),
  105. textCapitalization: TextCapitalization.sentences,
  106. textInputAction: TextInputAction.newline,
  107. cursorColor: ColorName.colorPrimary,
  108. decoration: const BoxDecoration(),
  109. expands: true,
  110. maxLines: null,
  111. minLines: null,
  112. ),
  113. )),
  114. Image(
  115. image: Assets.images.iconChatAddFile.provider(),
  116. width: 26.w,
  117. height: 26.w),
  118. Container(
  119. margin: EdgeInsets.only(left: 16.w),
  120. child: Image(
  121. image: Assets.images.iconChatSend.provider(),
  122. width: 26.w,
  123. height: 26.w),
  124. )
  125. ],
  126. )
  127. ],
  128. ),
  129. ),
  130. ),
  131. ],
  132. );
  133. }
  134. Widget _chatItemBuilder(
  135. BuildContext context, int index, Animation<double> animation) {
  136. return Text('聊天内容 $index');
  137. }
  138. Widget buildTopGradient() {
  139. return Container(
  140. width: 1.sw,
  141. height: 128.h,
  142. decoration: BoxDecoration(
  143. gradient: LinearGradient(
  144. colors: ['#E8EBFF'.toColor(), '#00E8EBFF'.toColor()],
  145. begin: Alignment.topCenter,
  146. end: Alignment.bottomCenter,
  147. stops: const [0.5, 1.0],
  148. ),
  149. ));
  150. }
  151. Widget buildBackgroundGradient() {
  152. return Container(
  153. width: 1.sw,
  154. height: 1.sh,
  155. decoration: BoxDecoration(
  156. gradient: LinearGradient(
  157. colors: ['#F2F8F4'.toColor(), '#F6F6F6'.toColor()],
  158. begin: Alignment.topCenter,
  159. end: Alignment.bottomCenter,
  160. stops: const [0, 1.0],
  161. ),
  162. ),
  163. );
  164. }
  165. }