attachment_page.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:auto_route/auto_route.dart';
  5. import 'package:flutter_hooks/flutter_hooks.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:plugin_platform/engine/image/image_nine_grid.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_text_view.dart';
  13. import '../../router/page/form_page_router.dart';
  14. import 'vm/apply_view_model.dart';
  15. @RoutePage()
  16. class AttachmentPage extends HookConsumerWidget {
  17. const AttachmentPage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.push(const AttachmentPageRoute());
  22. } else {
  23. appRouter.push(const AttachmentPageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.watch(applyViewModelProvider.notifier);
  29. final state = ref.watch(applyViewModelProvider);
  30. useEffect(() {
  31. //赋值State的值
  32. Future.microtask(() {});
  33. return () {
  34. // 组件卸载时执行
  35. };
  36. }, []);
  37. return WillPopScope(
  38. child: Scaffold(
  39. appBar: MyAppBar.appBar(context, state.applyDetail?['title']),
  40. backgroundColor: context.appColors.backgroundWhite,
  41. body: Column(
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: [
  44. SingleChildScrollView(
  45. scrollDirection: Axis.vertical,
  46. physics: const BouncingScrollPhysics(),
  47. child: Container(
  48. margin: const EdgeInsets.symmetric(horizontal: 15),
  49. width: double.infinity,
  50. child: Column(
  51. mainAxisSize: MainAxisSize.max,
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. children: [
  54. MyTextView(
  55. S.current.attachments,
  56. fontSize: 17,
  57. marginTop: 30,
  58. marginBottom: 13,
  59. isFontMedium: true,
  60. textColor: context.appColors.textBlack,
  61. ),
  62. //Note to Management 的文本
  63. MyTextView(
  64. state.applyDetail?['detail_data']['attachment_txt'],
  65. fontSize: 15,
  66. marginBottom: 14,
  67. isFontRegular: true,
  68. textColor: context.appColors.textBlack,
  69. ),
  70. //选择图片九宫格
  71. ImageNineGrid(
  72. isSelectEnable: state.enableEdit,
  73. maxImages: 10,
  74. spacing: 10,
  75. aspectRatio: 108 / 80,
  76. initialImages: const [
  77. "https://img1.baidu.com/it/u=2931243091,718249849&fm=253&fmt=auto&app=120&f=JPEG?w=569&h=427",
  78. "https://inews.gtimg.com/om_bt/OVx3YS2XJc1zbndGTkjPKW9J0W7kN8M0SIidT-3K4mb2YAA/641",
  79. "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641"
  80. ],
  81. onImagesChanged: (list) {
  82. },
  83. ),
  84. ],
  85. ),
  86. ),
  87. ).expanded(),
  88. //底部按钮
  89. MyButton(
  90. onPressed: viewModel.gotoNextPage,
  91. text: S.current.next,
  92. textColor: Colors.white,
  93. backgroundColor: context.appColors.btnBgDefault,
  94. fontWeight: FontWeight.w500,
  95. type: ClickType.throttle,
  96. fontSize: 16,
  97. minHeight: 50,
  98. radius: 0,
  99. ),
  100. ],
  101. )),
  102. onWillPop: () async {
  103. viewModel.handlePopAction();
  104. return true;
  105. });
  106. }
  107. }