fix(withdraw): update amount when isMaxAmount and show dropdown icon#44
fix(withdraw): update amount when isMaxAmount and show dropdown icon#44
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (4)
- packages/komodo_defi_sdk/lib/src/market_data/market_data_manager.dart: Language not supported
- packages/komodo_ui/lib/src/core/inputs/address_select_input.dart: Language not supported
- packages/komodo_ui/lib/src/defi/withdraw/source_address_field.dart: Language not supported
- packages/komodo_ui/lib/src/defi/withdraw/withdraw_amount_field.dart: Language not supported
convert to stateful widget and use a text editing controller to set the update the amount value regardless of the enabled/disabled status of the widget
02ad091 to
7a3219f
Compare
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
WalkthroughThe changes update asset identifier handling in the market data manager by switching from Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant MDM as MarketDataManager
participant TS as _getTradingSymbol
participant Price as PriceService
Client->>MDM: Request fiat price for asset
MDM->>TS: Retrieve trading symbol for asset
TS-->>MDM: Return configSymbol
MDM->>Price: Query price using trading symbol
Price-->>MDM: Return fiat price data
MDM-->>Client: Provide fiat price result
sequenceDiagram
participant User
participant WAF as WithdrawAmountField
participant Controller as TextEditingController
User->>WAF: Open withdrawal form
WAF->>Controller: initState initializes TextEditingController with current amount
User->>WAF: Update withdrawal amount input
WAF->>WAF: didUpdateWidget updates controller text preserving cursor
Controller-->>WAF: Trigger onChanged callback
WAF-->>User: Refresh UI with updated amount and error/balance status
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/komodo_defi_sdk/lib/src/market_data/market_data_manager.dart (1)
125-128: Method encapsulation for trading symbol retrievalAdded a new
_getTradingSymbolmethod that encapsulates the logic for retrieving the trading symbol. However, there's a discrepancy between the method comment and implementation.The comment mentions preferring the
binanceIdif available, but the implementation simply returnsconfigSymbol. Consider either:
- Updating the comment to match the current implementation
- Implementing the binanceId preference as mentioned in the comment
/// Gets the trading symbol to use for price lookups. -/// Prefers the binanceId if available, falls back to configSymbol +/// Uses the configSymbol for price lookups String _getTradingSymbol(AssetId assetId) { return assetId.symbol.configSymbol; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/komodo_defi_sdk/lib/src/market_data/market_data_manager.dart(6 hunks)packages/komodo_ui/lib/src/defi/withdraw/source_address_field.dart(11 hunks)packages/komodo_ui/lib/src/defi/withdraw/withdraw_amount_field.dart(6 hunks)
🔇 Additional comments (13)
packages/komodo_ui/lib/src/defi/withdraw/source_address_field.dart (6)
61-63: Color handling improvement with withValues()This change improves color handling by using
withValues(alpha: 0.7)instead of the likely previouswithOpacity(0.7). This approach provides more control over color properties and maintains consistency with similar changes throughout the file.
76-99: Improved address selection implementationThe code now directly instantiates
AddressSelectInputinstead of using a separate helper method, which simplifies the code structure. The widget includes proper handling for address selection, copying to clipboard, and verification.The addition of the copy-to-clipboard functionality with user feedback via a SnackBar improves the user experience significantly.
112-114: Good encapsulation of address verification logicMoving the address verification logic to a dedicated method
_isAddressVerifiedenhances code readability and follows the single responsibility principle. This approach makes the code easier to maintain and test.
145-146: Consistent color opacity handlingThe change to use
withValues(alpha: 0.2)maintains consistency with the new approach for handling color opacity throughout the file.
167-168: Consistent color opacity approach across multiple componentsThe consistent application of
withValues(alpha: x)across various UI components (LoadingState text, ErrorState text, BalanceIndicator) ensures a uniform approach to managing color opacity throughout the application.Also applies to: 221-223, 350-351, 357-358
189-190: Consistent color handling in background elementsThe color opacity changes have been consistently applied to background elements like Cards and Containers, ensuring visual consistency throughout the UI.
Also applies to: 285-286, 314-315, 370-371
packages/komodo_defi_sdk/lib/src/market_data/market_data_manager.dart (4)
84-85: Improved asset identification using symbol instead of idChanged from using
idtosymbolwhen initializing known tickers, which aligns with the overall approach of using configurable symbols for asset identification throughout the system.
116-117: Consistent cache key generation using configSymbolUpdated cache key generation to use
assetId.symbol.configSymbolinstead of what was likelyassetId.idpreviously. This ensures consistency in how assets are identified when caching prices and changes.Also applies to: 121-122
174-175: Consistent use of trading symbol methodThe code now uses the new
_getTradingSymbolmethod when fetching prices and checking if a ticker is known. This improves consistency and makes future changes to symbol handling easier to implement.Also applies to: 211-213
253-254: Consistent asset identification in price queriesChanged to use
assetId.symbol.configSymbolinstead of what was likelyassetId.idwhen looking up price data and historical prices. This ensures consistent asset identification across all price-related operations.Also applies to: 286-287
packages/komodo_ui/lib/src/defi/withdraw/withdraw_amount_field.dart (3)
4-45: Enhanced widget architecture with state managementThe widget has been refactored from a
StatelessWidgetto aStatefulWidgetwith improved properties and documentation:
- Added state management capabilities
- Added essential properties (
isMaxAmount,onChanged,onMaxToggled)- Added optional properties (
amountError,hasInsufficientBalance,availableBalance)- Provided comprehensive documentation for all properties
This change significantly improves the component's flexibility and usability, addressing the PR objective to "ensure that the amount field updates correctly when the
isMaxAmountcondition is true."
47-80: Well-implemented state management for text inputThe
_WithdrawAmountFieldStateclass properly handles the text input state with these key features:
- Proper initialization of the
TextEditingController- Well-implemented
didUpdateWidgetmethod that preserves cursor position during updates- Proper resource cleanup in the
disposemethodThis implementation solves the issue mentioned in the PR objectives by ensuring the amount field updates correctly when isMaxAmount is true, while maintaining a good user experience by preserving cursor position.
97-103: Proper widget property references and controller integrationThe build method correctly references properties through
widgetand uses the controller for theTextFormField. The field is properly disabled when maximum amount is selected, and the UI correctly reflects the current state (errors, balance information).The checkbox and MAX button functionality for toggling maximum amount selection is well integrated with the new callback properties.
Also applies to: 108-148, 157-166
WithdrawAmountFieldto a StatefulWidget to update the amount field whenisMaxAmountis trueSummary by CodeRabbit
New Features
Refactor