[UIKit] Ui changes for upload_progress_indicator

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-02-17 17:55:13 +05:30
parent d5e9cec305
commit aa44d5840c
6 changed files with 43 additions and 45 deletions
@@ -113,13 +113,17 @@ class _InProgressState extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
_IconButton( Align(
icon: StreamSvgIcon.close( alignment: Alignment.topRight,
color: StreamChatTheme.of(context).colorTheme.white, child: _IconButton(
icon: StreamSvgIcon.close(
color: StreamChatTheme.of(context).colorTheme.white,
),
onPressed: () => channel.cancelAttachmentUpload(attachmentId),
), ),
onPressed: () => channel.cancelAttachmentUpload(attachmentId),
), ),
Center( Align(
alignment: Alignment.topRight,
child: UploadProgressIndicator( child: UploadProgressIndicator(
uploaded: sent, uploaded: sent,
total: total, total: total,
@@ -242,12 +242,7 @@ class FileAttachment extends AttachmentWidget {
progressIndicatorColor: theme.colorTheme.accentBlue, progressIndicatorColor: theme.colorTheme.accentBlue,
); );
}, },
success: () { success: () => Text('${fileSize(size, 2)}', style: textStyle),
return Text(
'${fileSize(size, 1)}/${fileSize(size, 1)}',
style: textStyle,
);
},
failed: (_) => Text('UPLOAD ERROR', style: textStyle), failed: (_) => Text('UPLOAD ERROR', style: textStyle),
) ?? ) ??
Text('${fileSize(size)}', style: textStyle); Text('${fileSize(size)}', style: textStyle);
@@ -86,11 +86,7 @@ class VideoAttachment extends AttachmentWidget {
}, },
child: Stack( child: Stack(
children: [ children: [
Container( videoWidget,
height: size?.height,
width: size?.width,
child: videoWidget,
),
Center( Center(
child: Material( child: Material(
shape: CircleBorder(), shape: CircleBorder(),
@@ -1653,13 +1653,11 @@ class MessageInputState extends State<MessageInput> {
case 'video': case 'video':
return Stack( return Stack(
children: [ children: [
Container( VideoThumbnailImage(
height: 104, height: 104,
width: 104, width: 104,
child: VideoThumbnailImage( video: attachment.file?.path ?? attachment.assetUrl,
video: attachment.file.path, fit: BoxFit.cover,
fit: BoxFit.cover,
),
), ),
Positioned( Positioned(
left: 8, left: 8,
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'stream_chat_theme.dart'; import 'stream_chat_theme.dart';
import 'utils.dart';
class UploadProgressIndicator extends StatelessWidget { class UploadProgressIndicator extends StatelessWidget {
final int uploaded; final int uploaded;
@@ -24,6 +23,7 @@ class UploadProgressIndicator extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = StreamChatTheme.of(context); final theme = StreamChatTheme.of(context);
final _percentage = (uploaded / total) * 100;
Widget child = Padding( Widget child = Padding(
padding: padding, padding: padding,
child: Row( child: Row(
@@ -39,7 +39,7 @@ class UploadProgressIndicator extends StatelessWidget {
), ),
SizedBox(width: 8), SizedBox(width: 8),
Text( Text(
'${fileSize(uploaded, 1)}/${fileSize(total, 1)}', '${_percentage.toInt()}%',
style: textStyle ?? style: textStyle ??
theme.textTheme.footnote.copyWith( theme.textTheme.footnote.copyWith(
color: theme.colorTheme.white, color: theme.colorTheme.white,
@@ -58,28 +58,33 @@ class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
return FutureBuilder<Uint8List>( return FutureBuilder<Uint8List>(
future: thumbnailFuture, future: thumbnailFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasError) { return AnimatedSwitcher(
if (widget.errorBuilder != null) { duration: const Duration(milliseconds: 350),
return widget.errorBuilder(context, snapshot.error); child: Builder(
} key: ValueKey<AsyncSnapshot<Uint8List>>(snapshot),
return Center(child: StreamSvgIcon.error()); builder: (_) {
} if (snapshot.hasError) {
if (!snapshot.hasData) { return widget.errorBuilder?.call(context, snapshot.error) ??
if (widget.placeholderBuilder != null) { Center(child: StreamSvgIcon.error());
return widget.placeholderBuilder(context); }
} if (!snapshot.hasData) {
return Image.asset( return widget.placeholderBuilder?.call(context) ??
'images/placeholder.png', Image.asset(
package: 'stream_chat_flutter', 'images/placeholder.png',
fit: widget.fit, package: 'stream_chat_flutter',
); fit: widget.fit,
} height: widget.height,
final data = snapshot.data; width: widget.width,
return Image.memory( );
data, }
fit: widget.fit, return Image.memory(
height: widget.height, snapshot.data,
width: widget.width, fit: widget.fit,
height: widget.height,
width: widget.width,
);
},
),
); );
}, },
); );