view.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/module/files/controller.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/router/app_pages.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter_screenutil/flutter_screenutil.dart';
  7. import 'package:get/get.dart';
  8. import 'package:get/get_core/src/get_main.dart';
  9. import '../../resource/assets.gen.dart';
  10. class FilesPage extends BasePage<FilesController> {
  11. const FilesPage({super.key});
  12. @override
  13. bool immersive() {
  14. return true;
  15. }
  16. @override
  17. Widget buildBody(BuildContext context) {
  18. return Scaffold(
  19. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  20. appBar: AppBar(
  21. title: const Text('文件夹'),
  22. backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
  23. scrolledUnderElevation: 0,
  24. actions: [
  25. IconButton(
  26. onPressed: () {},
  27. icon: ImageIcon(Assets.images.iconFilesNewDir.provider()),
  28. ),
  29. IconButton(
  30. onPressed: () {},
  31. icon: ImageIcon(Assets.images.iconMore.provider()),
  32. ),
  33. ],
  34. ),
  35. body: Column(
  36. children: [
  37. Column(
  38. children: [
  39. GestureDetector(
  40. onTap: () {
  41. Get.toNamed(RoutePath.fileSearch);
  42. },
  43. child: Container(
  44. margin: EdgeInsets.symmetric(horizontal: 12.w),
  45. padding:
  46. EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
  47. height: 36.w,
  48. decoration: BoxDecoration(
  49. color: Colors.white,
  50. borderRadius: BorderRadius.circular(8.w),
  51. ),
  52. child: TextField(
  53. maxLines: 1,
  54. textAlignVertical: TextAlignVertical.center,
  55. textInputAction: TextInputAction.search,
  56. decoration: InputDecoration(
  57. hintText: '搜索所有文件标题 / 内容',
  58. border: InputBorder.none,
  59. icon: ImageIcon(Assets.images.iconSearch.provider()),
  60. iconColor: const Color.fromRGBO(95, 95, 97, 1),
  61. enabled: false),
  62. style: TextStyle(fontSize: 14.sp),
  63. ),
  64. ),
  65. ),
  66. ],
  67. ),
  68. Expanded(
  69. child: Padding(
  70. padding: EdgeInsets.only(top: 16.w, left: 12.w, right: 12.w),
  71. child: CustomScrollView(
  72. slivers: [
  73. SliverAnimatedGrid(
  74. itemBuilder: _buildDirItem,
  75. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  76. crossAxisCount: 2,
  77. crossAxisSpacing: 8.w,
  78. mainAxisSpacing: 8.w,
  79. childAspectRatio: 164 / 65,
  80. ),
  81. initialItemCount: 10,
  82. ),
  83. SliverToBoxAdapter(
  84. child: Padding(
  85. padding: EdgeInsets.only(top: 20.w, bottom: 12.w),
  86. child: Text('全部谈话',
  87. style: TextStyle(
  88. fontSize: 14.sp,
  89. color: ColorName.secondaryTextColor,
  90. fontWeight: FontWeight.bold))),
  91. ),
  92. SliverAnimatedList(
  93. itemBuilder: _buildFileItem,
  94. initialItemCount: 20,
  95. )
  96. ],
  97. )))
  98. ],
  99. ),
  100. );
  101. }
  102. Widget _buildDirItem(
  103. BuildContext context, int index, Animation<double> animation) {
  104. return Container(
  105. decoration: BoxDecoration(
  106. color: Colors.white,
  107. borderRadius: BorderRadius.circular(8.w),
  108. ),
  109. padding: EdgeInsets.only(left: 8.w),
  110. child: Row(
  111. crossAxisAlignment: CrossAxisAlignment.center,
  112. children: [
  113. Image(
  114. image: Assets.images.iconFilesDir.provider(),
  115. width: 32.w,
  116. height: 32.w),
  117. Expanded(
  118. child: Padding(
  119. padding: EdgeInsets.symmetric(horizontal: 8.w),
  120. child: Column(
  121. mainAxisAlignment: MainAxisAlignment.center,
  122. crossAxisAlignment: CrossAxisAlignment.start,
  123. children: [
  124. Text('文件夹',
  125. maxLines: 1,
  126. overflow: TextOverflow.ellipsis,
  127. style: TextStyle(
  128. fontSize: 14.sp,
  129. color: ColorName.primaryTextColor,
  130. fontWeight: FontWeight.bold)),
  131. Text('2021-09-09 12:00:00',
  132. maxLines: 1,
  133. overflow: TextOverflow.ellipsis,
  134. style: TextStyle(
  135. fontSize: 12.sp, color: ColorName.secondaryTextColor)),
  136. ],
  137. ),
  138. ))
  139. ],
  140. ),
  141. );
  142. }
  143. Widget _buildFileItem(
  144. BuildContext context, int index, Animation<double> animation) {
  145. return Padding(
  146. padding: EdgeInsets.only(bottom: 8.w),
  147. child: Container(
  148. decoration: BoxDecoration(
  149. color: Colors.white,
  150. borderRadius: BorderRadius.circular(8.w),
  151. ),
  152. padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 14.w),
  153. child: Row(
  154. crossAxisAlignment: CrossAxisAlignment.start,
  155. children: [
  156. Image(
  157. image: Assets.images.iconFilesFile.provider(),
  158. width: 28.w,
  159. height: 32.w),
  160. Expanded(
  161. child: Padding(
  162. padding: EdgeInsets.symmetric(horizontal: 8.w),
  163. child: Column(
  164. crossAxisAlignment: CrossAxisAlignment.start,
  165. children: [
  166. Text('文件标题',
  167. maxLines: 1,
  168. overflow: TextOverflow.ellipsis,
  169. style: TextStyle(
  170. fontSize: 14.sp,
  171. color: ColorName.primaryTextColor,
  172. fontWeight: FontWeight.bold)),
  173. Text(
  174. '这个群,现在由我管理。目的是把你们训练成一个个社会高薪人士,从本周起,hhhhhhhhhhhhh已经开始执行军事化理...',
  175. maxLines: 2,
  176. overflow: TextOverflow.ellipsis,
  177. style: TextStyle(
  178. fontSize: 12.sp,
  179. color: ColorName.secondaryTextColor)),
  180. Container(
  181. margin: EdgeInsets.only(top: 6.w),
  182. child: Row(
  183. crossAxisAlignment: CrossAxisAlignment.center,
  184. children: [
  185. Text("1m12s",
  186. style: TextStyle(
  187. fontSize: 12.sp,
  188. color: ColorName.tertiaryTextColor)),
  189. Text(" | ",
  190. style: TextStyle(
  191. fontSize: 12.sp,
  192. color: ColorName.tertiaryTextColor,
  193. fontWeight: FontWeight.bold)),
  194. Text("2021-09-09 12:00:00",
  195. style: TextStyle(
  196. fontSize: 12.sp,
  197. color: ColorName.tertiaryTextColor)),
  198. ],
  199. ),
  200. )
  201. ],
  202. ),
  203. )),
  204. ],
  205. ),
  206. ));
  207. }
  208. }