mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
* feat(walletconnect): Minor update to WalletConnect tile UI to fix expanded image issue * feat(walletconnect): Minor update to WalletConnect tile UI to fix expanded image issue * feat(walletconnect): Enhance WalletConnect EVM chain service. This change: - Improves signTypedDataV4 method handing and data parsing in extractPermitData. - Adjusts UI for One Click Auth requests * feat(walletconnect): Add redirect to PairingMetadata in WalletKit setup * fix(walletconnect): Ensure session null checks before handling redirects in EvmChainService * fix(walletconnect): Add null safety checks for permitData properties in EvmChainService * refactor(walletconnect): Update WCPairingItemWidget layout and improve error handling for image loading * fix(walletconnect): Handle break in connection flow triggered by global exception handler when SVGParser fails on invalid SvgData and triggers FlutterError. * refactor(solana): Remove redundant session request responses and simplify error handling in SolanaChainService --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
91 lines
3.1 KiB
Dart
91 lines
3.1 KiB
Dart
import 'package:cw_core/utils/proxy_wrapper.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
class ImageUtil {
|
|
static Widget getImageFromPath({required String imagePath, double? height, double? width}) {
|
|
bool isNetworkImage = imagePath.startsWith('http') || imagePath.startsWith('https');
|
|
if (CakeTor.instance.enabled && isNetworkImage) {
|
|
imagePath = "assets/images/tor_logo.svg";
|
|
isNetworkImage = false;
|
|
}
|
|
final bool isSvg = imagePath.endsWith('.svg');
|
|
final double _height = height ?? 35;
|
|
final double _width = width ?? 35;
|
|
if (isNetworkImage) {
|
|
return isSvg
|
|
? SvgPicture.network(
|
|
key: ValueKey(imagePath),
|
|
imagePath,
|
|
height: _height,
|
|
width: _width,
|
|
placeholderBuilder: (BuildContext context) => Container(
|
|
height: _height,
|
|
width: _width,
|
|
child: Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
),
|
|
errorBuilder: (_, __, ___) {
|
|
return Container(
|
|
height: _height,
|
|
width: _width,
|
|
child: Center(
|
|
child: Icon(Icons.error_outline, color: Colors.grey),
|
|
),
|
|
);
|
|
},
|
|
)
|
|
: Image.network(
|
|
key: ValueKey(imagePath),
|
|
imagePath,
|
|
height: _height,
|
|
width: _width,
|
|
loadingBuilder:
|
|
(BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
|
if (loadingProgress == null) {
|
|
return child;
|
|
}
|
|
return Container(
|
|
height: _height,
|
|
width: _width,
|
|
child: Center(
|
|
child: CircularProgressIndicator(
|
|
value: loadingProgress.expectedTotalBytes != null
|
|
? loadingProgress.cumulativeBytesLoaded /
|
|
loadingProgress.expectedTotalBytes!
|
|
: null,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
|
return Container(
|
|
height: _height,
|
|
width: _width,
|
|
child: Center(
|
|
child: Icon(Icons.error_outline, color: Colors.grey),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
} else {
|
|
return isSvg
|
|
? SvgPicture.asset(
|
|
imagePath,
|
|
height: _height,
|
|
width: _width,
|
|
placeholderBuilder: (_) => Icon(Icons.error),
|
|
errorBuilder: (_, __, ___) => Icon(Icons.error),
|
|
key: ValueKey(imagePath),
|
|
)
|
|
: Image.asset(
|
|
imagePath,
|
|
height: _height,
|
|
width: _width,
|
|
errorBuilder: (_, __, ___) => Icon(Icons.error),
|
|
key: ValueKey(imagePath),
|
|
);
|
|
}
|
|
}
|
|
}
|