AI_Drawing/lib/tools/me/screen_tips.dart
2024-06-03 15:30:15 +08:00

117 lines
4.1 KiB
Dart

import 'package:flutter/material.dart';
import '../../generated/l10n.dart';
///排序弹框
class ScreenTips extends StatefulWidget {
// 点击返回index 0 1
final double dx;
final double dy;
final int index;
final int type; //0 我的作品 1 收藏
Function onTap;
ScreenTips({required this.dx, required this.dy, required this.index, required this.type, required this.onTap});
@override
_ScreenTipsState createState() => _ScreenTipsState();
}
class _ScreenTipsState extends State<ScreenTips> {
List<String> items = [];
@override
void initState() {
// TODO: implement initState
super.initState();
Future.delayed(const Duration(seconds: 0), () {
if (widget.type == 0) {
items = [S.of(context).Newest, S.of(context).Oldest, S.of(context).Most_favorite, S.of(context).Least_Favorite];
} else {
items = [S.of(context).Newest, S.of(context).Oldest];
}
setState(() {});
});
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
double h = items.length * 30 + 0.33;
return Material(
type: MaterialType.transparency, //透明类型
color: const Color(0x00000000),
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Stack(
children: <Widget>[
Positioned(
top: widget.dy - 5,
right: 5,
child: SizedBox(
width: 90,
height: h,
child: Card(
clipBehavior: Clip.antiAlias,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
margin: const EdgeInsets.all(0), //
child: ListView.builder(
shrinkWrap: true,
itemCount: items.length,
itemExtent: 30,
padding: const EdgeInsets.only(left: 0, right: 0),
//数据的数量
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.pop(context);
if (widget.onTap != null) {
widget.onTap(index);
}
},
child: Container(
color: Color(widget.index == index ? 0xFFE0E0E0 : 0xFFFFFFFF),
child: Stack(
children: [
index == 0
? Container()
: Container(
height: 1,
width: double.infinity,
color: const Color(0xFFE0E0E0),
),
Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(left: 0, top: 0),
width: double.infinity,
child: Text(
items[index],
style: TextStyle(
color: widget.index == index ? const Color(0xFF8841FF) : const Color(0xFF666666),
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
],
),
));
},
physics: const BouncingScrollPhysics(),
//类似 cellForRow 函数
scrollDirection: Axis.vertical),
),
),
),
],
),
),
);
}
}