Add real client api call for config and resources
This commit is contained in:
parent
1a043ec675
commit
0245d659bf
@ -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<ConfigurationsScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Configurations"
|
||||
)
|
||||
),
|
||||
FutureBuilder(
|
||||
future: getConfigurations(appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> 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<List<ConfigurationDTO>> getConfigurations(dynamic appContext) async {
|
||||
List<ConfigurationDTO> configurations = await appContext.getContext().clientAPI.configurationApi.configurationGet();
|
||||
print("number of configurations " + configurations.length.toString());
|
||||
configurations.forEach((element) {
|
||||
print(element);
|
||||
});
|
||||
return configurations;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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<DevicesScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
|
||||
@ -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<ResourcesScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Resources"
|
||||
)
|
||||
),
|
||||
FutureBuilder(
|
||||
future: getResources(appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> 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<List<RessourceDTO>> getResources(dynamic appContext) async {
|
||||
List<RessourceDTO> ressources = await appContext.getContext().clientAPI.ressourceApi.ressourceGet();
|
||||
print("number of ressources " + ressources.length.toString());
|
||||
ressources.forEach((element) {
|
||||
print(element);
|
||||
});
|
||||
return ressources;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user