small tweaks and fixes

This commit is contained in:
julian 2024-07-04 11:20:11 -06:00
parent 3025fc359a
commit 89718c6933

View file

@ -56,8 +56,6 @@ class DesktopReceive extends ConsumerStatefulWidget {
this.clipboard = const ClipboardWrapper(), this.clipboard = const ClipboardWrapper(),
}); });
static const String routeName = "/desktopReceive";
final String walletId; final String walletId;
final String? contractAddress; final String? contractAddress;
final ClipboardInterface clipboard; final ClipboardInterface clipboard;
@ -73,10 +71,6 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
late final bool supportsSpark; late final bool supportsSpark;
late final bool showMultiType; late final bool showMultiType;
String? _sparkAddress;
String? _qrcodeContent;
bool _showSparkAddress = true;
int _currentIndex = 0; int _currentIndex = 0;
final List<AddressType> _walletAddressTypes = []; final List<AddressType> _walletAddressTypes = [];
@ -108,8 +102,6 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
), ),
); );
await wallet.generateNewReceivingAddress();
final Address? address; final Address? address;
if (wallet is Bip39HDWallet && wallet is! BCashInterface) { if (wallet is Bip39HDWallet && wallet is! BCashInterface) {
final type = DerivePathType.values.firstWhere( final type = DerivePathType.values.firstWhere(
@ -129,8 +121,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
shouldPop = true; shouldPop = true;
if (mounted) { if (mounted) {
Navigator.of(context) Navigator.of(context, rootNavigator: true).pop();
.popUntil(ModalRoute.withName(DesktopReceive.routeName));
setState(() { setState(() {
_addressMap[_walletAddressTypes[_currentIndex]] = _addressMap[_walletAddressTypes[_currentIndex]] =
@ -174,11 +165,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
if (mounted) { if (mounted) {
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
if (_sparkAddress != address.value) { setState(() {
setState(() { _addressMap[AddressType.spark] = address.value;
_sparkAddress = address.value; });
});
}
} }
} }
} }
@ -242,29 +231,6 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
} }
} }
if (supportsSpark) {
_streamSub = ref
.read(mainDBProvider)
.isar
.addresses
.where()
.walletIdEqualTo(walletId)
.filter()
.typeEqualTo(AddressType.spark)
.sortByDerivationIndexDesc()
.findFirst()
.asStream()
.listen((event) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
_sparkAddress = event?.value;
});
}
});
});
}
super.initState(); super.initState();
} }
@ -285,16 +251,6 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
address = ref.watch(pWalletReceivingAddress(walletId)); address = ref.watch(pWalletReceivingAddress(walletId));
} }
if (supportsSpark) {
if (_showSparkAddress) {
_qrcodeContent = _sparkAddress;
} else {
_qrcodeContent = ref.watch(pWalletReceivingAddress(walletId));
}
} else {
_qrcodeContent = ref.watch(pWalletReceivingAddress(walletId));
}
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@ -373,95 +329,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
if (_showSparkAddress) child,
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
clipboard.setData(
ClipboardData(text: address),
);
showFloatingFlushBar(
type: FlushBarType.info,
message: "Copied to clipboard",
iconAsset: Assets.svg.copy,
context: context,
);
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
width: 1,
),
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
child: RoundedWhiteContainer(
child: Column(
children: [
Row(
children: [
Text(
"Your ${widget.contractAddress == null ? coin.ticker : ref.watch(
pCurrentTokenWallet.select(
(value) => value!.tokenContract.symbol,
),
)}${supportsSpark ? " SPARK" : ""} address",
style: STextStyles.itemSubtitle(context),
),
const Spacer(),
Row(
children: [
SvgPicture.asset(
Assets.svg.copy,
width: 15,
height: 15,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
const SizedBox(
width: 4,
),
Text(
"Copy",
style: STextStyles.link2(context),
),
],
),
],
),
const SizedBox(
height: 8,
),
Row(
children: [
Expanded(
child: Text(
address,
style:
STextStyles.desktopTextExtraExtraSmall(
context,
).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
),
),
],
),
],
),
),
),
),
),
if (!_showSparkAddress) child,
], ],
), ),
child: MouseRegion( child: MouseRegion(
@ -534,7 +402,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
ref.watch(pWalletReceivingAddress(walletId)), address,
style: STextStyles.desktopTextExtraExtraSmall( style: STextStyles.desktopTextExtraExtraSmall(
context, context,
).copyWith( ).copyWith(
@ -566,7 +434,8 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
supportsSpark) supportsSpark)
SecondaryButton( SecondaryButton(
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: supportsSpark && _showSparkAddress onPressed: supportsSpark &&
_walletAddressTypes[_currentIndex] == AddressType.spark
? generateNewSparkAddress ? generateNewSparkAddress
: generateNewAddress, : generateNewAddress,
label: "Generate new address", label: "Generate new address",
@ -578,7 +447,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
child: QR( child: QR(
data: AddressUtils.buildUriString( data: AddressUtils.buildUriString(
coin, coin,
_qrcodeContent ?? "", address,
{}, {},
), ),
size: 200, size: 200,
@ -617,7 +486,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
RouteGenerator.generateRoute( RouteGenerator.generateRoute(
RouteSettings( RouteSettings(
name: GenerateUriQrCodeView.routeName, name: GenerateUriQrCodeView.routeName,
arguments: Tuple2(coin, _qrcodeContent ?? ""), arguments: Tuple2(coin, address),
), ),
), ),
], ],
@ -634,7 +503,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute, shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder: (_) => GenerateUriQrCodeView( builder: (_) => GenerateUriQrCodeView(
coin: coin, coin: coin,
receivingAddress: _qrcodeContent ?? "", receivingAddress: address,
), ),
settings: const RouteSettings( settings: const RouteSettings(
name: GenerateUriQrCodeView.routeName, name: GenerateUriQrCodeView.routeName,