view.dart 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/data/bean/talks.dart';
  3. import 'package:electronic_assistant/dialog/alert_dialog.dart';
  4. import 'package:electronic_assistant/module/files/controller.dart';
  5. import 'package:electronic_assistant/module/talk/view.dart';
  6. import 'package:electronic_assistant/resource/colors.gen.dart';
  7. import 'package:electronic_assistant/resource/string.gen.dart';
  8. import 'package:electronic_assistant/router/app_pages.dart';
  9. import 'package:electronic_assistant/utils/expand.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter_screenutil/flutter_screenutil.dart';
  12. import 'package:get/get.dart';
  13. import 'package:pull_to_refresh/pull_to_refresh.dart';
  14. import '../../resource/assets.gen.dart';
  15. class FilesPage extends BasePage<FilesController> {
  16. const FilesPage({super.key});
  17. @override
  18. bool immersive() {
  19. return true;
  20. }
  21. @override
  22. Widget buildBody(BuildContext context) {
  23. return Scaffold(
  24. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  25. appBar: AppBar(
  26. title: Text(StringName.talkAll.tr),
  27. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  28. scrolledUnderElevation: 0,
  29. // actions: [
  30. // IconButton(
  31. // onPressed: () {},
  32. // icon: ImageIcon(Assets.images.iconFilesNewDir.provider()),
  33. // ),
  34. // IconButton(
  35. // onPressed: () {},
  36. // icon: ImageIcon(Assets.images.iconMore.provider()),
  37. // ),
  38. // ],
  39. ),
  40. body: Column(
  41. children: [
  42. // Column(
  43. // children: [
  44. // GestureDetector(
  45. // onTap: () {
  46. // Get.toNamed(RoutePath.fileSearch);
  47. // },
  48. // child: Container(
  49. // margin: EdgeInsets.symmetric(horizontal: 12.w),
  50. // padding:
  51. // EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
  52. // height: 36.w,
  53. // decoration: BoxDecoration(
  54. // color: Colors.white,
  55. // borderRadius: BorderRadius.circular(8.w),
  56. // ),
  57. // child: TextField(
  58. // maxLines: 1,
  59. // textAlignVertical: TextAlignVertical.center,
  60. // textInputAction: TextInputAction.search,
  61. // decoration: InputDecoration(
  62. // hintText: '搜索所有文件标题 / 内容',
  63. // border: InputBorder.none,
  64. // icon: ImageIcon(Assets.images.iconSearch.provider()),
  65. // iconColor: const Color.fromRGBO(95, 95, 97, 1),
  66. // enabled: false),
  67. // style: TextStyle(fontSize: 14.sp),
  68. // ),
  69. // ),
  70. // ),
  71. // ],
  72. // ),
  73. Expanded(
  74. child: Padding(
  75. // padding: EdgeInsets.only(top: 16.w, left: 12.w, right: 12.w),
  76. padding: EdgeInsets.only(left: 12.w, right: 12.w),
  77. child: SmartRefresher(
  78. enablePullUp: true,
  79. enablePullDown: true,
  80. controller: controller.refreshController,
  81. onRefresh: controller.onRefreshData,
  82. onLoading: controller.onLoadMoreTalkData,
  83. child: CustomScrollView(
  84. slivers: [
  85. // SliverAnimatedGrid(
  86. // itemBuilder: _buildDirItem,
  87. // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  88. // crossAxisCount: 2,
  89. // crossAxisSpacing: 8.w,
  90. // mainAxisSpacing: 8.w,
  91. // childAspectRatio: 164 / 65,
  92. // ),
  93. // initialItemCount: 10,
  94. // ),
  95. // SliverToBoxAdapter(
  96. // child: Padding(
  97. // padding: EdgeInsets.only(top: 20.w, bottom: 12.w),
  98. // child: Text(StringName.talkAll.tr,
  99. // style: TextStyle(
  100. // fontSize: 14.sp,
  101. // color: ColorName.secondaryTextColor,
  102. // fontWeight: FontWeight.bold))),
  103. // ),
  104. Obx(() {
  105. return SliverList.builder(
  106. itemBuilder: _buildFileItem,
  107. itemCount: controller.talkList.length);
  108. }),
  109. ],
  110. ),
  111. ),
  112. ))
  113. ],
  114. ),
  115. );
  116. }
  117. Widget _buildDirItem(
  118. BuildContext context, int index, Animation<double> animation) {
  119. return Container(
  120. decoration: BoxDecoration(
  121. color: Colors.white,
  122. borderRadius: BorderRadius.circular(8.w),
  123. ),
  124. padding: EdgeInsets.only(left: 8.w),
  125. child: Row(
  126. crossAxisAlignment: CrossAxisAlignment.center,
  127. children: [
  128. Image(
  129. image: Assets.images.iconFilesDir.provider(),
  130. width: 32.w,
  131. height: 32.w),
  132. Expanded(
  133. child: Padding(
  134. padding: EdgeInsets.symmetric(horizontal: 8.w),
  135. child: Column(
  136. mainAxisAlignment: MainAxisAlignment.center,
  137. crossAxisAlignment: CrossAxisAlignment.start,
  138. children: [
  139. Text('文件夹',
  140. maxLines: 1,
  141. overflow: TextOverflow.ellipsis,
  142. style: TextStyle(
  143. fontSize: 14.sp,
  144. color: ColorName.primaryTextColor,
  145. fontWeight: FontWeight.bold)),
  146. Text('2021-09-09 12:00:00',
  147. maxLines: 1,
  148. overflow: TextOverflow.ellipsis,
  149. style: TextStyle(
  150. fontSize: 12.sp, color: ColorName.secondaryTextColor)),
  151. ],
  152. ),
  153. ))
  154. ],
  155. ),
  156. );
  157. }
  158. Widget _buildFileItem(BuildContext context, int index) {
  159. TalkBean talkBean = controller.talkList[index];
  160. return Obx(() {
  161. return Padding(
  162. padding: EdgeInsets.only(bottom: 8.w),
  163. child: GestureDetector(
  164. onTap: () {
  165. TalkPage.start(talkBean);
  166. },
  167. child: Container(
  168. decoration: BoxDecoration(
  169. color: Colors.white,
  170. borderRadius: BorderRadius.circular(8.w),
  171. ),
  172. padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 14.w),
  173. child: Row(
  174. crossAxisAlignment: CrossAxisAlignment.start,
  175. children: [
  176. Image(
  177. image: (talkBean.status.value == TalkStatus.analysing ||
  178. talkBean.status.value == TalkStatus.waitAnalysis)
  179. ? Assets.images.iconTalkAnalysis.provider()
  180. : Assets.images.iconFilesFile.provider(),
  181. width: 28.w,
  182. height: 32.w),
  183. Expanded(
  184. child: Padding(
  185. padding: EdgeInsets.symmetric(horizontal: 8.w),
  186. child: Column(
  187. crossAxisAlignment: CrossAxisAlignment.start,
  188. children: [
  189. Text(talkBean.title.value.orEmpty,
  190. maxLines: 1,
  191. overflow: TextOverflow.ellipsis,
  192. style: TextStyle(
  193. fontSize: 14.sp,
  194. color: ColorName.primaryTextColor,
  195. fontWeight: FontWeight.bold)),
  196. Text(talkBean.summary.value.orEmpty,
  197. maxLines: 2,
  198. overflow: TextOverflow.ellipsis,
  199. style: TextStyle(
  200. fontSize: 12.sp,
  201. color: talkBean.status.value ==
  202. TalkStatus.analysisFail
  203. ? "#F5574E".toColor()
  204. : ColorName.secondaryTextColor)),
  205. Container(
  206. margin: EdgeInsets.only(top: 6.w),
  207. child: Row(
  208. crossAxisAlignment: CrossAxisAlignment.center,
  209. children: [
  210. Text(talkBean.duration.toFormattedDuration(),
  211. style: TextStyle(
  212. fontSize: 12.sp,
  213. color: ColorName.tertiaryTextColor)),
  214. Text(" | ",
  215. style: TextStyle(
  216. fontSize: 12.sp,
  217. color: ColorName.tertiaryTextColor,
  218. fontWeight: FontWeight.bold)),
  219. Text(talkBean.createTime.orEmpty,
  220. style: TextStyle(
  221. fontSize: 12.sp,
  222. color: ColorName.tertiaryTextColor)),
  223. ],
  224. ),
  225. )
  226. ],
  227. ),
  228. )),
  229. ],
  230. ),
  231. ),
  232. ));
  233. });
  234. }
  235. }