123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- import 'dart:convert';
- import 'package:fis_lib_report/converts/pt_to_px_converter.dart';
- import 'package:fis_lib_report/pages/block_element_page.dart';
- import 'package:fis_lib_report/pages/components/vid_image.dart';
- import 'package:fis_lib_report/report/interfaces/block_element.dart';
- import 'package:fis_lib_report/report/report_template_document.dart';
- import 'package:fis_lib_report/report/rt_thickness.dart';
- import 'package:fis_lib_report/report_info/report_info.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- void main() {
- runApp(const MyApp());
- }
- class MyApp extends StatelessWidget {
- const MyApp({Key? key}) : super(key: key);
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- // This is the theme of your application.
- //
- // Try running your application with "flutter run". You'll see the
- // application has a blue toolbar. Then, without quitting the app, try
- // changing the primarySwatch below to Colors.green and then invoke
- // "hot reload" (press "r" in the console where you ran "flutter run",
- // or simply save your changes to "hot reload" in a Flutter IDE).
- // Notice that the counter didn't reset back to zero; the application
- // is not restarted.
- primarySwatch: Colors.blue,
- ),
- home: const MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- const MyHomePage({Key? key, required this.title}) : super(key: key);
- final String title;
- @override
- State<MyHomePage> createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- ReportTemplateDocument _reportTemplate = ReportTemplateDocument();
- double _height = 0;
- double _width = 0;
- List<IBlockElement> _blocks = [];
- List<IBlockElement> _header = [];
- List<IBlockElement> _footer = [];
- double _baseFontSize = 9.0;
- double _footerDistance = 34.0;
- double _footerHeight = 0;
- EdgeInsetsGeometry _padding = EdgeInsets.all(PtToPxConverter.ptToPx(56.83));
- @override
- initState() {
- _intitTemplate();
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- final demoImags = [
- 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF2.VID',
- 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E8%83%8E%E5%84%BF1.VID',
- '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',
- 'http://192.168.6.117:9001/Flyinsono-BJ-1300984704.VCS.AP-BeiJing/compress%E4%B9%B3%E8%85%BAVideo.VID',
- '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'
- ];
- return Scaffold(
- body: Row(
- children: [
- Container(
- decoration: _buildDecoration(),
- padding: _padding,
- alignment: Alignment.center,
- height: _height,
- width: _width,
- child: ListView(
- // mainAxisAlignment: MainAxisAlignment.center,
- // crossAxisAlignment: CrossAxisAlignment.center,
- // mainAxisSize: MainAxisSize.min,
- children: [
- ..._header.map((head) {
- return BlockElementPage(element: head);
- }),
- ..._blocks.map((block) {
- return BlockElementPage(element: block);
- }),
- const SizedBox(height: 10),
- ..._footer.map((footer) {
- return BlockElementPage(element: footer);
- }),
- ],
- ),
- ),
- const SizedBox(width: 40),
- Container(
- decoration: _buildDecoration(),
- padding: _padding,
- alignment: Alignment.center,
- height: _height,
- width: _width,
- child: Wrap(
- children: [
- ...demoImags.map((element) {
- return MouseRegion(
- cursor: SystemMouseCursors.click,
- child: GestureDetector(
- onTap: () {
- ReportInfo.instance.getSelectedInputImage(element);
- },
- child: Container(
- margin: const EdgeInsets.all(15),
- child: VidImageView.network(element),
- ),
- ),
- );
- })
- ],
- )),
- ],
- ),
- );
- }
- BoxDecoration _buildDecoration() {
- return BoxDecoration(
- border: Border.all(
- width: 0.5,
- color: const Color.fromARGB(255, 83, 83, 83),
- ),
- color: Colors.white);
- }
- void _intitTemplate() {
- rootBundle.loadString('assets/default.json').then((jsonStr) {
- final reportMap = jsonDecode(jsonStr);
- final template = ReportTemplateDocument.fromJson(reportMap);
- _reportTemplate = template;
- ReportInfo.instance.init(_reportTemplate);
- setState(() {
- _initPage();
- });
- });
- }
- void _initPage() {
- try {
- _height = PtToPxConverter.ptToPx(_reportTemplate.pageSize!.height);
- _width = PtToPxConverter.ptToPx(_reportTemplate.pageSize!.width);
- _baseFontSize = PtToPxConverter.ptToPx(_reportTemplate.baseFontSize);
- _footerDistance = PtToPxConverter.ptToPx(_reportTemplate.footerDistance);
- _footerHeight = PtToPxConverter.ptToPx(_reportTemplate.footerHeight);
- final pagePadding =
- _reportTemplate.pagePadding ?? RTThickness.uniform(56);
- _padding = EdgeInsets.only(
- left: PtToPxConverter.ptToPx(pagePadding.left),
- right: PtToPxConverter.ptToPx(pagePadding.right),
- top: PtToPxConverter.ptToPx(pagePadding.top),
- bottom: PtToPxConverter.ptToPx(pagePadding.bottom),
- );
- _footer = _reportTemplate.footer ?? [];
- _blocks = _reportTemplate.blocks ?? [];
- _header = _reportTemplate.header ?? [];
- } catch (e) {
- _height = 841.8897637795275;
- _width = 595.275590551181;
- }
- }
- }
|