app-starlock/lib/tools/custom_bottom_sheet.dart
2024-08-19 15:24:14 +08:00

116 lines
2.9 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
class AlertBottomWidget extends StatelessWidget {
AlertBottomWidget(
{required this.items, required this.chooseCallback, required this.topTitle, Key? key})
: super(key: key);
List items;
ValueChanged<int> chooseCallback;
String topTitle;
List<Widget> itemsWidget(context) {
List<Widget> list = [];
if (topTitle.isNotEmpty) {
list.add(Container(
padding: const EdgeInsets.only(top: 18, bottom: 18),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
topTitle,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
fontSize: ScreenUtil().setSp(24)),
),
// const SizedBox(
// height: 4,
// ),
// Text(
// subTitle,
// style: TextStyle(
// color: AppColors.darkGrayTextColor,
// fontSize: ScreenUtil().setSp(24)),
// )
],
),
));
list.add(
Container(
color: AppColors.greyBackgroundColor,
height: 8,
),
);
}
for (int i = 0; i < items.length; i++) {
list.add(
SizedBox(
width: ScreenUtil().screenWidth,
child: TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
items[i],
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(22)),
),
onPressed: () {
Navigator.pop(context);
chooseCallback(i);
},
),
),
);
list.add(Container(
height: 1.h,
color: AppColors.greyBackgroundColor,
));
}
list.add(
Container(
color: AppColors.greyBackgroundColor,
height: 5.h,
),
);
list.add(SizedBox(
width: ScreenUtil().screenWidth,
child: TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
'取消'.tr,
style: TextStyle(color: Colors.black, fontSize: ScreenUtil().setSp(24)),
),
onPressed: () {
Navigator.pop(context);
},
),
));
return list;
}
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: itemsWidget(context),
),
);
}
}