YSAlertView.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import '../../tools/YSTools.dart';
  3. class YSTipsAlertView extends StatefulWidget {
  4. final ValueSetter<bool> valueSetter;
  5. final String tipsStr;
  6. final String? btnStr1;
  7. final String? btnStr2;
  8. const YSTipsAlertView({Key? key, required this.valueSetter, this.tipsStr = '', this.btnStr1, this.btnStr2}) : super(key: key);
  9. @override
  10. YSTipsAlertViewState createState() => YSTipsAlertViewState();
  11. }
  12. class YSTipsAlertViewState extends State<YSTipsAlertView> {
  13. @override
  14. Widget build(BuildContext context) {
  15. return Center(
  16. child: Container(
  17. width: ysWidth(context)-30,
  18. height: 150,
  19. decoration: const BoxDecoration(
  20. color: Colors.white,
  21. borderRadius: BorderRadius.all(Radius.circular(10))
  22. ),
  23. child: LayoutBuilder(
  24. builder: (context,conSize){
  25. return Column(
  26. children: [
  27. Container(
  28. height: 100,
  29. alignment: Alignment.center,
  30. padding: const EdgeInsets.all(10),
  31. child: Text(widget.tipsStr,
  32. style: const TextStyle(fontSize: 15,color: Colors.black,decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 3,overflow: TextOverflow.ellipsis,),
  33. ),
  34. Container(
  35. height: 50,
  36. decoration: const BoxDecoration(
  37. border: Border(top: BorderSide(color: Colors.grey,width: 0.5))
  38. ),
  39. child: ListView.separated(
  40. itemBuilder: (context,index){
  41. return GestureDetector(
  42. onTap: (){
  43. Navigator.pop(context);
  44. widget.valueSetter(index==1);
  45. },
  46. behavior: HitTestBehavior.opaque,
  47. child: Container(
  48. width: conSize.maxWidth/2-0.25,
  49. alignment: Alignment.center,
  50. child: Text(
  51. index==0?widget.btnStr1??'否':widget.btnStr2??'是',
  52. style: const TextStyle(fontSize: 15,color: Colors.black,decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  53. ),
  54. ),
  55. );
  56. },
  57. separatorBuilder: (context,index){
  58. return Container(width: 0.5,color:Colors.grey,);
  59. },
  60. itemCount: 2,
  61. scrollDirection: Axis.horizontal,
  62. ),
  63. )
  64. ],
  65. );
  66. },
  67. ),
  68. ),
  69. );
  70. }
  71. }