desktop_shortcut_dialog.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. width: 280.w,
  97. padding: EdgeInsets.only(
  98. left: 16.w, right: 16.w, top: 28.h, bottom: 24.h),
  99. decoration: BoxDecoration(
  100. color: ColorName.white,
  101. borderRadius: BorderRadius.circular(12.w)),
  102. child: Column(
  103. children: [
  104. Text(
  105. '“小听快听”已尝试添加到桌面',
  106. style: TextStyle(
  107. fontWeight: FontWeight.bold,
  108. fontSize: 15.sp,
  109. color: ColorName.primaryTextColor),
  110. ),
  111. SizedBox(height: 12.h),
  112. Expanded(
  113. child: Text(
  114. textAlign: TextAlign.center,
  115. '若添加失败,请前往系统设置,为小听打开“创建桌面快捷方式”的权限。',
  116. style: TextStyle(
  117. fontSize: 14.sp, color: ColorName.secondaryTextColor),
  118. ),
  119. ),
  120. SizedBox(height: 32.h),
  121. GestureDetector(
  122. onTap: () {
  123. SmartDialog.dismiss();
  124. onConfirm.call();
  125. },
  126. child: Container(
  127. decoration: BoxDecoration(
  128. color: ColorName.colorPrimary,
  129. borderRadius: BorderRadius.circular(8.w)),
  130. height: 38.w,
  131. child: Center(
  132. child: Text(
  133. StringName.sure.tr,
  134. style: TextStyle(
  135. fontSize: 14.sp, color: ColorName.white),
  136. ))))
  137. ],
  138. ),
  139. ),
  140. );
  141. });
  142. }