diff --git a/lib/Screens/Configurations/configurations_screen.dart b/lib/Screens/Configurations/configurations_screen.dart index 79955d9..ff821c1 100644 --- a/lib/Screens/Configurations/configurations_screen.dart +++ b/lib/Screens/Configurations/configurations_screen.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:managerapi/api.dart'; +import 'package:provider/provider.dart'; class ConfigurationsScreen extends StatefulWidget { ConfigurationsScreen({Key key}) : super(key: key); @@ -10,12 +13,49 @@ class ConfigurationsScreen extends StatefulWidget { class _ConfigurationsScreenState extends State { @override Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + return Container( - child: Center( - child: Text( - "Configurations" - ) + child: Column( + children: [ + Text( + "Configurations" + ), + FutureBuilder( + future: getConfigurations(appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return GridView.builder( + shrinkWrap: true, + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + itemCount: snapshot.data.length, + itemBuilder: (BuildContext context, int index) { + return // User Picture + Text(snapshot.data[0].label); + } + ); + } 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'))); + } + } + ), + ] ), ); } } + +Future> getConfigurations(dynamic appContext) async { + List configurations = await appContext.getContext().clientAPI.configurationApi.configurationGet(); + print("number of configurations " + configurations.length.toString()); + configurations.forEach((element) { + print(element); + }); + return configurations; +} + + + diff --git a/lib/Screens/Devices/devices_screen.dart b/lib/Screens/Devices/devices_screen.dart index e3d65cf..2899f17 100644 --- a/lib/Screens/Devices/devices_screen.dart +++ b/lib/Screens/Devices/devices_screen.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:provider/provider.dart'; class DevicesScreen extends StatefulWidget { DevicesScreen({Key key}) : super(key: key); @@ -10,6 +12,9 @@ class DevicesScreen extends StatefulWidget { class _DevicesScreenState extends State { @override Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + return Container( child: Center( child: Text( diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index 16a5e71..29d5b1e 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:managerapi/api.dart'; +import 'package:provider/provider.dart'; class ResourcesScreen extends StatefulWidget { ResourcesScreen({Key key}) : super(key: key); @@ -8,14 +11,49 @@ class ResourcesScreen extends StatefulWidget { } class _ResourcesScreenState extends State { + @override Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + return Container( - child: Center( - child: Text( - "Resources" - ) + child: Column( + children: [ + Text( + "Resources" + ), + FutureBuilder( + future: getResources(appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return GridView.builder( + shrinkWrap: true, + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + itemCount: snapshot.data.length, + itemBuilder: (BuildContext context, int index) { + return // User Picture + Text("Test resources"); + } + ); + } 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'))); + } + } + ), + ] ), ); } } + +Future> getResources(dynamic appContext) async { + List ressources = await appContext.getContext().clientAPI.ressourceApi.ressourceGet(); + print("number of ressources " + ressources.length.toString()); + ressources.forEach((element) { + print(element); + }); + return ressources; +}