644 lines
25 KiB
Dart
644 lines
25 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:circle_app/app/circle/logic.dart';
|
|
import 'package:circle_app/app/circle/widgets/info_list_view.dart';
|
|
import 'package:circle_app/app/my_circle/logic.dart';
|
|
import 'package:circle_app/app/select_circle/logic.dart';
|
|
import 'package:circle_app/common/Widgets/circle_share.dart';
|
|
import 'package:circle_app/common/Widgets/text_more.dart';
|
|
import 'package:circle_app/components/my_app_bar.dart';
|
|
import 'package:circle_app/router/app_routers.dart';
|
|
import 'package:circle_app/util/util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../util/eventBus.dart';
|
|
|
|
class My_circlePage extends StatefulWidget {
|
|
My_circlePage({Key? key}) : super(key: key);
|
|
@override
|
|
_My_circlePageState createState() => _My_circlePageState();
|
|
}
|
|
|
|
class _My_circlePageState extends State<My_circlePage>
|
|
with AutomaticKeepAliveClientMixin {
|
|
@override
|
|
bool get wantKeepAlive => true;
|
|
|
|
// 是否需要缓存
|
|
final logic = Get.put(MyCircleLogic());
|
|
|
|
final state = Get.find<MyCircleLogic>().state;
|
|
|
|
var getContext;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
getContext = context;
|
|
return Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF423055),
|
|
image: DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: AssetImage(getBaseImage('home_back')))),
|
|
child: Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
body: SafeArea(
|
|
child: GetBuilder(builder: (MyCircleLogic controller) {
|
|
return Stack(
|
|
children: [
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height,
|
|
child: Container(
|
|
child: Column(children: [
|
|
backNavigatorItem(),
|
|
// Text(controller.state.msg),
|
|
//组件使用
|
|
Expanded(
|
|
child: logic.circle.lists.isEmpty
|
|
? !logic.isMore
|
|
? noResultWidget()
|
|
: loaddingWidget(logic.isMore)
|
|
: ListView.builder(
|
|
// controller: logic.rightCtr,
|
|
itemBuilder: (context, index) {
|
|
var bean = logic.circle.lists[index];
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.translucent,
|
|
onTap: () {
|
|
|
|
Get.toNamed(AppRoutes.Signal_circle_list, arguments: bean.id);
|
|
|
|
},
|
|
child: circleInfoItemWidget(
|
|
logic.circle.lists[index]));
|
|
},
|
|
itemCount: logic.circle.lists.length,
|
|
))
|
|
// Swiper(
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
// var bean = logic.circle.lists[index];
|
|
// // final GlobalKey<InfoListViewState> infoListViewKey = GlobalKey<InfoListViewState>();
|
|
// // MyinfoListViewKey = infoListViewKey;
|
|
// return InfoListView(
|
|
// index,
|
|
// bean,
|
|
// controller
|
|
// );
|
|
// },
|
|
// index: controller.state.index,
|
|
// itemCount: logic.circle.lists.length,
|
|
// viewportFraction: 0.93,
|
|
// // scale: 0.9,
|
|
// loop: false,
|
|
// onIndexChanged: (index) {
|
|
// controller.state.index = index;
|
|
// if (index == logic.circle.lists.length - 1 && controller.isMore) {
|
|
//
|
|
// logic.loadMore();
|
|
// }
|
|
//
|
|
// },
|
|
// // pagination: new SwiperPagination(),//如果不填则不显示指示点
|
|
// // control: new SwiperControl(),//如果不填则不显示左右按钮
|
|
// )
|
|
]),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
));
|
|
}
|
|
|
|
var MyinfoListViewKey;
|
|
|
|
circleInfoItemWidget(Circle bean) {
|
|
List<JoinUser> urlList = bean.lastJoinUsers;
|
|
List<Widget> widgets = [];
|
|
int i = 0;
|
|
// print(urlList);
|
|
if (null != urlList) {
|
|
urlList.forEach((element) {
|
|
if (widgets.length > 2) {
|
|
return;
|
|
}
|
|
widgets.add(Positioned(
|
|
left: 15.sp * i,
|
|
child: circleWidget(
|
|
element.avatar! ??
|
|
"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",
|
|
),
|
|
));
|
|
i++;
|
|
});
|
|
}
|
|
return Container(
|
|
margin: EdgeInsets.only(bottom: 10.sp, left: 10.sp, right: 10.sp),
|
|
child: Column(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(10.sp),
|
|
topRight: Radius.circular(10.sp)),
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
|
|
height: 72.sp,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: AssetImage(getCircleImage('top_circle_bg')))),
|
|
child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
width: 42.sp,
|
|
height: 42.sp,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
gradient: const LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFF71F3F2),
|
|
Color(0xFFF558FF),
|
|
],
|
|
stops: [0.0365, 0.9427],
|
|
),
|
|
),
|
|
padding: EdgeInsets.all(1.sp),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
child: CachedNetworkImage(
|
|
imageUrl: bean.image,
|
|
width: 40.sp,
|
|
height: 40.sp,
|
|
memCacheHeight: 40,
|
|
memCacheWidth: 40,
|
|
fit: BoxFit.cover),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 8.sp, top: 12.sp),
|
|
// alignment: Alignment.,
|
|
height: 72.sp,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
bean.title,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w600),
|
|
),
|
|
SizedBox(
|
|
height: 4.sp,
|
|
),
|
|
Text(
|
|
'${convertToTenThousand(bean.viewTotal)}人看过',
|
|
textAlign: TextAlign.left,
|
|
style: TextStyle(
|
|
color: const Color(0xff03FEFB),
|
|
fontSize: 12.sp,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
GestureDetector(
|
|
//加入圈子
|
|
onTap: () async {
|
|
if (bean.isJoin) {
|
|
Get.bottomSheet(
|
|
CircleShare('','',bean), isScrollControlled: true,
|
|
enableDrag: false
|
|
);
|
|
} else {
|
|
await logic.outCircle(
|
|
bean.id.toString(), bean.isJoin);
|
|
}
|
|
},
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Image.asset(
|
|
getCircleImage('add'),
|
|
width: 77.sp,
|
|
),
|
|
Text(
|
|
!bean.isJoin ? '申请加入' : '分享有奖',
|
|
style: TextStyle(
|
|
color: Colors.white, fontSize: 12.sp),
|
|
)
|
|
],
|
|
))
|
|
],
|
|
),
|
|
)),
|
|
Container(
|
|
padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
|
|
// height:urlList.length==0?47.sp: 118.sp,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: AssetImage(getCircleImage('circle_desc')))),
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 10.sp, bottom: 10.sp),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(bottom: 7.sp),
|
|
width: Get.width - 20.sp,
|
|
// height: 50.sp,
|
|
child: HideText(
|
|
text: bean.intro,
|
|
maxWidth: Get.width - 50.sp,
|
|
additionText: '查看更多',
|
|
maxLines: 3,
|
|
style:
|
|
TextStyle(color: Colors.white, fontSize: 17.sp),
|
|
additionStyle: TextStyle(
|
|
color: const Color(0xFFFF4DF6), fontSize: 17.sp),
|
|
onTap: () {
|
|
_showTextContentDialog(
|
|
Get.context!,
|
|
bean.intro,
|
|
);
|
|
},
|
|
)),
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
// showToast("点个鸡毛,星哥还没做");
|
|
// Get.toNamed(AppRoutes.FriendsActivity,arguments: '3');
|
|
},
|
|
child: urlList.length == 0
|
|
? Container()
|
|
: Row(
|
|
children: [
|
|
SizedBox(
|
|
height: 30.sp,
|
|
width:
|
|
30.0.sp + 14.sp * (widgets.length - 1.sp),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: widgets,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 4.sp,
|
|
),
|
|
Text(
|
|
'${convertToTenThousand(bean.joinTotal)}圈友加入',
|
|
style: TextStyle(
|
|
color: Colors.white, fontSize: 12.sp),
|
|
),
|
|
SizedBox(
|
|
width: 4.sp,
|
|
),
|
|
// GestureDetector(
|
|
// onTap: () {
|
|
// // Get.bottomSheet(
|
|
// // CircleShare(logic.homeData!.inviteCode!,logic.homeData!.link!,bean), isScrollControlled: true,
|
|
// // enableDrag: false
|
|
// // );
|
|
// },
|
|
// behavior: HitTestBehavior.opaque,
|
|
// child: Container(
|
|
// height: 30.sp,
|
|
// alignment: Alignment.center,
|
|
// child: Image.asset(
|
|
// getCircleImage('play'),
|
|
// width: 20.sp,
|
|
// ),
|
|
// ),
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
backNavigatorItem() {
|
|
return MyAppBar(
|
|
centerTitle: '我的圈子',
|
|
onCenterTitlePressed: () {
|
|
EventBusManager.fire(ScrollToTop());
|
|
},
|
|
actionWdiget: Image.asset(
|
|
getCircleImage('callout_icon'),
|
|
width: 75.sp,
|
|
),
|
|
onPressed: () async {
|
|
List<MyConfigData> numbers = [];
|
|
numbers.add(MyConfigData(logic.getCircleIndex().id.toString(),
|
|
logic.getCircleIndex().title!, false));
|
|
var data = await Get.toNamed(AppRoutes.Call_out,
|
|
arguments: {'numbers': numbers});
|
|
// MyinfoListViewKey.currentState?.loadCallOutListData();
|
|
// logic.refresh();
|
|
// logic.update();
|
|
},
|
|
);
|
|
}
|
|
|
|
navigatorItem() {
|
|
List<String> urlList = [
|
|
'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp',
|
|
'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp',
|
|
'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp'
|
|
];
|
|
List<Widget> widgets = [];
|
|
int index = 0;
|
|
urlList.forEach((element) {
|
|
widgets.add(Positioned(
|
|
left: 15.sp * index,
|
|
child: circleWidget(element),
|
|
));
|
|
index++;
|
|
});
|
|
return Container(
|
|
width: Get.width,
|
|
padding: EdgeInsets.only(left: 18.sp, right: 18.sp),
|
|
height: 44.sp,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 0,
|
|
child: Container(
|
|
width: 30.sp * widgets.length,
|
|
height: 44.sp,
|
|
child: Stack(
|
|
alignment: Alignment.centerLeft,
|
|
children: widgets,
|
|
),
|
|
)),
|
|
ShaderMask(
|
|
shaderCallback: (Rect bounds) {
|
|
return const LinearGradient(
|
|
begin: Alignment(0.0, -1.0),
|
|
end: Alignment.bottomCenter,
|
|
colors: [Color(0xff71F3F2), Color(0xffF657FF)],
|
|
).createShader(Offset.zero & bounds.size);
|
|
},
|
|
child: Text(
|
|
'发现',
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
shadows: [
|
|
Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1))
|
|
]),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(AppRoutes.MyCircle,
|
|
arguments: '', preventDuplicates: false);
|
|
},
|
|
child: Image.asset(
|
|
getCircleImage('my_circle'),
|
|
width: 64.sp,
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
circleWidget(String url, {double width = 30}) {
|
|
return GestureDetector(
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Image.asset(
|
|
getCircleImage('avatar_bg'),
|
|
width: width.sp,
|
|
),
|
|
ClipOval(
|
|
child: Image.network(
|
|
url,
|
|
width: (width - 1).sp,
|
|
height: (width - 1).sp,
|
|
fit: BoxFit.fill,
|
|
),
|
|
)
|
|
],
|
|
));
|
|
}
|
|
|
|
void _showTextContentDialog(BuildContext context, String msg) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
child: Container(
|
|
height: 300.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: [
|
|
Container(
|
|
margin: EdgeInsets.only(
|
|
top: 12.sp, left: 14.sp, right: 14.sp),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
msg,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Color(0xCCF7FAFA), fontSize: 16.sp),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
void _showOutCircleDialog(BuildContext context, var controller, Circle bean) {
|
|
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);
|
|
logic.outCircle(bean.id.toString(), bean.isJoin);
|
|
},
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|