Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into 20-local-discovery-wait-any-answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Darcraytore1 authored May 21, 2024
2 parents 8a7487c + 3afb424 commit 343aedb
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 315 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:

- run: flutter clean
- run: flutter pub get
- run: flutter pub run flutter_launcher_icons

# If build from tag will use the tag name like build name with these 2 steps

Expand Down
Binary file added assets/icon_app_android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 0 additions & 65 deletions assets/logo2.svg

This file was deleted.

Binary file added assets/logo_circle_black_blue_1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
223 changes: 0 additions & 223 deletions assets/proposition_29022024.svg

This file was deleted.

3 changes: 3 additions & 0 deletions lib/after_setup_pages/add_connection_with_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ class ManualConnectionPage extends StatelessWidget {

const ManualConnectionPage({
super.key,
required this.name,
required this.ip,
required this.port
});

final String name;
final String ip;
final String port;

Expand All @@ -28,6 +30,7 @@ class ManualConnectionPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AddConnectionForm(
name: name,
ip: ip,
port: port,
)
Expand Down
8 changes: 4 additions & 4 deletions lib/after_setup_pages/discovery_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class DiscoveryPage extends StatefulWidget {

class _DiscoveryPageState extends State<DiscoveryPage> {

List<(InternetAddress, int)> platformsIpsPorts = [];
List<(InternetAddress, int, String)> platformsIpsPorts = [];
bool isLoading = false;

// List of button of local platform detected
Widget localDiscoveryConnections(List<(InternetAddress, int)> platformsIpsPorts, bool isLoading) {
Widget localDiscoveryConnections(List<(InternetAddress, int, String)> platformsIpsPorts, bool isLoading) {

if (isLoading) {
return Center(
Expand All @@ -53,8 +53,7 @@ class _DiscoveryPageState extends State<DiscoveryPage> {
child: Column (
children: <Widget>[
AutoSizeText(
// '${platformsIpsPorts[index].$1.host}',
"local",
platformsIpsPorts[index].$3,
style: TextStyle(
color: blue
),
Expand All @@ -74,6 +73,7 @@ class _DiscoveryPageState extends State<DiscoveryPage> {
context,
MaterialPageRoute(
builder: (context) => ManualConnectionPage(
name: platformsIpsPorts[index].$3,
ip: platformsIpsPorts[index].$1.address,
port: "1883"
),
Expand Down
3 changes: 3 additions & 0 deletions lib/after_setup_pages/manual_connection_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import 'package:panduza_sandbox_flutter/utils_widgets/appBar.dart';
class ManualConnectionPage extends StatelessWidget {
const ManualConnectionPage({
super.key,
this.name = "",
this.ip = "",
this.port = "",
});

final String name;
final String ip;
final String port;

Expand All @@ -25,6 +27,7 @@ class ManualConnectionPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AddConnectionForm(
name: name,
ip: ip,
port: port
)
Expand Down
18 changes: 12 additions & 6 deletions lib/data/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ Future<bool> checkIfConnectionValid(BuildContext context, String name, String ho
broadcast with UTF-8 format and getting an answer for each platform
*/

Future<List<(InternetAddress, int)>> platformDiscovery() async {
Future<List<(InternetAddress, int, String)>> platformDiscovery() async {

List<(InternetAddress, int)> ipPort = [];
List<(InternetAddress, int, String)> ipPort = [];
String waitedAnswer = '{"name": "panduza_platform","version": 1.0}';

// Could have some problem with some android phone ?
List<NetworkInterface> listInterface = await NetworkInterface.list();
Expand All @@ -299,11 +300,16 @@ Future<List<(InternetAddress, int)>> platformDiscovery() async {
socket.listen((e) {
Datagram? datagram = socket.receive();
if (datagram != null) {
// String answer = String.fromCharCodes(datagram.data);
String answer = utf8.decode(datagram.data);

// Here send the port of platform and not broker, how to get the port of the broker ?
if (!ipPort.contains((datagram.address, datagram.port))) ipPort.add((datagram.address, datagram.port));

Map<String, dynamic> answerMap = jsonDecode(answer);
String? platformName = answerMap["name"];

// if platform name is not given in the answer payload do not add this platform
if (platformName != null) {
// Get addr, port and platform name
if (!ipPort.contains((datagram.address, datagram.port))) ipPort.add((datagram.address, datagram.port, platformName));
}
}
});

Expand Down
6 changes: 5 additions & 1 deletion lib/forms/add_connection_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class AddConnectionForm extends StatelessWidget {

const AddConnectionForm({
super.key,
required this.name,
required this.ip,
required this.port,
});

final String name;
final String ip;
final String port;

@override
Widget build(BuildContext context) {

final ctrlName = TextEditingController();
final ctrlName = TextEditingController(
text: name
);
final ctrlHostIp = TextEditingController(
text: ip,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/utils_widgets/appBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PreferredSizeWidget? getAppBar(String title) {
// TO DO : Change to logo2
actions: <Widget>[
IconButton(
icon: Image.asset('assets/logo_1024.png'),
icon: Image.asset('assets/logo_circle_black_blue_1024.png'),
/*
icon: SvgPicture.asset(
'../../assets/icons/logo2.svg'
Expand Down Expand Up @@ -54,7 +54,7 @@ PreferredSizeWidget? getAppBarUserSpace(String title, BuildContext context) {
// TO DO : Change to logo2
actions: <Widget>[
IconButton(
icon: Image.asset('assets/logo_1024.png'),
icon: Image.asset('assets/logo_circle_black_blue_1024.png'),
/*
icon: SvgPicture.asset(
'../../assets/icons/logo2.svg'
Expand Down Expand Up @@ -103,7 +103,7 @@ PreferredSizeWidget? getConnectionsAppBar(String title, BuildContext context) {
),
),
IconButton(
icon: Image.asset('assets/logo_1024.png'),
icon: Image.asset('assets/logo_circle_black_blue_1024.png'),
/*
icon: SvgPicture.asset(
'../../assets/icons/logo2.svg'
Expand Down
22 changes: 11 additions & 11 deletions lib/utils_widgets/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ Widget getDrawer(BuildContext context) {
backgroundColor: white,
child: Column(
children: [
// Need to change logo to pass to the new final version
IconButton(
icon: Image.asset('assets/logo_1024.png'),
/*
icon: SvgPicture.asset(
'../../assets/icons/logo2.svg'
const SizedBox(
height: 10,
),
SizedBox(
height: 200,
width: 200,
child: IconButton(
icon: Image.asset('assets/logo_circle_black_blue_1024.png'),
onPressed: () {
return;
},
),
*/
iconSize: 10,
onPressed: () {
return;
},
),
const SizedBox(
height: 10,
Expand Down
7 changes: 5 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ flutter:


flutter_launcher_icons:
android: "launcher_icon"
android: true
ios: true
image_path: "assets/logo_1024.png"
adaptive_icon_background: "#39b0ff"
adaptive_icon_foreground: "assets/icon_app_android.png"
image_path: "assets/logo_circle_black_blue_1024.png"
min_sdk_android: 21 # android min sdk min:16, default 21


0 comments on commit 343aedb

Please sign in to comment.