更新我的房屋页面

hmxc
小赖 4 years ago
parent 0a11fc2b8c
commit 382f4cb1f2

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@ -474,6 +474,14 @@ class R {
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/json/zbbj.json) /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/json/zbbj.json)
static const String ASSETS_JSON_ZBBJ_JSON = 'assets/json/zbbj.json'; static const String ASSETS_JSON_ZBBJ_JSON = 'assets/json/zbbj.json';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/static/house_auth_fail.webp)
static const String ASSETS_STATIC_HOUSE_AUTH_FAIL_WEBP =
'assets/static/house_auth_fail.webp';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/static/house_auth_success.webp)
static const String ASSETS_STATIC_HOUSE_AUTH_SUCCESS_WEBP =
'assets/static/house_auth_success.webp';
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/static/reviewing.webp) /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/static/reviewing.webp)
static const String ASSETS_STATIC_REVIEWING_WEBP = static const String ASSETS_STATIC_REVIEWING_WEBP =
'assets/static/reviewing.webp'; 'assets/static/reviewing.webp';

@ -8,7 +8,16 @@ class AppTheme {
primaryColor: Color(0xFFFFD000), primaryColor: Color(0xFFFFD000),
accentColor: Color(0xFFFFD000), accentColor: Color(0xFFFFD000),
textTheme: ThemeData.light().textTheme.copyWith( textTheme: ThemeData.light().textTheme.copyWith(
headline3: TextStyle(
fontSize: 40.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
subtitle1: TextStyle( subtitle1: TextStyle(
fontSize: 32.sp,
color: Color(0xFF333333),
),
subtitle2: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
color: Color(0xFF333333), color: Color(0xFF333333),
), ),
@ -76,6 +85,20 @@ class AppTheme {
enableFeedback: true, enableFeedback: true,
), ),
), ),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled))
return Color(0xFFFFF4D7);
return Color(0xFFFFD000).withOpacity(0.2);
}),
foregroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled))
return Color(0xFF666666);
return Color(0xFF333333);
}),
),
),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
dividerColor: Color(0xFFE8E8E8), dividerColor: Color(0xFFE8E8E8),
); );

@ -1,26 +1,77 @@
import 'package:flustars/flustars.dart'; import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
class HouseModel { class HouseModel {
int id; int id;
String roomName; String roomName;
int status; int status;
int type;
String effectiveTimeStart; String effectiveTimeStart;
String effectiveTimeEnd; String effectiveTimeEnd;
DateTime get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart); DateTime get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart);
DateTime get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd); DateTime get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd);
String get typeValue {
switch (type) {
case 1:
return '业主';
case 2:
return '租客';
case 3:
return '情书';
}
return '';
}
///
///
List<Color> get backgroundColor {
//TODO
if (status != 4)
return [
Color(0xFFF5F5F5),
Color(0xFFEFEEEE),
Color(0xFFE8E8E8),
];
if (type == 1)
return [
Color(0xFFFFDF7D),
Color(0xFFFFD654),
Color(0xFFFFC40C),
];
if (type == 2)
return [
Color(0xFFFFA446),
Color(0xFFFFA547),
Color(0xFFFF8200),
];
if (type == 3)
return [
Color(0xFF9ADE79),
Color(0xFF91DE6B),
Color(0xFF6ECB41),
];
return [
Color(0xFFF5F5F5),
Color(0xFFEFEEEE),
Color(0xFFE8E8E8),
];
}
HouseModel( HouseModel({
{this.id, this.id,
this.roomName, this.roomName,
this.status, this.status,
this.effectiveTimeStart, this.type,
this.effectiveTimeEnd}); this.effectiveTimeStart,
this.effectiveTimeEnd,
});
HouseModel.fromJson(Map<String, dynamic> json) { HouseModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
roomName = json['roomName']; roomName = json['roomName'];
status = json['status']; status = json['status'];
type = json['type'];
effectiveTimeStart = json['effectiveTimeStart']; effectiveTimeStart = json['effectiveTimeStart'];
effectiveTimeEnd = json['effectiveTimeEnd']; effectiveTimeEnd = json['effectiveTimeEnd'];
} }

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:amap_flutter_location/amap_flutter_location.dart'; import 'package:amap_flutter_location/amap_flutter_location.dart';
@ -174,4 +175,30 @@ class AppProvider extends ChangeNotifier {
_messageCenterModel = MessageCenterModel.fromJson(response.data); _messageCenterModel = MessageCenterModel.fromJson(response.data);
notifyListeners(); notifyListeners();
} }
List<HouseModel> _houses = [];
///
List<HouseModel> get houses => _houses;
///
updateHouses(List<HouseModel> items) {
_houses = items;
notifyListeners();
}
HouseModel _selectedHouse;
///
HouseModel get selectedHouse {
if (_houses?.isEmpty ?? true) return null;
if (_selectedHouse == null) _selectedHouse = _houses.first;
return _selectedHouse;
}
///
setCurrentHouse(HouseModel model) {
_selectedHouse = model;
notifyListeners();
}
} }

