lint changes
This commit is contained in:
@@ -2,16 +2,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_portal/flutter_portal.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||
|
||||
/// Tile to display a message, used in stream chat to display connection status
|
||||
class InfoTile extends StatelessWidget {
|
||||
final String message;
|
||||
final Widget child;
|
||||
final bool showMessage;
|
||||
final Alignment? tileAnchor;
|
||||
final Alignment? childAnchor;
|
||||
final TextStyle? textStyle;
|
||||
final Color? backgroundColor;
|
||||
|
||||
/// Constructor for creating an [InfoTile] widget
|
||||
const InfoTile({
|
||||
Key? key,
|
||||
required this.message,
|
||||
required this.child,
|
||||
required this.showMessage,
|
||||
@@ -19,11 +14,31 @@ class InfoTile extends StatelessWidget {
|
||||
this.childAnchor,
|
||||
this.textStyle,
|
||||
this.backgroundColor,
|
||||
});
|
||||
}) : super(key: key);
|
||||
|
||||
/// String to display
|
||||
final String message;
|
||||
|
||||
/// Widget to display over
|
||||
final Widget child;
|
||||
|
||||
/// Flag to show message
|
||||
final bool showMessage;
|
||||
|
||||
/// Anchor for tile - [portalAnchor] for [PortalEntry]
|
||||
final Alignment? tileAnchor;
|
||||
|
||||
/// Alignment for child - [childAnchor] for [PortalEntry]
|
||||
final Alignment? childAnchor;
|
||||
|
||||
/// [TextStyle] for message
|
||||
final TextStyle? textStyle;
|
||||
|
||||
/// Background color for tile
|
||||
final Color? backgroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PortalEntry(
|
||||
Widget build(BuildContext context) => PortalEntry(
|
||||
visible: showMessage,
|
||||
portalAnchor: tileAnchor ?? Alignment.topCenter,
|
||||
childAnchor: childAnchor ?? Alignment.bottomCenter,
|
||||
@@ -46,4 +61,3 @@ class InfoTile extends StatelessWidget {
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
|
||||
|
||||
import '../stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
extension on Duration {
|
||||
String format() {
|
||||
@@ -19,16 +18,21 @@ extension on Duration {
|
||||
}
|
||||
}
|
||||
|
||||
/// Constructs a list of media
|
||||
class MediaListView extends StatefulWidget {
|
||||
final List<String> selectedIds;
|
||||
final void Function(AssetEntity media)? onSelect;
|
||||
|
||||
/// Constructor for creating a [MediaListView] widget
|
||||
const MediaListView({
|
||||
Key? key,
|
||||
this.selectedIds = const [],
|
||||
this.onSelect,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Stores the media selected
|
||||
final List<String> selectedIds;
|
||||
|
||||
/// Callback for on media selected
|
||||
final void Function(AssetEntity media)? onSelect;
|
||||
|
||||
@override
|
||||
_MediaListViewState createState() => _MediaListViewState();
|
||||
}
|
||||
@@ -39,13 +43,12 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
int _currentPage = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LazyLoadScrollView(
|
||||
Widget build(BuildContext context) => LazyLoadScrollView(
|
||||
onEndOfPage: () async => _getMedia(),
|
||||
child: GridView.builder(
|
||||
itemCount: _media.length,
|
||||
controller: _scrollController,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
),
|
||||
itemBuilder: (
|
||||
@@ -66,8 +69,8 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: FadeInImage(
|
||||
fadeInDuration: Duration(milliseconds: 300),
|
||||
placeholder: AssetImage(
|
||||
fadeInDuration: const Duration(milliseconds: 300),
|
||||
placeholder: const AssetImage(
|
||||
'images/placeholder.png',
|
||||
package: 'stream_chat_flutter',
|
||||
),
|
||||
@@ -80,8 +83,9 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: AnimatedOpacity(
|
||||
duration: Duration(milliseconds: 300),
|
||||
opacity: widget.selectedIds.any((id) => id == media.id)
|
||||
duration: const Duration(milliseconds: 300),
|
||||
opacity:
|
||||
widget.selectedIds.any((id) => id == media.id)
|
||||
? 1.0
|
||||
: 0.0,
|
||||
child: Container(
|
||||
@@ -100,8 +104,9 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
StreamChatTheme.of(context).colorTheme.white,
|
||||
child: StreamSvgIcon.check(
|
||||
size: 24,
|
||||
color:
|
||||
StreamChatTheme.of(context).colorTheme.black,
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -135,7 +140,6 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -165,36 +169,38 @@ class _MediaListViewState extends State<MediaListView> {
|
||||
}
|
||||
}
|
||||
|
||||
/// ImageProvider implementation
|
||||
class MediaThumbnailProvider extends ImageProvider<MediaThumbnailProvider> {
|
||||
/// Constructor for creating a [MediaThumbnailProvider]
|
||||
const MediaThumbnailProvider({
|
||||
required this.media,
|
||||
});
|
||||
|
||||
/// Media to load
|
||||
final AssetEntity media;
|
||||
|
||||
@override
|
||||
ImageStreamCompleter load(key, decode) {
|
||||
return MultiFrameImageStreamCompleter(
|
||||
ImageStreamCompleter load(
|
||||
MediaThumbnailProvider key, DecoderCallback decode) =>
|
||||
MultiFrameImageStreamCompleter(
|
||||
codec: _loadAsync(key, decode),
|
||||
scale: 1,
|
||||
informationCollector: () sync* {
|
||||
yield ErrorDescription('Id: ${media.id}');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<ui.Codec> _loadAsync(
|
||||
MediaThumbnailProvider key, DecoderCallback decode) async {
|
||||
assert(key == this);
|
||||
assert(key == this, 'Checks MediaThumbnailProvider');
|
||||
final bytes = await media.thumbData;
|
||||
|
||||
return await decode(bytes!);
|
||||
return decode(bytes!);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MediaThumbnailProvider> obtainKey(ImageConfiguration configuration) {
|
||||
return SynchronousFuture<MediaThumbnailProvider>(this);
|
||||
}
|
||||
Future<MediaThumbnailProvider> obtainKey(ImageConfiguration configuration) =>
|
||||
SynchronousFuture<MediaThumbnailProvider>(this);
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
|
||||
@@ -3,8 +3,19 @@ import 'package:flutter/material.dart';
|
||||
import '../stream_chat_flutter.dart';
|
||||
|
||||
/// This widget is used for showing user tiles for mentions
|
||||
/// Use [title], [subtitle], [leading], [trailing] for substituting widgets in respective positions
|
||||
/// Use [title], [subtitle], [leading], [trailing] for
|
||||
/// substituting widgets in respective positions
|
||||
class MentionTile extends StatelessWidget {
|
||||
/// Constructor for creating a [MentionTile] widget
|
||||
const MentionTile(
|
||||
this.member, {
|
||||
Key? key,
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.leading,
|
||||
this.trailing,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Member to display in the tile
|
||||
final Member member;
|
||||
|
||||
@@ -20,34 +31,25 @@ class MentionTile extends StatelessWidget {
|
||||
/// Widget at the end of tile
|
||||
final Widget? trailing;
|
||||
|
||||
const MentionTile(
|
||||
this.member, {
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.leading,
|
||||
this.trailing,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
height: 56,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
leading ??
|
||||
UserAvatar(
|
||||
constraints: BoxConstraints.tight(
|
||||
Size(
|
||||
const Size(
|
||||
40,
|
||||
40,
|
||||
),
|
||||
),
|
||||
user: member.user!,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Expanded(
|
||||
@@ -64,7 +66,7 @@ class MentionTile extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: StreamChatTheme.of(context).textTheme.bodyBold,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
subtitle ??
|
||||
@@ -98,4 +100,3 @@ class MentionTile extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,13 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
/// Class describing a message action
|
||||
class MessageAction {
|
||||
/// returns a new instance of a [MessageAction]
|
||||
MessageAction({
|
||||
this.leading,
|
||||
this.title,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
/// leading widget
|
||||
final Widget? leading;
|
||||
|
||||
@@ -11,11 +18,4 @@ class MessageAction {
|
||||
|
||||
/// callback called on tap
|
||||
final OnMessageTap? onTap;
|
||||
|
||||
/// returns a new instance of a [MessageAction]
|
||||
MessageAction({
|
||||
this.leading,
|
||||
this.title,
|
||||
this.onTap,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user