main.dart 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. @override
  46. initState() {
  47. onSelect = FEventHandler<String>();
  48. rootBundle.loadString('assets/default.json').then((jsonStr) {
  49. setState(() {
  50. _jsonStr = jsonStr;
  51. });
  52. });
  53. super.initState();
  54. Future.delayed(
  55. const Duration(milliseconds: 8000),
  56. () => rootBundle.loadString('assets/single_image.json').then((jsonStr) {
  57. ReportInfo.instance.reload('', DateTime.now(), jsonStr, onSelect);
  58. }));
  59. }
  60. @override
  61. Widget build(BuildContext context) {
  62. final demoImags = [
  63. 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF2.VID',
  64. 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF1.VID',
  65. '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',
  66. 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E4%B9%B3%E8%85%BAVideo.VID',
  67. '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'
  68. ];
  69. return Scaffold(
  70. body: Row(
  71. children: [
  72. ReportEditPage(
  73. reporter: 'Loki',
  74. reportDate: DateTime.now(),
  75. jsonStr: _jsonStr,
  76. onSelect: onSelect,
  77. ),
  78. const SizedBox(width: 40),
  79. Container(
  80. decoration: _buildDecoration(),
  81. padding: _padding,
  82. alignment: Alignment.center,
  83. height: 800,
  84. width: 600,
  85. child: Wrap(
  86. children: [
  87. ...demoImags.map((element) {
  88. return MouseRegion(
  89. cursor: SystemMouseCursors.click,
  90. child: GestureDetector(
  91. onTap: () {
  92. onSelect.emit(this, element);
  93. },
  94. child: Container(
  95. margin: const EdgeInsets.all(15),
  96. child: VidImageView.network(element),
  97. ),
  98. ),
  99. );
  100. })
  101. ],
  102. )),
  103. ],
  104. ),
  105. );
  106. }
  107. BoxDecoration _buildDecoration() {
  108. return BoxDecoration(
  109. border: Border.all(
  110. width: 0.5,
  111. color: const Color.fromARGB(255, 83, 83, 83),
  112. ),
  113. color: Colors.white);
  114. }
  115. }