From 87f399aca3561e90da28a975322dd7becf1d36a7 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 29 Mar 2021 09:27:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=91=E7=9A=84=E8=BD=A6?= =?UTF-8?q?=E4=BD=8D=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/app_values.dart | 3 ++ lib/model/user/car_parking_model.dart | 28 ++++++++++++++ lib/pages/home/widget/animate_app_bar.dart | 3 +- lib/pages/sign/sign_in_page.dart | 5 ++- .../things_page/widget/bee_list_view.dart | 2 +- lib/provider/app_provider.dart | 8 ++++ .../profile/car_parking/car_parking_card.dart | 38 +++++++++++++++++-- .../profile/car_parking/car_parking_func.dart | 7 ++++ .../profile/car_parking/car_parking_page.dart | 10 +++-- .../car_parking/manage_car_parking_page.dart | 16 ++++++++ .../car_parking/mange_card_parking_card.dart | 10 +++++ lib/ui/profile/house/add_house_page.dart | 3 +- lib/ui/profile/house/house_card.dart | 3 +- lib/ui/profile/house/house_owners_page.dart | 17 +++++++-- lib/ui/profile/house/pick_my_house_page.dart | 3 +- 15 files changed, 139 insertions(+), 17 deletions(-) create mode 100644 lib/constants/app_values.dart create mode 100644 lib/model/user/car_parking_model.dart create mode 100644 lib/ui/profile/car_parking/car_parking_func.dart create mode 100644 lib/ui/profile/car_parking/manage_car_parking_page.dart create mode 100644 lib/ui/profile/car_parking/mange_card_parking_card.dart diff --git a/lib/constants/app_values.dart b/lib/constants/app_values.dart new file mode 100644 index 00000000..f847d3f5 --- /dev/null +++ b/lib/constants/app_values.dart @@ -0,0 +1,3 @@ +class AppValues { + static const String plotName = '人才公寓智慧小区'; +} diff --git a/lib/model/user/car_parking_model.dart b/lib/model/user/car_parking_model.dart new file mode 100644 index 00000000..d22f4754 --- /dev/null +++ b/lib/model/user/car_parking_model.dart @@ -0,0 +1,28 @@ +import 'package:flustars/flustars.dart'; + +class CarParkingModel { + String code; + int type; + String effectiveTimeEnd; + DateTime get effectiveDate => DateUtil.getDateTime(effectiveTimeEnd); + bool get outdated { + DateTime now = DateTime.now(); + return effectiveDate.isAfter(now); + } + + CarParkingModel({this.code, this.type, this.effectiveTimeEnd}); + + CarParkingModel.fromJson(Map json) { + code = json['code']; + type = json['type']; + effectiveTimeEnd = json['effectiveTimeEnd']; + } + + Map toJson() { + final Map data = new Map(); + data['code'] = this.code; + data['type'] = this.type; + data['effectiveTimeEnd'] = this.effectiveTimeEnd; + return data; + } +} diff --git a/lib/pages/home/widget/animate_app_bar.dart b/lib/pages/home/widget/animate_app_bar.dart index 77eaf554..35f91fbf 100644 --- a/lib/pages/home/widget/animate_app_bar.dart +++ b/lib/pages/home/widget/animate_app_bar.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/constants/app_values.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -39,7 +40,7 @@ class _AnimateAppBarState extends State { Widget build(BuildContext context) { final appProvider = Provider.of(context); return AppBar( - title: Text('人才公寓智慧小区'), + title: Text(AppValues.plotName), backgroundColor: _bgColor, leading: Container( margin: EdgeInsets.only(left: 32.w), diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index a6734e57..b4316450 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -240,7 +240,10 @@ class _SignInPageState extends State { controller: _code, suffix: MaterialButton( height: 82.w, - shape: StadiumBorder(), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.horizontal(right: Radius.circular(41.w)), + ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, child: Text( _timer?.isActive ?? false diff --git a/lib/pages/things_page/widget/bee_list_view.dart b/lib/pages/things_page/widget/bee_list_view.dart index 1f48423f..15930a27 100644 --- a/lib/pages/things_page/widget/bee_list_view.dart +++ b/lib/pages/things_page/widget/bee_list_view.dart @@ -98,7 +98,7 @@ class _BeeListViewState extends State { ); _models = widget.convert(_model); widget.controller?.resetLoadState(); - setState(() {}); + if(mounted)setState(() {}); }, firstRefresh: true, onLoad: () async { diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 4126fb40..fa061004 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/user/car_parking_model.dart'; import 'package:akuCommunity/model/user/house_model.dart'; import 'package:flutter/material.dart'; @@ -201,4 +202,11 @@ class AppProvider extends ChangeNotifier { _selectedHouse = model; notifyListeners(); } + + List _carParkingModels = []; + List get carParkingModels => _carParkingModels; + updateCarParkingModels(List models) { + _carParkingModels = models; + notifyListeners(); + } } diff --git a/lib/ui/profile/car_parking/car_parking_card.dart b/lib/ui/profile/car_parking/car_parking_card.dart index 3e62b740..2db87359 100644 --- a/lib/ui/profile/car_parking/car_parking_card.dart +++ b/lib/ui/profile/car_parking/car_parking_card.dart @@ -1,12 +1,14 @@ +import 'package:akuCommunity/constants/app_values.dart'; +import 'package:akuCommunity/model/user/car_parking_model.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter/material.dart'; class CarparkingCard extends StatelessWidget { - final bool outdated; - const CarparkingCard({Key key, @required this.outdated}) : super(key: key); + final CarParkingModel model; + const CarparkingCard({Key key, @required this.model}) : super(key: key); String get _assetImage { - return outdated + return model.outdated ? R.ASSETS_STATIC_PARKING_GREY_WEBP : R.ASSETS_STATIC_PARKING_YELLOW_WEBP; } @@ -16,11 +18,39 @@ class CarparkingCard extends StatelessWidget { return AspectRatio( aspectRatio: 688 / 286, child: Container( + padding: EdgeInsets.all(40.w), child: Column( - children: [], + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '地上车位B0001', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 36.sp, + ), + ), + Text( + AppValues.plotName, + style: Theme.of(context) + .textTheme + .subtitle2 + .copyWith(color: Color(0xFF999999)), + ), + Spacer(), + Row( + children: [ + Column( + children: [ + Text('类型'), + ], + ), + ], + ), + ], ), decoration: BoxDecoration( image: DecorationImage(image: AssetImage(_assetImage)), + borderRadius: BorderRadius.circular(4.w), ), ), ); diff --git a/lib/ui/profile/car_parking/car_parking_func.dart b/lib/ui/profile/car_parking/car_parking_func.dart new file mode 100644 index 00000000..86c20f10 --- /dev/null +++ b/lib/ui/profile/car_parking/car_parking_func.dart @@ -0,0 +1,7 @@ +import 'package:akuCommunity/model/user/car_parking_model.dart'; + +class CarParkingFunc { + static Future getCarParkingModels() async { + // return + } +} diff --git a/lib/ui/profile/car_parking/car_parking_page.dart b/lib/ui/profile/car_parking/car_parking_page.dart index 3e52bbd5..316af20a 100644 --- a/lib/ui/profile/car_parking/car_parking_page.dart +++ b/lib/ui/profile/car_parking/car_parking_page.dart @@ -1,8 +1,10 @@ +import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/ui/profile/car_parking/car_parking_card.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:provider/provider.dart'; class CarParkingPage extends StatefulWidget { CarParkingPage({Key key}) : super(key: key); @@ -35,6 +37,7 @@ class _CarParkingPageState extends State { @override Widget build(BuildContext context) { + final appProvider = Provider.of(context); return BeeScaffold( title: '我的车位', actions: [ @@ -46,14 +49,15 @@ class _CarParkingPageState extends State { body: EasyRefresh( onRefresh: () async {}, header: MaterialHeader(), - // emptyWidget: _renderEmptyWidget, + emptyWidget: + appProvider.carParkingModels.isEmpty ? _renderEmptyWidget : null, child: ListView.separated( separatorBuilder: (context, index) => 32.hb, itemBuilder: (context, index) { - return CarparkingCard(outdated: false); + return CarparkingCard(model: appProvider.carParkingModels[index]); }, padding: EdgeInsets.all(32.w), - itemCount: 2, + itemCount: appProvider.carParkingModels.length, ), ), ); diff --git a/lib/ui/profile/car_parking/manage_car_parking_page.dart b/lib/ui/profile/car_parking/manage_car_parking_page.dart new file mode 100644 index 00000000..c0a448d0 --- /dev/null +++ b/lib/ui/profile/car_parking/manage_car_parking_page.dart @@ -0,0 +1,16 @@ +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; + +class ManageCarParkingPage extends StatefulWidget { + ManageCarParkingPage({Key key}) : super(key: key); + + @override + _ManageCarParkingPageState createState() => _ManageCarParkingPageState(); +} + +class _ManageCarParkingPageState extends State { + @override + Widget build(BuildContext context) { + return BeeScaffold(title: '我的车位'); + } +} diff --git a/lib/ui/profile/car_parking/mange_card_parking_card.dart b/lib/ui/profile/car_parking/mange_card_parking_card.dart new file mode 100644 index 00000000..0bddd13d --- /dev/null +++ b/lib/ui/profile/car_parking/mange_card_parking_card.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class ManageCarParkingCard extends StatelessWidget { + const ManageCarParkingCard({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/ui/profile/house/add_house_page.dart b/lib/ui/profile/house/add_house_page.dart index 9447ef0c..9401c16f 100644 --- a/lib/ui/profile/house/add_house_page.dart +++ b/lib/ui/profile/house/add_house_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/constants/app_values.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -170,7 +171,7 @@ class _AddHousePageState extends State { _renderTile( title: '小区名称', item: _renderPicker( - text: '人才公寓智慧小区', + text: AppValues.plotName, hintText: '请选择小区', // 跳转到选择小区页面 // TODO 小区页面 diff --git a/lib/ui/profile/house/house_card.dart b/lib/ui/profile/house/house_card.dart index 885c1860..1d2970b6 100644 --- a/lib/ui/profile/house/house_card.dart +++ b/lib/ui/profile/house/house_card.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/model/user/house_model.dart'; import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart'; import 'package:flutter/material.dart'; @@ -118,7 +119,7 @@ class HouseCard extends StatelessWidget { ), 12.hb, Text( - '人才公寓智慧小区', + AppValues.plotName, style: Theme.of(context).textTheme.headline3, ), 10.hb, diff --git a/lib/ui/profile/house/house_owners_page.dart b/lib/ui/profile/house/house_owners_page.dart index f1b88076..f949270a 100644 --- a/lib/ui/profile/house/house_owners_page.dart +++ b/lib/ui/profile/house/house_owners_page.dart @@ -75,11 +75,20 @@ class _HouseOwnersPageState extends State { ), if (!_emptyHouse) 88.hb, if (!_haveAuthedHouse) - Padding( - padding: EdgeInsets.symmetric(horizontal: 75.w), - child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP), + Stack( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 75.w), + child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP), + ), + Positioned( + bottom: 100.w, + left: 0, + right: 0, + child: _houseTitle.centered(), + ), + ], ), - Center(child: _houseTitle), if (_emptyHouse) Center( child: ElevatedButton( diff --git a/lib/ui/profile/house/pick_my_house_page.dart b/lib/ui/profile/house/pick_my_house_page.dart index dfcb00a5..37b159d6 100644 --- a/lib/ui/profile/house/pick_my_house_page.dart +++ b/lib/ui/profile/house/pick_my_house_page.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/model/user/house_model.dart'; import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/ui/profile/house/add_house_page.dart'; @@ -190,7 +191,7 @@ class _HouseCard extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - '人才公寓智慧小区', + AppValues.plotName, style: Theme.of(context).textTheme.subtitle1.copyWith( color: highlight ? Color(0xFFFF8200) : Color(0xFF333333),