Added host and complete url for qr code
This commit is contained in:
parent
e321eda0ac
commit
fec95bbfe8
@ -1,11 +1,12 @@
|
||||
import 'package:manager_api_new/api.dart';
|
||||
import 'package:manager_app/Models/managerContext.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'dart:html' as html;
|
||||
|
||||
class PDFHelper {
|
||||
static downloadPDF(List<SectionDTO> sections) async {
|
||||
static downloadPDF(ManagerAppContext managerAppContext, List<SectionDTO> sections) async {
|
||||
var sectionsArticle = sections.where((section) => section.type == SectionType.Article || section.type == SectionType.Quizz); // TODO HERE Support more section types
|
||||
if(sectionsArticle.length > 0) {
|
||||
//final font = await rootBundle.load("fonts/OpenSans-Medium.ttf");
|
||||
@ -25,7 +26,7 @@ class PDFHelper {
|
||||
pw.Text(section.label!.replaceAll(RegExp("[^A-Za-z0-9---():!éàèëêäâç' ]"), '')), //style: pw.TextStyle(font: ttf, fontSize: 30)
|
||||
pw.Padding(padding: const pw.EdgeInsets.only(top: 20)),
|
||||
pw.BarcodeWidget(
|
||||
data: section.id!,
|
||||
data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${section.id!}",
|
||||
width: 150,
|
||||
height: 150,
|
||||
barcode: pw.Barcode.qrCode(),
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Helpers/PDFHelper.dart';
|
||||
import 'package:manager_app/Models/managerContext.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
import 'package:manager_api_new/api.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DownloadPDF extends StatefulWidget {
|
||||
final List<SectionDTO> sections;
|
||||
@ -23,11 +26,14 @@ class _DownloadPDFState extends State<DownloadPDF> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
|
||||
return
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
try {
|
||||
PDFHelper.downloadPDF(widget.sections);
|
||||
PDFHelper.downloadPDF(managerAppContext, widget.sections);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
@ -85,6 +85,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
}
|
||||
|
||||
Widget bodySection(SectionDTO? sectionDTO, Size size, AppContext appContext, BuildContext context, GlobalKey globalKey) {
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
//mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@ -183,7 +185,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
key: globalKey,
|
||||
child: QrImageView(
|
||||
padding: EdgeInsets.only(left: 5.0, top: 5.0, bottom: 5.0, right: 5.0),
|
||||
data: sectionDTO!.id!,
|
||||
data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${sectionDTO!.id!}",
|
||||
version: QrVersions.auto,
|
||||
size: 50.0,
|
||||
),
|
||||
|
||||
@ -63,6 +63,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
}
|
||||
|
||||
Widget bodyConfiguration(ConfigurationDTO configurationDTO, Size size, AppContext appContext, BuildContext context) {
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
return Column(
|
||||
//mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@ -244,7 +245,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
textColor: Colors.white,
|
||||
fontSize: 15,
|
||||
press: () {
|
||||
PDFHelper.downloadPDF(sections!);
|
||||
PDFHelper.downloadPDF(managerAppContext, sections!);
|
||||
},
|
||||
),
|
||||
CheckInputContainer(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user