main.dart 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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/pages/components/vid_image.dart';
  5. import 'package:fis_lib_report/report_edit.dart';
  6. import 'package:fis_lib_report/report_info/element_tag_names.dart';
  7. import 'package:fis_lib_report/report_info/input_text_info.dart';
  8. import 'package:fis_lib_report/report_info/report_info.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. ];
  79. return Scaffold(
  80. backgroundColor: Colors.white,
  81. body: Row(
  82. children: [
  83. if (_jsonStr.isNotEmpty)
  84. Expanded(
  85. child: ReportEditPage(
  86. reporter: 'Loki',
  87. reportDate: DateTime.now(),
  88. jsonStr: _jsonStr,
  89. onSelect: onSelect,
  90. // patinentAge: '22',
  91. // patinentId: '20220705',
  92. // patinentName: 'name',
  93. // patinentSex: '男',
  94. ),
  95. ),
  96. const SizedBox(width: 40),
  97. Container(
  98. decoration: _buildDecoration(),
  99. padding: _padding,
  100. alignment: Alignment.center,
  101. height: 800,
  102. width: 600,
  103. child: Wrap(
  104. children: [
  105. ...demoImags.map((element) {
  106. return MouseRegion(
  107. cursor: SystemMouseCursors.click,
  108. child: GestureDetector(
  109. onTap: () {
  110. onSelect.emit(this, element);
  111. },
  112. child: Container(
  113. margin: const EdgeInsets.all(15),
  114. child: VidImageView.network(element),
  115. ),
  116. ),
  117. );
  118. })
  119. ],
  120. ),
  121. ),
  122. SizedBox(
  123. width: 400,
  124. child: Wrap(
  125. children: [
  126. MaterialButton(
  127. child: Text('testAI'),
  128. onPressed: () {
  129. ReportInfo.instance
  130. .reload('test', DateTime.now(), _aiJson, onSelect);
  131. }),
  132. MaterialButton(
  133. child: Text('testDefault'),
  134. onPressed: () {
  135. ReportInfo.instance.reload(
  136. 'default', DateTime.now(), _jsonStr, onSelect);
  137. }),
  138. MaterialButton(
  139. child: Text('testPet'),
  140. onPressed: () {
  141. ReportInfo.instance
  142. .reload('pet', DateTime.now(), _petStr, onSelect);
  143. }),
  144. MaterialButton(
  145. child: Text('onClose'),
  146. onPressed: () {
  147. ReportInfo.instance.onClose.emit(this, null);
  148. }),
  149. MaterialButton(
  150. child: Text('open'),
  151. onPressed: () {
  152. setState(() {});
  153. }),
  154. MaterialButton(
  155. child: const Text('testInfo'),
  156. onPressed: () {
  157. final reportMap = jsonDecode(_testStr);
  158. ReportInfo.instance.fromJson(reportMap);
  159. }),
  160. MaterialButton(
  161. child: const Text('testToJson'),
  162. onPressed: () {
  163. ReportInfo.instance.toJson();
  164. final items = ReportInfo.instance.jsonItems;
  165. final json = jsonEncode(items);
  166. print(json);
  167. }),
  168. ],
  169. ),
  170. ),
  171. ],
  172. ),
  173. );
  174. }
  175. BoxDecoration _buildDecoration() {
  176. return BoxDecoration(
  177. border: Border.all(
  178. width: 0.5,
  179. color: const Color.fromARGB(255, 83, 83, 83),
  180. ),
  181. color: Colors.white);
  182. }
  183. }