@@ -60,8 +60,8 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
6060 setState (() {
6161 leftSelectedChain = newChain;
6262 if (newChain == Chains .TFChain .name) {
63- currentOperation = BridgeOperation .Withdraw ;
64- _handleRightChainChange (Chains .Stellar .name);
63+ currentOperation = BridgeOperation .Withdraw ;
64+ _handleRightChainChange (Chains .Stellar .name);
6565 } else {
6666 currentOperation = BridgeOperation .Deposit ;
6767 }
@@ -97,17 +97,20 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
9797 _buildChainInfo (
9898 context,
9999 selectedChain: leftSelectedChain,
100- excludeChains: [Chains . Solana .name, rightSelectedChain],
100+ excludeChains: [rightSelectedChain],
101101 onChainChanged: _handleLeftChainChange,
102+ disabledChains: rightSelectedChain == Chains .Solana .name
103+ ? [Chains .TFChain .name, Chains .Solana .name]
104+ : [Chains .Solana .name],
102105 ),
103106 _buildSwapButton (context, disableSwap),
104107 _buildChainInfo (
105108 context,
106109 selectedChain: rightSelectedChain,
107- excludeChains: [
108- leftSelectedChain,
109- if (leftSelectedChain == Chains .TFChain .name) Chains . Solana .name
110- ],
110+ excludeChains: [leftSelectedChain],
111+ disabledChains : leftSelectedChain == Chains . TFChain .name
112+ ? [ Chains .Solana .name]
113+ : [ ],
111114 onChainChanged: _handleRightChainChange,
112115 isLeft: false ,
113116 ),
@@ -122,6 +125,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
122125 required List <String > excludeChains,
123126 required ValueChanged <String > onChainChanged,
124127 bool isLeft = true ,
128+ List <String > disabledChains = const [],
125129 }) {
126130 return Flexible (
127131 flex: 1 ,
@@ -137,6 +141,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
137141 onChanged: onChainChanged,
138142 colorScheme: Theme .of (context).colorScheme,
139143 textTheme: Theme .of (context).textTheme,
144+ disabledChains: disabledChains,
140145 ),
141146 ),
142147 ],
@@ -174,6 +179,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
174179class ChainDropdown extends StatelessWidget {
175180 final String selectedChain;
176181 final List <String > excludeChains;
182+ final List <String > disabledChains;
177183 final ValueChanged <String > onChanged;
178184 final ColorScheme colorScheme;
179185 final TextTheme textTheme;
@@ -185,6 +191,7 @@ class ChainDropdown extends StatelessWidget {
185191 required this .onChanged,
186192 required this .colorScheme,
187193 required this .textTheme,
194+ this .disabledChains = const [],
188195 });
189196
190197 @override
@@ -198,16 +205,24 @@ class ChainDropdown extends StatelessWidget {
198205 child: DropdownButton <String >(
199206 value: selectedChain,
200207 items: chains.map ((c) {
208+ final isDisabled = disabledChains.contains (c);
201209 return DropdownMenuItem <String >(
202- value: c,
203- child: _ChainItem (chain: c, colorScheme: colorScheme),
210+ value: isDisabled ? null : c,
211+ enabled: ! isDisabled,
212+ child: _ChainItem (
213+ chain: c,
214+ colorScheme: colorScheme,
215+ isDisabled: isDisabled,
216+ ),
204217 );
205218 }).toList (),
206219 selectedItemBuilder: (context) => chains.map ((c) {
220+ final isDisabled = disabledChains.contains (c);
207221 return _ChainItem (
208222 chain: c,
209223 colorScheme: colorScheme,
210224 isSelected: true ,
225+ isDisabled: isDisabled,
211226 );
212227 }).toList (),
213228 onChanged: (v) => v != null ? onChanged (v) : null ,
@@ -220,22 +235,28 @@ class _ChainItem extends StatelessWidget {
220235 final String chain;
221236 final ColorScheme colorScheme;
222237 final bool isSelected;
238+ final bool isDisabled;
223239
224240 const _ChainItem ({
225241 required this .chain,
226242 required this .colorScheme,
227243 this .isSelected = false ,
244+ this .isDisabled = false ,
228245 });
229246
230247 @override
231248 Widget build (BuildContext context) {
249+ final color = isDisabled
250+ ? colorScheme.onSurface.withOpacity (0.4 )
251+ : colorScheme.onSurface;
252+
232253 return Row (
233254 children: [
234255 Image .asset (
235256 _getChainIcon (chain),
236257 width: isSelected ? 30 : 20 ,
237258 height: isSelected ? 30 : 20 ,
238- color: colorScheme.onSurface ,
259+ color: color ,
239260 ),
240261 const SizedBox (width: 8 ),
241262 Column (
@@ -246,14 +267,14 @@ class _ChainItem extends StatelessWidget {
246267 style: TextStyle (
247268 fontWeight: FontWeight .bold,
248269 fontSize: isSelected ? 14 : 12 ,
249- color: colorScheme.onSurface ,
270+ color: color ,
250271 ),
251272 ),
252273 Text (
253274 chain,
254275 style: TextStyle (
255276 fontSize: isSelected ? 12 : 10 ,
256- color: colorScheme.onSurface ,
277+ color: color ,
257278 ),
258279 ),
259280 ],
@@ -263,12 +284,11 @@ class _ChainItem extends StatelessWidget {
263284 }
264285
265286 String _getChainIcon (String chain) {
266- Map chainIcons = {
267- Chains .Stellar .name: 'assets/stellar.png' ,
268- Chains .Solana .name: 'assets/solana.png' ,
269- Chains .TFChain .name: 'assets/tf_chain.png' ,
270- };
271-
272- return chainIcons[chain] ?? 'assets/tf_chain.png' ;
287+ return {
288+ Chains .Stellar .name: 'assets/stellar.png' ,
289+ Chains .Solana .name: 'assets/solana.png' ,
290+ Chains .TFChain .name: 'assets/tf_chain.png' ,
291+ }[chain] ??
292+ 'assets/tf_chain.png' ;
273293 }
274294}
0 commit comments