From 4d3faaa39f05bd82dc2f0b9b97177148a17b79c5 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 23 Apr 2021 18:43:06 +0200 Subject: [PATCH] Test datatable configurations --- lib/Components/text_field_container.dart | 2 +- .../Configurations/configurations_screen.dart | 94 +++++++++++++++++-- lib/Screens/Devices/devices_screen.dart | 39 +++++++- lib/Screens/login_screen.dart | 4 +- 4 files changed, 126 insertions(+), 13 deletions(-) diff --git a/lib/Components/text_field_container.dart b/lib/Components/text_field_container.dart index 9241d20..b2a995b 100644 --- a/lib/Components/text_field_container.dart +++ b/lib/Components/text_field_container.dart @@ -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, diff --git a/lib/Screens/Configurations/configurations_screen.dart b/lib/Screens/Configurations/configurations_screen.dart index ff821c1..8a4d615 100644 --- a/lib/Screens/Configurations/configurations_screen.dart +++ b/lib/Screens/Configurations/configurations_screen.dart @@ -19,22 +19,20 @@ class _ConfigurationsScreenState extends State { return Container( child: Column( children: [ - Text( - "Configurations" - ), FutureBuilder( future: getConfigurations(appContext), builder: (context, AsyncSnapshot 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 { ), ); } + + Widget bodyData(data) => DataTable( + sortColumnIndex: 0, + sortAscending: true, + columns: [ + 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( (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> getConfigurations(dynamic appContext) async { diff --git a/lib/Screens/Devices/devices_screen.dart b/lib/Screens/Devices/devices_screen.dart index 2899f17..79b0b50 100644 --- a/lib/Screens/Devices/devices_screen.dart +++ b/lib/Screens/Devices/devices_screen.dart @@ -16,11 +16,42 @@ class _DevicesScreenState extends State { 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 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> getDevices(dynamic appContext) async { + List devices = await appContext.getContext().clientAPI.deviceApi.deviceGet(); + print("number of devices " + ressources.length.toString()); + devices.forEach((element) { + print(element); + }); + return devices; +}*/ diff --git a/lib/Screens/login_screen.dart b/lib/Screens/login_screen.dart index 9133471..0f74ce7 100644 --- a/lib/Screens/login_screen.dart +++ b/lib/Screens/login_screen.dart @@ -18,8 +18,8 @@ class LoginScreen extends StatefulWidget { } class _LoginScreenState extends State { - String email;// = "test@email.be"; - String password;// = "kljqsdkljqsd"; + String email = "test@email.be"; + String password = "kljqsdkljqsd"; final clientAPI = Client(); void authenticateTRY(dynamic appContext) async {