dialog_checked.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/svg.dart';
  3. import 'package:get/get.dart';
  4. import '../../model.dart';
  5. import '../../widget/app_net_image.dart';
  6. import '../../styles/color_schemes.g.dart';
  7. class DialogChecked extends StatelessWidget {
  8. final VoidCallback? onConfirm;
  9. final String title;
  10. final String sn;
  11. final MNetImage? image;
  12. final String content;
  13. final bool isOk;
  14. const DialogChecked({
  15. super.key,
  16. required this.title,
  17. required this.sn,
  18. required this.isOk,
  19. this.onConfirm,
  20. this.image,
  21. this.content = '',
  22. });
  23. @override
  24. Widget build(BuildContext context) {
  25. return Padding(
  26. padding: const EdgeInsets.fromLTRB(50, 80, 50, 80),
  27. child: Column(
  28. children: [
  29. Expanded(
  30. child: Stack(
  31. children: [
  32. SvgPicture.asset(
  33. 'assets/images/bk_check_point.svg',
  34. height: double.infinity,
  35. width: double.infinity,
  36. fit: BoxFit.fill,
  37. ),
  38. Padding(
  39. padding: const EdgeInsets.all(44),
  40. child: Column(
  41. children: [
  42. Text(
  43. title,
  44. style: context.textTheme.headlineLarge,
  45. ),
  46. Text(sn, style: context.textTheme.titleLarge,),
  47. isOk?const SizedBox(width: 0, height: 0)
  48. :Text('顺序错误,请去正确的检查点',
  49. style: context.textTheme.bodyLarge?.copyWith(
  50. color: context.theme.colorScheme.error)),
  51. const Divider(),
  52. const SizedBox(height: 12),
  53. ConstrainedBox(
  54. constraints: const BoxConstraints(
  55. maxHeight: 120,
  56. ),
  57. child: AppNetImage(
  58. netImage: image ?? MNetImage(),
  59. fit: BoxFit.contain),
  60. ),
  61. const SizedBox(height: 12),
  62. SizedBox(
  63. width: double.infinity,
  64. child: Text(
  65. content,
  66. style: context.textTheme.bodyLarge,
  67. ),
  68. ),
  69. ],
  70. )),
  71. isOk?
  72. Positioned(
  73. right: 30,
  74. bottom: 60,
  75. child: Transform.rotate(
  76. angle: -0.3,
  77. child: Image.asset(
  78. 'assets/images/ic_checked.png',
  79. width: 100,
  80. height: 40,
  81. fit: BoxFit.fill,
  82. ),
  83. ),
  84. ):const SizedBox(width: 0, height: 0)
  85. ],
  86. )),
  87. const SizedBox(height: 18),
  88. ElevatedButton(onPressed: onConfirm, child: const Text('确定'))
  89. ],
  90. ));
  91. }
  92. }
  93. class _Empty extends StatelessWidget {
  94. @override
  95. Widget build(BuildContext context) {
  96. _showDialog();
  97. return const Scaffold();
  98. }
  99. }
  100. Future<void> _showDialog() async {
  101. await Future.delayed(2.seconds);
  102. Get.dialog(const DialogChecked(
  103. title: '点位: 231',
  104. sn: "A123",
  105. isOk: true,
  106. content: '一些内容',
  107. ));
  108. }
  109. void main() async {
  110. runApp(GetMaterialApp(
  111. theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
  112. home: _Empty()));
  113. }