@@ -10,9 +10,11 @@ import 'widgets/action_button.dart';
10
10
class CallScreenWidget extends StatefulWidget {
11
11
final SIPUAHelper ? _helper;
12
12
final Call ? _call;
13
+
13
14
CallScreenWidget (this ._helper, this ._call, {Key ? key}) : super (key: key);
15
+
14
16
@override
15
- _MyCallScreenWidget createState () => _MyCallScreenWidget ();
17
+ State < CallScreenWidget > createState () => _MyCallScreenWidget ();
16
18
}
17
19
18
20
class _MyCallScreenWidget extends State <CallScreenWidget >
@@ -27,13 +29,17 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
27
29
28
30
bool _showNumPad = false ;
29
31
String _timeLabel = '00:00' ;
30
- late Timer _timer;
31
32
bool _audioMuted = false ;
32
33
bool _videoMuted = false ;
33
34
bool _speakerOn = false ;
34
35
bool _hold = false ;
36
+ bool _mirror = true ;
35
37
String ? _holdOriginator;
36
38
CallStateEnum _state = CallStateEnum .NONE ;
39
+
40
+ late String _transferTarget;
41
+ late Timer _timer;
42
+
37
43
SIPUAHelper ? get helper => widget._helper;
38
44
39
45
bool get voiceOnly =>
@@ -237,6 +243,9 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
237
243
void _switchCamera () {
238
244
if (_localStream != null ) {
239
245
Helper .switchCamera (_localStream! .getVideoTracks ()[0 ]);
246
+ setState (() {
247
+ _mirror = ! _mirror;
248
+ });
240
249
}
241
250
}
242
251
@@ -264,7 +273,6 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
264
273
}
265
274
}
266
275
267
- late String _transferTarget;
268
276
void _handleTransfer () {
269
277
showDialog <void >(
270
278
context: context,
@@ -324,7 +332,7 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
324
332
}
325
333
326
334
List <Widget > _buildNumPad () {
327
- var labels = [
335
+ final labels = [
328
336
[
329
337
{'1' : '' },
330
338
{'2' : 'abc' },
@@ -364,22 +372,22 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
364
372
}
365
373
366
374
Widget _buildActionButtons () {
367
- var hangupBtn = ActionButton (
375
+ final hangupBtn = ActionButton (
368
376
title: "hangup" ,
369
377
onPressed: () => _handleHangup (),
370
378
icon: Icons .call_end,
371
379
fillColor: Colors .red,
372
380
);
373
381
374
- var hangupBtnInactive = ActionButton (
382
+ final hangupBtnInactive = ActionButton (
375
383
title: "hangup" ,
376
384
onPressed: () {},
377
385
icon: Icons .call_end,
378
386
fillColor: Colors .grey,
379
387
);
380
388
381
- var basicActions = < Widget > [];
382
- var advanceActions = < Widget > [];
389
+ final basicActions = < Widget > [];
390
+ final advanceActions = < Widget > [];
383
391
384
392
switch (_state) {
385
393
case CallStateEnum .NONE :
@@ -472,91 +480,117 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
472
480
break ;
473
481
}
474
482
475
- var actionWidgets = < Widget > [];
483
+ final actionWidgets = < Widget > [];
476
484
477
485
if (_showNumPad) {
478
486
actionWidgets.addAll (_buildNumPad ());
479
487
} else {
480
488
if (advanceActions.isNotEmpty) {
481
- actionWidgets.add (Padding (
489
+ actionWidgets.add (
490
+ Padding (
482
491
padding: const EdgeInsets .all (3 ),
483
492
child: Row (
484
493
mainAxisAlignment: MainAxisAlignment .spaceEvenly,
485
- children: advanceActions)));
494
+ children: advanceActions),
495
+ ),
496
+ );
486
497
}
487
498
}
488
499
489
- actionWidgets.add (Padding (
500
+ actionWidgets.add (
501
+ Padding (
490
502
padding: const EdgeInsets .all (3 ),
491
503
child: Row (
492
504
mainAxisAlignment: MainAxisAlignment .spaceEvenly,
493
- children: basicActions)));
505
+ children: basicActions),
506
+ ),
507
+ );
494
508
495
509
return Column (
496
- crossAxisAlignment: CrossAxisAlignment .end,
497
- mainAxisAlignment: MainAxisAlignment .end,
498
- children: actionWidgets);
510
+ crossAxisAlignment: CrossAxisAlignment .end,
511
+ mainAxisAlignment: MainAxisAlignment .end,
512
+ children: actionWidgets,
513
+ );
499
514
}
500
515
501
516
Widget _buildContent () {
502
- var stackWidgets = < Widget > [];
517
+ final stackWidgets = < Widget > [];
503
518
504
519
if (! voiceOnly && _remoteStream != null ) {
505
- stackWidgets.add (Center (
506
- child: RTCVideoView (_remoteRenderer! ),
507
- ));
520
+ stackWidgets.add (
521
+ Center (
522
+ child: RTCVideoView (
523
+ _remoteRenderer! ,
524
+ objectFit: RTCVideoViewObjectFit .RTCVideoViewObjectFitCover ,
525
+ ),
526
+ ),
527
+ );
508
528
}
509
529
510
530
if (! voiceOnly && _localStream != null ) {
511
- stackWidgets.add (Container (
512
- child: AnimatedContainer (
513
- child: RTCVideoView (_localRenderer! ),
531
+ stackWidgets.add (
532
+ AnimatedContainer (
533
+ child: RTCVideoView (
534
+ _localRenderer! ,
535
+ mirror: _mirror,
536
+ objectFit: RTCVideoViewObjectFit .RTCVideoViewObjectFitCover ,
537
+ ),
514
538
height: _localVideoHeight,
515
539
width: _localVideoWidth,
516
540
alignment: Alignment .topRight,
517
541
duration: Duration (milliseconds: 300 ),
518
542
margin: _localVideoMargin,
519
543
),
520
- alignment: Alignment .topRight,
521
- ));
544
+ );
522
545
}
523
546
524
- stackWidgets.addAll ([
525
- Positioned (
526
- top: voiceOnly ? 48 : 6 ,
527
- left: 0 ,
528
- right: 0 ,
529
- child: Center (
547
+ stackWidgets.addAll (
548
+ [
549
+ Positioned (
550
+ top: voiceOnly ? 48 : 6 ,
551
+ left: 0 ,
552
+ right: 0 ,
553
+ child: Center (
530
554
child: Column (
531
- crossAxisAlignment: CrossAxisAlignment .center,
532
- mainAxisAlignment: MainAxisAlignment .center,
533
- children: < Widget > [
534
- Center (
535
- child: Padding (
555
+ crossAxisAlignment: CrossAxisAlignment .center,
556
+ mainAxisAlignment: MainAxisAlignment .center,
557
+ children: < Widget > [
558
+ Center (
559
+ child: Padding (
536
560
padding: const EdgeInsets .all (6 ),
537
561
child: Text (
538
562
(voiceOnly ? 'VOICE CALL' : 'VIDEO CALL' ) +
539
563
(_hold
540
564
? ' PAUSED BY ${_holdOriginator !.toUpperCase ()}'
541
565
: '' ),
542
566
style: TextStyle (fontSize: 24 , color: Colors .black54),
543
- ))),
544
- Center (
545
- child: Padding (
567
+ ),
568
+ ),
569
+ ),
570
+ Center (
571
+ child: Padding (
546
572
padding: const EdgeInsets .all (6 ),
547
573
child: Text (
548
574
'$remoteIdentity ' ,
549
575
style: TextStyle (fontSize: 18 , color: Colors .black54),
550
- ))),
551
- Center (
552
- child: Padding (
576
+ ),
577
+ ),
578
+ ),
579
+ Center (
580
+ child: Padding (
553
581
padding: const EdgeInsets .all (6 ),
554
- child: Text (_timeLabel,
555
- style: TextStyle (fontSize: 14 , color: Colors .black54))))
556
- ],
557
- )),
558
- ),
559
- ]);
582
+ child: Text (
583
+ _timeLabel,
584
+ style: TextStyle (fontSize: 14 , color: Colors .black54),
585
+ ),
586
+ ),
587
+ )
588
+ ],
589
+ ),
590
+ ),
591
+ ),
592
+ ],
593
+ );
560
594
561
595
return Stack (
562
596
children: stackWidgets,
@@ -566,16 +600,18 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
566
600
@override
567
601
Widget build (BuildContext context) {
568
602
return Scaffold (
569
- appBar: AppBar (
570
- automaticallyImplyLeading: false ,
571
- title: Text ('[$direction ] ${EnumHelper .getName (_state )}' )),
572
- body: Container (
573
- child: _buildContent (),
574
- ),
575
- floatingActionButtonLocation: FloatingActionButtonLocation .centerFloat,
576
- floatingActionButton: Padding (
577
- padding: EdgeInsets .fromLTRB (0.0 , 0.0 , 0.0 , 24.0 ),
578
- child: Container (width: 320 , child: _buildActionButtons ())));
603
+ appBar: AppBar (
604
+ automaticallyImplyLeading: false ,
605
+ title: Text ('[$direction ] ${EnumHelper .getName (_state )}' ),
606
+ ),
607
+ body: _buildContent (),
608
+ floatingActionButtonLocation: FloatingActionButtonLocation .centerFloat,
609
+ floatingActionButton: Container (
610
+ width: 320 ,
611
+ padding: EdgeInsets .only (bottom: 24.0 ),
612
+ child: _buildActionButtons (),
613
+ ),
614
+ );
579
615
}
580
616
581
617
@override
0 commit comments