diff --git a/lib/painters/upload_painter.dart b/lib/painters/upload_painter.dart new file mode 100644 index 00000000..61a38fd4 --- /dev/null +++ b/lib/painters/upload_painter.dart @@ -0,0 +1,47 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class UploadPainter extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + Paint paint = Paint() + ..strokeWidth = 20.w + ..color = Color(0xFFDEE1EB) + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round; + Path path = Path(); + Rect rect = Rect.fromCircle(center: Offset(50.w, 100.w), radius: 40.w); + path.arcTo(rect, pi / 2, pi, true); + Rect rect2 = Rect.fromCircle(center: Offset(100.w, 60.w), radius: 50.w); + path.arcTo(rect2, pi, pi ,true); + + Rect rect3= Rect.fromCircle(center: Offset(150.w, 100.w), radius: 40.w); + path.arcTo(rect3, 1.5 * pi, pi , true); + canvas.drawPath(path, paint); + Paint spaint = Paint() + ..strokeWidth = 15.w + ..color = Color(0xFFC3CCEA) + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round; + Path spath = Path(); + spath.moveTo(100.w, 110.w); + spath.lineTo(75.w, 135.w); + spath.moveTo(100.w, 110.w); + spath.lineTo(125.w, 135.w); + spath.moveTo(100.w, 110.w); + spath.lineTo(100.w, 170.w); + canvas.drawPath(spath, spaint); + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return false; + } + + @override + bool shouldRebuildSemantics(CustomPainter oldDelegate) { + return false; + } +} diff --git a/lib/ui/community/notice/notice_detail_page.dart b/lib/ui/community/notice/notice_detail_page.dart index 9035455d..b96e7e90 100644 --- a/lib/ui/community/notice/notice_detail_page.dart +++ b/lib/ui/community/notice/notice_detail_page.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/widget/views/%20bee_download_view.dart'; +import 'package:aku_community/widget/views/doc_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -13,7 +15,6 @@ import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/picker/bee_image_preview.dart'; -import 'package:aku_community/widget/views/%20bee_download_view.dart'; class NoticeDetailPage extends StatefulWidget { final int? id; @@ -31,38 +32,6 @@ class _NoticeDetailPageState extends State { children: [], ); - Widget docView(String title, String? path) { - // if (title?.isEmpty ?? true) return SizedBox(); - return Container( - margin: EdgeInsets.only(right: 113.w), - alignment: Alignment.centerLeft, - child: MaterialButton( - minWidth: 606.w, - height: 154.w, - padding: EdgeInsets.symmetric(horizontal: 32.w), - child: Row( - children: [ - title.text.size(32.sp).make().expand(), - Image.asset( - R.ASSETS_ICONS_FILE_PNG, - height: 52.w, - width: 52.w, - ), - ], - ), - onPressed: () async { - String? result = await Get.dialog(BeeDownloadView(file: path)); - if (result != null) OpenFile.open(result); - }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.w), - side: BorderSide(color: Color(0xFFD4CFBE)), - ), - color: Colors.white, - ), - ); - } - @override Widget build(BuildContext context) { return BeeScaffold( @@ -119,7 +88,16 @@ class _NoticeDetailPageState extends State { 44.hb, model!.content!.text.size(28.sp).make(), 43.hb, - docView(model?.fileDocName ?? '', model!.fileDocUrl), + DocViw( + title: model?.fileDocName ?? '', + onPressed: () async { + String? result = await Get.dialog(BeeDownloadView( + file: model!.fileDocUrl, + )); + if (result != null) OpenFile.open(result); + + }, + ), ], ), ).material(color: Colors.white), diff --git a/lib/ui/profile/house/download_contract_page.dart b/lib/ui/profile/house/download_contract_page.dart index 39dac93c..c3316ca2 100644 --- a/lib/ui/profile/house/download_contract_page.dart +++ b/lib/ui/profile/house/download_contract_page.dart @@ -1,8 +1,10 @@ import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/ui/profile/house/upload_contracts_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/others/finish_result_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class DownLoadContractPage extends StatefulWidget { @@ -33,25 +35,38 @@ class _DownLoadContractPageState extends State { '请下载合同'.text.size(26.sp).color(ktextSubColor).make(), '完善信息并盖章后再上传合同'.text.size(26.sp).color(ktextSubColor).make(), 126.w.heightBox, - Row( - children: [ - MaterialButton( - color: Colors.white, - elevation: 0, - padding: EdgeInsets.symmetric(vertical:16.w ,horizontal: 78.w), - onPressed: () {}, - child: - '下载合同'.text.size(32.sp).bold.color(ktextPrimary).make(), - ).expand(), - MaterialButton( - padding: EdgeInsets.symmetric(vertical:16.w ,horizontal: 78.w), - elevation: 0, - color: kPrimaryColor, - onPressed: () {}, - child: - '上传文件'.text.size(32.sp).bold.color(ktextPrimary).make(), - ) - ], + Padding( + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + MaterialButton( + color: Colors.white, + elevation: 0, + minWidth: 280.w, + shape: RoundedRectangleBorder( + side: BorderSide(color: Color(0xFF666666), width: 1.w)), + padding: + EdgeInsets.symmetric(vertical: 16.w, horizontal: 78.w), + onPressed: () {}, + child: + '下载合同'.text.size(32.sp).bold.color(ktextPrimary).make(), + ), + 62.w.widthBox, + MaterialButton( + minWidth: 280.w, + padding: + EdgeInsets.symmetric(vertical: 16.w, horizontal: 78.w), + elevation: 0, + color: kPrimaryColor, + onPressed: () { + Get.to(() => UploadContractsPage()); + }, + child: + '上传文件'.text.size(32.sp).bold.color(ktextPrimary).make(), + ) + ], + ), ), ], ), diff --git a/lib/ui/profile/house/upload_contracts_page.dart b/lib/ui/profile/house/upload_contracts_page.dart new file mode 100644 index 00000000..af3fb503 --- /dev/null +++ b/lib/ui/profile/house/upload_contracts_page.dart @@ -0,0 +1,141 @@ +import 'dart:io'; + +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/painters/upload_painter.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:aku_community/widget/buttons/bottom_button.dart'; +import 'package:aku_community/widget/picker/bee_image_picker.dart'; +import 'package:aku_community/widget/views/doc_view.dart'; +import 'package:dotted_border/dotted_border.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:open_file/open_file.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:aku_community/extensions/widget_list_ext.dart'; + +class UploadContractsPage extends StatefulWidget { + UploadContractsPage({Key? key}) : super(key: key); + + @override + _UploadContractsPageState createState() => _UploadContractsPageState(); +} + +class _UploadContractsPageState extends State { + List _files = []; + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '上传文件', + body: ListView( + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), + children: [ + 100.w.heightBox, + _uploadWidget(), + 64.w.heightBox, + Padding( + padding: EdgeInsets.symmetric(horizontal: 60.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ..._files + .map( + (e) => DocViw( + title: e.path.split('/').last, + margin: EdgeInsets.zero, + onLongPress: () async { + var deleteSheet = CupertinoActionSheet( + title: '删除文件' + .text + .size(28.sp) + .bold + .isIntrinsic + .color(ktextPrimary) + .make(), + actions: [ + CupertinoActionSheetAction( + onPressed: () { + _files.remove(e); + Get.back(); + setState(() {}); + }, + child: '删除' + .text + .size(32.sp) + .isIntrinsic + .bold + .color(kDangerColor) + .make()) + ], + ); + await Get.bottomSheet( + deleteSheet, + ); + }, + onPressed: () async { + await OpenFile.open(e.path); + }, + ), + ) + .toList() + ].sepWidget(separate: 12.w.heightBox), + ), + ) + ], + ), + bottomNavi: BottomButton( + onPressed: () {}, + child: '提交审核'.text.size(32.sp).color(ktextPrimary).bold.make()), + ); + } + + Widget _uploadWidget() { + return GestureDetector( + onTap: () async { + File? _file = await BeeImagePicker.pick(title: '选择合同照片'); + if (_file != null) { + _files.add(_file); + setState(() {}); + } + }, + child: Center( + child: DottedBorder( + dashPattern: [6, 4], + child: Container( + width: 500.w, + height: 500.w, + color: Color(0x19C4C4C4), + alignment: Alignment.center, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 87.w.heightBox, + SizedBox( + width: 200.w, + height: 200.w, + child: CustomPaint( + painter: UploadPainter(), + ), + ), + 43.w.heightBox, + '点击上传文件' + .text + .size(32.sp) + .color(Color(0xFFADB2C4)) + .bold + .make(), + 43.w.heightBox, + '仅支持PDF、PNG、JPG格式的文件' + .text + .size(28.sp) + .color(Color(0x999999)) + .make(), + ], + ), + )), + ), + ); + } +} diff --git a/lib/utils/websocket/fire_dialog.dart b/lib/utils/websocket/fire_dialog.dart index 6dd75d56..7bc1d7db 100644 --- a/lib/utils/websocket/fire_dialog.dart +++ b/lib/utils/websocket/fire_dialog.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/pages/tab_navigator.dart'; +import 'package:aku_community/utils/developer_util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -25,9 +27,16 @@ class FireDialog { child: Text('确认'), onPressed: () => Get.back(), ), + if (DeveloperUtil.dev) + CupertinoDialogAction( + child: Text('清除所有弹窗'), + onPressed: () => Get.offAll( + () => TabNavigator(), + ), + ), ], ), barrierDismissible: false, ); } -} \ No newline at end of file +} diff --git a/lib/widget/others/finish_result_image.dart b/lib/widget/others/finish_result_image.dart index 6765b989..81656bac 100644 --- a/lib/widget/others/finish_result_image.dart +++ b/lib/widget/others/finish_result_image.dart @@ -25,7 +25,8 @@ class FinishResultImage extends StatelessWidget { this.status! ? CupertinoIcons.checkmark : CupertinoIcons.multiply, - size: 100.w, + size: 70.w, + color: Colors.white, ), ); } diff --git a/lib/widget/views/doc_view.dart b/lib/widget/views/doc_view.dart new file mode 100644 index 00000000..f3611f16 --- /dev/null +++ b/lib/widget/views/doc_view.dart @@ -0,0 +1,50 @@ +import 'package:aku_community/const/resource.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class DocViw extends StatelessWidget { + const DocViw({ + Key? key, + required this.title, + required this.onPressed, + this.margin, this.onLongPress, + }) : super(key: key); + + final String title; + final VoidCallback onPressed; + final EdgeInsetsGeometry? margin; + final VoidCallback? onLongPress; + @override + Widget build(BuildContext context) { + // if (title?.isEmpty ?? true) return SizedBox(); + return GestureDetector( + onLongPress: onLongPress, + child: Container( + margin: margin ?? EdgeInsets.only(right: 113.w), + alignment: Alignment.centerLeft, + child: MaterialButton( + minWidth: 606.w, + height: 154.w, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Row( + children: [ + title.text.size(32.sp).make().expand(), + Image.asset( + R.ASSETS_ICONS_FILE_PNG, + height: 52.w, + width: 52.w, + ), + ], + ), + onPressed: onPressed, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), + side: BorderSide(color: Color(0xFFD4CFBE)), + ), + color: Colors.white, + ), + ), + ); + } +}