guide_dialog.dart 6.9 KB

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