agreement_dialog.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import 'package:flutter/gestures.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:get/get.dart';
  6. import 'package:location/module/browser/browser_view.dart';
  7. import 'package:location/resource/assets.gen.dart';
  8. import 'package:location/resource/colors.gen.dart';
  9. import 'package:location/resource/string.gen.dart';
  10. import 'package:location/utils/common_expand.dart';
  11. import '../data/consts/web_url.dart';
  12. class AgreementDialog {
  13. static final _tag = "AgreementDialog";
  14. static void show(
  15. {required VoidCallback cancelClick, required VoidCallback sureClick}) {
  16. SmartDialog.show(
  17. tag: _tag,
  18. backDismiss: false,
  19. builder: (_) {
  20. return _AgreementDialog(cancelClick, sureClick);
  21. },
  22. clickMaskDismiss: false,
  23. );
  24. }
  25. static void dismiss() {
  26. SmartDialog.dismiss(tag: _tag);
  27. }
  28. }
  29. class _AgreementDialog extends Dialog {
  30. final RxBool isFirstStep = true.obs;
  31. final VoidCallback cancelClick;
  32. final VoidCallback sureClick;
  33. _AgreementDialog(this.cancelClick, this.sureClick);
  34. @override
  35. Widget build(BuildContext context) {
  36. return Container(
  37. width: 300.w,
  38. decoration: BoxDecoration(
  39. color: Colors.white,
  40. borderRadius: BorderRadius.circular(8.w),
  41. ),
  42. child: IntrinsicHeight(
  43. child: Stack(
  44. children: [
  45. Column(children: [
  46. SizedBox(height: 24.w),
  47. Text(StringName.privacyTitle,
  48. style: TextStyle(
  49. fontSize: 17.sp,
  50. color: '#202020'.color,
  51. fontWeight: FontWeight.bold)),
  52. SizedBox(height: 16.w),
  53. Container(
  54. margin: EdgeInsets.symmetric(horizontal: 24.w),
  55. child: Obx(() {
  56. if (isFirstStep.value) {
  57. return oneStepContentRichText();
  58. } else {
  59. return twoStepContentRichText();
  60. }
  61. })),
  62. SizedBox(height: 28.w),
  63. Row(
  64. mainAxisAlignment: MainAxisAlignment.center,
  65. children: [
  66. Obx(() {
  67. return cancelText(
  68. isFirstStep.value
  69. ? StringName.privacyDisagree
  70. : StringName.privacyDisagreeAndExit,
  71. () => cancel());
  72. }),
  73. SizedBox(width: 16.w),
  74. sureText(StringName.privacyAgree, () {
  75. AgreementDialog.dismiss();
  76. sureClick();
  77. })
  78. ],
  79. ),
  80. SizedBox(height: 24.w)
  81. ]),
  82. Positioned(
  83. top: 12.w,
  84. right: 12.w,
  85. child: GestureDetector(
  86. onTap: () => cancel(),
  87. child: Assets.images.iconAgreementClose
  88. .image(width: 14.w, height: 14.w),
  89. )),
  90. ],
  91. ),
  92. ),
  93. );
  94. }
  95. Widget twoStepContentRichText() {
  96. return RichText(
  97. text: TextSpan(
  98. style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
  99. children: [
  100. const TextSpan(
  101. text: "需要同意",
  102. ),
  103. TextSpan(
  104. text: StringName.privacyPolicy,
  105. style: TextStyle(color: '#2F79FF'.color),
  106. recognizer: TapGestureRecognizer()
  107. ..onTap = () {
  108. BrowserPage.start(WebUrl.privacyPolicy);
  109. },
  110. ),
  111. const TextSpan(
  112. text: "和",
  113. ),
  114. TextSpan(
  115. text: StringName.termOfService,
  116. style: TextStyle(color: '#2F79FF'.color),
  117. recognizer: TapGestureRecognizer()
  118. ..onTap = () {
  119. BrowserPage.start(WebUrl.userAgreement);
  120. },
  121. ),
  122. const TextSpan(
  123. text: "才能继续为您提供服务,如您选择不同意很遗憾我们难以继续为您继续服务。",
  124. ),
  125. ]),
  126. );
  127. }
  128. Widget oneStepContentRichText() {
  129. return RichText(
  130. text: TextSpan(
  131. style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
  132. children: [
  133. const TextSpan(
  134. text:
  135. "亲爱的用户,感谢您使用我们产品,为了更好的为您服务,我们可能向系统申请以下必要权限:定位信息权限、存储空间、电话权限等,用于应用的基本服务和功能),你有权拒绝或者撤回权限。\n本软件非常重视您的隐私和个人信息,在您使用之前请仔细阅读",
  136. ),
  137. TextSpan(
  138. text: StringName.privacyPolicy,
  139. style: TextStyle(color: '#2F79FF'.color),
  140. recognizer: TapGestureRecognizer()
  141. ..onTap = () {
  142. BrowserPage.start(WebUrl.privacyPolicy);
  143. },
  144. ),
  145. const TextSpan(
  146. text: "和",
  147. ),
  148. TextSpan(
  149. text: StringName.termOfService,
  150. style: TextStyle(color: '#2F79FF'.color),
  151. recognizer: TapGestureRecognizer()
  152. ..onTap = () {
  153. BrowserPage.start(WebUrl.userAgreement);
  154. },
  155. ),
  156. const TextSpan(
  157. text: "全文,如您同意,请点击点击下方的“同意”按钮。",
  158. ),
  159. ]),
  160. );
  161. }
  162. void privacyClick() {
  163. BrowserPage.start(WebUrl.privacyPolicy);
  164. }
  165. void userAgreementClick() {
  166. BrowserPage.start(WebUrl.userAgreement);
  167. }
  168. void cancel() {
  169. if (isFirstStep.value) {
  170. isFirstStep.value = !isFirstStep.value;
  171. } else {
  172. cancelClick();
  173. }
  174. }
  175. Widget cancelText(String txt, VoidCallback onTap) {
  176. return GestureDetector(
  177. onTap: onTap,
  178. child: Container(
  179. decoration: BoxDecoration(
  180. color: '#F8F8F8'.color,
  181. borderRadius: BorderRadius.circular(26.w),
  182. ),
  183. width: 118.w,
  184. height: 40.w,
  185. child: Center(
  186. child: Text(txt,
  187. style: TextStyle(
  188. fontSize: 16.sp,
  189. color: '#A7A7A7'.color,
  190. fontWeight: FontWeight.bold)),
  191. ),
  192. ),
  193. );
  194. }
  195. Widget sureText(String txt, VoidCallback onTap) {
  196. return GestureDetector(
  197. onTap: onTap,
  198. child: Container(
  199. decoration: BoxDecoration(
  200. color: ColorName.colorPrimary,
  201. borderRadius: BorderRadius.circular(26.w),
  202. ),
  203. width: 118.w,
  204. height: 40.w,
  205. child: Center(
  206. child: Text(txt,
  207. style: TextStyle(
  208. fontSize: 16.sp,
  209. color: Colors.white,
  210. fontWeight: FontWeight.bold)),
  211. ),
  212. ),
  213. );
  214. }
  215. }