Skip to content

Commit fbc47e7

Browse files
committed
feat(下载对话框): 添加响应式宽度支持以改善客户端选择显示
在客户端选择下拉框中添加响应式宽度支持,根据屏幕宽度动态调整显示宽度 大屏幕上使用60%宽度,小屏幕上限制为240px以改善显示效果
1 parent ebdd2e6 commit fbc47e7

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

lib/widgets/torrent_download_dialog.dart

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,45 @@ class _TorrentDownloadDialogState extends State<TorrentDownloadDialog> {
257257
border: OutlineInputBorder(),
258258
isDense: true,
259259
),
260+
selectedItemBuilder: (context) {
261+
return _clients.map((client) {
262+
final screenWidth = MediaQuery.of(context).size.width;
263+
// 响应式宽度:手机上限制最大宽度,大屏上允许更宽
264+
final maxWidth = screenWidth > 600
265+
? screenWidth * 0.6 // 大屏上使用60%宽度
266+
: 240.0; // 小屏上限制200px
267+
268+
return SizedBox(
269+
width: maxWidth,
270+
child: Text(
271+
'${client.name} (${client.host}:${client.port})',
272+
overflow: TextOverflow.ellipsis,
273+
maxLines: 1,
274+
),
275+
);
276+
}).toList();
277+
},
260278
items: _clients.map((client) {
261279
return DropdownMenuItem(
262280
value: client,
263-
child: Text('${client.name} (${client.host}:${client.port})'),
281+
child: Builder(
282+
builder: (context) {
283+
final screenWidth = MediaQuery.of(context).size.width;
284+
// 响应式宽度:手机上限制最大宽度,大屏上允许更宽
285+
final maxWidth = screenWidth > 600
286+
? screenWidth * 0.6 // 大屏上使用60%宽度
287+
: 240.0; // 小屏上限制200px
288+
289+
return SizedBox(
290+
width: maxWidth,
291+
child: Text(
292+
'${client.name} (${client.host}:${client.port})',
293+
overflow: TextOverflow.ellipsis,
294+
maxLines: 1,
295+
),
296+
);
297+
},
298+
),
264299
);
265300
}).toList(),
266301
onChanged: (client) {

0 commit comments

Comments
 (0)