211 lines
7.1 KiB
Dart
211 lines
7.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_modular/flutter_modular.dart';
|
|
import 'package:peach/config/Colors.dart';
|
|
import 'package:peach/utils/_.dart';
|
|
import 'package:peach/widget/TextLimitDisplay.dart';
|
|
import 'package:peach/widget/_.dart';
|
|
|
|
/*
|
|
* 头像和粉丝内容等
|
|
*/
|
|
class PersonalpTitle extends StatelessWidget {
|
|
final double headImgHeight;
|
|
final bool isEditing;
|
|
final bool isText;
|
|
final Function onExpand;
|
|
final double textHeight;
|
|
// 是否是本人空间 true 是
|
|
final bool isOpenFollow;
|
|
// 是否已经关注 true 是
|
|
final bool isFollow;
|
|
final Function opusFollowUser;
|
|
|
|
// 头像
|
|
final String imgHead;
|
|
final String nickname;
|
|
final String autograph;
|
|
final int fansNums;
|
|
final int satisfiedNums;
|
|
final int followNums;
|
|
|
|
final int userId;
|
|
|
|
PersonalpTitle({
|
|
this.headImgHeight = 58,
|
|
this.isEditing = false,
|
|
this.onExpand,
|
|
this.isText = false,
|
|
this.textHeight = 20,
|
|
this.imgHead = '',
|
|
this.nickname = '',
|
|
this.autograph = '',
|
|
this.fansNums = 0,
|
|
this.satisfiedNums = 0,
|
|
this.followNums = 0,
|
|
this.isOpenFollow = false,
|
|
this.isFollow = false,
|
|
this.opusFollowUser,
|
|
this.userId = 0,
|
|
});
|
|
|
|
GlobalKey txtKey = GlobalKey();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(right: Screen.setWidth(40)),
|
|
child: ClipOval(
|
|
child: Image.network(
|
|
imgHead,
|
|
width: Screen.setWidth(this.headImgHeight),
|
|
height: Screen.setWidth(this.headImgHeight),
|
|
fit: BoxFit.cover,
|
|
),
|
|
)),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
width: 160,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
Modular.to.pushNamed("/fans/${userId}");
|
|
},
|
|
child: Column(
|
|
children: [
|
|
Text(fansNums.toString(),
|
|
style: TextStyle(fontSize: 16)),
|
|
Text(
|
|
"粉丝",
|
|
style: TextStyle(
|
|
color: ColorConfig.TextColor,
|
|
fontSize: 14,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Modular.to.pushNamed("/follow/${userId}");
|
|
},
|
|
child: Column(
|
|
children: [
|
|
Text(followNums.toString(),
|
|
style: TextStyle(fontSize: 16)),
|
|
Text(
|
|
"关注",
|
|
style: TextStyle(
|
|
color: ColorConfig.TextColor,
|
|
fontSize: 14,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(satisfiedNums.toString(),
|
|
style: TextStyle(fontSize: 16)),
|
|
Text(
|
|
"获赞",
|
|
style: TextStyle(
|
|
color: ColorConfig.TextColor,
|
|
fontSize: 14,
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
this.isEditing
|
|
? Container(
|
|
width: Screen.setWidth(240),
|
|
margin: EdgeInsets.only(top: Screen.setFontSize(5)),
|
|
child: isOpenFollow
|
|
? FollowButton(
|
|
isCheck: isFollow,
|
|
onPressed: () {
|
|
opusFollowUser();
|
|
})
|
|
: ElevatedButton(
|
|
style: ButtonStyle(backgroundColor:
|
|
MaterialStateProperty.resolveWith(
|
|
(states) {
|
|
//设置按下时的背景颜色
|
|
if (states
|
|
.contains(MaterialState.pressed)) {
|
|
return ColorConfig.ThemeOtherColor;
|
|
}
|
|
//默认不使用背景颜色
|
|
return ColorConfig.ThemeColor;
|
|
})),
|
|
child: Text("编辑资料",
|
|
style: TextStyle(fontSize: Screen.setFontSize(18))),
|
|
onPressed: () {
|
|
Navigator.of(context)
|
|
.pushNamed("/editMaterials");
|
|
},
|
|
),
|
|
)
|
|
: Container()
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
var keyContext = txtKey.currentContext;
|
|
if (keyContext != null) {
|
|
final txtBox = keyContext.findRenderObject() as RenderBox;
|
|
print(
|
|
'height ${txtBox.size.height} and width ${txtBox.size.width}');
|
|
}
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: Screen.setHeight(10)),
|
|
child: Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
nickname,
|
|
style: TextStyle(
|
|
color: ColorConfig.ThemeColor,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: Screen.setHeight(10)),
|
|
child: Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
autograph,
|
|
style: TextStyle(
|
|
color: ColorConfig.TextColor,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|