| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- import 'package:electronic_assistant/base/base_page.dart';
- import 'package:electronic_assistant/resource/assets.gen.dart';
- import 'package:electronic_assistant/resource/colors.gen.dart';
- import 'package:electronic_assistant/utils/expand.dart';
- import 'package:electronic_assistant/utils/toast_util.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import '../../../data/bean/talks.dart';
- import '../../../resource/string.gen.dart';
- import 'controller.dart';
- class FileSearchPage extends BasePage<FileSearchController> {
- const FileSearchPage({super.key});
- @override
- bool immersive() {
- return true;
- }
- Widget _buildFileItem(BuildContext context, int index) {
- return Obx(() {
- TalkBean talkBean = controller.talkList[index];
- return Padding(
- padding: EdgeInsets.only(bottom: 8.w),
- child: GestureDetector(
- onTap: () {
- if (talkBean.status.value == TalkStatus.analysisSuccess) {
- Get.back(result: talkBean);
- } else {
- ToastUtil.showToast("谈话未分析,请选择其他文件");
- }
- },
- child: Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(8.w),
- ),
- padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 14.w),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Image(
- image: (talkBean.status.value == TalkStatus.analysing ||
- talkBean.status.value == TalkStatus.waitAnalysis)
- ? Assets.images.iconTalkAnalysis.provider()
- : Assets.images.iconFilesFile.provider(),
- width: 28.w,
- height: 32.w),
- Expanded(
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: 8.w),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(talkBean.title.value.orEmpty,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 14.sp,
- color: ColorName.primaryTextColor,
- fontWeight: FontWeight.bold)),
- Text(talkBean.summary.value.orEmpty,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12.sp,
- color: talkBean.status.value ==
- TalkStatus.analysisFail
- ? "#F5574E".toColor()
- : ColorName.secondaryTextColor)),
- Container(
- margin: EdgeInsets.only(top: 6.w),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(talkBean.duration.toFormattedDuration(),
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.tertiaryTextColor)),
- Text(" | ",
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.tertiaryTextColor,
- fontWeight: FontWeight.bold)),
- Text(talkBean.createTime.orEmpty,
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.tertiaryTextColor)),
- ],
- ),
- )
- ],
- ),
- )),
- ],
- ),
- ),
- ));
- });
- }
- @override
- Widget buildBody(BuildContext context) {
- return Scaffold(
- backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
- appBar: AppBar(
- title: Text(StringName.talkAll.tr),
- backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
- scrolledUnderElevation: 0,
- leading: IconButton(
- icon: const Icon(Icons.arrow_back_ios_new_rounded),
- onPressed: () {
- Get.back();
- },
- ),
- ),
- body: Column(
- children: [
- Expanded(
- child: Padding(
- padding: EdgeInsets.only(left: 12.w, right: 12.w),
- child: SmartRefresher(
- enablePullUp: true,
- enablePullDown: true,
- controller: controller.refreshController,
- onRefresh: controller.onRefreshData,
- onLoading: controller.onLoadMoreTalkData,
- child: CustomScrollView(
- slivers: [
- Obx(() {
- return SliverList.builder(
- itemBuilder: _buildFileItem,
- itemCount: controller.talkList.length);
- }),
- ],
- ),
- ),
- ))
- ],
- ),
- );
- // return Column(children: [
- // Row(
- // children: [
- // Expanded(
- // child: Padding(
- // padding: EdgeInsets.only(left: 12.w),
- // child: CupertinoSearchTextField(
- // placeholder: '搜索所有文件标题 / 内容',
- // prefixIcon:
- // ImageIcon(Assets.images.iconSearch.provider(), size: 20.w),
- // backgroundColor: const Color(0xFFF6F6F6),
- // style:
- // TextStyle(fontSize: 14.w, color: ColorName.primaryTextColor),
- // placeholderStyle:
- // TextStyle(fontSize: 14.w, color: const Color(0xFFAFAFAF)),
- // ),
- // )),
- // TextButton(
- // onPressed: () {
- // Get.back();
- // },
- // child: Text('取消',
- // style: TextStyle(
- // fontSize: 14.w, color: ColorName.secondaryTextColor))),
- // ],
- // ),
- // Padding(
- // padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
- // child: Row(children: [
- // Text(
- // "搜索结果",
- // style: TextStyle(
- // fontSize: 15.w,
- // color: ColorName.primaryTextColor,
- // fontWeight: FontWeight.bold),
- // ),
- // Expanded(
- // child: Row(
- // mainAxisAlignment: MainAxisAlignment.end,
- // children: [
- // Text("更新时间排序",
- // style: TextStyle(
- // fontSize: 14.w,
- // fontWeight: FontWeight.bold,
- // color: ColorName.primaryTextColor)),
- // Image(
- // image: Assets.images.iconArrowDown.provider(),
- // width: 16.w,
- // height: 16.w)
- // ],
- // ))
- // ]),
- // ),
- // Visibility(
- // visible: true,
- // child: Expanded(
- // child: Stack(
- // fit: StackFit.expand,
- // children: [
- // Padding(
- // padding: EdgeInsets.symmetric(horizontal: 12.w),
- // child: CustomScrollView(
- // slivers: [
- // SliverToBoxAdapter(
- // child: Text("文件夹",
- // style: TextStyle(
- // fontSize: 14.w,
- // color: ColorName.secondaryTextColor))),
- // SliverAnimatedList(
- // itemBuilder: _dirItemBuilder,
- // initialItemCount: 5,
- // ),
- // SliverToBoxAdapter(
- // child: Container(
- // margin: EdgeInsets.only(top: 8.w),
- // child: Text("谈话",
- // style: TextStyle(
- // fontSize: 14.w,
- // color: ColorName.secondaryTextColor)),
- // )),
- // SliverAnimatedList(
- // itemBuilder: _fileItemBuilder,
- // initialItemCount: 5,
- // ),
- // ],
- // ),
- // ),
- // Visibility(
- // visible: false,
- // child: Stack(
- // children: [
- // Container(
- // color: ColorName.black55,
- // ),
- // Container(
- // // color: ColorName.white,
- // width: double.infinity,
- // decoration: BoxDecoration(
- // color: ColorName.white,
- // borderRadius: BorderRadius.only(
- // bottomLeft: Radius.circular(16.w),
- // bottomRight: Radius.circular(16.w))),
- // child: Padding(
- // padding:
- // EdgeInsets.symmetric(horizontal: 12.w, vertical: 12
- // .w),
- // child: IntrinsicHeight(
- // child: Column(
- // children: [
- // Container(
- // margin: EdgeInsets.only(bottom: 22.w),
- // child: Row(
- // children: [
- // const Expanded(
- // child: Text('更新时间排序',
- // style: TextStyle(
- // fontSize: 14,
- // fontWeight: FontWeight.bold,
- // color: ColorName
- // .colorPrimary))),
- // ImageIcon(
- // Assets.images.iconFilesOrderSelected
- // .provider(),
- // size: 20.w,
- // color: ColorName.colorPrimary)
- // ],
- // ),
- // ),
- // Container(
- // margin: EdgeInsets.only(bottom: 6.w),
- // child: Row(
- // children: [
- // const Expanded(
- // child: Text('创建时间排序')),
- // ImageIcon(
- // Assets.images.iconFilesOrderSelected
- // .provider(),
- // size: 20.w)
- // ],
- // ),
- // )
- // ],
- // ),
- // ),
- // ),
- // )
- // ],
- // ),
- // )
- // ],
- // )),
- // )
- // ]);
- }
- Widget _dirItemBuilder(
- BuildContext context, int index, Animation<double> animation) {
- return Padding(
- padding: EdgeInsets.symmetric(vertical: 12.w),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Image(
- image: Assets.images.iconFilesDir.provider(),
- width: 32.w,
- height: 32.w,
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 8.w),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('文件夹 $index',
- maxLines: 1,
- style: TextStyle(
- fontSize: 15.w,
- color: ColorName.primaryTextColor,
- fontWeight: FontWeight.bold,
- overflow: TextOverflow.ellipsis)),
- Text('日期 $index',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12.w,
- color: ColorName.secondaryTextColor,
- overflow: TextOverflow.ellipsis)),
- ],
- ),
- ),
- )
- ],
- ),
- );
- }
- Widget _fileItemBuilder(
- BuildContext context, int index, Animation<double> animation) {
- return Padding(
- padding: EdgeInsets.symmetric(vertical: 12.w),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Image(
- image: Assets.images.iconFilesFile.provider(),
- width: 32.w,
- height: 32.w,
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 8.w),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('文件夹 $index',
- maxLines: 1,
- style: TextStyle(
- fontSize: 15.w,
- color: ColorName.primaryTextColor,
- fontWeight: FontWeight.bold,
- overflow: TextOverflow.ellipsis)),
- Text('缩略 $index',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12.w,
- color: ColorName.secondaryTextColor,
- overflow: TextOverflow.ellipsis)),
- Container(
- margin: EdgeInsets.only(top: 6.w),
- child: Row(
- children: [
- Text('1m12s',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12.w,
- color: ColorName.tertiaryTextColor)),
- Text(' | ',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12.w,
- color: ColorName.tertiaryTextColor)),
- Text('2024-04-15 10:04',
- maxLines: 1,
- style: TextStyle(
- fontSize: 12.w,
- color: ColorName.tertiaryTextColor)),
- ],
- ),
- )
- ],
- ),
- ),
- )
- ],
- ),
- );
- }
- }
|