Test datatable configurations

This commit is contained in:
Thomas Fransolet 2021-04-23 18:43:06 +02:00
parent 0245d659bf
commit 4d3faaa39f
4 changed files with 126 additions and 13 deletions

View File

@ -16,7 +16,7 @@ class TextFieldContainer extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
width: size.width * 0.8,
decoration: BoxDecoration(
color: kTextLightColor,
color: kSecond,
borderRadius: BorderRadius.circular(29),
),
child: child,

View File

@ -19,22 +19,20 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
return Container(
child: Column(
children: [
Text(
"Configurations"
),
FutureBuilder(
future: getConfigurations(appContext),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return GridView.builder(
return bodyData(snapshot.data);
/*return GridView.builder(
shrinkWrap: true,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return // User Picture
return
Text(snapshot.data[0].label);
}
);
);*/
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
} else {
@ -46,6 +44,90 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
),
);
}
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 {

View File

@ -16,11 +16,42 @@ class _DevicesScreenState extends State<DevicesScreen> {
Size size = MediaQuery.of(context).size;
return Container(
child: Center(
child: Text(
"Devices"
)
child: Column(
children: [
Text(
"Devices"
),
/*FutureBuilder(
future: getDevices(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 devices");
}
);
} 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<DeviceDTO>> getDevices(dynamic appContext) async {
List<DeviceDTO> devices = await appContext.getContext().clientAPI.deviceApi.deviceGet();
print("number of devices " + ressources.length.toString());
devices.forEach((element) {
print(element);
});
return devices;
}*/

View File

@ -18,8 +18,8 @@ class LoginScreen extends StatefulWidget {
}
class _LoginScreenState extends State<LoginScreen> {
String email;// = "test@email.be";
String password;// = "kljqsdkljqsd";
String email = "test@email.be";
String password = "kljqsdkljqsd";
final clientAPI = Client();
void authenticateTRY(dynamic appContext) async {