mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
load address ids in futurebuilder
This commit is contained in:
parent
5f4e8a6e58
commit
8f80b6976f
2 changed files with 16 additions and 10 deletions
|
@ -21,13 +21,13 @@ import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|||
class AddressCard extends StatefulWidget {
|
||||
const AddressCard({
|
||||
Key? key,
|
||||
required this.address,
|
||||
required this.addressId,
|
||||
required this.walletId,
|
||||
required this.coin,
|
||||
this.clipboard = const ClipboardWrapper(),
|
||||
}) : super(key: key);
|
||||
|
||||
final Address address;
|
||||
final int addressId;
|
||||
final String walletId;
|
||||
final Coin coin;
|
||||
final ClipboardInterface clipboard;
|
||||
|
@ -38,18 +38,23 @@ class AddressCard extends StatefulWidget {
|
|||
|
||||
class _AddressCardState extends State<AddressCard> {
|
||||
late Stream<AddressLabel?> stream;
|
||||
late final Address address;
|
||||
|
||||
AddressLabel? label;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
label = MainDB.instance
|
||||
.getAddressLabelSync(widget.walletId, widget.address.value);
|
||||
address = MainDB.instance.isar.addresses
|
||||
.where()
|
||||
.idEqualTo(widget.addressId)
|
||||
.findFirstSync()!;
|
||||
|
||||
label = MainDB.instance.getAddressLabelSync(widget.walletId, address.value);
|
||||
Id? id = label?.id;
|
||||
if (id == null) {
|
||||
label = AddressLabel(
|
||||
walletId: widget.walletId,
|
||||
addressString: widget.address.value,
|
||||
addressString: address.value,
|
||||
value: "",
|
||||
);
|
||||
id = MainDB.instance.putAddressLabelSync(label!);
|
||||
|
@ -97,7 +102,7 @@ class _AddressCardState extends State<AddressCard> {
|
|||
children: [
|
||||
Expanded(
|
||||
child: SelectableText(
|
||||
widget.address.value,
|
||||
address.value,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
)
|
||||
|
@ -119,7 +124,7 @@ class _AddressCardState extends State<AddressCard> {
|
|||
onPressed: () async {
|
||||
await widget.clipboard.setData(
|
||||
ClipboardData(
|
||||
text: widget.address.value,
|
||||
text: address.value,
|
||||
),
|
||||
);
|
||||
if (mounted) {
|
||||
|
@ -149,7 +154,7 @@ class _AddressCardState extends State<AddressCard> {
|
|||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AddressQrPopup(
|
||||
addressString: widget.address.value,
|
||||
addressString: address.value,
|
||||
coin: widget.coin,
|
||||
clipboard: widget.clipboard,
|
||||
),
|
||||
|
|
|
@ -112,8 +112,9 @@ class _WalletAddressesViewState extends ConsumerState<WalletAddressesView> {
|
|||
.not()
|
||||
.typeEqualTo(AddressType.nonWallet)
|
||||
.sortByDerivationIndex()
|
||||
.idProperty()
|
||||
.findAll(),
|
||||
builder: (context, AsyncSnapshot<List<Address>> snapshot) {
|
||||
builder: (context, AsyncSnapshot<List<int>> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.data != null) {
|
||||
// listview
|
||||
|
@ -124,7 +125,7 @@ class _WalletAddressesViewState extends ConsumerState<WalletAddressesView> {
|
|||
),
|
||||
itemBuilder: (_, index) => AddressCard(
|
||||
walletId: widget.walletId,
|
||||
address: snapshot.data![index],
|
||||
addressId: snapshot.data![index],
|
||||
coin: coin,
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue