certificate_page.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:keyboard_actions/keyboard_actions.dart';
  5. import 'package:liftmanager/internal/account/account_router.dart';
  6. import 'package:liftmanager/internal/account/model/certificate_item.dart';
  7. import 'package:liftmanager/net/api_service.dart';
  8. import 'package:liftmanager/res/gaps.dart';
  9. import 'package:liftmanager/res/resources.dart';
  10. import 'package:liftmanager/routers/fluro_navigator.dart';
  11. import 'package:liftmanager/utils/toast.dart';
  12. import 'package:liftmanager/widgets/app_bar.dart';
  13. import 'package:liftmanager/widgets/click_item.dart';
  14. import 'package:liftmanager/widgets/selected_image.dart';
  15. class CertificatePage extends StatefulWidget {
  16. @override
  17. State<StatefulWidget> createState() {
  18. return CertificatePageState();
  19. }
  20. }
  21. class CertificatePageState extends State<CertificatePage> {
  22. CertificateItem item = CertificateItem();
  23. @override
  24. void initState() {
  25. super.initState();
  26. getCertificateDetail();
  27. }
  28. getCertificateDetail() {
  29. ApiService(context: context).liftCertificateFindByUser(onSuccess: (res) {
  30. if (res != null) {
  31. item = res;
  32. }
  33. setState(() {});
  34. }, onError: (code, msg) {
  35. toasts(msg);
  36. });
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. return Scaffold(
  41. appBar: MyAppBar(
  42. centerTitle: "操作证",
  43. actions: <Widget>[
  44. FlatButton(
  45. child: Text("上传"),
  46. textColor: Colours.dark_text,
  47. highlightColor: Colors.transparent,
  48. onPressed: () {
  49. NavigatorUtils.pushResult(
  50. context, AccountRouter.certificateUploadPage, (res) {
  51. getCertificateDetail();
  52. });
  53. },
  54. )
  55. ],
  56. ),
  57. body: SafeArea(
  58. child: Column(
  59. children: <Widget>[
  60. Expanded(
  61. flex: 1,
  62. child: defaultTargetPlatform == TargetPlatform.iOS
  63. ? FormKeyboardActions(child: _buildBody())
  64. : SingleChildScrollView(child: _buildBody()),
  65. )
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. _buildBody() {
  72. return Column(
  73. crossAxisAlignment: CrossAxisAlignment.start,
  74. children: _listWidgets(),
  75. );
  76. }
  77. _listWidgets() {
  78. if (item.status == 0)
  79. return [
  80. ClickItem(
  81. title: "操作证",
  82. content:
  83. "${item.status == 1 ? '待审核' : item.status == 2 ? '审核未通过' : item.status == 3 ? '合格' : item.status == 4 ? '超期' : '无证'}",
  84. )
  85. ];
  86. return [
  87. ClickItem(
  88. title: "操作证",
  89. content:
  90. "${item.status == 1 ? '待审核' : item.status == 2 ? '审核未通过' : item.status == 3 ? '合格' : item.status == 4 ? '超期' : '无证'}",
  91. ),
  92. ClickItem(
  93. title: "操作证类型",
  94. content: "${item.code == 1 ? '维保工操作证' : '其他'}",
  95. ),
  96. ClickItem(
  97. title: "证件有效期",
  98. content: "${item.expirationDate}",
  99. ),
  100. ClickItem(
  101. title: "发证单位",
  102. content: "${item.issuanceAgency}",
  103. ),
  104. Gaps.vGap10,
  105. ClickItem(
  106. title: "操作证图片",
  107. content: "",
  108. hideDiv: true,
  109. ),
  110. Row(
  111. children: <Widget>[
  112. Gaps.hGap10,
  113. Image.network(
  114. "${item.firstImgUrl}",
  115. width: 150,
  116. height: 150,
  117. fit: BoxFit.fill,
  118. ),
  119. Gaps.hGap10,
  120. Image.network(
  121. "${item.secondImgUrl}",
  122. width: 150,
  123. height: 150,
  124. fit: BoxFit.fill,
  125. )
  126. ],
  127. )
  128. ];
  129. }
  130. }