144 lines
4.5 KiB
Dart
144 lines
4.5 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: [
|
|
FutureBuilder(
|
|
future: getConfigurations(appContext),
|
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
return bodyData(snapshot.data);
|
|
/*return GridView.builder(
|
|
shrinkWrap: true,
|
|
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
|
itemCount: snapshot.data.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return
|
|
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')));
|
|
}
|
|
}
|
|
),
|
|
]
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget bodyData(data) => DataTable(
|
|
sortColumnIndex: 0,
|
|
sortAscending: true,
|
|
columns: <DataColumn>[
|
|
DataColumn(
|
|
label: Text("Label"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
// data.sort((a) => a.label);
|
|
});
|
|
},
|
|
),
|
|
DataColumn(
|
|
label: Text("Primary color"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
/*data.sort((a, b) => a.data["stats"]["dividendYield"]
|
|
.compareTo(b.data["stats"]["dividendYield"]));*/
|
|
});
|
|
},
|
|
),
|
|
DataColumn(
|
|
label: Text("Secondary color"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
/*data.sort((a, b) => a.data["quote"]["iexBidPrice"]
|
|
.compareTo(b.data["quote"]["iexBidPrice"]));*/
|
|
});
|
|
},
|
|
),
|
|
DataColumn(
|
|
label: Text("Languages"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
/*data.sort((a, b) => a.data["stats"]["latestPrice"]
|
|
.compareTo(b.data["stats"]["latestPrice"]));*/
|
|
});
|
|
},
|
|
),
|
|
DataColumn(
|
|
label: Text("Date creation"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
/*data.sort((a, b) => a.data["stats"]["latestPrice"]
|
|
.compareTo(b.data["stats"]["latestPrice"]));*/
|
|
});
|
|
},
|
|
),
|
|
DataColumn(
|
|
label: Text("Actions"),
|
|
onSort: (_, __) {
|
|
setState(() {
|
|
/*data.sort((a, b) => a.data["stats"]["latestPrice"]
|
|
.compareTo(b.data["stats"]["latestPrice"]));*/
|
|
});
|
|
},
|
|
),
|
|
],
|
|
rows: data
|
|
.map<DataRow>( (configuration) => DataRow(
|
|
cells: [
|
|
DataCell(
|
|
Text('${configuration.label ?? ""}'),
|
|
),
|
|
DataCell(
|
|
Text('${configuration.primaryColor ?? ""}'),
|
|
),
|
|
DataCell(
|
|
Text('${configuration.secondaryColor ?? ""}'),
|
|
),
|
|
DataCell(
|
|
Text('${configuration.languages ?? ""}'),
|
|
),
|
|
DataCell(
|
|
Text('${configuration.dateCreation ?? ""}'),
|
|
),
|
|
DataCell(
|
|
Text("Todo buttons - open, edit, delete"),
|
|
),
|
|
],
|
|
),
|
|
).toList()
|
|
);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
|