Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Upload组件,限制最大数量存在BUG #440

Open
q920447939 opened this issue Jan 3, 2025 · 5 comments
Open

使用Upload组件,限制最大数量存在BUG #440

q920447939 opened this issue Jan 3, 2025 · 5 comments

Comments

@q920447939
Copy link
Contributor

q920447939 commented Jan 3, 2025

tdesign-flutter 版本

0.1.8

重现链接

https://github.com/Tencent/tdesign-flutter/tree/main/tdesign-component/example

重现步骤

Upload中有一个属性是 max ,用来限制最大数量。
比如 max 填入3
如果在选择时,选择超过3张照片以上 ,那么直接报错

I/flutter ( 8076): TDUploadValidatorError.overQuantity

期望结果

选择的图片数量大于max, 应该不可以再选择图片或者对用户提示选择的数量超过max数量(但是如果给予i提示的话,那么对用户的体验来说不友好)

实际结果

报错

I/flutter ( 8076): TDUploadValidatorError.overQuantity

Flutter版本

3.24.4

设备与机型信息

Android

系统版本

emulator

补充说明

使用example 工程,应该可以复现。

IssueShoot

  • 预估时长:1
  • 期望完成时间:2025-2-28
  • 开发难度:中
  • 参与人数:1
  • 需求对接人:zflyluo
  • 验收标准:实现期望改造效果,提 MR并通过 验收无误。点击直接弹图片的功能,希望有个参数定义是否开启。
  • 备注:最终激励以实际提交 pr 并合并为准。TDesignFlutter贡献指南:https://tdesign.tencent.com/flutter/develop
Copy link
Contributor

github-actions bot commented Jan 3, 2025

👋 @q920447939,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@Jzow
Copy link
Contributor

Jzow commented Jan 6, 2025

感谢,晚点我写个测试页面看一下。

但是如果给予i提示的话,那么对用户的体验来说不友好

我理解这个需求,当上传数量超过max的阈值时,需要提供一个Toast提示,是这样吗?

@q920447939
Copy link
Contributor Author

是这个意思。但是我觉得可以更加通用一点,Toast 可以允许用户来实现

Copy link
Contributor

github-actions bot commented Feb 5, 2025

这个 Issue 被标记为了过时 stale ,因为它已经持续 30 天没有任何活动了。删除 stale 标签或评论,否则将在 7 天内关闭。

@Jzow
Copy link
Contributor

Jzow commented Feb 7, 2025

下个版本会支持Toast提示,为Upload组件新增了一个onMaxLimitReached函数,它是可选的,当onMaxLimitReached函数不填写的时候,默认控制台还是会提示TDUploadValidatorError.overQuantity错误。

下面是个简单示例:

final List<TDUploadFile> files1 = [
    TDUploadFile(key: 1, remotePath: 'https://tdesign.gtimg.com/demo/images/example1.png'),
    TDUploadFile(key: 2, remotePath: 'https://tdesign.gtimg.com/demo/images/example2.png'),
    TDUploadFile(key: 3, remotePath: 'https://tdesign.gtimg.com/demo/images/example3.png'),
];

void tips() {
    TDToast.showIconText('选择的图片数量超过最大限制', icon: TDIcons.chat_error, context: context);
}

TDUpload(
    files: files1,
    multiple: true,
    max: 1,
    onClick: onClick,
    onCancel: onCancel,
    onError: print,
    onValidate: print,
    onMaxLimitReached: tips,
    onChange: ((files, type) => onValueChanged(files1, files, type)),
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants