import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:location/resource/assets.gen.dart';
import 'package:location/resource/colors.gen.dart';
import 'package:location/resource/string.gen.dart';
import 'package:location/utils/common_expand.dart';

import '../utils/common_style.dart';

class TrackErrorTipsDialog {
  static const String _tag = 'TrackErrorTipsDialog';

  static void show() {
    SmartDialog.show(
      tag: _tag,
      maskColor: ColorName.black80,
      builder: (_) => _TrackErrorTipsView(),
    );
  }

  static void dismiss() {
    SmartDialog.dismiss(tag: _tag);
  }
}

class _TrackErrorTipsView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 274.w,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(16.r),
          border: Border.all(
            color: ColorName.white,
            width: 3.w,
          ),
          gradient: LinearGradient(colors: [
            '#E4E4FF'.color,
            ColorName.white,
          ], stops: const [
            0.0,
            0.2
          ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
      child: Stack(
        children: [
          Assets.images.bgDialogTrackError.image(width: double.infinity),
          Container(
            width: double.infinity,
            padding: EdgeInsets.symmetric(horizontal: 17.w),
            child: IntrinsicHeight(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(height: 24.w),
                  Align(
                    alignment: Alignment.center,
                    child: Text(
                      StringName.dialogTrackErrorTitle,
                      style: TextStyle(
                          fontSize: 17.sp,
                          color: '#333333'.color,
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                  SizedBox(height: 35.w),
                  buildTip(StringName.dialogTrackErrorTip1),
                  buildTipDesc(StringName.dialogTrackErrorTip1Desc),
                  buildTip(StringName.dialogTrackErrorTip2),
                  buildTipDesc(StringName.dialogTrackErrorTip2Desc),
                  buildTip(StringName.dialogTrackErrorTip3),
                  buildTipDesc(StringName.dialogTrackErrorTip3Desc),
                  SizedBox(height: 7.w),
                  GestureDetector(
                    onTap: () {
                      TrackErrorTipsDialog.dismiss();
                    },
                    child: Container(
                        decoration: getPrimaryBtnDecoration(100.r),
                        width: double.infinity,
                        height: 40.w,
                        child: Center(
                            child: Text(StringName.dialogTrackErrorBtnTxt,
                                style: TextStyle(
                                    fontSize: 14.sp, color: ColorName.white)))),
                  ),
                  SizedBox(height: 20.w),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }

  Widget buildTip(String title) {
    return Container(
      margin: EdgeInsets.only(bottom: 6.w),
      child: Text(title,
          style: TextStyle(
              fontSize: 13.sp,
              color: '#404040'.color,
              fontWeight: FontWeight.bold)),
    );
  }

  Widget buildTipDesc(String desc) {
    return Container(
      margin: EdgeInsets.only(bottom: 24.w),
      child:
          Text(desc, style: TextStyle(fontSize: 12.sp, color: '#666666'.color)),
    );
  }
}
