7 changed files with 323 additions and 92 deletions
@ -1,74 +1,218 @@ |
|||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
class FiltrateDrawer extends StatelessWidget { |
import '../../controllers/meeting_controller.dart'; |
||||
const FiltrateDrawer({super.key}); |
|
||||
|
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 |
@override |
||||
Widget build(BuildContext context) { |
Widget build(BuildContext context) { |
||||
return SafeArea( |
return SafeArea( |
||||
child: Column( |
child: Padding( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
padding: EdgeInsets.symmetric(horizontal: 12.w), |
||||
children: [ |
child: Column( |
||||
Padding( |
crossAxisAlignment: CrossAxisAlignment.start, |
||||
padding: EdgeInsets.all(20.w), |
children: [ |
||||
child: TextField( |
Container( |
||||
decoration: InputDecoration( |
padding: EdgeInsets.symmetric(horizontal: 10.w), |
||||
hintText: '在所有文件中搜索', |
margin: EdgeInsets.symmetric(vertical: 15.w), |
||||
prefixIcon: Icon(Icons.search), |
alignment: Alignment.center, |
||||
border: OutlineInputBorder( |
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(12.w), |
color: Colors.grey[200], |
||||
borderSide: BorderSide.none, |
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, |
|
||||
), |
), |
||||
), |
), |
||||
), |
Padding( |
||||
ListTile( |
padding: EdgeInsetsGeometry.symmetric(vertical: 15.w), |
||||
leading: Icon(Icons.folder, color: Colors.red), |
child: Divider( |
||||
title: |
height: 1, |
||||
Text('全部文件(4)', style: TextStyle(fontWeight: FontWeight.bold)), |
color: Colors.grey[300], |
||||
onTap: () {}, |
), |
||||
), |
), |
||||
ListTile( |
Padding( |
||||
leading: Icon(Icons.category, color: Colors.blue), |
padding: EdgeInsets.only(bottom: 10.w), |
||||
title: Text('未分类(4)'), |
child: Text( |
||||
onTap: () {}, |
'来自', |
||||
), |
style: TextStyle( |
||||
ListTile( |
color: Colors.grey, |
||||
leading: Icon(Icons.delete, color: Colors.teal), |
fontSize: 14.sp, |
||||
title: Text('回收站'), |
fontWeight: FontWeight.bold, |
||||
onTap: () {}, |
), |
||||
), |
), |
||||
Divider(), |
), |
||||
Padding( |
...['IMPORT', 'TRANSLAT', 'LOCAL'].map( |
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.w), |
(name) => GestureDetector( |
||||
child: Text('文件夹', style: TextStyle(color: Colors.grey)), |
onTap: () { |
||||
), |
_filtrateDataList(name); |
||||
...['NOTE', 'CALL', 'NotePin', 'Import', 'Desktop'] |
}, |
||||
.map((name) => ListTile( |
behavior: HitTestBehavior.translucent, |
||||
title: Text(name), |
child: Container( |
||||
onTap: () {}, |
width: double.infinity, |
||||
)), |
padding: |
||||
Divider(), |
EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.w), |
||||
Padding( |
margin: EdgeInsets.symmetric(vertical: 2.w), |
||||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.w), |
decoration: _controller.filtrateType.value == name |
||||
child: Text('排序方式', style: TextStyle(color: Colors.grey)), |
? BoxDecoration( |
||||
), |
color: Colors.white, |
||||
ListTile( |
borderRadius: BorderRadius.circular(12.w), |
||||
title: Text('创建时间'), |
boxShadow: [ |
||||
trailing: Icon(Icons.arrow_upward), |
BoxShadow( |
||||
onTap: () {}, |
color: Colors.black.withOpacity(0.06), |
||||
), |
blurRadius: 10, |
||||
ListTile( |
offset: const Offset(0, 2), |
||||
title: Text('修改时间'), |
), |
||||
trailing: Icon(Icons.arrow_upward), |
], |
||||
onTap: () {}, |
) |
||||
), |
: 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