123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- import 'dart:convert';
- import 'package:fis_lib_report/converts/event_type.dart';
- import 'package:fis_lib_report/converts/pt_to_px_converter.dart';
- import 'package:fis_lib_report/report_edit.dart';
- import 'package:fis_lib_report/report_info/report_info.dart';
- import 'package:fis_ui/index.dart';
- import 'package:flutter/material.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:fis_lib_business_components/index.dart';
- import 'package:fis_i18n/i18n.dart';
- import 'package:flutter/services.dart';
- import 'package:fis_theme/theme.dart';
- import 'pages/theme.dart';
- void main() {
- runApp(const MyApp());
- }
- class MyApp extends StatelessWidget {
- const MyApp({Key? key}) : super(key: key);
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- // This is the theme of your application.
- //
- // Try running your application with "flutter run". You'll see the
- // application has a blue toolbar. Then, without quitting the app, try
- // changing the primarySwatch below to Colors.green and then invoke
- // "hot reload" (press "r" in the console where you ran "flutter run",
- // or simply save your changes to "hot reload" in a Flutter IDE).
- // Notice that the counter didn't reset back to zero; the application
- // is not restarted.
- primarySwatch: Colors.blue,
- ),
- home: const MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- const MyHomePage({Key? key, required this.title}) : super(key: key);
- final String title;
- @override
- State<MyHomePage> createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- final EdgeInsetsGeometry _padding =
- EdgeInsets.all(PtToPxConverter.ptToPx(56.83));
- String _jsonStr = '';
- final List<String> _demoImags = [
- 'http://cdn-bj.fis.plus/db38b8d36a7b48ada3effe0a53ea8993.jpg',
- 'http://cdn-bj.fis.plus/480e058b1eef47f9a9e333c3a54697eb.jpg',
- 'http://cdn-bj.fis.plus/0abdd310057e43c9b0d3fbe8ff854f1d.jpg',
- 'http://cdn-bj.fis.plus/cafd704360a24234b3c6630b771d6d42.jpg',
- 'http://cdn-bj.fis.plus/b93f044024a4426d90ea21a5ca8f71d1.jpg',
- "http://cdn-bj.fis.plus/36cd135e1b144c55a189fdde52085a5c.jpg",
- "http://cdn-bj.fis.plus/452e838ed56c46c7a41e59c5553db504.jpg",
- "http://cdn-bj.fis.plus/238f463a8bc74984b3368163417f1d70.jpg",
- "http://cdn-bj.fis.plus/dbf5eb4fec814001b6b91e36af5aec76.jpg",
- 'http://cdn-bj.fis.plus/2163bb64ebfa42cca5958b9cdbb4248d.jpg',
- 'http://cdn-bj.fis.plus/0743d4884601465c837f18fe0c54a7f2.jpg',
- 'http://cdn-bj.fis.plus/d4b4a2421e7d4b4189031ca736a52312.jpg',
- ];
- late FEventHandler<String> onSelect;
- String _aiJson = '';
- String _petStr = '';
- String _testStr = '';
- String _reportInfoStr = '';
- bool _isInitI18nbopok = false;
- @override
- initState() {
- onSelect = FEventHandler<String>();
- rootBundle.loadString('assets/心智医联(脑卒中).json').then((jsonStr) {
- setState(() {
- _jsonStr = jsonStr;
- });
- });
- rootBundle.loadString('assets/北京同仁堂.json').then((jsonStr) {
- _aiJson = jsonStr;
- });
- rootBundle.loadString('assets/心智简单结论报告(颈动脉).json').then((jsonStr) {
- _petStr = jsonStr;
- });
- rootBundle.loadString('assets/心智医联(心血管).json').then((jsonStr) {
- _testStr = jsonStr;
- });
- rootBundle.loadString('assets/血友病.json').then((jsonStr) {
- _reportInfoStr = jsonStr;
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return FutureBuilder<bool>(
- future: _loadi18nBook(),
- builder: (c, snapshot) {
- if (snapshot.connectionState != ConnectionState.done ||
- snapshot.data == null) {
- return const FCenter(
- child: FSizedBox(
- width: 20,
- height: 20,
- child: FCircularProgressIndicator(),
- ),
- );
- }
- return Scaffold(
- backgroundColor: Colors.white,
- body: SizedBox(
- child: Row(
- children: [
- if (_jsonStr.isNotEmpty && _demoImags.isNotEmpty)
- Expanded(
- child: ListView(
- shrinkWrap: true,
- children: [
- FReportEditPage(
- reporter: 'Loki',
- reportDate: DateTime.now(),
- jsonStr: _jsonStr,
- onSelect: onSelect,
- revoke: i18nBook.common.revoke.t,
- selectEntry: i18nBook.remedical.selectWord.t,
- selectImageHint:
- i18nBook.remedical.clickAndSelectImage.t,
- ),
- ],
- ),
- ),
- const SizedBox(width: 40),
- Container(
- decoration: _buildDecoration(),
- padding: _padding,
- alignment: Alignment.center,
- height: 800,
- width: 600,
- child: ListView(
- shrinkWrap: true,
- children: [
- Wrap(
- children: [
- ..._demoImags.map((element) {
- return Container(
- width: 150,
- height: 100,
- margin: const EdgeInsets.all(15),
- child: FContentImage(
- fileDataType:
- RemedicalFileDataTypeEnum.Image,
- terminalImage: TerminalImage(
- coverImageUrl: element,
- previewUrl: element,
- imageUrl: element,
- ),
- onTap: () => onSelect.emit(this, element),
- ),
- );
- })
- ],
- ),
- ],
- )),
- SizedBox(
- width: 400,
- child: Wrap(
- children: [
- MaterialButton(
- child: const Text('北京同仁堂'),
- onPressed: () {
- FReportInfo.instance.reload(
- '北京同仁堂',
- DateTime.now(),
- _aiJson,
- onSelect,
- i18nBook.common.revoke.t,
- i18nBook.remedical.selectWord.t,
- i18nBook.remedical.clickAndSelectImage.t);
- }),
- MaterialButton(
- child: const Text('testDefault'),
- onPressed: () {
- FReportInfo.instance.reload(
- '海孚结构化颈动脉',
- DateTime.now(),
- _jsonStr,
- onSelect,
- i18nBook.common.revoke.t,
- i18nBook.remedical.selectWord.t,
- i18nBook.remedical.clickAndSelectImage.t);
- }),
- MaterialButton(
- child: const Text('testPet'),
- onPressed: () {
- FReportInfo.instance.reload(
- '北京养老院模板',
- DateTime.now(),
- _petStr,
- onSelect,
- i18nBook.common.revoke.t,
- i18nBook.remedical.selectWord.t,
- i18nBook.remedical.clickAndSelectImage.t);
- }),
- MaterialButton(
- child: const Text('onClose'),
- onPressed: () {
- FReportInfo.instance.onClose.emit(this, null);
- }),
- MaterialButton(
- child: const Text('open'),
- onPressed: () {
- setState(() {});
- }),
- MaterialButton(
- child: const Text('testCustomTemplate'),
- onPressed: () {
- FReportInfo.instance.reload(
- 'testCustomTemplate',
- DateTime.now(),
- _testStr,
- onSelect,
- i18nBook.common.revoke.t,
- i18nBook.remedical.selectWord.t,
- '');
- }),
- MaterialButton(
- child: const Text('海弗'),
- onPressed: () {
- final reportMap = jsonDecode(_reportInfoStr);
- FReportInfo.instance.fromJson(reportMap);
- }),
- MaterialButton(
- child: const Text('testToJson'),
- onPressed: () {
- FReportInfo.instance.toJson();
- final items = FReportInfo.instance.jsonItems;
- final json = jsonEncode(items);
- print(json);
- }),
- MaterialButton(
- child: const Text('testDiagnostic'),
- onPressed: () {
- FReportInfo.instance.insertDiagnostic(
- '主动脉极度扩张,主动脉窦扩张形成主动脉窦瘤,主动脉瓣呈囊袋状。 心底短轴显示主动脉瓣的对合不良。 多普勒超声显示舒张期返流束,起自主动脉瓣射向左心室达心尖部。 二尖瓣与主动脉瓣均脱垂。左心室扩张,呈容量负荷过重。左心功能正常。',
- '符合冠心病间隔梗塞后的超声表现并伴室壁瘤形成,左心功能不全');
- }),
- MaterialButton(
- child: const Text('setMockDatas'),
- onPressed: () {
- FReportInfo.instance.setMockDatas.emit(this, '');
- }),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- });
- }
- BoxDecoration _buildDecoration() {
- return BoxDecoration(
- border: Border.all(
- width: 0.5,
- color: const Color.fromARGB(255, 83, 83, 83),
- ),
- color: Colors.white);
- }
- Future<bool> _loadi18nBook() async {
- var theme = AppTheme();
- try {
- await FTheme.init(theme);
- } catch (e) {
- await FTheme.ins.switchTheme('lightness');
- }
- await FTheme.ins.switchTheme('lightness', true);
- if (_isInitI18nbopok) {
- return true;
- }
- const curLocale = Locale('zh', 'CN');
- var bookOptions = [
- FTrKeybookOption.ChineseOption,
- ];
- try {
- await FI18n.init((locale) => locale, bookOptions);
- await FI18n.load(curLocale);
- } catch (e) {}
- _isInitI18nbopok = true;
- return true;
- }
- }
|