certificate_page.dart 3.6 KB

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