import 'package:carousel_slider/carousel_slider.dart'; import 'package:cssd/config/colors.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:pinch_zoom/pinch_zoom.dart'; import 'package:url_launcher/url_launcher.dart'; class DatasBox extends StatelessWidget { const DatasBox({ Key? key, required this.datas, required double deviceBlockSize, }) : _deviceBlockSize = deviceBlockSize, super(key: key); final Map datas; final double _deviceBlockSize; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(20), child: ListView( children: [ SizedBox( height: 10, ), Text( 'Test Result Details', style: TextStyle( fontWeight: FontWeight.w700, fontSize: 5 * _deviceBlockSize, letterSpacing: 3, ), ), SizedBox( height: 10, ), Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Color.fromRGBO(230, 230, 230, 1), border: Border( left: BorderSide( color: datas['verified'] == 'Verified' ? kLightBlue : datas['verified'] == 'NotVerified' ? kPink : Colors.grey, width: 2, ), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( DateFormat.yMMMd().format( DateTime.parse( datas['date'], ), ), style: TextStyle( color: datas['verified'] == 'Verified' ? kLightBlue : datas['verified'] == 'NotVerified' ? kPink : Colors.grey, ), ), Divider(), Text( datas['test_type_name'], style: TextStyle( color: datas['verified'] == 'Verified' ? kLightBlue : datas['verified'] == 'NotVerified' ? kPink : Colors.grey, fontWeight: FontWeight.w700, ), ), SizedBox( height: 30, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Test Register ID', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( datas['id'].toString(), style: TextStyle( fontWeight: FontWeight.w700, ), overflow: TextOverflow.clip, ), ), ], ), Divider(), SizedBox( height: 5, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Autoclave ID', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( datas['auto_cleave_id'].toString(), style: TextStyle( fontWeight: FontWeight.w700, ), overflow: TextOverflow.clip, ), ), ], ), Divider(), SizedBox( height: 5, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Hospital', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( datas['hospital'].toString(), style: TextStyle( fontWeight: FontWeight.w700, ), overflow: TextOverflow.clip, ), ), ], ), Divider(), SizedBox( height: 5, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Date', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( DateFormat('d-M-y').format( DateTime.parse( datas['date'], ), ), style: TextStyle( fontWeight: FontWeight.w700, ), overflow: TextOverflow.clip, ), ), ], ), Divider(), SizedBox( height: 5, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Status', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( datas['verified'] == 'Verified' ? 'Accepted' : datas['verified'] == 'NotVerified' ? 'Rejected' : 'Pending..', style: TextStyle( fontWeight: FontWeight.w700, color: datas['verified'] == 'Verified' ? kLightBlue : datas['verified'] == 'NotVerified' ? kPink : Colors.grey, ), overflow: TextOverflow.clip, ), ), ], ), Divider(), SizedBox( height: 5, ), Row( children: [ Container( width: 35 * _deviceBlockSize, child: Text( 'Description', style: TextStyle( color: Colors.grey, ), ), ), Container( width: 45 * _deviceBlockSize, child: Text( datas['description'].toString(), style: TextStyle( fontWeight: FontWeight.w700, ), overflow: TextOverflow.clip, ), ), ], ), if (datas['files'].isNotEmpty) Divider(), if (datas['files'].isNotEmpty) SizedBox( height: 10, ), if (datas['files'].isNotEmpty) Container( width: double.infinity, padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), child: CarouselSlider.builder( disableGesture: true, itemBuilder: (ctx, index, realIndex) { return InkWell( child: Image(image: NetworkImage(datas['files'][index])), onTap: () { showDialog( context: context, builder: (BuildContext context) => PinchZoom( child: Image.network(datas['files'][index])), ); }, ); }, itemCount: datas['files'].length, options: CarouselOptions( enlargeCenterPage: true, aspectRatio: 16 / 8, viewportFraction: datas['files'].length == 1 ? 1 : 0.6, padEnds: false, pauseAutoPlayOnTouch: true, disableCenter: false, autoPlay: false, enlargeFactor: 0.5, enableInfiniteScroll: datas['files'].length == 1 ? false : true, ), ), ), ], ), ), SizedBox( height: 20, ), InkWell( onTap: () async => await launch( 'https://cssd-doc.com/Show/TestResult/${datas['id'].toString()}', // 'https://cssd-doc.com/api/TestResults/${datas['id'].toString()}', // forceSafariVC: true, // forceWebView: true, // headers: {'my_header_key': 'my_header_value'}, // child: Text('Show Full Details'), ), child: Container( padding: EdgeInsets.symmetric(vertical: 20), width: double.infinity, decoration: BoxDecoration( color: Color.fromRGBO(230, 230, 230, 1), borderRadius: BorderRadius.circular(25), ), child: Center( child: Text( 'Show More Details', style: TextStyle(fontWeight: FontWeight.w700), ), ), ), ) ], ), ); } }