feat: add MessageListView.reverse property

This commit is contained in:
Salvatore Giordano
2021-07-20 10:54:20 +02:00
parent 4f3c44f6f7
commit 069ec910a6
4 changed files with 22 additions and 9 deletions
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@@ -41,7 +41,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
@@ -1,5 +1,6 @@
// ignore_for_file: lines_longer_than_80_chars
import 'dart:async';
import 'dart:math';
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
@@ -166,11 +167,19 @@ class MessageListView extends StatefulWidget {
this.showFloatingDateDivider = true,
this.threadSeparatorBuilder,
this.messageListController,
this.reverse = false,
}) : super(key: key);
/// Function used to build a custom message widget
final MessageBuilder? messageBuilder;
/// Whether the view scrolls in the reading direction.
///
/// Defaults to true.
///
/// See [ScrollView.reverse].
final bool reverse;
/// Function used to build a custom system message widget
final SystemMessageBuilder? systemMessageBuilder;
@@ -445,7 +454,7 @@ class _MessageListViewState extends State<MessageListView> {
initialAlignment: initialAlignment ?? 0,
physics: widget.scrollPhysics,
itemScrollController: _scrollController,
reverse: true,
reverse: widget.reverse,
addAutomaticKeepAlives: false,
itemCount: itemCount,
@@ -608,7 +617,8 @@ class _MessageListViewState extends State<MessageListView> {
}
Positioned _buildFloatingDateDivider(int itemCount) => Positioned(
top: 20,
top: widget.reverse ? 20 : null,
bottom: widget.reverse ? null : 20,
child: BetterStreamBuilder<Iterable<ItemPosition>>(
initialData: _itemPositionListener.itemPositions.value,
stream: _itemPositionStream,
@@ -700,8 +710,11 @@ class _MessageListViewState extends State<MessageListView> {
);
}
},
child: StreamSvgIcon.down(
color: _streamTheme.colorTheme.textHighEmphasis,
child: Transform.rotate(
angle: widget.reverse ? 0 : pi,
child: StreamSvgIcon.down(
color: _streamTheme.colorTheme.textHighEmphasis,
),
),
),
if (showUnreadCount)