main.dart 6.0 KB

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