common_popup.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import 'dart:ui';
  2. import 'package:electronic_assistant/utils/expand.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  7. void showPressTouchPopup(
  8. Offset offset, Alignment alignment, List<Widget> childWidget,
  9. {String? tag, BuildContext? bindWidget}) {
  10. SmartDialog.showAttach(
  11. targetContext: null,
  12. targetBuilder: (_, __) => offset,
  13. animationType: SmartAnimationType.fade,
  14. clickMaskDismiss: true,
  15. alignment: alignment,
  16. bindWidget: bindWidget,
  17. tag: tag,
  18. maskColor: Colors.transparent,
  19. builder: (_) {
  20. return IntrinsicWidth(
  21. child: Container(
  22. constraints: BoxConstraints(
  23. minWidth: 128.w,
  24. ),
  25. decoration: BoxDecoration(
  26. color: Colors.white,
  27. border: Border.all(color: '#D8D8D8'.toColor(), width: 1), // 边框
  28. borderRadius: BorderRadius.circular(8), // 圆角
  29. boxShadow: [
  30. BoxShadow(
  31. color: Colors.black.withOpacity(0.1), // 阴影颜色
  32. spreadRadius: 2, // 阴影扩散半径
  33. blurRadius: 6, // 阴影模糊半径
  34. offset: const Offset(0, 3), // 阴影偏移量
  35. ),
  36. ],
  37. ),
  38. child: Column(
  39. children: childWidget,
  40. ),
  41. ),
  42. );
  43. },
  44. );
  45. }
  46. void showViewTargetPopup(BuildContext context, Alignment alignment,
  47. List<Widget> childWidget,
  48. {Offset? offset}) {
  49. SmartDialog.showAttach(
  50. targetContext: context,
  51. targetBuilder: (targetOffset, targetSize) {
  52. return Offset(targetOffset.dx + (offset != null ? offset.dx : 0),
  53. targetOffset.dy + (offset != null ? offset.dy : 0));
  54. },
  55. alignment: alignment,
  56. animationType: SmartAnimationType.fade,
  57. clickMaskDismiss: true,
  58. maskColor: Colors.transparent,
  59. bindPage: true,
  60. builder: (_) => IntrinsicWidth(
  61. child: Container(
  62. constraints: BoxConstraints(
  63. minWidth: 128.w,
  64. ),
  65. decoration: BoxDecoration(
  66. color: Colors.white,
  67. border: Border.all(color: '#D8D8D8'.toColor(), width: 1), // 边框
  68. borderRadius: BorderRadius.circular(8), // 圆角
  69. boxShadow: [
  70. BoxShadow(
  71. color: Colors.black.withOpacity(0.1), // 阴影颜色
  72. spreadRadius: 2, // 阴影扩散半径
  73. blurRadius: 6, // 阴影模糊半径
  74. offset: const Offset(0, 3), // 阴影偏移量
  75. ),
  76. ],
  77. ),
  78. child: Column(
  79. children: childWidget,
  80. ),
  81. ),
  82. ),
  83. );
  84. }