payment_info_page.dart 8.1 KB

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