import 'package:cs_resources/generated/l10n.dart'; import 'package:cs_resources/theme/app_colors_theme.dart'; import 'package:flutter/material.dart'; import 'package:auto_route/auto_route.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:plugin_platform/engine/image/image_nine_grid.dart'; import 'package:router/ext/auto_router_extensions.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:widgets/my_appbar.dart'; import 'package:widgets/my_button.dart'; import 'package:widgets/my_text_view.dart'; import '../../router/page/form_page_router.dart'; import 'vm/apply_view_model.dart'; @RoutePage() class AttachmentPage extends HookConsumerWidget { const AttachmentPage({Key? key}) : super(key: key); //启动当前页面 static void startInstance({BuildContext? context}) { if (context != null) { context.router.push(const AttachmentPageRoute()); } else { appRouter.push(const AttachmentPageRoute()); } } @override Widget build(BuildContext context, WidgetRef ref) { final viewModel = ref.watch(applyViewModelProvider.notifier); final state = ref.watch(applyViewModelProvider); useEffect(() { //赋值State的值 Future.microtask(() {}); return () { // 组件卸载时执行 }; }, []); return WillPopScope( child: Scaffold( appBar: MyAppBar.appBar(context, state.applyDetail?['title']), backgroundColor: context.appColors.whiteBG, body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SingleChildScrollView( scrollDirection: Axis.vertical, physics: const BouncingScrollPhysics(), child: Container( margin: const EdgeInsets.symmetric(horizontal: 15), width: double.infinity, child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ MyTextView( S.current.attachments, fontSize: 17, marginTop: 30, marginBottom: 13, isFontMedium: true, textColor: context.appColors.textBlack, ), //Note to Management 的文本 MyTextView( state.applyDetail?['detail_data']['attachment_txt'], fontSize: 15, marginBottom: 14, isFontRegular: true, textColor: context.appColors.textBlack, ), //选择图片九宫格 ImageNineGrid( isSelectEnable: state.enableEdit, maxImages: 10, spacing: 10, aspectRatio: 108 / 80, initialImages: const [ "https://img1.baidu.com/it/u=2931243091,718249849&fm=253&fmt=auto&app=120&f=JPEG?w=569&h=427", "https://inews.gtimg.com/om_bt/OVx3YS2XJc1zbndGTkjPKW9J0W7kN8M0SIidT-3K4mb2YAA/641", "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641" ], onImagesChanged: (list) { }, ), ], ), ), ).expanded(), //底部按钮 MyButton( onPressed: viewModel.gotoNextPage, text: S.current.next, textColor: Colors.white, backgroundColor: context.appColors.btnBgDefault, fontWeight: FontWeight.w500, type: ClickType.throttle, fontSize: 16, minHeight: 50, radius: 0, ), ], )), onWillPop: () async { viewModel.handlePopAction(); return true; }); } }