232 lines
9.1 KiB
Dart
232 lines
9.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../generated/l10n.dart';
|
|
|
|
class guideDialog extends StatefulWidget {
|
|
// 点击返回index 0 1
|
|
Function onTap;
|
|
final String name;
|
|
final List list;
|
|
final List selectList;
|
|
|
|
guideDialog({Key? key, required this.onTap, required this.name, required this.list, required this.selectList}) : super(key: key);
|
|
|
|
@override
|
|
_guideDialogState createState() => _guideDialogState();
|
|
}
|
|
|
|
class _guideDialogState extends State<guideDialog> {
|
|
List selectList = [];
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
if (widget.selectList != null && widget.selectList.isNotEmpty) {
|
|
selectList = widget.selectList;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h328 = size.width / 1.097561;
|
|
final h564 = size.width / 0.64;
|
|
return Material(
|
|
type: MaterialType.transparency, //透明类型
|
|
color: const Color(0x1A000000),
|
|
child: Center(
|
|
// ClipRRect 创建圆角矩形 要不然发现下边button不是圆角
|
|
child: Container(
|
|
width: h328,
|
|
height: h564,
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
//设置四周圆角 角度
|
|
borderRadius: BorderRadius.all(Radius.circular(6.6))),
|
|
child: Stack(
|
|
alignment: Alignment.topCenter,
|
|
children: <Widget>[
|
|
Container(
|
|
margin: const EdgeInsets.only(top: 14),
|
|
child: Text(
|
|
widget.name,
|
|
style: const TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.w800),
|
|
),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(left: 12, right: 12, top: 52, bottom: 58),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: widget.list.length,
|
|
padding: const EdgeInsets.all(0),
|
|
//数据的数量
|
|
itemBuilder: (context, index) {
|
|
return GestureDetector(
|
|
onTap: () {},
|
|
child: Container(
|
|
margin: const EdgeInsets.only(bottom: 13),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFF3F3FB),
|
|
//设置四周圆角 角度
|
|
borderRadius: BorderRadius.all(Radius.circular(6.6))),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
margin: const EdgeInsets.only(left: 13, top: 13),
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
widget.list[index]["name"].toString(),
|
|
style: const TextStyle(color: Colors.black, fontSize: 16),
|
|
),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(left: 13, bottom: 18, top: 18),
|
|
child: Wrap(
|
|
spacing: 15.0,
|
|
//主轴间距
|
|
runSpacing: 15,
|
|
//副轴间距
|
|
alignment: WrapAlignment.start,
|
|
//主轴上的对齐方式
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
//副轴上的对齐方式
|
|
children: List<Widget>.generate(
|
|
widget.list[index]["content"].length,
|
|
(int i) {
|
|
return _sizeItem2(index, widget.list[index]["content"][i], i);
|
|
},
|
|
).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
));
|
|
},
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
//类似 cellForRow 函数
|
|
scrollDirection: Axis.vertical),
|
|
],
|
|
),
|
|
)),
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
if (widget.onTap != null) {
|
|
Navigator.pop(context);
|
|
widget.onTap(selectList);
|
|
}
|
|
},
|
|
child: Container(
|
|
height: 40,
|
|
alignment: Alignment.center,
|
|
margin: const EdgeInsets.only(bottom: 11, left: 23, right: 23),
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.centerLeft, //渐变开始于上面的中间开始
|
|
end: Alignment.centerRight, //渐变结束于下面的中间
|
|
colors: [Color(0xFF808EEF), Color(0xFFBE6FDF)]),
|
|
borderRadius: BorderRadius.all(Radius.circular(20))),
|
|
child: Text(
|
|
S.of(context).Save,
|
|
style: const TextStyle(color: Colors.white, fontSize: 16),
|
|
),
|
|
),
|
|
)),
|
|
Positioned(
|
|
top: 15,
|
|
right: 15,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: const SizedBox(
|
|
width: 20,
|
|
height: 20,
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/cuo.png'),
|
|
),
|
|
),
|
|
))
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_sizeItem2(index, String bean, i) {
|
|
bool isSelect = false;
|
|
if (selectList != null && selectList.isNotEmpty) {
|
|
for (var v in selectList) {
|
|
if (bean == v) {
|
|
isSelect = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return Container(
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
if (selectList.contains(bean)) {
|
|
selectList.remove(bean);
|
|
} else {
|
|
selectList.add(bean);
|
|
}
|
|
print(selectList); //{a: a3, 2: b3, 3: null}
|
|
setState(() {});
|
|
},
|
|
child: Container(
|
|
padding: const EdgeInsets.only(left: 10, right: 10, top: 1, bottom: 1),
|
|
decoration: BoxDecoration(
|
|
//设置四周圆角 角度
|
|
borderRadius: const BorderRadius.all(Radius.circular(3.5)),
|
|
//设置四周边框
|
|
border: Border.all(width: 1, color: Color(isSelect ? 0xFFBE75FF : 0xFF666666)),
|
|
color: Color(isSelect ? 0xFFBE75FF : 0x00FFFFFF),
|
|
),
|
|
child: Text(
|
|
bean,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(color: Color(isSelect ? 0xFFFFFFFF : 0xFF999999), fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
/* _sizeItem2(List<String> list) {
|
|
return list.map((e) {
|
|
int index = list.indexOf(e);
|
|
return GestureDetector(
|
|
onTap: () {
|
|
mainBodyIndex = index;
|
|
t2 = responseData["body"][index]["content"];
|
|
setState(() {});
|
|
},
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF3F3FB),
|
|
//设置四周圆角 角度
|
|
borderRadius: const BorderRadius.all(Radius.circular(6.6)),
|
|
//设置四周边框
|
|
border: Border.all(width: 1, color: Color(mainBodyIndex == index ? 0xFF8841FF : 0xFFFFFFFF)),
|
|
),
|
|
child: Text(
|
|
list[index],
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(color: Color(mainBodyIndex == index ? 0xFF8841FF : 0xFF999999), fontSize: 12),
|
|
),
|
|
),
|
|
);
|
|
}).toList();
|
|
}*/
|
|
}
|