main.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. import 'dart:convert';
  2. import 'package:fis_lib_report/converts/event_type.dart';
  3. import 'package:fis_lib_report/converts/pt_to_px_converter.dart';
  4. import 'package:fis_lib_report/report_edit.dart';
  5. import 'package:fis_lib_report/report_info/report_info.dart';
  6. import 'package:fis_ui/index.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:fis_jsonrpc/rpc.dart';
  9. import 'package:fis_lib_business_components/index.dart';
  10. import 'package:fis_i18n/i18n.dart';
  11. import 'package:flutter/services.dart';
  12. import 'package:fis_theme/theme.dart';
  13. import 'pages/theme.dart';
  14. void main() {
  15. runApp(const MyApp());
  16. }
  17. class MyApp extends StatelessWidget {
  18. const MyApp({Key? key}) : super(key: key);
  19. // This widget is the root of your application.
  20. @override
  21. Widget build(BuildContext context) {
  22. return MaterialApp(
  23. title: 'Flutter Demo',
  24. theme: ThemeData(
  25. // This is the theme of your application.
  26. //
  27. // Try running your application with "flutter run". You'll see the
  28. // application has a blue toolbar. Then, without quitting the app, try
  29. // changing the primarySwatch below to Colors.green and then invoke
  30. // "hot reload" (press "r" in the console where you ran "flutter run",
  31. // or simply save your changes to "hot reload" in a Flutter IDE).
  32. // Notice that the counter didn't reset back to zero; the application
  33. // is not restarted.
  34. primarySwatch: Colors.blue,
  35. ),
  36. home: const MyHomePage(title: 'Flutter Demo Home Page'),
  37. );
  38. }
  39. }
  40. class MyHomePage extends StatefulWidget {
  41. const MyHomePage({Key? key, required this.title}) : super(key: key);
  42. final String title;
  43. @override
  44. State<MyHomePage> createState() => _MyHomePageState();
  45. }
  46. class _MyHomePageState extends State<MyHomePage> {
  47. final EdgeInsetsGeometry _padding =
  48. EdgeInsets.all(PtToPxConverter.ptToPx(56.83));
  49. String _jsonStr = '';
  50. final List<String> _demoImags = [
  51. 'http://cdn-bj.fis.plus/db38b8d36a7b48ada3effe0a53ea8993.jpg',
  52. 'http://cdn-bj.fis.plus/480e058b1eef47f9a9e333c3a54697eb.jpg',
  53. 'http://cdn-bj.fis.plus/0abdd310057e43c9b0d3fbe8ff854f1d.jpg',
  54. 'http://cdn-bj.fis.plus/cafd704360a24234b3c6630b771d6d42.jpg',
  55. 'http://cdn-bj.fis.plus/b93f044024a4426d90ea21a5ca8f71d1.jpg',
  56. "http://cdn-bj.fis.plus/36cd135e1b144c55a189fdde52085a5c.jpg",
  57. "http://cdn-bj.fis.plus/452e838ed56c46c7a41e59c5553db504.jpg",
  58. "http://cdn-bj.fis.plus/238f463a8bc74984b3368163417f1d70.jpg",
  59. "http://cdn-bj.fis.plus/dbf5eb4fec814001b6b91e36af5aec76.jpg",
  60. 'http://cdn-bj.fis.plus/2163bb64ebfa42cca5958b9cdbb4248d.jpg',
  61. 'http://cdn-bj.fis.plus/0743d4884601465c837f18fe0c54a7f2.jpg',
  62. 'http://cdn-bj.fis.plus/d4b4a2421e7d4b4189031ca736a52312.jpg',
  63. ];
  64. late FEventHandler<String> onSelect;
  65. String _aiJson = '';
  66. String _petStr = '';
  67. String _testStr = '';
  68. String _reportInfoStr = '';
  69. bool _isInitI18nbopok = false;
  70. @override
  71. initState() {
  72. onSelect = FEventHandler<String>();
  73. rootBundle.loadString('assets/心智医联(脑卒中).json').then((jsonStr) {
  74. setState(() {
  75. _jsonStr = jsonStr;
  76. });
  77. });
  78. rootBundle.loadString('assets/北京同仁堂.json').then((jsonStr) {
  79. _aiJson = jsonStr;
  80. });
  81. rootBundle.loadString('assets/心智简单结论报告(颈动脉).json').then((jsonStr) {
  82. _petStr = jsonStr;
  83. });
  84. rootBundle.loadString('assets/心智医联(心血管).json').then((jsonStr) {
  85. _testStr = jsonStr;
  86. });
  87. rootBundle.loadString('assets/血友病.json').then((jsonStr) {
  88. _reportInfoStr = jsonStr;
  89. });
  90. super.initState();
  91. }
  92. @override
  93. Widget build(BuildContext context) {
  94. return FutureBuilder<bool>(
  95. future: _loadi18nBook(),
  96. builder: (c, snapshot) {
  97. if (snapshot.connectionState != ConnectionState.done ||
  98. snapshot.data == null) {
  99. return const FCenter(
  100. child: FSizedBox(
  101. width: 20,
  102. height: 20,
  103. child: FCircularProgressIndicator(),
  104. ),
  105. );
  106. }
  107. return Scaffold(
  108. backgroundColor: Colors.white,
  109. body: SizedBox(
  110. child: Row(
  111. children: [
  112. if (_jsonStr.isNotEmpty && _demoImags.isNotEmpty)
  113. Expanded(
  114. child: ListView(
  115. shrinkWrap: true,
  116. children: [
  117. FReportEditPage(
  118. reporter: 'Loki',
  119. reportDate: DateTime.now(),
  120. jsonStr: _jsonStr,
  121. onSelect: onSelect,
  122. revoke: i18nBook.common.revoke.t,
  123. selectEntry: i18nBook.remedical.selectWord.t,
  124. selectImageHint:
  125. i18nBook.remedical.clickAndSelectImage.t,
  126. ),
  127. ],
  128. ),
  129. ),
  130. const SizedBox(width: 40),
  131. Container(
  132. decoration: _buildDecoration(),
  133. padding: _padding,
  134. alignment: Alignment.center,
  135. height: 800,
  136. width: 600,
  137. child: ListView(
  138. shrinkWrap: true,
  139. children: [
  140. Wrap(
  141. children: [
  142. ..._demoImags.map((element) {
  143. return Container(
  144. width: 150,
  145. height: 100,
  146. margin: const EdgeInsets.all(15),
  147. child: FContentImage(
  148. fileDataType:
  149. RemedicalFileDataTypeEnum.Image,
  150. terminalImage: TerminalImage(
  151. coverImageUrl: element,
  152. previewUrl: element,
  153. imageUrl: element,
  154. ),
  155. onTap: () => onSelect.emit(this, element),
  156. ),
  157. );
  158. })
  159. ],
  160. ),
  161. ],
  162. )),
  163. SizedBox(
  164. width: 400,
  165. child: Wrap(
  166. children: [
  167. MaterialButton(
  168. child: const Text('北京同仁堂'),
  169. onPressed: () {
  170. FReportInfo.instance.reload(
  171. '北京同仁堂',
  172. DateTime.now(),
  173. _aiJson,
  174. onSelect,
  175. i18nBook.common.revoke.t,
  176. i18nBook.remedical.selectWord.t,
  177. i18nBook.remedical.clickAndSelectImage.t);
  178. }),
  179. MaterialButton(
  180. child: const Text('testDefault'),
  181. onPressed: () {
  182. FReportInfo.instance.reload(
  183. '海孚结构化颈动脉',
  184. DateTime.now(),
  185. _jsonStr,
  186. onSelect,
  187. i18nBook.common.revoke.t,
  188. i18nBook.remedical.selectWord.t,
  189. i18nBook.remedical.clickAndSelectImage.t);
  190. }),
  191. MaterialButton(
  192. child: const Text('testPet'),
  193. onPressed: () {
  194. FReportInfo.instance.reload(
  195. '北京养老院模板',
  196. DateTime.now(),
  197. _petStr,
  198. onSelect,
  199. i18nBook.common.revoke.t,
  200. i18nBook.remedical.selectWord.t,
  201. i18nBook.remedical.clickAndSelectImage.t);
  202. }),
  203. MaterialButton(
  204. child: const Text('onClose'),
  205. onPressed: () {
  206. FReportInfo.instance.onClose.emit(this, null);
  207. }),
  208. MaterialButton(
  209. child: const Text('open'),
  210. onPressed: () {
  211. setState(() {});
  212. }),
  213. MaterialButton(
  214. child: const Text('testCustomTemplate'),
  215. onPressed: () {
  216. FReportInfo.instance.reload(
  217. 'testCustomTemplate',
  218. DateTime.now(),
  219. _testStr,
  220. onSelect,
  221. i18nBook.common.revoke.t,
  222. i18nBook.remedical.selectWord.t,
  223. '');
  224. }),
  225. MaterialButton(
  226. child: const Text('海弗'),
  227. onPressed: () {
  228. final reportMap = jsonDecode(_reportInfoStr);
  229. FReportInfo.instance.fromJson(reportMap);
  230. }),
  231. MaterialButton(
  232. child: const Text('testToJson'),
  233. onPressed: () {
  234. FReportInfo.instance.toJson();
  235. final items = FReportInfo.instance.jsonItems;
  236. final json = jsonEncode(items);
  237. print(json);
  238. }),
  239. MaterialButton(
  240. child: const Text('testDiagnostic'),
  241. onPressed: () {
  242. FReportInfo.instance.insertDiagnostic(
  243. '主动脉极度扩张,主动脉窦扩张形成主动脉窦瘤,主动脉瓣呈囊袋状。 心底短轴显示主动脉瓣的对合不良。 多普勒超声显示舒张期返流束,起自主动脉瓣射向左心室达心尖部。 二尖瓣与主动脉瓣均脱垂。左心室扩张,呈容量负荷过重。左心功能正常。',
  244. '符合冠心病间隔梗塞后的超声表现并伴室壁瘤形成,左心功能不全');
  245. }),
  246. MaterialButton(
  247. child: const Text('setMockDatas'),
  248. onPressed: () {
  249. FReportInfo.instance.setMockDatas.emit(this, '');
  250. }),
  251. ],
  252. ),
  253. ),
  254. ],
  255. ),
  256. ),
  257. );
  258. });
  259. }
  260. BoxDecoration _buildDecoration() {
  261. return BoxDecoration(
  262. border: Border.all(
  263. width: 0.5,
  264. color: const Color.fromARGB(255, 83, 83, 83),
  265. ),
  266. color: Colors.white);
  267. }
  268. Future<bool> _loadi18nBook() async {
  269. var theme = AppTheme();
  270. try {
  271. await FTheme.init(theme);
  272. } catch (e) {
  273. await FTheme.ins.switchTheme('lightness');
  274. }
  275. await FTheme.ins.switchTheme('lightness', true);
  276. if (_isInitI18nbopok) {
  277. return true;
  278. }
  279. const curLocale = Locale('zh', 'CN');
  280. var bookOptions = [
  281. FTrKeybookOption.ChineseOption,
  282. ];
  283. try {
  284. await FI18n.init((locale) => locale, bookOptions);
  285. await FI18n.load(curLocale);
  286. } catch (e) {}
  287. _isInitI18nbopok = true;
  288. return true;
  289. }
  290. }