agreement_dialog.dart 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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:keyboard/utils/common_expand.dart';
  7. import '../data/consts/web_url.dart';
  8. import '../module/browser/browser_page.dart';
  9. import '../resource/assets.gen.dart';
  10. import '../resource/colors.gen.dart';
  11. import '../resource/string.gen.dart';
  12. import '../utils/styles.dart';
  13. import '../widget/click_text_span.dart';
  14. class AgreementDialog {
  15. static final _tag = "AgreementDialog";
  16. static void show({
  17. required VoidCallback cancelClick,
  18. required VoidCallback sureClick,
  19. }) {
  20. SmartDialog.show(
  21. tag: _tag,
  22. backType: SmartBackType.block,
  23. builder: (_) {
  24. return _AgreementDialog(cancelClick, sureClick);
  25. },
  26. alignment: Alignment.center,
  27. clickMaskDismiss: false,
  28. );
  29. }
  30. static void dismiss() {
  31. SmartDialog.dismiss(tag: _tag);
  32. }
  33. }
  34. class _AgreementDialog extends Dialog {
  35. final VoidCallback cancelClick;
  36. final VoidCallback sureClick;
  37. bool _isClicked = false;
  38. _AgreementDialog(this.cancelClick, this.sureClick);
  39. @override
  40. Widget build(BuildContext context) {
  41. return Container(
  42. width: 300.w,
  43. decoration: BoxDecoration(
  44. color: Colors.white,
  45. borderRadius: BorderRadius.circular(20.w),
  46. ),
  47. child: Container(
  48. width: 300.w,
  49. decoration: BoxDecoration(
  50. image: DecorationImage(
  51. image: Assets.images.bgAgreementDialog.provider(),
  52. fit: BoxFit.contain,
  53. alignment: Alignment.topCenter,
  54. ),
  55. ),
  56. child: Column(
  57. mainAxisSize: MainAxisSize.min,
  58. crossAxisAlignment: CrossAxisAlignment.center,
  59. children: [
  60. SizedBox(height: 114.w),
  61. SizedBox(
  62. width: 241.w,
  63. child: Opacity(
  64. opacity: 0.80,
  65. child: Text.rich(
  66. textAlign: TextAlign.start,
  67. TextSpan(
  68. children: [
  69. TextSpan(
  70. text:
  71. '亲爱的用户,为您提供更好的服务,我们需要您同意我们的用户协议和隐私政策。这些文件包含了关于您如何使用我们的服务、我们如何处理您的个人信息以及您的权利和责任的重要信息。请花些时间仔细阅读它们 ',
  72. style: TextStyle(
  73. color: Colors.black.withAlpha(204),
  74. fontSize: 14,
  75. fontWeight: FontWeight.w400,
  76. height: 1.43,
  77. ),
  78. ),
  79. TextSpan(
  80. text: '隐私政策',
  81. style: TextStyle(
  82. color: const Color(0xFF374BFF),
  83. fontSize: 14,
  84. fontWeight: FontWeight.w500,
  85. decoration: TextDecoration.underline,
  86. decorationColor: const Color(0xFF374BFF),
  87. height: 1.43,
  88. ),
  89. recognizer:
  90. TapGestureRecognizer()
  91. ..onTap = () {
  92. BrowserPage.start(WebUrl.privacyPolicy);
  93. },
  94. ),
  95. TextSpan(
  96. text: ' 和 ',
  97. style: TextStyle(
  98. color: Colors.black.withAlpha(204),
  99. fontSize: 14,
  100. fontWeight: FontWeight.w400,
  101. height: 1.43,
  102. ),
  103. ),
  104. TextSpan(
  105. text: '用户协议',
  106. style: TextStyle(
  107. color: const Color(0xFF374BFF),
  108. fontSize: 14,
  109. fontWeight: FontWeight.w500,
  110. decoration: TextDecoration.underline,
  111. decorationColor: const Color(0xFF374BFF),
  112. height: 1.43,
  113. ),
  114. recognizer:
  115. TapGestureRecognizer()
  116. ..onTap = () {
  117. BrowserPage.start(WebUrl.serviceAgreement);
  118. },
  119. ),
  120. TextSpan(
  121. text: '全文,如您同意,请点击点击下方的“同意”按钮。',
  122. style: TextStyle(
  123. color: Colors.black.withAlpha(204),
  124. fontSize: 14,
  125. fontWeight: FontWeight.w400,
  126. height: 1.43,
  127. ),
  128. ),
  129. ],
  130. ),
  131. ),
  132. ),
  133. ),
  134. SizedBox(height: 30.w),
  135. Row(
  136. mainAxisAlignment: MainAxisAlignment.center,
  137. children: [
  138. cancelText(StringName.privacyDisagree, () => cancel()),
  139. SizedBox(width: 16.w),
  140. sureText(StringName.privacyAgree, () {
  141. if (_isClicked) {
  142. return;
  143. }
  144. _isClicked = true;
  145. AgreementDialog.dismiss();
  146. sureClick();
  147. }),
  148. ],
  149. ),
  150. SizedBox(height: 30.w),
  151. ],
  152. ),
  153. ),
  154. );
  155. }
  156. void cancel() {
  157. cancelClick();
  158. }
  159. Widget cancelText(String txt, VoidCallback onTap) {
  160. return GestureDetector(
  161. onTap: onTap,
  162. child: Container(
  163. decoration: ShapeDecoration(
  164. color: const Color(0xFFF5F4F9),
  165. shape: RoundedRectangleBorder(
  166. borderRadius: BorderRadius.circular(50.r),
  167. ),
  168. ),
  169. width: 128.w,
  170. height: 40.w,
  171. child: Center(
  172. child: Text(
  173. txt,
  174. style: TextStyle(
  175. fontSize: 16.sp,
  176. color: Colors.black.withAlpha(102),
  177. fontWeight: FontWeight.w500,
  178. ),
  179. ),
  180. ),
  181. ),
  182. );
  183. }
  184. Widget sureText(String txt, VoidCallback onTap) {
  185. return GestureDetector(
  186. onTap: onTap,
  187. child: Container(
  188. decoration: Styles.getActivateButtonDecoration(50.r),
  189. width: 128.w,
  190. height: 40.w,
  191. child: Center(
  192. child: Text(
  193. txt,
  194. style: TextStyle(
  195. fontSize: 16.sp,
  196. color: Colors.white,
  197. fontWeight: FontWeight.w500,
  198. ),
  199. ),
  200. ),
  201. ),
  202. );
  203. }
  204. }