view.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vitalapp/pages/contract/package_list/controller.dart';
  5. /// 包详情
  6. class PackageInfoPage extends GetView<ServicePackageContractController> {
  7. final ServicePackDTO? dto;
  8. const PackageInfoPage({super.key, this.dto});
  9. Widget buildAlertDialog(ServicePackDTO? servicePackDTO) {
  10. return Container(
  11. margin: const EdgeInsets.only(left: 55),
  12. alignment: Alignment.topLeft,
  13. padding: const EdgeInsets.symmetric(horizontal: 15),
  14. child: Column(
  15. crossAxisAlignment: CrossAxisAlignment.start,
  16. children: [
  17. const Text(
  18. '服务名称',
  19. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
  20. ),
  21. const SizedBox(
  22. height: 10,
  23. ),
  24. Container(
  25. color: const Color.fromARGB(255, 243, 240, 240),
  26. child: _buildItemContent(servicePackDTO?.name ?? ""),
  27. ),
  28. const SizedBox(
  29. height: 10,
  30. ),
  31. const Text(
  32. '服务介绍',
  33. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
  34. ),
  35. const SizedBox(
  36. height: 10,
  37. ),
  38. Container(
  39. color: const Color.fromARGB(255, 243, 240, 240),
  40. child: _buildItemContent(servicePackDTO?.content ?? ""),
  41. ),
  42. const SizedBox(
  43. height: 10,
  44. ),
  45. const Text(
  46. '服务项目',
  47. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
  48. ),
  49. const SizedBox(
  50. height: 10,
  51. ),
  52. Expanded(
  53. child: Container(
  54. color: const Color.fromARGB(255, 243, 240, 240),
  55. child: Scrollbar(
  56. thumbVisibility: true,
  57. child: ListView(
  58. children: [
  59. ...controller
  60. .getServiceItemsName(
  61. servicePackDTO?.items ?? [],
  62. )
  63. .map(
  64. (ServiceItemDTO e) => _buildServiceItem(e),
  65. ),
  66. ],
  67. ),
  68. ),
  69. ),
  70. ),
  71. ],
  72. ),
  73. );
  74. }
  75. Widget _buildServiceItem(ServiceItemDTO dto) {
  76. return Container(
  77. margin: const EdgeInsets.only(left: 20),
  78. padding: const EdgeInsets.all(5),
  79. child: Column(
  80. crossAxisAlignment: CrossAxisAlignment.start,
  81. children: [
  82. Text(
  83. dto.name ?? '',
  84. style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
  85. ),
  86. const SizedBox(
  87. height: 5,
  88. ),
  89. Container(
  90. margin: const EdgeInsets.only(left: 20),
  91. child: Text(
  92. dto.content ?? '',
  93. style: const TextStyle(fontSize: 18),
  94. ),
  95. ),
  96. ],
  97. ),
  98. );
  99. }
  100. Widget _buildItemContent(String itemName) {
  101. return LayoutBuilder(
  102. builder: (BuildContext context, BoxConstraints constraints) {
  103. return ConstrainedBox(
  104. constraints: const BoxConstraints(
  105. maxHeight: 100,
  106. ),
  107. child: Scrollbar(
  108. thumbVisibility: true,
  109. child: ListView(
  110. shrinkWrap: true,
  111. children: [
  112. Container(
  113. margin: const EdgeInsets.only(left: 20),
  114. padding: const EdgeInsets.all(5),
  115. child: Text(
  116. itemName,
  117. style: const TextStyle(fontSize: 18),
  118. ),
  119. ),
  120. ],
  121. ),
  122. ),
  123. );
  124. },
  125. );
  126. }
  127. @override
  128. Widget build(BuildContext context) {
  129. return Scaffold(
  130. appBar: AppBar(
  131. title: const Text(
  132. "服务包详情",
  133. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
  134. ),
  135. // leading: Container(),
  136. // leadingWidth: 0,
  137. // actions: [
  138. // IconButton(
  139. // onPressed: () {
  140. // Navigator.pop(context);
  141. // },
  142. // icon: const Icon(
  143. // Icons.cancel,
  144. // size: 24,
  145. // ))
  146. // ],
  147. ),
  148. body: buildAlertDialog(dto),
  149. );
  150. }
  151. }