-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dogfooding): added registered devices list to dogfooding app (#833
) * added registered devices list to dogfooding * tweaks --------- Co-authored-by: Deven Joshi <[email protected]>
- Loading branch information
Showing
5 changed files
with
173 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:stream_video_flutter/stream_video_flutter.dart'; | ||
|
||
class DeviceList extends StatefulWidget { | ||
const DeviceList({ | ||
required this.devices, | ||
super.key, | ||
}); | ||
|
||
final List<PushDevice> devices; | ||
|
||
@override | ||
State<DeviceList> createState() => _DeviceListState(); | ||
} | ||
|
||
class _DeviceListState extends State<DeviceList> { | ||
List<PushDevice> devices = []; | ||
|
||
@override | ||
void initState() { | ||
devices = widget.devices; | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SingleChildScrollView( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: devices | ||
.map( | ||
(e) => Row( | ||
children: [ | ||
IconButton( | ||
onPressed: () async { | ||
await StreamVideo.instance.removeDevice( | ||
pushToken: e.pushToken, | ||
); | ||
|
||
setState(() { | ||
devices.remove(e); | ||
}); | ||
}, | ||
icon: const Icon( | ||
Icons.delete, | ||
color: Colors.red, | ||
), | ||
), | ||
Expanded( | ||
child: ListTile( | ||
title: Text(e.pushProvider.name), | ||
subtitle: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Expanded(child: Text(e.userId ?? '')), | ||
if (e.voip == true) ...[ | ||
const Icon( | ||
Icons.phone, | ||
size: 16, | ||
), | ||
const SizedBox(width: 4), | ||
const Text('VOIP'), | ||
], | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
) | ||
.toList(), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dogfooding/widgets/device_list.dart'; | ||
import 'package:stream_video_flutter/stream_video_flutter.dart'; | ||
|
||
import '../theme/app_palette.dart'; | ||
|
||
class UserActionsAvatar extends StatelessWidget { | ||
const UserActionsAvatar({ | ||
required this.currentUser, | ||
super.key, | ||
}); | ||
|
||
final UserInfo currentUser; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.all(8), | ||
child: MenuAnchor( | ||
style: const MenuStyle( | ||
alignment: Alignment.bottomRight, | ||
padding: WidgetStatePropertyAll(EdgeInsets.all(8)), | ||
backgroundColor: | ||
WidgetStatePropertyAll(AppColorPalette.buttonSecondary), | ||
), | ||
alignmentOffset: const Offset(00, 0), | ||
builder: ( | ||
BuildContext context, | ||
MenuController controller, | ||
Widget? child, | ||
) { | ||
return InkWell( | ||
onTap: () { | ||
if (controller.isOpen) { | ||
controller.close(); | ||
} else { | ||
controller.open(); | ||
} | ||
}, | ||
child: StreamUserAvatar(user: currentUser), | ||
); | ||
}, | ||
menuChildren: [ | ||
MenuItemButton( | ||
child: const Text( | ||
'List devices', | ||
style: TextStyle(color: Colors.white), | ||
), | ||
onPressed: () async { | ||
final devices = await StreamVideo.instance.getDevices(); | ||
|
||
showDialog( | ||
// ignore: use_build_context_synchronously | ||
context: context, | ||
builder: (context) { | ||
return AlertDialog( | ||
title: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
const Text('Devices'), | ||
IconButton( | ||
onPressed: () async { | ||
for (final device in devices.getDataOrNull()!) { | ||
await StreamVideo.instance | ||
.removeDevice(pushToken: device.pushToken); | ||
} | ||
|
||
// ignore: use_build_context_synchronously | ||
Navigator.of(context).pop(); | ||
}, | ||
icon: const Icon( | ||
Icons.delete, | ||
color: Colors.red, | ||
), | ||
) | ||
], | ||
), | ||
content: DeviceList( | ||
devices: devices.getDataOrNull()!, | ||
), | ||
); | ||
}, | ||
); | ||
}, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters