view.dart 9.6 KB

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