初始化
This commit is contained in:
95
lib/widgets/room/file_drawer.dart
Normal file
95
lib/widgets/room/file_drawer.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import 'package:app/config/theme/base/app_theme_ext.dart';
|
||||
import 'package:app/widgets/base/button/index.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../common/preview/file_previewer.dart';
|
||||
|
||||
///快捷打开文件弹窗
|
||||
void showFileDialog(
|
||||
BuildContext context, {
|
||||
bool isUpload = true,
|
||||
}) {
|
||||
showGeneralDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
// 点击外部关闭
|
||||
barrierLabel: "RightSheet",
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
return FileDrawer(
|
||||
isUpload: isUpload,
|
||||
);
|
||||
},
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
final tween = Tween<Offset>(begin: Offset(1, 0), end: Offset(0, 0));
|
||||
return SlideTransition(
|
||||
position: tween.animate(animation),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
///文件弹窗
|
||||
class FileDrawer extends StatefulWidget {
|
||||
final bool isUpload;
|
||||
|
||||
const FileDrawer({super.key, this.isUpload = true});
|
||||
|
||||
@override
|
||||
State<FileDrawer> createState() => _FileDrawerState();
|
||||
}
|
||||
|
||||
class _FileDrawerState extends State<FileDrawer> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
width: 300,
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.all(context.pagePadding),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'上传文件列表',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 15),
|
||||
itemBuilder: (_, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
showFilePreviewer(
|
||||
context,
|
||||
url: "https://doaf.asia/api/assets/1/图/65252305_p0.jpg",
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text("文件1.png", style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) => SizedBox(height: 15),
|
||||
itemCount: 15,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.isUpload,
|
||||
child: Button(
|
||||
text: "上传",
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user