view.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/resource/assets.gen.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/utils/expand.dart';
  5. import 'package:electronic_assistant/utils/toast_util.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:get/get.dart';
  9. import 'package:pull_to_refresh/pull_to_refresh.dart';
  10. import '../../../data/bean/talks.dart';
  11. import '../../../resource/string.gen.dart';
  12. import 'controller.dart';
  13. class FileSearchPage extends BasePage<FileSearchController> {
  14. const FileSearchPage({super.key});
  15. @override
  16. bool immersive() {
  17. return true;
  18. }
  19. Widget _buildFileItem(BuildContext context, int index) {
  20. return Obx(() {
  21. TalkBean talkBean = controller.talkList[index];
  22. return Padding(
  23. padding: EdgeInsets.only(bottom: 8.w),
  24. child: GestureDetector(
  25. onTap: () {
  26. if (talkBean.status == TalkStatus.analysisSuccess) {
  27. Get.back(result: talkBean);
  28. } else {
  29. ToastUtil.showToast("谈话未分析,请选择其他文件");
  30. }
  31. },
  32. child: Container(
  33. decoration: BoxDecoration(
  34. color: Colors.white,
  35. borderRadius: BorderRadius.circular(8.w),
  36. ),
  37. padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 14.w),
  38. child: Row(
  39. crossAxisAlignment: CrossAxisAlignment.start,
  40. children: [
  41. Image(
  42. image: (talkBean.status == TalkStatus.analysing ||
  43. talkBean.status == TalkStatus.waitAnalysis)
  44. ? Assets.images.iconTalkAnalysis.provider()
  45. : Assets.images.iconFilesFile.provider(),
  46. width: 28.w,
  47. height: 32.w),
  48. Expanded(
  49. child: Padding(
  50. padding: EdgeInsets.symmetric(horizontal: 8.w),
  51. child: Column(
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. children: [
  54. Text(talkBean.title.value.orEmpty,
  55. maxLines: 1,
  56. overflow: TextOverflow.ellipsis,
  57. style: TextStyle(
  58. fontSize: 14.sp,
  59. color: ColorName.primaryTextColor,
  60. fontWeight: FontWeight.bold)),
  61. Text(talkBean.summary.value.orEmpty,
  62. maxLines: 2,
  63. overflow: TextOverflow.ellipsis,
  64. style: TextStyle(
  65. fontSize: 12.sp,
  66. color:
  67. talkBean.status == TalkStatus.analysisFail
  68. ? "#F5574E".toColor()
  69. : ColorName.secondaryTextColor)),
  70. Container(
  71. margin: EdgeInsets.only(top: 6.w),
  72. child: Row(
  73. crossAxisAlignment: CrossAxisAlignment.center,
  74. children: [
  75. Text(talkBean.duration.toFormattedDuration(),
  76. style: TextStyle(
  77. fontSize: 12.sp,
  78. color: ColorName.tertiaryTextColor)),
  79. Text(" | ",
  80. style: TextStyle(
  81. fontSize: 12.sp,
  82. color: ColorName.tertiaryTextColor,
  83. fontWeight: FontWeight.bold)),
  84. Text(talkBean.createTime.orEmpty,
  85. style: TextStyle(
  86. fontSize: 12.sp,
  87. color: ColorName.tertiaryTextColor)),
  88. ],
  89. ),
  90. )
  91. ],
  92. ),
  93. )),
  94. ],
  95. ),
  96. ),
  97. ));
  98. });
  99. }
  100. @override
  101. Widget buildBody(BuildContext context) {
  102. return Scaffold(
  103. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  104. appBar: AppBar(
  105. title: Text(StringName.talkAll.tr),
  106. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  107. scrolledUnderElevation: 0,
  108. leading: IconButton(
  109. icon: const Icon(Icons.arrow_back_ios_new_rounded),
  110. onPressed: () {
  111. Get.back();
  112. },
  113. ),
  114. ),
  115. body: Column(
  116. children: [
  117. Expanded(
  118. child: Padding(
  119. padding: EdgeInsets.only(left: 12.w, right: 12.w),
  120. child: SmartRefresher(
  121. enablePullUp: true,
  122. enablePullDown: true,
  123. controller: controller.refreshController,
  124. onRefresh: controller.onRefreshData,
  125. onLoading: controller.onLoadMoreTalkData,
  126. child: CustomScrollView(
  127. slivers: [
  128. Obx(() {
  129. return SliverList.builder(
  130. itemBuilder: _buildFileItem,
  131. itemCount: controller.talkList.length);
  132. }),
  133. ],
  134. ),
  135. ),
  136. ))
  137. ],
  138. ),
  139. );
  140. // return Column(children: [
  141. // Row(
  142. // children: [
  143. // Expanded(
  144. // child: Padding(
  145. // padding: EdgeInsets.only(left: 12.w),
  146. // child: CupertinoSearchTextField(
  147. // placeholder: '搜索所有文件标题 / 内容',
  148. // prefixIcon:
  149. // ImageIcon(Assets.images.iconSearch.provider(), size: 20.w),
  150. // backgroundColor: const Color(0xFFF6F6F6),
  151. // style:
  152. // TextStyle(fontSize: 14.w, color: ColorName.primaryTextColor),
  153. // placeholderStyle:
  154. // TextStyle(fontSize: 14.w, color: const Color(0xFFAFAFAF)),
  155. // ),
  156. // )),
  157. // TextButton(
  158. // onPressed: () {
  159. // Get.back();
  160. // },
  161. // child: Text('取消',
  162. // style: TextStyle(
  163. // fontSize: 14.w, color: ColorName.secondaryTextColor))),
  164. // ],
  165. // ),
  166. // Padding(
  167. // padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
  168. // child: Row(children: [
  169. // Text(
  170. // "搜索结果",
  171. // style: TextStyle(
  172. // fontSize: 15.w,
  173. // color: ColorName.primaryTextColor,
  174. // fontWeight: FontWeight.bold),
  175. // ),
  176. // Expanded(
  177. // child: Row(
  178. // mainAxisAlignment: MainAxisAlignment.end,
  179. // children: [
  180. // Text("更新时间排序",
  181. // style: TextStyle(
  182. // fontSize: 14.w,
  183. // fontWeight: FontWeight.bold,
  184. // color: ColorName.primaryTextColor)),
  185. // Image(
  186. // image: Assets.images.iconArrowDown.provider(),
  187. // width: 16.w,
  188. // height: 16.w)
  189. // ],
  190. // ))
  191. // ]),
  192. // ),
  193. // Visibility(
  194. // visible: true,
  195. // child: Expanded(
  196. // child: Stack(
  197. // fit: StackFit.expand,
  198. // children: [
  199. // Padding(
  200. // padding: EdgeInsets.symmetric(horizontal: 12.w),
  201. // child: CustomScrollView(
  202. // slivers: [
  203. // SliverToBoxAdapter(
  204. // child: Text("文件夹",
  205. // style: TextStyle(
  206. // fontSize: 14.w,
  207. // color: ColorName.secondaryTextColor))),
  208. // SliverAnimatedList(
  209. // itemBuilder: _dirItemBuilder,
  210. // initialItemCount: 5,
  211. // ),
  212. // SliverToBoxAdapter(
  213. // child: Container(
  214. // margin: EdgeInsets.only(top: 8.w),
  215. // child: Text("谈话",
  216. // style: TextStyle(
  217. // fontSize: 14.w,
  218. // color: ColorName.secondaryTextColor)),
  219. // )),
  220. // SliverAnimatedList(
  221. // itemBuilder: _fileItemBuilder,
  222. // initialItemCount: 5,
  223. // ),
  224. // ],
  225. // ),
  226. // ),
  227. // Visibility(
  228. // visible: false,
  229. // child: Stack(
  230. // children: [
  231. // Container(
  232. // color: ColorName.black55,
  233. // ),
  234. // Container(
  235. // // color: ColorName.white,
  236. // width: double.infinity,
  237. // decoration: BoxDecoration(
  238. // color: ColorName.white,
  239. // borderRadius: BorderRadius.only(
  240. // bottomLeft: Radius.circular(16.w),
  241. // bottomRight: Radius.circular(16.w))),
  242. // child: Padding(
  243. // padding:
  244. // EdgeInsets.symmetric(horizontal: 12.w, vertical: 12
  245. // .w),
  246. // child: IntrinsicHeight(
  247. // child: Column(
  248. // children: [
  249. // Container(
  250. // margin: EdgeInsets.only(bottom: 22.w),
  251. // child: Row(
  252. // children: [
  253. // const Expanded(
  254. // child: Text('更新时间排序',
  255. // style: TextStyle(
  256. // fontSize: 14,
  257. // fontWeight: FontWeight.bold,
  258. // color: ColorName
  259. // .colorPrimary))),
  260. // ImageIcon(
  261. // Assets.images.iconFilesOrderSelected
  262. // .provider(),
  263. // size: 20.w,
  264. // color: ColorName.colorPrimary)
  265. // ],
  266. // ),
  267. // ),
  268. // Container(
  269. // margin: EdgeInsets.only(bottom: 6.w),
  270. // child: Row(
  271. // children: [
  272. // const Expanded(
  273. // child: Text('创建时间排序')),
  274. // ImageIcon(
  275. // Assets.images.iconFilesOrderSelected
  276. // .provider(),
  277. // size: 20.w)
  278. // ],
  279. // ),
  280. // )
  281. // ],
  282. // ),
  283. // ),
  284. // ),
  285. // )
  286. // ],
  287. // ),
  288. // )
  289. // ],
  290. // )),
  291. // )
  292. // ]);
  293. }
  294. Widget _dirItemBuilder(
  295. BuildContext context, int index, Animation<double> animation) {
  296. return Padding(
  297. padding: EdgeInsets.symmetric(vertical: 12.w),
  298. child: Row(
  299. crossAxisAlignment: CrossAxisAlignment.center,
  300. children: [
  301. Image(
  302. image: Assets.images.iconFilesDir.provider(),
  303. width: 32.w,
  304. height: 32.w,
  305. ),
  306. Expanded(
  307. child: Container(
  308. margin: EdgeInsets.only(left: 8.w),
  309. child: Column(
  310. mainAxisAlignment: MainAxisAlignment.center,
  311. crossAxisAlignment: CrossAxisAlignment.start,
  312. children: [
  313. Text('文件夹 $index',
  314. maxLines: 1,
  315. style: TextStyle(
  316. fontSize: 15.w,
  317. color: ColorName.primaryTextColor,
  318. fontWeight: FontWeight.bold,
  319. overflow: TextOverflow.ellipsis)),
  320. Text('日期 $index',
  321. maxLines: 1,
  322. style: TextStyle(
  323. fontSize: 12.w,
  324. color: ColorName.secondaryTextColor,
  325. overflow: TextOverflow.ellipsis)),
  326. ],
  327. ),
  328. ),
  329. )
  330. ],
  331. ),
  332. );
  333. }
  334. Widget _fileItemBuilder(
  335. BuildContext context, int index, Animation<double> animation) {
  336. return Padding(
  337. padding: EdgeInsets.symmetric(vertical: 12.w),
  338. child: Row(
  339. crossAxisAlignment: CrossAxisAlignment.start,
  340. children: [
  341. Image(
  342. image: Assets.images.iconFilesFile.provider(),
  343. width: 32.w,
  344. height: 32.w,
  345. ),
  346. Expanded(
  347. child: Container(
  348. margin: EdgeInsets.only(left: 8.w),
  349. child: Column(
  350. mainAxisAlignment: MainAxisAlignment.center,
  351. crossAxisAlignment: CrossAxisAlignment.start,
  352. children: [
  353. Text('文件夹 $index',
  354. maxLines: 1,
  355. style: TextStyle(
  356. fontSize: 15.w,
  357. color: ColorName.primaryTextColor,
  358. fontWeight: FontWeight.bold,
  359. overflow: TextOverflow.ellipsis)),
  360. Text('缩略 $index',
  361. maxLines: 1,
  362. style: TextStyle(
  363. fontSize: 12.w,
  364. color: ColorName.secondaryTextColor,
  365. overflow: TextOverflow.ellipsis)),
  366. Container(
  367. margin: EdgeInsets.only(top: 6.w),
  368. child: Row(
  369. children: [
  370. Text('1m12s',
  371. maxLines: 1,
  372. style: TextStyle(
  373. fontSize: 12.w,
  374. color: ColorName.tertiaryTextColor)),
  375. Text(' | ',
  376. maxLines: 1,
  377. style: TextStyle(
  378. fontSize: 12.w,
  379. color: ColorName.tertiaryTextColor)),
  380. Text('2024-04-15 10:04',
  381. maxLines: 1,
  382. style: TextStyle(
  383. fontSize: 12.w,
  384. color: ColorName.tertiaryTextColor)),
  385. ],
  386. ),
  387. )
  388. ],
  389. ),
  390. ),
  391. )
  392. ],
  393. ),
  394. );
  395. }
  396. }