YSBase.dart 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_wallet/generated/l10n.dart';
  3. import 'package:flutter_wallet/login/view/YSHelpView.dart';
  4. import '../tools/YSColors.dart';
  5. import '../tools/YSTools.dart';
  6. class YSBase extends StatefulWidget {
  7. final Color? ysColor;
  8. final bool isTab;
  9. final String ysTitle;
  10. final Widget? ysRightWidget;
  11. final Widget? ysLeftWidget;
  12. final Widget? ysChild;
  13. final bool isBake;
  14. const YSBase({Key? key, this.ysColor, this.isTab = false, this.ysTitle = '', this.ysRightWidget, this.ysChild, this.isBake = false, this.ysLeftWidget}) : super(key: key);
  15. @override
  16. YSBaseState createState() => YSBaseState();
  17. }
  18. class YSBaseState extends State<YSBase> {
  19. @override
  20. Widget build(BuildContext context) {
  21. return Scaffold(
  22. backgroundColor: widget.ysColor??YSColors.containColor(context),
  23. body: GestureDetector(
  24. onTap: (){
  25. FocusScope.of(context).unfocus();
  26. },
  27. child: SizedBox(
  28. width: ysWidth(context),
  29. height: ysHeight(context),
  30. child: SingleChildScrollView(
  31. child: Stack(
  32. children: [
  33. Container(
  34. height: ysTOP(context)+70,
  35. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: ysTOP(context)),
  36. decoration: BoxDecoration(
  37. gradient: LinearGradient(
  38. colors: [YSColors.buttonColor(context),YSColors.buttonColor(context)]
  39. )
  40. ),
  41. child: LayoutBuilder(
  42. builder: (context,conSize){
  43. return Row(
  44. children: [
  45. Container(
  46. width: hsp(75),
  47. alignment: Alignment.centerLeft,
  48. child: widget.isTab==true?SizedBox(
  49. width: hsp(30),
  50. ):widget.ysLeftWidget??GestureDetector(
  51. onTap: (){
  52. Navigator.pop(context);
  53. },
  54. child: Row(
  55. children: [
  56. Icon(Icons.chevron_left,size: zsp(30),color: YSColors.contain2Color(context),),
  57. Text(S.current.FANHUI,style: YSColors.content2Style(context),)
  58. ],
  59. )
  60. ),
  61. ),
  62. Container(
  63. width: conSize.maxWidth-hsp(150),
  64. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  65. alignment: Alignment.center,
  66. child: widget.isBake==true?Image.asset(
  67. YSColors.imageStyle(context, '资源 3'),
  68. width: hsp(150),
  69. height: hsp(30),
  70. ):Text(widget.ysTitle.fixAutoLines(),style: YSColors.title2Style(context),maxLines: 1,),
  71. ),
  72. Container(
  73. width: hsp(75),
  74. alignment: Alignment.centerRight,
  75. child: widget.ysRightWidget??Container(),
  76. )
  77. ],
  78. );
  79. },
  80. ),
  81. ),
  82. Padding(
  83. padding: EdgeInsets.only(top: ysTOP(context)+60),
  84. child: ClipRRect(
  85. borderRadius: const BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
  86. child: Container(
  87. height: ysHeight(context)-ysTOP(context)-(widget.isTab?130:60),
  88. width: ysWidth(context),
  89. color: YSColors.backgroundColor(context),
  90. child: SingleChildScrollView(
  91. child: widget.ysChild
  92. ),
  93. ),
  94. ),
  95. )
  96. ],
  97. ),
  98. ),
  99. ),
  100. ),
  101. );
  102. }
  103. }
  104. class YSBase2 extends StatefulWidget {
  105. final Color? ysColor;
  106. final bool isTab;
  107. final String ysTitle;
  108. final Widget? ysRightWidget;
  109. final Widget? ysChild;
  110. final int titleType;
  111. final bool isScroll;
  112. final int topHeight;
  113. const YSBase2({Key? key, this.ysColor, this.isTab = false, this.ysTitle = '', this.ysRightWidget, this.ysChild, this.titleType = 0, this.isScroll = true, this.topHeight = 300}) : super(key: key);
  114. @override
  115. YSBase2State createState() => YSBase2State();
  116. }
  117. class YSBase2State extends State<YSBase2> {
  118. @override
  119. Widget build(BuildContext context) {
  120. return Scaffold(
  121. body: GestureDetector(
  122. onTap: (){FocusScope.of(context).unfocus();},
  123. child: SizedBox(
  124. height: ysHeight(context),
  125. width: ysWidth(context),
  126. child: SingleChildScrollView(
  127. child: Stack(
  128. children: [
  129. const YSHeadView(),
  130. // Image.asset(YSColors.imageStyle(context, '背景图'),height: hsp(widget.topHeight),width: ysWidth(context),fit: BoxFit.fill,color: Colors.black,),
  131. SizedBox(
  132. child: Column(
  133. children: [
  134. Container(
  135. height: ysTOP(context)+44,
  136. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: ysTOP(context)),
  137. child: LayoutBuilder(
  138. builder: (context,conSize){
  139. return Row(
  140. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  141. children: [
  142. Container(
  143. width: hsp(75),
  144. alignment: Alignment.centerLeft,
  145. child: widget.isTab==true?SizedBox(width: hsp(30),):GestureDetector(
  146. onTap: (){
  147. Navigator.pop(context);
  148. },
  149. child: Row(
  150. children: [
  151. Icon(Icons.chevron_left,size: zsp(30),color: YSColors.containColor(context),),
  152. Text(S.current.FANHUI,style: YSColors.content2Style(context),)
  153. ],
  154. )
  155. ),
  156. ),
  157. widget.titleType==2?const YSChangeNetView(
  158. ):Container(
  159. width: conSize.maxWidth-hsp(150),
  160. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  161. alignment: Alignment.center,
  162. child: widget.titleType==1?Image.asset(
  163. YSColors.imageStyle(context, '资源 3'),
  164. width: hsp(150),
  165. height: hsp(30),
  166. ):widget.titleType==2?const YSChangeNetView(
  167. ):Text(widget.ysTitle,style: YSColors.title2Style(context),maxLines: 1,),
  168. ),
  169. Container(
  170. width: hsp(75),
  171. alignment: Alignment.centerRight,
  172. child: widget.ysRightWidget??Container(),
  173. )
  174. ],
  175. );
  176. },
  177. ),
  178. ),
  179. SizedBox(
  180. height: ysHeight(context)-ysTOP(context)-(widget.isTab?114:44),
  181. width: ysWidth(context),
  182. child: widget.isScroll?SingleChildScrollView(
  183. child: widget.ysChild
  184. ):widget.ysChild,
  185. )
  186. ],
  187. ),
  188. )
  189. ],
  190. ),
  191. ),
  192. ),
  193. ),
  194. );
  195. }
  196. }