format
This commit is contained in:
parent
4cf3b4f6d5
commit
760458931a
|
@ -429,7 +429,7 @@ class MessageState extends ChangeNotifier {
|
|||
} else {
|
||||
var parts = message['d'].toString().split("||");
|
||||
if (parts.length == 2) {
|
||||
print("jsondecoding: "+utf8.fuse(base64).decode(parts[1].substring(5)));
|
||||
print("jsondecoding: " + utf8.fuse(base64).decode(parts[1].substring(5)));
|
||||
var jsonObj = jsonDecode(utf8.fuse(base64).decode(parts[1].substring(5)));
|
||||
this._inviteTarget = jsonObj['GroupID'];
|
||||
this._inviteNick = jsonObj['GroupName'];
|
||||
|
|
|
@ -81,18 +81,16 @@ class _MessageViewState extends State<MessageView> {
|
|||
|
||||
void _sendMessage([String ignoredParam]) {
|
||||
ChatMessage cm = new ChatMessage(o: 1, d: ctrlrCompose.value.text);
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SendMessage(
|
||||
Provider.of<ContactInfoState>(context, listen: false).profileOnion,
|
||||
Provider.of<ContactInfoState>(context, listen: false).onion,
|
||||
jsonEncode(cm));
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, jsonEncode(cm));
|
||||
_sendMessageHelper();
|
||||
}
|
||||
|
||||
void _sendInvitation([String ignoredParam]) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SendInvitation(
|
||||
Provider.of<ContactInfoState>(context, listen: false).profileOnion,
|
||||
Provider.of<ContactInfoState>(context, listen: false).onion,
|
||||
this.selectedContact);
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.SendInvitation(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, this.selectedContact);
|
||||
_sendMessageHelper();
|
||||
}
|
||||
|
||||
|
@ -121,23 +119,25 @@ class _MessageViewState extends State<MessageView> {
|
|||
textInputAction: TextInputAction.send,
|
||||
onSubmitted: _sendMessage,
|
||||
)),
|
||||
Column(children:[SizedBox(
|
||||
width: 100,
|
||||
height: 50,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(2, 2, 2, 2),
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.send, size: 24, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(86, 50)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: _sendMessage,
|
||||
))),
|
||||
SizedBox(
|
||||
width: 86, height: 40,
|
||||
child: IconButton(icon: Icon(Icons.insert_invitation, size: 12, color: Provider.of<Settings>(context).theme.mainTextColor()), onPressed: () => _modalSendInvitation(context))
|
||||
),])
|
||||
Column(children: [
|
||||
SizedBox(
|
||||
width: 100,
|
||||
height: 50,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(2, 2, 2, 2),
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.send, size: 24, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(86, 50)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: _sendMessage,
|
||||
))),
|
||||
SizedBox(
|
||||
width: 86,
|
||||
height: 40,
|
||||
child: IconButton(icon: Icon(Icons.insert_invitation, size: 12, color: Provider.of<Settings>(context).theme.mainTextColor()), onPressed: () => _modalSendInvitation(context))),
|
||||
])
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -165,10 +165,16 @@ class _MessageViewState extends State<MessageView> {
|
|||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(ctx, listen: false), child: DropdownContacts(onChanged: (newVal) {
|
||||
setState((){ this.selectedContact = newVal; });
|
||||
})),
|
||||
SizedBox(height: 20,),
|
||||
ChangeNotifierProvider.value(
|
||||
value: Provider.of<ProfileInfoState>(ctx, listen: false),
|
||||
child: DropdownContacts(onChanged: (newVal) {
|
||||
setState(() {
|
||||
this.selectedContact = newVal;
|
||||
});
|
||||
})),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text(AppLocalizations.of(bcontext).inviteBtn, semanticsLabel: AppLocalizations.of(bcontext).inviteBtn),
|
||||
onPressed: () {
|
||||
|
|
|
@ -8,7 +8,9 @@ import '../model.dart';
|
|||
// Displays nicknames to UI but uses handles as values
|
||||
// Pass an onChanged handler to access value
|
||||
class DropdownContacts extends StatefulWidget {
|
||||
DropdownContacts({this.onChanged,});
|
||||
DropdownContacts({
|
||||
this.onChanged,
|
||||
});
|
||||
final Function(dynamic) onChanged;
|
||||
|
||||
@override
|
||||
|
@ -20,15 +22,18 @@ class _DropdownContactsState extends State<DropdownContacts> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DropdownButton(value: this.selected, items: Provider.of<ProfileInfoState>(context, listen: false).contactList.contacts.map<DropdownMenuItem<String>>((ContactInfoState contact) {
|
||||
return DropdownMenuItem<String>(value: contact.onion, child: Text(contact.nickname??contact.onion));
|
||||
}).toList(), onChanged: (newVal) {
|
||||
setState(() {
|
||||
this.selected = newVal;
|
||||
});
|
||||
if (widget.onChanged != null) {
|
||||
widget.onChanged(newVal);
|
||||
}
|
||||
});
|
||||
return DropdownButton(
|
||||
value: this.selected,
|
||||
items: Provider.of<ProfileInfoState>(context, listen: false).contactList.contacts.map<DropdownMenuItem<String>>((ContactInfoState contact) {
|
||||
return DropdownMenuItem<String>(value: contact.onion, child: Text(contact.nickname ?? contact.onion));
|
||||
}).toList(),
|
||||
onChanged: (newVal) {
|
||||
setState(() {
|
||||
this.selected = newVal;
|
||||
});
|
||||
if (widget.onChanged != null) {
|
||||
widget.onChanged(newVal);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,27 +43,33 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
|||
senderDisplayStr = contact.nickname ?? contact.onion;
|
||||
}
|
||||
}
|
||||
var wdgSender = Center(widthFactor:1, child: SelectableText(senderDisplayStr + '\u202F',
|
||||
style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor())));
|
||||
var wdgSender = Center(
|
||||
widthFactor: 1,
|
||||
child: SelectableText(senderDisplayStr + '\u202F',
|
||||
style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor())));
|
||||
|
||||
// todo: translations
|
||||
var messageStr = "";
|
||||
if (fromMe) {
|
||||
//todo: get group name?
|
||||
messageStr = "You sent an invitation for "+(isGroup ? "a group" : Provider.of<MessageState>(context).message ?? "");
|
||||
messageStr = "You sent an invitation for " + (isGroup ? "a group" : Provider.of<MessageState>(context).message ?? "");
|
||||
} else {
|
||||
messageStr = (isGroup ? "You have been invited to join "+(Provider.of<MessageState>(context).inviteNick??"") : "This is a contact suggestion for:") + "\n" + (Provider.of<MessageState>(context).inviteTarget ?? "");
|
||||
messageStr = (isGroup ? "You have been invited to join " + (Provider.of<MessageState>(context).inviteNick ?? "") : "This is a contact suggestion for:") +
|
||||
"\n" +
|
||||
(Provider.of<MessageState>(context).inviteTarget ?? "");
|
||||
}
|
||||
var wdgMessage = Center(widthFactor:1, child: SelectableText(
|
||||
messageStr + '\u202F',
|
||||
key: Key(myKey),
|
||||
focusNode: _focus,
|
||||
style: TextStyle(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
textWidthBasis: TextWidthBasis.longestLine,
|
||||
));
|
||||
var wdgMessage = Center(
|
||||
widthFactor: 1,
|
||||
child: SelectableText(
|
||||
messageStr + '\u202F',
|
||||
key: Key(myKey),
|
||||
focusNode: _focus,
|
||||
style: TextStyle(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
textWidthBasis: TextWidthBasis.longestLine,
|
||||
));
|
||||
|
||||
Widget wdgDecorations;
|
||||
if (fromMe) {
|
||||
|
@ -72,15 +78,14 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
|||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(prettyDate, style: TextStyle(
|
||||
fontSize: 9.0,
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor()
|
||||
), textAlign: fromMe ? TextAlign.right : TextAlign.left),
|
||||
Text(prettyDate,
|
||||
style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor()),
|
||||
textAlign: fromMe ? TextAlign.right : TextAlign.left),
|
||||
!fromMe
|
||||
? SizedBox(width: 1, height: 1)
|
||||
: Provider.of<MessageState>(context).ackd
|
||||
? Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
? Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
],
|
||||
));
|
||||
} else if (isAccepted) {
|
||||
|
@ -88,10 +93,12 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
|||
} else if (this.rejected) {
|
||||
wdgDecorations = Text("Rejected.");
|
||||
} else {
|
||||
wdgDecorations = Center(widthFactor:1,child:Row(children: [
|
||||
Padding(padding: EdgeInsets.all(5), child: TextButton(child: Text("Reject"), onPressed: _btnReject)),
|
||||
Padding(padding: EdgeInsets.all(5), child: TextButton(child: Text("Accept"), onPressed: _btnAccept)),
|
||||
]));
|
||||
wdgDecorations = Center(
|
||||
widthFactor: 1,
|
||||
child: Row(children: [
|
||||
Padding(padding: EdgeInsets.all(5), child: TextButton(child: Text("Reject"), onPressed: _btnReject)),
|
||||
Padding(padding: EdgeInsets.all(5), child: TextButton(child: Text("Accept"), onPressed: _btnAccept)),
|
||||
]));
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
|
@ -110,21 +117,26 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
|||
bottomRight: fromMe ? Radius.zero : Radius.circular(borderRadiousEh),
|
||||
),
|
||||
),
|
||||
child: Center(widthFactor: 1.0,child:Padding(
|
||||
padding: EdgeInsets.all(9.0),
|
||||
child: Row(mainAxisSize: MainAxisSize.min, children: [Center(widthFactor: 1,child: Padding(padding:EdgeInsets.all(4), child:Icon(Icons.group_add, size: 32))),
|
||||
Center(widthFactor: 1.0,child: Column(
|
||||
crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: fromMe ? [wdgMessage, wdgDecorations] : [wdgSender, wdgMessage, wdgDecorations])),
|
||||
])))));
|
||||
child: Center(
|
||||
widthFactor: 1.0,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(9.0),
|
||||
child: Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
Center(widthFactor: 1, child: Padding(padding: EdgeInsets.all(4), child: Icon(Icons.group_add, size: 32))),
|
||||
Center(
|
||||
widthFactor: 1.0,
|
||||
child: Column(
|
||||
crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: fromMe ? [wdgMessage, wdgDecorations] : [wdgSender, wdgMessage, wdgDecorations])),
|
||||
])))));
|
||||
});
|
||||
}
|
||||
|
||||
void _btnReject() {
|
||||
//todo: how should we track inline invite rejections?
|
||||
setState(()=>this.rejected = true);
|
||||
setState(() => this.rejected = true);
|
||||
}
|
||||
|
||||
void _btnAccept() {
|
||||
|
|
|
@ -13,6 +13,6 @@ class MessageLoadingBubble extends StatefulWidget {
|
|||
class MessageLoadingBubbleState extends State<MessageLoadingBubble> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child:Row(children:[SizedBox(width:40, height:100, child: Text(""))]));
|
||||
return Center(child: Row(children: [SizedBox(width: 40, height: 100, child: Text(""))]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ class _MessageRowState extends State<MessageRow> {
|
|||
Widget build(BuildContext context) {
|
||||
var fromMe = Provider.of<MessageState>(context).senderOnion == Provider.of<ProfileInfoState>(context).onion;
|
||||
|
||||
Widget wdgBubble = Flexible(flex: 3, fit: FlexFit.loose, child: Provider.of<MessageState>(context).loaded == true ? widgetForOverlay(Provider.of<MessageState>(context).overlay) : MessageLoadingBubble());
|
||||
Widget wdgBubble =
|
||||
Flexible(flex: 3, fit: FlexFit.loose, child: Provider.of<MessageState>(context).loaded == true ? widgetForOverlay(Provider.of<MessageState>(context).overlay) : MessageLoadingBubble());
|
||||
Widget wdgIcons = Icon(Icons.delete_forever_outlined, color: Provider.of<Settings>(context).theme.dropShadowColor());
|
||||
Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10));
|
||||
var widgetRow = <Widget>[];
|
||||
|
@ -38,12 +39,12 @@ class _MessageRowState extends State<MessageRow> {
|
|||
} else {
|
||||
var contact = Provider.of<ContactInfoState>(context);
|
||||
Widget wdgPortrait = GestureDetector(
|
||||
onTap: _btnAdd,
|
||||
child: ProfileImage(
|
||||
diameter: 48.0,
|
||||
imagePath: Provider.of<MessageState>(context).senderImage ?? contact.imagePath,
|
||||
//maskOut: contact.status != "Authenticated",
|
||||
border: contact.status == "Authenticated" ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()));
|
||||
onTap: _btnAdd,
|
||||
child: ProfileImage(
|
||||
diameter: 48.0,
|
||||
imagePath: Provider.of<MessageState>(context).senderImage ?? contact.imagePath,
|
||||
//maskOut: contact.status != "Authenticated",
|
||||
border: contact.status == "Authenticated" ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor()));
|
||||
|
||||
widgetRow = <Widget>[
|
||||
wdgPortrait,
|
||||
|
@ -58,9 +59,11 @@ class _MessageRowState extends State<MessageRow> {
|
|||
|
||||
Widget widgetForOverlay(int o) {
|
||||
switch (o) {
|
||||
case 1: return MessageBubble();
|
||||
case 1:
|
||||
return MessageBubble();
|
||||
case 100:
|
||||
case 101: return InvitationBubble();
|
||||
case 101:
|
||||
return InvitationBubble();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue