diff --git a/lib/model.dart b/lib/model.dart index 8c13a5e..bead765 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -370,6 +370,7 @@ class MessageState extends ChangeNotifier { this.contactHandle, this.messageIndex, }) { + this._senderOnion = profileOnion; tryLoad(context); } @@ -400,9 +401,8 @@ class MessageState extends ChangeNotifier { Provider.of(context, listen: false).cwtch.GetMessage(profileOnion, contactHandle, messageIndex).then((jsonMessage) { dynamic messageWrapper = jsonDecode(jsonMessage); if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') { - this._senderOnion = profileOnion; //todo: remove once sent group messages are prestored - Future.delayed(const Duration(milliseconds: 200), () { + Future.delayed(const Duration(milliseconds: 2), () { tryLoad(context); }); return; diff --git a/lib/widgets/messageloadingbubble.dart b/lib/widgets/messageloadingbubble.dart index 227b245..237c770 100644 --- a/lib/widgets/messageloadingbubble.dart +++ b/lib/widgets/messageloadingbubble.dart @@ -11,84 +11,8 @@ class MessageLoadingBubble extends StatefulWidget { } class MessageLoadingBubbleState extends State { - FocusNode _focus = FocusNode(); - @override Widget build(BuildContext context) { - var fromMe = Provider.of(context).senderOnion == Provider.of(context).onion; - var prettyDate = ""; - var borderRadiousEh = 15.0; - var myKey = Provider.of(context).profileOnion + "::" + Provider.of(context).contactHandle + "::" + Provider.of(context).messageIndex.toString(); - - if (Provider.of(context).timestamp != null) { - // user-configurable timestamps prolly ideal? #todo - prettyDate = DateFormat.yMd().add_jm().format(Provider.of(context).timestamp); - } - - var senderDisplayStr = ""; - if (Provider.of(context).senderOnion != null) { - var contact = Provider.of(context).contactList.getContact(Provider.of(context).senderOnion); - if (contact == null) { - senderDisplayStr = Provider.of(context).senderOnion; - } else { - senderDisplayStr = contact.nickname ?? contact.onion; - } - } - var wdgSender = SelectableText(senderDisplayStr, - style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor())); - - var wdgMessage = SelectableText( - "loading" + '\u202F', - key: Key(myKey), - focusNode: _focus, - style: TextStyle( - color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), - ), - textAlign: TextAlign.left, - textWidthBasis: TextWidthBasis.longestLine, - ); - - var wdgDecorations = Center( - widthFactor: 1.0, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text(prettyDate, - style: TextStyle( - fontSize: 9.0, - color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), - ), - textAlign: fromMe ? TextAlign.right : TextAlign.left), - !fromMe - ? SizedBox(width: 1, height: 1) - : Provider.of(context).ackd - ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - ], - )); - - return LayoutBuilder(builder: (context, constraints) { - //print(constraints.toString()+", "+constraints.maxWidth.toString()); - return Container( - child: Container( - decoration: BoxDecoration( - color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), - border: - Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), width: 1), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(borderRadiousEh), - topRight: Radius.circular(borderRadiousEh), - bottomLeft: fromMe ? Radius.circular(borderRadiousEh) : Radius.zero, - bottomRight: fromMe ? Radius.zero : Radius.circular(borderRadiousEh), - ), - ), - child: Padding( - padding: EdgeInsets.all(9.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])))); - }); + return Center(child:Row(children:[SizedBox(width:40, height:100, child: Text(""))])); } }