Fix #163
continuous-integration/drone/pr Build is running Details

Also make quoted messages nicer
This commit is contained in:
Sarah Jamie Lewis 2021-09-17 13:38:10 -07:00
parent 3a34044f8e
commit c1aee0d128
10 changed files with 105 additions and 89 deletions

View File

@ -448,7 +448,6 @@ class CwtchFfi implements Cwtch {
malloc.free(u2);
}
@override
// ignore: non_constant_identifier_names
void UpdateMessageFlags(String profile, String handle, int index, int flags) {

View File

@ -31,6 +31,7 @@ class AppState extends ChangeNotifier {
String? _selectedProfile;
String? _selectedConversation;
int _initialScrollIndex = 0;
int _hoveredIndex = -1;
int? _selectedIndex;
bool _unreadMessagesBelow = false;
@ -62,6 +63,14 @@ class AppState extends ChangeNotifier {
notifyListeners();
}
// Never use this for message lookup - can be a non-indexed value
// e.g. -1
int get hoveredIndex => _hoveredIndex;
set hoveredIndex(int newVal) {
this._hoveredIndex = newVal;
notifyListeners();
}
bool get unreadMessagesBelow => _unreadMessagesBelow;
set unreadMessagesBelow(bool newVal) {
this._unreadMessagesBelow = newVal;
@ -381,10 +390,8 @@ class ContactInfoState extends ChangeNotifier {
String? _server;
late bool _archived;
ContactInfoState(
this.profileOnion,
this.onion, {
nickname = "",
ContactInfoState(this.profileOnion, this.onion,
{nickname = "",
isGroup = false,
authorization = ContactAuthorization.unknown,
status = "",
@ -394,8 +401,7 @@ class ContactInfoState extends ChangeNotifier {
numUnread = 0,
lastMessageTime,
server,
archived = false
}) {
archived = false}) {
this._nickname = nickname;
this._isGroup = isGroup;
this._authorization = authorization;
@ -421,8 +427,8 @@ class ContactInfoState extends ChangeNotifier {
this._archived = archived;
notifyListeners();
}
bool get isArchived => this._archived;
bool get isArchived => this._archived;
set savePeerHistory(String newVal) {
this._savePeerHistory = newVal;

View File

@ -30,6 +30,7 @@ void selectConversation(BuildContext context, String handle) {
Provider.of<AppState>(context, listen: false).initialScrollIndex = initialIndex;
Provider.of<AppState>(context, listen: false).selectedConversation = handle;
Provider.of<AppState>(context, listen: false).selectedIndex = null;
Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
// if in singlepane mode, push to the stack
var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context);
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);

View File

@ -162,11 +162,12 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
onPressed: () {
showAlertDialog(context);
},
style: ButtonStyle (
backgroundColor: MaterialStateProperty.all(Colors.transparent)
),
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.transparent)),
icon: Icon(CwtchIcons.leave_group),
label: Text(AppLocalizations.of(context)!.leaveGroup, style: TextStyle(decoration: TextDecoration.underline),),
label: Text(
AppLocalizations.of(context)!.leaveGroup,
style: TextStyle(decoration: TextDecoration.underline),
),
))
])
])

View File

@ -257,18 +257,27 @@ class _MessageViewState extends State<MessageView> {
color: message.getMetadata().senderHandle != Provider.of<AppState>(context).selectedProfile
? Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor()
: Provider.of<Settings>(context).theme.messageFromMeBackgroundColor(),
child: Wrap(runAlignment: WrapAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly, runSpacing: 1.0, crossAxisAlignment: WrapCrossAlignment.center, children: [
Center(widthFactor: 1, child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.reply, size: 32))),
Center(widthFactor: 1.0, child: message.getPreviewWidget(context)),
Center(
widthFactor: 1.0,
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Stack(children: [
Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(Icons.highlight_remove),
tooltip: AppLocalizations.of(context)!.tooltipRemoveThisQuotedMessage,
onPressed: () {
Provider.of<AppState>(context, listen: false).selectedIndex = null;
},
))
)),
Align(
alignment: Alignment.topLeft,
child: Padding(padding: EdgeInsets.all(2.0), child: Icon(Icons.reply)),
)
]),
Wrap(
runAlignment: WrapAlignment.spaceEvenly,
alignment: WrapAlignment.center,
runSpacing: 1.0,
children: [Center(widthFactor: 1.0, child: Padding(padding: EdgeInsets.all(10.0), child: message.getPreviewWidget(context)))]),
]));
} else {
return MessageLoadingBubble();

View File

@ -69,7 +69,8 @@ class _ContactRowState extends State<ContactRow> {
visible: !Provider.of<Settings>(context).streamerMode,
child: Text(contact.onion,
style: TextStyle(color: contact.isBlocked ? Provider.of<Settings>(context).theme.portraitBlockedTextColor() : Provider.of<Settings>(context).theme.mainTextColor())),
)],
)
],
))),
Padding(
padding: const EdgeInsets.all(5.0),

View File

@ -22,7 +22,6 @@ class MessageRow extends StatefulWidget {
}
class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMixin {
bool showMenu = false;
bool showBlockedMessage = false;
late AnimationController _controller;
late Animation<Alignment> _animation;
@ -70,7 +69,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
}
Widget wdgIcons = Visibility(
visible: this.showMenu,
visible: Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageIndex,
maintainSize: true,
maintainAnimation: true,
maintainState: true,
@ -164,12 +163,12 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
// For desktop...
onHover: (event) {
setState(() {
this.showMenu = true;
Provider.of<AppState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context).messageIndex;
});
},
onExit: (event) {
setState(() {
this.showMenu = false;
Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
});
},
child: GestureDetector(