This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/utils.class.dart

80 lines
1.4 KiB
Dart
Raw Normal View History

2018-09-25 22:47:06 +03:00
part of 'main.dart';
class TheLogger {
static List<String> _log = [];
static String getLog() {
String res = '';
_log.forEach((line) {
res += "$line\n";
});
return res;
}
static bool get isInDebugMode {
bool inDebugMode = false;
assert(inDebugMode = true);
return inDebugMode;
}
static void log(String level, String message) {
if (isInDebugMode) {
debugPrint('$message');
}
_log.add("[$level] : $message");
if (_log.length > 50) {
_log.removeAt(0);
}
}
}
2018-10-02 00:41:40 +03:00
class HAUtils {
2018-09-25 22:47:06 +03:00
static void launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
TheLogger.log("Error", "Could not launch $url");
}
}
}
class StateChangedEvent {
String entityId;
String newState;
2018-09-29 17:59:38 +03:00
bool localChange;
2018-09-25 22:47:06 +03:00
2018-09-29 17:59:38 +03:00
StateChangedEvent(this.entityId, this.newState, this.localChange);
2018-09-25 22:47:06 +03:00
}
class SettingsChangedEvent {
bool reconnect;
SettingsChangedEvent(this.reconnect);
}
2018-10-07 02:17:14 +03:00
class RefreshDataEvent {
RefreshDataEvent();
}
class RefreshDataFinishedEvent {
RefreshDataFinishedEvent();
}
class ServiceCallEvent {
String domain;
String service;
String entityId;
Map<String, String> additionalParams;
ServiceCallEvent(this.domain, this.service, this.entityId, this.additionalParams);
2018-09-29 16:19:01 +03:00
}
class ShowEntityPageEvent {
Entity entity;
ShowEntityPageEvent(this.entity);
2018-09-25 22:47:06 +03:00
}