328 lines
12 KiB
Dart
328 lines
12 KiB
Dart
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 ReportPage extends StatelessWidget {
|
||
ReportPage({Key? key}) : super(key: key);
|
||
|
||
final logic = Get.find<ReportLogic>();
|
||
final state = Get.find<ReportLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return GetBuilder(builder: (ReportLogic controller) {
|
||
return GestureDetector(
|
||
onTap: () {
|
||
FocusManager.instance.primaryFocus?.unfocus();
|
||
},
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getBaseImage("home_back")),
|
||
fit: BoxFit.cover,
|
||
),
|
||
),
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
appBar: MyAppBar(
|
||
centerTitle: '举报',
|
||
actionWdiget: Text(
|
||
"提交",
|
||
style: TextStyle(color: Colors.white),
|
||
),
|
||
onPressed: () {
|
||
logic.onSubmit();
|
||
},
|
||
),
|
||
body: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Padding(
|
||
padding: EdgeInsets.only(left: 16.sp, top: 16.sp),
|
||
child: Text(
|
||
'举报类目',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
),
|
||
),
|
||
),
|
||
Container(
|
||
height: 120.sp,
|
||
child: _reportAdapter(controller),
|
||
),
|
||
Expanded(
|
||
child: Padding(
|
||
padding: EdgeInsets.fromLTRB(16, 20, 16, 0),
|
||
child: ListView(
|
||
children: [
|
||
Text(
|
||
'详细截图(请至少上传一张图片,帮助审核处理)',
|
||
style: TextStyle(
|
||
color: Colors.white70,
|
||
fontSize: 16.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 20.sp),
|
||
// 添加 RecyclerView(ListView) 的内容
|
||
// 例如: MyRecyclerViewWidget(),
|
||
Container(
|
||
height: 130.sp,
|
||
child: _imageAdapter(controller)),
|
||
Text(
|
||
'补充说明',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 30),
|
||
Container(
|
||
// margin: EdgeInsets.only(left: 10, right: 10),
|
||
height: 200.sp,
|
||
width: double.infinity,
|
||
decoration: BoxDecoration(
|
||
color: Color(0xFF4C3E5F),
|
||
borderRadius: BorderRadius.circular(10),
|
||
),
|
||
padding: EdgeInsets.all(16.sp),
|
||
child: Stack(
|
||
children: [
|
||
Container(
|
||
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: Color.fromRGBO(
|
||
255, 255, 255, 0.6),
|
||
fontSize: 14.sp),
|
||
hintText: '违规补充说明,帮助审核处理,选填',
|
||
border: InputBorder.none,
|
||
|
||
counter: Text('')),
|
||
),
|
||
),
|
||
Positioned(
|
||
// right: 1.sp,
|
||
top: 160.sp,
|
||
child: Text(
|
||
'${controller.textEditingController.text.length}/200',
|
||
style: TextStyle(
|
||
color: Colors.white, fontSize: 12.sp),
|
||
)),
|
||
|
||
|
||
|
||
],
|
||
)
|
||
|
||
|
||
// Stack(
|
||
// children: [
|
||
// TextField(
|
||
// decoration: InputDecoration.collapsed(
|
||
// hintText: '违规补充说明,帮助审核处理,选填',
|
||
// border: InputBorder.none,
|
||
// hintStyle: TextStyle(
|
||
// color: Color(0xFFB7BECC),
|
||
// fontSize: 12,
|
||
// ),
|
||
// ),
|
||
// maxLength: 200,
|
||
// style: TextStyle(
|
||
// color: Color(0xFFFFFFFF),
|
||
// fontSize: 12,
|
||
// ),
|
||
// ),
|
||
// ],
|
||
// ),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
);
|
||
});
|
||
}
|
||
|
||
Widget _reportAdapter(ReportLogic controller) {
|
||
return GridView.builder(
|
||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||
crossAxisCount: 3,
|
||
// crossAxisSpacing: 6.sp,
|
||
childAspectRatio: 3,
|
||
),
|
||
itemCount: controller.getItemList().length,
|
||
shrinkWrap: true,
|
||
itemBuilder: (BuildContext context, int index) {
|
||
return GestureDetector(
|
||
onTap: () {
|
||
if(controller.myPosition != -1){
|
||
controller.arrList[controller.myPosition].isSelect = false;
|
||
}
|
||
controller.myPosition = index;
|
||
controller.arrList[index].isSelect = true;
|
||
controller.update();
|
||
},
|
||
child: _getItemSelect(controller.arrList[index]),
|
||
);
|
||
},
|
||
);
|
||
}
|
||
|
||
Widget _imageAdapter(ReportLogic controller) {
|
||
return GridView.builder(
|
||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||
crossAxisCount: 3, // 每行显示的项目数量
|
||
),
|
||
itemCount: controller.state.imaglist.length<3 ? controller.state.imaglist.length+1: controller.state.imaglist.length, // Replace with your item count// 项目的总数量,包括固定图片和接口获取的项目
|
||
itemBuilder: (BuildContext context, int index) {
|
||
if (index == 0&&controller.state.imaglist.length<3) {
|
||
// 第一个项目,显示固定的图片
|
||
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.length<3 ?
|
||
controller.state.imaglist[index-1]: controller.state.imaglist[index], // Replace with your item count
|
||
controller,controller.state.imaglist.length<3 ? index-1:index ),
|
||
),
|
||
);
|
||
}
|
||
},
|
||
);
|
||
}
|
||
|
||
Widget _getItemSelect(MyObject bean) {
|
||
if (bean.isSelect) {
|
||
return Container(
|
||
margin:
|
||
EdgeInsets.only(left: 8.sp, right: 8.sp, top: 6.sp, bottom: 6.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(20.sp),
|
||
gradient: LinearGradient(
|
||
colors: [
|
||
Color(0xFF06F9FA),
|
||
Color(0xFFDC5BFD),
|
||
],
|
||
begin: Alignment.centerLeft,
|
||
end: Alignment.centerRight,
|
||
),
|
||
),
|
||
padding:
|
||
EdgeInsets.only(top: 2.sp, bottom: 2.sp, left: 15.sp, right: 15.sp),
|
||
child: Center(
|
||
child: Text(
|
||
bean.name,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 11.sp,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
} else {
|
||
return Container(
|
||
margin:
|
||
EdgeInsets.only(left: 8.sp, right: 8.sp, top: 6.sp, bottom: 6.sp),
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(20.0), // 设置圆角半径
|
||
border: Border.all(
|
||
color: Color(0xFF392D53),
|
||
),
|
||
color: Color(0xFF392D53),
|
||
),
|
||
child: Padding(
|
||
padding: EdgeInsets.only(
|
||
top: 2.sp, bottom: 2.sp, left: 15.sp, right: 15.sp),
|
||
child: Center(
|
||
child: Text(
|
||
bean.name,
|
||
style: TextStyle(
|
||
fontSize: 11.0,
|
||
color: Colors.white,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
Widget _buildImageItem(String url, ReportLogic controller, int index) {
|
||
return Stack(
|
||
children: [
|
||
ClipRRect(
|
||
borderRadius: BorderRadius.circular(0.0),
|
||
child: Container(
|
||
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: () {
|
||
controller.state.imaglist.removeAt(index);
|
||
controller.update();
|
||
},
|
||
child: Image(
|
||
image: AssetImage(getMineImage("icon_img_del")),
|
||
width: 20.sp,
|
||
height: 20.sp,
|
||
),
|
||
))
|
||
],
|
||
);
|
||
}
|
||
}
|