desktop_shortcut_dialog.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import 'package:electronic_assistant/resource/assets.gen.dart';
  2. import 'package:electronic_assistant/resource/colors.gen.dart';
  3. import 'package:electronic_assistant/resource/string.gen.dart';
  4. import 'package:electronic_assistant/utils/common_style.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter_screenutil/flutter_screenutil.dart';
  7. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  8. import 'package:get/get.dart';
  9. void showAddDesktopShortcutDialog(
  10. {required void Function() onConfirm, required void Function() onCancel}) {
  11. SmartDialog.show(
  12. backType: SmartBackType.block,
  13. clickMaskDismiss: false,
  14. builder: (_) {
  15. return IntrinsicHeight(
  16. child: Column(
  17. children: [
  18. Stack(
  19. children: [
  20. Assets.images.bgDesktopShortcutHeader
  21. .image(width: 300.w, height: 142.w),
  22. Positioned(
  23. top: 14.w,
  24. right: 14.w,
  25. child: GestureDetector(
  26. onTap: () {
  27. onCancel.call();
  28. SmartDialog.dismiss();
  29. },
  30. child: Assets.images.iconDesktopShortcutClose
  31. .image(width: 28.w, height: 28.w),
  32. ),
  33. ),
  34. ],
  35. ),
  36. Container(
  37. decoration: BoxDecoration(
  38. color: ColorName.white,
  39. borderRadius: BorderRadius.only(
  40. bottomLeft: Radius.circular(12.w),
  41. bottomRight: Radius.circular(12.w))),
  42. width: 300.w,
  43. child: Column(
  44. children: [
  45. SizedBox(height: 24.h),
  46. Text(
  47. StringName.addDesktopShortcut.tr,
  48. style: TextStyle(
  49. fontWeight: FontWeight.bold,
  50. fontSize: 18.sp,
  51. color: ColorName.primaryTextColor),
  52. ),
  53. SizedBox(height: 6.h),
  54. SizedBox(
  55. width: 238.w,
  56. child: Text(
  57. textAlign: TextAlign.center,
  58. StringName.addDesktopShortcutTips.tr,
  59. style: TextStyle(
  60. fontSize: 14.sp,
  61. color: ColorName.secondaryTextColor),
  62. )),
  63. SizedBox(height: 33.h),
  64. GestureDetector(
  65. onTap: () {
  66. SmartDialog.dismiss();
  67. onConfirm.call();
  68. },
  69. child: Container(
  70. width: 268.w,
  71. height: 48.w,
  72. decoration: getCommonDecoration(8.w),
  73. child: Center(
  74. child: Text(
  75. StringName.addDesktopShortcutBtnTxt.tr,
  76. style: TextStyle(
  77. fontSize: 16.sp, color: ColorName.white),
  78. ))),
  79. ),
  80. SizedBox(height: 16.h),
  81. ],
  82. ),
  83. )
  84. ],
  85. ),
  86. );
  87. });
  88. }
  89. void showAddDesktopShortcutTipsDialog(
  90. {required void Function() onConfirm, required void Function() onDismiss}) {
  91. SmartDialog.show(
  92. onDismiss: onDismiss,
  93. builder: (_) {
  94. return IntrinsicHeight(
  95. child: Container(
  96. color: ColorName.white,
  97. child: Column(
  98. children: [
  99. Text(
  100. '添加到桌面可能会失败,需要去设置页-权限进行授权,授权后再次尝试即可',
  101. style: TextStyle(
  102. fontSize: 14.sp, color: ColorName.primaryTextColor),
  103. ),
  104. GestureDetector(
  105. onTap: () {
  106. SmartDialog.dismiss();
  107. onConfirm.call();
  108. },
  109. child: SizedBox(
  110. width: 100.w,
  111. height: 30.w,
  112. child: Center(child: Text('确认'))))
  113. ],
  114. ),
  115. ),
  116. );
  117. });
  118. }