mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 00:51:19 +00:00
Add login page + connect to api, update api code + add debug page to test (wip)
This commit is contained in:
parent
acaaefd6a6
commit
10965da184
38
lib/Components/Buttons/rounded_button.dart
Normal file
38
lib/Components/Buttons/rounded_button.dart
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/constants.dart';
|
||||||
|
|
||||||
|
class RoundedButton extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final Function press;
|
||||||
|
final Color color, textColor;
|
||||||
|
final double fontSize;
|
||||||
|
|
||||||
|
const RoundedButton({
|
||||||
|
Key key,
|
||||||
|
this.text,
|
||||||
|
this.press,
|
||||||
|
this.color = kBodyTextColor, // TODO
|
||||||
|
this.textColor = Colors.white,
|
||||||
|
this.fontSize
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return FlatButton(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(35.0),
|
||||||
|
//side: BorderSide(color: kSubTitleColor)
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 25),
|
||||||
|
color: color,
|
||||||
|
onPressed: () => {
|
||||||
|
press()
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: new TextStyle(color: textColor, fontSize: fontSize, fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
lib/Components/rounded_input_field.dart
Normal file
46
lib/Components/rounded_input_field.dart
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/Components/text_field_container.dart';
|
||||||
|
import 'package:myhomie_app/constants.dart';
|
||||||
|
|
||||||
|
class RoundedInputField extends StatelessWidget {
|
||||||
|
final String hintText;
|
||||||
|
final IconData icon;
|
||||||
|
final ValueChanged<String> onChanged;
|
||||||
|
final String initialValue;
|
||||||
|
final Color color, textColor, iconColor;
|
||||||
|
final int maxLength;
|
||||||
|
const RoundedInputField({
|
||||||
|
Key key,
|
||||||
|
this.hintText,
|
||||||
|
this.initialValue,
|
||||||
|
this.icon,
|
||||||
|
this.color = kTitleTextColor, // TODO
|
||||||
|
this.textColor = kBodyTextColor, // TODO
|
||||||
|
this.iconColor = kTitleTextColor, // TODO
|
||||||
|
this.onChanged,
|
||||||
|
this.maxLength, // 50
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextFieldContainer(
|
||||||
|
color: color,
|
||||||
|
child: TextFormField (
|
||||||
|
onChanged: onChanged,
|
||||||
|
initialValue: initialValue,
|
||||||
|
cursorColor: textColor,
|
||||||
|
maxLength: maxLength,
|
||||||
|
style: TextStyle(fontSize: 20, color: textColor),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
icon: icon != null ? Icon(
|
||||||
|
icon,
|
||||||
|
color: iconColor,
|
||||||
|
): null,
|
||||||
|
hintText: hintText,
|
||||||
|
hintStyle: TextStyle(fontSize: 20.0, color: textColor),
|
||||||
|
border: InputBorder.none,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
lib/Components/rounded_password_field.dart
Normal file
34
lib/Components/rounded_password_field.dart
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/Components/text_field_container.dart';
|
||||||
|
import 'package:myhomie_app/constants.dart';
|
||||||
|
|
||||||
|
class RoundedPasswordField extends StatelessWidget {
|
||||||
|
final ValueChanged<String> onChanged;
|
||||||
|
const RoundedPasswordField({
|
||||||
|
Key key,
|
||||||
|
this.onChanged,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextFieldContainer(
|
||||||
|
child: TextField(
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: onChanged,
|
||||||
|
cursorColor: kBodyTextColor, // TODO
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Password",
|
||||||
|
icon: Icon(
|
||||||
|
Icons.lock,
|
||||||
|
color: kBodyTextColor, // TODO
|
||||||
|
),
|
||||||
|
suffixIcon: Icon(
|
||||||
|
Icons.visibility,
|
||||||
|
color: kBodyTextColor, // TODO
|
||||||
|
),
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
lib/Components/text_field_container.dart
Normal file
27
lib/Components/text_field_container.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/constants.dart';
|
||||||
|
|
||||||
|
class TextFieldContainer extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final Color color;
|
||||||
|
const TextFieldContainer({
|
||||||
|
Key key,
|
||||||
|
this.child,
|
||||||
|
this.color = kBackgroundColor, // TODO
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 10),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
|
||||||
|
width: size.width * 0.8,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color,
|
||||||
|
borderRadius: BorderRadius.circular(29),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
107
lib/Helpers/DatabaseHelper.dart
Normal file
107
lib/Helpers/DatabaseHelper.dart
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:myhomie_app/Models/homieContext.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
class DatabaseHelper {
|
||||||
|
static final _databaseName = "homie_database.db";
|
||||||
|
static final _databaseVersion = 1;
|
||||||
|
|
||||||
|
static final table = 'homieAppContext';
|
||||||
|
|
||||||
|
static final columnId = 'id';
|
||||||
|
static final columnUserId = 'deviceId';
|
||||||
|
static final columnHomeId = 'homeId';
|
||||||
|
static final columnToken = 'token';
|
||||||
|
static final columnHost = 'host';
|
||||||
|
static final columnLanguage = 'language';
|
||||||
|
|
||||||
|
DatabaseHelper._privateConstructor();
|
||||||
|
static final DatabaseHelper instance = DatabaseHelper._privateConstructor();
|
||||||
|
|
||||||
|
static Database _database;
|
||||||
|
Future<Database> get database async {
|
||||||
|
if (_database != null) return _database;
|
||||||
|
_database = await _initDatabase();
|
||||||
|
return _database;
|
||||||
|
}
|
||||||
|
|
||||||
|
_initDatabase() async {
|
||||||
|
String path = join(await getDatabasesPath(), _databaseName);
|
||||||
|
return await openDatabase(path,
|
||||||
|
version: _databaseVersion, onCreate: _onCreate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SQL code to create the database table
|
||||||
|
Future _onCreate(Database db, int version) async {
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE $table (
|
||||||
|
$columnId TEXT NOT NULL PRIMARY KEY,
|
||||||
|
$columnUserId TEXT NOT NULL,
|
||||||
|
$columnToken TEXT NOT NULL,
|
||||||
|
$columnHomeId TEXT NOT NULL,
|
||||||
|
$columnHost TEXT NOT NULL,
|
||||||
|
$columnLanguage TEXT NOT NULL
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> insert(HomieAppContext tabletAppContext) async {
|
||||||
|
Database db = await instance.database;
|
||||||
|
|
||||||
|
var res = await db.insert(table, tabletAppContext.toMap());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> update(HomieAppContext tabletAppContext) async {
|
||||||
|
// Get a reference to the database.
|
||||||
|
final db = await instance.database;
|
||||||
|
|
||||||
|
await db.update(
|
||||||
|
'tabletAppContext',
|
||||||
|
tabletAppContext.toMap(),
|
||||||
|
where: "id = ?",
|
||||||
|
whereArgs: [tabletAppContext.id],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> queryAllRows() async {
|
||||||
|
Database db = await instance.database;
|
||||||
|
var res = await db.query(table, orderBy: "$columnId DESC");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> delete(String email) async {
|
||||||
|
Database db = await instance.database;
|
||||||
|
return await db.delete(table, where: '$columnId = ?', whereArgs: [email]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> clearTable() async {
|
||||||
|
Database db = await instance.database;
|
||||||
|
return await db.rawQuery("DELETE FROM $table");
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<HomieAppContext> getData() async {
|
||||||
|
HomieAppContext homieAppContext;
|
||||||
|
|
||||||
|
await DatabaseHelper.instance.queryAllRows().then((value) {
|
||||||
|
value.forEach((element) {
|
||||||
|
print("DB - CONTEXT --- ");
|
||||||
|
|
||||||
|
homieAppContext = HomieAppContext(
|
||||||
|
id: element["id"],
|
||||||
|
userId: element["userId"],
|
||||||
|
token: element["token"],
|
||||||
|
host: element["host"],
|
||||||
|
homeId: element["homeId"],
|
||||||
|
language: element["language"]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}).catchError((error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
return homieAppContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
121
lib/Helpers/MQTTHelper.dart
Normal file
121
lib/Helpers/MQTTHelper.dart
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_client.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||||
|
import 'package:myhomie_app/Models/homieContext.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class MQTTHelper {
|
||||||
|
MQTTHelper._privateConstructor();
|
||||||
|
bool isInstantiated = false;
|
||||||
|
static final MQTTHelper instance = MQTTHelper._privateConstructor();
|
||||||
|
String lastMessage;
|
||||||
|
|
||||||
|
void onConnected(dynamic appContext) {
|
||||||
|
print('Connected !!!!!!!!!!!! ----------------------------------');
|
||||||
|
HomieAppContext homieAppContext = appContext.getContext();
|
||||||
|
|
||||||
|
homieAppContext.clientMQTT.subscribe("#", MqttQos.atLeastOnce);
|
||||||
|
|
||||||
|
print(homieAppContext.clientMQTT);
|
||||||
|
|
||||||
|
homieAppContext.clientMQTT.updates.listen((List<MqttReceivedMessage<MqttMessage>> c) async {
|
||||||
|
print("IN Received message");
|
||||||
|
final MqttPublishMessage message = c[0].payload;
|
||||||
|
final payload = MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||||
|
print('Received message:$payload from topic: ${c[0].topic}');
|
||||||
|
|
||||||
|
lastMessage = 'Received message:$payload from topic: ${c[0].topic}';
|
||||||
|
|
||||||
|
var topic = c[0].topic.split('/')[0];
|
||||||
|
|
||||||
|
switch(topic) {
|
||||||
|
case "config":
|
||||||
|
print('Get message in topic config = $payload');
|
||||||
|
break;
|
||||||
|
case "player":
|
||||||
|
print('Get message in topic player = $payload');
|
||||||
|
// refresh device info
|
||||||
|
try {
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
print('Error = $e');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// unconnected
|
||||||
|
void onDisconnected() {
|
||||||
|
print('Disconnected');
|
||||||
|
}
|
||||||
|
|
||||||
|
// subscribe to topic succeeded
|
||||||
|
void onSubscribed(String topic) {
|
||||||
|
print('Subscribed topic: $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
// subscribe to topic failed
|
||||||
|
void onSubscribeFail(String topic) {
|
||||||
|
print('Failed to subscribe $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsubscribe succeeded
|
||||||
|
void onUnsubscribed(String topic) {
|
||||||
|
print('Unsubscribed topic: $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
String getLastMessage() {
|
||||||
|
print("LAST MESSAAAGE");
|
||||||
|
print(lastMessage);
|
||||||
|
return lastMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<MqttServerClient> connect(dynamic appContext) async {
|
||||||
|
HomieAppContext homieAppContext = appContext.getContext();
|
||||||
|
|
||||||
|
if (homieAppContext == null) {
|
||||||
|
homieAppContext = new HomieAppContext(host: '192.168.31.140', userId: 'TODO');
|
||||||
|
} // TO DEBUG
|
||||||
|
|
||||||
|
if(homieAppContext.host != null) {
|
||||||
|
homieAppContext.clientMQTT = MqttServerClient.withPort(homieAppContext.host.replaceAll('http://', ''), 'homie_app_'+homieAppContext.userId, 1883);
|
||||||
|
isInstantiated = true;
|
||||||
|
|
||||||
|
homieAppContext.clientMQTT.logging(on: false);
|
||||||
|
homieAppContext.clientMQTT.keepAlivePeriod = 20;
|
||||||
|
homieAppContext.clientMQTT.onDisconnected = onDisconnected;
|
||||||
|
homieAppContext.clientMQTT.onConnected = () => onConnected(appContext);
|
||||||
|
homieAppContext.clientMQTT.onSubscribed = onSubscribed;
|
||||||
|
|
||||||
|
var message = {
|
||||||
|
"userId": homieAppContext.userId,
|
||||||
|
"connected": false
|
||||||
|
};
|
||||||
|
|
||||||
|
final connMessage = MqttConnectMessage().authenticateAs('user', 'user') // TODO ONLINE
|
||||||
|
.keepAliveFor(60)
|
||||||
|
.withWillTopic('player/status')
|
||||||
|
.withWillMessage(jsonEncode(message))
|
||||||
|
.withClientIdentifier('tablet_app_'+homieAppContext.userId)
|
||||||
|
.startClean()
|
||||||
|
.withWillQos(MqttQos.atLeastOnce);
|
||||||
|
|
||||||
|
homieAppContext.clientMQTT.connectionMessage = connMessage;
|
||||||
|
homieAppContext.clientMQTT.autoReconnect = true;
|
||||||
|
try {
|
||||||
|
await homieAppContext.clientMQTT.connect();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception: $e');
|
||||||
|
homieAppContext.clientMQTT.disconnect();
|
||||||
|
}
|
||||||
|
appContext.setContext(homieAppContext); // TODO CLEAN
|
||||||
|
|
||||||
|
return homieAppContext.clientMQTT;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
48
lib/Models/homieContext.dart
Normal file
48
lib/Models/homieContext.dart
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:myhomie_app/client.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class HomieAppContext with ChangeNotifier{
|
||||||
|
Client clientAPI;
|
||||||
|
MqttServerClient clientMQTT;
|
||||||
|
String id;
|
||||||
|
String host;
|
||||||
|
String language;
|
||||||
|
String userId;
|
||||||
|
String homeId;
|
||||||
|
String token;
|
||||||
|
|
||||||
|
|
||||||
|
HomieAppContext({this.id, this.userId, this.homeId, this.host, this.language, this.token});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'userId': userId,
|
||||||
|
'homeId': homeId,
|
||||||
|
'host': host,
|
||||||
|
'language': language,
|
||||||
|
'token': token,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory HomieAppContext.fromJson(Map<String, dynamic> json) {
|
||||||
|
return new HomieAppContext(
|
||||||
|
id: json['id'] as String,
|
||||||
|
userId: json['userId'] as String,
|
||||||
|
host: json['host'] as String,
|
||||||
|
homeId: json['homeId'] as String,
|
||||||
|
language: json['language'] as String,
|
||||||
|
token: json['token'] as String
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implement toString to make it easier to see information about
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'TabletAppContext{id: $id, userId: $userId, homeId: $homeId, language: $language, host: $host}';
|
||||||
|
}
|
||||||
|
}
|
||||||
47
lib/Screens/Debug/DebugPage.dart
Normal file
47
lib/Screens/Debug/DebugPage.dart
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/Helpers/MQTTHelper.dart';
|
||||||
|
import 'package:myhomie_app/app_context.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DebugPage extends StatefulWidget {
|
||||||
|
DebugPage({Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DebugPageState createState() => _DebugPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DebugPageState extends State<DebugPage> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
String lastMessage = "test";
|
||||||
|
|
||||||
|
//lastMessage = MQTTHelper.instance.getLastMessage() == null ? "rien" : MQTTHelper.instance.getLastMessage();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text("Debug TODO"),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
"Last Message",
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
MQTTHelper.instance.getLastMessage() == null ? "rien" : MQTTHelper.instance.getLastMessage(),
|
||||||
|
style: Theme.of(context).textTheme.headline4,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () => {},
|
||||||
|
tooltip: 'Increment',
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
155
lib/Screens/Home/HomePage.dart
Normal file
155
lib/Screens/Home/HomePage.dart
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_client.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||||
|
import 'package:mycoreapi/api.dart';
|
||||||
|
import 'package:myhomie_app/Helpers/MQTTHelper.dart';
|
||||||
|
import 'package:myhomie_app/Screens/Debug/DebugPage.dart';
|
||||||
|
import 'package:myhomie_app/app_context.dart';
|
||||||
|
import 'package:myhomie_app/client.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class HomePage extends StatefulWidget {
|
||||||
|
HomePage({Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_HomePageState createState() => _HomePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomePageState extends State<HomePage> {
|
||||||
|
int _counter = 0;
|
||||||
|
final MqttServerClient client = MqttServerClient.withPort('192.168.31.140', 'flutter_client', 1883); // TODO Add switch button or check online connexion if local broker available
|
||||||
|
//final MqttServerClient client = MqttServerClient.withPort('myhomie.be', 'flutter_client00', 1883); // TODO ONLINE
|
||||||
|
|
||||||
|
void _incrementCounter() {
|
||||||
|
setState(() {
|
||||||
|
_counter++;
|
||||||
|
|
||||||
|
print("client.connectionStatus !!! ==" + client.connectionStatus.toString());
|
||||||
|
if (client.connectionStatus.state == MqttConnectionState.connected) {
|
||||||
|
const pubTopic = 'topic/test';
|
||||||
|
final builder = MqttClientPayloadBuilder();
|
||||||
|
builder.addString('Hello MQTT');
|
||||||
|
client.publishMessage(pubTopic, MqttQos.atLeastOnce, builder.payload);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// connection succeeded
|
||||||
|
void onConnected() {
|
||||||
|
print('Connected !!!!!!!!!!!! ----------------------------------');
|
||||||
|
|
||||||
|
client.updates.listen((List<MqttReceivedMessage<MqttMessage>> c) {
|
||||||
|
final MqttPublishMessage message = c[0].payload;
|
||||||
|
final payload = MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||||
|
print('Received message:$payload from topic: ${c[0].topic}>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// unconnected
|
||||||
|
void onDisconnected() {
|
||||||
|
print('Disconnected');
|
||||||
|
}
|
||||||
|
|
||||||
|
// subscribe to topic succeeded
|
||||||
|
void onSubscribed(String topic) {
|
||||||
|
print('Subscribed topic: $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
// subscribe to topic failed
|
||||||
|
void onSubscribeFail(String topic) {
|
||||||
|
print('Failed to subscribe $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsubscribe succeeded
|
||||||
|
void onUnsubscribed(String topic) {
|
||||||
|
print('Unsubscribed topic: $topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<MqttServerClient> connect() async {
|
||||||
|
client.logging(on: false);
|
||||||
|
client.keepAlivePeriod = 20;
|
||||||
|
client.onDisconnected = onDisconnected;
|
||||||
|
client.onConnected = onConnected;
|
||||||
|
client.onSubscribed = onSubscribed;
|
||||||
|
|
||||||
|
/// Security context
|
||||||
|
/*SecurityContext context = new SecurityContext()
|
||||||
|
..useCertificateChain('path/to/my_cert.pem')
|
||||||
|
..usePrivateKey('path/to/my_key.pem', password: 'key_password')
|
||||||
|
..setClientAuthorities('path/to/client.crt', password: 'password');*/
|
||||||
|
//client.setProtocolV31();
|
||||||
|
//client.secure = true;
|
||||||
|
//client.securityContext = context;
|
||||||
|
|
||||||
|
final connMessage = MqttConnectMessage()
|
||||||
|
.authenticateAs('thomas', 'MyCore,1') // TODO ONLINE
|
||||||
|
/*.keepAliveFor(60)
|
||||||
|
.withWillTopic('willtopic')
|
||||||
|
.withWillMessage('Will message')*/
|
||||||
|
.withClientIdentifier("TESSST")
|
||||||
|
.startClean();
|
||||||
|
//.withWillQos(MqttQos.atLeastOnce);
|
||||||
|
//client.secure = true;
|
||||||
|
client.connectionMessage = connMessage;
|
||||||
|
client.autoReconnect = true;
|
||||||
|
try {
|
||||||
|
await client.connect();
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception: $e');
|
||||||
|
client.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
client.subscribe("#", MqttQos.atLeastOnce);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
|
||||||
|
if (!MQTTHelper.instance.isInstantiated)
|
||||||
|
{
|
||||||
|
print("MQTT NOT INSTANTIATED");
|
||||||
|
MQTTHelper.instance.connect(appContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text("HomePage TODO"),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
'You have pushed the button this many times:',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'$_counter',
|
||||||
|
style: Theme.of(context).textTheme.headline4,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () => {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return DebugPage();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
tooltip: 'Increment',
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
lib/Screens/Login/components/background.dart
Normal file
40
lib/Screens/Login/components/background.dart
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Background extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
const Background({
|
||||||
|
Key key,
|
||||||
|
@required this.child,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: size.height,
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
/*Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
child: Image.asset(
|
||||||
|
"assets/images/main_top.png",
|
||||||
|
width: size.width * 0.35,
|
||||||
|
),
|
||||||
|
),*/
|
||||||
|
/*Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Image.asset(
|
||||||
|
"assets/images/login_bottom.png",
|
||||||
|
width: size.width * 0.4,
|
||||||
|
),
|
||||||
|
),*/
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
188
lib/Screens/Login/components/body.dart
Normal file
188
lib/Screens/Login/components/body.dart
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||||
|
import 'package:mycoreapi/api.dart';
|
||||||
|
import 'package:myhomie_app/Components/Buttons/rounded_button.dart';
|
||||||
|
import 'package:myhomie_app/Components/rounded_input_field.dart';
|
||||||
|
import 'package:myhomie_app/Components/rounded_password_field.dart';
|
||||||
|
import 'package:myhomie_app/Models/homieContext.dart';
|
||||||
|
import 'package:myhomie_app/Screens/Home/HomePage.dart';
|
||||||
|
import 'package:myhomie_app/Screens/Login/components/background.dart';
|
||||||
|
import 'package:myhomie_app/app_context.dart';
|
||||||
|
import 'package:myhomie_app/client.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class Body extends StatefulWidget {
|
||||||
|
const Body({
|
||||||
|
Key key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Body> createState() => _BodyState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BodyState extends State<Body> {
|
||||||
|
final clientAPI = Client('http://192.168.31.140'); // TODO field
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Background(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
"LOGIN",
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
SizedBox(height: size.height * 0.03),
|
||||||
|
/*SvgPicture.asset(
|
||||||
|
"assets/icons/login.svg",
|
||||||
|
height: size.height * 0.35,
|
||||||
|
),*/
|
||||||
|
SizedBox(height: size.height * 0.03),
|
||||||
|
RoundedInputField(
|
||||||
|
hintText: "Your Email",
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
|
RoundedPasswordField(
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
|
RoundedButton(
|
||||||
|
text: "LOGIN",
|
||||||
|
press: () async {
|
||||||
|
// TODO check login etc
|
||||||
|
var connected = await authenticateTRY();
|
||||||
|
if (connected) {
|
||||||
|
HomieAppContext homieAppContext = new HomieAppContext();
|
||||||
|
homieAppContext.host = "http://192.168.31.140";// TODO
|
||||||
|
homieAppContext.clientMQTT = new MqttServerClient(homieAppContext.host.replaceAll('http://', ''),'tablet_app_'+'TODODODO');
|
||||||
|
// homieAppContext.clientAPI = client; // TODO
|
||||||
|
homieAppContext.userId = "TODO"; // TODO
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
appContext.setContext(homieAppContext);
|
||||||
|
});
|
||||||
|
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return HomePage();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(Route<dynamic> route) => false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: size.height * 0.03),
|
||||||
|
// TODO
|
||||||
|
/*AlreadyHaveAnAccountCheck(
|
||||||
|
press: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
//return SignUpScreen();
|
||||||
|
// TODODODO
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),*/
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> authenticateTRY() async {
|
||||||
|
print("try auth.. ");
|
||||||
|
|
||||||
|
// if () {} // Add if token exist and not null + not expired
|
||||||
|
var isConnected = false;
|
||||||
|
try {
|
||||||
|
//LoginDTO loginDTO = new LoginDTO(email: "test@email.be", password: "kljqsdkljqsd");
|
||||||
|
LoginDTO loginDTO = new LoginDTO(email: "", password: "");
|
||||||
|
TokenDTO token = await clientAPI.authenticationApi.authenticationAuthenticateWithJson(loginDTO);
|
||||||
|
print("Token ??");
|
||||||
|
print(token);
|
||||||
|
print(token.accessToken);
|
||||||
|
setAccessToken(token.accessToken);
|
||||||
|
isConnected = true; // TODO update context + db
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
print("error auth");
|
||||||
|
}
|
||||||
|
|
||||||
|
return isConnected;
|
||||||
|
|
||||||
|
/*if (!isError) {
|
||||||
|
UserInfoDetailDTO user = await clientAPI.userApi.userGet("6182c472e20a6dbcfe8fe82c");
|
||||||
|
print("user values ??");
|
||||||
|
print(user.email);
|
||||||
|
print(user.id);
|
||||||
|
|
||||||
|
List<HomeDTO> homes = await clientAPI.homeApi.homeGetAll(user.id);
|
||||||
|
print("number of homes " + homes.length.toString());
|
||||||
|
homes.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
HomeDTO home = homes[0]; // TODO
|
||||||
|
|
||||||
|
List<RoomSummaryDTO> rooms = await clientAPI.roomApi.roomGetAll(home.id);
|
||||||
|
print("number of rooms " + rooms.length.toString());
|
||||||
|
rooms.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ProviderDTO> providers = await clientAPI.providerApi.providerGetAll(home.id);
|
||||||
|
print("number of providers " + providers.length.toString());
|
||||||
|
providers.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
List<DeviceSummaryDTO> devices = await clientAPI.deviceApi.deviceGetAll(home.id);
|
||||||
|
print("number of devices " + devices.length.toString());
|
||||||
|
/*devices.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});*/
|
||||||
|
|
||||||
|
List<AlarmModeDTO> alarms = await clientAPI.alarmApi.alarmGetAll(home.id);
|
||||||
|
print("number of alarms " + alarms.length.toString());
|
||||||
|
alarms.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*List<EventDetailDTO> lastEvents = await clientAPI.eventApi.eventGet(home.id);
|
||||||
|
print("number of events " + lastEvents.length.toString());
|
||||||
|
lastEvents.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});*/
|
||||||
|
|
||||||
|
List<AutomationDTO> automations = await clientAPI.automationApi.automationGetAll(home.id);
|
||||||
|
print("number of automations " + automations.length.toString());
|
||||||
|
automations.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
List<GroupSummaryDTO> groups = await clientAPI.groupApi.groupGetAll(home.id);
|
||||||
|
print("number of groups " + groups.length.toString());
|
||||||
|
groups.forEach((element) {
|
||||||
|
print(element);
|
||||||
|
});
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(String accessToken) {
|
||||||
|
clientAPI.apiApi.authentications.forEach((key, auth) {
|
||||||
|
if (auth is OAuth) {
|
||||||
|
auth.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
11
lib/Screens/Login/login_screen.dart
Normal file
11
lib/Screens/Login/login_screen.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/Screens/Login/components/body.dart';
|
||||||
|
|
||||||
|
class LoginScreen extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Body(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
lib/app_context.dart
Normal file
18
lib/app_context.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:myhomie_app/client.dart';
|
||||||
|
|
||||||
|
import 'Models/homieContext.dart';
|
||||||
|
|
||||||
|
class AppContext with ChangeNotifier {
|
||||||
|
HomieAppContext _homieContext;
|
||||||
|
Client clientAPI;
|
||||||
|
|
||||||
|
AppContext(this._homieContext);
|
||||||
|
|
||||||
|
getContext() => _homieContext;
|
||||||
|
setContext(HomieAppContext appContext) async {
|
||||||
|
_homieContext = appContext;
|
||||||
|
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,6 +14,15 @@ class Client {
|
|||||||
UserApi _userApi;
|
UserApi _userApi;
|
||||||
UserApi get userApi => _userApi;
|
UserApi get userApi => _userApi;
|
||||||
|
|
||||||
|
HomeApi _homeApi;
|
||||||
|
HomeApi get homeApi => _homeApi;
|
||||||
|
|
||||||
|
AlarmApi _alarmApi;
|
||||||
|
AlarmApi get alarmApi => _alarmApi;
|
||||||
|
|
||||||
|
EventApi _eventApi;
|
||||||
|
EventApi get eventApi => _eventApi;
|
||||||
|
|
||||||
GroupApi _groupApi;
|
GroupApi _groupApi;
|
||||||
GroupApi get groupApi => _groupApi;
|
GroupApi get groupApi => _groupApi;
|
||||||
|
|
||||||
@ -29,13 +38,16 @@ class Client {
|
|||||||
RoomApi _roomApi;
|
RoomApi _roomApi;
|
||||||
RoomApi get roomApi => _roomApi;
|
RoomApi get roomApi => _roomApi;
|
||||||
|
|
||||||
Client() {
|
Client(String path) {
|
||||||
_apiClient = ApiClient(
|
_apiClient = ApiClient(
|
||||||
basePath: "http://192.168.31.140");
|
basePath: path);
|
||||||
//basePath: "http://localhost:25049");
|
//basePath: "http://localhost:25049");
|
||||||
_tokenApi = TokenApi(_apiClient);
|
_tokenApi = TokenApi(_apiClient);
|
||||||
_authenticationApi = AuthenticationApi(_apiClient);
|
_authenticationApi = AuthenticationApi(_apiClient);
|
||||||
_userApi = UserApi(_apiClient);
|
_userApi = UserApi(_apiClient);
|
||||||
|
_homeApi = HomeApi(_apiClient);
|
||||||
|
_alarmApi = AlarmApi(_apiClient);
|
||||||
|
_eventApi = EventApi(_apiClient);
|
||||||
_groupApi = GroupApi(_apiClient);
|
_groupApi = GroupApi(_apiClient);
|
||||||
_deviceApi = DeviceApi(_apiClient);
|
_deviceApi = DeviceApi(_apiClient);
|
||||||
_automationApi = AutomationApi(_apiClient);
|
_automationApi = AutomationApi(_apiClient);
|
||||||
|
|||||||
263
lib/main.dart
263
lib/main.dart
@ -1,19 +1,36 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mqtt_client/mqtt_client.dart';
|
|
||||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
|
||||||
import 'package:mycoreapi/api.dart';
|
|
||||||
import 'package:myhomie_app/client.dart';
|
import 'package:myhomie_app/client.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'Helpers/DatabaseHelper.dart';
|
||||||
|
import 'Models/homieContext.dart';
|
||||||
|
import 'Screens/Home/HomePage.dart';
|
||||||
|
import 'Screens/Login/login_screen.dart';
|
||||||
|
import 'app_context.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
|
|
||||||
void main() {
|
void main() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
String initialRoute;
|
String initialRoute;
|
||||||
|
HomieAppContext localContext = new HomieAppContext();
|
||||||
|
bool isLogged = false;
|
||||||
|
|
||||||
initialRoute = '/home';
|
localContext = await DatabaseHelper.instance.getData();
|
||||||
|
|
||||||
|
if(localContext != null) {
|
||||||
|
print("we've got an local db !");
|
||||||
|
localContext.clientAPI = new Client(localContext.host); // TODO "http://192.168.31.140"
|
||||||
|
isLogged = localContext.token != null; // TODO refresh token..
|
||||||
|
print(localContext);
|
||||||
|
} else {
|
||||||
|
print("NO LOCAL DB !");
|
||||||
|
}
|
||||||
|
|
||||||
|
initialRoute = isLogged ? '/home' : '/login';
|
||||||
|
|
||||||
final MyApp myApp = MyApp(
|
final MyApp myApp = MyApp(
|
||||||
initialRoute: initialRoute,
|
initialRoute: initialRoute,
|
||||||
//context: localContext,
|
homieAppContext: localContext,
|
||||||
);
|
);
|
||||||
|
|
||||||
runApp(myApp);
|
runApp(myApp);
|
||||||
@ -21,225 +38,39 @@ void main() {
|
|||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatefulWidget {
|
||||||
final String initialRoute;
|
final String initialRoute;
|
||||||
//final Context context;
|
final HomieAppContext homieAppContext;
|
||||||
MyApp({this.initialRoute});
|
MyApp({this.initialRoute, this.homieAppContext});
|
||||||
|
|
||||||
// This widget is the root of your application.
|
|
||||||
@override
|
@override
|
||||||
_MyAppState createState() => _MyAppState();
|
_MyAppState createState() => _MyAppState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
|
//HomieAppContext homieAppContext;
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
title: 'MyHomie App Demo',
|
|
||||||
initialRoute: widget.initialRoute,
|
|
||||||
/*supportedLocales: [
|
|
||||||
const Locale('en', 'US'),
|
|
||||||
//const Locale('fr', 'FR'),
|
|
||||||
],*/
|
|
||||||
theme: ThemeData(
|
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
scaffoldBackgroundColor: kBackgroundColor,
|
|
||||||
//fontFamily: "Vollkorn",
|
|
||||||
textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)),
|
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
||||||
),
|
|
||||||
routes: {
|
|
||||||
'/home': (context) => MyHomePage(title: 'MyHomie App Demo Home Page')
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
MyHomePage({Key key, this.title}) : super(key: key);
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _counter = 0;
|
|
||||||
//final MqttServerClient client = MqttServerClient.withPort('192.168.31.140', 'flutter_client', 1883); // TODO Add switch button or check online connexion if local broker available
|
|
||||||
//final MqttServerClient client = MqttServerClient.withPort('myhomie.be', 'flutter_client00', 1883); // TODO ONLINE
|
|
||||||
final clientAPI = Client();
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
|
|
||||||
/*print("client.connectionStatus !!! ==" + client.connectionStatus.toString());
|
|
||||||
if (client.connectionStatus.state == MqttConnectionState.connected) {
|
|
||||||
const pubTopic = 'topic/test';
|
|
||||||
final builder = MqttClientPayloadBuilder();
|
|
||||||
builder.addString('Hello MQTT');
|
|
||||||
client.publishMessage(pubTopic, MqttQos.atLeastOnce, builder.payload);
|
|
||||||
}*/
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void authenticateTRY() async {
|
|
||||||
print("try auth.. ");
|
|
||||||
var isError = true;
|
|
||||||
try {
|
|
||||||
LoginDTO loginDTO = new LoginDTO(email: "test@email.be", password: "kljqsdkljqsd");
|
|
||||||
TokenDTO token = await clientAPI.authenticationApi.authenticationAuthenticateWithJson(loginDTO);
|
|
||||||
print("Token ??");
|
|
||||||
print(token.accessToken);
|
|
||||||
setAccessToken(token.accessToken);
|
|
||||||
isError = false;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
print("error auth");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isError) {
|
|
||||||
UserInfoDetailDTO user = await clientAPI.userApi.userGet("604a33639b4a377a413045b9");
|
|
||||||
print("user values ??");
|
|
||||||
print(user.email);
|
|
||||||
print(user.id);
|
|
||||||
|
|
||||||
List<RoomSummaryDTO> rooms = await clientAPI.roomApi.roomGetAll(user.id);
|
|
||||||
print("number of rooms " + rooms.length.toString());
|
|
||||||
rooms.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});
|
|
||||||
|
|
||||||
List<ProviderDTO> providers = await clientAPI.providerApi.providerGetAll(user.id);
|
|
||||||
print("number of providers " + providers.length.toString());
|
|
||||||
providers.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});
|
|
||||||
|
|
||||||
List<DeviceSummaryDTO> devices = await clientAPI.deviceApi.deviceGetAll(user.id);
|
|
||||||
print("number of devices " + devices.length.toString());
|
|
||||||
/*devices.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
List<AutomationDTO> automations = await clientAPI.automationApi.automationGetAll(user.id);
|
|
||||||
print("number of automations " + automations.length.toString());
|
|
||||||
automations.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});
|
|
||||||
|
|
||||||
List<GroupSummaryDTO> groups = await clientAPI.groupApi.groupGetAll(user.id);
|
|
||||||
print("number of groups " + groups.length.toString());
|
|
||||||
groups.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// connection succeeded
|
|
||||||
void onConnected() {
|
|
||||||
print('Connected !!!!!!!!!!!! ----------------------------------');
|
|
||||||
|
|
||||||
/*client.updates.listen((List<MqttReceivedMessage<MqttMessage>> c) {
|
|
||||||
final MqttPublishMessage message = c[0].payload;
|
|
||||||
final payload = MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
|
||||||
print('Received message:$payload from topic: ${c[0].topic}>');
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAccessToken(String accessToken) {
|
|
||||||
clientAPI.apiApi.authentications.forEach((key, auth) {
|
|
||||||
if (auth is OAuth) {
|
|
||||||
auth.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// unconnected
|
|
||||||
void onDisconnected() {
|
|
||||||
print('Disconnected');
|
|
||||||
}
|
|
||||||
|
|
||||||
// subscribe to topic succeeded
|
|
||||||
void onSubscribed(String topic) {
|
|
||||||
print('Subscribed topic: $topic');
|
|
||||||
}
|
|
||||||
|
|
||||||
// subscribe to topic failed
|
|
||||||
void onSubscribeFail(String topic) {
|
|
||||||
print('Failed to subscribe $topic');
|
|
||||||
}
|
|
||||||
|
|
||||||
// unsubscribe succeeded
|
|
||||||
void onUnsubscribed(String topic) {
|
|
||||||
print('Unsubscribed topic: $topic');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<MqttServerClient> connect() async {
|
|
||||||
/*client.logging(on: false);
|
|
||||||
client.keepAlivePeriod = 20;
|
|
||||||
client.onDisconnected = onDisconnected;
|
|
||||||
client.onConnected = onConnected;
|
|
||||||
client.onSubscribed = onSubscribed;*/
|
|
||||||
|
|
||||||
/// Security context
|
|
||||||
/*SecurityContext context = new SecurityContext()
|
|
||||||
..useCertificateChain('path/to/my_cert.pem')
|
|
||||||
..usePrivateKey('path/to/my_key.pem', password: 'key_password')
|
|
||||||
..setClientAuthorities('path/to/client.crt', password: 'password');*/
|
|
||||||
//client.setProtocolV31();
|
|
||||||
//client.secure = true;
|
|
||||||
//client.securityContext = context;
|
|
||||||
|
|
||||||
final connMessage = MqttConnectMessage()
|
|
||||||
.authenticateAs('thomas', 'MyCore,1') // TODO ONLINE
|
|
||||||
/*.keepAliveFor(60)
|
|
||||||
.withWillTopic('willtopic')
|
|
||||||
.withWillMessage('Will message')*/
|
|
||||||
.withClientIdentifier("TESSST")
|
|
||||||
.startClean();
|
|
||||||
//.withWillQos(MqttQos.atLeastOnce);
|
|
||||||
//client.secure = true;
|
|
||||||
/*client.connectionMessage = connMessage;
|
|
||||||
client.autoReconnect = true;
|
|
||||||
try {
|
|
||||||
await client.connect();
|
|
||||||
} catch (e) {
|
|
||||||
print('Exception: $e');
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
client.subscribe("#", MqttQos.atLeastOnce);
|
|
||||||
*/
|
|
||||||
//return client;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
connect();
|
return ChangeNotifierProvider<AppContext>(
|
||||||
return Scaffold(
|
create: (_) => AppContext(widget.homieAppContext),
|
||||||
appBar: AppBar(
|
child: MaterialApp(
|
||||||
title: Text(widget.title),
|
debugShowCheckedModeBanner: false,
|
||||||
),
|
title: 'MyHomie App Demo',
|
||||||
body: Center(
|
initialRoute: widget.initialRoute,
|
||||||
child: Column(
|
/*supportedLocales: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
const Locale('en', 'US'),
|
||||||
children: <Widget>[
|
//const Locale('fr', 'FR'),
|
||||||
Text(
|
],*/
|
||||||
'You have pushed the button this many times:',
|
theme: ThemeData(
|
||||||
),
|
primarySwatch: Colors.blue,
|
||||||
Text(
|
scaffoldBackgroundColor: kBackgroundColor,
|
||||||
'$_counter',
|
//fontFamily: "Vollkorn",
|
||||||
style: Theme.of(context).textTheme.headline4,
|
textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)),
|
||||||
),
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
],
|
),
|
||||||
),
|
routes: {
|
||||||
),
|
'/home': (context) => HomePage(),
|
||||||
floatingActionButton: FloatingActionButton(
|
'/login': (context) => LoginScreen()
|
||||||
onPressed: authenticateTRY,
|
}
|
||||||
tooltip: 'Increment',
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import sqflite
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,7 @@ part 'model/room_create_or_update_detail_dto.dart';
|
|||||||
part 'model/room_detail_dto.dart';
|
part 'model/room_detail_dto.dart';
|
||||||
part 'model/room_summary_dto.dart';
|
part 'model/room_summary_dto.dart';
|
||||||
part 'model/screen_device.dart';
|
part 'model/screen_device.dart';
|
||||||
|
part 'model/screen_widget.dart';
|
||||||
part 'model/smart_garden_message.dart';
|
part 'model/smart_garden_message.dart';
|
||||||
part 'model/smart_printer_message.dart';
|
part 'model/smart_printer_message.dart';
|
||||||
part 'model/time_period_alarm.dart';
|
part 'model/time_period_alarm.dart';
|
||||||
|
|||||||
@ -181,7 +181,7 @@ class EventApi {
|
|||||||
/// * [OneOfEventType] eventType:
|
/// * [OneOfEventType] eventType:
|
||||||
///
|
///
|
||||||
/// * [OneOfDeviceType] deviceType:
|
/// * [OneOfDeviceType] deviceType:
|
||||||
Future<Response> eventGetWithHttpInfo(String homeId, { String deviceId, String roomId, int startIndex, int count, DateTime dateStart, DateTime dateEnd, OneOfEventType eventType, OneOfDeviceType deviceType }) async {
|
Future<Response> eventGetWithHttpInfo(String homeId, { String deviceId, String roomId, int startIndex, int count, DateTime dateStart, DateTime dateEnd, EventType eventType, DeviceType deviceType }) async {
|
||||||
// Verify required params are set.
|
// Verify required params are set.
|
||||||
if (homeId == null) {
|
if (homeId == null) {
|
||||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: homeId');
|
throw ApiException(HttpStatus.badRequest, 'Missing required param: homeId');
|
||||||
@ -271,7 +271,7 @@ class EventApi {
|
|||||||
/// * [OneOfEventType] eventType:
|
/// * [OneOfEventType] eventType:
|
||||||
///
|
///
|
||||||
/// * [OneOfDeviceType] deviceType:
|
/// * [OneOfDeviceType] deviceType:
|
||||||
Future<List<EventDetailDTO>> eventGet(String homeId, { String deviceId, String roomId, int startIndex, int count, DateTime dateStart, DateTime dateEnd, OneOfEventType eventType, OneOfDeviceType deviceType }) async {
|
Future<List<EventDetailDTO>> eventGet(String homeId, { String deviceId, String roomId, int startIndex, int count, DateTime dateStart, DateTime dateEnd, EventType eventType, DeviceType deviceType }) async {
|
||||||
final response = await eventGetWithHttpInfo(homeId, deviceId: deviceId, roomId: roomId, startIndex: startIndex, count: count, dateStart: dateStart, dateEnd: dateEnd, eventType: eventType, deviceType: deviceType );
|
final response = await eventGetWithHttpInfo(homeId, deviceId: deviceId, roomId: roomId, startIndex: startIndex, count: count, dateStart: dateStart, dateEnd: dateEnd, eventType: eventType, deviceType: deviceType );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||||
|
|||||||
@ -46,9 +46,9 @@ class AlarmMode {
|
|||||||
|
|
||||||
AlarmType type;
|
AlarmType type;
|
||||||
|
|
||||||
OneOfProgrammedMode programmedMode;
|
ProgrammedMode programmedMode;
|
||||||
|
|
||||||
OneOfGeolocalizedMode geolocalizedMode;
|
GeolocalizedMode geolocalizedMode;
|
||||||
|
|
||||||
List<Trigger> triggers;
|
List<Trigger> triggers;
|
||||||
|
|
||||||
@ -158,8 +158,8 @@ class AlarmMode {
|
|||||||
? null
|
? null
|
||||||
: DateTime.parse(json[r'updatedDate']),
|
: DateTime.parse(json[r'updatedDate']),
|
||||||
type: AlarmType.fromJson(json[r'type']),
|
type: AlarmType.fromJson(json[r'type']),
|
||||||
programmedMode: OneOfProgrammedMode.fromJson(json[r'programmedMode']),
|
programmedMode: ProgrammedMode.fromJson(json[r'programmedMode']),
|
||||||
geolocalizedMode: OneOfGeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
geolocalizedMode: GeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
||||||
triggers: Trigger.listFromJson(json[r'triggers']),
|
triggers: Trigger.listFromJson(json[r'triggers']),
|
||||||
actions: Action.listFromJson(json[r'actions']),
|
actions: Action.listFromJson(json[r'actions']),
|
||||||
devicesIds: json[r'devicesIds'] == null
|
devicesIds: json[r'devicesIds'] == null
|
||||||
|
|||||||
@ -49,9 +49,9 @@ class AlarmModeCreateOrUpdateDetailDTO {
|
|||||||
|
|
||||||
List<Action> actions;
|
List<Action> actions;
|
||||||
|
|
||||||
OneOfProgrammedMode programmedMode;
|
ProgrammedMode programmedMode;
|
||||||
|
|
||||||
OneOfGeolocalizedMode geolocalizedMode;
|
GeolocalizedMode geolocalizedMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is AlarmModeCreateOrUpdateDetailDTO &&
|
bool operator ==(Object other) => identical(this, other) || other is AlarmModeCreateOrUpdateDetailDTO &&
|
||||||
@ -152,8 +152,8 @@ class AlarmModeCreateOrUpdateDetailDTO {
|
|||||||
: DateTime.parse(json[r'updatedDate']),
|
: DateTime.parse(json[r'updatedDate']),
|
||||||
triggers: Trigger.listFromJson(json[r'triggers']),
|
triggers: Trigger.listFromJson(json[r'triggers']),
|
||||||
actions: Action.listFromJson(json[r'actions']),
|
actions: Action.listFromJson(json[r'actions']),
|
||||||
programmedMode: OneOfProgrammedMode.fromJson(json[r'programmedMode']),
|
programmedMode: ProgrammedMode.fromJson(json[r'programmedMode']),
|
||||||
geolocalizedMode: OneOfGeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
geolocalizedMode: GeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<AlarmModeCreateOrUpdateDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<AlarmModeCreateOrUpdateDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -22,9 +22,9 @@ class AlarmModeCreateOrUpdateDetailDTOAllOf {
|
|||||||
|
|
||||||
List<Action> actions;
|
List<Action> actions;
|
||||||
|
|
||||||
OneOfProgrammedMode programmedMode;
|
ProgrammedMode programmedMode;
|
||||||
|
|
||||||
OneOfGeolocalizedMode geolocalizedMode;
|
GeolocalizedMode geolocalizedMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is AlarmModeCreateOrUpdateDetailDTOAllOf &&
|
bool operator ==(Object other) => identical(this, other) || other is AlarmModeCreateOrUpdateDetailDTOAllOf &&
|
||||||
@ -67,8 +67,8 @@ class AlarmModeCreateOrUpdateDetailDTOAllOf {
|
|||||||
: AlarmModeCreateOrUpdateDetailDTOAllOf(
|
: AlarmModeCreateOrUpdateDetailDTOAllOf(
|
||||||
triggers: Trigger.listFromJson(json[r'triggers']),
|
triggers: Trigger.listFromJson(json[r'triggers']),
|
||||||
actions: Action.listFromJson(json[r'actions']),
|
actions: Action.listFromJson(json[r'actions']),
|
||||||
programmedMode: OneOfProgrammedMode.fromJson(json[r'programmedMode']),
|
programmedMode: ProgrammedMode.fromJson(json[r'programmedMode']),
|
||||||
geolocalizedMode: OneOfGeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
geolocalizedMode: GeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<AlarmModeCreateOrUpdateDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<AlarmModeCreateOrUpdateDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -49,9 +49,9 @@ class AlarmModeDetailDTO {
|
|||||||
|
|
||||||
List<DeviceDetailDTO> devices;
|
List<DeviceDetailDTO> devices;
|
||||||
|
|
||||||
OneOfProgrammedMode programmedMode;
|
ProgrammedMode programmedMode;
|
||||||
|
|
||||||
OneOfGeolocalizedMode geolocalizedMode;
|
GeolocalizedMode geolocalizedMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is AlarmModeDetailDTO &&
|
bool operator ==(Object other) => identical(this, other) || other is AlarmModeDetailDTO &&
|
||||||
@ -152,8 +152,8 @@ class AlarmModeDetailDTO {
|
|||||||
: DateTime.parse(json[r'updatedDate']),
|
: DateTime.parse(json[r'updatedDate']),
|
||||||
triggers: Trigger.listFromJson(json[r'triggers']),
|
triggers: Trigger.listFromJson(json[r'triggers']),
|
||||||
devices: DeviceDetailDTO.listFromJson(json[r'devices']),
|
devices: DeviceDetailDTO.listFromJson(json[r'devices']),
|
||||||
programmedMode: OneOfProgrammedMode.fromJson(json[r'programmedMode']),
|
programmedMode: ProgrammedMode.fromJson(json[r'programmedMode']),
|
||||||
geolocalizedMode: OneOfGeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
geolocalizedMode: GeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<AlarmModeDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<AlarmModeDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -22,9 +22,9 @@ class AlarmModeDetailDTOAllOf {
|
|||||||
|
|
||||||
List<DeviceDetailDTO> devices;
|
List<DeviceDetailDTO> devices;
|
||||||
|
|
||||||
OneOfProgrammedMode programmedMode;
|
ProgrammedMode programmedMode;
|
||||||
|
|
||||||
OneOfGeolocalizedMode geolocalizedMode;
|
GeolocalizedMode geolocalizedMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is AlarmModeDetailDTOAllOf &&
|
bool operator ==(Object other) => identical(this, other) || other is AlarmModeDetailDTOAllOf &&
|
||||||
@ -67,8 +67,8 @@ class AlarmModeDetailDTOAllOf {
|
|||||||
: AlarmModeDetailDTOAllOf(
|
: AlarmModeDetailDTOAllOf(
|
||||||
triggers: Trigger.listFromJson(json[r'triggers']),
|
triggers: Trigger.listFromJson(json[r'triggers']),
|
||||||
devices: DeviceDetailDTO.listFromJson(json[r'devices']),
|
devices: DeviceDetailDTO.listFromJson(json[r'devices']),
|
||||||
programmedMode: OneOfProgrammedMode.fromJson(json[r'programmedMode']),
|
programmedMode: ProgrammedMode.fromJson(json[r'programmedMode']),
|
||||||
geolocalizedMode: OneOfGeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
geolocalizedMode: GeolocalizedMode.fromJson(json[r'geolocalizedMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<AlarmModeDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<AlarmModeDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class Condition {
|
|||||||
|
|
||||||
String deviceId;
|
String deviceId;
|
||||||
|
|
||||||
OneOfAutomationState state;
|
AutomationState state;
|
||||||
|
|
||||||
String startTime;
|
String startTime;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class Condition {
|
|||||||
? null
|
? null
|
||||||
: Condition(
|
: Condition(
|
||||||
deviceId: json[r'deviceId'],
|
deviceId: json[r'deviceId'],
|
||||||
state: OneOfAutomationState.fromJson(json[r'state']),
|
state: AutomationState.fromJson(json[r'state']),
|
||||||
startTime: json[r'startTime'],
|
startTime: json[r'startTime'],
|
||||||
endTime: json[r'endTime'],
|
endTime: json[r'endTime'],
|
||||||
type: ConditionType.fromJson(json[r'type']),
|
type: ConditionType.fromJson(json[r'type']),
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class CreateOrUpdateHomeDTO {
|
|||||||
|
|
||||||
bool isDefault;
|
bool isDefault;
|
||||||
|
|
||||||
OneOfAlarmModeDTO currentAlarmMode;
|
AlarmModeDTO currentAlarmMode;
|
||||||
|
|
||||||
DateTime createdDate;
|
DateTime createdDate;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class CreateOrUpdateHomeDTO {
|
|||||||
name: json[r'name'],
|
name: json[r'name'],
|
||||||
isAlarm: json[r'isAlarm'],
|
isAlarm: json[r'isAlarm'],
|
||||||
isDefault: json[r'isDefault'],
|
isDefault: json[r'isDefault'],
|
||||||
currentAlarmMode: OneOfAlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
currentAlarmMode: AlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
||||||
createdDate: json[r'createdDate'] == null
|
createdDate: json[r'createdDate'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json[r'createdDate']),
|
: DateTime.parse(json[r'createdDate']),
|
||||||
|
|||||||
@ -32,11 +32,11 @@ class EventDetailDTO {
|
|||||||
|
|
||||||
String roomId;
|
String roomId;
|
||||||
|
|
||||||
OneOfDeviceState deviceState;
|
DeviceState deviceState;
|
||||||
|
|
||||||
OneOfAutomationTriggered automationTriggered;
|
AutomationTriggered automationTriggered;
|
||||||
|
|
||||||
OneOfAlarmTriggered alarmTriggered;
|
AlarmTriggered alarmTriggered;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is EventDetailDTO &&
|
bool operator ==(Object other) => identical(this, other) || other is EventDetailDTO &&
|
||||||
@ -104,9 +104,9 @@ class EventDetailDTO {
|
|||||||
: DateTime.parse(json[r'date']),
|
: DateTime.parse(json[r'date']),
|
||||||
type: EventType.fromJson(json[r'type']),
|
type: EventType.fromJson(json[r'type']),
|
||||||
roomId: json[r'roomId'],
|
roomId: json[r'roomId'],
|
||||||
deviceState: OneOfDeviceState.fromJson(json[r'deviceState']),
|
deviceState: DeviceState.fromJson(json[r'deviceState']),
|
||||||
automationTriggered: OneOfAutomationTriggered.fromJson(json[r'automationTriggered']),
|
automationTriggered: AutomationTriggered.fromJson(json[r'automationTriggered']),
|
||||||
alarmTriggered: OneOfAlarmTriggered.fromJson(json[r'alarmTriggered']),
|
alarmTriggered: AlarmTriggered.fromJson(json[r'alarmTriggered']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<EventDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<EventDetailDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -17,11 +17,11 @@ class EventDetailDTOAllOf {
|
|||||||
this.alarmTriggered,
|
this.alarmTriggered,
|
||||||
});
|
});
|
||||||
|
|
||||||
OneOfDeviceState deviceState;
|
DeviceState deviceState;
|
||||||
|
|
||||||
OneOfAutomationTriggered automationTriggered;
|
AutomationTriggered automationTriggered;
|
||||||
|
|
||||||
OneOfAlarmTriggered alarmTriggered;
|
AlarmTriggered alarmTriggered;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is EventDetailDTOAllOf &&
|
bool operator ==(Object other) => identical(this, other) || other is EventDetailDTOAllOf &&
|
||||||
@ -57,9 +57,9 @@ class EventDetailDTOAllOf {
|
|||||||
static EventDetailDTOAllOf fromJson(Map<String, dynamic> json) => json == null
|
static EventDetailDTOAllOf fromJson(Map<String, dynamic> json) => json == null
|
||||||
? null
|
? null
|
||||||
: EventDetailDTOAllOf(
|
: EventDetailDTOAllOf(
|
||||||
deviceState: OneOfDeviceState.fromJson(json[r'deviceState']),
|
deviceState: DeviceState.fromJson(json[r'deviceState']),
|
||||||
automationTriggered: OneOfAutomationTriggered.fromJson(json[r'automationTriggered']),
|
automationTriggered: AutomationTriggered.fromJson(json[r'automationTriggered']),
|
||||||
alarmTriggered: OneOfAlarmTriggered.fromJson(json[r'alarmTriggered']),
|
alarmTriggered: AlarmTriggered.fromJson(json[r'alarmTriggered']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<EventDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<EventDetailDTOAllOf> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -22,9 +22,9 @@ class GeolocalizedMode {
|
|||||||
|
|
||||||
String longitude;
|
String longitude;
|
||||||
|
|
||||||
OneOfAlarmMode homeMode;
|
AlarmMode homeMode;
|
||||||
|
|
||||||
OneOfAlarmMode absentMode;
|
AlarmMode absentMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is GeolocalizedMode &&
|
bool operator ==(Object other) => identical(this, other) || other is GeolocalizedMode &&
|
||||||
@ -67,8 +67,8 @@ class GeolocalizedMode {
|
|||||||
: GeolocalizedMode(
|
: GeolocalizedMode(
|
||||||
latitude: json[r'latitude'],
|
latitude: json[r'latitude'],
|
||||||
longitude: json[r'longitude'],
|
longitude: json[r'longitude'],
|
||||||
homeMode: OneOfAlarmMode.fromJson(json[r'homeMode']),
|
homeMode: AlarmMode.fromJson(json[r'homeMode']),
|
||||||
absentMode: OneOfAlarmMode.fromJson(json[r'absentMode']),
|
absentMode: AlarmMode.fromJson(json[r'absentMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<GeolocalizedMode> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<GeolocalizedMode> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class HomeDetailDTO {
|
|||||||
|
|
||||||
bool isDefault;
|
bool isDefault;
|
||||||
|
|
||||||
OneOfAlarmModeDTO currentAlarmMode;
|
AlarmModeDTO currentAlarmMode;
|
||||||
|
|
||||||
DateTime createdDate;
|
DateTime createdDate;
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class HomeDetailDTO {
|
|||||||
name: json[r'name'],
|
name: json[r'name'],
|
||||||
isAlarm: json[r'isAlarm'],
|
isAlarm: json[r'isAlarm'],
|
||||||
isDefault: json[r'isDefault'],
|
isDefault: json[r'isDefault'],
|
||||||
currentAlarmMode: OneOfAlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
currentAlarmMode: AlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
||||||
createdDate: json[r'createdDate'] == null
|
createdDate: json[r'createdDate'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json[r'createdDate']),
|
: DateTime.parse(json[r'createdDate']),
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class HomeDTO {
|
|||||||
|
|
||||||
bool isDefault;
|
bool isDefault;
|
||||||
|
|
||||||
OneOfAlarmModeDTO currentAlarmMode;
|
AlarmModeDTO currentAlarmMode;
|
||||||
|
|
||||||
DateTime createdDate;
|
DateTime createdDate;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class HomeDTO {
|
|||||||
name: json[r'name'],
|
name: json[r'name'],
|
||||||
isAlarm: json[r'isAlarm'],
|
isAlarm: json[r'isAlarm'],
|
||||||
isDefault: json[r'isDefault'],
|
isDefault: json[r'isDefault'],
|
||||||
currentAlarmMode: OneOfAlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
currentAlarmMode: AlarmModeDTO.fromJson(json[r'currentAlarmMode']),
|
||||||
createdDate: json[r'createdDate'] == null
|
createdDate: json[r'createdDate'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json[r'createdDate']),
|
: DateTime.parse(json[r'createdDate']),
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class OddNice {
|
|||||||
|
|
||||||
String homeTeam;
|
String homeTeam;
|
||||||
|
|
||||||
OneOfOddObject odds;
|
OddObject odds;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is OddNice &&
|
bool operator ==(Object other) => identical(this, other) || other is OddNice &&
|
||||||
@ -70,7 +70,7 @@ class OddNice {
|
|||||||
: (json[r'teams'] as List).cast<String>(),
|
: (json[r'teams'] as List).cast<String>(),
|
||||||
commenceTime: json[r'commence_time'],
|
commenceTime: json[r'commence_time'],
|
||||||
homeTeam: json[r'home_team'],
|
homeTeam: json[r'home_team'],
|
||||||
odds: OneOfOddObject.fromJson(json[r'odds']),
|
odds: OddObject.fromJson(json[r'odds']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<OddNice> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<OddNice> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class TimePeriodAlarm {
|
|||||||
|
|
||||||
String end;
|
String end;
|
||||||
|
|
||||||
OneOfAlarmMode alarmMode;
|
AlarmMode alarmMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is TimePeriodAlarm &&
|
bool operator ==(Object other) => identical(this, other) || other is TimePeriodAlarm &&
|
||||||
@ -59,7 +59,7 @@ class TimePeriodAlarm {
|
|||||||
: TimePeriodAlarm(
|
: TimePeriodAlarm(
|
||||||
start: json[r'start'],
|
start: json[r'start'],
|
||||||
end: json[r'end'],
|
end: json[r'end'],
|
||||||
alarmMode: OneOfAlarmMode.fromJson(json[r'alarmMode']),
|
alarmMode: AlarmMode.fromJson(json[r'alarmMode']),
|
||||||
);
|
);
|
||||||
|
|
||||||
static List<TimePeriodAlarm> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
static List<TimePeriodAlarm> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
||||||
|
|||||||
76
pubspec.lock
76
pubspec.lock
@ -7,7 +7,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.8.2"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -21,14 +21,14 @@ packages:
|
|||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -64,6 +64,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
|
enum_to_string:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: enum_to_string
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
event_bus:
|
event_bus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -88,6 +95,18 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
fluttertoast:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: fluttertoast
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "8.0.8"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -109,20 +128,27 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.16.1"
|
version: "0.16.1"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.3"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.10"
|
version: "0.12.11"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.7.0"
|
||||||
mqtt_client:
|
mqtt_client:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -137,6 +163,13 @@ packages:
|
|||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
nested:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nested
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -151,6 +184,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.11.0"
|
||||||
|
provider:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: provider
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.0.0"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -170,6 +210,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.1"
|
||||||
|
sqflite:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: sqflite
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0+4"
|
||||||
|
sqflite_common:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: sqflite_common
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1+1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -191,6 +245,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
|
synchronized:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: synchronized
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -204,7 +265,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.19"
|
version: "0.4.3"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -220,4 +281,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0-0.0 <3.0.0"
|
dart: ">=2.12.0 <3.0.0"
|
||||||
|
flutter: ">=1.16.0"
|
||||||
|
|||||||
@ -24,6 +24,10 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
fluttertoast:
|
||||||
|
sqflite:
|
||||||
|
provider: ^5.0.0
|
||||||
|
enum_to_string: ^2.0.1
|
||||||
mqtt_client: ^8.1.0
|
mqtt_client: ^8.1.0
|
||||||
rxdart: 0.22.0
|
rxdart: 0.22.0
|
||||||
mycoreapi:
|
mycoreapi:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user