@@ -60,8 +60,8 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
60
60
setState (() {
61
61
leftSelectedChain = newChain;
62
62
if (newChain == Chains .TFChain .name) {
63
- currentOperation = BridgeOperation .Withdraw ;
64
- _handleRightChainChange (Chains .Stellar .name);
63
+ currentOperation = BridgeOperation .Withdraw ;
64
+ _handleRightChainChange (Chains .Stellar .name);
65
65
} else {
66
66
currentOperation = BridgeOperation .Deposit ;
67
67
}
@@ -97,17 +97,20 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
97
97
_buildChainInfo (
98
98
context,
99
99
selectedChain: leftSelectedChain,
100
- excludeChains: [Chains . Solana .name, rightSelectedChain],
100
+ excludeChains: [rightSelectedChain],
101
101
onChainChanged: _handleLeftChainChange,
102
+ disabledChains: rightSelectedChain == Chains .Solana .name
103
+ ? [Chains .TFChain .name, Chains .Solana .name]
104
+ : [Chains .Solana .name],
102
105
),
103
106
_buildSwapButton (context, disableSwap),
104
107
_buildChainInfo (
105
108
context,
106
109
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
+ : [ ],
111
114
onChainChanged: _handleRightChainChange,
112
115
isLeft: false ,
113
116
),
@@ -122,6 +125,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
122
125
required List <String > excludeChains,
123
126
required ValueChanged <String > onChainChanged,
124
127
bool isLeft = true ,
128
+ List <String > disabledChains = const [],
125
129
}) {
126
130
return Flexible (
127
131
flex: 1 ,
@@ -137,6 +141,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
137
141
onChanged: onChainChanged,
138
142
colorScheme: Theme .of (context).colorScheme,
139
143
textTheme: Theme .of (context).textTheme,
144
+ disabledChains: disabledChains,
140
145
),
141
146
),
142
147
],
@@ -174,6 +179,7 @@ class _SwapTransactionWidgetState extends State<SwapTransactionWidget> {
174
179
class ChainDropdown extends StatelessWidget {
175
180
final String selectedChain;
176
181
final List <String > excludeChains;
182
+ final List <String > disabledChains;
177
183
final ValueChanged <String > onChanged;
178
184
final ColorScheme colorScheme;
179
185
final TextTheme textTheme;
@@ -185,6 +191,7 @@ class ChainDropdown extends StatelessWidget {
185
191
required this .onChanged,
186
192
required this .colorScheme,
187
193
required this .textTheme,
194
+ this .disabledChains = const [],
188
195
});
189
196
190
197
@override
@@ -198,16 +205,24 @@ class ChainDropdown extends StatelessWidget {
198
205
child: DropdownButton <String >(
199
206
value: selectedChain,
200
207
items: chains.map ((c) {
208
+ final isDisabled = disabledChains.contains (c);
201
209
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
+ ),
204
217
);
205
218
}).toList (),
206
219
selectedItemBuilder: (context) => chains.map ((c) {
220
+ final isDisabled = disabledChains.contains (c);
207
221
return _ChainItem (
208
222
chain: c,
209
223
colorScheme: colorScheme,
210
224
isSelected: true ,
225
+ isDisabled: isDisabled,
211
226
);
212
227
}).toList (),
213
228
onChanged: (v) => v != null ? onChanged (v) : null ,
@@ -220,22 +235,28 @@ class _ChainItem extends StatelessWidget {
220
235
final String chain;
221
236
final ColorScheme colorScheme;
222
237
final bool isSelected;
238
+ final bool isDisabled;
223
239
224
240
const _ChainItem ({
225
241
required this .chain,
226
242
required this .colorScheme,
227
243
this .isSelected = false ,
244
+ this .isDisabled = false ,
228
245
});
229
246
230
247
@override
231
248
Widget build (BuildContext context) {
249
+ final color = isDisabled
250
+ ? colorScheme.onSurface.withOpacity (0.4 )
251
+ : colorScheme.onSurface;
252
+
232
253
return Row (
233
254
children: [
234
255
Image .asset (
235
256
_getChainIcon (chain),
236
257
width: isSelected ? 30 : 20 ,
237
258
height: isSelected ? 30 : 20 ,
238
- color: colorScheme.onSurface ,
259
+ color: color ,
239
260
),
240
261
const SizedBox (width: 8 ),
241
262
Column (
@@ -246,14 +267,14 @@ class _ChainItem extends StatelessWidget {
246
267
style: TextStyle (
247
268
fontWeight: FontWeight .bold,
248
269
fontSize: isSelected ? 14 : 12 ,
249
- color: colorScheme.onSurface ,
270
+ color: color ,
250
271
),
251
272
),
252
273
Text (
253
274
chain,
254
275
style: TextStyle (
255
276
fontSize: isSelected ? 12 : 10 ,
256
- color: colorScheme.onSurface ,
277
+ color: color ,
257
278
),
258
279
),
259
280
],
@@ -263,12 +284,11 @@ class _ChainItem extends StatelessWidget {
263
284
}
264
285
265
286
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' ;
273
293
}
274
294
}
0 commit comments