@ -57,7 +57,7 @@ class _AddHousePageState extends State<AddHousePage> {
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 16.w), padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 16.w),
child: Text(title, style: Theme.of(context).textTheme.subtitle1), child: Text(title, style: Theme.of(context).textTheme.subtitle2),
), ),
item ?? SizedBox(), item ?? SizedBox(),
], ],
@ -279,6 +279,6 @@ class _AddHousePageState extends State<AddHousePage> {
showMessage: true, showMessage: true,
); );
cancel(); cancel();
if (model.status) Get.back(); if (model.status) Get.back(result:true);
} }
} }

@ -0,0 +1,158 @@
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:get/get.dart';
enum CardAuthType {
FAIL,
SUCCESS,
}
class HouseCard extends StatelessWidget {
final String plotName;
final String houseName;
final int role;
final CardAuthType type;
const HouseCard({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
@required this.type,
}) : super(key: key);
const HouseCard.fail({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
}) : type = CardAuthType.FAIL,
super(key: key);
const HouseCard.success({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
}) : type = CardAuthType.SUCCESS,
super(key: key);
String get _assetPath {
switch (type) {
case CardAuthType.FAIL:
return R.ASSETS_STATIC_HOUSE_AUTH_FAIL_WEBP;
case CardAuthType.SUCCESS:
return R.ASSETS_STATIC_HOUSE_AUTH_SUCCESS_WEBP;
}
return '';
}
String get _roleName {
switch (role) {
case 1:
return '业主';
case 2:
return '';
case 3:
return '';
default:
return '';
}
}
List<BoxShadow> get _shadows {
switch (type) {
case CardAuthType.FAIL:
return [
BoxShadow(
offset: Offset(0, 10.w),
blurRadius: 30.w,
color: Color(0xFFF0F0F0),
),
];
case CardAuthType.SUCCESS:
return [
BoxShadow(
offset: Offset(0, 10.w),
blurRadius: 30.w,
color: Color(0xFFFFF0BF),
),
];
}
return [];
}
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 686 / 386,
child: Container(
clipBehavior: Clip.antiAlias,
height: double.infinity,
width: double.infinity,
padding: EdgeInsets.only(left: 40.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
28.hb,
Align(
alignment: Alignment.centerRight,
child: MaterialButton(
height: 48.w,
minWidth: 152.w,
color: Colors.white,
padding: EdgeInsets.zero,
elevation: 0,
focusElevation: 0,
hoverElevation: 0,
disabledElevation: 0,
highlightElevation: 0,
child: Text(
'切换房屋',
style: TextStyle(
color: Color(0xFF333333),
fontSize: 24.sp,
),
),
onPressed: () {
Get.to(PickMyHousePage());
},
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.horizontal(left: Radius.circular(24.w)),
),
),
),
12.hb,
Text(
plotName,
style: Theme.of(context).textTheme.headline3,
),
10.hb,
Text(
houseName,
style: Theme.of(context).textTheme.subtitle1,
),
Spacer(),
Text(
'身份',
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: Color(0xFF666666),
),
),
Text(
_roleName,
style: Theme.of(context).textTheme.subtitle1,
),
40.hb,
],
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
image: DecorationImage(image: AssetImage(_assetPath)),
boxShadow: _shadows,
),
),
);
}
}

@ -0,0 +1,12 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
class HouseFunc {
static Future<List<HouseModel>> get houses async {
BaseModel model = await NetUtil().get(API.user.houseList);
if (!model.status) return [];
return (model.data as List).map((e) => HouseModel.fromJson(e)).toList();
}
}

