切换房屋功能

hmxc
小赖 4 years ago
parent 382f4cb1f2
commit 9b155715eb

@ -11,6 +11,9 @@ class HouseModel {
DateTime get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart); DateTime get effectiveStartDate => DateUtil.getDateTime(effectiveTimeStart);
DateTime get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd); DateTime get effectiveEndDate => DateUtil.getDateTime(effectiveTimeEnd);
//TODO
bool get reviewed => status == 4;
String get typeValue { String get typeValue {
switch (type) { switch (type) {
case 1: case 1:

@ -197,7 +197,8 @@ class _AddHousePageState extends State<AddHousePage> {
text: PickRolePage.getType(_roleType), text: PickRolePage.getType(_roleType),
hintText: '请选择身份', hintText: '请选择身份',
onTap: () async { onTap: () async {
int role = await Get.to(() => PickRolePage()); int role =
await Get.to(() => PickRolePage(init: _roleType));
if (role != null) { if (role != null) {
_roleType = role; _roleType = role;
setState(() {}); setState(() {});
@ -279,6 +280,6 @@ class _AddHousePageState extends State<AddHousePage> {
showMessage: true, showMessage: true,
); );
cancel(); cancel();
if (model.status) Get.back(result:true); if (model.status) Get.back(result: true);
} }
} }

@ -1,4 +1,5 @@
import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart'; import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
@ -10,30 +11,22 @@ enum CardAuthType {
} }
class HouseCard extends StatelessWidget { class HouseCard extends StatelessWidget {
final String plotName; final HouseModel model;
final String houseName;
final int role;
final CardAuthType type; final CardAuthType type;
const HouseCard({ const HouseCard({
Key key, Key key,
@required this.plotName, @required this.model,
@required this.houseName,
@required this.role,
@required this.type, @required this.type,
}) : super(key: key); }) : super(key: key);
const HouseCard.fail({ const HouseCard.fail({
Key key, Key key,
@required this.plotName, @required this.model,
@required this.houseName,
@required this.role,
}) : type = CardAuthType.FAIL, }) : type = CardAuthType.FAIL,
super(key: key); super(key: key);
const HouseCard.success({ const HouseCard.success({
Key key, Key key,
@required this.plotName, @required this.model,
@required this.houseName,
@required this.role,
}) : type = CardAuthType.SUCCESS, }) : type = CardAuthType.SUCCESS,
super(key: key); super(key: key);
@ -48,7 +41,7 @@ class HouseCard extends StatelessWidget {
} }
String get _roleName { String get _roleName {
switch (role) { switch (model.type) {
case 1: case 1:
return '业主'; return '业主';
case 2: case 2:
@ -125,12 +118,12 @@ class HouseCard extends StatelessWidget {
), ),
12.hb, 12.hb,
Text( Text(
plotName, '人才公寓智慧小区',
style: Theme.of(context).textTheme.headline3, style: Theme.of(context).textTheme.headline3,
), ),
10.hb, 10.hb,
Text( Text(
houseName, model.roomName,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
), ),
Spacer(), Spacer(),

@ -1,8 +1,6 @@
import 'package:akuCommunity/model/user/house_model.dart';
import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/provider/app_provider.dart';
import 'package:akuCommunity/ui/profile/house/house_card.dart'; import 'package:akuCommunity/ui/profile/house/house_card.dart';
import 'package:akuCommunity/ui/profile/house/house_func.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';
@ -10,9 +8,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; 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/ui/profile/house/add_house_page.dart'; import 'package:akuCommunity/ui/profile/house/add_house_page.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:akuCommunity/utils/headers.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -32,6 +28,12 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
return appProvider.houses.isEmpty; return appProvider.houses.isEmpty;
} }
///
bool get _haveAuthedHouse {
final appProvider = Provider.of<AppProvider>(context, listen: false);
return (appProvider?.selectedHouse?.status ?? 0) == 4;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context); final appProvider = Provider.of<AppProvider>(context);
@ -56,23 +58,26 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
? 280.hb ? 280.hb
: Padding( : Padding(
padding: EdgeInsets.all(32.w), padding: EdgeInsets.all(32.w),
child: HouseCard.fail( child: HouseCard(
plotName: '人才公寓智慧小区', type: appProvider.selectedHouse.reviewed
houseName: appProvider.selectedHouse.roomName, ? CardAuthType.SUCCESS
role: 1, : CardAuthType.FAIL,
model: appProvider.selectedHouse,
), ),
), ),
if (!_emptyHouse) 88.hb, if (!_emptyHouse) 88.hb,
Padding( if (!_haveAuthedHouse)
padding: EdgeInsets.symmetric(horizontal: 75.w), Padding(
child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP), padding: EdgeInsets.symmetric(horizontal: 75.w),
), child: Image.asset(R.ASSETS_STATIC_REVIEWING_WEBP),
Center( ),
child: ElevatedButton( if (!_haveAuthedHouse)
onPressed: _addHouse, Center(
child: Text('添加房屋'), child: ElevatedButton(
onPressed: _addHouse,
child: Text('添加房屋'),
),
), ),
),
], ],
), ),
), ),

