YSBase.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'package:flutter/material.dart';
  2. import '../tool/YSTools.dart';
  3. class YSBase extends StatefulWidget {
  4. final Color ysColor;
  5. final bool isTab;
  6. final String ysTitle;
  7. final Widget? ysRightWidget;
  8. final Widget? ysChild;
  9. const YSBase({Key? key, this.ysColor = const Color(0xFF23262B), this.isTab = false, this.ysTitle = '', this.ysRightWidget, this.ysChild}) : super(key: key);
  10. @override
  11. YSBaseState createState() => YSBaseState();
  12. }
  13. class YSBaseState extends State<YSBase> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return Scaffold(
  17. backgroundColor: widget.ysColor,
  18. body: GestureDetector(
  19. onTap: (){
  20. FocusScope.of(context).unfocus();
  21. },
  22. child: SizedBox(
  23. width: ysWidth(context),
  24. height: ysHeight(context),
  25. child: SingleChildScrollView(
  26. child: Column(
  27. children: [
  28. Container(
  29. height: ysTOP(context)+44,
  30. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: ysTOP(context)),
  31. decoration: BoxDecoration(
  32. color: widget.ysColor,
  33. ),
  34. child: LayoutBuilder(
  35. builder: (context,conSize){
  36. return Row(
  37. children: [
  38. Container(
  39. width: hsp(50),
  40. alignment: Alignment.centerLeft,
  41. child: widget.isTab==true?SizedBox(width: hsp(30),):GestureDetector(
  42. onTap: (){
  43. Navigator.pop(context);
  44. },
  45. child: Container(
  46. height: hsp(30),
  47. width: hsp(30),
  48. alignment: Alignment.center,
  49. decoration: BoxDecoration(
  50. color: const Color(0xFF23262B),
  51. borderRadius: const BorderRadius.all(Radius.circular(50)),
  52. border: Border.all(color: const Color(0xFF23262B),width: hsp(1)),
  53. boxShadow: const [
  54. BoxShadow(color: Color(0xFF3E434E),blurRadius: 5)
  55. ]
  56. ),
  57. child: Image.asset('images/tzh_back.png',height: hsp(20),width: hsp(20),),
  58. )
  59. ),
  60. ),
  61. Container(
  62. width: conSize.maxWidth-hsp(100),
  63. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  64. alignment: Alignment.center,
  65. child: Text(widget.ysTitle,style: TextStyle(fontSize: zsp(17),color: Colors.white),),
  66. ),
  67. Container(
  68. width: hsp(50),
  69. alignment: Alignment.centerRight,
  70. child: widget.ysRightWidget??Container(),
  71. )
  72. ],
  73. );
  74. },
  75. ),
  76. ),
  77. SizedBox(
  78. height: ysHeight(context)-ysTOP(context)-(widget.isTab?158:44),
  79. width: ysWidth(context),
  80. child: widget.ysChild,
  81. )
  82. ],
  83. ),
  84. ),
  85. ),
  86. ),
  87. );
  88. }
  89. }