You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

527 lines
16 KiB

3 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
3 years ago
import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/constants/application_objects.dart';
import 'package:aku_new_community/pages/life_pay/life_pay_choose_page.dart';
import 'package:aku_new_community/pages/property/property_func.dart';
import 'package:aku_new_community/provider/app_provider.dart';
import 'package:aku_new_community/provider/user_provider.dart';
import 'package:aku_new_community/ui/profile/house/add_house_page.dart';
import 'package:aku_new_community/ui/profile/house/house_owners_page.dart';
import 'package:aku_new_community/utils/headers.dart';
import 'package:aku_new_community/widget/views/application_view.dart';
3 years ago
class PropertyPage extends StatefulWidget {
final bool? isSign;
PropertyPage({Key? key, this.isSign}) : super(key: key);
@override
_PropertyPageState createState() => _PropertyPageState();
}
class _PropertyPageState extends State<PropertyPage>
3 years ago
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
3 years ago
int sum = 0;
int commentCount = 0;
int sysCount = 0;
num unpaid = 0;
num paid = 0;
3 years ago
late TabController _tabController;
@override
void initState() {
super.initState();
_getRefresh();
_tabController = TabController(initialIndex: 0, length: 2, vsync: this);
3 years ago
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
3 years ago
_getRefresh() {
Future.delayed(Duration(milliseconds: 0), () async {
paid = await PropertyFunc.getDailyPaymentPrePay();
3 years ago
unpaid = await PropertyFunc.getFindUnpaidAmount();
setState(() {});
});
}
3 years ago
3 years ago
SliverAppBar _sliverAppBar(double height) {
final userProvider = Provider.of<UserProvider>(context);
AppProvider appProvider = Provider.of<AppProvider>(context);
commentCount = appProvider.messageCenterModel.commentCount ?? 0;
sysCount = appProvider.messageCenterModel.sysCount ?? 0;
sum = commentCount + sysCount;
return SliverAppBar(
pinned: true,
snap: false,
//toolbarHeight: 0,
elevation: 0,
collapsedHeight: 420.w,
3 years ago
titleSpacing: 10.0,
floating: true,
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (appProvider.location != null)
Padding(
padding: EdgeInsets.only(right: 5),
3 years ago
child: Image.asset(
R.ASSETS_ICONS_ICON_PROPERTY_LOCATION_PNG,
width: 40.w,
height: 40.w,
3 years ago
),
),
Text(
appProvider.location?['city'] == null
? ''
: appProvider.location?['city'] as String? ?? '',
3 years ago
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 32.sp,
color: Colors.white.withOpacity(0.85),
3 years ago
),
textAlign: TextAlign.center,
),
]),
// actions: [
// GestureDetector(
// onTap: () {
// Get.to(() => BeeSearch());
// },
// child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_SEARCH_PNG,
// height: 40.w, width: 40.w),
// ),
// // Padding(
// // padding: EdgeInsets.only(right: 10.w, left: 12.w),
// // child: Badge(
// // elevation: 0,
// // badgeColor: Color(0xFFCF2525),
// // padding: sum > 9 ? EdgeInsets.all(2.w) : EdgeInsets.all(5.w),
// // showBadge: appProvider.messageCenterModel.commentCount != 0 ||
// // appProvider.messageCenterModel.sysCount != 0,
// // position: BadgePosition.topEnd(
// // top: 8.w,
// // end: -4.w,
// // ),
// // badgeContent: Text(
// // (sum).toString(),
// // style: TextStyle(color: Colors.white, fontSize: 20.sp),
// // ),
// // child: GestureDetector(
// // onTap: () {
// // if (LoginUtil.isNotLogin) return;
// // Get.to(() => MessageCenterPage());
// // },
// // child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_MESSAGE_PNG,
// // height: 40.w, width: 40.w),
// // )),
// // ),
// ],
3 years ago
expandedHeight: 420.w,
backgroundColor: Colors.white,
flexibleSpace: Stack(
children: [
Positioned(
child: Image.asset(
R.ASSETS_IMAGES_PROPERTY_BG_PNG,
3 years ago
width: double.infinity,
height: 503.w,
fit: BoxFit.cover,
3 years ago
),
top: 0,
left: 0,
right: 0,
bottom: 0),
Positioned(
child: Container(
3 years ago
margin: EdgeInsets.only(left: 32.w, right: 32.w, top: 10.w),
width: 686.w,
height: 74.w,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.25),
borderRadius: BorderRadius.all(
Radius.circular(8.w),
3 years ago
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
24.wb,
Text(
'当前绑定房屋',
style: TextStyle(
fontSize: 28.sp,
color: Colors.white.withOpacity(0.85),
height: 1.00),
),
Spacer(),
Text(
3 years ago
userProvider.myHouses.isEmpty
? ''
: userProvider.myHouses.first.communityName,
style: TextStyle(
fontSize: 28.sp,
color: Colors.white.withOpacity(0.85),
height: 1.00,
fontWeight: FontWeight.bold),
),
32.wb,
GestureDetector(
onTap: () {
Get.to(HouseOwnersPage(
identify: 4,
));
},
child: Container(
alignment: Alignment.center,
width: 80.w,
height: 42.w,
child: Text(
'切换',
style: TextStyle(
fontSize: 24.sp,
color: Colors.white.withOpacity(0.85)),
),
decoration: BoxDecoration(
color: Color(0xFF3D8CE8),
borderRadius: BorderRadius.all(
Radius.circular(8.w),
3 years ago
),
),
),
),
24.wb,
],
3 years ago
),
),
top: kTextTabBarHeight + 50.w,
left: 0,
right: 0,
),
3 years ago
Positioned(
child: _goodsTitle(),
top: kTextTabBarHeight + 50.w + 94.w,
3 years ago
left: 0,
right: 0,
),
Positioned(
child: Container(
padding: EdgeInsets.only(top: 20.w),
height: 150.w,
child: TabBarView(
children: [_payView(true), _payView(false)],
3 years ago
controller: _tabController,
physics: NeverScrollableScrollPhysics(),
),
),
top: kTextTabBarHeight + 50.w + 94.w + 60.w,
3 years ago
left: 0,
right: 0,
),
],
),
);
}
_payView(bool pay) {
3 years ago
return Container(
padding: EdgeInsets.only(left: 36.w, right: 36.w),
3 years ago
width: double.infinity,
height: 150.w,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
3 years ago
pay ? paid.toStringAsFixed(2) : unpaid.toStringAsFixed(2),
3 years ago
style: TextStyle(
color: Color(0xFFFFFFFF).withOpacity(0.85),
fontSize: 40.sp,
),
),
8.hb,
Text(
'点击查看明细',
style: TextStyle(
color: Color(0xFFFFFFFF).withOpacity(0.45),
fontSize: 22.sp,
),
),
],
),
Spacer(),
GestureDetector(
3 years ago
onTap: () async {
final appProvider =
Provider.of<AppProvider>(Get.context!, listen: false);
if (appProvider.selectedHouse == null) {
BotToast.showText(text: '请先添加房屋');
Get.to(() => AddHousePage());
3 years ago
} else {
bool? result = await Get.to(() => LifePayChoosePage());
if (result == true) _getRefresh();
}
},
child: Container(
alignment: Alignment.center,
width: 160.w,
height: 55.w,
child: Text(
!pay ? '缴纳账单' : '点击充值',
style: TextStyle(
fontSize: 24.sp, color: Colors.white.withOpacity(0.85)),
),
decoration: BoxDecoration(
color: Color(0xFFFFC257),
borderRadius: BorderRadius.all(
Radius.circular(8.w),
),
3 years ago
),
),
),
],
),
);
}
_goodsTitle() {
3 years ago
return Row(
children: [
24.wb,
Container(
height: 60.w,
child: Material(
3 years ago
color: Colors.transparent,
child: TabBar(
onTap: (index) {
// _presenter.fetchList(_category.id, 0, _sortType);
setState(() {});
},
isScrollable: true,
labelPadding: EdgeInsets.zero,
controller: _tabController,
labelColor: Colors.white.withOpacity(0.85),
unselectedLabelColor: Colors.white.withOpacity(0.65),
indicatorPadding: EdgeInsets.symmetric(horizontal: 40.w),
indicatorSize: TabBarIndicatorSize.label,
labelStyle: TextStyle(
color: Colors.white.withOpacity(0.85),
3 years ago
),
indicatorColor: Color(0xFFE8A93A),
tabs: _tabItems()),
),
),
Spacer(),
Container(
color: Colors.transparent,
child: Row(
children: [
Text(
'缴费记录',
style: TextStyle(
3 years ago
color: Colors.white.withOpacity(0.45),
fontSize: 24.sp,
3 years ago
),
),
10.wb,
Icon(
CupertinoIcons.chevron_forward,
size: 24.w,
color: Colors.white.withOpacity(0.45),
),
],
3 years ago
),
),
36.wb,
],
);
3 years ago
}
List<Widget> _tabItems() {
return [_tabItem(0, '未缴账单'), _tabItem(1, '预缴金额')];
3 years ago
}
_tabItem(int index, String text) {
3 years ago
bool isChoose = index == _tabController.index;
// Color textColor = index == _tabController.index
// ? getCurrentThemeColor()
// : Colors.black.withOpacity(0.9);
return Tab(
child: Container(
alignment: Alignment.center,
width: 150.w,
// color: Colors.white,
color: Colors.transparent,
padding: EdgeInsets.only(left: 10.w, right: 10.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
text,
style: TextStyle(
fontWeight: isChoose ? FontWeight.bold : FontWeight.normal,
fontSize: isChoose ? 32.sp : 28.sp,
color: isChoose
? Colors.white.withOpacity(0.85)
: Colors.white.withOpacity(0.65)),
3 years ago
),
],
),
),
);
}
Container _containerBar(String title) {
return Container(
color: title == '我的物业' ? Colors.white : BaseStyle.colorf9f9f9,
padding: EdgeInsets.all(title == '我的物业' ? 0 : 32.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: BaseStyle.fontSize34,
color: ktextPrimary,
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
3 years ago
super.build(context);
3 years ago
final double _statusHeight = MediaQuery.of(context).padding.top;
final userProvider = Provider.of<UserProvider>(context);
return Scaffold(
body: EasyRefresh(
header: MaterialHeader(),
onRefresh: () async {
await userProvider.updateUserInfo();
await userProvider.updateMyHouseInfo();
3 years ago
},
child: CustomScrollView(
slivers: <Widget>[
_sliverAppBar(_statusHeight),
// orderWidget,
SliverToBoxAdapter(
child: _getFunctionView(getOutApp, '出行安全', Color(0xFFFAC058)),
3 years ago
),
SliverToBoxAdapter(
child: _getFunctionView(
propertyServicesApp, '物业服务', Color(0xFF58FA8F)),
3 years ago
),
SliverToBoxAdapter(
child:
_getFunctionView(residentLifeApp, '居民生活', Color(0xFF58C0FA)),
3 years ago
),
SliverToBoxAdapter(
child: _getFunctionView(
aboutCommunityApp, '关于社区', Color(0xFFFA5858)),
3 years ago
),
SliverToBoxAdapter(
child: _getFunctionView(
wisdomServiceApp,
'智慧服务',
Color(0xFFFA5858),
),
),
SliverToBoxAdapter(
child: _getFunctionView(
nearbyShoppingApp,
'附近市场',
Color(0xFFFA5858),
),
)
3 years ago
],
),
),
);
}
_getFunctionView(
List<AO> item,
String title,
Color color,
) {
3 years ago
return Container(
margin: EdgeInsets.only(left: 32.w, right: 32.w, top: 32.w),
3 years ago
decoration: BoxDecoration(
color: Color(0xffffffff),
borderRadius: BorderRadius.all(Radius.circular(8)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.withOpacity(0.1),
offset: Offset(1, 1),
),
],
),
//margin: EdgeInsets.all(20.w),
padding: EdgeInsets.only(left: 32.w, right: 32.w, top: 24.w),
3 years ago
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// _containerBar('我的物业'),
Container(
child: Column(
children: [
Row(
//crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(top: 6.w),
width: 4.w,
height: 24.w,
color: color,
),
10.wb,
_getTitle(title),
],
),
ApplicationView.custom(
items: item,
needAllApp: false,
),
],
),
)
],
),
);
}
_getTitle(String title) {
return Text(
title,
3 years ago
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
color: ktextPrimary,
),
);
}
3 years ago
@override
bool get wantKeepAlive => true;
3 years ago
}