Skip to content

Commit 46f4f64

Browse files
committed
feat: fix loading icon size
1 parent 195bc21 commit 46f4f64

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

packages/stream_chat_flutter/example/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class _ChannelPageState extends State<ChannelPage> {
333333
),
334334
),
335335
StreamMessageInput(
336+
enableVoiceRecording: true,
336337
onQuotedMessageCleared:
337338
messageInputController.clearQuotedMessage,
338339
focusNode: focusNode,
@@ -381,6 +382,7 @@ class ThreadPage extends StatelessWidget {
381382
),
382383
),
383384
StreamMessageInput(
385+
enableVoiceRecording: true,
384386
messageInputController: StreamMessageInputController(
385387
message: Message(parentId: parent.id),
386388
),

packages/stream_chat_flutter/lib/src/attachment/voice_recording_attachment.dart

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,9 @@ class AudioControlButton extends StatelessWidget {
294294

295295
@override
296296
Widget build(BuildContext context) {
297+
final streamTheme = StreamChatTheme.of(context);
297298
final theme = StreamVoiceRecordingTheme.of(context).playerTheme;
298299

299-
final child = switch (state) {
300-
TrackState.loading => SizedBox.fromSize(
301-
size: const Size(24, 24),
302-
child: const Center(child: CircularProgressIndicator.adaptive()),
303-
),
304-
TrackState.idle => Icon(theme.playIcon, color: theme.iconColor),
305-
TrackState.playing => Icon(theme.pauseIcon, color: theme.iconColor),
306-
TrackState.paused => Icon(theme.playIcon, color: theme.iconColor),
307-
};
308-
309300
return ElevatedButton(
310301
style: ElevatedButton.styleFrom(
311302
elevation: theme.buttonElevation,
@@ -322,7 +313,21 @@ class AudioControlButton extends StatelessWidget {
322313
TrackState.playing => onPause,
323314
TrackState.paused => onPlay,
324315
},
325-
child: child,
316+
child: switch (state) {
317+
TrackState.loading => SizedBox.fromSize(
318+
size: const Size.square(24 - /* Padding */ 2),
319+
child: Center(
320+
child: CircularProgressIndicator.adaptive(
321+
valueColor: AlwaysStoppedAnimation(
322+
streamTheme.colorTheme.accentPrimary,
323+
),
324+
),
325+
),
326+
),
327+
TrackState.idle => Icon(theme.playIcon, color: theme.iconColor),
328+
TrackState.playing => Icon(theme.pauseIcon, color: theme.iconColor),
329+
TrackState.paused => Icon(theme.playIcon, color: theme.iconColor),
330+
},
326331
);
327332
}
328333
}

packages/stream_chat_flutter/lib/src/message_input/audio_recorder/stream_audio_recorder.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,23 @@ class PlaybackControlButton extends StatelessWidget {
612612

613613
return StreamMessageInputIconButton(
614614
color: theme.colorTheme.accentPrimary,
615-
onPressed: () => switch (state) {
615+
onPressed: switch (state) {
616616
TrackState.loading => null,
617-
TrackState.idle => onPlay?.call(),
618-
TrackState.playing => onPause?.call(),
619-
TrackState.paused => onPlay?.call(),
617+
TrackState.idle => onPlay,
618+
TrackState.playing => onPause,
619+
TrackState.paused => onPlay,
620620
},
621621
icon: switch (state) {
622-
TrackState.loading => const CircularProgressIndicator(),
622+
TrackState.loading => SizedBox.fromSize(
623+
size: const Size.square(24 - /* Padding */ 2),
624+
child: Center(
625+
child: CircularProgressIndicator.adaptive(
626+
valueColor: AlwaysStoppedAnimation(
627+
theme.colorTheme.accentPrimary,
628+
),
629+
),
630+
),
631+
),
623632
TrackState.idle => const StreamSvgIcon(icon: StreamSvgIcons.play),
624633
TrackState.paused => const StreamSvgIcon(icon: StreamSvgIcons.play),
625634
TrackState.playing => const StreamSvgIcon(icon: StreamSvgIcons.pause),

0 commit comments

Comments
 (0)