id_info.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import '../index.dart';
  5. class IdCardInfo extends GetView<IdCardScanController> {
  6. const IdCardInfo({Key? key}) : super(key: key);
  7. @override
  8. Widget build(BuildContext context) {
  9. return Obx(
  10. () => AnimatedContainer(
  11. duration: const Duration(milliseconds: 300),
  12. width: controller.state.isIdCardInfoShow ? 300 : 0,
  13. color: const Color.fromARGB(255, 231, 231, 231),
  14. child: OverflowBox(
  15. maxWidth: 300,
  16. minWidth: 300,
  17. alignment: Alignment.centerRight,
  18. child: Column(
  19. children: [
  20. const SizedBox(height: 20),
  21. Container(
  22. decoration: BoxDecoration(
  23. borderRadius: BorderRadius.circular(10),
  24. ),
  25. clipBehavior: Clip.antiAlias,
  26. child: Transform.scale(
  27. scale:
  28. controller.idCardInfo.localCardImagePath == '' ? 1 : 1.8,
  29. child: Image.file(
  30. File(controller.idCardInfo.localCardImagePath),
  31. errorBuilder: (context, error, stackTrace) {
  32. return const Image(
  33. image: AssetImage('assets/images/id_card.png'),
  34. color: Colors.grey,
  35. width: 220,
  36. );
  37. },
  38. width: 220,
  39. ),
  40. ),
  41. ),
  42. const SizedBox(height: 20),
  43. Expanded(
  44. child: Scrollbar(
  45. thumbVisibility: true,
  46. thickness: 10,
  47. radius: const Radius.circular(10),
  48. child: ListView(
  49. padding: const EdgeInsets.symmetric(horizontal: 20),
  50. children: [
  51. _buildLabel('姓名'),
  52. _buildValue(controller.idCardInfo.idCardName),
  53. const SizedBox(height: 10),
  54. _buildLabel('性别'),
  55. _buildValue(controller.idCardInfo.idCardGender),
  56. const SizedBox(height: 10),
  57. _buildLabel('民族'),
  58. _buildValue(controller.idCardInfo.idCardNation),
  59. const SizedBox(height: 10),
  60. _buildLabel('出生'),
  61. _buildValue(controller.idCardInfo.idCardBirthDate),
  62. const SizedBox(height: 10),
  63. _buildLabel('住址'),
  64. _buildValue(controller.idCardInfo.idCardAddress),
  65. const SizedBox(height: 10),
  66. _buildLabel('公民身份号码'),
  67. _buildValue(controller.idCardInfo.idCardNumber),
  68. const SizedBox(height: 10),
  69. ],
  70. ),
  71. ),
  72. ),
  73. _buildCaptureAgainButton(),
  74. const SizedBox(height: 10),
  75. ],
  76. ),
  77. ),
  78. ),
  79. );
  80. }
  81. Widget _buildLabel(String label) {
  82. return Row(
  83. children: [
  84. Padding(
  85. padding: const EdgeInsets.only(left: 20),
  86. child: Text(
  87. label,
  88. style: const TextStyle(color: Colors.grey, fontSize: 18),
  89. ),
  90. ),
  91. Expanded(child: Container()),
  92. // TODO 预留手动编辑入口
  93. // InkWell(
  94. // onTap: () {},
  95. // child: Container(
  96. // padding:
  97. // const EdgeInsets.only(left: 20, top: 2, bottom: 2, right: 20),
  98. // child: const Icon(
  99. // Icons.border_color_outlined,
  100. // color: Colors.grey,
  101. // size: 20,
  102. // ),
  103. // ),
  104. // ),
  105. ],
  106. );
  107. }
  108. Widget _buildValue(String value) {
  109. return Align(
  110. alignment: Alignment.centerLeft,
  111. child: Padding(
  112. padding: const EdgeInsets.only(left: 20),
  113. child: Text(
  114. value,
  115. style: const TextStyle(color: Colors.black87, fontSize: 20),
  116. ),
  117. ),
  118. );
  119. }
  120. Widget _buildCaptureAgainButton() {
  121. return Align(
  122. alignment: Alignment.center,
  123. child: Row(
  124. mainAxisAlignment: MainAxisAlignment.center,
  125. children: [
  126. const Text(
  127. '身份证信息不正确?',
  128. style: TextStyle(color: Colors.grey),
  129. ),
  130. TextButton(
  131. onPressed: () {
  132. controller.state.isIdCardInfoShow = false;
  133. controller.state.isShowIdCardInfoSwitch = false;
  134. controller.state.isInIdCardScan = false;
  135. controller.openBackCamera();
  136. },
  137. child: const Text(
  138. '重新拍摄',
  139. style: TextStyle(color: Colors.blue),
  140. ),
  141. ),
  142. ],
  143. ),
  144. );
  145. }
  146. }