WIP: user messages
This commit is contained in:
84
lib/utils/event_bus_events.dart
Normal file
84
lib/utils/event_bus_events.dart
Normal file
@ -0,0 +1,84 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class StateChangedEvent {
|
||||
String entityId;
|
||||
String newState;
|
||||
bool needToRebuildUI;
|
||||
|
||||
StateChangedEvent({
|
||||
this.entityId,
|
||||
this.newState,
|
||||
this.needToRebuildUI: false
|
||||
});
|
||||
}
|
||||
|
||||
class SettingsChangedEvent {
|
||||
bool reconnect;
|
||||
|
||||
SettingsChangedEvent(this.reconnect);
|
||||
}
|
||||
|
||||
class RefreshDataFinishedEvent {
|
||||
RefreshDataFinishedEvent();
|
||||
}
|
||||
|
||||
class ReloadUIEvent {
|
||||
final bool full;
|
||||
|
||||
ReloadUIEvent(this.full);
|
||||
}
|
||||
|
||||
class StartAuthEvent {
|
||||
String oauthUrl;
|
||||
bool starting;
|
||||
|
||||
StartAuthEvent(this.oauthUrl, this.starting);
|
||||
}
|
||||
|
||||
class ServiceCallEvent {
|
||||
String domain;
|
||||
String service;
|
||||
String entityId;
|
||||
Map<String, dynamic> additionalParams;
|
||||
|
||||
ServiceCallEvent(this.domain, this.service, this.entityId, this.additionalParams);
|
||||
}
|
||||
|
||||
class ShowPopupDialogEvent {
|
||||
final String title;
|
||||
final String body;
|
||||
final String positiveText;
|
||||
final String negativeText;
|
||||
final onPositive;
|
||||
final onNegative;
|
||||
|
||||
ShowPopupDialogEvent({this.title, this.body, this.positiveText: "Ok", this.negativeText: "Cancel", this.onPositive, this.onNegative});
|
||||
}
|
||||
|
||||
class ShowPopupMessageEvent {
|
||||
final String title;
|
||||
final String body;
|
||||
final String buttonText;
|
||||
final onButtonClick;
|
||||
|
||||
ShowPopupMessageEvent({this.title, this.body, this.buttonText: "Ok", this.onButtonClick});
|
||||
}
|
||||
|
||||
class ShowEntityPageEvent {
|
||||
Entity entity;
|
||||
|
||||
ShowEntityPageEvent(this.entity);
|
||||
}
|
||||
|
||||
class ShowPageEvent {
|
||||
final String path;
|
||||
final bool goBackFirst;
|
||||
|
||||
ShowPageEvent({@required this.path, this.goBackFirst: false});
|
||||
}
|
||||
|
||||
class ShowErrorEvent {
|
||||
final UserError error;
|
||||
|
||||
ShowErrorEvent(this.error);
|
||||
}
|
46
lib/utils/logger.dart
Normal file
46
lib/utils/logger.dart
Normal file
@ -0,0 +1,46 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class Logger {
|
||||
|
||||
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 e(String message) {
|
||||
_writeToLog("Error", message);
|
||||
}
|
||||
|
||||
static void w(String message) {
|
||||
_writeToLog("Warning", message);
|
||||
}
|
||||
|
||||
static void d(String message) {
|
||||
_writeToLog("Debug", message);
|
||||
}
|
||||
|
||||
static void _writeToLog(String level, String message) {
|
||||
if (isInDebugMode) {
|
||||
debugPrint('$message');
|
||||
}
|
||||
DateTime t = DateTime.now();
|
||||
_log.add("${formatDate(t, ["mm","dd"," ","HH",":","nn",":","ss"])} [$level] : $message");
|
||||
if (_log.length > 100) {
|
||||
_log.removeAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user