diff --git a/assets/fonts/LICENSE.txt b/assets/fonts/LICENSE-roboto.txt similarity index 100% rename from assets/fonts/LICENSE.txt rename to assets/fonts/LICENSE-roboto.txt diff --git a/assets/fonts/NotoColorEmoji-Regular.ttf b/assets/fonts/NotoColorEmoji-Regular.ttf new file mode 100644 index 00000000..bcb39645 Binary files /dev/null and b/assets/fonts/NotoColorEmoji-Regular.ttf differ diff --git a/assets/fonts/OFL.txt b/assets/fonts/OFL-Inter.txt similarity index 97% rename from assets/fonts/OFL.txt rename to assets/fonts/OFL-Inter.txt index ad214842..00287df1 100644 --- a/assets/fonts/OFL.txt +++ b/assets/fonts/OFL-Inter.txt @@ -1,93 +1,93 @@ -Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. +Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/fonts/OFL-noto.txt b/assets/fonts/OFL-noto.txt new file mode 100644 index 00000000..a939e409 --- /dev/null +++ b/assets/fonts/OFL-noto.txt @@ -0,0 +1,93 @@ +Copyright 2021 Google Inc. All Rights Reserved. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/lib/licenses.dart b/lib/licenses.dart index c9f6a018..49593ad5 100644 --- a/lib/licenses.dart +++ b/lib/licenses.dart @@ -4,7 +4,7 @@ Stream licenses() async* { /// Open Privacy Code yield LicenseEntryWithLineBreaks(["cwtch", "tapir", "connectivity", "log"], '''MIT License - Copyright (c) 2018 Open Privacy Research Society + Copyright (c) 2018-2023 Open Privacy Research Society Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files ("the Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -645,7 +645,102 @@ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. '''); + yield LicenseEntryWithLineBreaks(["Noto Color Emoji Fonts"], ''' + Copyright 2021 Google Inc. All Rights Reserved. +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. + + '''); yield LicenseEntryWithLineBreaks(["Roboto fonts"], ''' Apache License diff --git a/lib/models/message_draft.dart b/lib/models/message_draft.dart index 0ffb98ab..23ffb6ff 100644 --- a/lib/models/message_draft.dart +++ b/lib/models/message_draft.dart @@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart'; /// Only one draft is stored per conversation. class MessageDraft extends ChangeNotifier { QuotedReference? _quotedReference; - + int? _inviteHandle; TextEditingController ctrlCompose = TextEditingController(); static MessageDraft empty() { @@ -29,6 +29,15 @@ class MessageDraft extends ChangeNotifier { notifyListeners(); } + void attachInvite(int handle) { + this._inviteHandle = handle; + notifyListeners(); + } + + int? getInviteHandle() { + return this._inviteHandle; + } + QuotedReference? getQuotedMessage() { return this._quotedReference; } @@ -41,6 +50,7 @@ class MessageDraft extends ChangeNotifier { void clearDraft() { this._quotedReference = null; this.ctrlCompose.clear(); + this._inviteHandle = null; notifyListeners(); } @@ -49,6 +59,10 @@ class MessageDraft extends ChangeNotifier { ctrlCompose.dispose(); super.dispose(); } + + void clearInvite() { + this._inviteHandle = null; + } } /// A QuotedReference encapsulates the state of replied-to message. diff --git a/lib/models/messages/invitemessage.dart b/lib/models/messages/invitemessage.dart index 02fc7512..63c9236f 100644 --- a/lib/models/messages/invitemessage.dart +++ b/lib/models/messages/invitemessage.dart @@ -32,9 +32,13 @@ class InviteMessage extends Message { } else { var parts = this.content.toString().split("||"); if (parts.length == 2) { - var jsonObj = jsonDecode(utf8.fuse(base64).decode(parts[1].substring(5))); - inviteTarget = jsonObj['GroupID']; - inviteNick = jsonObj['GroupName']; + try { + var jsonObj = jsonDecode(utf8.fuse(base64).decode(parts[1].substring(5))); + inviteTarget = jsonObj['GroupID']; + inviteNick = jsonObj['GroupName']; + } catch (e) { + return MessageRow(MalformedBubble(), index); + } } else { return MessageRow(MalformedBubble(), index); } @@ -58,9 +62,13 @@ class InviteMessage extends Message { } else { var parts = this.content.toString().split("||"); if (parts.length == 2) { - var jsonObj = jsonDecode(utf8.fuse(base64).decode(parts[1].substring(5))); - inviteTarget = jsonObj['GroupID']; - inviteNick = jsonObj['GroupName']; + try { + var jsonObj = jsonDecode(utf8.fuse(base64).decode(parts[1].substring(5))); + inviteTarget = jsonObj['GroupID']; + inviteNick = jsonObj['GroupName']; + } catch (e) { + return MalformedBubble(); + } } else { return MalformedBubble(); } diff --git a/lib/models/redaction.dart b/lib/models/redaction.dart index a9a9021b..ab62a08d 100644 --- a/lib/models/redaction.dart +++ b/lib/models/redaction.dart @@ -18,11 +18,12 @@ String redactedNick(BuildContext context, String handle, String nick) { String prettyDateString(BuildContext context, DateTime date) { var settings = Provider.of(context, listen: false); + // We want to display *Never* for epoch dates regardless of setting status + if (date.millisecondsSinceEpoch == 0) { + return AppLocalizations.of(context)!.conversationNotificationPolicyNever; + } if (settings.streamerMode) { var now = DateTime.now(); - if (date.millisecondsSinceEpoch == 0) { - return AppLocalizations.of(context)!.conversationNotificationPolicyNever; - } if (now.difference(date).abs().inDays > 1) { return AppLocalizations.of(context)!.xDaysAgo.replaceAll("\$days", now.difference(date).abs().inDays.toString()); } diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index 9e3f7e6d..334ddeff 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -20,7 +20,7 @@ const mode_light = "light"; const mode_dark = "dark"; final TextStyle defaultSmallTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.normal, fontSize: 10); -final TextStyle defaultMessageTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w400, fontSize: 13); +final TextStyle defaultMessageTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w400, fontSize: 13, fontFamilyFallback: ['Noto Color Emoji']); final TextStyle defaultFormLabelTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: 20); final TextStyle defaultTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w500, fontSize: 12); final TextStyle defaultTextButtonStyle = defaultTextStyle.copyWith(fontWeight: FontWeight.bold); diff --git a/lib/third_party/linkify/flutter_linkify.dart b/lib/third_party/linkify/flutter_linkify.dart index 882bdfe5..9b61eca9 100644 --- a/lib/third_party/linkify/flutter_linkify.dart +++ b/lib/third_party/linkify/flutter_linkify.dart @@ -8,7 +8,7 @@ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights +// in the Software without restriction, including without limitatifon the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index add6e6ac..c5044d9c 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -12,10 +12,12 @@ import 'package:cwtch/models/contact.dart'; import 'package:cwtch/models/message.dart'; import 'package:cwtch/models/message_draft.dart'; import 'package:cwtch/models/messagecache.dart'; +import 'package:cwtch/models/messages/invitemessage.dart'; import 'package:cwtch/models/messages/quotedmessage.dart'; import 'package:cwtch/models/profile.dart'; import 'package:cwtch/themes/opaque.dart'; import 'package:cwtch/third_party/linkify/flutter_linkify.dart'; +import 'package:cwtch/widgets/invitationbubble.dart'; import 'package:cwtch/widgets/malformedbubble.dart'; import 'package:cwtch/widgets/messageloadingbubble.dart'; import 'package:cwtch/widgets/profileimage.dart'; @@ -345,6 +347,11 @@ class _MessageViewState extends State { return; } + var attachedInvite = Provider.of(context, listen: false).messageDraft.getInviteHandle(); + if (attachedInvite != null) { + this._sendInvitation(attachedInvite); + } + // Trim message var messageText = Provider.of(context, listen: false).messageDraft.messageText ?? ""; final messageWithoutNewLine = messageText.trimRight(); @@ -385,10 +392,10 @@ class _MessageViewState extends State { } } - void _sendInvitation([String? ignoredParam]) { + void _sendInvitation(int contact) { Provider.of(context, listen: false) .cwtch - .SendInvitation(Provider.of(context, listen: false).profileOnion, Provider.of(context, listen: false).identifier, this.selectedContact) + .SendInvitation(Provider.of(context, listen: false).profileOnion, Provider.of(context, listen: false).identifier, contact) .then(_sendMessageHandler); } @@ -434,6 +441,27 @@ class _MessageViewState extends State { focusNode.requestFocus(); } + Widget senderInviteChrome(String chrome, String targetName) { + var settings = Provider.of(context); + + return Wrap(children: [ + SelectableText( + chrome + '\u202F', + style: settings.scaleFonts(defaultMessageTextStyle.copyWith(color: Provider.of(context).theme.messageFromMeTextColor)), + textAlign: TextAlign.left, + maxLines: 2, + textWidthBasis: TextWidthBasis.longestLine, + ), + SelectableText( + targetName + '\u202F', + style: settings.scaleFonts(defaultMessageTextStyle.copyWith(color: Provider.of(context).theme.messageFromMeTextColor)), + textAlign: TextAlign.left, + maxLines: 2, + textWidthBasis: TextWidthBasis.longestLine, + ) + ]); + } + Widget _buildPreviewBox() { var showClickableLinks = Provider.of(context).isExperimentEnabled(ClickableLinksExperiment); @@ -686,6 +714,54 @@ class _MessageViewState extends State { Container(color: Provider.of(context).theme.backgroundMainColor, padding: EdgeInsets.all(2), margin: EdgeInsets.all(2), height: 164, child: Column(children: textEditChildren)); var children; + Widget invite = Container(); + if (Provider.of(context).messageDraft.getInviteHandle() != null) { + invite = FutureBuilder( + future: Future.value(Provider.of(context).messageDraft.getInviteHandle()), + builder: (context, snapshot) { + if (snapshot.hasData) { + var contactInvite = snapshot.data! as int; + var contact = Provider.of(context, listen: false).contactList.getContact(contactInvite); + return Container( + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(5), + color: Provider.of(context).theme.messageFromMeBackgroundColor, + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Stack(children: [ + Container( + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(5), + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration(color: Provider.of(context).theme.messageFromMeBackgroundColor), + height: 75, + child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ + Padding(padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0), child: Icon(CwtchIcons.send_invite, size: 32)), + Flexible( + child: DefaultTextStyle( + textWidthBasis: TextWidthBasis.parent, + child: senderInviteChrome("", contact!.nickname), + style: Provider.of(context).scaleFonts(defaultTextStyle), + overflow: TextOverflow.fade, + )) + ])), + Align( + alignment: Alignment.topRight, + child: IconButton( + icon: Icon(Icons.highlight_remove), + splashRadius: Material.defaultSplashRadius / 2, + tooltip: AppLocalizations.of(context)!.tooltipRemoveThisQuotedMessage, + onPressed: () { + Provider.of(context, listen: false).messageDraft.clearInvite(); + setState(() {}); + }, + )), + ]), + ])); + } + return Container(); + }); + } + if (Provider.of(context).selectedConversation != null && Provider.of(context).messageDraft.getQuotedMessage() != null) { var quoted = FutureBuilder( future: messageHandler(context, Provider.of(context).selectedProfile!, Provider.of(context).selectedConversation!, @@ -743,9 +819,9 @@ class _MessageViewState extends State { }, ); - children = [quoted, composeBox]; + children = [invite, quoted, composeBox]; } else { - children = [composeBox]; + children = [invite, composeBox]; } return Container(color: Provider.of(context).theme.backgroundMainColor, child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: children)); @@ -803,9 +879,10 @@ class _MessageViewState extends State { child: Text(AppLocalizations.of(bcontext)!.inviteBtn, semanticsLabel: AppLocalizations.of(bcontext)!.inviteBtn), onPressed: () { if (this.selectedContact != -1) { - this._sendInvitation(); + Provider.of(context, listen: false).messageDraft.attachInvite(this.selectedContact); } Navigator.pop(bcontext); + setState(() {}); }, ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 184b241c..ce9802ff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -115,6 +115,9 @@ flutter: - asset: assets/fonts/RobotoMono-Regular.ttf - asset: assets/fonts/RobotoMono-Bold.ttf weight: 700 + - family: 'Noto Color Emoji' + fonts: + - asset: assets/fonts/NotoColorEmoji-Regular.ttf - family: Inter fonts: - asset: assets/fonts/Inter-Regular.ttf