Skip to content

Commit 40a81aa

Browse files
iveshzfMinTate
authored andcommitted
[tuicallkit]4.0.2 update
1 parent ddc35eb commit 40a81aa

38 files changed

Lines changed: 979 additions & 1525 deletions

application/lib/src/login/login_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class _LoginWidgetState extends State<LoginWidget> {
185185
_enterMainWidget();
186186
}
187187
} else {
188-
LiveKitLogger.error("TUILogin login fail, {code:$result.errorCode, message:$result.errorMessage}");
189-
makeToast(msg: "code:$result.errorCode message:$result.errorMessage");
188+
LiveKitLogger.error("TUILogin login fail, {code:${result.errorCode}, message:${result.errorMessage}");
189+
makeToast(msg: "code:${result.errorCode} message:${result.errorMessage}");
190190
}
191191
_isButtonEnabled = true;
192192
}

atomic-x/lib/call/call_view.dart

Lines changed: 28 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,76 @@
1-
import 'package:tuikit_atomic_x/call/component/aisubtitle/ai_subtitle.dart';
2-
import 'package:tuikit_atomic_x/call/component/controls/multi_call_controls_widget.dart';
3-
import 'package:tuikit_atomic_x/call/component/controls/single_call_controls_widget.dart';
4-
import 'package:tuikit_atomic_x/call/component/hint/timer_widget.dart';
5-
import 'package:tuikit_atomic_x/call/component/stream_widget/multi_call_stream_widget.dart';
6-
import 'package:tuikit_atomic_x/call/component/stream_widget/single_call_stream_widget.dart';
71
import 'package:atomic_x_core/atomicxcore.dart';
8-
import 'package:flutter/cupertino.dart';
92
import 'package:flutter/material.dart';
3+
import 'package:tuikit_atomic_x/call/component/widgets/float/call_float_widget.dart';
4+
import 'package:tuikit_atomic_x/call/component/widgets/grid/call_grid_widget.dart';
5+
import 'package:tuikit_atomic_x/call/component/widgets/pip/call_pip_widget.dart';
106

117
class CallView extends StatefulWidget {
12-
final List<CallFeature> disableFeatures;
8+
final bool isPipMode;
139

1410
const CallView({
1511
super.key,
16-
this.disableFeatures = const [],
12+
this.isPipMode = false,
1713
});
1814

1915
@override
2016
State<CallView> createState() => _CallViewState();
2117
}
2218

