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