agreement_again_dialog.dart 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 AgreementAgainDialog {
  15. static final _tag = "AgreementAgainDialog";
  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 _AgreementAgainDialog(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 _AgreementAgainDialog extends Dialog {
  35. final VoidCallback cancelClick;
  36. final VoidCallback sureClick;
  37. bool _isClicked = false;
  38. _AgreementAgainDialog(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.bgAgreementAgainDialog.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: 29.55.w),
  61. Text(
  62. StringName.privacyTitle,
  63. textAlign: TextAlign.center,
  64. style: TextStyle(
  65. color: const Color(0xFF202020),
  66. fontSize: 16.sp,
  67. fontWeight: FontWeight.w700,
  68. ),
  69. ),
  70. SizedBox(height: 30.05.w),
  71. SizedBox(
  72. width: 240.w,
  73. child: Opacity(
  74. opacity: 0.80,
  75. child: Text.rich(
  76. TextSpan(
  77. children: [
  78. TextSpan(
  79. text: '需要同意',
  80. style: TextStyle(
  81. color: Colors.black.withAlpha(204),
  82. fontSize: 14.sp,
  83. fontWeight: FontWeight.w400,
  84. height: 1.43,
  85. ),
  86. ),
  87. TextSpan(
  88. text: '《隐私政策》',
  89. style: TextStyle(
  90. color: const Color(0xFF374BFF),
  91. fontSize: 14.sp,
  92. fontWeight: FontWeight.w500,
  93. height: 1.43,
  94. ),
  95. recognizer:
  96. TapGestureRecognizer()
  97. ..onTap = () {
  98. BrowserPage.start(WebUrl.privacyPolicy);
  99. },
  100. ),
  101. TextSpan(
  102. text: '和',
  103. style: TextStyle(
  104. color: Colors.black.withAlpha(204),
  105. fontSize: 14.sp,
  106. fontWeight: FontWeight.w400,
  107. height: 1.43,
  108. ),
  109. ),
  110. TextSpan(
  111. text: '《用户协议》',
  112. recognizer:
  113. TapGestureRecognizer()
  114. ..onTap = () {
  115. BrowserPage.start(WebUrl.serviceAgreement);
  116. },
  117. style: TextStyle(
  118. color: const Color(0xFF374BFF),
  119. fontSize: 14.sp,
  120. fontWeight: FontWeight.w500,
  121. height: 1.43,
  122. ),
  123. ),
  124. TextSpan(
  125. text: '才能继续为您提供服务,如您选择不同意很遗憾我们难以继续为您继续服务。',
  126. style: TextStyle(
  127. color: Colors.black.withAlpha(204),
  128. fontSize: 14.sp,
  129. fontWeight: FontWeight.w400,
  130. height: 1.43,
  131. ),
  132. ),
  133. ],
  134. ),
  135. ),
  136. ),
  137. ),
  138. SizedBox(height: 30.w),
  139. Container(
  140. margin: EdgeInsets.only(left: 25.w, right: 25.w),
  141. child: Row(
  142. children: [
  143. Expanded(
  144. child: sureText(StringName.privacyAgree, () {
  145. if (_isClicked) return;
  146. _isClicked = true;
  147. sureClick();
  148. }),
  149. ),
  150. ],
  151. ),
  152. ),
  153. SizedBox(height: 18.w),
  154. cancelText(StringName.privacyDisagreeAndExit, () => cancel()),
  155. SizedBox(height: 30.w),
  156. ],
  157. ),
  158. ),
  159. );
  160. }
  161. void cancel() {
  162. cancelClick();
  163. }
  164. Widget cancelText(String txt, VoidCallback onTap) {
  165. return GestureDetector(
  166. onTap: onTap,
  167. child: Center(
  168. child: Text(
  169. txt,
  170. style: TextStyle(
  171. fontSize: 16.sp,
  172. color: Colors.black.withAlpha(102),
  173. fontWeight: FontWeight.w500,
  174. ),
  175. ),
  176. ),
  177. );
  178. }
  179. Widget sureText(String txt, VoidCallback onTap) {
  180. return GestureDetector(
  181. onTap: onTap,
  182. child: Container(
  183. decoration: Styles.getActivateButtonDecoration(50.r),
  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. }