62 lines
2.1 KiB
Dart
62 lines
2.1 KiB
Dart
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);
|
|
|
|
@override
|
|
_ConfigurationsScreenState createState() => _ConfigurationsScreenState();
|
|
}
|
|
|
|
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: 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;
|
|
}
|
|
|
|
|
|
|