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

change architectures to make it more logical + fix warnings #65

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 0 additions & 247 deletions lib/data/rest_request.dart

This file was deleted.

18 changes: 3 additions & 15 deletions lib/forms/add_bench_to_config_form.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:convert';
import 'package:flutter/material.dart';

import 'package:panduza_sandbox_flutter/data/const.dart';
import 'package:panduza_sandbox_flutter/data/rest_request.dart';
import 'package:panduza_sandbox_flutter/utils/const.dart';

// Form to add a new manual connection
// The user can add on his disk a new setup of connection mqtt
Expand Down Expand Up @@ -50,21 +48,11 @@ class AddBenchToConfigForm extends StatelessWidget {
// Connect to the broker with the info of username and password given
ElevatedButton(
onPressed: () {
// Send a request to api to created a new bench
postBench(token, ctrlName.text).then((value) {

// instead to keep a copy of the data we can make a
// new request to get every bench to the API

getBench(token).then((response) {
Map<String, dynamic> responseObject = json.decode(response.body);
Navigator.pop(context, responseObject["bench"]);
});
});
// TO DO when cloud will be more advanced
},
// Show error message if unsuccessful connection
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(blue)
backgroundColor: WidgetStateProperty.all<Color>(blue)
),
child: Text(
'SAVE',
Expand Down
10 changes: 4 additions & 6 deletions lib/forms/add_connection_form.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:panduza_sandbox_flutter/after_setup_pages/connections_page.dart';
import 'package:panduza_sandbox_flutter/pages/after_setup_pages/connections_page.dart';

import 'package:panduza_sandbox_flutter/data/const.dart';
import 'package:panduza_sandbox_flutter/data/utils.dart';
import 'package:panduza_sandbox_flutter/utils_widgets/utils_widgets.dart';
import 'package:panduza_sandbox_flutter/utils/const.dart';
import 'package:panduza_sandbox_flutter/utils/utils_functions.dart';
import 'package:panduza_sandbox_flutter/widgets/utils_widgets/utils_widgets.dart';

// Form to add a new manual connection
// The user can add on his disk a new setup of connection mqtt
Expand Down
18 changes: 2 additions & 16 deletions lib/forms/add_device_to_bench_form.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'dart:convert';
import 'package:flutter/material.dart';

import 'package:panduza_sandbox_flutter/data/const.dart';
import 'package:panduza_sandbox_flutter/data/rest_request.dart';
import 'package:panduza_sandbox_flutter/data/utils.dart';
import 'package:panduza_sandbox_flutter/data/broker_connection_info.dart';
import 'package:panduza_sandbox_flutter/after_setup_pages/userspace_page.dart';
import 'package:panduza_sandbox_flutter/utils/const.dart';

// Form to add a new manual connection
// The user can add on his disk a new setup of connection mqtt
Expand Down Expand Up @@ -63,16 +58,7 @@ class AddDeviceToBenchForm extends StatelessWidget {
// Connect to the broker with the info of username and password given
ElevatedButton(
onPressed: () {
// Send a request to api to created a new device
postDevice(token, ctrlName.text, ctrlType.text).then((response) {

var responseObject = json.decode(response.body);

// then link this new device to the targeted bench
putDeviceInBench(token, benchId, responseObject["id"]).then((value) {
Navigator.pop(context);
});
});
// TO DO when cloud will be more advanced
},
// Show error message if unsuccessful connection
style: ButtonStyle(
Expand Down
10 changes: 5 additions & 5 deletions lib/forms/authentification_form.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';

import 'package:panduza_sandbox_flutter/data/const.dart';
import 'package:panduza_sandbox_flutter/data/utils.dart';
import 'package:panduza_sandbox_flutter/data/broker_connection_info.dart';
import 'package:panduza_sandbox_flutter/after_setup_pages/userspace_page.dart';
import 'package:panduza_sandbox_flutter/utils/const.dart';
import 'package:panduza_sandbox_flutter/utils/utils_functions.dart';
import 'package:panduza_sandbox_flutter/utils/utils_objects/broker_connection_info.dart';
import 'package:panduza_sandbox_flutter/pages/after_setup_pages/userspace_page.dart';

// Form to add a new manual connection
// The user can add on his disk a new setup of connection mqtt
Expand Down Expand Up @@ -69,7 +69,7 @@ class AuthentificationForm extends StatelessWidget {
context,
MaterialPageRoute(
builder: (context) => UserspacePage(
broker_connection_info: BrokerConnectionInfo(
brokerConnectionInfo: BrokerConnectionInfo(
ip,
int.parse(port),
client
Expand Down
Loading