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