Skip to content

Commit

Permalink
feat: add copying of address only to receive with payjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
kumulynja committed Dec 23, 2024
1 parent 246646c commit 9e077dd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 44 deletions.
7 changes: 7 additions & 0 deletions lib/receive/bloc/receive_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class ReceiveCubit extends Cubit<ReceiveState> {
state.walletBloc!.state.wallet!.isTestnet(),
state.defaultAddress!.address,
);
} else {
// Clear payjoin receiver
emit(
state.copyWith(
payjoinReceiver: null,
),
);
}
}

Expand Down
123 changes: 79 additions & 44 deletions lib/receive/receive_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1132,58 +1132,93 @@ class _ReceiveDisplayAddressState extends State<ReceiveDisplayAddress> {
);

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<Clippboard>()) {
await locator<Clippboard>().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<Clippboard>()) {
await locator<Clippboard>().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<Clippboard>()) {
await locator<Clippboard>().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<Clippboard>()) {
await locator<Clippboard>().copy(addr);
await locator<Clippboard>().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<Clippboard>()) {
await locator<Clippboard>().copy(addrOnly);
}

// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(content: Text('Copied to clipboard')),
// );
},
iconSize: 24,
color: Colors.blue,
icon: const Icon(Icons.copy),
),
],
),
],
));
}
}

Expand Down

0 comments on commit 9e077dd

Please sign in to comment.