showDeviceNameDialog method
Implementation
Future<void> showDeviceNameDialog(String deviceId) async {
TextEditingController _controller = TextEditingController();
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Choose a Device Name'),
content: TextField(
controller: _controller,
decoration: InputDecoration(hintText: "Device Name"),
),
actions: <Widget>[
TextButton(
child: Text('CANCEL'),
onPressed: () {
setState(() {
Navigator.pop(context);
});
},
),
TextButton(
child: Text('CONFIRM'),
onPressed: () async {
await LogbotCore.iots
.addIot(deviceId, IotRequestBody(name: _controller.text));
LogbotLogger().simple("Device added!");
widget.onSuccess(deviceId, currentStatus);
},
),
],
);
});
}