view.dart 7.6 KB

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