agreement_again_dialog.dart 6.3 KB

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