@ -4,6 +4,7 @@ import 'package:akuCommunity/ui/profile/house/house_func.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.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';
import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
@ -26,6 +27,32 @@ class _PickMyHousePageState extends State<PickMyHousePage> {
Widget get _renderSep => SliverToBoxAdapter(child: 24.hb); Widget get _renderSep => SliverToBoxAdapter(child: 24.hb);
List<HouseModel> get housesWithoutSelected {
final appProvider = Provider.of<AppProvider>(context, listen: false);
List<HouseModel> models = List.from(appProvider.houses);
models.removeWhere(
(element) => element.id == (appProvider?.selectedHouse?.id ?? -1),
);
if (models == null || models.isEmpty) return [];
return models;
}
_renderList() {
return SliverList(
delegate: SliverChildListDelegate(
housesWithoutSelected
.map((e) => _HouseCard(model: e))
.toList()
.sepWidget(
separate: Divider(
height: 1.w,
indent: 32.w,
endIndent: 32.w,
)),
),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context); final appProvider = Provider.of<AppProvider>(context);
@ -48,6 +75,9 @@ class _PickMyHousePageState extends State<PickMyHousePage> {
highlight: true, highlight: true,
), ),
), ),
_renderSep,
if (housesWithoutSelected.isNotEmpty) _renderTitle('其他房屋'),
if (housesWithoutSelected.isNotEmpty) _renderList(),
], ],
), ),
).material(color: Colors.white), ).material(color: Colors.white),
@ -122,7 +152,11 @@ class _HouseCard extends StatelessWidget {
), ),
], ],
), ),
onPressed: () {}, onPressed: () {
final appProvider = Provider.of<AppProvider>(context, listen: false);
appProvider.setCurrentHouse(model);
Get.back();
},
); );
} }
} }

@ -10,6 +10,10 @@ import 'package:akuCommunity/widget/bee_scaffold.dart';
/// ///
/// ///
class PickRolePage extends StatefulWidget { class PickRolePage extends StatefulWidget {
final int init;
PickRolePage({Key key, this.init = 0}) : super(key: key);
static String getType(int index) { static String getType(int index) {
switch (index) { switch (index) {
case 1: case 1:
@ -23,8 +27,6 @@ class PickRolePage extends StatefulWidget {
} }
} }
PickRolePage({Key key}) : super(key: key);
@override @override
_PickRolePageState createState() => _PickRolePageState(); _PickRolePageState createState() => _PickRolePageState();
} }
@ -55,6 +57,7 @@ class _PickRolePageState extends State<PickRolePage> {
setState(() { setState(() {
_pickedValue = value; _pickedValue = value;
}); });
Get.back(result: _pickedValue);
}, },
), ),
16.wb, 16.wb,
@ -70,6 +73,12 @@ class _PickRolePageState extends State<PickRolePage> {
); );
} }
@override
void initState() {
super.initState();
_pickedValue = widget.init;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(

Loading…
Cancel
Save