guide_dialog.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import 'package:electronic_assistant/module/home/view.dart';
  2. import 'package:electronic_assistant/resource/assets.gen.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/resource/string.gen.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  9. import 'package:get/get.dart';
  10. void mainGuide(GlobalKey topGuide, {VoidCallback? knowCallback}) {
  11. final topGuideOffset = getWidgetPosition(topGuide);
  12. const tag = 'mainGuideDialog';
  13. double padding = 7.5.w;
  14. SmartDialog.show(
  15. tag: tag,
  16. backType: SmartBackType.block,
  17. clickMaskDismiss: false,
  18. maskColor: ColorName.black70,
  19. builder: (_) {
  20. return SizedBox(
  21. width: double.infinity,
  22. height: double.infinity,
  23. child: Stack(
  24. children: [
  25. Positioned(
  26. left: 0,
  27. right: 0,
  28. top: topGuideOffset.dy - padding,
  29. child: Column(
  30. children: [
  31. Container(
  32. padding: EdgeInsets.all(padding),
  33. margin: EdgeInsets.symmetric(horizontal: 10.w),
  34. decoration: BoxDecoration(
  35. color: ColorName.white,
  36. borderRadius: BorderRadius.circular(14),
  37. ),
  38. child: getHomeHeadView()),
  39. Padding(
  40. padding: EdgeInsets.only(
  41. left: 17.5.w, right: 17.5.w, top: 4.w),
  42. child: Row(children: [
  43. Expanded(
  44. child: Column(children: [
  45. Assets.images.iconMainGuideArrow
  46. .image(width: 14.w, height: 27.w),
  47. SizedBox(height: 8.w),
  48. Text(StringName.guideRecord.tr,
  49. style: TextStyle(
  50. fontSize: 14.sp, color: ColorName.white))
  51. ]),
  52. ),
  53. SizedBox(width: 8.w),
  54. Expanded(
  55. child: Column(children: [
  56. Assets.images.iconMainGuideArrow
  57. .image(width: 14.w, height: 27.w),
  58. SizedBox(height: 8.w),
  59. Text(StringName.guideImport.tr,
  60. style: TextStyle(
  61. fontSize: 14.sp, color: ColorName.white))
  62. ]),
  63. ),
  64. ]),
  65. )
  66. ],
  67. ),
  68. ),
  69. Positioned(
  70. left: 0,
  71. right: 0,
  72. bottom: 8.h,
  73. child: Column(
  74. children: [
  75. GestureDetector(
  76. onTap: () {
  77. SmartDialog.dismiss(tag: tag);
  78. knowCallback?.call();
  79. },
  80. child: Container(
  81. decoration: BoxDecoration(
  82. border:
  83. Border.all(color: ColorName.white, width: 2.w),
  84. borderRadius: BorderRadius.circular(100.w),
  85. ),
  86. padding: EdgeInsets.symmetric(
  87. horizontal: 28.w, vertical: 11.w),
  88. child: Text(
  89. StringName.guideAiKnow.tr,
  90. style: TextStyle(
  91. fontSize: 15.sp, color: ColorName.white),
  92. ),
  93. ),
  94. ),
  95. SizedBox(height: 32.h),
  96. Container(
  97. width: 274.w,
  98. decoration: BoxDecoration(
  99. image: DecorationImage(
  100. image: Assets.images.bgGuideMainAiPopup.provider(),
  101. fit: BoxFit.cover,
  102. ),
  103. ),
  104. child: AspectRatio(
  105. aspectRatio: 274 / 76,
  106. child: Align(
  107. alignment: const FractionalOffset(0.6016, 0.361),
  108. child: IntrinsicHeight(
  109. child: Column(
  110. crossAxisAlignment: CrossAxisAlignment.start,
  111. children: [
  112. Text(
  113. StringName.guideAiSecretary.tr,
  114. style: TextStyle(
  115. fontSize: 16.sp,
  116. fontWeight: FontWeight.bold,
  117. color: ColorName.white),
  118. ),
  119. Text(
  120. StringName.guideAiSecretaryDesc.tr,
  121. style: TextStyle(
  122. fontSize: 12.sp,
  123. color: ColorName.white90),
  124. )
  125. ],
  126. ),
  127. ),
  128. ),
  129. )),
  130. SizedBox(height: 12.h),
  131. Assets.images.iconGuideMainAi
  132. .image(width: 66.w, height: 66.w),
  133. ],
  134. ),
  135. )
  136. ],
  137. ),
  138. );
  139. });
  140. }
  141. Offset getWidgetPosition(GlobalKey key) {
  142. final context = key.currentContext;
  143. if (context == null) {
  144. throw Exception('Context is null');
  145. }
  146. final renderObject = context.findRenderObject();
  147. if (renderObject == null || renderObject is! RenderBox) {
  148. throw Exception('RenderObject is null or not a RenderBox');
  149. }
  150. final offset = renderObject.localToGlobal(Offset.zero);
  151. return offset;
  152. }