7 changed files with 323 additions and 92 deletions
@ -1,74 +1,218 @@ |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
import 'package:get/get.dart'; |
|||
|
|||
class FiltrateDrawer extends StatelessWidget { |
|||
const FiltrateDrawer({super.key}); |
|||
import '../../controllers/meeting_controller.dart'; |
|||
|
|||
class FiltrateDrawer extends StatefulWidget { |
|||
final GlobalKey<ScaffoldState> scaffoldKey; |
|||
|
|||
const FiltrateDrawer(this.scaffoldKey, {super.key}); |
|||
|
|||
@override |
|||
State<FiltrateDrawer> createState() => _FiltrateDrawerState(); |
|||
} |
|||
|
|||
class _FiltrateDrawerState extends State<FiltrateDrawer> { |
|||
final _controller = Get.find<MeetingController>(); |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
return SafeArea( |
|||
child: Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
children: [ |
|||
Padding( |
|||
padding: EdgeInsets.all(20.w), |
|||
child: TextField( |
|||
decoration: InputDecoration( |
|||
hintText: '在所有文件中搜索', |
|||
prefixIcon: Icon(Icons.search), |
|||
border: OutlineInputBorder( |
|||
borderRadius: BorderRadius.circular(12.w), |
|||
borderSide: BorderSide.none, |
|||
child: Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|||
child: Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
children: [ |
|||
Container( |
|||
padding: EdgeInsets.symmetric(horizontal: 10.w), |
|||
margin: EdgeInsets.symmetric(vertical: 15.w), |
|||
alignment: Alignment.center, |
|||
decoration: BoxDecoration( |
|||
color: Colors.grey[200], |
|||
borderRadius: BorderRadius.circular(12.w), |
|||
), |
|||
child: Row( |
|||
children: [ |
|||
Icon( |
|||
Icons.search, |
|||
color: Colors.black87, |
|||
size: 20.w, |
|||
), |
|||
Expanded( |
|||
child: TextField( |
|||
controller: _controller.titleController, |
|||
style: TextStyle( |
|||
color: Colors.black87, |
|||
fontSize: 14.sp, |
|||
), |
|||
decoration: InputDecoration( |
|||
hintText: '在所有文件中搜索', |
|||
hintStyle: TextStyle( |
|||
color: Colors.black54, |
|||
fontSize: 14.sp, |
|||
), |
|||
isDense: true, |
|||
fillColor: Colors.transparent, |
|||
border: InputBorder.none, |
|||
contentPadding: EdgeInsets.symmetric(vertical: 10.w), |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
GestureDetector( |
|||
onTap: () { |
|||
_filtrateDataList(''); |
|||
}, |
|||
behavior: HitTestBehavior.translucent, |
|||
child: Container( |
|||
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.w), |
|||
decoration: _controller.filtrateType.value == '' |
|||
? BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(12.w), |
|||
boxShadow: [ |
|||
BoxShadow( |
|||
color: Colors.black.withOpacity(0.06), |
|||
blurRadius: 10, |
|||
offset: const Offset(0, 2), |
|||
), |
|||
], |
|||
) |
|||
: null, |
|||
child: Row( |
|||
children: [ |
|||
Icon( |
|||
Icons.folder, |
|||
color: Colors.red, |
|||
size: 20.w, |
|||
), |
|||
6.horizontalSpace, |
|||
Text( |
|||
'全部文件(${_controller.originalDataList.length})', |
|||
style: TextStyle( |
|||
color: Colors.black87, |
|||
fontSize: 14.sp, |
|||
), |
|||
), |
|||
], |
|||
), |
|||
filled: true, |
|||
fillColor: Colors.grey[100], |
|||
contentPadding: EdgeInsets.zero, |
|||
), |
|||
), |
|||
), |
|||
ListTile( |
|||
leading: Icon(Icons.folder, color: Colors.red), |
|||
title: |
|||
Text('全部文件(4)', style: TextStyle(fontWeight: FontWeight.bold)), |
|||
onTap: () {}, |
|||
), |
|||
ListTile( |
|||
leading: Icon(Icons.category, color: Colors.blue), |
|||
title: Text('未分类(4)'), |
|||
onTap: () {}, |
|||
), |
|||
ListTile( |
|||
leading: Icon(Icons.delete, color: Colors.teal), |
|||
title: Text('回收站'), |
|||
onTap: () {}, |
|||
), |
|||
Divider(), |
|||
Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.w), |
|||
child: Text('文件夹', style: TextStyle(color: Colors.grey)), |
|||
), |
|||
...['NOTE', 'CALL', 'NotePin', 'Import', 'Desktop'] |
|||
.map((name) => ListTile( |
|||
title: Text(name), |
|||
onTap: () {}, |
|||
)), |
|||
Divider(), |
|||
Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.w), |
|||
child: Text('排序方式', style: TextStyle(color: Colors.grey)), |
|||
), |
|||
ListTile( |
|||
title: Text('创建时间'), |
|||
trailing: Icon(Icons.arrow_upward), |
|||
onTap: () {}, |
|||
), |
|||
ListTile( |
|||
title: Text('修改时间'), |
|||
trailing: Icon(Icons.arrow_upward), |
|||
onTap: () {}, |
|||
), |
|||
], |
|||
Padding( |
|||
padding: EdgeInsetsGeometry.symmetric(vertical: 15.w), |
|||
child: Divider( |
|||
height: 1, |
|||
color: Colors.grey[300], |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.only(bottom: 10.w), |
|||
child: Text( |
|||
'来自', |
|||
style: TextStyle( |
|||
color: Colors.grey, |
|||
fontSize: 14.sp, |
|||
fontWeight: FontWeight.bold, |
|||
), |
|||
), |
|||
), |
|||
...['IMPORT', 'TRANSLAT', 'LOCAL'].map( |
|||
(name) => GestureDetector( |
|||
onTap: () { |
|||
_filtrateDataList(name); |
|||
}, |
|||
behavior: HitTestBehavior.translucent, |
|||
child: Container( |
|||
width: double.infinity, |
|||
padding: |
|||
EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.w), |
|||
margin: EdgeInsets.symmetric(vertical: 2.w), |
|||
decoration: _controller.filtrateType.value == name |
|||
? BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(12.w), |
|||
boxShadow: [ |
|||
BoxShadow( |
|||
color: Colors.black.withOpacity(0.06), |
|||
blurRadius: 10, |
|||
offset: const Offset(0, 2), |
|||
), |
|||
], |
|||
) |
|||
: null, |
|||
child: Text( |
|||
name, |
|||
style: TextStyle( |
|||
color: Colors.black87, |
|||
fontSize: 14.sp, |
|||
), |
|||
), |
|||
), |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.symmetric(vertical: 10.w), |
|||
child: Text( |
|||
'排序方式', |
|||
style: TextStyle( |
|||
color: Colors.grey, |
|||
fontSize: 14.sp, |
|||
fontWeight: FontWeight.bold, |
|||
), |
|||
), |
|||
), |
|||
GestureDetector( |
|||
onTap: () { |
|||
widget.scaffoldKey.currentState?.closeDrawer(); |
|||
_controller.isAsc = !_controller.isAsc; |
|||
_controller.dataList.value = |
|||
_controller.dataList.reversed.toList(); |
|||
}, |
|||
behavior: HitTestBehavior.translucent, |
|||
child: Container( |
|||
padding: EdgeInsets.symmetric(vertical: 10.w), |
|||
margin: EdgeInsets.symmetric(vertical: 2.w), |
|||
child: Row( |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children: [ |
|||
Text( |
|||
'创建时间', |
|||
style: TextStyle( |
|||
color: Colors.black87, |
|||
fontSize: 14.sp, |
|||
), |
|||
), |
|||
Icon( |
|||
_controller.isAsc |
|||
? Icons.keyboard_double_arrow_up |
|||
: Icons.keyboard_double_arrow_down, |
|||
color: Colors.grey, |
|||
size: 20.w, |
|||
), |
|||
], |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
); |
|||
} |
|||
|
|||
void _filtrateDataList(String type) { |
|||
widget.scaffoldKey.currentState?.closeDrawer(); |
|||
_controller.filtrateType.value = type; |
|||
if (type.isNotEmpty) { |
|||
_controller.dataList.value = |
|||
_controller.originalDataList.where((i) => i['type'] == type).toList(); |
|||
} else { |
|||
_controller.dataList.value = _controller.originalDataList; |
|||
} |
|||
if (_controller.isAsc) { |
|||
_controller.dataList.value = _controller.dataList.reversed.toList(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue