flutter_app/lib/model.dart

89 lines
1.5 KiB
Dart
Raw Normal View History

2021-01-21 20:37:35 +00:00
import 'dart:convert';
import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'dart:async';
import 'dart:collection';
import 'cwtch/cwtch.dart';
////////////////////
/// UI State ///
////////////////////
class ProfileModel {
String onion;
String nickname;
String creationDate;
2021-01-21 20:37:35 +00:00
String imagePath;
HashMap<String, ContactModel> contacts;
}
class ContactModel {
String onion;
String nickname;
bool isGroup;
2021-01-21 20:37:35 +00:00
bool isInvitation;
bool isBlocked;
String status;
2021-01-21 20:37:35 +00:00
String imagePath;
2021-01-21 20:37:35 +00:00
ContactModel({this.onion, this.nickname, this.status, this.isInvitation, this.isBlocked, this.imagePath});
}
2021-01-22 07:56:30 +00:00
class DanMessageModel {
2021-01-14 23:36:09 +00:00
String Timestamp;
bool Acknowledged;
String Message;
}
2021-01-21 20:37:35 +00:00
class ChatMessage {
final int o;
final String d;
ChatMessage({this.o, this.d});
ChatMessage.fromJson(Map<String, dynamic> json)
: o = json['o'],
d = json['d'];
Map<String, dynamic> toJson() =>
{
'o': o,
'd': d,
};
}
/////////////
/// ACN ///
/////////////
class AppModel {
final Cwtch cwtch;
AppModel({this.cwtch});
Stream<String> contactEvents() async* {
while (true) {
2021-01-14 23:36:09 +00:00
String event = await cwtch.ContactEvents();
if (event != "") {
print(event);
yield event;
} else {
await Future.delayed(Duration(seconds: 1));
}
}
}
Stream<String> torStatus() async* {
while (true) {
2021-01-14 23:36:09 +00:00
String event = await cwtch.ACNEvents();
if (event != "") {
yield event;
} else {
await Future.delayed(Duration(seconds: 1));
}
}
}
}