circle_app/circle_app/lib/app/circle/view.dart

493 lines
18 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:circle_app/app/circle/widgets/info_list_view.dart';
import 'package:circle_app/common/Widgets/open_vip_tip/view.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 '../select_circle/logic.dart';
import 'logic.dart';
class CirclePage extends StatefulWidget {
CirclePage({Key? key}) : super(key: key);
@override
State<CirclePage> createState() => _CirclePageState();
}
class _CirclePageState extends State<CirclePage>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
// 是否需要缓存
final logic = Get.put(CircleLogic());
final state = Get.find<CircleLogic>().state;
var getContext;
@override
Widget build(BuildContext context) {
getContext = context;
return GetBuilder<CircleLogic>(builder: (logic) {
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: Image.asset(
// getBaseImage('bg'),
// fit: BoxFit.fill,
// ),
child: Scaffold(
backgroundColor: Colors.transparent,
body: SafeArea(
child: GetBuilder(builder: (CircleLogic controller) {
return Stack(
children: [
Container(
child: Column(children: [
navigatorItem(),
Text(controller.state.msg),
//组件使用
Expanded(
child: Swiper(
itemBuilder: (BuildContext context, int index) {
var bean = logic.circle.lists[index];
return InfoListView(index, bean, logic);
},
onIndexChanged: (index) {
controller.state.index = index;
if (index == logic.circle.lists.length - 1) {
logic.loadMore();
}
print(index.toString());
controller.update();
},
index: controller.state.index,
itemCount: logic.circle.lists.length,
viewportFraction: 0.95,
// scale: 0.9,
loop: false,
// pagination: new SwiperPagination(),//如果不填则不显示指示点
// control: new SwiperControl(),//如果不填则不显示左右按钮
))
]),
),
Positioned(
bottom: 36.sp,
right: 10.sp,
child: GestureDetector(
onTap: () 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});
},
child: Image.asset(
getCircleImage('send_msg'),
width: 60.sp,
)))
],
);
}),
),
));
});
}
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(
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(
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,
),
)
],
));
}
tipWdiget() {
return Container(
width: Get.width,
height: Get.height,
child: Center(
child: Container(
width: 339.sp,
height: 330.sp,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(getCircleImage('add_tip_bg')))),
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
top: 5.sp,
right: 12.sp,
child: GestureDetector(
onTap: () {
Get.back();
},
child: Image.asset(
getCircleImage('close'),
width: 24.sp,
),
)),
Positioned(
top: 24.sp,
child: Text(
'解锁圈子才能主动私聊',
style: TextStyle(color: Colors.white, fontSize: 16.sp),
)),
Positioned(
left: 17.sp,
top: 64.sp,
child: Text(
'为什么要解锁圈子?',
style: TextStyle(color: Colors.white, fontSize: 16.sp),
)),
Positioned(
top: 98.sp,
child: Container(
width: 339.sp,
padding: EdgeInsets.only(left: 17.sp, right: 17.sp),
child: Text(
'为打造纯净的社交环境,更好地服务大家,基于以下几方面考虑:1、平台升级为全天24小时人工审核保证用户真实避免骗子、酒托、虚假人士等扰乱平台 ;2、杜绝未入圈用户随意骚扰或影响已入圈的跨友;3、谢绝只会白嫖的猎奇人士。',
style: TextStyle(
color: Color.fromRGBO(247, 250, 250, 0.8),
fontSize: 12.sp)),
)),
Positioned(
bottom: 18.sp,
child: Container(
width: 168.sp,
height: 42.sp,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21.sp),
gradient: const LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xff0AFCFF), Color(0xffD739EA)])),
child: Text(
'立即解锁',
style: TextStyle(color: Colors.white, fontSize: 16.sp),
),
)),
Positioned(
bottom: 72.sp,
child: Container(
child: Row(
children: [
Text(
'¥18',
style: TextStyle(
color: Color(0xffE845FF),
fontSize: 16.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
width: 2.sp,
),
Text(
'(原价60)',
style: TextStyle(
color: Colors.white70,
fontSize: 16.sp,
fontWeight: FontWeight.w400,
decoration: TextDecoration.lineThrough,
decorationColor: Colors.white70,
),
),
],
),
))
],
),
),
),
);
}
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, CircleLogic 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,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
}