guide_dialog.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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:
  78. aiBottom - 7.h + MediaQuery.of(context).padding.bottom,
  79. child: Column(
  80. children: [
  81. GestureDetector(
  82. onTap: () {
  83. SmartDialog.dismiss(tag: tag);
  84. knowCallback?.call();
  85. },
  86. child: Container(
  87. decoration: BoxDecoration(
  88. border:
  89. Border.all(color: ColorName.white, width: 2.w),
  90. borderRadius: BorderRadius.circular(100.w),
  91. ),
  92. padding: EdgeInsets.symmetric(
  93. horizontal: 28.w, vertical: 11.w),
  94. child: Text(
  95. StringName.guideAiKnow.tr,
  96. style: TextStyle(
  97. fontSize: 15.sp, color: ColorName.white),
  98. ),
  99. ),
  100. ),
  101. SizedBox(height: 32.h),
  102. Container(
  103. width: 274.w,
  104. decoration: BoxDecoration(
  105. image: DecorationImage(
  106. image:
  107. Assets.images.bgGuideMainAiPopup.provider(),
  108. fit: BoxFit.cover,
  109. ),
  110. ),
  111. child: AspectRatio(
  112. aspectRatio: 274 / 76,
  113. child: Align(
  114. alignment: const FractionalOffset(0.6016, 0.361),
  115. child: IntrinsicHeight(
  116. child: Column(
  117. crossAxisAlignment: CrossAxisAlignment.start,
  118. children: [
  119. Text(
  120. StringName.guideAiSecretary.tr,
  121. style: TextStyle(
  122. fontSize: 16.sp,
  123. fontWeight: FontWeight.bold,
  124. color: ColorName.white),
  125. ),
  126. Text(
  127. StringName.guideAiSecretaryDesc.tr,
  128. style: TextStyle(
  129. fontSize: 12.sp,
  130. color: ColorName.white90),
  131. )
  132. ],
  133. ),
  134. ),
  135. ),
  136. )),
  137. SizedBox(height: 12.h),
  138. Assets.images.iconGuideMainAi
  139. .image(width: 66.w, height: 66.w),
  140. ],
  141. ),
  142. );
  143. })
  144. ],
  145. ),
  146. );
  147. });
  148. }
  149. WidgetInfo getWidgetPosition(GlobalKey key) {
  150. final context = key.currentContext;
  151. if (context == null) {
  152. throw Exception('Context is null');
  153. }
  154. final renderObject = context.findRenderObject();
  155. if (renderObject == null || renderObject is! RenderBox) {
  156. throw Exception('RenderObject is null or not a RenderBox');
  157. }
  158. final offset = renderObject.localToGlobal(Offset.zero);
  159. final size = renderObject.size;
  160. return WidgetInfo(offset, size);
  161. }
  162. class WidgetInfo {
  163. final Offset position;
  164. final Size size;
  165. WidgetInfo(this.position, this.size);
  166. @override
  167. String toString() {
  168. return 'WidgetInfo{position: $position, size: $size}';
  169. }
  170. }