widgetItem.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'dart:io';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. class WidgetItem {
  5. factory WidgetItem() => _getInstance();
  6. static WidgetItem _instance;
  7. static WidgetItem _getInstance() {
  8. if (_instance == null) {
  9. _instance = WidgetItem._internal();
  10. }
  11. return _instance;
  12. }
  13. WidgetItem._internal();
  14. Widget returnFileOperateButton(BuildContext context, int cardColor,
  15. Function(FileSystemEntity file,int type) fun,String titleText,FileSystemEntity file,int type) {
  16. Color color;
  17. switch(titleText){
  18. case '删除':
  19. color=Colors.blueGrey;
  20. break;
  21. case '重命名':
  22. color=Colors.blue;
  23. break;
  24. case '复制':
  25. color=Colors.blueAccent;
  26. break;
  27. case '剪切':
  28. color=Colors.lightBlue;
  29. break;
  30. case '收藏':
  31. color=Colors.cyan;
  32. break;
  33. case '取消收藏':
  34. color=Colors.cyanAccent;
  35. break;
  36. }
  37. return Container(
  38. width: 170,
  39. child: Card(
  40. color: Color(cardColor),
  41. margin: EdgeInsets.only(left: 5, right: 5, bottom: 20),
  42. child: InkWell(
  43. child: Center(
  44. child: Padding(
  45. padding: EdgeInsets.all(10),
  46. child: Text(titleText, style: TextStyle(color: color)),
  47. ),
  48. ),
  49. onTap: () {
  50. Navigator.pop(context);
  51. fun(file,type);
  52. },
  53. ),
  54. ),
  55. );
  56. }
  57. }