forked from cwtch.im/cwtch-ui
Merge branch 'trunk' into copyVerPassWarn
This commit is contained in:
commit
e7c05343d6
|
@ -68,7 +68,13 @@ class CwtchNotifier {
|
||||||
}
|
}
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["GroupID"],
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["GroupID"],
|
||||||
authorization: ContactAuthorization.approved, imagePath: data["PicturePath"], nickname: data["GroupName"], status: status, server: data["GroupServer"], isGroup: true, lastMessageTime: DateTime.now()));
|
authorization: ContactAuthorization.approved,
|
||||||
|
imagePath: data["PicturePath"],
|
||||||
|
nickname: data["GroupName"],
|
||||||
|
status: status,
|
||||||
|
server: data["GroupServer"],
|
||||||
|
isGroup: true,
|
||||||
|
lastMessageTime: DateTime.now()));
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now());
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -329,14 +329,10 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ContactAuthorization {
|
enum ContactAuthorization { unknown, approved, blocked }
|
||||||
unknown,
|
|
||||||
approved,
|
|
||||||
blocked
|
|
||||||
}
|
|
||||||
|
|
||||||
ContactAuthorization stringToContactAuthorization(String authStr) {
|
ContactAuthorization stringToContactAuthorization(String authStr) {
|
||||||
switch(authStr) {
|
switch (authStr) {
|
||||||
case "approved":
|
case "approved":
|
||||||
return ContactAuthorization.approved;
|
return ContactAuthorization.approved;
|
||||||
case "blocked":
|
case "blocked":
|
||||||
|
@ -346,7 +342,6 @@ ContactAuthorization stringToContactAuthorization(String authStr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ContactInfoState extends ChangeNotifier {
|
class ContactInfoState extends ChangeNotifier {
|
||||||
final String profileOnion;
|
final String profileOnion;
|
||||||
final String onion;
|
final String onion;
|
||||||
|
|
|
@ -23,8 +23,6 @@ const TorV3ContactHandleLength = 56;
|
||||||
// Defines the length of a Cwtch v2 Group.
|
// Defines the length of a Cwtch v2 Group.
|
||||||
const GroupConversationHandleLength = 32;
|
const GroupConversationHandleLength = 32;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
abstract class Message {
|
abstract class Message {
|
||||||
MessageMetadata getMetadata();
|
MessageMetadata getMetadata();
|
||||||
Widget getWidget(BuildContext context);
|
Widget getWidget(BuildContext context);
|
||||||
|
|
|
@ -10,6 +10,17 @@ import 'package:provider/provider.dart';
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
import '../../model.dart';
|
import '../../model.dart';
|
||||||
|
|
||||||
|
class QuotedMessageStructure {
|
||||||
|
final String quotedHash;
|
||||||
|
final String body;
|
||||||
|
QuotedMessageStructure(this.quotedHash, this.body);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'quotedHash': quotedHash,
|
||||||
|
'body': body,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class LocallyIndexedMessage {
|
class LocallyIndexedMessage {
|
||||||
final dynamic message;
|
final dynamic message;
|
||||||
final int index;
|
final int index;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:cwtch/cwtch_icons_icons.dart';
|
import 'package:cwtch/cwtch_icons_icons.dart';
|
||||||
import 'package:cwtch/models/message.dart';
|
import 'package:cwtch/models/message.dart';
|
||||||
|
import 'package:cwtch/models/messages/quotedmessage.dart';
|
||||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||||
import 'package:cwtch/widgets/profileimage.dart';
|
import 'package:cwtch/widgets/profileimage.dart';
|
||||||
|
@ -127,7 +128,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
var bytes1 = utf8.encode(messageWrapper["PeerID"] + messageWrapper['Message']);
|
var bytes1 = utf8.encode(messageWrapper["PeerID"] + messageWrapper['Message']);
|
||||||
var digest1 = sha256.convert(bytes1);
|
var digest1 = sha256.convert(bytes1);
|
||||||
var contentHash = base64Encode(digest1.bytes);
|
var contentHash = base64Encode(digest1.bytes);
|
||||||
var quotedMessage = "{\"quotedHash\":\"" + contentHash + "\",\"body\":\"" + ctrlrCompose.value.text + "\"}";
|
var quotedMessage = jsonEncode(QuotedMessageStructure(contentHash, ctrlrCompose.value.text));
|
||||||
ChatMessage cm = new ChatMessage(o: QuotedMessageOverlay, d: quotedMessage);
|
ChatMessage cm = new ChatMessage(o: QuotedMessageOverlay, d: quotedMessage);
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
|
@ -204,7 +205,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(CwtchIcons.send_24px, size: 24, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
icon: Icon(CwtchIcons.send_24px, size: 24, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||||
tooltip: AppLocalizations.of(context)!.sendMessage,
|
tooltip: AppLocalizations.of(context)!.sendMessage,
|
||||||
onPressed: isOffline ? null :_sendMessage,
|
onPressed: isOffline ? null : _sendMessage,
|
||||||
),
|
),
|
||||||
)))),
|
)))),
|
||||||
),
|
),
|
||||||
|
|
|
@ -99,8 +99,6 @@ class _ContactRowState extends State<ContactRow> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _btnApprove() {
|
void _btnApprove() {
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
|
|
|
@ -39,6 +39,7 @@ class MessageRowState extends State<MessageRow> {
|
||||||
|
|
||||||
Widget wdgIcons = Visibility(
|
Widget wdgIcons = Visibility(
|
||||||
visible: this.showMenu,
|
visible: this.showMenu,
|
||||||
|
maintainSize: true,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
tooltip: AppLocalizations.of(context)!.tooltipReplyToThisMessage,
|
tooltip: AppLocalizations.of(context)!.tooltipReplyToThisMessage,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -127,10 +128,7 @@ class MessageRowState extends State<MessageRow> {
|
||||||
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
||||||
child: Text(AppLocalizations.of(context)!.addContact),
|
child: Text(AppLocalizations.of(context)!.addContact),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Provider
|
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, senderOnion);
|
||||||
.of<FlwtchState>(context, listen: false)
|
|
||||||
.cwtch
|
|
||||||
.ImportBundle(profileOnion, senderOnion);
|
|
||||||
final snackBar = SnackBar(
|
final snackBar = SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)!.successfullAddedContact),
|
content: Text(AppLocalizations.of(context)!.successfullAddedContact),
|
||||||
duration: Duration(seconds: 2),
|
duration: Duration(seconds: 2),
|
||||||
|
|
|
@ -5,7 +5,8 @@ import 'package:provider/provider.dart';
|
||||||
import '../settings.dart';
|
import '../settings.dart';
|
||||||
|
|
||||||
class ProfileImage extends StatefulWidget {
|
class ProfileImage extends StatefulWidget {
|
||||||
ProfileImage({required this.imagePath, required this.diameter, required this.border, this.badgeCount = 0, required this.badgeColor, required this.badgeTextColor, this.maskOut = false, this.tooltip = ""});
|
ProfileImage(
|
||||||
|
{required this.imagePath, required this.diameter, required this.border, this.badgeCount = 0, required this.badgeColor, required this.badgeTextColor, this.maskOut = false, this.tooltip = ""});
|
||||||
final double diameter;
|
final double diameter;
|
||||||
final String imagePath;
|
final String imagePath;
|
||||||
final Color border;
|
final Color border;
|
||||||
|
@ -28,8 +29,8 @@ class _ProfileImageState extends State<ProfileImage> {
|
||||||
// We need some theme specific blending here...we might want to consider making this a theme level attribute
|
// We need some theme specific blending here...we might want to consider making this a theme level attribute
|
||||||
colorBlendMode: !widget.maskOut
|
colorBlendMode: !widget.maskOut
|
||||||
? Provider.of<Settings>(context).theme.identifier() == "dark"
|
? Provider.of<Settings>(context).theme.identifier() == "dark"
|
||||||
? BlendMode.softLight
|
? BlendMode.softLight
|
||||||
: BlendMode.darken
|
: BlendMode.darken
|
||||||
: BlendMode.srcOut,
|
: BlendMode.srcOut,
|
||||||
color: Provider.of<Settings>(context).theme.backgroundHilightElementColor(),
|
color: Provider.of<Settings>(context).theme.backgroundHilightElementColor(),
|
||||||
isAntiAlias: true,
|
isAntiAlias: true,
|
||||||
|
@ -47,11 +48,7 @@ class _ProfileImageState extends State<ProfileImage> {
|
||||||
color: widget.border,
|
color: widget.border,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(2.0), //border size
|
padding: const EdgeInsets.all(2.0), //border size
|
||||||
child: ClipOval(
|
child: ClipOval(clipBehavior: Clip.antiAlias, child: widget.tooltip == "" ? image : Tooltip(message: widget.tooltip, child: image))))),
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: widget.tooltip == "" ? image : Tooltip(
|
|
||||||
message: widget.tooltip,
|
|
||||||
child: image))))),
|
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.badgeCount > 0,
|
visible: widget.badgeCount > 0,
|
||||||
child: Positioned(
|
child: Positioned(
|
||||||
|
|
Loading…
Reference in New Issue