feat: add MessageListView.reverse property
This commit is contained in:
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
|
|||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 30
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
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).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.example.example"
|
applicationId "com.example.example"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 30
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.50'
|
ext.kotlin_version = '1.5.20'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -166,11 +167,19 @@ class MessageListView extends StatefulWidget {
|
|||||||
this.showFloatingDateDivider = true,
|
this.showFloatingDateDivider = true,
|
||||||
this.threadSeparatorBuilder,
|
this.threadSeparatorBuilder,
|
||||||
this.messageListController,
|
this.messageListController,
|
||||||
|
this.reverse = false,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Function used to build a custom message widget
|
/// Function used to build a custom message widget
|
||||||
final MessageBuilder? messageBuilder;
|
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
|
/// Function used to build a custom system message widget
|
||||||
final SystemMessageBuilder? systemMessageBuilder;
|
final SystemMessageBuilder? systemMessageBuilder;
|
||||||
|
|
||||||
@@ -445,7 +454,7 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
initialAlignment: initialAlignment ?? 0,
|
initialAlignment: initialAlignment ?? 0,
|
||||||
physics: widget.scrollPhysics,
|
physics: widget.scrollPhysics,
|
||||||
itemScrollController: _scrollController,
|
itemScrollController: _scrollController,
|
||||||
reverse: true,
|
reverse: widget.reverse,
|
||||||
addAutomaticKeepAlives: false,
|
addAutomaticKeepAlives: false,
|
||||||
itemCount: itemCount,
|
itemCount: itemCount,
|
||||||
|
|
||||||
@@ -608,7 +617,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Positioned _buildFloatingDateDivider(int itemCount) => Positioned(
|
Positioned _buildFloatingDateDivider(int itemCount) => Positioned(
|
||||||
top: 20,
|
top: widget.reverse ? 20 : null,
|
||||||
|
bottom: widget.reverse ? null : 20,
|
||||||
child: BetterStreamBuilder<Iterable<ItemPosition>>(
|
child: BetterStreamBuilder<Iterable<ItemPosition>>(
|
||||||
initialData: _itemPositionListener.itemPositions.value,
|
initialData: _itemPositionListener.itemPositions.value,
|
||||||
stream: _itemPositionStream,
|
stream: _itemPositionStream,
|
||||||
@@ -700,8 +710,11 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: StreamSvgIcon.down(
|
child: Transform.rotate(
|
||||||
color: _streamTheme.colorTheme.textHighEmphasis,
|
angle: widget.reverse ? 0 : pi,
|
||||||
|
child: StreamSvgIcon.down(
|
||||||
|
color: _streamTheme.colorTheme.textHighEmphasis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (showUnreadCount)
|
if (showUnreadCount)
|
||||||
|
|||||||
Reference in New Issue
Block a user