@ -1,3 +1,8 @@
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:akuCommunity/provider/app_provider.dart';
import 'package:akuCommunity/ui/profile/house/house_card.dart';
import 'package:akuCommunity/ui/profile/house/house_func.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -7,9 +12,10 @@ import 'package:get/get.dart';
import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/ui/profile/house/add_house_page.dart'; import 'package:akuCommunity/ui/profile/house/add_house_page.dart';
import 'package:akuCommunity/utils/network/base_list_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:provider/provider.dart';
class HouseOwnersPage extends StatefulWidget { class HouseOwnersPage extends StatefulWidget {
HouseOwnersPage({Key key}) : super(key: key); HouseOwnersPage({Key key}) : super(key: key);
@ -21,48 +27,61 @@ class HouseOwnersPage extends StatefulWidget {
class _HouseOwnersPageState extends State<HouseOwnersPage> { class _HouseOwnersPageState extends State<HouseOwnersPage> {
EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController = EasyRefreshController();
bool get _emptyHouse {
final appProvider = Provider.of<AppProvider>(context, listen: false);
return appProvider.houses.isEmpty;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final media = MediaQuery.of(context); final appProvider = Provider.of<AppProvider>(context);
return BeeScaffold( return BeeScaffold(
title: '我的房屋', title: '我的房屋',
actions: [], actions: [
TextButton(
onPressed: _addHouse,
child: Text('新增房屋'),
),
],
body: EasyRefresh( body: EasyRefresh(
header: MaterialHeader(), header: MaterialHeader(),
controller: _refreshController, controller: _refreshController,
firstRefresh: true, firstRefresh: true,
onRefresh: () async { onRefresh: () async {
await _getFirstHouse(); appProvider.updateHouses(await HouseFunc.houses);
}, },
child: SizedBox( child: ListView(
height: media.size.height - media.padding.top - 56, children: [
child: Column( _emptyHouse
mainAxisAlignment: MainAxisAlignment.center, ? 280.hb
children: [ : Padding(
Padding( padding: EdgeInsets.all(32.w),
padding: EdgeInsets.symmetric(horizontal: 75.w), child: HouseCard.fail(
child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP), plotName: '人才公寓智慧小区',
), houseName: appProvider.selectedHouse.roomName,
ElevatedButton( role: 1,
),
),
if (!_emptyHouse) 88.hb,
Padding(
padding: EdgeInsets.symmetric(horizontal: 75.w),
child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP),
),
Center(
child: ElevatedButton(
onPressed: _addHouse, onPressed: _addHouse,
child: Text('添加房屋'), child: Text('添加房屋'),
), ),
], ),
), ],
), ),
), ),
); );
} }
///
_addHouse() async { _addHouse() async {
await Get.to(() => AddHousePage()); bool result = await Get.to(() => AddHousePage());
} if (result == true) _refreshController.callRefresh();
Future _getFirstHouse() async {
BaseListModel model = await NetUtil().getList(
API.user.houseList,
params: {'pageNum': 1, 'size': 1},
);
print(model.tableList);
} }
} }

@ -0,0 +1,128 @@
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:akuCommunity/provider/app_provider.dart';
import 'package:akuCommunity/ui/profile/house/house_func.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';
import 'package:akuCommunity/utils/headers.dart';
class PickMyHousePage extends StatefulWidget {
PickMyHousePage({Key key}) : super(key: key);
@override
_PickMyHousePageState createState() => _PickMyHousePageState();
}
class _PickMyHousePageState extends State<PickMyHousePage> {
_renderTitle(String title) {
return SliverPadding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 16.w),
sliver: SliverToBoxAdapter(
child: Text(title, style: Theme.of(context).textTheme.subtitle2),
),
);
}
Widget get _renderSep => SliverToBoxAdapter(child: 24.hb);
@override
Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context);
return BeeScaffold(
title: '我的房屋',
body: EasyRefresh(
header: MaterialHeader(),
onRefresh: () async {
final appProvider = Provider.of<AppProvider>(context, listen: false);
appProvider.updateHouses(await HouseFunc.houses);
},
firstRefresh: true,
child: CustomScrollView(
slivers: [
_renderSep,
_renderTitle('当前房屋'),
SliverToBoxAdapter(
child: _HouseCard(
model: appProvider.selectedHouse,
highlight: true,
),
),
],
),
).material(color: Colors.white),
bottomNavi: ElevatedButton(
child: Text('新增房屋'),
onPressed: () {},
style: ButtonStyle(
padding:
MaterialStateProperty.all(EdgeInsets.symmetric(vertical: 26.w)),
),
),
);
}
}
class _HouseCard extends StatelessWidget {
final HouseModel model;
final bool highlight;
const _HouseCard({Key key, @required this.model, this.highlight = false})
: super(key: key);
@override
Widget build(BuildContext context) {
return MaterialButton(
padding: EdgeInsets.symmetric(horizontal: 32.w),
height: 136.w,
child: Row(
children: [
Container(
child: Text(
model.typeValue,
style: Theme.of(context).textTheme.subtitle2.copyWith(
fontWeight: FontWeight.bold,
),
),
alignment: Alignment.center,
height: 88.w,
width: 88.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w),
gradient: LinearGradient(
colors: model.backgroundColor,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
),
24.wb,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'人才公寓智慧小区',
style: Theme.of(context).textTheme.subtitle1.copyWith(
color:
highlight ? Color(0xFFFF8200) : Color(0xFF333333),
fontWeight: FontWeight.bold,
),
),
8.hb,
Text(
model.roomName,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: Color(0xFF999999),
),
),
],
),
),
],
),
onPressed: () {},
);
}
}

@ -281,13 +281,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.0-nullsafety.2" version: "3.0.0-nullsafety.2"
flutter_datetime_picker:
dependency: "direct main"
description:
name: flutter_datetime_picker
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.0"
flutter_easyrefresh: flutter_easyrefresh:
dependency: "direct main" dependency: "direct main"
description: description:

@ -47,8 +47,6 @@ dependencies:
dio: ^4.0.0-prev3 dio: ^4.0.0-prev3
#骨架 #骨架
shimmer: ^2.0.0-nullsafety.0 shimmer: ^2.0.0-nullsafety.0
#时间选择
flutter_datetime_picker: ^1.4.0
#随机二维码 #随机二维码
qr_flutter: ^4.0.0 qr_flutter: ^4.0.0

Loading…
Cancel
Save