circle_app/circle_app/lib/app/userinfo/view.dart

903 lines
30 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../components/my_app_bar.dart';
import '../../router/app_routers.dart';
import '../../util/util.dart';
import 'logic.dart';
class UserinfoPage extends StatefulWidget {
@override
_MyTabbedScreenState createState() => _MyTabbedScreenState();
}
class _MyTabbedScreenState extends State<UserinfoPage>
with SingleTickerProviderStateMixin {
late TabController _tabController;
ScrollController scrollController = ScrollController();
bool isShowBlackTitle = false;
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
void _onScroll(offset) {
if (offset > 100) {
setState(() {
isShowBlackTitle = true;
});
} else {
setState(() {
isShowBlackTitle = false;
});
}
}
final logic = Get.find<UserinfoLogic>();
final state = Get.find<UserinfoLogic>().state;
@override
Widget build(BuildContext context) {
return GetBuilder(builder: (UserinfoLogic controller) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(getBaseImage("home_back")),
fit: BoxFit.cover,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
centerTitle: '个人主页',
),
body: Stack(
children: [
Container(
child: buildContent(controller),
),
Positioned(
bottom: 27.sp,
width: Get.width,
child: _MeInfoButton(controller),
)
],
),
));
});
}
Widget _MeInfoButton(UserinfoLogic controller) {
if (controller.userId == "") {
return GestureDetector(
onTap: () {
// showToast("完善资料");
Get.toNamed(AppRoutes.Complete_materialPage, arguments: "user");
},
child: Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp, bottom: 10.sp, left: 55.sp, right: 55.sp),
child: Text(
"完善个人形象照",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
),
);
} else {
return Container(
margin: EdgeInsets.only(left: 18.sp, right: 18.sp),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
showToast("鼓掌");
_showBottomSheet(context);
},
child: Image(
image: AssetImage(getMineImage("icon_like")),
width: 40.sp,
height: 40.sp,
),
),
GestureDetector(
onTap: () {
showToast("喜欢");
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17.sp),
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp, bottom: 10.sp, left: 52.sp, right: 52.sp),
child: Text(
"喜欢",
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
),
),
),
),
GestureDetector(
onTap: () {
showToast("私聊");
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17.sp),
gradient: LinearGradient(
colors: [
Color(0x26FFFFFF),
Color(0x26FFFFFF),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp, bottom: 10.sp, left: 52.sp, right: 52.sp),
child: Text(
"私聊",
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
),
),
),
)
],
),
);
}
}
Widget buildContent(UserinfoLogic controller) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 19.sp, vertical: 14.sp),
child: Column(
children: [
Row(
children: [
_imagelistView(controller),
Flexible(
child: buildUserContainer(),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
"name",
style: TextStyle(
color: Color.fromRGBO(247, 250, 250, 1.0),
fontSize: 16,
),
),
SizedBox(width: 10.sp),
_buildInfoRow(),
],
),
Row(
children: [
Container(
margin: EdgeInsets.only(right: 5.sp),
width: 10.sp,
height: 10.sp,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFF00FFF4),
),
),
Text(
"在线·深圳",
style: TextStyle(color: Color(0xFF00FFF4)),
)
],
),
],
),
Container(
// margin: EdgeInsets.only(top: 18.sp, bottom: 18.sp),
height: 59.sp,
child: ListView.builder(
itemCount: 8,
// 替换为实际的 item 数量
scrollDirection: Axis.horizontal,
// 设置为水平方向
padding: EdgeInsets.symmetric(vertical: 18.sp),
// 替换为实际的边距值
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.only(right: 11.sp), // 替换为实际的 item 间距
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17.0), // 设置圆角半径
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
),
color: Color(0xFF392D53),
),
child: Container(
margin: EdgeInsets.all(0.2.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17.0),
// shape: BoxShape.circle,
color: Color(0xFF392D53),
),
child: Padding(
padding: EdgeInsets.only(
top: 2.sp, bottom: 2.sp, left: 15.sp, right: 15.sp),
child: Center(
child: Text(
"圆角背景边框",
style: TextStyle(
fontSize: 11.0,
color: Colors.white,
),
),
),
),
),
), // 替换为实际的列表项小部件
);
},
),
),
titleTab(),
Container(
margin: EdgeInsets.only(top: 18.sp, bottom: 14.sp),
child: Text(
"1314位圈友感兴趣其中10位已催您更新",
style: TextStyle(color: Colors.white30),
)),
Expanded(
child: Container(
// color: Colors.blue,
child: TabBarView(
controller: _tabController,
children: [
_imageAdapter(controller),
Text("喊话"),
],
),
))
],
),
);
}
Widget titleTab(){
return Container(
alignment: Alignment.centerLeft,
height: 27.sp,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TabBar(
isScrollable: true,
controller: _tabController,
indicatorColor: Color(0xFF00FFF4),
indicatorWeight: 2.sp,
labelColor: Color(0xFF00FFF4),
unselectedLabelColor: Color(0xB3FFFFFF),
indicatorSize: TabBarIndicatorSize.label,
tabs: [
Tab(
text: "形象照",
),
Tab(text: "喊话")
],
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 2.sp, bottom: 2.sp, left: 12.sp, right: 12.sp),
child: Text(
"完成",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
],
));
}
Widget _imageAdapter(UserinfoLogic controller) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // 每行显示的项目数量
),
itemCount: controller.state.imaglist.length+1, // 项目的总数量,包括固定图片和接口获取的项目
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
// 第一个项目,显示固定的图片
return GestureDetector(
onTap: () {
controller.getImageFile();
},
child: Container(
margin: EdgeInsets.all(5.sp),
child: Image(
image: AssetImage(getMineImage("icon_img_add")),
),
),
);
} else {
// 后续项目,根据接口获取数据
// 假设通过接口获取到的数据存储在一个名为 data 的列表中
// var itemData = data[index - 1]; // 减去第一个固定图片的索引
return Container(
margin: EdgeInsets.all(5.sp),
child: Center(
child: _buildImageItem(
controller.state.imaglist[index-1],
controller,index-1)),
);
}
},
);
}
Widget _buildInfoRow() {
return Row(
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color.fromRGBO(141, 255, 248, 1.0),
Color.fromRGBO(181, 211, 255, 1.0),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 2.sp, bottom: 2.sp, left: 10.sp, right: 10.sp),
child: Text(
"33CD",
style: TextStyle(
color: Colors.black,
fontSize: 10,
),
),
),
SizedBox(width: 6.sp),
Image(
image: AssetImage(getBaseImage("vip")),
width: 44.sp,
height: 18.sp,
),
],
);
}
Widget buildUserContainer() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 1.sp, vertical: 14.sp),
height: 58.sp,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(getMineImage("icon_user_content")),
fit: BoxFit.fill,
),
),
child: Container(
margin: EdgeInsets.only(left: 24.sp),
child: Center(
child: Text(
'动物是灵性的动物是灵性的动物是灵性的动物是灵性的动物是灵性的动物是灵性的动物是灵性的,不同于植物。 你若孤独, 它陪伴你。在阳光的午后,蜷缩在你的...',
maxLines: 2,
style: TextStyle(color: Colors.white),
overflow: TextOverflow.ellipsis,
),
),
),
);
}
Widget _imagelistView(UserinfoLogic controller) {
return Stack(
alignment: Alignment.center,
children: [
Container(
width: 68.sp,
height: 68.sp,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
SizedBox(
width: 66.sp,
height: 66.sp,
child: _buildAvatar1(controller),
)
],
);
}
Widget _buildAvatar1(UserinfoLogic controller) {
return ClipOval(
child: GestureDetector(
onTap: () {
var imgList = <String>[];
imgList.add("https://book.flutterchina.club/assets/img/logo.png");
Get.toNamed(AppRoutes.Swiper,arguments:imgList);
},
child: Image.network(
'https://book.flutterchina.club/assets/img/logo.png',
width: 66.sp,
height: 66.sp,
),
),
);
}
Widget _buildImageItem(String url, UserinfoLogic controller,int index) {
return Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(0.0),
child: GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.Swiper,arguments:controller.state.imaglist);
},
child: Image.network(
url,
),
),
),
if (controller.userId == "")
Positioned(
top: 0,
right: 0,
child: GestureDetector(
onTap: () {
// showToast("删除");
_showDelImgDialog(context,controller,index);
},
child: Image(
image: AssetImage(getMineImage("icon_img_del")),
width: 20.sp,
height: 20.sp,
),
))
],
);
}
void _showBottomSheet(BuildContext context) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
gradient: LinearGradient(
colors: [
Color(0xFF4A3E5D),
Color(0xFF344143),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
height: 118.0,
width: double.infinity,
child: Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
Get.toNamed(AppRoutes.ReportActivity);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image(
image: AssetImage(getMineImage("icon_report")),
width: 40.sp,
height: 40.sp,
),
Container(
margin: EdgeInsets.only(top: 2.sp),
child: Text(
"举报",
style: TextStyle(color: Colors.white),
),
)
],
),
),
SizedBox(width: 75.sp),
GestureDetector(
onTap: () {
Navigator.pop(context);
_showReportDialog(context);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image(
image: AssetImage(getMineImage("icon_block")),
width: 40.sp,
height: 40.sp,
),
Container(
margin: EdgeInsets.only(top: 2.sp),
child: Text(
"拉黑",
style: TextStyle(color: Colors.white),
),
)
],
),
),
],
),
));
},
);
}
void _showDelImgDialog(BuildContext context,UserinfoLogic controller,int index) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 160.sp,
padding: EdgeInsets.all(1.0),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
Container(
margin: EdgeInsets.all(1.sp),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [Color(0xFF4C3E5F), Color(0xFF324140)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
Container(
margin: EdgeInsets.only(top: 24.sp),
child: Column(
children: [
Center(
child: Text(
"提示",
style:
TextStyle(color: Colors.white, fontSize: 16.sp),
),
),
Container(
margin: EdgeInsets.only(
top: 12.sp, left: 14.sp, right: 14.sp),
alignment: Alignment.center,
child: Text(
"是否确认删除该形象照。",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xCCF7FAFA), fontSize: 16.sp),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
margin: EdgeInsets.only(top: 30.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0x26FFFFFF),
Color(0x26FFFFFF),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp,
bottom: 10.sp,
left: 52.sp,
right: 52.sp),
child: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
),
SizedBox(width: 24.sp),
GestureDetector(
onTap: () {
Navigator.pop(context);
controller.state.imaglist.removeAt(index);
controller.update();
},
child: Container(
margin: EdgeInsets.only(top: 24.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp,
bottom: 10.sp,
left: 52.sp,
right: 52.sp),
child: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
void _showReportDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 277.sp,
padding: EdgeInsets.all(1.0),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
Container(
margin: EdgeInsets.all(1.sp),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [Color(0xFF4C3E5F), Color(0xFF324140)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
Container(
margin: EdgeInsets.only(top: 24.sp),
child: Column(
children: [
Center(
child: Text(
"是否拉黑",
style:
TextStyle(color: Colors.white, fontSize: 16.sp),
),
),
Container(
margin: EdgeInsets.only(top: 14.sp),
alignment: Alignment.center,
child: Image(
image: AssetImage(getMineImage("icon_dialog_black")),
width: 70.sp,
height: 70.sp,
),
),
Container(
margin: EdgeInsets.only(
top: 12.sp, left: 14.sp, right: 14.sp),
alignment: Alignment.center,
child: Text(
"拉黑后,你将屏蔽对方的任何信息若您关注了对方,将自动取消关注。",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xCCF7FAFA), fontSize: 16.sp),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
margin: EdgeInsets.only(top: 24.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0x26FFFFFF),
Color(0x26FFFFFF),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp,
bottom: 10.sp,
left: 52.sp,
right: 52.sp),
child: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
),
SizedBox(width: 24.sp),
GestureDetector(
onTap: () {},
child: Container(
margin: EdgeInsets.only(top: 24.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: LinearGradient(
colors: [
Color(0xFF06F9FA),
Color(0xFFDC5BFD),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
padding: EdgeInsets.only(
top: 10.sp,
bottom: 10.sp,
left: 52.sp,
right: 52.sp),
child: Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
}