update service generation + update layout for edit device info (dropdown)
This commit is contained in:
parent
168c62585c
commit
0b05d1bd3d
@ -8,6 +8,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
final ValueChanged<String> onChanged;
|
final ValueChanged<String> onChanged;
|
||||||
final String initialValue;
|
final String initialValue;
|
||||||
final Color color, textColor, iconColor;
|
final Color color, textColor, iconColor;
|
||||||
|
final int maxLength;
|
||||||
const RoundedInputField({
|
const RoundedInputField({
|
||||||
Key key,
|
Key key,
|
||||||
this.hintText,
|
this.hintText,
|
||||||
@ -17,6 +18,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
this.textColor = kBlack,
|
this.textColor = kBlack,
|
||||||
this.iconColor = kPrimaryColor,
|
this.iconColor = kPrimaryColor,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.maxLength = 50,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -27,6 +29,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
cursorColor: textColor,
|
cursorColor: textColor,
|
||||||
|
maxLength: maxLength,
|
||||||
style: TextStyle(fontSize: 20, color: textColor),
|
style: TextStyle(fontSize: 20, color: textColor),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
icon: icon != null ? Icon(
|
icon: icon != null ? Icon(
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class StringInputContainer extends StatelessWidget {
|
|||||||
final ValueChanged<String> onChanged;
|
final ValueChanged<String> onChanged;
|
||||||
final bool isUrl;
|
final bool isUrl;
|
||||||
final bool isSmall;
|
final bool isSmall;
|
||||||
|
final int maxLength;
|
||||||
const StringInputContainer({
|
const StringInputContainer({
|
||||||
Key key,
|
Key key,
|
||||||
this.color = kSecond,
|
this.color = kSecond,
|
||||||
@ -17,6 +18,7 @@ class StringInputContainer extends StatelessWidget {
|
|||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.isUrl = false,
|
this.isUrl = false,
|
||||||
this.isSmall = false,
|
this.isSmall = false,
|
||||||
|
this.maxLength = 50,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -32,12 +34,13 @@ class StringInputContainer extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: isUrl ? size.width *0.6 : isSmall != null ? size.width *0.1 : size.width *0.2,
|
width: isUrl ? size.width *0.6 : isSmall ? size.width *0.1 : size.width *0.2,
|
||||||
child: RoundedInputField(
|
child: RoundedInputField(
|
||||||
color: color,
|
color: color,
|
||||||
textColor: kBlack,
|
textColor: kBlack,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
|
maxLength: maxLength,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
145
lib/Screens/Devices/change_device_info_modal.dart
Normal file
145
lib/Screens/Devices/change_device_info_modal.dart
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
|
||||||
|
import 'dropDown_configuration.dart';
|
||||||
|
|
||||||
|
showChangeInfo (String text, DeviceDTO inputDevice, Function onGetResult, int maxLines, BuildContext mainContext, dynamic appContext) {
|
||||||
|
Size size = MediaQuery.of(mainContext).size;
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||||
|
),
|
||||||
|
title: Center(child: Text(text)),
|
||||||
|
content: Container(
|
||||||
|
width: size.width * 0.3,
|
||||||
|
height: size.height * 0.3,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Container(
|
||||||
|
width: size.width * 0.3,
|
||||||
|
height: size.height * 0.15,
|
||||||
|
child: StringInputContainer(
|
||||||
|
label: "Nom:",
|
||||||
|
initialValue: inputDevice.name,
|
||||||
|
onChanged: (value) {
|
||||||
|
inputDevice.name = value;
|
||||||
|
},
|
||||||
|
maxLength: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
child: Text("Configuration:", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: size.height * 0.1,
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: getConfigurations(appContext),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: DropDownConfig(
|
||||||
|
configurations: snapshot.data,
|
||||||
|
selectedConfigurationId: inputDevice.configurationId,
|
||||||
|
onChange: (ConfigurationDTO configurationOut) {
|
||||||
|
inputDevice.configuration = configurationOut.label;
|
||||||
|
inputDevice.configurationId = configurationOut.id;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} 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')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 180,
|
||||||
|
height: 70,
|
||||||
|
child: RoundedButton(
|
||||||
|
text: "Annuler",
|
||||||
|
icon: Icons.undo,
|
||||||
|
color: kSecond,
|
||||||
|
press: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 180,
|
||||||
|
height: 70,
|
||||||
|
child: RoundedButton(
|
||||||
|
text: "Changer",
|
||||||
|
icon: Icons.check,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
textColor: kWhite,
|
||||||
|
press: () {
|
||||||
|
onGetResult(inputDevice);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
), context: mainContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getConfigurationsElement(DeviceDTO inputDevice, data, Function onGetResult) {
|
||||||
|
List<Widget> widgets = new List<Widget>();
|
||||||
|
for(var configuration in data as List<ConfigurationDTO>) {
|
||||||
|
var widget = new InkWell(
|
||||||
|
onTap: () {
|
||||||
|
inputDevice.configuration = configuration.label;
|
||||||
|
inputDevice.configurationId = configuration.id;
|
||||||
|
},
|
||||||
|
child: Ink(
|
||||||
|
color: inputDevice.configurationId == configuration.id ? kPrimaryColor : null,
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.account_tree_rounded),
|
||||||
|
title: Text(configuration.label),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
widgets.add(widget);
|
||||||
|
}
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,68 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
|
||||||
import 'package:manager_app/Components/string_input_container.dart';
|
|
||||||
import 'package:manager_app/constants.dart';
|
|
||||||
import 'package:managerapi/api.dart';
|
|
||||||
|
|
||||||
showChangeNameModal (String text, String name, Function onGetResult, int maxLines, BuildContext mainContext, dynamic appContext) {
|
|
||||||
Size size = MediaQuery.of(mainContext).size;
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
builder: (BuildContext context) => AlertDialog(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
|
||||||
),
|
|
||||||
title: Center(child: Text(text)),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: size.width * 0.3,
|
|
||||||
height: size.height * 0.15,
|
|
||||||
child: StringInputContainer(
|
|
||||||
label: "Nom :",
|
|
||||||
initialValue: name,
|
|
||||||
onChanged: (value) {
|
|
||||||
name = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 180,
|
|
||||||
height: 70,
|
|
||||||
child: RoundedButton(
|
|
||||||
text: "Annuler",
|
|
||||||
icon: Icons.undo,
|
|
||||||
color: kSecond,
|
|
||||||
press: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 180,
|
|
||||||
height: 70,
|
|
||||||
child: RoundedButton(
|
|
||||||
text: "Changer",
|
|
||||||
icon: Icons.check,
|
|
||||||
color: kPrimaryColor,
|
|
||||||
textColor: kWhite,
|
|
||||||
press: () {
|
|
||||||
onGetResult(name);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
), context: mainContext
|
|
||||||
);
|
|
||||||
}
|
|
||||||
129
lib/Screens/Devices/device_element.dart
Normal file
129
lib/Screens/Devices/device_element.dart
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
|
import 'package:manager_app/Screens/Devices/change_device_info_modal.dart';
|
||||||
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DeviceElement extends StatefulWidget {
|
||||||
|
final DeviceDTO deviceDTO;
|
||||||
|
const DeviceElement({
|
||||||
|
Key key,
|
||||||
|
this.deviceDTO,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DeviceElementState createState() => _DeviceElementState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DeviceElementState extends State<DeviceElement> {
|
||||||
|
DeviceDTO deviceDTO;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
deviceDTO = widget.deviceDTO;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
|
child: Container(
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: deviceDTO.connected ? Colors.green : Colors.red,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kSecond,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 3,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
left: 10,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
AutoSizeText(
|
||||||
|
deviceDTO.name,
|
||||||
|
style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
AutoSizeText(
|
||||||
|
deviceDTO.configuration,
|
||||||
|
style: new TextStyle(fontSize: 25),
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 10,
|
||||||
|
right: 10,
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.edit),
|
||||||
|
onPressed: () {
|
||||||
|
showChangeInfo(
|
||||||
|
"Mettre à jour le device",
|
||||||
|
deviceDTO,
|
||||||
|
(DeviceDTO outputDevice) {
|
||||||
|
// For refresh
|
||||||
|
setState(() {
|
||||||
|
print("output");
|
||||||
|
print(outputDevice);
|
||||||
|
deviceDTO = outputDevice;
|
||||||
|
// Update device main info
|
||||||
|
updateMainInfos(deviceDTO, appContext);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
1,
|
||||||
|
context,
|
||||||
|
appContext
|
||||||
|
);
|
||||||
|
},
|
||||||
|
color: kPrimaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DeviceDTO> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async {
|
||||||
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
print(deviceToUpdate);
|
||||||
|
DeviceDTO device = await managerAppContext.clientAPI.deviceApi.deviceUpdateMainInfos(deviceToUpdate);
|
||||||
|
print(device);
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,6 @@
|
|||||||
import 'package:auto_size_text/auto_size_text.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/Screens/Devices/change_name_modal.dart';
|
import 'package:manager_app/Screens/Devices/device_element.dart';
|
||||||
import 'package:manager_app/Screens/Devices/select_config_modal.dart';
|
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:managerapi/api.dart';
|
import 'package:managerapi/api.dart';
|
||||||
@ -39,7 +37,7 @@ class _DevicesScreenState extends State<DevicesScreen> {
|
|||||||
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: getElement(snapshot.data[index], size, appContext)
|
child: DeviceElement(deviceDTO: snapshot.data[index]), //getElement()
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -56,7 +54,7 @@ class _DevicesScreenState extends State<DevicesScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getElement(DeviceDTO device, Size size, dynamic appContext) {
|
/*getElement(DeviceDTO device, Size size, dynamic appContext) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
@ -121,18 +119,39 @@ class _DevicesScreenState extends State<DevicesScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Row(
|
child: device.configuration != null ?
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
AutoSizeText(
|
AutoSizeText(
|
||||||
"Configuration: ",
|
device.configuration,
|
||||||
style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
device.configurationId != null ?
|
|
||||||
AutoSizeText(
|
|
||||||
device.configurationId,
|
|
||||||
style: new TextStyle(fontSize: 25),
|
style: new TextStyle(fontSize: 25),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.edit),
|
||||||
|
onPressed: () {
|
||||||
|
showSelectConfigModal(
|
||||||
|
"Sélectionner une configuration",
|
||||||
|
(String configurationId) {
|
||||||
|
|
||||||
|
device.configurationId = configurationId;
|
||||||
|
// Update device main info
|
||||||
|
updateMainInfos(device, appContext);
|
||||||
|
|
||||||
|
// For refresh // TODO better refresh
|
||||||
|
/*setState(() {
|
||||||
|
});*/
|
||||||
|
},
|
||||||
|
1,
|
||||||
|
context,
|
||||||
|
appContext
|
||||||
|
);
|
||||||
|
},
|
||||||
|
color: kPrimaryColor,
|
||||||
|
)
|
||||||
|
],
|
||||||
) : InkWell(
|
) : InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showSelectConfigModal(
|
showSelectConfigModal(
|
||||||
@ -144,8 +163,8 @@ class _DevicesScreenState extends State<DevicesScreen> {
|
|||||||
updateMainInfos(device, appContext);
|
updateMainInfos(device, appContext);
|
||||||
|
|
||||||
// For refresh // TODO better refresh
|
// For refresh // TODO better refresh
|
||||||
setState(() {
|
/*setState(() {
|
||||||
});
|
});*/
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
context,
|
context,
|
||||||
@ -168,15 +187,13 @@ class _DevicesScreenState extends State<DevicesScreen> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async {
|
Future<void> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async {
|
||||||
|
|||||||
60
lib/Screens/Devices/dropDown_configuration.dart
Normal file
60
lib/Screens/Devices/dropDown_configuration.dart
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DropDownConfig extends StatefulWidget {
|
||||||
|
final List<ConfigurationDTO> configurations;
|
||||||
|
final String selectedConfigurationId;
|
||||||
|
final ValueChanged<ConfigurationDTO> onChange;
|
||||||
|
const DropDownConfig({
|
||||||
|
Key key,
|
||||||
|
this.configurations,
|
||||||
|
this.selectedConfigurationId,
|
||||||
|
this.onChange,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DropDownConfigState createState() => _DropDownConfigState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DropDownConfigState extends State<DropDownConfig> {
|
||||||
|
ConfigurationDTO configurationDTO;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
configurationDTO = widget.configurations.firstWhere((config) => config.id == widget.selectedConfigurationId);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return DropdownButton<ConfigurationDTO>(
|
||||||
|
value: configurationDTO,
|
||||||
|
icon: const Icon(Icons.arrow_downward),
|
||||||
|
iconSize: 24,
|
||||||
|
elevation: 16,
|
||||||
|
style: const TextStyle(color: kBlack),
|
||||||
|
underline: Container(
|
||||||
|
height: 2,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
),
|
||||||
|
onChanged: (ConfigurationDTO newValue) {
|
||||||
|
setState(() {
|
||||||
|
configurationDTO = newValue;
|
||||||
|
widget.onChange(configurationDTO);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: widget.configurations.map<DropdownMenuItem<ConfigurationDTO>>((ConfigurationDTO value) {
|
||||||
|
return DropdownMenuItem<ConfigurationDTO>(
|
||||||
|
value: value,
|
||||||
|
child: Text(value.label, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400)),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,91 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
|
||||||
import 'package:manager_app/constants.dart';
|
|
||||||
import 'package:managerapi/api.dart';
|
|
||||||
|
|
||||||
showSelectConfigModal (String text, Function onGetResult, int maxLines, BuildContext mainContext, dynamic appContext) {
|
|
||||||
Size size = MediaQuery.of(mainContext).size;
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
builder: (BuildContext context) => AlertDialog(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
|
||||||
),
|
|
||||||
title: Center(child: Text(text)),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: size.width * 0.2,
|
|
||||||
height: size.height * 0.3,
|
|
||||||
child: FutureBuilder(
|
|
||||||
future: getConfigurations(appContext),
|
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
return ListView(
|
|
||||||
scrollDirection: Axis.vertical,
|
|
||||||
children: getConfigurationsElement(snapshot.data, onGetResult, () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} 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')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 180,
|
|
||||||
height: 70,
|
|
||||||
child: RoundedButton(
|
|
||||||
text: "Annuler",
|
|
||||||
icon: Icons.undo,
|
|
||||||
color: kSecond,
|
|
||||||
press: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
), context: mainContext
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getConfigurationsElement(data, Function onGetResult, Function requestClose) {
|
|
||||||
List<Widget> widgets = new List<Widget>();
|
|
||||||
for(var configuration in data as List<ConfigurationDTO>) {
|
|
||||||
var widget = new InkWell(
|
|
||||||
onTap: () {
|
|
||||||
onGetResult(configuration.id);
|
|
||||||
requestClose();
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: Icon(Icons.account_tree_rounded),
|
|
||||||
title: Text(configuration.label)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
widgets.add(widget);
|
|
||||||
}
|
|
||||||
return widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@ -12,6 +12,7 @@ Name | Type | Description | Notes
|
|||||||
**name** | **String** | | [optional]
|
**name** | **String** | | [optional]
|
||||||
**ipAddress** | **String** | | [optional]
|
**ipAddress** | **String** | | [optional]
|
||||||
**configurationId** | **String** | | [optional]
|
**configurationId** | **String** | | [optional]
|
||||||
|
**configuration** | **String** | | [optional]
|
||||||
**connected** | **bool** | | [optional]
|
**connected** | **bool** | | [optional]
|
||||||
**dateCreation** | [**DateTime**](DateTime.md) | | [optional]
|
**dateCreation** | [**DateTime**](DateTime.md) | | [optional]
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ Name | Type | Description | Notes
|
|||||||
**name** | **String** | | [optional]
|
**name** | **String** | | [optional]
|
||||||
**ipAddress** | **String** | | [optional]
|
**ipAddress** | **String** | | [optional]
|
||||||
**configurationId** | **String** | | [optional]
|
**configurationId** | **String** | | [optional]
|
||||||
|
**configuration** | **String** | | [optional]
|
||||||
**connected** | **bool** | | [optional]
|
**connected** | **bool** | | [optional]
|
||||||
**dateCreation** | [**DateTime**](DateTime.md) | | [optional]
|
**dateCreation** | [**DateTime**](DateTime.md) | | [optional]
|
||||||
**connectionLevel** | **String** | | [optional]
|
**connectionLevel** | **String** | | [optional]
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class DeviceDetailDTO {
|
|||||||
this.name,
|
this.name,
|
||||||
this.ipAddress,
|
this.ipAddress,
|
||||||
this.configurationId,
|
this.configurationId,
|
||||||
|
this.configuration,
|
||||||
this.connected,
|
this.connected,
|
||||||
this.dateCreation,
|
this.dateCreation,
|
||||||
this.connectionLevel,
|
this.connectionLevel,
|
||||||
@ -32,6 +33,8 @@ class DeviceDetailDTO {
|
|||||||
|
|
||||||
String configurationId;
|
String configurationId;
|
||||||
|
|
||||||
|
String configuration;
|
||||||
|
|
||||||
bool connected;
|
bool connected;
|
||||||
|
|
||||||
DateTime dateCreation;
|
DateTime dateCreation;
|
||||||
@ -50,6 +53,7 @@ class DeviceDetailDTO {
|
|||||||
other.name == name &&
|
other.name == name &&
|
||||||
other.ipAddress == ipAddress &&
|
other.ipAddress == ipAddress &&
|
||||||
other.configurationId == configurationId &&
|
other.configurationId == configurationId &&
|
||||||
|
other.configuration == configuration &&
|
||||||
other.connected == connected &&
|
other.connected == connected &&
|
||||||
other.dateCreation == dateCreation &&
|
other.dateCreation == dateCreation &&
|
||||||
other.connectionLevel == connectionLevel &&
|
other.connectionLevel == connectionLevel &&
|
||||||
@ -63,6 +67,7 @@ class DeviceDetailDTO {
|
|||||||
(name == null ? 0 : name.hashCode) +
|
(name == null ? 0 : name.hashCode) +
|
||||||
(ipAddress == null ? 0 : ipAddress.hashCode) +
|
(ipAddress == null ? 0 : ipAddress.hashCode) +
|
||||||
(configurationId == null ? 0 : configurationId.hashCode) +
|
(configurationId == null ? 0 : configurationId.hashCode) +
|
||||||
|
(configuration == null ? 0 : configuration.hashCode) +
|
||||||
(connected == null ? 0 : connected.hashCode) +
|
(connected == null ? 0 : connected.hashCode) +
|
||||||
(dateCreation == null ? 0 : dateCreation.hashCode) +
|
(dateCreation == null ? 0 : dateCreation.hashCode) +
|
||||||
(connectionLevel == null ? 0 : connectionLevel.hashCode) +
|
(connectionLevel == null ? 0 : connectionLevel.hashCode) +
|
||||||
@ -71,7 +76,7 @@ class DeviceDetailDTO {
|
|||||||
(lastBatteryLevel == null ? 0 : lastBatteryLevel.hashCode);
|
(lastBatteryLevel == null ? 0 : lastBatteryLevel.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'DeviceDetailDTO[id=$id, name=$name, ipAddress=$ipAddress, configurationId=$configurationId, connected=$connected, dateCreation=$dateCreation, connectionLevel=$connectionLevel, lastConnectionLevel=$lastConnectionLevel, batteryLevel=$batteryLevel, lastBatteryLevel=$lastBatteryLevel]';
|
String toString() => 'DeviceDetailDTO[id=$id, name=$name, ipAddress=$ipAddress, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation, connectionLevel=$connectionLevel, lastConnectionLevel=$lastConnectionLevel, batteryLevel=$batteryLevel, lastBatteryLevel=$lastBatteryLevel]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -87,6 +92,9 @@ class DeviceDetailDTO {
|
|||||||
if (configurationId != null) {
|
if (configurationId != null) {
|
||||||
json[r'configurationId'] = configurationId;
|
json[r'configurationId'] = configurationId;
|
||||||
}
|
}
|
||||||
|
if (configuration != null) {
|
||||||
|
json[r'configuration'] = configuration;
|
||||||
|
}
|
||||||
if (connected != null) {
|
if (connected != null) {
|
||||||
json[r'connected'] = connected;
|
json[r'connected'] = connected;
|
||||||
}
|
}
|
||||||
@ -117,6 +125,7 @@ class DeviceDetailDTO {
|
|||||||
name: json[r'name'],
|
name: json[r'name'],
|
||||||
ipAddress: json[r'ipAddress'],
|
ipAddress: json[r'ipAddress'],
|
||||||
configurationId: json[r'configurationId'],
|
configurationId: json[r'configurationId'],
|
||||||
|
configuration: json[r'configuration'],
|
||||||
connected: json[r'connected'],
|
connected: json[r'connected'],
|
||||||
dateCreation: json[r'dateCreation'] == null
|
dateCreation: json[r'dateCreation'] == null
|
||||||
? null
|
? null
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class DeviceDTO {
|
|||||||
this.name,
|
this.name,
|
||||||
this.ipAddress,
|
this.ipAddress,
|
||||||
this.configurationId,
|
this.configurationId,
|
||||||
|
this.configuration,
|
||||||
this.connected,
|
this.connected,
|
||||||
this.dateCreation,
|
this.dateCreation,
|
||||||
});
|
});
|
||||||
@ -28,6 +29,8 @@ class DeviceDTO {
|
|||||||
|
|
||||||
String configurationId;
|
String configurationId;
|
||||||
|
|
||||||
|
String configuration;
|
||||||
|
|
||||||
bool connected;
|
bool connected;
|
||||||
|
|
||||||
DateTime dateCreation;
|
DateTime dateCreation;
|
||||||
@ -38,6 +41,7 @@ class DeviceDTO {
|
|||||||
other.name == name &&
|
other.name == name &&
|
||||||
other.ipAddress == ipAddress &&
|
other.ipAddress == ipAddress &&
|
||||||
other.configurationId == configurationId &&
|
other.configurationId == configurationId &&
|
||||||
|
other.configuration == configuration &&
|
||||||
other.connected == connected &&
|
other.connected == connected &&
|
||||||
other.dateCreation == dateCreation;
|
other.dateCreation == dateCreation;
|
||||||
|
|
||||||
@ -47,11 +51,12 @@ class DeviceDTO {
|
|||||||
(name == null ? 0 : name.hashCode) +
|
(name == null ? 0 : name.hashCode) +
|
||||||
(ipAddress == null ? 0 : ipAddress.hashCode) +
|
(ipAddress == null ? 0 : ipAddress.hashCode) +
|
||||||
(configurationId == null ? 0 : configurationId.hashCode) +
|
(configurationId == null ? 0 : configurationId.hashCode) +
|
||||||
|
(configuration == null ? 0 : configuration.hashCode) +
|
||||||
(connected == null ? 0 : connected.hashCode) +
|
(connected == null ? 0 : connected.hashCode) +
|
||||||
(dateCreation == null ? 0 : dateCreation.hashCode);
|
(dateCreation == null ? 0 : dateCreation.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'DeviceDTO[id=$id, name=$name, ipAddress=$ipAddress, configurationId=$configurationId, connected=$connected, dateCreation=$dateCreation]';
|
String toString() => 'DeviceDTO[id=$id, name=$name, ipAddress=$ipAddress, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -67,6 +72,9 @@ class DeviceDTO {
|
|||||||
if (configurationId != null) {
|
if (configurationId != null) {
|
||||||
json[r'configurationId'] = configurationId;
|
json[r'configurationId'] = configurationId;
|
||||||
}
|
}
|
||||||
|
if (configuration != null) {
|
||||||
|
json[r'configuration'] = configuration;
|
||||||
|
}
|
||||||
if (connected != null) {
|
if (connected != null) {
|
||||||
json[r'connected'] = connected;
|
json[r'connected'] = connected;
|
||||||
}
|
}
|
||||||
@ -85,6 +93,7 @@ class DeviceDTO {
|
|||||||
name: json[r'name'],
|
name: json[r'name'],
|
||||||
ipAddress: json[r'ipAddress'],
|
ipAddress: json[r'ipAddress'],
|
||||||
configurationId: json[r'configurationId'],
|
configurationId: json[r'configurationId'],
|
||||||
|
configuration: json[r'configuration'],
|
||||||
connected: json[r'connected'],
|
connected: json[r'connected'],
|
||||||
dateCreation: json[r'dateCreation'] == null
|
dateCreation: json[r'dateCreation'] == null
|
||||||
? null
|
? null
|
||||||
|
|||||||
@ -225,6 +225,12 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
'404':
|
||||||
|
description: ''
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
'409':
|
'409':
|
||||||
description: ''
|
description: ''
|
||||||
content:
|
content:
|
||||||
@ -1307,6 +1313,9 @@ components:
|
|||||||
configurationId:
|
configurationId:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
|
configuration:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
connected:
|
connected:
|
||||||
type: boolean
|
type: boolean
|
||||||
dateCreation:
|
dateCreation:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user