Skip to content

Commit 5a1e9d1

Browse files
author
jeremiawang
committed
【AtomicX】【Flutter】Adapt to AtomicXCore v3.6.0
1 parent 231cb60 commit 5a1e9d1

4 files changed

Lines changed: 135 additions & 185 deletions

File tree

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

Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
3636
return ValueListenableBuilder(
3737
valueListenable: CallParticipantStore.shared.state.selfInfo,
3838
builder: (context, selfInfo, child) {
39-
if (selfInfo.status == CallParticipantStatus.waiting
40-
&& selfInfo.id != CallStore.shared.state.activeCall.value.inviterId) {
39+
if (selfInfo.status == CallParticipantStatus.waiting &&
40+
selfInfo.id != CallStore.shared.state.activeCall.value.inviterId) {
4141
return _buildWaitingFunctionView();
4242
} else {
4343
return _buildAcceptedFunctionView(context);
4444
}
45-
}
46-
);
45+
});
4746
}
4847

4948
_buildWaitingFunctionView() {
@@ -82,9 +81,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
8281
left: isFunctionExpand
8382
? ((MediaQuery.of(context).size.width / 4) - (btnWidth / 2))
8483
: (MediaQuery.of(context).size.width * 2 / 6 - btnWidth / 2),
85-
bottom: isFunctionExpand
86-
? bottomEdge + bigBtnHeight + edge
87-
: bottomEdge,
84+
bottom: isFunctionExpand ? bottomEdge + bigBtnHeight + edge : bottomEdge,
8885
child: _getAnimatedMicButton(isFunctionExpand),
8986
),
9087
AnimatedPositioned(
@@ -93,9 +90,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
9390
left: isFunctionExpand
9491
? (MediaQuery.of(context).size.width / 2 - btnWidth / 2)
9592
: (MediaQuery.of(context).size.width * 3 / 6 - btnWidth / 2),
96-
bottom: isFunctionExpand
97-
? bottomEdge + bigBtnHeight + edge
98-
: bottomEdge,
93+
bottom: isFunctionExpand ? bottomEdge + bigBtnHeight + edge : bottomEdge,
9994
child: _getAnimatedSpeakerPhoneButton(isFunctionExpand),
10095
),
10196
AnimatedPositioned(
@@ -104,9 +99,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
10499
left: isFunctionExpand
105100
? (MediaQuery.of(context).size.width * 3 / 4 - btnWidth / 2)
106101
: (MediaQuery.of(context).size.width * 4 / 6 - btnWidth / 2),
107-
bottom: isFunctionExpand
108-
? bottomEdge + bigBtnHeight + edge
109-
: bottomEdge,
102+
bottom: isFunctionExpand ? bottomEdge + bigBtnHeight + edge : bottomEdge,
110103
child: _getAnimatedCameraButton(isFunctionExpand),
111104
),
112105
AnimatedPositioned(
@@ -122,18 +115,15 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
122115
curve: curve,
123116
duration: Duration(milliseconds: duration),
124117
left: (MediaQuery.of(context).size.width / 6 - smallBtnHeight / 2),
125-
bottom: isFunctionExpand
126-
? bottomEdge + smallBtnHeight / 4 + 22
127-
: bottomEdge + 22,
118+
bottom: isFunctionExpand ? bottomEdge + smallBtnHeight / 4 + 22 : bottomEdge + 22,
128119
child: InkWell(
129120
onTap: () {
130121
isFunctionExpand = !isFunctionExpand;
131122
setState(() {});
132123
},
133124
child: Transform(
134125
alignment: Alignment.center,
135-
transform: Matrix4.identity()
136-
..scale(1.0, isFunctionExpand ? 1.0 : -1.0, 1.0),
126+
transform: Matrix4.identity()..scale(1.0, isFunctionExpand ? 1.0 : -1.0, 1.0),
137127
child: Image.asset(
138128
'call_assets/arrow.png',
139129
package: 'tuikit_atomic_x',
@@ -180,27 +170,20 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
180170
);
181171
}
182172

183-
184173
Widget _getAnimatedMicButton(bool isFunctionExpand) {
185174
return ValueListenableBuilder(
186175
valueListenable: DeviceStore.shared.state.microphoneStatus,
187176
builder: (context, value, child) {
188177
return ControlsButton(
189178
isDisabled: _isWidgetDisabled(CallFeature.toggleMicrophone),
190-
imgUrl: value == DeviceSwitchStatus.on
191-
? "call_assets/mute.png"
192-
: "call_assets/mute_on.png",
179+
imgUrl: value == DeviceStatus.on ? "call_assets/mute.png" : "call_assets/mute_on.png",
193180
tips: isFunctionExpand
194-
? (value == DeviceSwitchStatus.on
195-
? CallKit_t("microphoneIsOn")
196-
: CallKit_t("microphoneIsOff"))
181+
? (value == DeviceStatus.on ? CallKit_t("microphoneIsOn") : CallKit_t("microphoneIsOff"))
197182
: '',
198183
textColor: Colors.white,
199-
imgHeight: isFunctionExpand
200-
? bigBtnHeight
201-
: smallBtnHeight,
184+
imgHeight: isFunctionExpand ? bigBtnHeight : smallBtnHeight,
202185
onTap: () {
203-
if (value == DeviceSwitchStatus.on) {
186+
if (value == DeviceStatus.on) {
204187
DeviceStore.shared.closeLocalMicrophone();
205188
} else {
206189
DeviceStore.shared.openLocalMicrophone();
@@ -209,8 +192,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
209192
useAnimation: true,
210193
duration: Duration(milliseconds: duration),
211194
);
212-
}
213-
);
195+
});
214196
}
215197

216198
Widget _getAnimatedSpeakerPhoneButton(bool isFunctionExpand) {
@@ -219,18 +201,12 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
219201
builder: (context, value, child) {
220202
return ControlsButton(
221203
isDisabled: _isWidgetDisabled(CallFeature.selectAudioRoute),
222-
imgUrl: value == AudioRoute.speakerphone
223-
? "call_assets/handsfree_on.png"
224-
: "call_assets/handsfree.png",
204+
imgUrl: value == AudioRoute.speakerphone ? "call_assets/handsfree_on.png" : "call_assets/handsfree.png",
225205
tips: isFunctionExpand
226-
? (value == AudioRoute.speakerphone
227-
? CallKit_t("speakerIsOn")
228-
: CallKit_t("speakerIsOff"))
206+
? (value == AudioRoute.speakerphone ? CallKit_t("speakerIsOn") : CallKit_t("speakerIsOff"))
229207
: '',
230208
textColor: Colors.white,
231-
imgHeight: isFunctionExpand
232-
? bigBtnHeight
233-
: smallBtnHeight,
209+
imgHeight: isFunctionExpand ? bigBtnHeight : smallBtnHeight,
234210
onTap: () {
235211
if (value == AudioRoute.speakerphone) {
236212
DeviceStore.shared.setAudioRoute(AudioRoute.earpiece);
@@ -241,8 +217,7 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
241217
useAnimation: true,
242218
duration: Duration(milliseconds: duration),
243219
);
244-
}
245-
);
220+
});
246221
}
247222

248223
Widget _getAnimatedCameraButton(bool isFunctionExpand) {
@@ -251,20 +226,13 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
251226
builder: (context, value, child) {
252227
return ControlsButton(
253228
isDisabled: _isWidgetDisabled(CallFeature.toggleCamera),
254-
imgUrl: value == DeviceSwitchStatus.on
255-
? "call_assets/camera_on.png"
256-
: "call_assets/camera_off.png",
257-
tips: isFunctionExpand
258-
? (value == DeviceSwitchStatus.on
259-
? CallKit_t("cameraIsOn")
260-
: CallKit_t("cameraIsOff"))
261-
: '',
229+
imgUrl: value == DeviceStatus.on ? "call_assets/camera_on.png" : "call_assets/camera_off.png",
230+
tips:
231+
isFunctionExpand ? (value == DeviceStatus.on ? CallKit_t("cameraIsOn") : CallKit_t("cameraIsOff")) : '',
262232
textColor: Colors.white,
263-
imgHeight: isFunctionExpand
264-
? bigBtnHeight
265-
: smallBtnHeight,
233+
imgHeight: isFunctionExpand ? bigBtnHeight : smallBtnHeight,
266234
onTap: () {
267-
if (value == DeviceSwitchStatus.on) {
235+
if (value == DeviceStatus.on) {
268236
DeviceStore.shared.closeLocalCamera();
269237
} else {
270238
DeviceStore.shared.openLocalCamera(DeviceStore.shared.state.isFrontCamera.value);
@@ -273,27 +241,24 @@ class _MultiCallControlsWidgetState extends State<MultiCallControlsWidget> {
273241
useAnimation: true,
274242
duration: Duration(milliseconds: duration),
275243
);
276-
}
277-
);
244+
});
278245
}
279246

280247
Widget _getAnimatedHangupButton(bool isFunctionExpand) {
281248
return ControlsButton(
282249
isDisabled: _isWidgetDisabled(CallFeature.hangup),
283250
imgUrl: "call_assets/hangup.png",
284251
textColor: Colors.white,
285-
imgHeight: isFunctionExpand
286-
? bigBtnHeight
287-
: smallBtnHeight,
252+
imgHeight: isFunctionExpand ? bigBtnHeight : smallBtnHeight,
288253
onTap: () {
289254
CallStore.shared.hangup();
290255
},
291256
useAnimation: true,
292257
duration: Duration(milliseconds: duration),
293258
);
294259
}
295-
260+
296261
bool _isWidgetDisabled(CallFeature feature) {
297262
return widget.disableFeatures.contains(CallFeature.all) || widget.disableFeatures.contains(feature);
298263
}
299-
}
264+
}

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

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class SingleCallControlsWidget extends StatelessWidget {
4040
return _selectViewStrategy(type, selfInfo.status, "caller");
4141
}
4242
return _selectViewStrategy(type, selfInfo.status, "called");
43-
}
44-
);
43+
});
4544
},
4645
);
4746
},
@@ -53,7 +52,6 @@ class SingleCallControlsWidget extends StatelessWidget {
5352
'audio_waiting_caller': _buildAudioCallerWaitingView,
5453
'audio_waiting_called': _buildAudioAndVideoCalleeWaitingView,
5554
'audio_accept': _buildAudioAcceptedView,
56-
5755
'video_waiting_caller': _buildVideoCallerWaitingView,
5856
'video_waiting_called': _buildAudioAndVideoCalleeWaitingView,
5957
'video_accept': _buildVideoCallerAndCalleeAcceptedView,
@@ -162,13 +160,12 @@ class SingleCallControlsWidget extends StatelessWidget {
162160
ValueListenableBuilder(
163161
valueListenable: DeviceStore.shared.state.cameraStatus,
164162
builder: (context, value, child) {
165-
return value == DeviceSwitchStatus.on
163+
return value == DeviceStatus.on
166164
? _getSwitchCameraSmallButton()
167165
: const SizedBox(
168-
width: 100,
169-
);
170-
}
171-
),
166+
width: 100,
167+
);
168+
}),
172169
]),
173170
],
174171
);
@@ -232,24 +229,19 @@ class SingleCallControlsWidget extends StatelessWidget {
232229
builder: (context, value, child) {
233230
return ControlsButton(
234231
isDisabled: _isWidgetDisabled(CallFeature.toggleMicrophone),
235-
imgUrl: value == DeviceSwitchStatus.on
236-
? "call_assets/mute.png"
237-
: "call_assets/mute_on.png",
238-
tips: value == DeviceSwitchStatus.on
239-
? CallKit_t("microphoneIsOn")
240-
: CallKit_t("microphoneIsOff"),
232+
imgUrl: value == DeviceStatus.on ? "call_assets/mute.png" : "call_assets/mute_on.png",
233+
tips: value == DeviceStatus.on ? CallKit_t("microphoneIsOn") : CallKit_t("microphoneIsOff"),
241234
textColor: _getTextColor(),
242235
imgHeight: 60,
243236
onTap: () {
244-
if (value == DeviceSwitchStatus.on) {
237+
if (value == DeviceStatus.on) {
245238
DeviceStore.shared.closeLocalMicrophone();
246239
} else {
247240
DeviceStore.shared.openLocalMicrophone();
248241
}
249242
},
250243
);
251-
}
252-
);
244+
});
253245
}
254246

