48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/resource_input_container.dart';
|
|
import 'package:manager_api_new/api.dart';
|
|
import 'dart:convert';
|
|
|
|
class AgendaConfig extends StatefulWidget {
|
|
final String? color;
|
|
final String? label;
|
|
final String initialValue;
|
|
final ValueChanged<String> onChanged;
|
|
const AgendaConfig({
|
|
Key? key,
|
|
this.color,
|
|
this.label,
|
|
required this.initialValue,
|
|
required this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_AgendaConfigState createState() => _AgendaConfigState();
|
|
}
|
|
|
|
class _AgendaConfigState extends State<AgendaConfig> {
|
|
late AgendaDTO agendaDTO;
|
|
|
|
@override
|
|
void initState() {
|
|
AgendaDTO test = AgendaDTO.fromJson(json.decode(widget.initialValue))!;
|
|
agendaDTO = test;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ResourceInputContainer(
|
|
label: "Fichier JSON :",
|
|
initialValue: agendaDTO.resourceId == null ? '': agendaDTO.resourceId,
|
|
inResourceTypes: [ResourceType.Json, ResourceType.JsonUrl],
|
|
onChanged: (ResourceDTO resourceDTO) {
|
|
agendaDTO.resourceUrl = resourceDTO.url;
|
|
agendaDTO.resourceId = resourceDTO.id;
|
|
widget.onChanged(jsonEncode(agendaDTO).toString());
|
|
}
|
|
);
|
|
}
|
|
}
|