import 'dart:io';
|
import 'dart:ui';
|
|
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/material.dart';
|
import 'package:makemoney/api/msg_api.dart';
|
import 'package:makemoney/api/team_api.dart';
|
import 'package:makemoney/model/msg/app_notify_msg_model.dart';
|
import 'package:makemoney/model/team/team_member_list_vo.dart';
|
import 'package:makemoney/ui/mine/invite_friends.dart';
|
import 'package:makemoney/ui/widget/base_ui.dart';
|
import 'package:makemoney/ui/widget/button.dart';
|
import 'package:makemoney/ui/widget/images_widget.dart';
|
import 'package:makemoney/ui/widget/refresh_listview.dart';
|
import '../../ui/common/browser.dart';
|
import '../../utils/config_util.dart';
|
import '../../utils/share_preference.dart';
|
import '../../utils/string_util.dart';
|
import '../../utils/ui_constant.dart';
|
import '../../ui/widget/nav.dart';
|
import '../../utils/pageutils.dart';
|
|
import 'advice_submit.dart';
|
import 'package:launch_review/launch_review.dart';
|
import 'package:package_info/package_info.dart';
|
|
class TeamPage extends StatefulWidget {
|
TeamPage({Key? key, required this.title, required this.first})
|
: super(key: key);
|
|
// This widget is the home page of your application. It is stateful, meaning
|
// that it has a State object (defined below) that contains fields that affect
|
// how it looks.
|
|
// This class is the configuration for the state. It holds the values (in this
|
// case the title) provided by the parent (in this case the App widget) and
|
// used by the build method of the State. Fields in a Widget subclass are
|
// always marked "final".
|
|
final String title;
|
final bool first;
|
|
@override
|
_TeamPageState createState() => _TeamPageState();
|
}
|
|
class _TeamPageState extends State<TeamPage>
|
with SingleTickerProviderStateMixin {
|
int level = 0;
|
int _page = 1;
|
List<TeamMemberListVo>? _teamList;
|
final MyRefreshController _refreshController =
|
MyRefreshController(initialRefresh: false);
|
|
@override
|
void initState() {
|
super.initState();
|
setState(() {
|
level = widget.first ? 0 : 1;
|
});
|
_refresh();
|
_getNotify();
|
}
|
|
BoxDecoration getItemDecoration(Color bgColor, Color shadowColor) {
|
return BoxDecoration(
|
borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)),
|
color: bgColor,
|
boxShadow: [
|
BoxShadow(
|
color: shadowColor,
|
blurRadius: 2.0,
|
offset: const Offset(0.0, 5.0), //阴影y轴偏移量
|
spreadRadius: 1 //阴影扩散程度
|
)
|
]);
|
}
|
|
//下拉刷新
|
void _refresh() {
|
if (_refreshController.dataNormal != null) {
|
_refreshController.dataNormal!();
|
}
|
_refreshController.loadComplete();
|
_getTeamList(1);
|
}
|
|
//上拉加载
|
void _loadMore() {
|
_getTeamList(_page + 1);
|
}
|
|
//获取队员列表
|
void _getTeamList(int page) async {
|
setState(() {
|
_page = page;
|
});
|
|
Map<String, dynamic>? result =
|
await TeamApiUtil.getMyTeamList(context, level == 0, _page);
|
|
_refreshController.refreshCompleted();
|
_refreshController.loadComplete();
|
|
if (result == null &&
|
_page == 1 &&
|
(_teamList == null || _teamList!.isEmpty)) {
|
_refreshController.apiError!();
|
}
|
|
if (result == null || result["code"] != 0) {
|
//页码回滚
|
if (_page > 1) {
|
setState(() {
|
_page = _page - 1;
|
});
|
}
|
return;
|
}
|
//解析数据
|
int count = result["data"]["count"];
|
List<dynamic> list = result["data"]["list"];
|
List<TeamMemberListVo> tempList = [];
|
list.forEach((element) {
|
tempList.add(TeamMemberListVo.fromJson(element));
|
});
|
|
if (_page == 1) {
|
setState(() {
|
_teamList = tempList;
|
});
|
} else {
|
_teamList = _teamList ?? [];
|
setState(() {
|
_teamList!.addAll(tempList);
|
});
|
}
|
|
//判断数据
|
|
if (_teamList!.isEmpty) {
|
//空数据
|
_refreshController.dataEmpty!();
|
} else {
|
_refreshController.dataNormal!();
|
if (count <= _teamList!.length) {
|
//没有数据了
|
_refreshController.loadNoData();
|
}
|
}
|
}
|
|
AppNotifyMsgModel? _notifyMsg;
|
|
void _getNotify() async {
|
AppNotifyMsgModel? notifyMsgModel =
|
await MsgApiUtil.getNotifyMsg(context, "team");
|
setState(() {
|
_notifyMsg = notifyMsgModel;
|
});
|
}
|
|
@override
|
Widget build(BuildContext context) {
|
return Scaffold(
|
backgroundColor: const Color(0xFFFFFFFF),
|
body: Column(
|
children: [
|
TopNavBar(
|
title: "团队",
|
rightImage: Image.asset(
|
"assets/imgs/mine/icon_team_invite_new.png",
|
height: 20,
|
),
|
rightClick: () {
|
NavigatorUtil.navigateToNextPage(
|
context, InviteFriendsPage(title: ""), (data) {});
|
},
|
),
|
// Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
// Expanded(flex: 1, child: getNavItem("直接队员", 0)),
|
// Container(
|
// width: 1,
|
// height: 20,
|
// color: const Color(0xFFE0E0E0),
|
// ),
|
// Expanded(flex: 1, child: getNavItem("间接队员", 1)),
|
// ]),
|
|
//通知消息
|
_notifyMsg == null
|
? Container()
|
: NotifyWidget(_notifyMsg!.content!,
|
textColor: const Color(0xFFFF8316),
|
bgColor: const Color(0xFFF5EBA4),
|
paddingRight: 0),
|
Expanded(
|
child: Container(
|
color: const Color(0xFFF0F0F0),
|
child: RefreshListView(
|
refreshController: _refreshController,
|
refresh: () {
|
_refresh();
|
},
|
loadMore: () {
|
_loadMore();
|
},
|
content: ListView.builder(
|
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
itemCount: _teamList == null ? 0 : _teamList!.length,
|
itemBuilder: (BuildContext context, int index) {
|
return getItemView(index);
|
},
|
),
|
emptyView: level == 0
|
? Column(
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
Padding(
|
padding: EdgeInsets.only(left: 60, right: 60),
|
child: MyFillButton(
|
"邀请好友刷视频赚钱",
|
10,
|
height: 44,
|
fontSize: 15,
|
onClick: () {
|
NavigatorUtil.navigateToNextPage(context,
|
InviteFriendsPage(title: ""), (data) {});
|
},
|
)),
|
InkWell(
|
onTap: () {
|
ConfigUtil.getConfig(context, "helpLink")
|
.then((value) {
|
if (value == null) {
|
return;
|
}
|
NavigatorUtil.navigateToNextPage(
|
context,
|
BrowserPage(title: "帮助中心", url: value),
|
(data) {});
|
});
|
},
|
child: const Padding(
|
padding: EdgeInsets.all(10),
|
child: Text(
|
"帮助",
|
style: TextStyle(
|
fontSize: 12, color: Color(0xFF0090FF)),
|
)))
|
],
|
)
|
: Container(
|
alignment: Alignment.center, child: Text("暂无数据")),
|
),
|
))
|
],
|
));
|
}
|
|
Widget getNavItem(title, int index) {
|
return InkWell(
|
onTap: () {
|
bool needRefresh = level != index;
|
|
setState(() {
|
level = index;
|
});
|
|
if (needRefresh) {
|
setState(() {
|
_teamList = null;
|
});
|
|
_refresh();
|
}
|
},
|
child: Column(
|
children: [
|
const SizedBox(
|
height: 10,
|
),
|
Text(
|
title,
|
style: TextStyle(
|
color: index == level ? ColorConstant.theme : Colors.black,
|
fontSize: 15,
|
fontWeight: FontWeight.bold),
|
),
|
Container(
|
width: 67,
|
height: 3,
|
margin: EdgeInsets.only(top: 10),
|
decoration: BoxDecoration(
|
borderRadius: BorderRadius.circular(1),
|
color: index == level ? ColorConstant.theme : Colors.white),
|
)
|
],
|
));
|
}
|
|
Widget getItemView(int index) {
|
return Container(
|
margin: const EdgeInsets.only(top: 11),
|
height: 85,
|
padding: const EdgeInsets.fromLTRB(15, 0, 10, 0),
|
decoration: BoxDecoration(
|
color: Colors.white, borderRadius: BorderRadius.circular(13)),
|
child: Row(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
children: [
|
ClipRRect(
|
borderRadius: BorderRadius.circular(30),
|
child: CommonImage(
|
_teamList![index].user!.portrait!,
|
width: 45,
|
height: 45,
|
)),
|
const SizedBox(
|
width: 12,
|
),
|
Expanded(
|
child: Container(
|
padding: EdgeInsets.zero,
|
height: 45,
|
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
Text(
|
_teamList![index].user!.nickName!,
|
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
style: const TextStyle(
|
color: Colors.black, fontSize: 14, height: 1),
|
),
|
Text(
|
_teamList![index].tag ?? "",
|
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
style: const TextStyle(
|
color: Color(0xFF888888), fontSize: 9, height: 1.4),
|
),
|
Expanded(child: Container()),
|
Text(
|
"入队时间:${_teamList![index].joinTime!}",
|
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
style: const TextStyle(
|
color: Color(0xFF888888), fontSize: 12, height: 1),
|
),
|
],
|
))),
|
_teamList![index].todayGoldCorn == null ||
|
_teamList![index].todayGoldCorn == 0
|
? Container()
|
: Column(
|
crossAxisAlignment: CrossAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
const Text(
|
"今日奖励",
|
style: TextStyle(
|
color: Colors.black, fontSize: 12, height: 1.5),
|
),
|
Wrap(
|
children: [
|
Image.asset(
|
"assets/imgs/icon_goldcorn.png",
|
height: 19,
|
),
|
const SizedBox(
|
width: 4,
|
),
|
Text(
|
"+${_teamList![index].todayGoldCorn}",
|
style: const TextStyle(
|
color: Color(0xFFFF8316),
|
fontSize: 15,
|
fontWeight: FontWeight.bold),
|
)
|
],
|
)
|
],
|
)
|
],
|
),
|
);
|
}
|
}
|