agreement_dialog.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. sureClick();
  76. })
  77. ],
  78. ),
  79. SizedBox(height: 24.w)
  80. ]),
  81. Positioned(
  82. top: 12.w,
  83. right: 12.w,
  84. child: GestureDetector(
  85. onTap: () => cancel(),
  86. child: Assets.images.iconAgreementClose
  87. .image(width: 14.w, height: 14.w),
  88. )),
  89. ],
  90. ),
  91. ),
  92. );
  93. }
  94. Widget twoStepContentRichText() {
  95. return RichText(
  96. text: TextSpan(
  97. style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
  98. children: [
  99. const TextSpan(
  100. text: "需要同意",
  101. ),
  102. TextSpan(
  103. text: StringName.privacyPolicy,
  104. style: TextStyle(color: '#2F79FF'.color),
  105. recognizer: TapGestureRecognizer()
  106. ..onTap = () {
  107. BrowserPage.start(WebUrl.privacyPolicy);
  108. },
  109. ),
  110. const TextSpan(
  111. text: "和",
  112. ),
  113. TextSpan(
  114. text: StringName.termOfService,
  115. style: TextStyle(color: '#2F79FF'.color),
  116. recognizer: TapGestureRecognizer()
  117. ..onTap = () {
  118. BrowserPage.start(WebUrl.userAgreement);
  119. },
  120. ),
  121. const TextSpan(
  122. text: "才能继续为您提供服务,如您选择不同意很遗憾我们难以继续为您继续服务。",
  123. ),
  124. ]),
  125. );
  126. }
  127. Widget oneStepContentRichText() {
  128. return RichText(
  129. text: TextSpan(
  130. style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
  131. children: [
  132. const TextSpan(
  133. text:
  134. "亲爱的用户,感谢您使用我们产品,为了更好的为您服务,我们可能向系统申请以下必要权限:定位信息权限、存储空间、电话权限等,用于应用的基本服务和功能),你有权拒绝或者撤回权限。\n本软件非常重视您的隐私和个人信息,在您使用之前请仔细阅读",
  135. ),
  136. TextSpan(
  137. text: StringName.privacyPolicy,
  138. style: TextStyle(color: '#2F79FF'.color),
  139. recognizer: TapGestureRecognizer()
  140. ..onTap = () {
  141. BrowserPage.start(WebUrl.privacyPolicy);
  142. },
  143. ),
  144. const TextSpan(
  145. text: "和",
  146. ),
  147. TextSpan(
  148. text: StringName.termOfService,
  149. style: TextStyle(color: '#2F79FF'.color),
  150. recognizer: TapGestureRecognizer()
  151. ..onTap = () {
  152. BrowserPage.start(WebUrl.userAgreement);
  153. },
  154. ),
  155. const TextSpan(
  156. text: "全文,如您同意,请点击点击下方的“同意”按钮。",
  157. ),
  158. ]),
  159. );
  160. }
  161. void privacyClick() {
  162. BrowserPage.start(WebUrl.privacyPolicy);
  163. }
  164. void userAgreementClick() {
  165. BrowserPage.start(WebUrl.userAgreement);
  166. }
  167. void cancel() {
  168. if (isFirstStep.value) {
  169. isFirstStep.value = !isFirstStep.value;
  170. } else {
  171. cancelClick();
  172. }
  173. }
  174. Widget cancelText(String txt, VoidCallback onTap) {
  175. return GestureDetector(
  176. onTap: onTap,
  177. child: Container(
  178. decoration: BoxDecoration(
  179. color: '#F8F8F8'.color,
  180. borderRadius: BorderRadius.circular(26.w),
  181. ),
  182. width: 118.w,
  183. height: 40.w,
  184. child: Center(
  185. child: Text(txt,
  186. style: TextStyle(
  187. fontSize: 16.sp,
  188. color: '#A7A7A7'.color,
  189. fontWeight: FontWeight.bold)),
  190. ),
  191. ),
  192. );
  193. }
  194. Widget sureText(String txt, VoidCallback onTap) {
  195. return GestureDetector(
  196. onTap: onTap,
  197. child: Container(
  198. decoration: BoxDecoration(
  199. color: ColorName.colorPrimary,
  200. borderRadius: BorderRadius.circular(26.w),
  201. ),
  202. width: 118.w,
  203. height: 40.w,
  204. child: Center(
  205. child: Text(txt,
  206. style: TextStyle(
  207. fontSize: 16.sp,
  208. color: Colors.white,
  209. fontWeight: FontWeight.bold)),
  210. ),
  211. ),
  212. );
  213. }
  214. }