agreement_dialog.dart 6.6 KB

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