circle_app/circle_app/lib/app/call_out/view.dart
2023-08-07 15:49:10 +08:00

769 lines
31 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/components/my_app_bar.dart';
import 'package:circle_app/util/util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:video_player/video_player.dart';
import '../../router/app_routers.dart';
import 'logic.dart';
class Call_outPage extends StatelessWidget {
Call_outPage({Key? key}) : super(key: key);
final logic = Get.find<Call_outLogic>();
final state = Get.find<Call_outLogic>().state;
@override
Widget build(BuildContext context) {
return GetBuilder<Call_outLogic>(builder: (logic) {
return GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(getBaseImage('home_back')))),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: MyAppBar(
centerTitle: '圈内喊话',
actionWdiget: Image.asset(
getCircleImage('push'),
width: 54.sp,
),
onPressed: () {
//
//showToast('111');
logic.sendShout();
},
),
body: SafeArea(
child: GetBuilder(builder: (Call_outLogic controller) {
return Column(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
logic.startSelectCircleActivity();
},
child: Container(
height: 45.sp,
padding: EdgeInsets.only(left: 17.sp, right: 17.sp),
child: Row(
children: [
Text(
'选择圈子:',
style: TextStyle(
color: Colors.white, fontSize: 16.sp),
),
Expanded(child: Container()),
logic.circleName == ''
? Container()
: Container(
padding: EdgeInsets.only(
left: 7.sp, right: 7.sp),
height: 21.sp,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
21 * 0.5.sp),
gradient: const LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xff0AFCFF),
Color(0xffD739EA)
])),
child: Text(
logic.circleName,
style: TextStyle(
color: Colors.white,
fontSize: 12.sp),
),
),
Image.asset(
getHomeImage('icon_in'),
width: 24.sp,
),
],
),
),
),
Image.asset(
getCircleImage('line'),
width: Get.width,
fit: BoxFit.fill,
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 15.sp),
child: Stack(
children: [
SizedBox(
height: 200.sp,
child: TextField(
controller: controller.textEditingController,
onChanged: (value) {
controller.update();
},
style: TextStyle(
color: Colors.white, fontSize: 14.0.sp),
maxLines: 32,
maxLength: 200,
decoration: InputDecoration(
hintStyle: TextStyle(
color: const Color.fromRGBO(
255, 255, 255, 0.6),
fontSize: 14.sp),
hintText: '请输入...(左下角上传图片或视频哦)',
border: InputBorder.none,
contentPadding: EdgeInsets.only(
left: 17.sp, right: 17.sp),
counter: const Text('')),
),
),
Positioned(
right: 15.sp,
top: 190.sp,
child: Text(
'${controller.textEditingController.text.length}/200',
style: TextStyle(
color: Colors.white, fontSize: 12.sp),
)),
Container(
margin: EdgeInsets.only(top: 220.sp),
child: _imageAdapter(controller)),
Container(
margin: EdgeInsets.only(top: 220.sp,left: 15.sp,right: 15.sp),
child:_showVideo(controller) ,)
],
),
)),
Container(
height: 60.sp,
padding: EdgeInsets.only(
left: 17.sp, right: 17.sp, bottom: 5.sp),
child: Row(
children: [
GestureDetector(
onTap: () {
logic.showImg();
},
child: Image.asset(
getCircleImage('photo'),
width: 30.sp,
),
),
const SizedBox(
width: 16,
),
GestureDetector(
onTap: () {
logic.showVideo();
},
child: Image.asset(
getCircleImage('video'),
width: 30.sp,
),
),
Expanded(
child: GestureDetector(
onTap: () {
if(controller.vip ==2){
controller.isCheck = !controller.isCheck;
controller.update();
}else{
showToast("至尊喊话为年会员特权,开通年会员即可享受哦~");
controller.showRechargeDialog();
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
getCircleImage(controller.isCheck
? 'check'
: 'uncheck'),
width: 17.5.sp,
),
SizedBox(
width: 4.sp,
),
Text(
'使用至尊喊话',
style: TextStyle(
color: Colors.white,
fontSize: 16.sp),
)
],
),
),
),
GestureDetector(
onTap: (){
navigateToContentGuidelines();
},
child: Text(
'内容规范',
style: TextStyle(
color: const Color(0xff00FFF4),
fontSize: 14.sp),
),
)
],
),
)
],
);
}),
),
)),
);
});
}
Widget _showVideo(Call_outLogic controller) {
if (controller.videoPlayerController == null) {
return Container();
} else {
return _mixVideo(controller);
}
}
// Widget _maxVideo(Call_outLogic controller){
// return SizedBox(
// width:controller.videoPlayerController!.value.size.width < controller.videoPlayerController!.value.size.height ? 9*15.sp : 16*15.sp,
// height:controller.videoPlayerController!.value.size.width < controller.videoPlayerController!.value.size.height ? 16*15.sp :9*15.sp,
//
// child: Stack(
// children: [
// ClipRRect(
// borderRadius: BorderRadius.circular(6.sp),
// child: VideoItemWidget(controller.state.videolist[0])),
// // Center(child:controller.videoPlayerController!.value.isPlaying ? Container() : Image(image: AssetImage(getMineImage("icon_play")),width: 30.sp,height: 30.sp,),),
// Positioned(
// top: 0,
// right: 0,
// child: GestureDetector(
// onTap: () {
// // showToast("删除");
// _showDelVideoDialog(Get.context!, controller);
// },
// child: Image(
// image: AssetImage(getMineImage("icon_img_del")),
// width: 20.sp,
// height: 20.sp,
// ),
// ))
//
// // ClosedCaption(text: controller.videoPlayerController!.value.caption.text),
// // _ControlsOverlay(controller: controller.videoPlayerController),
// // VideoProgressIndicator(controller.videoPlayerController!, allowScrubbing: true),
// ],
// ),
// );
// }
Widget _mixVideo(Call_outLogic controller){
return SizedBox(
width:controller.videoPlayerController!.value.size.width < controller.videoPlayerController!.value.size.height ? 135.sp : 240.sp,
height:controller.videoPlayerController!.value.size.width < controller.videoPlayerController!.value.size.height ? 240.sp :135.sp,
child: GestureDetector(
onTap: () {
if(controller.videoPlayerController!.value.isPlaying){
controller.videoPlayerController!.pause();
}else{
controller.videoPlayerController!.play();
}
controller.update();
},
child: AspectRatio(
aspectRatio: controller.videoPlayerController!.value.aspectRatio,
child: Stack(
children: [
VideoPlayer(controller.videoPlayerController!),
Center(child:controller.videoPlayerController!.value.isPlaying ? Container() : Image(image: AssetImage(getMineImage("icon_play")),width: 30.sp,height: 30.sp,),),
Positioned(
top: 0,
right: 0,
child: GestureDetector(
onTap: () {
// showToast("删除");
_showDelVideoDialog(Get.context!, controller);
},
child: Image(
image: AssetImage(getMineImage("icon_img_del")),
width: 20.sp,
height: 20.sp,
),
))
// ClosedCaption(text: controller.videoPlayerController!.value.caption.text),
// _ControlsOverlay(controller: controller.videoPlayerController),
// VideoProgressIndicator(controller.videoPlayerController!, allowScrubbing: true),
],
),
),
),
);
}
Widget _imageAdapter(Call_outLogic controller) {
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // 每行显示的项目数量
),
itemCount: controller.state.imaglist.length, // 项目的总数量,包括固定图片和接口获取的项目
itemBuilder: (BuildContext context, int index) {
return Container(
margin: EdgeInsets.all(5.sp),
child: Center(
child: _buildImageItem(
controller.state.imaglist[index], controller, index)),
);
},
);
}
Widget _buildImageItem(String url, Call_outLogic controller, int index) {
return Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(0.0),
child: SizedBox(
width: double.infinity, // 设置容器宽度为屏幕宽度
height: double.infinity, // 设置容器高度为屏幕高度
child: ClipRRect(
borderRadius: BorderRadius.circular(0.0),
child: GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.Swiper, arguments: {
'imaglist': controller.state.imaglist,
'index': index
});
},
child: Image.network(
fit: BoxFit.cover,
url,
),
),
),
),
),
Positioned(
top: 0,
right: 0,
child: GestureDetector(
onTap: () {
// showToast("删除");
_showDelImgDialog(Get.context!, controller, index);
},
child: Image(
image: AssetImage(getMineImage("icon_img_del")),
width: 20.sp,
height: 20.sp,
),
))
],
);
}
void _showDelImgDialog(
BuildContext context, Call_outLogic controller, int index) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 160.sp,
padding: const EdgeInsets.all(1.0),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: const 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: const 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: const 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: const 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: const 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: const 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: const Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
void _showDelVideoDialog(
BuildContext context, Call_outLogic controller) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
child: Container(
height: 160.sp,
padding: const EdgeInsets.all(1.0),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0),
gradient: const 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: const 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: const 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: const 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: const Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
),
SizedBox(width: 24.sp),
GestureDetector(
onTap: () {
Navigator.pop(context);
controller.videoPlayerController?.dispose();
controller.videoPlayerController=null;
controller.state.videolist = [];
controller.update();
},
child: Container(
margin: EdgeInsets.only(top: 24.sp),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17),
gradient: const 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: const Text(
"",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
)
],
)
],
),
)
],
),
),
);
},
);
}
// 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,
// ),
// ),
// ],
// ),
// ))
// ],
// ),
// ),
// ),
// );
// }
}