157 lines
5.8 KiB
Dart
157 lines
5.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/string_input_container.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:managerapi/api.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class SectionDetailScreen extends StatefulWidget {
|
|
final String id;
|
|
SectionDetailScreen({Key key, @required this.id}) : super(key: key);
|
|
|
|
@override
|
|
_SectionDetailScreenState createState() => _SectionDetailScreenState();
|
|
}
|
|
|
|
class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|
SectionDTO sectionDTO;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appContext = Provider.of<AppContext>(context);
|
|
Size size = MediaQuery.of(context).size;
|
|
|
|
return Container(
|
|
child: FutureBuilder(
|
|
future: getSection(widget.id, appContext.getContext().clientAPI),
|
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
print("euh fuck ?");
|
|
print(snapshot.data);
|
|
return bodySection(snapshot.data, size, appContext, context);
|
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
|
return Text("No data");
|
|
} else {
|
|
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
|
}
|
|
}
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget bodySection(SectionDTO sectionDTO, Size size, AppContext appContext, BuildContext context) {
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.bottomStart,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(sectionDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
|
|
Padding(
|
|
padding: const EdgeInsets.all(5.0),
|
|
child: Text(DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Align(
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
child: InkWell(
|
|
onTap: () {
|
|
ManagerAppContext managerAppContext = appContext.getContext();
|
|
managerAppContext.selectedConfiguration = null;
|
|
appContext.setContext(managerAppContext);
|
|
},
|
|
child: Container(
|
|
child: Icon(
|
|
Icons.arrow_back,
|
|
color: kPrimaryColor,
|
|
size: 50.0,
|
|
)
|
|
)
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
), // TITLE
|
|
Container(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Container(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
StringContainer(
|
|
label: "Nom :",
|
|
initialValue: sectionDTO.label,
|
|
onChanged: (value) {
|
|
sectionDTO.label = value;
|
|
},
|
|
),
|
|
StringContainer(
|
|
label: "Description :",
|
|
initialValue: sectionDTO.description,
|
|
onChanged: (value) {
|
|
sectionDTO.description = value;
|
|
},
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Test :",
|
|
),
|
|
Text(
|
|
"Test :",
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),// FIELDS SECTION
|
|
//getButtons(configurationDTO, appContext),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<SectionDTO> getSection(String sectionId, dynamic appContext) async {
|
|
print("YOULOU TEST GET SECTION");
|
|
print(sectionId);
|
|
dynamic section = await appContext.getContext().clientAPI.sectionApi.sectionGetDetail(sectionId);
|
|
print("received section");
|
|
print(section);
|
|
return section;
|
|
}
|