Skip to content

Commit 9bb5e5d

Browse files
Merge pull request #23 from sendbird/v1.2.0
Add 1.2.0.
2 parents 58bd955 + b2c8ffd commit 9bb5e5d

File tree

12 files changed

+363
-44
lines changed

12 files changed

+363
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.2.0 (Oct 29, 2025)
2+
3+
### Features
4+
- Added a `navigatorKey` parameter in `SendbirdUIKit.init()` to show the delayed connecting dialog
5+
16
## v1.1.0 (Jul 30, 2025)
27

38
### Features

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Add following dependencies and fonts for `SendbirdIcons` in `pubspec.yaml`.
3838

3939
```yaml
4040
dependencies:
41-
sendbird_uikit: ^1.1.0
42-
sendbird_chat_sdk: ^4.5.1
41+
sendbird_uikit: ^1.2.0
42+
sendbird_chat_sdk: ^4.7.0
4343

4444
flutter:
4545
fonts:

lib/fonts/SendbirdIcons.ttf

176 Bytes
Binary file not shown.

lib/src/internal/component/basic/sbu_bottom_sheet_user_component.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class SBUBottomSheetUserComponentState
8181
..name = ''
8282
..isDistinct = false,
8383
).then((channel) {
84-
Navigator.pop(context);
84+
if (context.mounted) {
85+
Navigator.pop(context);
86+
}
8587

8688
on1On1ChannelCreated(channel);
8789
});
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
// Copyright (c) 2025 Sendbird, Inc. All rights reserved.
2+
3+
import 'dart:async';
4+
5+
import 'package:flutter/foundation.dart';
6+
import 'package:flutter/material.dart';
7+
import 'package:provider/provider.dart';
8+
import 'package:sendbird_uikit/sendbird_uikit.dart';
9+
import 'package:sendbird_uikit/src/internal/component/base/sbu_base_component.dart';
10+
import 'package:sendbird_uikit/src/internal/component/basic/sbu_text_button_component.dart';
11+
import 'package:sendbird_uikit/src/internal/component/basic/sbu_text_component.dart';
12+
import 'package:sendbird_uikit/src/internal/resource/sbu_text_styles.dart';
13+
import 'package:sendbird_uikit/src/internal/utils/sbu_time_extensions.dart';
14+
15+
class SBUDelayedConnectingDialog extends SBUStatefulComponent {
16+
final int retryAfter;
17+
final bool showCloseButton;
18+
final void Function()? onCloseButtonClicked;
19+
final String? closeButtonText;
20+
21+
const SBUDelayedConnectingDialog({
22+
required this.retryAfter,
23+
this.showCloseButton = false,
24+
this.onCloseButtonClicked,
25+
this.closeButtonText,
26+
super.key,
27+
});
28+
29+
@override
30+
State<StatefulWidget> createState() => SBUDelayedConnectingDialogState();
31+
}
32+
33+
class SBUDelayedConnectingDialogState
34+
extends State<SBUDelayedConnectingDialog> {
35+
late int currentRetryAfter;
36+
late final DateTime startTime;
37+
Timer? _timer;
38+
39+
@override
40+
void initState() {
41+
super.initState();
42+
currentRetryAfter = widget.retryAfter;
43+
startTime = DateTime.now();
44+
_startTimer();
45+
}
46+
47+
void _startTimer() {
48+
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
49+
updateRetryAfter();
50+
if (currentRetryAfter <= 0) {
51+
_timer?.cancel();
52+
}
53+
});
54+
}
55+
56+
@override
57+
void dispose() {
58+
_timer?.cancel();
59+
super.dispose();
60+
}
61+
62+
void updateRetryAfter() {
63+
final now = DateTime.now();
64+
final elapsedTime = now.difference(startTime).inMilliseconds;
65+
final updatedRetryAfter = widget.retryAfter - elapsedTime / 1000;
66+
67+
setState(() {
68+
currentRetryAfter = updatedRetryAfter > 0 ? updatedRetryAfter.ceil() : 0;
69+
});
70+
}
71+
72+
@override
73+
Widget build(BuildContext context) {
74+
final isLightTheme = context.watch<SBUThemeProvider>().isLight();
75+
final strings = context.watch<SBUStringProvider>().strings;
76+
77+
return PopScope(
78+
canPop: false,
79+
child: Container(
80+
width: double.maxFinite,
81+
height: double.maxFinite,
82+
color: SBUColors.overlayLight,
83+
child: Center(
84+
child: Container(
85+
width: 280,
86+
decoration: BoxDecoration(
87+
color: isLightTheme
88+
? SBUColors.background50
89+
: SBUColors.background500,
90+
borderRadius: const BorderRadius.all(Radius.circular(4)),
91+
),
92+
child: Column(
93+
mainAxisSize: MainAxisSize.min,
94+
crossAxisAlignment: CrossAxisAlignment.start,
95+
children: [
96+
const SizedBox(height: 24),
97+
Padding(
98+
padding: const EdgeInsets.symmetric(horizontal: 24),
99+
child: DefaultTextStyle.merge(
100+
style: kIsWeb
101+
? const TextStyle(decoration: TextDecoration.none)
102+
: null,
103+
child: SBUTextComponent(
104+
text: strings.youWillBeReconnectedShortly,
105+
textType: SBUTextType.heading1,
106+
textColorType: SBUTextColorType.text01,
107+
maxLines: 3,
108+
),
109+
),
110+
),
111+
const SizedBox(height: 16),
112+
Padding(
113+
padding: const EdgeInsets.symmetric(horizontal: 24),
114+
child: DefaultTextStyle.merge(
115+
style: kIsWeb
116+
? const TextStyle(decoration: TextDecoration.none)
117+
: null,
118+
child: Row(
119+
mainAxisSize: MainAxisSize.min,
120+
children: [
121+
SBUTextComponent(
122+
text: currentRetryAfter > 0
123+
? strings.estimatedWaitingTime
124+
: '',
125+
textType: SBUTextType.body3,
126+
textColorType: SBUTextColorType.text02,
127+
),
128+
const SizedBox(width: 4),
129+
SBUTextComponent(
130+
text: currentRetryAfter > 0
131+
? currentRetryAfter.toTimeString()
132+
: '',
133+
textType: SBUTextType.body3Bold,
134+
textColorType: SBUTextColorType.text02,
135+
),
136+
],
137+
),
138+
),
139+
),
140+
const SizedBox(height: 24),
141+
if (widget.showCloseButton)
142+
Row(
143+
mainAxisAlignment: MainAxisAlignment.end,
144+
children: [
145+
Container(
146+
margin: const EdgeInsets.only(right: 8, bottom: 4),
147+
child: DefaultTextStyle.merge(
148+
style: kIsWeb
149+
? const TextStyle(
150+
decoration: TextDecoration.none)
151+
: null,
152+
child: SBUTextButtonComponent(
153+
height: 32,
154+
padding: const EdgeInsets.all(8),
155+
text: SBUTextComponent(
156+
text: (widget.closeButtonText != null)
157+
? widget.closeButtonText!
158+
: strings.close,
159+
textType: SBUTextType.button,
160+
textColorType: SBUTextColorType.primary,
161+
),
162+
onButtonClicked: () async {
163+
Navigator.pop(context);
164+
165+
if (widget.onCloseButtonClicked != null) {
166+
widget.onCloseButtonClicked!();
167+
}
168+
},
169+
),
170+
),
171+
),
172+
],
173+
),
174+
const SizedBox(height: 12),
175+
],
176+
),
177+
),
178+
),
179+
));
180+
}
181+
}

lib/src/internal/resource/sbu_text_styles.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum SBUTextType {
1212
body1,
1313
body2,
1414
body3,
15+
body3Bold,
1516
button,
1617
caption1,
1718
caption2,
@@ -123,6 +124,16 @@ class SBUTextStyles {
123124
decorationThickness: 0,
124125
leadingDistribution: TextLeadingDistribution.even,
125126
);
127+
case SBUTextType.body3Bold:
128+
return TextStyle(
129+
fontFamily: fontFamily,
130+
fontWeight: FontWeight.w700,
131+
fontSize: 14,
132+
height: 1.428,
133+
color: color,
134+
decorationThickness: 0,
135+
leadingDistribution: TextLeadingDistribution.even,
136+
);
126137
case SBUTextType.button:
127138
return TextStyle(
128139
fontFamily: fontFamily,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025 Sendbird, Inc. All rights reserved.
2+
3+
extension SBUTimeExtensions on int {
4+
String toTimeString() {
5+
final int hours = this ~/ 3600;
6+
final int minutes = (this % 3600) ~/ 60;
7+
final int seconds = this % 60;
8+
9+
if (hours == 0) {
10+
return '${minutes.toString().padLeft(2, '0')}:'
11+
'${seconds.toString().padLeft(2, '0')}';
12+
}
13+
14+
return '${hours.toString().padLeft(2, '0')}:'
15+
'${minutes.toString().padLeft(2, '0')}:'
16+
'${seconds.toString().padLeft(2, '0')}';
17+
}
18+
}

0 commit comments

Comments
 (0)