main.dart 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. super.initState();
  56. rootBundle.loadString('assets/single_image.json').then((jsonStr) {
  57. _aiJson = jsonStr;
  58. });
  59. rootBundle.loadString('assets/pet.json').then((jsonStr) {
  60. _petStr = jsonStr;
  61. });
  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. body: Row(
  74. children: [
  75. ReportEditPage(
  76. reporter: 'Loki',
  77. reportDate: DateTime.now(),
  78. jsonStr: _jsonStr,
  79. onSelect: onSelect,
  80. ),
  81. const SizedBox(width: 40),
  82. Container(
  83. decoration: _buildDecoration(),
  84. padding: _padding,
  85. alignment: Alignment.center,
  86. height: 800,
  87. width: 600,
  88. child: Wrap(
  89. children: [
  90. ...demoImags.map((element) {
  91. return MouseRegion(
  92. cursor: SystemMouseCursors.click,
  93. child: GestureDetector(
  94. onTap: () {
  95. onSelect.emit(this, element);
  96. },
  97. child: Container(
  98. margin: const EdgeInsets.all(15),
  99. child: VidImageView.network(element),
  100. ),
  101. ),
  102. );
  103. })
  104. ],
  105. ),
  106. ),
  107. MaterialButton(
  108. child: Text('testAI'),
  109. onPressed: () {
  110. ReportInfo.instance
  111. .reload('test', DateTime.now(), _aiJson, onSelect);
  112. }),
  113. MaterialButton(
  114. child: Text('testDefault'),
  115. onPressed: () {
  116. ReportInfo.instance
  117. .reload('default', DateTime.now(), _jsonStr, onSelect);
  118. }),
  119. MaterialButton(
  120. child: Text('testPet'),
  121. onPressed: () {
  122. ReportInfo.instance
  123. .reload('pet', DateTime.now(), _petStr, onSelect);
  124. }),
  125. ],
  126. ),
  127. );
  128. }
  129. BoxDecoration _buildDecoration() {
  130. return BoxDecoration(
  131. border: Border.all(
  132. width: 0.5,
  133. color: const Color.fromARGB(255, 83, 83, 83),
  134. ),
  135. color: Colors.white);
  136. }
  137. }