Skip to content

Commit 7a827b7

Browse files
committed
feat(receive_tx_screen): improve ux of copy address
1 parent 5ad3c41 commit 7a827b7

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

lib/screens/receive_transaction/receive_tx_screen.dart

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:async';
2+
import 'dart:developer';
3+
14
import 'package:flutter/material.dart';
25
import 'package:flutter/services.dart';
36
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -25,6 +28,9 @@ class ReceiveTransactionScreenState extends State<ReceiveTransactionScreen>
2528
with TickerProviderStateMixin {
2629
Account? selectedAccount;
2730
late AnimationController _loadingController;
31+
bool isLoading = false;
32+
String copyText = 'Copy selected address';
33+
bool enableButton = true;
2834

2935
@override
3036
void initState() {
@@ -49,13 +55,26 @@ class ReceiveTransactionScreenState extends State<ReceiveTransactionScreen>
4955
return [
5056
PaddedButton(
5157
padding: EdgeInsets.zero,
52-
text: 'Copy selected address',
58+
text: copyText,
5359
type: 'primary',
54-
enabled: true,
55-
onPressed: () => {
56-
Clipboard.setData(
57-
ClipboardData(text: selectedAccount?.address ?? ''))
58-
}),
60+
enabled: enableButton,
61+
isLoading: isLoading,
62+
onPressed: () async {
63+
await Clipboard.setData(
64+
ClipboardData(text: selectedAccount?.address ?? ''));
65+
if (await Clipboard.hasStrings()) {
66+
setState(() {
67+
enableButton = false;
68+
isLoading = true;
69+
});
70+
Timer(Duration(milliseconds: 400), () {
71+
setState(() {
72+
enableButton = true;
73+
isLoading = false;
74+
});
75+
});
76+
}
77+
}),
5978
// TODO: Implement generate new address
6079
// PaddedButton(
6180
// padding: EdgeInsets.only(bottom: 8),

0 commit comments

Comments
 (0)