58 lines
1.4 KiB
Dart
58 lines
1.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/pdf_file_input_container.dart';
|
|
import 'package:manager_app/Components/resource_input_container.dart';
|
|
import 'package:manager_api_new/api.dart';
|
|
import 'dart:convert';
|
|
|
|
import 'package:manager_app/constants.dart';
|
|
|
|
class PDFConfig extends StatefulWidget {
|
|
final String? color;
|
|
final String? label;
|
|
final String initialValue;
|
|
final ValueChanged<String> onChanged;
|
|
const PDFConfig({
|
|
Key? key,
|
|
this.color,
|
|
this.label,
|
|
required this.initialValue,
|
|
required this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_PDFConfigState createState() => _PDFConfigState();
|
|
}
|
|
|
|
class _PDFConfigState extends State<PDFConfig> {
|
|
late PdfDTO pdfDTO;
|
|
|
|
@override
|
|
void initState() {
|
|
PdfDTO test = PdfDTO.fromJson(json.decode(widget.initialValue))!;
|
|
pdfDTO = test;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Container(
|
|
height: 70,
|
|
width: 425,
|
|
child: PDFFileInputContainer(
|
|
label: "Fichiers PDF :",
|
|
initialValue: pdfDTO.pdfs != null ? pdfDTO.pdfs! : [],
|
|
color: kPrimaryColor,
|
|
onChanged: (List<PDFFileDTO>? value) {
|
|
if(value != null) {
|
|
pdfDTO.pdfs = value;
|
|
widget.onChanged(jsonEncode(pdfDTO).toString());
|
|
}
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|