showNwcConnectionOptionsDialog function
Future<bool>
showNwcConnectionOptionsDialog(
- BuildContext context,
- NdkFlutter ndkFlutter, {
- AlbyGoConnectConfig albyGoConnectConfig = kDefaultAlbyGoConnectConfig,
Shows a dialog to choose NWC connection method.
Returns true if a connection method was selected, false if cancelled.
Use albyGoConnectConfig to override Alby Go app metadata.
Implementation
Future<bool> showNwcConnectionOptionsDialog(
BuildContext context,
NdkFlutter ndkFlutter, {
AlbyGoConnectConfig albyGoConnectConfig = kDefaultAlbyGoConnectConfig,
}) async {
final l10n = AppLocalizations.of(context)!;
return await showDialog<bool>(
context: context,
builder: (dialogContext) => Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
onPressed: () async {
Navigator.of(dialogContext).pop(false);
if (context.mounted) {
await showAddWalletTypeDialog(
context,
ndkFlutter,
albyGoConnectConfig: albyGoConnectConfig,
);
}
},
icon: const Icon(Icons.arrow_back),
),
Expanded(
child: Text(
l10n.connectNwcTitle,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
),
GestureDetector(
onTap: () => Navigator.of(dialogContext).pop(false),
child: const Icon(Icons.close, size: 24),
),
],
),
const SizedBox(height: 8),
Text(
l10n.chooseNwcMethod,
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(color: Colors.grey),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
// Grid of connection options
Wrap(
spacing: 16,
runSpacing: 16,
alignment: WrapAlignment.center,
children: [
// Alby Go button (only on Android, not web)
if (!kIsWeb && Platform.isAndroid)
_WalletTypeOptionButton(
imageAsset: 'assets/images/albygo.png',
label: l10n.albyGoOption,
onTap: () async {
Navigator.of(dialogContext).pop(true);
await _connectAlbyGo(context, albyGoConnectConfig);
},
),
// Manual connection button (goes directly to QR scanner)
_WalletTypeOptionButton(
icon: Icons.qr_code_scanner,
label: l10n.manualOption,
onTap: () async {
Navigator.of(dialogContext).pop(true);
await _showNwcScannerAndAddWallet(
context,
ndkFlutter,
returnToNwcOptions: true,
albyGoConnectConfig: albyGoConnectConfig,
);
},
),
// Faucet button (only in debug mode)
if (kDebugMode)
_WalletTypeOptionButton(
icon: Icons.water_drop,
label: l10n.faucetOption,
onTap: () async {
Navigator.of(dialogContext).pop(true);
await _showNwcFaucetDialog(
context,
ndkFlutter,
returnToNwcOptions: true,
albyGoConnectConfig: albyGoConnectConfig,
);
},
),
],
),
],
),
),
),
) ??
false;
}