keyboard_guide_overlay_dialog.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  4. import 'package:keyboard/resource/assets.gen.dart';
  5. import '../../../resource/colors.gen.dart';
  6. import '../../../utils/widget_location_util.dart';
  7. /// 键盘引导-引导覆盖弹窗
  8. class KeyboardGuideOverlayDialog {
  9. static final tag = "KeyboardGuideOverlayDialog";
  10. /// 显示
  11. /// [targetWidgetKey] 目标组件的key
  12. /// [onFinishCallback] 结束引导时回调
  13. static void show(
  14. GlobalKey targetWidgetKey, {
  15. required VoidCallback onFinishCallback,
  16. }) {
  17. // 获取组件的位置信息
  18. var targetWidgetInfo = WidgetLocationUtil.getWidgetLocation(
  19. targetWidgetKey,
  20. );
  21. SmartDialog.show(
  22. tag: tag,
  23. backType: SmartBackType.normal,
  24. clickMaskDismiss: true,
  25. maskColor: ColorName.black70,
  26. onDismiss: () {
  27. onFinishCallback();
  28. },
  29. builder: (_) {
  30. return SizedBox(
  31. width: double.infinity,
  32. height: double.infinity,
  33. child: Stack(
  34. children: [
  35. Positioned(
  36. left: targetWidgetInfo.position.dx,
  37. top: targetWidgetInfo.position.dy,
  38. child: Assets.images.iconKeyboardGuideOverlay1.image(
  39. width: 320.w,
  40. ),
  41. ),
  42. ],
  43. ),
  44. );
  45. },
  46. );
  47. }
  48. }