fix: Scrolling in fragmented timeline
This commit is contained in:
parent
53af09227f
commit
cacb944918
4 changed files with 45 additions and 43 deletions
|
|
@ -224,9 +224,14 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
final timeline = this.timeline;
|
final timeline = this.timeline;
|
||||||
if (timeline == null) return;
|
if (timeline == null) return;
|
||||||
Logs().v('Requesting future...');
|
Logs().v('Requesting future...');
|
||||||
final mostRecentEventId = timeline.events.first.eventId;
|
|
||||||
|
final mostRecentEvent = timeline.events.filterByVisibleInGui().firstOrNull;
|
||||||
|
|
||||||
await timeline.requestFuture(historyCount: _loadHistoryCount);
|
await timeline.requestFuture(historyCount: _loadHistoryCount);
|
||||||
setReadMarker(eventId: mostRecentEventId);
|
|
||||||
|
if (mostRecentEvent != null) {
|
||||||
|
setReadMarker(eventId: mostRecentEvent.eventId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateScrollController() {
|
void _updateScrollController() {
|
||||||
|
|
@ -241,11 +246,6 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
setState(() => _scrolledUp = false);
|
setState(() => _scrolledUp = false);
|
||||||
setReadMarker();
|
setReadMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollController.position.pixels == 0 ||
|
|
||||||
scrollController.position.pixels == 64) {
|
|
||||||
requestFuture();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadDraft() async {
|
void _loadDraft() async {
|
||||||
|
|
@ -458,7 +458,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
|
|
||||||
void onInsert(int i) {
|
void onInsert(int i) {
|
||||||
// setState will be called by updateView() anyway
|
// setState will be called by updateView() anyway
|
||||||
animateInEventIndex = i;
|
if (i <= 5) animateInEventIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getTimeline({String? eventContextId}) async {
|
Future<void> _getTimeline({String? eventContextId}) async {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
|
import 'package:fluffychat/l10n/l10n.dart';
|
||||||
import 'package:fluffychat/pages/chat/chat.dart';
|
import 'package:fluffychat/pages/chat/chat.dart';
|
||||||
import 'package:fluffychat/pages/chat/events/message.dart';
|
import 'package:fluffychat/pages/chat/events/message.dart';
|
||||||
import 'package:fluffychat/pages/chat/seen_by_row.dart';
|
import 'package:fluffychat/pages/chat/seen_by_row.dart';
|
||||||
|
|
@ -63,16 +64,16 @@ class ChatEventList extends StatelessWidget {
|
||||||
(BuildContext context, int i) {
|
(BuildContext context, int i) {
|
||||||
// Footer to display typing indicator and read receipts:
|
// Footer to display typing indicator and read receipts:
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (timeline.isRequestingFuture) {
|
|
||||||
return const Center(
|
|
||||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (timeline.canRequestFuture) {
|
if (timeline.canRequestFuture) {
|
||||||
return Center(
|
return Center(
|
||||||
child: IconButton(
|
child: TextButton.icon(
|
||||||
onPressed: controller.requestFuture,
|
onPressed: timeline.isRequestingFuture
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
? null
|
||||||
|
: controller.requestFuture,
|
||||||
|
icon: timeline.isRequestingFuture
|
||||||
|
? CircularProgressIndicator.adaptive(strokeWidth: 2)
|
||||||
|
: const Icon(Icons.arrow_downward_outlined),
|
||||||
|
label: Text(L10n.of(context).loadMore),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -101,16 +102,14 @@ class ChatEventList extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Center(
|
return Center(
|
||||||
child: AnimatedSwitcher(
|
child: TextButton.icon(
|
||||||
duration: FluffyThemes.animationDuration,
|
onPressed: timeline.isRequestingHistory
|
||||||
child: timeline.canRequestHistory
|
? null
|
||||||
? IconButton(
|
: controller.requestHistory,
|
||||||
onPressed: controller.requestHistory,
|
icon: timeline.isRequestingHistory
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
? CircularProgressIndicator.adaptive(strokeWidth: 2)
|
||||||
)
|
: const Icon(Icons.arrow_upward_outlined),
|
||||||
: const CircularProgressIndicator.adaptive(
|
label: Text(L10n.of(context).loadMore),
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -289,8 +289,6 @@ class ChatView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButtonLocation:
|
|
||||||
FloatingActionButtonLocation.miniCenterFloat,
|
|
||||||
floatingActionButton:
|
floatingActionButton:
|
||||||
controller.showScrollDownButton &&
|
controller.showScrollDownButton &&
|
||||||
controller.selectedEvents.isEmpty
|
controller.selectedEvents.isEmpty
|
||||||
|
|
|
||||||
|
|
@ -544,22 +544,27 @@ class MatrixPill extends StatelessWidget {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
splashColor: Colors.transparent,
|
splashColor: Colors.transparent,
|
||||||
onTap: UrlLauncher(outerContext, uri).launchUrl,
|
onTap: UrlLauncher(outerContext, uri).launchUrl,
|
||||||
child: Row(
|
child: Text.rich(
|
||||||
mainAxisSize: .min,
|
TextSpan(
|
||||||
children: [
|
children: [
|
||||||
Avatar(mxContent: avatar, name: name, size: 16),
|
WidgetSpan(
|
||||||
const SizedBox(width: 6),
|
child: Padding(
|
||||||
Text(
|
padding: const EdgeInsets.only(right: 4.0),
|
||||||
name,
|
child: Avatar(mxContent: avatar, name: name, size: 16),
|
||||||
style: TextStyle(
|
),
|
||||||
color: color,
|
|
||||||
decorationColor: color,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
fontSize: fontSize,
|
|
||||||
height: 1.25,
|
|
||||||
),
|
),
|
||||||
),
|
TextSpan(
|
||||||
],
|
text: name,
|
||||||
|
style: TextStyle(
|
||||||
|
color: color,
|
||||||
|
decorationColor: color,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
fontSize: fontSize,
|
||||||
|
height: 1.25,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue