Improve Message Row Highlight/Performance Rendering
continuous-integration/drone/pr Build was killed
Details
continuous-integration/drone/pr Build was killed
Details
This commit is contained in:
parent
9c89c93013
commit
605e9c08c6
|
@ -12,8 +12,6 @@ class AppState extends ChangeNotifier {
|
||||||
String? _selectedProfile;
|
String? _selectedProfile;
|
||||||
int? _selectedConversation;
|
int? _selectedConversation;
|
||||||
int _initialScrollIndex = 0;
|
int _initialScrollIndex = 0;
|
||||||
int _hoveredIndex = -1;
|
|
||||||
int? _selectedIndex;
|
|
||||||
bool _unreadMessagesBelow = false;
|
bool _unreadMessagesBelow = false;
|
||||||
bool _disableFilePicker = false;
|
bool _disableFilePicker = false;
|
||||||
bool _focus = true;
|
bool _focus = true;
|
||||||
|
@ -59,14 +57,6 @@ class AppState extends ChangeNotifier {
|
||||||
notifyListeners();
|
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;
|
bool get unreadMessagesBelow => _unreadMessagesBelow;
|
||||||
set unreadMessagesBelow(bool newVal) {
|
set unreadMessagesBelow(bool newVal) {
|
||||||
this._unreadMessagesBelow = newVal;
|
this._unreadMessagesBelow = newVal;
|
||||||
|
|
|
@ -66,6 +66,8 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
String? _acnCircuit;
|
String? _acnCircuit;
|
||||||
MessageDraft _messageDraft = MessageDraft.empty();
|
MessageDraft _messageDraft = MessageDraft.empty();
|
||||||
|
|
||||||
|
var _hoveredIndex = -1;
|
||||||
|
|
||||||
ContactInfoState(
|
ContactInfoState(
|
||||||
this.profileOnion,
|
this.profileOnion,
|
||||||
this.identifier,
|
this.identifier,
|
||||||
|
@ -405,6 +407,14 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
return this.nickname + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" + this.statusString(context) + ")");
|
return this.nickname + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" + this.statusString(context) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
String statusString(BuildContext context) {
|
String statusString(BuildContext context) {
|
||||||
switch (this.availabilityStatus) {
|
switch (this.availabilityStatus) {
|
||||||
case ProfileStatusMenu.available:
|
case ProfileStatusMenu.available:
|
||||||
|
|
|
@ -50,7 +50,7 @@ void selectConversation(BuildContext context, int handle) {
|
||||||
// triggers update in Double/TripleColumnView
|
// triggers update in Double/TripleColumnView
|
||||||
Provider.of<AppState>(context, listen: false).initialScrollIndex = unread;
|
Provider.of<AppState>(context, listen: false).initialScrollIndex = unread;
|
||||||
Provider.of<AppState>(context, listen: false).selectedConversation = handle;
|
Provider.of<AppState>(context, listen: false).selectedConversation = handle;
|
||||||
Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
|
Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = -1;
|
||||||
// if in singlepane mode, push to the stack
|
// if in singlepane mode, push to the stack
|
||||||
var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context);
|
var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context);
|
||||||
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);
|
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);
|
||||||
|
|
|
@ -17,11 +17,9 @@ import 'package:cwtch/models/profile.dart';
|
||||||
import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
|
import 'package:cwtch/third_party/linkify/flutter_linkify.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/messagerow.dart';
|
|
||||||
import 'package:cwtch/widgets/profileimage.dart';
|
import 'package:cwtch/widgets/profileimage.dart';
|
||||||
import 'package:cwtch/controllers/filesharing.dart' as filesharing;
|
import 'package:cwtch/controllers/filesharing.dart' as filesharing;
|
||||||
import 'package:cwtch/widgets/staticmessagebubble.dart';
|
import 'package:cwtch/widgets/staticmessagebubble.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cwtch/config.dart';
|
||||||
import 'package:cwtch/models/appstate.dart';
|
import 'package:cwtch/models/appstate.dart';
|
||||||
import 'package:cwtch/models/contact.dart';
|
import 'package:cwtch/models/contact.dart';
|
||||||
import 'package:cwtch/models/message.dart';
|
import 'package:cwtch/models/message.dart';
|
||||||
|
|
|
@ -81,7 +81,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
Widget wdgReply = Platform.isAndroid
|
Widget wdgReply = Platform.isAndroid
|
||||||
? SizedBox.shrink()
|
? SizedBox.shrink()
|
||||||
: Visibility(
|
: Visibility(
|
||||||
visible: EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
|
visible: EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
|
||||||
maintainSize: true,
|
maintainSize: true,
|
||||||
maintainAnimation: true,
|
maintainAnimation: true,
|
||||||
maintainState: true,
|
maintainState: true,
|
||||||
|
@ -106,7 +106,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
Widget wdgSeeReplies = Platform.isAndroid
|
Widget wdgSeeReplies = Platform.isAndroid
|
||||||
? SizedBox.shrink()
|
? SizedBox.shrink()
|
||||||
: Visibility(
|
: Visibility(
|
||||||
visible: EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
|
visible: EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
|
||||||
maintainSize: true,
|
maintainSize: true,
|
||||||
maintainAnimation: true,
|
maintainAnimation: true,
|
||||||
maintainState: true,
|
maintainState: true,
|
||||||
|
@ -128,8 +128,8 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
: Visibility(
|
: Visibility(
|
||||||
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() &&
|
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() &&
|
||||||
Provider.of<Settings>(context).isExperimentEnabled(BlodeuweddExperiment) &&
|
Provider.of<Settings>(context).isExperimentEnabled(BlodeuweddExperiment) &&
|
||||||
(EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID),
|
(EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID),
|
||||||
maintainSize: false,
|
maintainSize: true,
|
||||||
maintainAnimation: true,
|
maintainAnimation: true,
|
||||||
maintainState: true,
|
maintainState: true,
|
||||||
maintainInteractivity: false,
|
maintainInteractivity: false,
|
||||||
|
@ -245,16 +245,12 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
var mr = MouseRegion(
|
var mr = MouseRegion(
|
||||||
// For desktop...
|
// For desktop...
|
||||||
onHover: (event) {
|
onHover: (event) {
|
||||||
if (Provider.of<AppState>(context, listen: false).hoveredIndex != Provider.of<MessageMetadata>(context, listen: false).messageID) {
|
if (Provider.of<ContactInfoState>(context, listen: false).hoveredIndex != Provider.of<MessageMetadata>(context, listen: false).messageID) {
|
||||||
setState(() {
|
Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||||
Provider.of<AppState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onExit: (event) {
|
onExit: (event) {
|
||||||
// setState(() {
|
Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = -1;
|
||||||
// Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
|
|
||||||
//});
|
|
||||||
},
|
},
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onPanUpdate: (details) {
|
onPanUpdate: (details) {
|
||||||
|
@ -270,12 +266,16 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
},
|
},
|
||||||
onPanEnd: (details) {
|
onPanEnd: (details) {
|
||||||
_runAnimation(details.velocity.pixelsPerSecond, size);
|
_runAnimation(details.velocity.pixelsPerSecond, size);
|
||||||
Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
if (Platform.isAndroid) {
|
||||||
Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate();
|
Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||||
setState(() {});
|
Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLongPress: () async {
|
onLongPress: () async {
|
||||||
modalShowReplies(context, AppLocalizations.of(context)!.headingReplies, AppLocalizations.of(context)!.messageNoReplies, settings, pis, cis, borderColor, cache, messageID);
|
if (Platform.isAndroid) {
|
||||||
|
modalShowReplies(context, AppLocalizations.of(context)!.headingReplies, AppLocalizations.of(context)!.messageNoReplies, settings, pis, cis, borderColor, cache, messageID);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(2),
|
padding: EdgeInsets.all(2),
|
||||||
|
|
Loading…
Reference in New Issue