recover_subscribe_view.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import 'package:flutter/Material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:keyboard/module/store/subscribe/recover_subscribe_controller.dart';
  4. import 'package:keyboard/resource/string.gen.dart';
  5. import '../../../base/base_view.dart';
  6. import '../../../resource/assets.gen.dart';
  7. import '../../../resource/colors.gen.dart';
  8. import '../../../widget/gradient_btn.dart';
  9. /// 点击确认时回调
  10. typedef OnConfirmCallback = void Function();
  11. /// 关闭弹窗时回调
  12. typedef OnCloseCallback = void Function();
  13. /// 恢复订阅弹窗内容
  14. class RecoverSubscribeView extends BaseView<RecoverSubscribeController> {
  15. final String desc;
  16. final OnConfirmCallback onConfirmCallback;
  17. final OnCloseCallback onCloseCallback;
  18. const RecoverSubscribeView({
  19. super.key,
  20. required this.desc,
  21. required this.onConfirmCallback,
  22. required this.onCloseCallback,
  23. });
  24. @override
  25. backgroundColor() => Colors.transparent;
  26. @override
  27. Widget buildBody(BuildContext context) {
  28. return Stack(
  29. children: [
  30. Container(
  31. padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 16.w),
  32. decoration: BoxDecoration(
  33. color: ColorName.white,
  34. borderRadius: BorderRadius.all(Radius.circular(16.r)),
  35. ),
  36. child: Column(
  37. // 包裹内容
  38. mainAxisSize: MainAxisSize.min,
  39. children: [
  40. // 标题
  41. _buildTitle(),
  42. SizedBox(height: 12.h),
  43. _buildDesc(desc),
  44. SizedBox(height: 24.h),
  45. _buildSaveBtn(),
  46. ],
  47. ),
  48. ),
  49. Positioned(
  50. top: 0,
  51. right: 0,
  52. child: InkWell(
  53. onTap: () {
  54. controller.doClose(onCloseCallback);
  55. },
  56. splashColor: ColorName.transparent,
  57. child: Container(
  58. padding: EdgeInsets.all(14.w),
  59. child: Assets.images.iconCustomDirectionEditClose.image(
  60. width: 24.w,
  61. height: 24.w,
  62. ),
  63. ),
  64. ),
  65. ),
  66. ],
  67. );
  68. }
  69. /// 标题
  70. Widget _buildTitle() {
  71. return Text(
  72. StringName.recoverSubscribeTitle,
  73. style: TextStyle(
  74. fontSize: 16.sp,
  75. color: ColorName.black80,
  76. fontWeight: FontWeight.bold,
  77. ),
  78. );
  79. }
  80. /// 描述
  81. Widget _buildDesc(String desc) {
  82. return Text(
  83. desc,
  84. style: TextStyle(
  85. fontSize: 16.sp,
  86. color: ColorName.black60,
  87. fontWeight: FontWeight.w400,
  88. ),
  89. );
  90. }
  91. /// 保存按钮
  92. Widget _buildSaveBtn() {
  93. return SizedBox(
  94. width: double.infinity,
  95. child: GradientTextBtn(
  96. StringName.recoverSubscribeConfirm,
  97. onPressed: () {
  98. controller.doOnConfirm(onConfirmCallback);
  99. },
  100. ),
  101. );
  102. }
  103. }