YSBase.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutterappfuyou/code/base/YSTools.dart';
  4. class YSBase extends StatefulWidget {
  5. final Widget yschild;
  6. final String ystitle;
  7. final Widget ysright;
  8. final Color ysColor;
  9. final Color ysBgColor;
  10. final bool isBack;
  11. const YSBase({Key key, this.yschild,this.ystitle,this.ysright, this.ysColor, this.ysBgColor, this.isBack = true}) : super(key: key);
  12. @override
  13. _YSBaseState createState() => _YSBaseState();
  14. }
  15. class _YSBaseState extends State<YSBase> {
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. backgroundColor: widget.ysBgColor??Colors.white,
  20. body: Stack(
  21. children: [
  22. Container(
  23. height: MediaQuery.of(context).padding.top+70,
  24. width: MediaQuery.of(context).size.width,
  25. color: widget.ysColor??Color(0xFFDB5278),
  26. ),
  27. Container(
  28. margin: EdgeInsets.only(top: 20),
  29. padding: EdgeInsets.only(left: 15,right: 15),
  30. height: 30+MediaQuery.of(context).padding.top,
  31. width: MediaQuery.of(context).size.width,
  32. child: Row(
  33. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  34. children: [
  35. Container(
  36. height: 30,
  37. width: 20,
  38. margin: EdgeInsets.only(right: 35),
  39. child: widget.isBack?CupertinoButton(
  40. padding: EdgeInsets.all(0),
  41. child: Icon(Icons.arrow_back_ios,size: 20,color: Colors.white,),
  42. onPressed: (){
  43. FocusScope.of(context).unfocus();
  44. Navigator.pop(context);
  45. },
  46. ):Container(),
  47. ),
  48. Container(
  49. width: ysWidth(context)-150,
  50. child: Text(widget.ystitle,style: TextStyle(color: Colors.white,fontSize: 16,decoration: TextDecoration.none,fontWeight: FontWeight.w600),
  51. textAlign: TextAlign.center,maxLines: 1,),
  52. ),
  53. Container(
  54. width: 55,
  55. height: 30,
  56. child: widget.ysright,
  57. ),
  58. ],
  59. ),
  60. ),
  61. Container(
  62. margin: EdgeInsets.only(top: 50+MediaQuery.of(context).padding.top),
  63. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-50,
  64. width: MediaQuery.of(context).size.width,
  65. decoration: BoxDecoration(
  66. color: widget.ysBgColor??Color(0xFFFAF8F5),
  67. borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20))
  68. ),
  69. child: widget.yschild,
  70. )
  71. ],
  72. ),
  73. );
  74. }
  75. }
  76. class YSBase2 extends StatefulWidget {
  77. final String title;
  78. final Color color;
  79. final Widget child;
  80. const YSBase2({Key key, this.title = '', this.color, @required this.child}) : super(key: key);
  81. @override
  82. _YSBase2State createState() => _YSBase2State();
  83. }
  84. class _YSBase2State extends State<YSBase2> {
  85. @override
  86. Widget build(BuildContext context) {
  87. return Scaffold(
  88. appBar: CupertinoNavigationBar(
  89. backgroundColor: Colors.white,
  90. leading: GestureDetector(
  91. child: Icon(Icons.arrow_back_ios,size: 20),
  92. onTap: (){
  93. Navigator.pop(context);
  94. },
  95. ),
  96. middle: Text(widget.title,style: TextStyle(fontSize: 16),),
  97. ),
  98. body: Container(
  99. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  100. width: MediaQuery.of(context).size.width,
  101. color: widget.color??Colors.white,
  102. child: SingleChildScrollView(
  103. child: widget.child,
  104. ),
  105. ),
  106. );
  107. }
  108. }
  109. class CustomerValueNotification extends Notification {
  110. final Map value;
  111. CustomerValueNotification(this.value);
  112. }