| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- import 'package:electronic_assistant/module/home/view.dart';
- import 'package:electronic_assistant/resource/assets.gen.dart';
- import 'package:electronic_assistant/resource/colors.gen.dart';
- import 'package:electronic_assistant/resource/string.gen.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
- import 'package:get/get.dart';
- void mainGuide(GlobalKey topGuide, GlobalKey aiGuide,
- {VoidCallback? knowCallback}) {
- final topWidgetInfo = getWidgetPosition(topGuide);
- final aiWidgetInfo = getWidgetPosition(aiGuide);
- double aiBottom =
- Get.height - aiWidgetInfo.position.dy - aiWidgetInfo.size.height;
- const tag = 'mainGuideDialog';
- double padding = 7.5.w;
- SmartDialog.show(
- tag: tag,
- backType: SmartBackType.block,
- clickMaskDismiss: false,
- maskColor: ColorName.black70,
- builder: (_) {
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: Stack(
- children: [
- Positioned(
- left: 0,
- right: 0,
- top: topWidgetInfo.position.dy - padding,
- child: Column(
- children: [
- Container(
- padding: EdgeInsets.all(padding),
- margin: EdgeInsets.symmetric(horizontal: 10.w),
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.circular(14),
- ),
- child: getHomeHeadView()),
- Padding(
- padding: EdgeInsets.only(
- left: 17.5.w, right: 17.5.w, top: 4.w),
- child: Row(children: [
- Expanded(
- child: Column(children: [
- Assets.images.iconMainGuideArrow
- .image(width: 14.w, height: 27.w),
- SizedBox(height: 8.w),
- Text(StringName.guideRecord.tr,
- style: TextStyle(
- fontSize: 14.sp, color: ColorName.white))
- ]),
- ),
- SizedBox(width: 8.w),
- Expanded(
- child: Column(children: [
- Assets.images.iconMainGuideArrow
- .image(width: 14.w, height: 27.w),
- SizedBox(height: 8.w),
- Text(StringName.guideImport.tr,
- style: TextStyle(
- fontSize: 14.sp, color: ColorName.white))
- ]),
- ),
- ]),
- )
- ],
- ),
- ),
- Builder(builder: (context) {
- return Positioned(
- left: 0,
- right: 0,
- bottom: aiBottom - 7.h,
- child: Column(
- children: [
- GestureDetector(
- onTap: () {
- SmartDialog.dismiss(tag: tag);
- knowCallback?.call();
- },
- child: Container(
- decoration: BoxDecoration(
- border:
- Border.all(color: ColorName.white, width: 2.w),
- borderRadius: BorderRadius.circular(100.w),
- ),
- padding: EdgeInsets.symmetric(
- horizontal: 28.w, vertical: 11.w),
- child: Text(
- StringName.guideAiKnow.tr,
- style: TextStyle(
- fontSize: 15.sp, color: ColorName.white),
- ),
- ),
- ),
- SizedBox(height: 32.h),
- Container(
- width: 274.w,
- decoration: BoxDecoration(
- image: DecorationImage(
- image:
- Assets.images.bgGuideMainAiPopup.provider(),
- fit: BoxFit.cover,
- ),
- ),
- child: AspectRatio(
- aspectRatio: 274 / 76,
- child: Align(
- alignment: const FractionalOffset(0.6016, 0.361),
- child: IntrinsicHeight(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- StringName.guideAiSecretary.tr,
- style: TextStyle(
- fontSize: 16.sp,
- fontWeight: FontWeight.bold,
- color: ColorName.white),
- ),
- Text(
- StringName.guideAiSecretaryDesc.tr,
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.white90),
- )
- ],
- ),
- ),
- ),
- )),
- SizedBox(height: 12.h),
- Assets.images.iconGuideMainAi
- .image(width: 66.w, height: 66.w),
- ],
- ),
- );
- })
- ],
- ),
- );
- });
- }
- WidgetInfo getWidgetPosition(GlobalKey key) {
- final context = key.currentContext;
- if (context == null) {
- throw Exception('Context is null');
- }
- final renderObject = context.findRenderObject();
- if (renderObject == null || renderObject is! RenderBox) {
- throw Exception('RenderObject is null or not a RenderBox');
- }
- final offset = renderObject.localToGlobal(Offset.zero);
- final size = renderObject.size;
- return WidgetInfo(offset, size);
- }
- class WidgetInfo {
- final Offset position;
- final Size size;
- WidgetInfo(this.position, this.size);
- @override
- String toString() {
- return 'WidgetInfo{position: $position, size: $size}';
- }
- }
|