main.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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: RemedicalFileDataTypeEnum.Image,
  149. // terminalImage: TerminalImage(
  150. // coverImageUrl: element,
  151. // previewUrl: element,
  152. // imageUrl: element,
  153. // ),
  154. // onTap: () => onSelect.emit(this, element),
  155. // ),
  156. // );
  157. // })
  158. // ],
  159. // ),
  160. // ],
  161. // )),
  162. // SizedBox(
  163. // width: 400,
  164. // child: Wrap(
  165. // children: [
  166. // MaterialButton(
  167. // child: const Text('北京同仁堂'),
  168. // onPressed: () {
  169. // FReportInfo.instance.reload(
  170. // '北京同仁堂',
  171. // DateTime.now(),
  172. // _aiJson,
  173. // onSelect,
  174. // i18nBook.common.revoke.t,
  175. // i18nBook.remedical.selectWord.t,
  176. // i18nBook.remedical.clickAndSelectImage.t);
  177. // }),
  178. // MaterialButton(
  179. // child: const Text('testDefault'),
  180. // onPressed: () {
  181. // FReportInfo.instance.reload(
  182. // '海孚结构化颈动脉',
  183. // DateTime.now(),
  184. // _jsonStr,
  185. // onSelect,
  186. // i18nBook.common.revoke.t,
  187. // i18nBook.remedical.selectWord.t,
  188. // i18nBook.remedical.clickAndSelectImage.t);
  189. // }),
  190. // MaterialButton(
  191. // child: const Text('testPet'),
  192. // onPressed: () {
  193. // FReportInfo.instance.reload(
  194. // '北京养老院模板',
  195. // DateTime.now(),
  196. // _petStr,
  197. // onSelect,
  198. // i18nBook.common.revoke.t,
  199. // i18nBook.remedical.selectWord.t,
  200. // i18nBook.remedical.clickAndSelectImage.t);
  201. // }),
  202. // MaterialButton(
  203. // child: const Text('onClose'),
  204. // onPressed: () {
  205. // FReportInfo.instance.onClose.emit(this, null);
  206. // }),
  207. // MaterialButton(
  208. // child: const Text('open'),
  209. // onPressed: () {
  210. // setState(() {});
  211. // }),
  212. // MaterialButton(
  213. // child: const Text('testCustomTemplate'),
  214. // onPressed: () {
  215. // FReportInfo.instance.reload(
  216. // 'testCustomTemplate',
  217. // DateTime.now(),
  218. // _testStr,
  219. // onSelect,
  220. // i18nBook.common.revoke.t,
  221. // i18nBook.remedical.selectWord.t,
  222. // '');
  223. // }),
  224. // MaterialButton(
  225. // child: const Text('海弗'),
  226. // onPressed: () {
  227. // final reportMap = jsonDecode(_reportInfoStr);
  228. // FReportInfo.instance.fromJson(reportMap);
  229. // }),
  230. // MaterialButton(
  231. // child: const Text('testToJson'),
  232. // onPressed: () {
  233. // FReportInfo.instance.toJson();
  234. // final items = FReportInfo.instance.jsonItems;
  235. // final json = jsonEncode(items);
  236. // print(json);
  237. // }),
  238. // MaterialButton(
  239. // child: const Text('testDiagnostic'),
  240. // onPressed: () {
  241. // FReportInfo.instance.insertDiagnostic(
  242. // '主动脉极度扩张,主动脉窦扩张形成主动脉窦瘤,主动脉瓣呈囊袋状。 心底短轴显示主动脉瓣的对合不良。 多普勒超声显示舒张期返流束,起自主动脉瓣射向左心室达心尖部。 二尖瓣与主动脉瓣均脱垂。左心室扩张,呈容量负荷过重。左心功能正常。',
  243. // '符合冠心病间隔梗塞后的超声表现并伴室壁瘤形成,左心功能不全');
  244. // }),
  245. // MaterialButton(
  246. // child: const Text('setMockDatas'),
  247. // onPressed: () {
  248. // FReportInfo.instance.setMockDatas.emit(this, '');
  249. // }),
  250. // ],
  251. // ),
  252. // ),
  253. ],
  254. ),
  255. ),
  256. );
  257. });
  258. }
  259. BoxDecoration _buildDecoration() {
  260. return BoxDecoration(
  261. border: Border.all(
  262. width: 0.5,
  263. color: const Color.fromARGB(255, 83, 83, 83),
  264. ),
  265. color: Colors.white);
  266. }
  267. Future<bool> _loadi18nBook() async {
  268. var theme = AppTheme();
  269. try {
  270. await FTheme.init(theme);
  271. } catch (e) {
  272. await FTheme.ins.switchTheme('lightness');
  273. }
  274. await FTheme.ins.switchTheme('lightness', true);
  275. if (_isInitI18nbopok) {
  276. return true;
  277. }
  278. const curLocale = Locale('zh', 'CN');
  279. var bookOptions = [
  280. FTrKeybookOption.ChineseOption,
  281. ];
  282. try {
  283. await FI18n.init((locale) => locale, bookOptions);
  284. await FI18n.load(curLocale);
  285. } catch (e) {}
  286. _isInitI18nbopok = true;
  287. return true;
  288. }
  289. }