diff --git a/lib/receive/bloc/receive_cubit.dart b/lib/receive/bloc/receive_cubit.dart index b4b69cd1..83409f6c 100644 --- a/lib/receive/bloc/receive_cubit.dart +++ b/lib/receive/bloc/receive_cubit.dart @@ -71,6 +71,13 @@ class ReceiveCubit extends Cubit { state.walletBloc!.state.wallet!.isTestnet(), state.defaultAddress!.address, ); + } else { + // Clear payjoin receiver + emit( + state.copyWith( + payjoinReceiver: null, + ), + ); } } diff --git a/lib/receive/receive_page.dart b/lib/receive/receive_page.dart index f81b2a7d..c1675661 100644 --- a/lib/receive/receive_page.dart +++ b/lib/receive/receive_page.dart @@ -1132,58 +1132,93 @@ class _ReceiveDisplayAddressState extends State { ); final addr = bip21Address.isNotEmpty ? bip21Address : widget.addressQr; + final addrOnly = widget.addressQr; + final isPjReceiver = + context.select((ReceiveCubit x) => x.state.payjoinReceiver); return AnimatedSwitcher( - duration: const Duration(milliseconds: 350), - child: !showToast - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, + duration: const Duration(milliseconds: 350), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BBText.body(receiveAddressLabel), + Row( children: [ - BBText.body(receiveAddressLabel), - Row( - children: [ - Expanded( - child: GestureDetector( - onTap: () async { - if (locator.isRegistered()) { - await locator().copy(addr); - } - - // ScaffoldMessenger.of(context).showSnackBar( - // const SnackBar( - // content: Text('Copied to clipboard'), - // ), - // ); - }, - child: BBText.bodySmall( - addr, - isBlue: true, - ), - ), + Expanded( + child: GestureDetector( + onTap: () async { + if (locator.isRegistered()) { + await locator().copy(addr); + } + + // ScaffoldMessenger.of(context).showSnackBar( + // const SnackBar( + // content: Text('Copied to clipboard'), + // ), + // ); + }, + child: BBText.bodySmall( + addr, + isBlue: true, ), - IconButton( - onPressed: () async { + ), + ), + IconButton( + onPressed: () async { + if (locator.isRegistered()) { + await locator().copy(addr); + } + + // ScaffoldMessenger.of(context).showSnackBar( + // const SnackBar(content: Text('Copied to clipboard')), + // ); + }, + iconSize: 24, + color: Colors.blue, + icon: const Icon(Icons.copy), + ), + ], + ), + if (isPjReceiver != null) + Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () async { if (locator.isRegistered()) { - await locator().copy(addr); + await locator().copy(addrOnly); } - - // ScaffoldMessenger.of(context).showSnackBar( - // const SnackBar(content: Text('Copied to clipboard')), - // ); }, - iconSize: 24, - color: Colors.blue, - icon: const Icon(Icons.copy), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const BBText.bodySmall('Address only:'), + BBText.bodySmall( + addrOnly, + isBlue: true, + ), + ], + ), ), - ], - ), - ], - ) - : const Padding( - padding: EdgeInsets.symmetric(vertical: 16), - child: BBText.body('Address copied to clipboard'), - ), - ); + ), + IconButton( + onPressed: () async { + if (locator.isRegistered()) { + await locator().copy(addrOnly); + } + + // ScaffoldMessenger.of(context).showSnackBar( + // const SnackBar(content: Text('Copied to clipboard')), + // ); + }, + iconSize: 24, + color: Colors.blue, + icon: const Icon(Icons.copy), + ), + ], + ), + ], + )); } }