123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:sport/bean/rank_game_info.dart';
- import 'package:sport/bean/user.dart';
- import 'package:sport/bean/user_info.dart';
- import 'package:sport/pages/social/chat_page.dart';
- import 'package:sport/pages/social/private_message_page.dart';
- import 'package:sport/router/navigator_util.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/services/userid.dart';
- import 'package:sport/utils/toast.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/button_primary.dart';
- import 'package:sport/widgets/dialog/request_dialog.dart';
- import 'package:sport/widgets/image.dart';
- import 'package:sport/widgets/misc.dart';
- import 'package:sport/widgets/space.dart';
- class RankPeopleDetailsPage extends StatefulWidget {
- final User _data;
- RankPeopleDetailsPage(this._data);
- @override
- State<StatefulWidget> createState() {
- return _RankPeopleDetailsPageState();
- }
- }
- class _RankPeopleDetailsPageState extends State<RankPeopleDetailsPage> with InjectApi, UserId {
- ValueNotifier<UserInfo> _valueNotifierUserInfo;
- @override
- void initState() {
- super.initState();
- _valueNotifierUserInfo = ValueNotifier(UserInfo.fromJson(widget._data.toJson()));
- api.getUserInfo("${widget._data.userId}").then((value) {
- _valueNotifierUserInfo.value = value.data;
- });
- }
- @override
- Widget build(BuildContext context) {
- final data = widget._data;
- return Scaffold(
- backgroundColor: Colors.white,
- appBar: AppBar(
- backgroundColor: Colors.white,
- elevation: 0,
- leading: buildBackButton(context),
- ),
- body: SingleChildScrollView(
- // physics: ClampingScrollPhysics(),
- child: Container(
- color: Colors.white,
- width: double.infinity,
- child: Column(
- children: <Widget>[
- ValueListenableBuilder(
- valueListenable: _valueNotifierUserInfo,
- builder: (BuildContext context, UserInfo user, Widget child) {
- if (user == null) {
- return Container();
- }
- return Container(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- CircleAvatar(
- backgroundImage: userAvatarProvider(user.avatar),
- radius: 45,
- ),
- Space(
- height: 12,
- ),
- Text(user.name, style: Theme.of(context).textTheme.headline1),
- Space(
- height: 6,
- ),
- Row(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Image.asset("lib/assets/img/mine_icon_${user.gender == 1 ? "man" : "girl"}_gray.png"),
- Space(
- width: 4,
- ),
- Text(user.gender == 1 ? "男" : "女", style: Theme.of(context).textTheme.bodyText1),
- Space(
- width: 10,
- ),
- Text(user.age != null ? "${user.age}岁" : "", style: Theme.of(context).textTheme.bodyText1),
- if ((user.districtId ?? 0) != 0)
- Padding(
- padding: const EdgeInsets.only(left: 10.0),
- child: Text("${user.province}${user.province == user.city ? '' : user.city}", style: Theme.of(context).textTheme.bodyText1),
- )
- ],
- ),
- if (selfId != '${widget._data.userId}')
- Padding(
- padding: const EdgeInsets.only(top: 20.0),
- child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
- PrimaryButton(
- width: 120,
- height: 35,
- callback: () {
- // 先尝试换一下
- NavigatorUtil.goPage(context, (context) => ChatPage(user));
- // NavigatorUtil.goPage(context, (context) => PrivateMessagePage(user));
- },
- content: '',
- child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
- Image.asset("lib/assets/img/mine_icon_message.png"),
- Space(
- width: 6,
- ),
- Text(
- "私信",
- strutStyle: fixedLine,
- style: Theme.of(context).textTheme.subtitle1.copyWith(color: Colors.white),
- )
- ]),
- ),
- Space(
- width: 12,
- ),
- user.followStatus == "friends" || user.followStatus == "followed"
- ? GestureDetector(
- child: Container(
- width: 120,
- height: 35,
- alignment: Alignment.center,
- child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
- Image.asset("lib/assets/img/mine_icon_followed.png"),
- Space(
- width: 6,
- ),
- Text(
- "已关注",
- strutStyle: fixedLine,
- style: Theme.of(context).textTheme.subtitle1.copyWith(color: Theme.of(context).accentColor),
- )
- ]),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- border: Border.all(
- color: Theme.of(context).accentColor,
- width: .5,
- ),
- ),
- ),
- onTap: () async {
- await request(context, () async {
- var resp = await api.userUnFollow(uid: user.id).catchError((onError) {});
- if (resp?.code == 0) {
- ToastUtil.show("取关成功");
- user.followStatus = "none";
- setState(() {});
- }
- });
- },
- )
- : PrimaryButton(
- width: 120,
- height: 35,
- callback: () async {
- await request(context, () async {
- var resp = await api.userFollow(uid: user.id).catchError((onError) {});
- if (resp?.code == 0) {
- ToastUtil.show("关注成功");
- user.followStatus = "followed";
- setState(() {});
- }
- });
- },
- content: '',
- child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
- Image.asset("lib/assets/img/mine_icon_follow.png"),
- Space(
- width: 6,
- ),
- Text(
- "关注",
- strutStyle: fixedLine,
- style: Theme.of(context).textTheme.subtitle1.copyWith(color: Colors.white),
- )
- ]),
- ),
- ]),
- ),
- Space(
- height: 32,
- ),
- ],
- ),
- );
- },
- ),
- Divider(
- endIndent: 12,
- indent: 12,
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "榜单排名",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "第 ${data.position} 名",
- style: TextStyle(color: Color.fromRGBO(255, 196, 0, 1)),
- )
- ],
- ),
- ),
- if (data.score != null)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "通关评分",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.score.toStringAsFixed(1)}分",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- if (data.sportDay == 0)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "通关日期",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.finishAt}",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- if (data.sportDay == 0)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "通关时长",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.duration}分钟",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- if (data.sportDay > 0)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "运动时长",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.duration}分钟",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- if (data.sportDay > 0)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "运动天数",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.sportDay}天",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- if (data.sportDay > 0)
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "每天平均时长",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.duration ~/ data.sportDay}分钟/天",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(
- bottom: 12.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "消耗能量",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${data.consume} kal",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(
- bottom: 5.0,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "运动效率",
- style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1)),
- ),
- Text(
- "${(data.consume / data.duration).toStringAsFixed(2)} kal/min",
- style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1)),
- )
- ],
- ),
- ),
- ],
- ),
- ),
- Divider(
- endIndent: 12,
- indent: 12,
- ),
- Column(
- children: <Widget>[
- Space(
- height: 24,
- ),
- // head
- Stack(
- alignment: Alignment.center,
- children: <Widget>[
- Image.asset(
- "lib/assets/img/mine_image_achievement.png",
- fit: BoxFit.fitWidth,
- width: 240,
- ),
- Text(
- "${(widget?._data?.userId?.toString() == selfId) ? "我" : "他"}的成就",
- style: Theme.of(context).textTheme.subtitle1,
- )
- ],
- ),
- // bottom
- Space(
- height: 12,
- ),
- ValueListenableBuilder(
- valueListenable: _valueNotifierUserInfo,
- builder: (BuildContext context, UserInfo user, Widget child) {
- if (user == null) {
- return Container();
- }
- return Padding(padding: EdgeInsets.all(12.0), child: achievementGroupWidget(user.achievements));
- },
- ),
- ],
- )
- ],
- ),
- ),
- ));
- }
- }
|