parent
0a11fc2b8c
commit
382f4cb1f2
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 24 KiB |
@ -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();
|
||||
}
|
||||
}
|
@ -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: () {},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue