main.dart 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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/element_tag_names.dart';
  6. import 'package:fis_lib_report/report_info/input_text_info.dart';
  7. import 'package:fis_lib_report/report_info/report_info.dart';
  8. import 'package:fis_ui/business/vid_img_view/index.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/services.dart';
  11. void main() {
  12. runApp(const MyApp());
  13. }
  14. class MyApp extends StatelessWidget {
  15. const MyApp({Key? key}) : super(key: key);
  16. // This widget is the root of your application.
  17. @override
  18. Widget build(BuildContext context) {
  19. return MaterialApp(
  20. title: 'Flutter Demo',
  21. theme: ThemeData(
  22. // This is the theme of your application.
  23. //
  24. // Try running your application with "flutter run". You'll see the
  25. // application has a blue toolbar. Then, without quitting the app, try
  26. // changing the primarySwatch below to Colors.green and then invoke
  27. // "hot reload" (press "r" in the console where you ran "flutter run",
  28. // or simply save your changes to "hot reload" in a Flutter IDE).
  29. // Notice that the counter didn't reset back to zero; the application
  30. // is not restarted.
  31. primarySwatch: Colors.blue,
  32. ),
  33. home: const MyHomePage(title: 'Flutter Demo Home Page'),
  34. );
  35. }
  36. }
  37. class MyHomePage extends StatefulWidget {
  38. const MyHomePage({Key? key, required this.title}) : super(key: key);
  39. final String title;
  40. @override
  41. State<MyHomePage> createState() => _MyHomePageState();
  42. }
  43. class _MyHomePageState extends State<MyHomePage> {
  44. String _jsonStr = '';
  45. final EdgeInsetsGeometry _padding =
  46. EdgeInsets.all(PtToPxConverter.ptToPx(56.83));
  47. late FEventHandler<String> onSelect;
  48. String _aiJson = '';
  49. String _petStr = '';
  50. String _testStr = '';
  51. @override
  52. initState() {
  53. onSelect = FEventHandler<String>();
  54. rootBundle.loadString('assets/default.json').then((jsonStr) {
  55. setState(() {
  56. _jsonStr = jsonStr;
  57. });
  58. });
  59. rootBundle.loadString('assets/single_image.json').then((jsonStr) {
  60. _aiJson = jsonStr;
  61. });
  62. rootBundle.loadString('assets/pet.json').then((jsonStr) {
  63. _petStr = jsonStr;
  64. });
  65. rootBundle.loadString('assets/test.json').then((jsonStr) {
  66. _testStr = jsonStr;
  67. });
  68. super.initState();
  69. }
  70. @override
  71. Widget build(BuildContext context) {
  72. final demoImags = [
  73. 'http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF2.VID',
  74. 'http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF1.VID',
  75. 'http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E4%B9%B3%E8%85%BA%E5%8D%95%E5%B8%A7%E5%9B%BE.VID',
  76. 'http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E4%B9%B3%E8%85%BAVideo.VID',
  77. 'http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E9%A2%88%E5%8A%A8%E8%84%89%E6%A8%AA%E5%88%87.VID',
  78. "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/2bf772b058a045f5b7e21466ab5f5d51.VID",
  79. "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/381c738696bd4a1fac8d429e4cb01606.VID",
  80. "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/7d48f5c52cd4423ba679950869adfadb.VID",
  81. "http://192.168.6.117:9303/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/5aa0a3f3fe214a0fbdec911321208b6b.VID"
  82. ];
  83. return Scaffold(
  84. backgroundColor: Colors.white,
  85. body: Row(
  86. children: [
  87. if (_jsonStr.isNotEmpty)
  88. Expanded(
  89. child: ReportEditPage(
  90. reporter: 'Loki',
  91. reportDate: DateTime.now(),
  92. jsonStr: _jsonStr,
  93. onSelect: onSelect,
  94. // patinentAge: '22',
  95. // patinentId: '20220705',
  96. // patinentName: 'name',
  97. // patinentSex: '男',
  98. ),
  99. ),
  100. const SizedBox(width: 40),
  101. Container(
  102. decoration: _buildDecoration(),
  103. padding: _padding,
  104. alignment: Alignment.center,
  105. height: 800,
  106. width: 600,
  107. child: Wrap(
  108. children: [
  109. ...demoImags.map((element) {
  110. return MouseRegion(
  111. cursor: SystemMouseCursors.click,
  112. child: GestureDetector(
  113. onTap: () {
  114. onSelect.emit(this, element);
  115. },
  116. child: Container(
  117. margin: const EdgeInsets.all(15),
  118. child: VidImageView(
  119. url: element,
  120. width: 150,
  121. height: 100,
  122. ),
  123. ),
  124. ),
  125. );
  126. })
  127. ],
  128. ),
  129. ),
  130. SizedBox(
  131. width: 400,
  132. child: Wrap(
  133. children: [
  134. MaterialButton(
  135. child: Text('testAI'),
  136. onPressed: () {
  137. ReportInfo.instance
  138. .reload('test', DateTime.now(), _aiJson, onSelect);
  139. }),
  140. MaterialButton(
  141. child: Text('testDefault'),
  142. onPressed: () {
  143. ReportInfo.instance.reload(
  144. 'default', DateTime.now(), _jsonStr, onSelect);
  145. }),
  146. MaterialButton(
  147. child: Text('testPet'),
  148. onPressed: () {
  149. ReportInfo.instance
  150. .reload('pet', DateTime.now(), _petStr, onSelect);
  151. }),
  152. MaterialButton(
  153. child: Text('onClose'),
  154. onPressed: () {
  155. ReportInfo.instance.onClose.emit(this, null);
  156. }),
  157. MaterialButton(
  158. child: Text('open'),
  159. onPressed: () {
  160. setState(() {});
  161. }),
  162. MaterialButton(
  163. child: const Text('testInfo'),
  164. onPressed: () {
  165. final reportMap = jsonDecode(_testStr);
  166. ReportInfo.instance.fromJson(reportMap);
  167. }),
  168. MaterialButton(
  169. child: const Text('testToJson'),
  170. onPressed: () {
  171. ReportInfo.instance.toJson();
  172. final items = ReportInfo.instance.jsonItems;
  173. final json = jsonEncode(items);
  174. print(json);
  175. }),
  176. ],
  177. ),
  178. ),
  179. ],
  180. ),
  181. );
  182. }
  183. BoxDecoration _buildDecoration() {
  184. return BoxDecoration(
  185. border: Border.all(
  186. width: 0.5,
  187. color: const Color.fromARGB(255, 83, 83, 83),
  188. ),
  189. color: Colors.white);
  190. }
  191. }