mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-19 02:31:09 +00:00
3e1e68237a
# Conflicts: # lib/models/isar/models/blockchain_data/address.dart # lib/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart # lib/pages/settings_views/global_settings_view/appearance_settings_view.dart # lib/pages_desktop_specific/settings/settings_menu/appearance_settings.dart # lib/utilities/db_version_migration.dart # test/pages/send_view/send_view_test.mocks.dart # test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart # test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart # test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart # test/screen_tests/exchange/exchange_view_test.mocks.dart # test/screen_tests/lockscreen_view_screen_test.mocks.dart # test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart # test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart # test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart # test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart # test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart # test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart # test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart # test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart # test/screen_tests/settings_view/settings_view_screen_test.mocks.dart # test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart # test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart # test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart # test/screen_tests/wallet_view/send_view_screen_test.mocks.dart # test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart # test/widget_tests/managed_favorite_test.mocks.dart # test/widget_tests/table_view/table_view_row_test.mocks.dart # test/widget_tests/transaction_card_test.mocks.dart # test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart # test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart
191 lines
6.1 KiB
Dart
191 lines
6.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:isar/isar.dart';
|
|
import 'package:stackwallet/db/isar/main_db.dart';
|
|
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
|
import 'package:stackwallet/pages/receive_view/addresses/address_tag.dart';
|
|
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|
|
|
class AddressCard extends StatefulWidget {
|
|
const AddressCard({
|
|
Key? key,
|
|
required this.addressId,
|
|
required this.walletId,
|
|
required this.coin,
|
|
this.onPressed,
|
|
this.clipboard = const ClipboardWrapper(),
|
|
}) : super(key: key);
|
|
|
|
final int addressId;
|
|
final String walletId;
|
|
final Coin coin;
|
|
final ClipboardInterface clipboard;
|
|
final VoidCallback? onPressed;
|
|
|
|
@override
|
|
State<AddressCard> createState() => _AddressCardState();
|
|
}
|
|
|
|
class _AddressCardState extends State<AddressCard> {
|
|
late Stream<AddressLabel?> stream;
|
|
late final Address address;
|
|
|
|
AddressLabel? label;
|
|
|
|
@override
|
|
void initState() {
|
|
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: address.value,
|
|
value: "",
|
|
tags: address.subType == AddressSubType.receiving
|
|
? ["receiving"]
|
|
: address.subType == AddressSubType.change
|
|
? ["change"]
|
|
: null,
|
|
);
|
|
id = MainDB.instance.putAddressLabelSync(label!);
|
|
}
|
|
stream = MainDB.instance.watchAddressLabel(id: id);
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return RoundedWhiteContainer(
|
|
onPressed: widget.onPressed,
|
|
child: StreamBuilder<AddressLabel?>(
|
|
stream: stream,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasData) {
|
|
label = snapshot.data!;
|
|
}
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (label!.value.isNotEmpty)
|
|
Text(
|
|
label!.value,
|
|
style: STextStyles.itemSubtitle(context),
|
|
textAlign: TextAlign.left,
|
|
),
|
|
// Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
// children: [
|
|
//
|
|
// CustomTextButton(
|
|
// text: "Edit label",
|
|
// textSize: 14,
|
|
// onTap: () {
|
|
// Navigator.of(context).pushNamed(
|
|
// EditAddressLabelView.routeName,
|
|
// arguments: label!.id,
|
|
// );
|
|
// },
|
|
// ),
|
|
// ],
|
|
// ),
|
|
if (label!.value.isNotEmpty)
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
address.value,
|
|
style: STextStyles.itemSubtitle12(context),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
|
|
if (label!.tags != null && label!.tags!.isNotEmpty)
|
|
Wrap(
|
|
spacing: 10,
|
|
runSpacing: 10,
|
|
children: label!.tags!
|
|
.map(
|
|
(e) => AddressTag(
|
|
tag: e,
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
// Row(
|
|
// children: [
|
|
// Expanded(
|
|
// child: SecondaryButton(
|
|
// label: "Copy address",
|
|
// icon: CopyIcon(
|
|
// color: Theme.of(context)
|
|
// .extension<StackColors>()!
|
|
// .buttonTextSecondary,
|
|
// ),
|
|
// onPressed: () async {
|
|
// await widget.clipboard.setData(
|
|
// ClipboardData(
|
|
// text: address.value,
|
|
// ),
|
|
// );
|
|
// if (mounted) {
|
|
// unawaited(
|
|
// showFloatingFlushBar(
|
|
// type: FlushBarType.info,
|
|
// message: "Copied to clipboard",
|
|
// context: context,
|
|
// ),
|
|
// );
|
|
// }
|
|
// },
|
|
// ),
|
|
// ),
|
|
// const SizedBox(
|
|
// width: 12,
|
|
// ),
|
|
// Expanded(
|
|
// child: SecondaryButton(
|
|
// label: "Show QR Code",
|
|
// icon: QrCodeIcon(
|
|
// color: Theme.of(context)
|
|
// .extension<StackColors>()!
|
|
// .buttonTextSecondary,
|
|
// ),
|
|
// onPressed: () {
|
|
// showDialog<void>(
|
|
// context: context,
|
|
// builder: (context) => AddressQrPopup(
|
|
// addressString: address.value,
|
|
// coin: widget.coin,
|
|
// clipboard: widget.clipboard,
|
|
// ),
|
|
// );
|
|
// },
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// )
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|