diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 61906438..03c231f7 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -75,6 +75,12 @@ class _User { ///我的房屋:假删除审核信息 String get deleteHouse => '/user/myHouse/falseDelete'; + + ///我的车位:查询所有的车位信息 + String get carParkingList => '/user/myParkingSpace/list'; + + ///我的车辆:查询所有的车辆 + String get carList => '/user/myCar/list'; } class _Manager { diff --git a/lib/constants/app_theme.dart b/lib/constants/app_theme.dart index 708d16b1..25244a9e 100644 --- a/lib/constants/app_theme.dart +++ b/lib/constants/app_theme.dart @@ -21,6 +21,10 @@ class AppTheme { fontSize: 28.sp, color: Color(0xFF333333), ), + bodyText1: TextStyle( + fontSize: 24.sp, + color: Color(0xFF333333), + ), ), floatingActionButtonTheme: FloatingActionButtonThemeData().copyWith( backgroundColor: Color(0xFFFFD000), diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index c66808e5..9b5eba41 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/ui/profile/car/car_manage_page.dart'; import 'package:akuCommunity/ui/profile/car_parking/car_parking_page.dart'; import 'package:flutter/material.dart'; @@ -78,7 +79,7 @@ List appObjects = [ List userAppObjects = [ AO('我的房屋', R.ASSETS_ICONS_USER_ICON_WDFW_PNG, () => HouseOwnersPage()), AO('我的车位', R.ASSETS_ICONS_USER_ICON_WDCW_PNG, () => CarParkingPage()), - AO('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () => CarParkingPage()), + AO('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () => CarManagePage()), AO('社区活动', R.ASSETS_ICONS_USER_ICON_WDSQHD_PNG, () => ActivityListPage()), AO('我的缴费', R.ASSETS_ICONS_USER_ICON_WDJF_PNG, () => LifePayPage()), AO('我的报修', R.ASSETS_ICONS_USER_ICON_WDBX_PNG, () => FixedSubmitPage()), diff --git a/lib/model/user/car_parking_model.dart b/lib/model/user/car_parking_model.dart index d22f4754..6a62adc2 100644 --- a/lib/model/user/car_parking_model.dart +++ b/lib/model/user/car_parking_model.dart @@ -1,15 +1,75 @@ import 'package:flustars/flustars.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; class CarParkingModel { String code; int type; String effectiveTimeEnd; - DateTime get effectiveDate => DateUtil.getDateTime(effectiveTimeEnd); + String get typeName { + switch (type) { + case 1: + return '产权车位'; + case 2: + return '临时车位'; + default: + return '未知'; + } + } + + String get carTypeName { + switch (type) { + case 1: + return '产权车位'; + case 2: + return '包年'; + case 3: + return '包月'; + case 4: + return '临时'; + default: + return '未知'; + } + } + + String get dateName { + if (effectiveTimeEnd == null) return '永久'; + if (outdated) return '$effectiveDateValue(已过期)'; + return effectiveDateValue; + } + + DateTime get effectiveDate { + if (effectiveTimeEnd == null) return null; + return DateUtil.getDateTime(effectiveTimeEnd); + } + + String get effectiveDateValue => + DateUtil.formatDate(effectiveDate, format: 'yyyy-MM-dd'); + bool get outdated { + if (effectiveDate == null) return false; DateTime now = DateTime.now(); return effectiveDate.isAfter(now); } + List get shadow { + if (!outdated) + return [ + BoxShadow( + offset: Offset(0, 10.w), + blurRadius: 30.w, + color: Color(0xFFFFF0BF), + ) + ]; + return [ + BoxShadow( + offset: Offset(0, 10.w), + blurRadius: 30.w, + color: Color(0xFFF0F0F0), + ) + ]; + } + CarParkingModel({this.code, this.type, this.effectiveTimeEnd}); CarParkingModel.fromJson(Map json) { diff --git a/lib/model/user/house_model.dart b/lib/model/user/house_model.dart index 2128e670..3494de59 100644 --- a/lib/model/user/house_model.dart +++ b/lib/model/user/house_model.dart @@ -32,7 +32,7 @@ class HouseModel { String get houseStatus { if (status == 1) return '审核中'; - if (status == 3) return '审核失败'; + if (status == 3) return '未通过'; if (type == 1) return '业主'; if (type == 2) return '亲属'; if (type == 3) return '租客'; diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index fa061004..d698727f 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -205,8 +205,23 @@ class AppProvider extends ChangeNotifier { List _carParkingModels = []; List get carParkingModels => _carParkingModels; - updateCarParkingModels(List models) { - _carParkingModels = models; + Future updateCarParkingModels() async { + BaseModel baseModel = await NetUtil().get(API.user.carParkingList); + if (baseModel?.data == null) return []; + _carParkingModels = (baseModel.data as List) + .map((e) => CarParkingModel.fromJson(e)) + .toList(); + notifyListeners(); + } + + List _carModels = []; + List get carModels => _carModels; + Future updateCarModels() async { + BaseModel baseModel = await NetUtil().get(API.user.carList); + if (baseModel?.data == null) return []; + _carModels = (baseModel.data as List) + .map((e) => CarParkingModel.fromJson(e)) + .toList(); notifyListeners(); } } diff --git a/lib/ui/profile/car/car_manage_card.dart b/lib/ui/profile/car/car_manage_card.dart new file mode 100644 index 00000000..37d37302 --- /dev/null +++ b/lib/ui/profile/car/car_manage_card.dart @@ -0,0 +1,88 @@ +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 CarManageCard extends StatelessWidget { + final CarParkingModel model; + const CarManageCard({Key key, @required this.model}) : super(key: key); + + String get _assetImage { + return model.outdated + ? R.ASSETS_STATIC_PARKING_GREY_WEBP + : R.ASSETS_STATIC_PARKING_YELLOW_WEBP; + } + + @override + Widget build(BuildContext context) { + return AspectRatio( + aspectRatio: 688 / 286, + child: Container( + padding: EdgeInsets.all(40.w), + decoration: BoxDecoration( + image: DecorationImage(image: AssetImage(_assetImage)), + borderRadius: BorderRadius.circular(8.w), + ), + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.code, + 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( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '类型', + style: Theme.of(context).textTheme.bodyText1.copyWith( + color: Color(0xFF666666), + ), + ), + Text( + model.typeName, + style: Theme.of(context).textTheme.subtitle2.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ], + ).expand(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '到期时间', + style: Theme.of(context).textTheme.bodyText1.copyWith( + color: Color(0xFF666666), + ), + ), + Text( + model.dateName, + style: Theme.of(context).textTheme.subtitle2.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ], + ).expand(), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/ui/profile/car/car_manage_page.dart b/lib/ui/profile/car/car_manage_page.dart new file mode 100644 index 00000000..5bdace6b --- /dev/null +++ b/lib/ui/profile/car/car_manage_page.dart @@ -0,0 +1,68 @@ +import 'package:akuCommunity/provider/app_provider.dart'; +import 'package:akuCommunity/ui/profile/car/car_manage_card.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 CarManagePage extends StatefulWidget { + CarManagePage({Key key}) : super(key: key); + + @override + _CarManagePageState createState() => _CarManagePageState(); +} + +class _CarManagePageState extends State { + Widget get _renderEmptyWidget { + return Center( + child: Stack( + children: [ + Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP).pSymmetric(h: 75.w), + Positioned( + bottom: 100.w, + left: 0, + right: 0, + child: Text( + '还没有车辆', + style: TextStyle( + color: Color(0xFF999999), + ), + ).centered(), + ), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + final appProvider = Provider.of(context); + return BeeScaffold( + title: '我的车位', + actions: [ + // TextButton( + // onPressed: () {}, + // child: Text('管理车位'), + // ), + ], + body: EasyRefresh( + firstRefresh: true, + onRefresh: () async { + await appProvider.updateCarModels(); + }, + header: MaterialHeader(), + emptyWidget: appProvider.carModels.isEmpty ? _renderEmptyWidget : null, + child: ListView.separated( + separatorBuilder: (context, index) => 32.hb, + itemBuilder: (context, index) { + return CarManageCard(model: appProvider.carModels[index]); + }, + padding: EdgeInsets.all(32.w), + itemCount: appProvider.carModels.length, + ), + ), + ); + } +} diff --git a/lib/ui/profile/car_parking/car_parking_card.dart b/lib/ui/profile/car_parking/car_parking_card.dart index 2db87359..3d678799 100644 --- a/lib/ui/profile/car_parking/car_parking_card.dart +++ b/lib/ui/profile/car_parking/car_parking_card.dart @@ -19,11 +19,16 @@ class CarparkingCard extends StatelessWidget { aspectRatio: 688 / 286, child: Container( padding: EdgeInsets.all(40.w), + decoration: BoxDecoration( + image: DecorationImage(image: AssetImage(_assetImage)), + borderRadius: BorderRadius.circular(8.w), + ), + clipBehavior: Clip.antiAlias, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '地上车位B0001', + model.code, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 36.sp, @@ -40,18 +45,43 @@ class CarparkingCard extends StatelessWidget { Row( children: [ Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('类型'), + Text( + '类型', + style: Theme.of(context).textTheme.bodyText1.copyWith( + color: Color(0xFF666666), + ), + ), + Text( + model.typeName, + style: Theme.of(context).textTheme.subtitle2.copyWith( + fontWeight: FontWeight.bold, + ), + ), ], - ), + ).expand(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '到期时间', + style: Theme.of(context).textTheme.bodyText1.copyWith( + color: Color(0xFF666666), + ), + ), + Text( + model.dateName, + style: Theme.of(context).textTheme.subtitle2.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ], + ).expand(), ], ), ], ), - 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 deleted file mode 100644 index 86c20f10..00000000 --- a/lib/ui/profile/car_parking/car_parking_func.dart +++ /dev/null @@ -1,7 +0,0 @@ -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 316af20a..9c0b934a 100644 --- a/lib/ui/profile/car_parking/car_parking_page.dart +++ b/lib/ui/profile/car_parking/car_parking_page.dart @@ -41,13 +41,16 @@ class _CarParkingPageState extends State { return BeeScaffold( title: '我的车位', actions: [ - TextButton( - onPressed: () {}, - child: Text('管理车位'), - ), + // TextButton( + // onPressed: () {}, + // child: Text('管理车位'), + // ), ], body: EasyRefresh( - onRefresh: () async {}, + firstRefresh: true, + onRefresh: () async { + await appProvider.updateCarParkingModels(); + }, header: MaterialHeader(), emptyWidget: appProvider.carParkingModels.isEmpty ? _renderEmptyWidget : null,