feat: Introduce QR Scanning to add new node (#1007)

* feat: Introduce QR Scanning to add new node

* fix: Exception handing for scan qr and invalid qr value

* fix: Exception handing for scan qr and invalid qr value
This commit is contained in:
Adegoke David
2023-08-04 14:27:19 +03:00
committed by GitHub
parent 76322a1777
commit e9df03b49b
3 changed files with 64 additions and 2 deletions
@@ -66,6 +66,19 @@ class NodeCreateOrEditPage extends BasePage {
@override
String get title => editingNode != null ? S.current.edit_node : S.current.node_new;
@override
Widget trailing(BuildContext context) => IconButton(
onPressed: () async {
await nodeCreateOrEditViewModel.scanQRCodeForNewNode();
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
icon: Image.asset(
'assets/images/qr_code_icon.png',
),
);
final NodeCreateOrEditViewModel nodeCreateOrEditViewModel;
final Node? editingNode;
final bool? isSelected;
@@ -44,6 +44,17 @@ class NodeForm extends StatelessWidget {
}
});
}
reaction((_) => nodeViewModel.address, (String address) {
if (address != _addressController.text) {
_addressController.text = address;
}
});
reaction((_) => nodeViewModel.port, (String port) {
if (port != _portController.text) {
_portController.text = port;
}
});
_addressController.addListener(() => nodeViewModel.address = _addressController.text);
_portController.addListener(() => nodeViewModel.port = _portController.text);