showAudioDevicePopup method
void
showAudioDevicePopup(
)
Implementation
void showAudioDevicePopup(
ChimeSession session,
BuildContext context,
) async {
final button = context.findRenderObject() as RenderBox;
final overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
final buttonTopLeft = button.localToGlobal(Offset.zero, ancestor: overlay);
const gap = 8.0;
const menuWidth = 260.0;
final device = await showGeneralDialog<String>(
context: context,
barrierDismissible: true,
barrierLabel: 'Dismiss',
barrierColor: Colors.transparent,
transitionDuration: const Duration(milliseconds: 180),
pageBuilder: (context, _, __) => const SizedBox.shrink(),
transitionBuilder: (context, animation, _, __) {
final curved = CurvedAnimation(
parent: animation,
curve: Curves.easeOutCubic,
reverseCurve: Curves.easeInCubic,
);
return Stack(
children: [
Positioned(
left: buttonTopLeft.dx,
bottom: overlay.size.height - buttonTopLeft.dy + gap,
child: FadeTransition(
opacity: curved,
child: Align(
alignment: Alignment.bottomLeft,
widthFactor: 1,
heightFactor: curved.value,
child: _AudioMenu(
width: menuWidth,
devices: session.deviceList,
selected: session.selectedAudioDevice,
iconFor: _iconForDevice,
onSelect: (d) => Navigator.of(context).pop(d),
),
),
),
),
],
);
},
);
if (device == null) {
logger.w('No device chosen.');
return;
}
logger.i('$device was chosen.');
await session.updateCurrentDevice(device);
}