payment_info_page.dart 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_button.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import 'package:widgets/widget_export.dart';
  15. import '../../router/page/payment_page_router.dart';
  16. import 'payment_info_view_model.dart';
  17. @RoutePage()
  18. class PaymentInfoPage extends HookConsumerWidget {
  19. const PaymentInfoPage({Key? key}) : super(key: key);
  20. //启动当前页面
  21. static void startInstance({BuildContext? context}) {
  22. if (context != null) {
  23. context.router.push(const PaymentInfoPageRoute());
  24. } else {
  25. appRouter.push(const PaymentInfoPageRoute());
  26. }
  27. }
  28. @override
  29. Widget build(BuildContext context, WidgetRef ref) {
  30. final viewModel = ref.watch(paymentInfoViewModelProvider.notifier);
  31. final state = ref.watch(paymentInfoViewModelProvider);
  32. final noteCount = useState(0);
  33. return Scaffold(
  34. appBar: MyAppBar.appBar(context, "付款的标题"),
  35. backgroundColor: context.appColors.backgroundWhite,
  36. body: Column(
  37. mainAxisSize: MainAxisSize.max,
  38. crossAxisAlignment: CrossAxisAlignment.start,
  39. children: [
  40. SingleChildScrollView(
  41. scrollDirection: Axis.vertical,
  42. physics: const BouncingScrollPhysics(),
  43. child: Column(
  44. crossAxisAlignment: CrossAxisAlignment.start,
  45. children: [
  46. //金额
  47. Row(
  48. children: [
  49. const MyAssetImage(Assets.paymentInfoDetails, width: 27, height: 27),
  50. MyTextView(
  51. S.current.payment_details,
  52. textColor: context.appColors.textBlack,
  53. fontSize: 17,
  54. marginLeft: 14,
  55. isFontMedium: true,
  56. ).expanded(),
  57. ],
  58. ).marginOnly(top: 15),
  59. Row(
  60. children: [
  61. MyTextView(
  62. "SGD",
  63. textColor: context.appColors.textBlack,
  64. fontSize: 18,
  65. isFontRegular: true,
  66. ),
  67. MyTextView(
  68. "\$21.80",
  69. textColor: context.appColors.textPrimary,
  70. fontSize: 22,
  71. marginLeft: 12,
  72. isFontMedium: true,
  73. ).expanded(),
  74. ],
  75. ).marginOnly(top: 20),
  76. Container(
  77. height: 0.5,
  78. margin: const EdgeInsets.only(top: 22,bottom: 13.5),
  79. color: context.appColors.dividerDefault,
  80. ),
  81. // DESC
  82. Row(
  83. children: [
  84. const MyAssetImage(Assets.paymentInfoNotes, width: 27, height: 27),
  85. MyTextView(
  86. S.current.notes_to_recipient,
  87. textColor: context.appColors.textBlack,
  88. fontSize: 17,
  89. marginLeft: 14,
  90. isFontMedium: true,
  91. ).expanded(),
  92. ],
  93. ),
  94. //大文本框
  95. IgnoreKeyboardDismiss(
  96. child: Container(
  97. height: 177,
  98. margin: const EdgeInsets.only(top: 24),
  99. padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
  100. decoration: BoxDecoration(
  101. color: context.appColors.authFiledBG,
  102. borderRadius: const BorderRadius.all(Radius.circular(5)),
  103. ),
  104. child: Stack(
  105. children: [
  106. TextField(
  107. cursorColor: context.appColors.authFiledText,
  108. cursorWidth: 1.5,
  109. autofocus: false,
  110. enabled: true,
  111. focusNode: state.formData["note"]!['focusNode'],
  112. controller: state.formData["note"]!['controller'],
  113. decoration: InputDecoration(
  114. isDense: true,
  115. isCollapsed: true,
  116. border: InputBorder.none,
  117. hintText: state.formData["note"]!['hintText'],
  118. hintStyle: TextStyle(
  119. color: context.appColors.authFiledHint,
  120. fontSize: 16.0,
  121. fontWeight: FontWeight.w500,
  122. ),
  123. ),
  124. style: TextStyle(
  125. color: context.appColors.authFiledText,
  126. fontSize: 16.0,
  127. fontWeight: FontWeight.w500,
  128. ),
  129. textInputAction: TextInputAction.done,
  130. onSubmitted: (value) {
  131. FocusScope.of(context).unfocus();
  132. },
  133. maxLines: null,
  134. expands: true,
  135. onChanged: (text) {
  136. // 当文本改变时,更新字符数量
  137. noteCount.value = text.length;
  138. },
  139. ),
  140. Positioned(
  141. bottom: 0.0,
  142. right: 0.0,
  143. child: Text(
  144. S.current.characters(noteCount.value),
  145. style: TextStyle(
  146. color: context.appColors.textBlack,
  147. fontSize: 15.0,
  148. ),
  149. ),
  150. ),
  151. ],
  152. ),
  153. ),
  154. ),
  155. ],
  156. ).paddingSymmetric(horizontal: 15))
  157. .expanded(),
  158. // 底部按钮
  159. MyButton(
  160. onPressed: viewModel.gotoConfirmPage,
  161. text: S.current.next,
  162. textColor: Colors.white,
  163. backgroundColor: context.appColors.btnBgDefault,
  164. fontWeight: FontWeight.w500,
  165. type: ClickType.throttle,
  166. fontSize: 16,
  167. minHeight: 50,
  168. radius: 0,
  169. ).marginOnly(top: 15),
  170. ],
  171. ),
  172. );
  173. }
  174. }