photo_over.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import 'package:flutter/material.dart';
  2. import 'package:fun_selfie_app/utils/common_toast.dart';
  3. import 'package:fun_selfie_app/widgets/home_button.dart';
  4. import 'package:fun_selfie_app/widgets/common_form_item.dart';
  5. class PhotoOverPage extends StatefulWidget {
  6. const PhotoOverPage({Key? key}) : super(key: key);
  7. @override
  8. State<StatefulWidget> createState() => _PhotoOverPageState();
  9. }
  10. class _PhotoOverPageState extends State<PhotoOverPage> {
  11. final TextEditingController printNum = TextEditingController();
  12. Widget renderImgBox(String imgSrc) {
  13. final screenSize = MediaQuery.of(context).size;
  14. return Container(
  15. padding: const EdgeInsets.only(top: 20),
  16. constraints: BoxConstraints(
  17. maxHeight: screenSize.height * 0.4, maxWidth: screenSize.width / 4),
  18. child: Image(
  19. image: AssetImage(imgSrc),
  20. fit: BoxFit.fill,
  21. width: (screenSize.width) / 4,
  22. ),
  23. );
  24. }
  25. Widget heightButton(
  26. String txt, Color? backgroundColor, VoidCallback? onPressed) {
  27. return SizedBox(
  28. height: 60,
  29. child: OutlinedButton(
  30. style: ButtonStyle(
  31. shadowColor: MaterialStateProperty.all(Colors.transparent),
  32. backgroundColor: MaterialStateProperty.all(backgroundColor)),
  33. onPressed: onPressed,
  34. child: Text(
  35. txt,
  36. style: const TextStyle(
  37. fontSize: 20, color: Color.fromRGBO(121, 72, 234, 1)),
  38. ),
  39. ),
  40. );
  41. }
  42. @override
  43. Widget build(BuildContext context) {
  44. final screenSize = MediaQuery.of(context).size;
  45. return Scaffold(
  46. body: Container(
  47. width: screenSize.width,
  48. height: screenSize.height,
  49. color: const Color.fromARGB(100, 229, 229, 229),
  50. child: Stack(children: <Widget>[
  51. Padding(
  52. padding: const EdgeInsets.all(10),
  53. child: Row(
  54. children: [
  55. Container(
  56. width: (screenSize.width / 4) + 40,
  57. color: const Color(0xffFF5833),
  58. child: SingleChildScrollView(
  59. child: Column(children: [
  60. renderImgBox('static/images/photo_img1.png'),
  61. renderImgBox('static/images/photo_img2.png'),
  62. renderImgBox('static/images/photo_img3.png'),
  63. renderImgBox('static/images/photo_img4.png'),
  64. ]))),
  65. Container(
  66. width: (screenSize.width - (screenSize.width / 3)),
  67. alignment: Alignment.center,
  68. child: SizedBox(
  69. width: (screenSize.width / 3),
  70. child: Column(
  71. mainAxisAlignment: MainAxisAlignment.center,
  72. children: <Widget>[
  73. Image(
  74. image: const AssetImage(
  75. 'static/images/qrcode.png'),
  76. fit: BoxFit.fill,
  77. width: (screenSize.width) / 5,
  78. height: (screenSize.width) / 5),
  79. const SizedBox(height: 40),
  80. const Text(
  81. '手机扫码看照片直播',
  82. style: TextStyle(
  83. fontSize: 24,
  84. color: Color.fromRGBO(121, 72, 234, 100)),
  85. ),
  86. const SizedBox(height: 40),
  87. Row(
  88. mainAxisAlignment:
  89. MainAxisAlignment.spaceEvenly,
  90. children: [
  91. heightButton('打印',
  92. const Color.fromARGB(14, 98, 0, 238), () {
  93. CommonToast.okToast('打印');
  94. }),
  95. heightButton('打印多张', Colors.transparent, () {
  96. showAlertDialog(
  97. context,
  98. );
  99. }),
  100. heightButton('不满意重拍', Colors.transparent, () {
  101. Navigator.pushNamed(context, "/takePhoto");
  102. }),
  103. heightButton('返回',
  104. const Color.fromARGB(14, 98, 0, 238), () {
  105. Navigator.pushNamed(
  106. context, "/photography");
  107. }),
  108. ],
  109. )
  110. ]))),
  111. ],
  112. )),
  113. const HomeButton()
  114. ]),
  115. ));
  116. }
  117. Future<void> showAlertDialog(BuildContext context) async {
  118. return showDialog<void>(
  119. context: context,
  120. barrierDismissible: false, // 点击对话框外部时,是否关闭对话框
  121. builder: (BuildContext context) {
  122. return AlertDialog(
  123. title: const Text('打印多张'),
  124. content: SizedBox(
  125. width: 400,
  126. child: CommonFormItem(
  127. label: '打印数量',
  128. hitText: '请输入',
  129. controller: printNum,
  130. validator: (v) => (v == '') ? "请输入" : null,
  131. ),
  132. ),
  133. actions: <Widget>[
  134. TextButton(
  135. child: const Text('取消',
  136. style: TextStyle(
  137. color: Color.fromARGB(255, 98, 0, 238), fontSize: 20)),
  138. onPressed: () {
  139. printNum.text = '';
  140. Navigator.of(context).pop();
  141. },
  142. ),
  143. TextButton(
  144. child: const Text('确定',
  145. style: TextStyle(
  146. color: Color.fromARGB(255, 98, 0, 238), fontSize: 20)),
  147. onPressed: () {
  148. if (printNum.text == '') {
  149. CommonToast.errToast('请填写打印数量');
  150. return;
  151. } else {
  152. RegExp numbers = RegExp(r"\d+$");
  153. if (!numbers.hasMatch(printNum.text)) {
  154. CommonToast.errToast('请填写正整数');
  155. return;
  156. }
  157. }
  158. Navigator.of(context).pop();
  159. },
  160. ),
  161. ],
  162. );
  163. },
  164. );
  165. }
  166. }