main.dart 4.9 KB

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