切换房屋功能

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

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

@ -197,7 +197,8 @@ class _AddHousePageState extends State<AddHousePage> {
text: PickRolePage.getType(_roleType),
hintText: '请选择身份',
onTap: () async {
int role = await Get.to(() => PickRolePage());
int role =
await Get.to(() => PickRolePage(init: _roleType));
if (role != null) {
_roleType = role;
setState(() {});
@ -279,6 +280,6 @@ class _AddHousePageState extends State<AddHousePage> {
showMessage: true,
);
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/model/user/house_model.dart';
import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart';
@ -10,30 +11,22 @@ enum CardAuthType {
}
class HouseCard extends StatelessWidget {
final String plotName;
final String houseName;
final int role;
final HouseModel model;
final CardAuthType type;
const HouseCard({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
@required this.model,
@required this.type,
}) : super(key: key);
const HouseCard.fail({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
@required this.model,
}) : type = CardAuthType.FAIL,
super(key: key);
const HouseCard.success({
Key key,
@required this.plotName,
@required this.houseName,
@required this.role,
@required this.model,
}) : type = CardAuthType.SUCCESS,
super(key: key);
@ -48,7 +41,7 @@ class HouseCard extends StatelessWidget {
}
String get _roleName {
switch (role) {
switch (model.type) {
case 1:
return '业主';
case 2:
@ -125,12 +118,12 @@ class HouseCard extends StatelessWidget {
),
12.hb,
Text(
plotName,
'人才公寓智慧小区',
style: Theme.of(context).textTheme.headline3,
),
10.hb,
Text(
houseName,
model.roomName,
style: Theme.of(context).textTheme.subtitle1,
),
Spacer(),

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

@ -4,6 +4,7 @@ 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:get/get.dart';
import 'package:provider/provider.dart';
import 'package:akuCommunity/utils/headers.dart';
@ -26,6 +27,32 @@ class _PickMyHousePageState extends State<PickMyHousePage> {
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
Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context);
@ -48,6 +75,9 @@ class _PickMyHousePageState extends State<PickMyHousePage> {
highlight: true,
),
),
_renderSep,
if (housesWithoutSelected.isNotEmpty) _renderTitle('其他房屋'),
if (housesWithoutSelected.isNotEmpty) _renderList(),
],
),
).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 {
final int init;
PickRolePage({Key key, this.init = 0}) : super(key: key);
static String getType(int index) {
switch (index) {
case 1:
@ -23,8 +27,6 @@ class PickRolePage extends StatefulWidget {
}
}
PickRolePage({Key key}) : super(key: key);
@override
_PickRolePageState createState() => _PickRolePageState();
}
@ -55,6 +57,7 @@ class _PickRolePageState extends State<PickRolePage> {
setState(() {
_pickedValue = value;
});
Get.back(result: _pickedValue);
},
),
16.wb,
@ -70,6 +73,12 @@ class _PickRolePageState extends State<PickRolePage> {
);
}
@override
void initState() {
super.initState();
_pickedValue = widget.init;
}
@override
Widget build(BuildContext context) {
return BeeScaffold(

Loading…
Cancel
Save