diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 2acf4a82..cae92a8c 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -235,7 +235,7 @@ class _Community { class _Upload { ///上传咨询建议照片 - String get uploadArticle => '/user/upload/uploadArticle'; + String get uploadAdvice => '/user/upload/uploadAdvice'; ///上传头像 String get uploadAvatar => '/user/upload/appHeadSculpture'; diff --git a/lib/pages/setting_page/settings_page.dart b/lib/pages/setting_page/settings_page.dart index 17957a5a..ab6ae718 100644 --- a/lib/pages/setting_page/settings_page.dart +++ b/lib/pages/setting_page/settings_page.dart @@ -132,10 +132,10 @@ class _SettingsPageState extends State { )), 26.hb, ...[ - _buildTile( - title: '清除缓存', - onTap: () {}, - ), + // _buildTile( + // title: '清除缓存', + // onTap: () {}, + // ), _buildTile( title: '意见反馈', onTap: () => Get.to(() => FeedBackPage()), @@ -156,7 +156,6 @@ class _SettingsPageState extends State { separate: Divider( indent: 32.w, endIndent: 32.w, - color: Color(0xFFD8D8D8), thickness: 1.w, height: 1.w, )), diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index 77d019dd..094269e1 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -1,6 +1,7 @@ import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart'; +import 'package:flustars/flustars.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -34,6 +35,7 @@ class _VisitorAccessPageState extends State { TextEditingController _userCarNum = new TextEditingController(); DateTime dateTime; int _selectSex = 1; + GlobalKey formKey = GlobalKey(); Widget _buildHouseCard( String title, @@ -82,7 +84,8 @@ class _VisitorAccessPageState extends State { ); } - Widget _input(String title, hintText, TextEditingController controller) { + Widget _input(String title, hintText, TextEditingController controller, + FormFieldValidator validator) { return Container( padding: EdgeInsets.only( left: 36.w, @@ -103,7 +106,11 @@ class _VisitorAccessPageState extends State { style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), ), SizedBox(height: 25.w), - CommonInput(inputController: controller, hintText: hintText) + CommonInput( + inputController: controller, + hintText: hintText, + validator: validator, + ), ], ), ); @@ -243,11 +250,17 @@ class _VisitorAccessPageState extends State { ) { return MaterialButton( onPressed: () async { - VoidCallback cancel = BotToast.showLoading(); - await ManagerFunc.insertVisitorInfo(id, type, _userName.text, - _selectSex, tel, _userCarNum.text, dateTime); - cancel(); - Get.off(VisitorRecordPage()); + if (formKey.currentState.validate()) { + if (dateTime == null) { + BotToast.showText(text: '请选择到访时间'); + return; + } + VoidCallback cancel = BotToast.showLoading(); + await ManagerFunc.insertVisitorInfo(id, type, _userName.text, + _selectSex, tel, _userCarNum.text, dateTime); + cancel(); + Get.off(VisitorRecordPage()); + } }, minWidth: double.infinity, height: 96.w, @@ -293,8 +306,8 @@ class _VisitorAccessPageState extends State { child: '访客记录'.text.black.size(28.sp).make(), ) ], - body: Container( - color: Colors.white, + body: Form( + key: formKey, child: ListView( children: [ SingleChildScrollView( @@ -309,9 +322,23 @@ class _VisitorAccessPageState extends State { S.of(context).tempPlotName, appProvider.selectedHouse.roomName, ), - _input('访客姓名', '请输入访客姓名', _userName), + _input( + '访客姓名', + '请输入访客姓名', + _userName, + (text) { + if (TextUtil.isEmpty(text)) return '姓名不能为空'; + if (!RegexUtil.isZh(text)) return '姓名包含特殊文字'; + return null; + }, + ), _sexSelect(), - _input('是否驾车', '请输入,例如浙A88888(没有驾车可不填)', _userCarNum), + _input( + '是否驾车', + '请输入,例如浙A88888(没有驾车可不填)', + _userCarNum, + (text) => null, + ), _selectTime(), SizedBox(height: 64.w), _create( @@ -325,7 +352,7 @@ class _VisitorAccessPageState extends State { ), ), ], - ), + ).material(color: Colors.white), ), ); } diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index 73c3d706..fc4d24ee 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -68,7 +68,7 @@ class _AdvicePageState extends State with TickerProviderStateMixin { return index == 0 ? 2 : 1; break; case AdviceType.COMPLAIN: - return index == 0 ? 4 : 3; + return index == 0 ? 3 : 4; break; } return 0; diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index f66d2038..0d34a3f2 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -100,7 +100,7 @@ class _NewAdvicePageState extends State { Future addAdvice(int type, List files, String content) async { VoidCallback cancel = BotToast.showLoading(); List urls = - await NetUtil().uploadFiles(files, API.upload.uploadArticle); + await NetUtil().uploadFiles(files, API.upload.uploadAdvice); BaseModel baseModel = await NetUtil().post( API.manager.addAdvice, params: { @@ -210,7 +210,7 @@ class _NewAdvicePageState extends State { type = _type == 0 ? 2 : 1; break; case AdviceType.COMPLAIN: - type = _type == 0 ? 4 : 3; + type = _type == 0 ? 3 : 4; break; } addAdvice(type, _files, _editingController.text); diff --git a/lib/widget/common_input.dart b/lib/widget/common_input.dart index 4d9b83ac..102226a3 100644 --- a/lib/widget/common_input.dart +++ b/lib/widget/common_input.dart @@ -7,7 +7,9 @@ import 'package:akuCommunity/utils/headers.dart'; class CommonInput extends StatefulWidget { final TextEditingController inputController; final String hintText; - CommonInput({Key key, this.inputController, this.hintText}) : super(key: key); + final FormFieldValidator validator; + CommonInput({Key key, this.inputController, this.hintText, this.validator}) + : super(key: key); @override _CommonInputState createState() => _CommonInputState(); @@ -18,6 +20,7 @@ class _CommonInputState extends State { Widget build(BuildContext context) { return Container( child: TextFormField( + validator: widget.validator, cursorColor: Color(0xffffc40c), style: TextStyle( fontWeight: FontWeight.w600, diff --git a/lib/widget/views/horizontal_image_view.dart b/lib/widget/views/horizontal_image_view.dart index 27cddc12..c407a74d 100644 --- a/lib/widget/views/horizontal_image_view.dart +++ b/lib/widget/views/horizontal_image_view.dart @@ -28,10 +28,7 @@ class HorizontalImageView extends StatelessWidget { itemBuilder: (context, index) { return GestureDetector( onTap: () { - Get.to( - BeeImagePreview.path(path: urls[index]), - opaque: false, - ); + BeeImagePreview.toPath(path: urls[index], tag: urls[index]); }, child: Hero( tag: urls[index], diff --git a/pubspec.lock b/pubspec.lock index 40a88c21..0b8abc49 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -582,7 +582,7 @@ packages: name: power_logger url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0-nullsafety.0" + version: "1.0.1-nullsafety.1" process: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f35c4160..ac99d5be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,7 +55,7 @@ dependencies: ref: null-safety image_picker: ^0.7.3 - power_logger: ^1.0.0-nullsafety.0 + power_logger: ^1.0.0-nullsafety.1 flutter_rating_bar: ^4.0.0 jpush_flutter: ^2.0.1 open_file: ^3.1.0