app-starlock/lib/tools/custom_bottom_sheet.dart

122 lines
3.0 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
2023-11-28 13:47:49 +08:00
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
2023-11-28 13:47:49 +08:00
import '../translations/trans_lib.dart';
class AlertBottomWidget extends StatelessWidget {
List items;
ValueChanged<int> chooseCallback;
String topTitle;
AlertBottomWidget(
{Key? key,
required this.items,
required this.chooseCallback,
required this.topTitle})
: super(key: key);
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);
},
),
),
);
2024-04-02 17:30:44 +08:00
list.add(Container(
height: 1.h,
color: AppColors.greyBackgroundColor,
));
}
list.add(
Container(
color: AppColors.greyBackgroundColor,
2024-04-02 17:30:44 +08:00
height: 5.h,
),
);
list.add(SizedBox(
width: ScreenUtil().screenWidth,
child: TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
2023-11-28 13:47:49 +08:00
TranslationLoader.lanKeys!.cancel!.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),
),
);
}
}