Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UI to change connection port and protocol #27

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Raptors65
Copy link

No description provided.

Copy link
Contributor

@BalajiLeninrajan BalajiLeninrajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work so far! Left a couple of comments and there's places where I need clarification.

TextField(
controller: portController,
decoration: const InputDecoration(hintText: "Port"),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a SizedBox between the text fields and the button, give it a height and experiment with values until you find something that looks nice (I think 8 would be a good starting point in this case)

final comm =
MavlinkCommunication(MavlinkCommunicationType.tcp, '127.0.0.1', 14550);

final defaultCommunicationType = MavlinkCommunicationType.tcp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the idea of having the the default params be constants! This feels like a good interim solution while your task is in progress. Maybe break these out into a separate file, preferably yaml but a Dart file with constant variables also works (this will be on the same level as main.dart)

@@ -25,4 +32,11 @@ class HomePage extends StatelessWidget {
),
);
}

void updateCommunicationParams(MavlinkCommunicationType connectionType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a module instead?

import 'package:flutter/material.dart';
import 'package:imacs/modules/mavlink_communication.dart';

const Map<MavlinkCommunicationType, String> mavCommTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simplier way to do this is to use the .name attr of a MavlinkCommunicationType to get it's string representation:

final MavlinkCommunicationType _connectionType = MavlinkCommunicationType.tcp;
final String _connectionTypeStrRepr = _connectionType.name; // tcp

final MavlinkCommunicationType communicationType;
final String communicationAddress;
final int tcpPort;
final Function(MavlinkCommunicationType communicationType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get the purpose of passing in a function into this widget, can you ping me on Discord to explain why this isn't just built in to the class.


late MavlinkCommunicationType? selectedType = widget.communicationType;

var statusMsg = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always type your variables

String statusMsg = "";


@override
void dispose() {
addressController.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we only dispose on of the TextEditingControllers

controller: addressController,
decoration: const InputDecoration(hintText: "Address"),
),
TextField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this text field natural numbers only


void main() {
group('Change Port/Protocol Widget', () {
testWidgets(
Copy link
Contributor

@BalajiLeninrajan BalajiLeninrajan Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test which actually changes the params and checks (I know this functionality isn't done yet but it's good to have tests early on)

@BalajiLeninrajan
Copy link
Contributor

Are there any updates on this?

@Raptors65
Copy link
Author

Hi @BalajiLeninrajan, sorry, just saw your comment now. Yes, I believe I implemented all the requested changes! I pinged you on the Discord post. Happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants