view.dart 5.5 KB

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