255247
Widget _getSpeakerphoneButton() {
@@ -258,12 +250,8 @@ class SingleCallControlsWidget extends StatelessWidget {
258250
builder: (context, value, child) {
259251
return ControlsButton(
260252
isDisabled: _isWidgetDisabled(CallFeature.selectAudioRoute),
261-
imgUrl: value == AudioRoute.speakerphone
262-
? "call_assets/handsfree_on.png"
263-
: "call_assets/handsfree.png",
264-
tips: value == AudioRoute.speakerphone
265-
? CallKit_t("speakerIsOn")
266-
: CallKit_t("speakerIsOff"),
253+
imgUrl: value == AudioRoute.speakerphone ? "call_assets/handsfree_on.png" : "call_assets/handsfree.png",
254+
tips: value == AudioRoute.speakerphone ? CallKit_t("speakerIsOn") : CallKit_t("speakerIsOff"),
267255
textColor: _getTextColor(),
268256
imgHeight: 60,
269257
onTap: () {
@@ -274,8 +262,7 @@ class SingleCallControlsWidget extends StatelessWidget {
274262
}
275263
},
276264
);
277-
}
278-
);
265+
});
279266
}
280267

281268
Widget _getCameraControlButton() {
@@ -284,24 +271,19 @@ class SingleCallControlsWidget extends StatelessWidget {
284271
builder: (context, value, child) {
285272
return ControlsButton(
286273
isDisabled: _isWidgetDisabled(CallFeature.toggleCamera),
287-
imgUrl: value == DeviceSwitchStatus.on
288-
? "call_assets/camera_on.png"
289-
: "call_assets/camera_off.png",
290-
tips: value == DeviceSwitchStatus.on
291-
? CallKit_t("cameraIsOn")
292-
: CallKit_t("cameraIsOff"),
274+
imgUrl: value == DeviceStatus.on ? "call_assets/camera_on.png" : "call_assets/camera_off.png",
275+
tips: value == DeviceStatus.on ? CallKit_t("cameraIsOn") : CallKit_t("cameraIsOff"),
293276
textColor: _getTextColor(),
294277
imgHeight: 60,
295278
onTap: () {
296-
if (value == DeviceSwitchStatus.on) {
279+
if (value == DeviceStatus.on) {
297280
DeviceStore.shared.closeLocalCamera();
298281
} else {
299282
DeviceStore.shared.openLocalCamera(DeviceStore.shared.state.isFrontCamera.value);
300283
}
301284
},
302285
);
303-
}
304-
);
286+
});
305287
}
306288

307289
Widget _getSwitchCameraSmallButton() {
@@ -319,15 +301,14 @@ class SingleCallControlsWidget extends StatelessWidget {
319301
DeviceStore.shared.switchCamera(!DeviceStore.shared.state.isFrontCamera.value);
320302
},
321303
);
322-
}
323-
);
304+
});
324305
}
325-
306+
326307
bool _isWidgetDisabled(CallFeature feature) {
327308
return disableFeatures.contains(CallFeature.all) || disableFeatures.contains(feature);
328309
}
329310

330311
Color _getTextColor() {
331312
return Colors.white;
332313
}
333-
}
314+
}

0 commit comments

Comments
 (0)