Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.2.0 (Oct 29, 2025)

### Features
- Added a `navigatorKey` parameter in `SendbirdUIKit.init()` to show the delayed connecting dialog

## v1.1.0 (Jul 30, 2025)

### Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Add following dependencies and fonts for `SendbirdIcons` in `pubspec.yaml`.

```yaml
dependencies:
sendbird_uikit: ^1.1.0
sendbird_chat_sdk: ^4.5.1
sendbird_uikit: ^1.2.0
sendbird_chat_sdk: ^4.7.0

flutter:
fonts:
Expand Down
Binary file modified lib/fonts/SendbirdIcons.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class SBUBottomSheetUserComponentState
..name = ''
..isDistinct = false,
).then((channel) {
Navigator.pop(context);
if (context.mounted) {
Navigator.pop(context);
}

on1On1ChannelCreated(channel);
});
Expand Down
181 changes: 181 additions & 0 deletions lib/src/internal/component/dialog/sbu_delayed_connecting_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// Copyright (c) 2025 Sendbird, Inc. All rights reserved.

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sendbird_uikit/sendbird_uikit.dart';
import 'package:sendbird_uikit/src/internal/component/base/sbu_base_component.dart';
import 'package:sendbird_uikit/src/internal/component/basic/sbu_text_button_component.dart';
import 'package:sendbird_uikit/src/internal/component/basic/sbu_text_component.dart';
import 'package:sendbird_uikit/src/internal/resource/sbu_text_styles.dart';
import 'package:sendbird_uikit/src/internal/utils/sbu_time_extensions.dart';

class SBUDelayedConnectingDialog extends SBUStatefulComponent {
final int retryAfter;
final bool showCloseButton;
final void Function()? onCloseButtonClicked;
final String? closeButtonText;

const SBUDelayedConnectingDialog({
required this.retryAfter,
this.showCloseButton = false,
this.onCloseButtonClicked,
this.closeButtonText,
super.key,
});

@override
State<StatefulWidget> createState() => SBUDelayedConnectingDialogState();
}

class SBUDelayedConnectingDialogState
extends State<SBUDelayedConnectingDialog> {
late int currentRetryAfter;
late final DateTime startTime;
Timer? _timer;

@override
void initState() {
super.initState();
currentRetryAfter = widget.retryAfter;
startTime = DateTime.now();
_startTimer();
}

void _startTimer() {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
updateRetryAfter();
if (currentRetryAfter <= 0) {
_timer?.cancel();
}
});
}

@override
void dispose() {
_timer?.cancel();
super.dispose();
}

void updateRetryAfter() {
final now = DateTime.now();
final elapsedTime = now.difference(startTime).inMilliseconds;
final updatedRetryAfter = widget.retryAfter - elapsedTime / 1000;

setState(() {
currentRetryAfter = updatedRetryAfter > 0 ? updatedRetryAfter.ceil() : 0;
});
}

@override
Widget build(BuildContext context) {
final isLightTheme = context.watch<SBUThemeProvider>().isLight();
final strings = context.watch<SBUStringProvider>().strings;

return PopScope(
canPop: false,
child: Container(
width: double.maxFinite,
height: double.maxFinite,
color: SBUColors.overlayLight,
child: Center(
child: Container(
width: 280,
decoration: BoxDecoration(
color: isLightTheme
? SBUColors.background50
: SBUColors.background500,
borderRadius: const BorderRadius.all(Radius.circular(4)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: DefaultTextStyle.merge(
style: kIsWeb
? const TextStyle(decoration: TextDecoration.none)
: null,
child: SBUTextComponent(
text: strings.youWillBeReconnectedShortly,
textType: SBUTextType.heading1,
textColorType: SBUTextColorType.text01,
maxLines: 3,
),
),
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: DefaultTextStyle.merge(
style: kIsWeb
? const TextStyle(decoration: TextDecoration.none)
: null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
SBUTextComponent(
text: currentRetryAfter > 0
? strings.estimatedWaitingTime
: '',
textType: SBUTextType.body3,
textColorType: SBUTextColorType.text02,
),
const SizedBox(width: 4),
SBUTextComponent(
text: currentRetryAfter > 0
? currentRetryAfter.toTimeString()
: '',
textType: SBUTextType.body3Bold,
textColorType: SBUTextColorType.text02,
),
],
),
),
),
const SizedBox(height: 24),
if (widget.showCloseButton)
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
margin: const EdgeInsets.only(right: 8, bottom: 4),
child: DefaultTextStyle.merge(
style: kIsWeb
? const TextStyle(
decoration: TextDecoration.none)
: null,
child: SBUTextButtonComponent(
height: 32,
padding: const EdgeInsets.all(8),
text: SBUTextComponent(
text: (widget.closeButtonText != null)
? widget.closeButtonText!
: strings.close,
textType: SBUTextType.button,
textColorType: SBUTextColorType.primary,
),
onButtonClicked: () async {
Navigator.pop(context);

if (widget.onCloseButtonClicked != null) {
widget.onCloseButtonClicked!();
}
},
),
),
),
],
),
const SizedBox(height: 12),
],
),
),
),
));
}
}
11 changes: 11 additions & 0 deletions lib/src/internal/resource/sbu_text_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum SBUTextType {
body1,
body2,
body3,
body3Bold,
button,
caption1,
caption2,
Expand Down Expand Up @@ -123,6 +124,16 @@ class SBUTextStyles {
decorationThickness: 0,
leadingDistribution: TextLeadingDistribution.even,
);
case SBUTextType.body3Bold:
return TextStyle(
fontFamily: fontFamily,
fontWeight: FontWeight.w700,
fontSize: 14,
height: 1.428,
color: color,
decorationThickness: 0,
leadingDistribution: TextLeadingDistribution.even,
);
case SBUTextType.button:
return TextStyle(
fontFamily: fontFamily,
Expand Down
18 changes: 18 additions & 0 deletions lib/src/internal/utils/sbu_time_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2025 Sendbird, Inc. All rights reserved.

extension SBUTimeExtensions on int {
String toTimeString() {
final int hours = this ~/ 3600;
final int minutes = (this % 3600) ~/ 60;
final int seconds = this % 60;

if (hours == 0) {
return '${minutes.toString().padLeft(2, '0')}:'
'${seconds.toString().padLeft(2, '0')}';
}

return '${hours.toString().padLeft(2, '0')}:'
'${minutes.toString().padLeft(2, '0')}:'
'${seconds.toString().padLeft(2, '0')}';
}
}
Loading