2319
class _CallViewState extends State<CallView> {
24-
bool isMultiPerson = false;
20+
late final CallCoreController controller;
2521

2622
@override
2723
void initState() {
24+
controller = CallCoreController.create();
2825
DeviceStore.shared.openLocalMicrophone();
2926
DeviceStore.shared.setAudioRoute(
3027
CallStore.shared.state.activeCall.value.mediaType == CallMediaType.audio
3128
? AudioRoute.earpiece
3229
: AudioRoute.speakerphone
3330
);
31+
if (CallStore.shared.state.activeCall.value.mediaType == CallMediaType.video) {
32+
DeviceStore.shared.openLocalCamera(true);
33+
}
3434
super.initState();
3535
}
3636

3737
@override
3838
void dispose() {
39+
controller.dispose();
3940
DeviceStore.shared.closeLocalMicrophone();
4041
super.dispose();
4142
}
4243

4344
@override
4445
Widget build(BuildContext context) {
4546
return Material(
46-
child: Container(
47+
child: SizedBox(
4748
width: double.infinity,
4849
height: double.infinity,
4950
child: ValueListenableBuilder(
5051
valueListenable: CallStore.shared.state.activeCall,
5152
builder: (context, activeCall, child) {
52-
return ValueListenableBuilder(
53-
valueListenable: CallParticipantStore.shared.state.allParticipants,
54-
builder: (context, allParticipants, child) {
55-
Widget streamWidget = SingleCallStreamWidget(disableFeatures: widget.disableFeatures,);
56-
Widget controlsWidget = SingleCallControlsWidget(disableFeatures: widget.disableFeatures,);
57-
if (activeCall.chatGroupId.isNotEmpty || isMultiPerson || activeCall.inviteeIds.length >= 2) {
58-
isMultiPerson = true;
59-
streamWidget = MultiCallStreamWidget(disableFeatures: widget.disableFeatures,);
60-
controlsWidget = MultiCallControlsWidget(disableFeatures: widget.disableFeatures,);
61-
}
53+
if (widget.isPipMode) {
54+
controller.setLayoutTemplate(CallLayoutTemplate.pip);
55+
return CallPipWidget(
56+
controller: controller,
57+
);
58+
}
6259

63-
final isTwoRowsButtons = activeCall.mediaType == CallMediaType.video || isMultiPerson;
64-
return Stack(
65-
children: [
66-
streamWidget,
67-
Positioned(
68-
left: 0,
69-
right: 0,
70-
bottom: isTwoRowsButtons ? 240 : 120,
71-
child: Container(
72-
constraints: BoxConstraints(
73-
maxWidth: MediaQuery.of(context).size.width * 0.9,
74-
maxHeight: MediaQuery.of(context).size.height * 0.3,
75-
),
76-
child: AISubtitle(userId: CallParticipantStore.shared.state.selfInfo.value.id),
77-
),
78-
),
79-
if (!widget.disableFeatures.contains(CallFeature.all)
80-
&& !widget.disableFeatures.contains(CallFeature.timer))
81-
getTimerWidget(),
82-
Positioned(
83-
right: 0,
84-
left: 0,
85-
bottom: isMultiPerson ? 0 : 40,
86-
child: widget.disableFeatures.contains(CallFeature.all)
87-
? Container()
88-
: controlsWidget,
89-
),
90-
],
91-
);
92-
}
60+
if (activeCall.chatGroupId.isNotEmpty || activeCall.inviteeIds.length > 1) {
61+
controller.setLayoutTemplate(CallLayoutTemplate.grid);
62+
return CallGridWidget(
63+
controller: controller,
64+
);
65+
}
66+
67+
controller.setLayoutTemplate(CallLayoutTemplate.float);
68+
return CallFloatWidget(
69+
controller: controller,
9370
);
9471
}
9572
),
9673
),
9774
);
9875
}
99-
100-
Widget getTimerWidget() {
101-
return ValueListenableBuilder(
102-
valueListenable: SingleCallUserWidgetData.isOnlyShowVideoView,
103-
builder: (context, value, child) {
104-
if (value) {
105-
return Container();
106-
}
107-
return Positioned(
108-
top: 20,
109-
width: MediaQuery.of(context).size.width,
110-
height: 100,
111-
child: Center(child: TimerWidget(),),
112-
);
113-
},
114-
);
115-
}
116-
}
117-
118-
enum CallFeature {
119-
timer,
120-
networkQuality,
121-
openFloatWindow,
122-
invite,
123-
accept,
124-
hangup,
125-
toggleMicrophone,
126-
toggleCamera,
127-
selectAudioRoute,
128-
switchCamera,
129-
virtualBackground,
130-
all,
13176
}

atomic-x/lib/call/common/constants.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'package:atomic_x_core/atomicxcore.dart';
2+
import 'package:flutter/cupertino.dart';
3+
14
class Constants {
25
static const int groupCallMaxUserCount = 9;
36
static const int roomIdMaxValue = 2147483647; // 2^31 - 1
@@ -7,4 +10,18 @@ class Constants {
710

811
static const int blurLevelHigh = 3;
912
static const int blurLevelClose = 0;
13+
14+
static final Image defaultAvatarImage = Image.network(defaultAvatar, fit: BoxFit.cover,);
15+
static final Image loading = Image.asset('call_assets/loading.gif', package: 'tuikit_atomic_x');
16+
static final Map<VolumeLevel, Image> volumeIcons = {
17+
VolumeLevel.mute : Image.asset('call_assets/audio_unavailable.png', package: 'tuikit_atomic_x'),
18+
VolumeLevel.medium: Image.asset('call_assets/speaking.png', package: 'tuikit_atomic_x'),
19+
VolumeLevel.high : Image.asset('call_assets/speaking.png', package: 'tuikit_atomic_x'),
20+
VolumeLevel.peak : Image.asset('call_assets/speaking.png', package: 'tuikit_atomic_x'),
21+
};
22+
static final Map<NetworkQuality, Image> networkQualityIcons = {
23+
NetworkQuality.bad : Image.asset('call_assets/network_bad.png', package: 'tuikit_atomic_x'),
24+
NetworkQuality.veryBad : Image.asset('call_assets/network_bad.png', package: 'tuikit_atomic_x'),
25+
NetworkQuality.down : Image.asset('call_assets/network_bad.png', package: 'tuikit_atomic_x'),
26+
};
1027
}

atomic-x/lib/call/common/widget/controls_button.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class ControlsButton extends StatelessWidget {
5555
if (isDisabled) {
5656
return const SizedBox();
5757
}
58-
return InkWell(
58+
return GestureDetector(
59+
behavior: HitTestBehavior.deferToChild,
5960
onTap: () {
6061
onTap?.call();
6162
},

atomic-x/lib/call/component/aisubtitle/ai_subtitle.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class _AISubtitleState extends State<AISubtitle> {
215215

216216
Future<String?> _getUserDisplayName(String userId) async {
217217
try {
218-
final allParticipants = CallParticipantStore.shared.state.allParticipants.value;
218+
final allParticipants = CallStore.shared.state.allParticipants.value;
219219
for (final participant in allParticipants) {
220220
if (participant.id == userId) {
221221
return _getDisplayName(participant);

atomic-x/lib/call/component/controls/multi_call_controls_widget.dart

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import 'package:tuikit_atomic_x/call/call_view.dart';
77
import '../../common/call_colors.dart';
88

99
class MultiCallControlsWidget extends StatefulWidget {
10-
final List<CallFeature> disableFeatures;
1110

1211
const MultiCallControlsWidget({
1312
super.key,
14-
required this.disableFeatures,
1513
});
1614

1715
@override
@@ -36,7 +34,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
3634
@override
3735
Widget build(BuildContext context) {
3836
return ValueListenableBuilder(
39-
valueListenable: CallParticipantStore.shared.state.selfInfo,
37+
valueListenable: CallStore.shared.state.selfInfo,
4038
builder: (context, selfInfo, child) {
4139
if (selfInfo.status == CallParticipantStatus.waiting &&
4240
selfInfo.id != CallStore.shared.state.activeCall.value.inviterId) {
@@ -57,6 +55,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
5755
_getAcceptButton(),
5856
],
5957
),
58+
const SizedBox(height: 40,),
6059
],
6160
);
6261
}
@@ -148,7 +147,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
148147

149148
Widget _getRejectButton() {
150149
return ControlsButton(
151-
isDisabled: _isWidgetDisabled(CallFeature.hangup),
152150
imgUrl: "call_assets/hangup.png",
153151
tips: CallKit_t("hangUp"),
154152
textColor: CallColors.colorG7,
@@ -161,7 +159,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
161159

162160
Widget _getAcceptButton() {
163161
return ControlsButton(
164-
isDisabled: _isWidgetDisabled(CallFeature.accept),
165162
imgUrl: "call_assets/dialing.png",
166163
tips: CallKit_t("accept"),
167164
textColor: CallColors.colorG7,
@@ -177,7 +174,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
177174
valueListenable: DeviceStore.shared.state.microphoneStatus,
178175
builder: (context, value, child) {
179176
return ControlsButton(
180-
isDisabled: _isWidgetDisabled(CallFeature.toggleMicrophone),
181177
imgUrl: value == DeviceStatus.on ? "call_assets/mute.png" : "call_assets/mute_on.png",
182178
tips: isFunctionExpand
183179
? (value == DeviceStatus.on ? CallKit_t("microphoneIsOn") : CallKit_t("microphoneIsOff"))
@@ -202,7 +198,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
202198
valueListenable: DeviceStore.shared.state.currentAudioRoute,
203199
builder: (context, value, child) {
204200
return ControlsButton(
205-
isDisabled: _isWidgetDisabled(CallFeature.selectAudioRoute),
206201
imgUrl: value == AudioRoute.speakerphone ? "call_assets/handsfree_on.png" : "call_assets/handsfree.png",
207202
tips: isFunctionExpand
208203
? (value == AudioRoute.speakerphone ? CallKit_t("speakerIsOn") : CallKit_t("speakerIsOff"))
@@ -227,7 +222,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
227222
valueListenable: DeviceStore.shared.state.cameraStatus,
228223
builder: (context, value, child) {
229224
return ControlsButton(
230-
isDisabled: _isWidgetDisabled(CallFeature.toggleCamera),
231225
imgUrl: value == DeviceStatus.on ? "call_assets/camera_on.png" : "call_assets/camera_off.png",
232226
tips:
233227
isFunctionExpand ? (value == DeviceStatus.on ? CallKit_t("cameraIsOn") : CallKit_t("cameraIsOff")) : '',
@@ -248,7 +242,6 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
248242

249243
Widget _getAnimatedHangupButton(bool isFunctionExpand) {
250244
return ControlsButton(
251-
isDisabled: _isWidgetDisabled(CallFeature.hangup),
252245
imgUrl: "call_assets/hangup.png",
253246
textColor: CallColors.colorG7,
254247
imgHeight: isFunctionExpand ? bigBtnHeight : smallBtnHeight,
@@ -259,8 +252,4 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
259252
duration: Duration(milliseconds: duration),
260253
);
261254
}
262-
263-
bool _isWidgetDisabled(CallFeature feature) {
264-
return widget.disableFeatures.contains(CallFeature.all) || widget.disableFeatures.contains(feature);
265-
}
266255
}

0 commit comments

Comments
 (0)