YSAlertView.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import 'package:flutter/material.dart';
  2. import 'package:image_picker/image_picker.dart';
  3. import 'YSTools.dart';
  4. class YSWorkUrgeAlertView extends StatefulWidget {
  5. final ValueSetter<bool> valueSetter;
  6. const YSWorkUrgeAlertView({Key? key, required this.valueSetter}) : super(key: key);
  7. @override
  8. YSWorkUrgeAlertViewState createState() => YSWorkUrgeAlertViewState();
  9. }
  10. class YSWorkUrgeAlertViewState extends State<YSWorkUrgeAlertView> {
  11. @override
  12. Widget build(BuildContext context) {
  13. return Center(
  14. child: Container(
  15. width: ysWidth(context)-hsp(60),
  16. height: hsp(200),
  17. decoration: const BoxDecoration(
  18. color: Colors.white,
  19. borderRadius: BorderRadius.all(Radius.circular(10))
  20. ),
  21. child: LayoutBuilder(
  22. builder: (context,conSize){
  23. return Column(
  24. children: [
  25. Container(
  26. padding: EdgeInsets.all(hsp(24)),
  27. height: hsp(150),
  28. child: Column(
  29. children: [
  30. Text('催办提醒',style: TextStyle(fontSize: zsp(16),color: const Color(0xFF323233),decoration: TextDecoration.none),),
  31. Padding(
  32. padding: EdgeInsets.only(top: hsp(8),bottom: hsp(8)),
  33. child: RichText(text: TextSpan(//当前进度:等待部分负责人审批,您是否确定通知提醒相关人员进行审批?
  34. text: '当前进度:',
  35. style: TextStyle(fontSize: zsp(14),color: const Color(0xFF4A4A4A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  36. children: const [
  37. TextSpan(
  38. text: '等待部分负责人审批,',
  39. style: TextStyle(color: Color(0xFF377DFE))
  40. ),
  41. TextSpan(
  42. text: '您是否确定通知提醒相关人员进行审批?',
  43. )
  44. ]
  45. )),
  46. ),
  47. Text('注:每天只能发送一次提醒通知',style: TextStyle(fontSize: zsp(12),color: const Color(0xFF969799),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  48. ],
  49. ),
  50. ),
  51. Container(
  52. height: hsp(50),
  53. decoration: const BoxDecoration(
  54. border: Border(top: BorderSide(color: Color(0xFFEBEDF0),width: 0.5))
  55. ),
  56. child: ListView.separated(
  57. itemBuilder: (context,index){
  58. return GestureDetector(
  59. onTap: (){
  60. Navigator.pop(context);
  61. widget.valueSetter(index==1);
  62. },
  63. behavior: HitTestBehavior.opaque,
  64. child: Container(
  65. width: conSize.maxWidth/2-0.25,
  66. alignment: Alignment.center,
  67. child: Text(
  68. index==0?'取消':'确定',
  69. style: TextStyle(
  70. fontSize: zsp(16),
  71. color: index==0?const Color(0xFF323233):const Color(0xFF377DFE),
  72. decoration: TextDecoration.none,
  73. fontWeight: FontWeight.normal
  74. ),
  75. ),
  76. ),
  77. );
  78. },
  79. separatorBuilder: (context,index){
  80. return Container(width: 0.5,color: const Color(0xFFEBEDF0),);
  81. },
  82. itemCount: 2,
  83. scrollDirection: Axis.horizontal,
  84. ),
  85. )
  86. ],
  87. );
  88. },
  89. ),
  90. ),
  91. );
  92. }
  93. }
  94. class YSTipsAlertView extends StatefulWidget {
  95. final ValueSetter<bool> valueSetter;
  96. final String tipsStr;
  97. final String btnStr1;
  98. final String btnStr2;
  99. const YSTipsAlertView({Key? key, required this.valueSetter, this.tipsStr = '', this.btnStr1 = '否', this.btnStr2 = '是'}) : super(key: key);
  100. @override
  101. YSTipsAlertViewState createState() => YSTipsAlertViewState();
  102. }
  103. class YSTipsAlertViewState extends State<YSTipsAlertView> {
  104. @override
  105. Widget build(BuildContext context) {
  106. return Center(
  107. child: Container(
  108. width: ysWidth(context)-hsp(60),
  109. height: hsp(150),
  110. decoration: const BoxDecoration(
  111. color: Color(0xFF3A3F49),
  112. borderRadius: BorderRadius.all(Radius.circular(10))
  113. ),
  114. child: LayoutBuilder(
  115. builder: (context,conSize){
  116. return Column(
  117. children: [
  118. // Container(
  119. // height: hsp(50),
  120. // decoration: const BoxDecoration(
  121. // border: Border(bottom: BorderSide(color: Color(0xFFEBEDF0),width: 0.5))
  122. // ),
  123. // alignment: Alignment.center,
  124. // child: Text('提醒',style: TextStyle(fontSize: zsp(16),color: Colors.black,decoration: TextDecoration.none),),
  125. // ),
  126. Container(
  127. height: hsp(100),
  128. alignment: Alignment.center,
  129. padding: EdgeInsets.all(hsp(10)),
  130. child: Text(widget.tipsStr,style: TextStyle(fontSize: zsp(16),color: Colors.white,
  131. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 3,overflow: TextOverflow.ellipsis,),
  132. ),
  133. Container(
  134. height: hsp(50),
  135. decoration: const BoxDecoration(
  136. border: Border(top: BorderSide(color: Color(0xFF1A1C1F),width: 0.5))
  137. ),
  138. child: ListView.separated(
  139. itemBuilder: (context,index){
  140. return GestureDetector(
  141. onTap: (){
  142. Navigator.pop(context);
  143. widget.valueSetter(index==1);
  144. },
  145. behavior: HitTestBehavior.opaque,
  146. child: Container(
  147. width: conSize.maxWidth/2-0.25,
  148. alignment: Alignment.center,
  149. child: Text(
  150. index==0?widget.btnStr1:widget.btnStr2,
  151. style: TextStyle(
  152. fontSize: zsp(16),
  153. color: index==0?const Color(0xFFACB5C5):const Color(0xFFFBFBFB),
  154. decoration: TextDecoration.none,
  155. fontWeight: FontWeight.normal
  156. ),
  157. ),
  158. ),
  159. );
  160. },
  161. separatorBuilder: (context,index){
  162. return Container(width: 0.5,color: const Color(0xFF1A1C1F),);
  163. },
  164. itemCount: 2,
  165. scrollDirection: Axis.horizontal,
  166. ),
  167. )
  168. ],
  169. );
  170. },
  171. ),
  172. ),
  173. );
  174. }
  175. }
  176. class YSChooseFileView extends StatefulWidget {
  177. final bool isPhoto;
  178. final ValueSetter valueSetter;
  179. const YSChooseFileView({Key? key, required this.valueSetter, this.isPhoto = true}) : super(key: key);
  180. @override
  181. YSChooseFileViewState createState() => YSChooseFileViewState();
  182. }
  183. class YSChooseFileViewState extends State<YSChooseFileView> {
  184. final ImagePicker _picker = ImagePicker();
  185. final List _chooseArray = [];
  186. @override
  187. void initState() {
  188. _chooseArray.clear();
  189. if(widget.isPhoto){
  190. _chooseArray.addAll([
  191. {'title':'拍摄小票','type':5},
  192. {'title':'选择小票','type':6},
  193. {'title':'拍摄发票','type':7},
  194. {'title':'选择发票','type':8},
  195. {'title':'取消','type':0}
  196. ]);
  197. }else{
  198. _chooseArray.addAll([
  199. {'title':'拍摄图片','type':1},
  200. {'title':'选择图片','type':2},
  201. {'title':'拍摄视频','type':3},
  202. {'title':'选择视频','type':4},
  203. {'title':'取消','type':0}
  204. ]);
  205. }
  206. super.initState();
  207. }
  208. @override
  209. Widget build(BuildContext context) {
  210. return Container(
  211. height: hsp(20)+hsp(50*_chooseArray.length),
  212. decoration: const BoxDecoration(
  213. color: Colors.white,
  214. borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
  215. ),
  216. child: ListView.separated(
  217. physics: const NeverScrollableScrollPhysics(),
  218. itemCount: _chooseArray.length,
  219. padding: const EdgeInsets.all(0),
  220. itemBuilder: (context,index){
  221. Map item = _chooseArray[index];
  222. int type = item['type'];
  223. return GestureDetector(
  224. onTap: (){
  225. if(type==0){
  226. Navigator.pop(context);
  227. }else{
  228. if(type==1||type==5||type==6||type==7||type==8){
  229. _picker.pickImage(source: type==6||type==8?ImageSource.gallery:ImageSource.camera,imageQuality: 60).then((value){
  230. Map image = {'type':1,'value':value!};
  231. if(type==7||type==8)image['invoice'] = true;
  232. widget.valueSetter(image);
  233. Navigator.pop(context);
  234. });
  235. }else if(type==2){
  236. _picker.pickMultiImage(imageQuality: 60).then((value){
  237. widget.valueSetter({'type':1,'value':value});
  238. Navigator.pop(context);
  239. });
  240. }else if(type==3||type==4){
  241. _picker.pickVideo(source: type==3?ImageSource.camera:ImageSource.gallery).then((value){
  242. widget.valueSetter({'type':2,'value':value!});
  243. Navigator.pop(context);
  244. });
  245. }
  246. }
  247. },
  248. behavior: HitTestBehavior.opaque,
  249. child: Container(
  250. height: hsp(50),
  251. width: MediaQuery.of(context).size.width,
  252. padding: EdgeInsets.only(left: hsp(16),right: hsp(16)),
  253. alignment: Alignment.center,
  254. child: Text(item['title'],style: TextStyle(fontSize: zsp(16),color: Colors.black),),
  255. ),
  256. );
  257. },
  258. separatorBuilder: (context,index){
  259. return Divider(height: index==_chooseArray.length-2?hsp(8):hsp(1),thickness: index==_chooseArray.length-2?hsp(8):hsp(1),color: const Color(0xFFF7F7F7),);
  260. },
  261. ),
  262. );
  263. }
  264. }