From 08f86b30aed1f81a0eb756146aff0eeba380fc90 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 31 Mar 2021 10:35:18 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=85=AC=E5=91=8A=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .fvm/fvm_config.json | 2 +- lib/ui/home/home_notification.dart | 48 +++++++----------------------- pubspec.lock | 7 +++++ pubspec.yaml | 6 +--- 4 files changed, 20 insertions(+), 43 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 309af34c..1c922f80 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,3 @@ { - "flutterSdkVersion": "2.0.0" + "flutterSdkVersion": "stable" } \ No newline at end of file diff --git a/lib/ui/home/home_notification.dart b/lib/ui/home/home_notification.dart index 731cd930..a2f44d7c 100644 --- a/lib/ui/home/home_notification.dart +++ b/lib/ui/home/home_notification.dart @@ -1,6 +1,4 @@ -import 'dart:async'; -import 'dart:math'; - +import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -9,7 +7,6 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/model/community/board_model.dart'; -import 'package:akuCommunity/ui/community/notice/notice_detail_page.dart'; import 'package:akuCommunity/ui/community/notice/notice_page.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -22,26 +19,6 @@ class HomeNotification extends StatefulWidget { } class _HomeNotificationState extends State { - BoardItemModel get randomItem { - if (widget.items.isEmpty) return null; - int index = Random().nextInt(widget.items.length - 1); - return widget.items[index]; - } - - Timer _timer; - - @override - void initState() { - super.initState(); - _timer = Timer.periodic( - Duration(milliseconds: 5000), (timer) => setState(() {})); - } - - @override - void dispose() { - _timer?.cancel(); - super.dispose(); - } @override Widget build(BuildContext context) { @@ -57,20 +34,17 @@ class _HomeNotificationState extends State { 24.wb, widget.items.isEmpty ? Spacer() - : GestureDetector( - onTap: () { - if (randomItem != null) - Get.to(() => NoticeDetailPage(id: randomItem.id)); - }, - child: AnimatedSwitcher( - duration: Duration(milliseconds: 1000), - child: Align( - alignment: Alignment.centerLeft, - key: ObjectKey(randomItem), - child: Text(randomItem?.title ?? ''), - ), + : Container( + alignment: Alignment.centerLeft, + height: 85.w, + child: AnimatedTextKit( + animatedTexts: widget.items + .map((e) => RotateAnimatedText(e.title)) + .toList(), + repeatForever: true, ), - ).expand(), + ), + Spacer(), MaterialButton( shape: StadiumBorder(), padding: EdgeInsets.symmetric(horizontal: 12.w), diff --git a/pubspec.lock b/pubspec.lock index 50d439fc..9ab4aaf2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -24,6 +24,13 @@ packages: url: "http://159.75.73.143:8080/third_packages/amap_flutter_map" source: git version: "2.0.2-nullsafety" + animated_text_kit: + dependency: "direct main" + description: + name: animated_text_kit + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.1" animator: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8d9112f7..81a1dfa3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,17 +12,12 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - # 权限组件 permission_handler: ^6.1.1 - # 版本信息 package_info: ^2.0.0 provider: ^5.0.0 - # 屏幕适配 flutter_screenutil: ^5.0.0-nullsafety.11 cupertino_icons: ^1.0.2 - # 打电话等各种功能 url_launcher: ^6.0.2 - # 工具类 flustars: ^2.0.1 # icons # TODO need remove @@ -70,6 +65,7 @@ dependencies: ref: nullsafety amap_flutter_location: ^1.0.1 amap_flutter_base: ^1.0.2 + animated_text_kit: ^4.1.1 dev_dependencies: flutter_test: From 49991ff863443afed83f832a603e6eb8e3527fe2 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 31 Mar 2021 14:02:18 +0800 Subject: [PATCH 2/9] l10n support --- .gitattributes | 1 + l10n.yaml | 4 ++++ lib/constants/app_values.dart | 6 +++--- lib/l10n/app_zh.arb | 10 ++++++++++ lib/main.dart | 6 ++++-- .../goods_deto_page/deto_code_page/deto_code_page.dart | 5 ++--- .../deto_create_page/deto_create_page.dart | 2 +- lib/pages/home/widget/animate_app_bar.dart | 3 ++- lib/pages/life_pay/life_pay_page.dart | 9 ++++++++- lib/pages/life_pay/widget/life_pay_detail_page.dart | 2 +- lib/pages/life_pay/widget/my_house_page.dart | 5 ++++- .../things_page/widget/add_fixed_submit_page.dart | 3 ++- lib/pages/visitor_access_page/visitor_access_page.dart | 2 +- lib/ui/manager/advice/new_advice_page.dart | 2 +- lib/ui/profile/car/car_manage_card.dart | 2 +- lib/ui/profile/car_parking/car_parking_card.dart | 2 +- lib/ui/profile/house/add_house_page.dart | 2 +- lib/ui/profile/house/house_card.dart | 4 ++-- lib/ui/profile/house/pick_my_house_page.dart | 2 +- lib/utils/headers.dart | 1 + pubspec.lock | 2 +- pubspec.yaml | 2 ++ 22 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 .gitattributes create mode 100644 l10n.yaml create mode 100644 lib/l10n/app_zh.arb diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..ca4b4a72 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.arb diff \ No newline at end of file diff --git a/l10n.yaml b/l10n.yaml new file mode 100644 index 00000000..dff1749c --- /dev/null +++ b/l10n.yaml @@ -0,0 +1,4 @@ +arb-dir: lib/l10n +template-arb-file: app_zh.arb +output-localization-file: app_localizations.dart +output-class: S \ No newline at end of file diff --git a/lib/constants/app_values.dart b/lib/constants/app_values.dart index f847d3f5..f9734570 100644 --- a/lib/constants/app_values.dart +++ b/lib/constants/app_values.dart @@ -1,3 +1,3 @@ -class AppValues { - static const String plotName = '人才公寓智慧小区'; -} +// class AppValues { +// static const String plotName = '人才公寓智慧小区'; +// } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb new file mode 100644 index 00000000..76a6eb9c --- /dev/null +++ b/lib/l10n/app_zh.arb @@ -0,0 +1,10 @@ +{ + "appName": "智慧社区", + "@appName":{ + "description": "应用名称" + }, + "tempPlotName": "人才公寓智慧小区", + "@tempPlotName":{ + "description": "临时使用的小区名称" + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index eae19676..910f65aa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,6 +17,7 @@ import 'package:akuCommunity/provider/cart.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/developer_util.dart'; +import 'package:akuCommunity/utils/headers.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -87,17 +88,18 @@ class _MyAppState extends State { designSize: Size(750, 1334), allowFontScaling: true, builder: () => GetMaterialApp( - title: '智慧社区', + onGenerateTitle: (context) => S.of(context).appName, debugShowCheckedModeBanner: false, theme: AppTheme.theme, home: SplashPage(), //国际化支持 localizationsDelegates: [ + S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - supportedLocales: [const Locale('zh', 'CH')], + supportedLocales: [const Locale('zh')], locale: Locale('zh'), builder: BotToastInit(), navigatorObservers: [BotToastNavigatorObserver()], diff --git a/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart b/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart index b3e05dc9..027fbd87 100644 --- a/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart +++ b/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart @@ -1,13 +1,12 @@ -import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_icons/flutter_icons.dart'; +import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; @@ -25,7 +24,7 @@ class DetoCodePage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - AppValues.plotName, + S.of(Get.context).tempPlotName, style: TextStyle(fontSize: 40.sp, color: Color(0xffffffff)), ), SizedBox(height: 10.w), diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index a0403b3f..0a5885bb 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -109,7 +109,7 @@ class _DetoCreatePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - AppValues.plotName, + S.of(context).tempPlotName, style: TextStyle( fontWeight: FontWeight.w600, fontSize: 32.sp, diff --git a/lib/pages/home/widget/animate_app_bar.dart b/lib/pages/home/widget/animate_app_bar.dart index 35f91fbf..52178048 100644 --- a/lib/pages/home/widget/animate_app_bar.dart +++ b/lib/pages/home/widget/animate_app_bar.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/constants/app_values.dart'; +import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -40,7 +41,7 @@ class _AnimateAppBarState extends State { Widget build(BuildContext context) { final appProvider = Provider.of(context); return AppBar( - title: Text(AppValues.plotName), + title: Text( S.of(context).tempPlotName), backgroundColor: _bgColor, leading: Container( margin: EdgeInsets.only(left: 32.w), diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 6d85a58a..1653faf4 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -82,7 +82,14 @@ class _LifePayPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppValues.plotName.text.black.size(32.sp).bold.make(), + S + .of(context) + .tempPlotName + .text + .black + .size(32.sp) + .bold + .make(), 10.w.heightBox, appProvider.selectedHouse.roomName.text.black .size(32.sp) diff --git a/lib/pages/life_pay/widget/life_pay_detail_page.dart b/lib/pages/life_pay/widget/life_pay_detail_page.dart index 790dd69f..c60bc2fa 100644 --- a/lib/pages/life_pay/widget/life_pay_detail_page.dart +++ b/lib/pages/life_pay/widget/life_pay_detail_page.dart @@ -94,7 +94,7 @@ class _LifePayDetailPageState extends State { children: [ model.name.text.black.size(30.sp).bold.make(), Spacer(), - '${AppValues.plotName} ${userProvider.currentHouse}' + '${S.of(context).tempPlotName} ${userProvider.currentHouse}' .text .color(ktextSubColor) .size(24.sp) diff --git a/lib/pages/life_pay/widget/my_house_page.dart b/lib/pages/life_pay/widget/my_house_page.dart index 760dc20f..4d30a41c 100644 --- a/lib/pages/life_pay/widget/my_house_page.dart +++ b/lib/pages/life_pay/widget/my_house_page.dart @@ -87,7 +87,10 @@ class _MyHousePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - AppValues.plotName.text + S + .of(context) + .tempPlotName + .text .size(24.sp) .color(ktextSubColor) .bold diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 91e66f16..a015f98a 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -4,6 +4,7 @@ import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/ui/profile/house/house_owners_page.dart'; import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -221,7 +222,7 @@ class _AddFixedSubmitPageState extends State { body: ListView( children: [ _buildHouseCard( - AppValues.plotName, + S.of(context).tempPlotName, appProvider.selectedHouse.roomName, ), _getType(), diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index 5f423d40..8b7d3bbd 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -306,7 +306,7 @@ class _VisitorAccessPageState extends State { child: Column( children: [ _buildHouseCard( - AppValues.plotName, + S.of(context).tempPlotName, appProvider.selectedHouse.roomName, ), _input('访客姓名', '请输入访客姓名', _userName), diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index 751fc1aa..f66d2038 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -145,7 +145,7 @@ class _NewAdvicePageState extends State { width: 60.w, ), 40.wb, - '${AppValues.plotName}\n${appProvider.selectedHouse.roomName}' + '${S.of(context).tempPlotName}\n${appProvider.selectedHouse.roomName}' .text .size(32.sp) .black diff --git a/lib/ui/profile/car/car_manage_card.dart b/lib/ui/profile/car/car_manage_card.dart index 123b6201..efb993c3 100644 --- a/lib/ui/profile/car/car_manage_card.dart +++ b/lib/ui/profile/car/car_manage_card.dart @@ -36,7 +36,7 @@ class CarManageCard extends StatelessWidget { ), ), Text( - AppValues.plotName, + S.of(context).tempPlotName, style: Theme.of(context) .textTheme .subtitle2 diff --git a/lib/ui/profile/car_parking/car_parking_card.dart b/lib/ui/profile/car_parking/car_parking_card.dart index 6dbecb69..e3b392ba 100644 --- a/lib/ui/profile/car_parking/car_parking_card.dart +++ b/lib/ui/profile/car_parking/car_parking_card.dart @@ -36,7 +36,7 @@ class CarparkingCard extends StatelessWidget { ), ), Text( - AppValues.plotName, + S.of(context).tempPlotName, style: Theme.of(context) .textTheme .subtitle2 diff --git a/lib/ui/profile/house/add_house_page.dart b/lib/ui/profile/house/add_house_page.dart index 9401c16f..5aa294db 100644 --- a/lib/ui/profile/house/add_house_page.dart +++ b/lib/ui/profile/house/add_house_page.dart @@ -171,7 +171,7 @@ class _AddHousePageState extends State { _renderTile( title: '小区名称', item: _renderPicker( - text: AppValues.plotName, + text: S.of(context).tempPlotName, hintText: '请选择小区', // 跳转到选择小区页面 // TODO 小区页面 diff --git a/lib/ui/profile/house/house_card.dart b/lib/ui/profile/house/house_card.dart index c9e29d15..107b866c 100644 --- a/lib/ui/profile/house/house_card.dart +++ b/lib/ui/profile/house/house_card.dart @@ -109,7 +109,7 @@ class HouseCard extends StatelessWidget { ), ), onPressed: () { - Get.to(()=>PickMyHousePage()); + Get.to(() => PickMyHousePage()); }, shape: RoundedRectangleBorder( borderRadius: @@ -119,7 +119,7 @@ class HouseCard extends StatelessWidget { ), 12.hb, Text( - AppValues.plotName, + S.of(context).tempPlotName, style: Theme.of(context).textTheme.headline3, ), 10.hb, diff --git a/lib/ui/profile/house/pick_my_house_page.dart b/lib/ui/profile/house/pick_my_house_page.dart index 11ea4e16..994aa6ba 100644 --- a/lib/ui/profile/house/pick_my_house_page.dart +++ b/lib/ui/profile/house/pick_my_house_page.dart @@ -196,7 +196,7 @@ class _HouseCard extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - AppValues.plotName, + S.of(context).tempPlotName, style: Theme.of(context).textTheme.subtitle1.copyWith( color: highlight ? Color(0xFFFF8200) : Color(0xFF333333), diff --git a/lib/utils/headers.dart b/lib/utils/headers.dart index 5ccd4463..c0016417 100644 --- a/lib/utils/headers.dart +++ b/lib/utils/headers.dart @@ -3,3 +3,4 @@ export 'package:akuCommunity/extensions/num_ext.dart'; export 'package:akuCommunity/extensions/widget_list_ext.dart'; export 'package:velocity_x/velocity_x.dart'; export 'package:akuCommunity/const/resource.dart'; +export 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/pubspec.lock b/pubspec.lock index 9ab4aaf2..754feb35 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -416,7 +416,7 @@ packages: source: hosted version: "4.4.2" intl: - dependency: transitive + dependency: "direct main" description: name: intl url: "https://pub.flutter-io.cn" diff --git a/pubspec.yaml b/pubspec.yaml index 81a1dfa3..61b47be1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter + intl: ^0.17.0 permission_handler: ^6.1.1 package_info: ^2.0.0 provider: ^5.0.0 @@ -75,6 +76,7 @@ dev_dependencies: flutter: uses-material-design: true + generate: true assets: - assets/ From 857e0c011d26394981bf91344965f287200e1e7e Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 11:26:45 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 1 + .../event_activity/voting_detail_page.dart | 5 +- .../activity/activity_detail_page.dart | 6 +- .../community/notice/notice_detail_page.dart | 8 ++- lib/widget/views/ bee_download_view.dart | 62 +++++++++++++++++++ pubspec.lock | 7 +++ pubspec.yaml | 3 +- 7 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 lib/widget/views/ bee_download_view.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 03c231f7..2acf4a82 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -9,6 +9,7 @@ class API { static String get resource => '$host/static'; static String image(String path) => '$resource$path'; + static String file(String path) => '$resource$path'; static const int networkTimeOut = 10000; static _Login login = _Login(); diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index 98d2b45b..15a54e65 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -219,8 +219,9 @@ class _VotingDetailPageState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(8.w), child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(_model.imgUrls.first.url)), + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(_model.imgUrls.first.url), + ), ), ), 44.w.heightBox, diff --git a/lib/ui/community/activity/activity_detail_page.dart b/lib/ui/community/activity/activity_detail_page.dart index 63f2af2b..59738d7f 100644 --- a/lib/ui/community/activity/activity_detail_page.dart +++ b/lib/ui/community/activity/activity_detail_page.dart @@ -105,12 +105,12 @@ class _ActivityDetailPageState extends State { .map((e) => GestureDetector( onTap: () { Get.to( - BeeImagePreview.path(path: API.image(e.url)), + BeeImagePreview.path(path: e.url), opaque: false, ); }, child: Hero( - tag: API.image(e.url), + tag: e.url, child: Container( height: 228.w, decoration: BoxDecoration( @@ -120,7 +120,7 @@ class _ActivityDetailPageState extends State { clipBehavior: Clip.antiAlias, child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: e.url, + image: API.image(e.url), fit: BoxFit.cover, ), ), diff --git a/lib/ui/community/notice/notice_detail_page.dart b/lib/ui/community/notice/notice_detail_page.dart index e506a485..7d849ef9 100644 --- a/lib/ui/community/notice/notice_detail_page.dart +++ b/lib/ui/community/notice/notice_detail_page.dart @@ -1,7 +1,10 @@ +import 'package:akuCommunity/widget/views/%20bee_download_view.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; +import 'package:open_file/open_file.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/const/resource.dart'; @@ -48,7 +51,10 @@ class _NoticeDetailPageState extends State { ), ], ), - onPressed: () {}, + 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)), diff --git a/lib/widget/views/ bee_download_view.dart b/lib/widget/views/ bee_download_view.dart new file mode 100644 index 00000000..4ed7366d --- /dev/null +++ b/lib/widget/views/ bee_download_view.dart @@ -0,0 +1,62 @@ +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:path_provider/path_provider.dart'; + +import 'package:akuCommunity/constants/api.dart'; + +class BeeDownloadView extends StatefulWidget { + final String file; + BeeDownloadView({Key key, this.file}) : super(key: key); + + @override + _BeeDownloadViewState createState() => _BeeDownloadViewState(); +} + +class _BeeDownloadViewState extends State { + Dio dio = Dio(); + double progress; + Future download() async { + Directory dir = await getApplicationDocumentsDirectory(); + Directory docPath = Directory('${dir.path}/docs'); + if (!await (docPath.exists())) { + await docPath.create(); + } + await Future.delayed(Duration(milliseconds: 500)); + await dio.download( + API.file(widget.file), + '${docPath.path}/${widget.file.split('/').last}', + onReceiveProgress: (start, all) { + setState(() { + progress = start / all; + }); + print('$start,$all'); + }, + ); + Get.back(result: '${docPath.path}/${widget.file.split('/').last}'); + } + + @override + void initState() { + super.initState(); + download(); + } + + @override + Widget build(BuildContext context) { + return Center( + child: Container( + width: 100, + height: 100, + alignment: Alignment.center, + child: CircularProgressIndicator(value: progress), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 754feb35..40a88c21 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -471,6 +471,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0-nullsafety.1" + open_file: + dependency: "direct main" + description: + name: open_file + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.0" package_info: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 61b47be1..d8dea878 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,7 +58,7 @@ dependencies: power_logger: ^1.0.0-nullsafety.0 flutter_rating_bar: ^4.0.0 jpush_flutter: ^2.0.1 - + open_file: ^3.1.0 badges: ^2.0.0-nullsafety.1 amap_flutter_map: git: @@ -67,6 +67,7 @@ dependencies: amap_flutter_location: ^1.0.1 amap_flutter_base: ^1.0.2 animated_text_kit: ^4.1.1 + dev_dependencies: flutter_test: From 5de81e360ae155b2d35010f06488fbd79bec2067 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 14:14:02 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=88=BF=E4=BA=A7=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/user/house_model.dart | 4 ++++ lib/pages/life_pay/life_pay_page.dart | 6 +++--- .../life_pay/widget/life_pay_detail_page.dart | 4 +++- lib/pages/life_pay/widget/my_house_page.dart | 8 +++----- .../widget/add_fixed_submit_page.dart | 2 +- .../visitor_access_page.dart | 2 +- lib/provider/app_provider.dart | 4 ++++ lib/provider/user_provider.dart | 17 +++-------------- lib/ui/profile/house/pick_my_house_page.dart | 17 ++++++++++++++--- 9 files changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/model/user/house_model.dart b/lib/model/user/house_model.dart index 3494de59..199b6d07 100644 --- a/lib/model/user/house_model.dart +++ b/lib/model/user/house_model.dart @@ -5,6 +5,8 @@ class HouseModel { int id; String roomName; + int estateId; + ///1.未审核,3.审核失败,4.审核成功 int status; @@ -87,6 +89,7 @@ class HouseModel { this.type, this.effectiveTimeStart, this.effectiveTimeEnd, + this.estateId, }); HouseModel.fromJson(Map json) { @@ -96,6 +99,7 @@ class HouseModel { type = json['type']; effectiveTimeStart = json['effectiveTimeStart']; effectiveTimeEnd = json['effectiveTimeEnd']; + estateId = json['estateId']; } Map toJson() { diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 1653faf4..d32ebac1 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -69,6 +69,7 @@ class _LifePayPageState extends State { GestureDetector( onTap: () { Get.to(() => PickMyHousePage()); + _controller.callRefresh(); }, child: Row( children: [ @@ -216,6 +217,7 @@ class _LifePayPageState extends State { @override Widget build(BuildContext context) { UserProvider userProvider = Provider.of(context); + final appProvider = Provider.of(context); return BeeScaffold( title: '生活缴费', actions: [ @@ -234,9 +236,7 @@ class _LifePayPageState extends State { body: BeeListView( path: API.manager.dailyPaymentList, controller: _controller, - extraParams: { - 'estateId': userProvider.currentHouseId, - }, + extraParams: {'estateId': appProvider.selectedHouse.estateId}, convert: (model) { _selectPay = List.generate(model.tableList.length, (index) => SelectPay(payCount: 0, payTotal: 0.0)); diff --git a/lib/pages/life_pay/widget/life_pay_detail_page.dart b/lib/pages/life_pay/widget/life_pay_detail_page.dart index c60bc2fa..3899fce4 100644 --- a/lib/pages/life_pay/widget/life_pay_detail_page.dart +++ b/lib/pages/life_pay/widget/life_pay_detail_page.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/constants/app_values.dart'; +import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -86,6 +87,7 @@ class _LifePayDetailPageState extends State { Widget _buildCard(DailyPaymentTypeVos model) { UserProvider userProvider = Provider.of(context); + final appProvider = Provider.of(context); return Container( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), child: Column( @@ -94,7 +96,7 @@ class _LifePayDetailPageState extends State { children: [ model.name.text.black.size(30.sp).bold.make(), Spacer(), - '${S.of(context).tempPlotName} ${userProvider.currentHouse}' + '${S.of(context).tempPlotName} ${appProvider.selectedHouse.estateId}' .text .color(ktextSubColor) .size(24.sp) diff --git a/lib/pages/life_pay/widget/my_house_page.dart b/lib/pages/life_pay/widget/my_house_page.dart index 4d30a41c..273b3836 100644 --- a/lib/pages/life_pay/widget/my_house_page.dart +++ b/lib/pages/life_pay/widget/my_house_page.dart @@ -1,4 +1,3 @@ -import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/material.dart'; @@ -72,14 +71,13 @@ class _MyHousePageState extends State { padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w), child: GestureDetector( onTap: () { - userProvider.setCurrentHouse(estateName); setState(() {}); }, child: Row( children: [ CommonRadio( value: BeeParse.getEstateNameId(estateName), - groupValue: userProvider.currentHouseId, + groupValue: 0, size: 32.w, ), 24.w.widthBox, @@ -125,8 +123,8 @@ class _MyHousePageState extends State { ...userProvider.userDetailModel.estateNames.isEmpty ? [SizedBox()] : userProvider.userDetailModel.estateNames - .map((e) => _buildCard(userProvider.currentHouseId, e, - userProvider.userDetailModel.estateNames.indexOf(e), + .map((e) => _buildCard( + 0, e, userProvider.userDetailModel.estateNames.indexOf(e), paid: widget.needFindPayTag ? false : _unPaidList diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index a015f98a..038484b2 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -237,7 +237,7 @@ class _AddFixedSubmitPageState extends State { List urls = await NetUtil() .uploadFiles(_files, API.upload.uploadRepair); BaseModel baseModel = await ManagerFunc.reportRepairInsert( - appProvider.selectedHouse.id, + appProvider.selectedHouse.estateId, _selectType + 1, _textEditingController.text, urls); diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index 8b7d3bbd..77d019dd 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -315,7 +315,7 @@ class _VisitorAccessPageState extends State { _selectTime(), SizedBox(height: 64.w), _create( - appProvider.selectedHouse.id, + appProvider.selectedHouse.estateId, userProvider.userDetailModel.type, userProvider.userDetailModel.tel, ), diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 29860aa4..031fd2b5 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -186,6 +186,10 @@ class AppProvider extends ChangeNotifier { updateHouses(List items) { if (items == null) return; if (items.isEmpty) return; + _selectedHouse = items.firstWhere( + (element) => element.id == (_selectedHouse?.id ?? -1), + orElse: () => null, + ); _houses = items; notifyListeners(); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 4baee0a5..5e37f756 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -8,7 +8,6 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/user/user_detail_model.dart'; import 'package:akuCommunity/model/user/user_info_model.dart'; import 'package:akuCommunity/pages/sign/sign_func.dart'; -import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; @@ -20,21 +19,20 @@ class UserProvider extends ChangeNotifier { bool get isLogin => _isLogin; bool get isNotLogin => !_isLogin; Future setLogin(int token) async { - final appProvider = Provider.of(Get.context,listen: false); + final appProvider = Provider.of(Get.context, listen: false); _isLogin = true; NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token); HiveStore.appBox.put('token', token); HiveStore.appBox.put('login', true); await updateProfile(); await updateUserDetail(); - await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true) - ? '' - : _userDetailModel?.estateNames?.first); await appProvider.updateHouses(await HouseFunc.houses); notifyListeners(); } logout() { + final appProvider = Provider.of(Get.context, listen: false); + appProvider.setCurrentHouse(null); _isLogin = false; _token = null; _userInfoModel = null; @@ -133,13 +131,4 @@ class UserProvider extends ChangeNotifier { await updateProfile(); } } - - ///设置默认房屋 - String _currentHouse; - int get currentHouseId => BeeParse.getEstateNameId(_currentHouse); - String get currentHouse => BeeParse.getEstateName(_currentHouse); - setCurrentHouse(String house) { - _currentHouse = house; - notifyListeners(); - } } diff --git a/lib/ui/profile/house/pick_my_house_page.dart b/lib/ui/profile/house/pick_my_house_page.dart index 994aa6ba..89c570e9 100644 --- a/lib/ui/profile/house/pick_my_house_page.dart +++ b/lib/ui/profile/house/pick_my_house_page.dart @@ -49,7 +49,10 @@ class _PickMyHousePageState extends State { return SliverList( delegate: SliverChildListDelegate( housesWithoutSelected - .map((e) => _HouseCard(model: e)) + .map((e) => _HouseCard( + model: e, + controller: _refreshController, + )) .toList() .sepWidget( separate: Divider( @@ -82,6 +85,7 @@ class _PickMyHousePageState extends State { child: _HouseCard( model: appProvider.selectedHouse, highlight: true, + controller: _refreshController, ), ), _renderSep, @@ -108,8 +112,13 @@ class _PickMyHousePageState extends State { class _HouseCard extends StatelessWidget { final HouseModel model; final bool highlight; - const _HouseCard({Key key, @required this.model, this.highlight = false}) - : super(key: key); + final EasyRefreshController controller; + const _HouseCard({ + Key key, + @required this.model, + this.highlight = false, + @required this.controller, + }) : super(key: key); bool get canTapSlide { if (model == null) return false; return model.status == 4 || model.status == 3 && !highlight; @@ -147,6 +156,8 @@ class _HouseCard extends StatelessWidget { 'ids': [model.id] }, ); + // if(controller.) + controller.callRefresh(); cancel(); } } From e3dd5ed9e3ebe9f2391c231152d23c94380d017c Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 15:16:33 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=9D=E9=A2=98?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/personal/user_profile_page.dart | 8 +++--- .../community_views/add_new_event_page.dart | 27 ++++++++++++++++--- .../topic/topic_detail_page.dart | 5 +++- .../community_views/widgets/chat_card.dart | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart index 2df4d13a..0d4c1dec 100644 --- a/lib/pages/personal/user_profile_page.dart +++ b/lib/pages/personal/user_profile_page.dart @@ -96,7 +96,7 @@ class _UserProfilePageState extends State { child: ClipOval( child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(userProvider.userInfoModel.imgUrl), + image: API.image(userProvider.userInfoModel?.imgUrl ?? ''), height: 56.w, width: 56.w, fit: BoxFit.cover, @@ -107,7 +107,7 @@ class _UserProfilePageState extends State { ), _buildTile( '姓名', - userProvider.userInfoModel.name.text.make(), + (userProvider.userInfoModel?.name ?? '').text.make(), onPressed: () {}, ), _buildTile( @@ -119,7 +119,9 @@ class _UserProfilePageState extends State { ), _buildTile( '手机号', - TextUtil.hideNumber(userProvider.userInfoModel.tel).text.make(), + TextUtil.hideNumber(userProvider.userInfoModel?.tel ?? '') + .text + .make(), onPressed: () { Get.to(() => UpdateTelPage()); }, diff --git a/lib/ui/community/community_views/add_new_event_page.dart b/lib/ui/community/community_views/add_new_event_page.dart index 1bbfeaf6..a30c576b 100644 --- a/lib/ui/community/community_views/add_new_event_page.dart +++ b/lib/ui/community/community_views/add_new_event_page.dart @@ -18,7 +18,17 @@ import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; class AddNewEventPage extends StatefulWidget { - AddNewEventPage({Key key}) : super(key: key); + final int initTopic; + final String topicName; + AddNewEventPage({Key key}) + : initTopic = null, + topicName = null, + super(key: key); + AddNewEventPage.topic({ + Key key, + @required this.initTopic, + @required this.topicName, + }) : super(key: key); @override _AddNewEventPageState createState() => _AddNewEventPageState(); @@ -40,12 +50,17 @@ class _AddNewEventPageState extends State { } Map params = { - 'gambitId': _hotTopicModel == null ? -1 : _hotTopicModel.id, 'content': content, 'isComment': _commentable ? 1 : 0, 'isPublic': 1, 'imgUrls': imgs, }; + if (widget.initTopic != null) { + params.putIfAbsent('gambitId', () => widget.initTopic); + } else { + params.putIfAbsent( + 'gambitId', () => _hotTopicModel == null ? -1 : _hotTopicModel.id); + } BaseModel baseModel = await NetUtil().post( API.community.addEvent, @@ -187,7 +202,13 @@ class _AddNewEventPageState extends State { _buildSelectable(), Divider(height: 1.w), 28.hb, - _pickTopic(), + if (widget.initTopic == null) _pickTopic(), + Align( + alignment: Alignment.centerLeft, + child: _renderTopic( + HotTopicModel(name: widget.topicName, id: widget.initTopic), + ), + ), ], ).material(color: Colors.white), ); diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 2c65c0e2..96030d89 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -36,7 +36,10 @@ class _TopicDetailPageState extends State { heroTag: 'event_add', onPressed: () async { if (LoginUtil.isNotLogin) return; - bool result = await Get.to(() => AddNewEventPage()); + bool result = await Get.to(() => AddNewEventPage.topic( + topicName: widget.model.summary, + initTopic: widget.model.id, + )); }, child: Icon(Icons.add), ), diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 1a8c6baa..fadd618d 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -345,7 +345,7 @@ class _ChatCardState extends State { shape: StadiumBorder( side: BorderSide(), ), - ), + ).pOnly(top: 10.w), Row( children: [ 64.hb, From 18017af5325c38c611813ba61bb78bd17fda0be5 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 15:32:34 +0800 Subject: [PATCH 6/9] fix vote image --- lib/model/common/img_model.dart | 6 +++++ lib/model/manager/voting_detail_model.dart | 6 +++++ .../event_activity/event_voting_page.dart | 8 ++++--- .../event_activity/voting_detail_page.dart | 23 ++++++++++--------- lib/pages/manager_func.dart | 10 ++++---- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/lib/model/common/img_model.dart b/lib/model/common/img_model.dart index e8a9dd2c..7614a251 100644 --- a/lib/model/common/img_model.dart +++ b/lib/model/common/img_model.dart @@ -15,6 +15,12 @@ class ImgModel { sort = json['sort']; } + static String first(List models) { + if (models == null) return ''; + if (models.isEmpty) return ''; + return models.first.url ?? ''; + } + Map toJson() { final Map data = new Map(); data['url'] = this.url; diff --git a/lib/model/manager/voting_detail_model.dart b/lib/model/manager/voting_detail_model.dart index 47e5e2e2..1d52902e 100644 --- a/lib/model/manager/voting_detail_model.dart +++ b/lib/model/manager/voting_detail_model.dart @@ -9,6 +9,12 @@ class VotingDetailModel { List imgUrls; List appVoteCandidateVos; + String get firstImage { + if (imgUrls == null) return ''; + if (imgUrls.isEmpty) return ''; + return imgUrls.first.url ?? ''; + } + VotingDetailModel( {this.id, this.title, diff --git a/lib/pages/event_activity/event_voting_page.dart b/lib/pages/event_activity/event_voting_page.dart index 2c6085ce..2af5ae42 100644 --- a/lib/pages/event_activity/event_voting_page.dart +++ b/lib/pages/event_activity/event_voting_page.dart @@ -59,9 +59,11 @@ class _EventVotingPageState extends State { width: double.infinity, child: ClipRect( child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image( - model.imgUrls.isNotEmpty ? model.imgUrls.first.url : '')), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image( + model.imgUrls.isNotEmpty ? model.imgUrls.first.url : ''), + fit: BoxFit.cover, + ), ), ), Padding( diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index 15a54e65..5d92488f 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -122,8 +123,12 @@ class _VotingDetailPageState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(4.w), child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(model.imgUrls.first.url)), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image( + ImgModel.first(model.imgUrls), + ), + fit: BoxFit.cover, + ), ), ), 30.w.widthBox, @@ -213,15 +218,11 @@ class _VotingDetailPageState extends State { children: [ _model.title.text.black.size(32.sp).bold.maxLines(2).make(), 44.w.heightBox, - SizedBox( - width: double.infinity, - height: 228.w, - child: ClipRRect( - borderRadius: BorderRadius.circular(8.w), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(_model.imgUrls.first.url), - ), + ClipRRect( + borderRadius: BorderRadius.circular(8.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(_model.firstImage), ), ), 44.w.heightBox, diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index e1f532b9..a3fcae7a 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -169,11 +169,11 @@ class ManagerFunc { } static Future voteDetail(int id) async { - BaseModel baseModel = await NetUtil().get(API.manager.voteDetail, - params: { - 'voteId': 1, - }, - showMessage: false); + BaseModel baseModel = await NetUtil().get( + API.manager.voteDetail, + params: {'voteId': id}, + showMessage: false, + ); return VotingDetailModel.fromJson(baseModel.data); } From ad4f8b41ba13403cec63bddf2a051d4898ac3acf Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 15:41:21 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=95=E7=A5=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=97=A0=E6=B3=95=E6=8A=95=E7=A5=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/event_activity/voting_detail_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index 5d92488f..b41e03dd 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -259,9 +259,9 @@ class _VotingDetailPageState extends State { BotToast.showText(text: '请先选择候选人!'); } else { BaseModel baseModel = - await ManagerFunc.vote(_selectId, widget.id); + await ManagerFunc.vote(widget.id, _selectId); if (baseModel.status) { - Get.dialog(_shouwVoteDialog()); + await Get.dialog(_shouwVoteDialog()); _hasVoted = true; setState(() {}); } else { From de52a4f5d01bc801b8cbe163aa509a1a08a8d23a Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 16:03:34 +0800 Subject: [PATCH 8/9] update image preview --- .../activity/activity_detail_page.dart | 6 +--- lib/widget/picker/bee_image_preview.dart | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/ui/community/activity/activity_detail_page.dart b/lib/ui/community/activity/activity_detail_page.dart index 59738d7f..01343396 100644 --- a/lib/ui/community/activity/activity_detail_page.dart +++ b/lib/ui/community/activity/activity_detail_page.dart @@ -104,15 +104,11 @@ class _ActivityDetailPageState extends State { ...model.imgUrls .map((e) => GestureDetector( onTap: () { - Get.to( - BeeImagePreview.path(path: e.url), - opaque: false, - ); + BeeImagePreview.toPath(path: e.url); }, child: Hero( tag: e.url, child: Container( - height: 228.w, decoration: BoxDecoration( color: Colors.black12, borderRadius: BorderRadius.circular(8.w), diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index 5e8dd8e2..9293daa7 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -9,6 +9,34 @@ import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/constants/api.dart'; class BeeImagePreview extends StatefulWidget { + static Future toFile({@required File file, String tag}) async { + return await navigator.push( + PageRouteBuilder( + opaque: false, + pageBuilder: (context, animation, secondAnimation) { + return FadeTransition( + opacity: animation, + child: BeeImagePreview.file(file: file, tag: tag), + ); + }, + ), + ); + } + + static toPath({@required String path, String tag}) { + navigator.push( + PageRouteBuilder( + opaque: false, + pageBuilder: (context, animation, secondAnimation) { + return FadeTransition( + opacity: animation, + child: BeeImagePreview.path(path: path, tag: tag), + ); + }, + ), + ); + } + final File file; final String path; final String tag; From 61e9dd5666e91708dc7afe20028438c0e77b9b36 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 1 Apr 2021 16:20:04 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/community/activity/activity_card.dart | 2 +- .../community_views/widgets/chat_card.dart | 7 +++--- .../widgets/my_event_card.dart | 14 +++++------- lib/ui/community/notice/notice_card.dart | 22 +++++++++++-------- .../community/notice/notice_detail_page.dart | 6 +---- lib/utils/login_util.dart | 3 ++- lib/widget/views/bee_grid_image_view.dart | 5 +---- 7 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/ui/community/activity/activity_card.dart b/lib/ui/community/activity/activity_card.dart index 352ce8f3..c9cd443d 100644 --- a/lib/ui/community/activity/activity_card.dart +++ b/lib/ui/community/activity/activity_card.dart @@ -41,7 +41,7 @@ class ActivityCard extends StatelessWidget { firstPath == null ? SizedBox() : Hero( - tag: API.image(firstPath), + tag: firstPath, child: Material( color: Colors.grey, child: FadeInImage.assetNetwork( diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index fadd618d..1ed60867 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -65,9 +66,9 @@ class _ChatCardState extends State { borderRadius: BorderRadius.circular(8.w), ), onPressed: () { - Get.to( - BeeImagePreview.path(path: widget.model.imgUrls.first.url), - opaque: false, + BeeImagePreview.toPath( + path: ImgModel.first(widget.model.imgUrls), + tag: ImgModel.first(widget.model.imgUrls), ); }, child: ConstrainedBox( diff --git a/lib/ui/community/community_views/widgets/my_event_card.dart b/lib/ui/community/community_views/widgets/my_event_card.dart index 16dba44a..4b64f147 100644 --- a/lib/ui/community/community_views/widgets/my_event_card.dart +++ b/lib/ui/community/community_views/widgets/my_event_card.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -76,16 +77,13 @@ class MyEventCard extends StatelessWidget { ? SizedBox(height: 152.w) : GestureDetector( onTap: () { - Get.to( - BeeImagePreview.path( - path: model.imgUrl.first.url, - tag: API.image(model.imgUrl.first.url), - ), - opaque: false, + BeeImagePreview.toPath( + path: ImgModel.first(model.imgUrl), + tag: ImgModel.first(model.imgUrl), ); }, child: Hero( - tag: API.image(model.imgUrl.first.url), + tag: ImgModel.first(model.imgUrl), child: Container( clipBehavior: Clip.antiAlias, decoration: BoxDecoration( @@ -94,7 +92,7 @@ class MyEventCard extends StatelessWidget { ), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(model.imgUrl.first.url), + image: API.image(ImgModel.first(model.imgUrl)), width: 152.w, height: 152.w, fit: BoxFit.cover, diff --git a/lib/ui/community/notice/notice_card.dart b/lib/ui/community/notice/notice_card.dart index d3756121..eeea3df3 100644 --- a/lib/ui/community/notice/notice_card.dart +++ b/lib/ui/community/notice/notice_card.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; @@ -84,9 +85,9 @@ class NoticeCard extends StatelessWidget { ? SizedBox(height: 152.w) : GestureDetector( onTap: () { - Get.to( - BeeImagePreview.path(path: model.imgUrls.first.url), - opaque: false, + BeeImagePreview.toPath( + path: ImgModel.first(model.imgUrls), + tag: ImgModel.first(model.imgUrls), ); }, child: Container( @@ -95,12 +96,15 @@ class NoticeCard extends StatelessWidget { color: Colors.black12, borderRadius: BorderRadius.circular(8.w), ), - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(model.imgUrls.first.url), - width: 152.w, - height: 152.w, - fit: BoxFit.cover, + child: Hero( + tag: ImgModel.first(model.imgUrls), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: ImgModel.first(model.imgUrls), + width: 152.w, + height: 152.w, + fit: BoxFit.cover, + ), ), ), ), diff --git a/lib/ui/community/notice/notice_detail_page.dart b/lib/ui/community/notice/notice_detail_page.dart index 7d849ef9..e119b551 100644 --- a/lib/ui/community/notice/notice_detail_page.dart +++ b/lib/ui/community/notice/notice_detail_page.dart @@ -92,15 +92,11 @@ class _NoticeDetailPageState extends State { .map( (e) => GestureDetector( onTap: () { - Get.to( - BeeImagePreview.path(path: e.url), - opaque: false, - ); + BeeImagePreview.toPath(path: e.url, tag: e.url); }, child: Hero( tag: e.url, child: Container( - height: 228.w, clipBehavior: Clip.antiAlias, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.w), diff --git a/lib/utils/login_util.dart b/lib/utils/login_util.dart index a97aeac4..56a80f4e 100644 --- a/lib/utils/login_util.dart +++ b/lib/utils/login_util.dart @@ -32,7 +32,8 @@ class LoginUtil { static bool get isNotLogin => !isLogin; static bool haveRoom(String name) { - if (!name.contains(RegExp('访客邀请|报事报修|建议咨询|生活缴费|物品出门|投诉表扬|我的访客|我的报修'))) return true; + if (!name.contains(RegExp('访客邀请|报事报修|建议咨询|生活缴费|物品出门|投诉表扬|我的访客|我的报修|我的缴费'))) + return true; final appProvider = Provider.of(Get.context, listen: false); if (appProvider.selectedHouse == null) { BotToast.showText(text: '请先添加房屋'); diff --git a/lib/widget/views/bee_grid_image_view.dart b/lib/widget/views/bee_grid_image_view.dart index ed9594ef..a0b3fa61 100644 --- a/lib/widget/views/bee_grid_image_view.dart +++ b/lib/widget/views/bee_grid_image_view.dart @@ -29,10 +29,7 @@ class BeeGridImageView 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],