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

Feature/td upload #405

Merged
merged 6 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,980 changes: 1,980 additions & 0 deletions tdesign-component/demo_tool/aop/3.16.9/aop_flutter_sdk.patch

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tdesign-component/demo_tool/aop/flutter_aop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# TODO: 指定自己的flutter目录,并且切换到3.10.0版本
flutterDir=/Users/zflyluo/tools/flutter
# TODO:指定当前example的目录,后面不带"/"
projectDir=/Users/zflyluo/WorkSpace/flutter/tdesign_group/tdesign-mobile-flutter/tdesign-component
projectDir=/Users/zflyluo/WorkSpace/flutter/tdesign_group/tdesign-flutter/tdesign-component/
# 指定aop运行版本
version=3.10.0
version=3.16.9

# 切换到3.10.0版本
cd $flutterDir
Expand All @@ -22,7 +22,7 @@ echo "=====apply aop patch end====="

bin/flutter --version

echo "=====打印日志带'TDFlutterAop',则表示AOP 应用成功====="
echo "=====打印日志带'AOPTools',则表示AOP 应用成功====="

#cd $exampleDir
#flutter clean
Expand Down
15 changes: 15 additions & 0 deletions tdesign-component/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ subprojects {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

buildscript {
//待统一的kollin版本
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
//kotlin版本对应的gradle version
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
10 changes: 8 additions & 2 deletions tdesign-component/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
PODS:
- Flutter (1.0.0)
- image_picker_ios (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- Flutter (from `Flutter`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
image_picker_ios: b545a5f16c0fa88e3ecbbce3ed4de45567a8ec18
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943

PODFILE CHECKSUM: cf0c950f7e9a456b4e325f5b8fc0f98906a3705a

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
EF2485925A6014C2D38ED73D /* [CP] Copy Pods Resources */,
BDA91D8CAA844B388F3140CD /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -169,7 +169,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -264,7 +264,7 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
EF2485925A6014C2D38ED73D /* [CP] Copy Pods Resources */ = {
BDA91D8CAA844B388F3140CD /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IntlResourceDelegate extends TDResourceDelegate {

@override
String get weeksLabel => AppLocalizations.of(context)!.dateLabel;
}

String get friday => AppLocalizations.of(context)!.friday;

@override
Expand Down
4 changes: 2 additions & 2 deletions tdesign-component/example/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import 'page/td_theme_page.dart';
import 'page/td_time_counter_page.dart';
import 'page/td_toast_page.dart';
import 'page/td_tree_select_page.dart';
import 'page/td_upload_page.dart';
import 'page/todo_page.dart';

PageBuilder _wrapInheritedTheme(WidgetBuilder builder) {
Expand Down Expand Up @@ -151,8 +152,7 @@ Map<String, List<ExamplePageModel>> exampleMap = {
ExamplePageModel(
text: 'Upload 上传',
name: 'upload',
isTodo: true,
pageBuilder: _wrapInheritedTheme((context) => const TodoPage())),
pageBuilder: _wrapInheritedTheme((context) => const TDUploadPage())),
],
'数据展示': [
ExamplePageModel(
Expand Down
2 changes: 1 addition & 1 deletion tdesign-component/example/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"yearLabel": "year",
"monthLabel": "month",
"dateLabel": "date",
"weeks":"weeks"
"weeks":"weeks",
"sunday": "SUN",
"monday": "MON",
"tuesday": "TUE",
Expand Down
2 changes: 1 addition & 1 deletion tdesign-component/example/lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"yearLabel":"年",
"monthLabel": "月",
"dateLabel": "日",
"weeks":"周"
"weeks":"周",
"sunday": "日",
"monday": "一",
"tuesday": "二",
Expand Down
202 changes: 202 additions & 0 deletions tdesign-component/example/lib/page/td_upload_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import '../annotation/demo.dart';
import '../base/example_widget.dart';

class TDUploadPage extends StatefulWidget {
const TDUploadPage({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() => TDUploadState();
}

class TDUploadState extends State<TDUploadPage> {
final List<TDUploadFile> files1 = [];
final List<TDUploadFile> files2 = [
TDUploadFile(
key: 1,
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example4.png'),
TDUploadFile(
key: 2,
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example6.png'),
TDUploadFile(
key: 3,
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example5.png'),
];
final List<TDUploadFile> files3 = [
TDUploadFile(
key: 1,
status: TDUploadFileStatus.loading,
loadingText: '上传中...',
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example5.png'),
TDUploadFile(
key: 2,
status: TDUploadFileStatus.loading,
progress: 68,
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example4.png'),
];
final List<TDUploadFile> files4 = [
TDUploadFile(
key: 1,
status: TDUploadFileStatus.retry,
retryText: '重新上传',
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example4.png'),
];
final List<TDUploadFile> files5 = [
TDUploadFile(
key: 1,
status: TDUploadFileStatus.error,
errorText: '上传失败',
remotePath:
'https://tdesign.gtimg.com/miniprogram/images/example4.png'),
];

void onVaueChanged(List<TDUploadFile> fileList, List<TDUploadFile> value,

Check warning on line 61 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
TDUploadType event) {
switch (event) {
case TDUploadType.add:
setState(() {
fileList.addAll(value);
});
break;
case TDUploadType.remove:
setState(() {
fileList.removeWhere((element) => element.key == value[0].key);
});
break;
}
}

void onClick(int key) {
print('点击 $key');
}

void onCancel() {
print('取消');
}

@override
Widget build(BuildContext context) {
return ExamplePage(
title: tdTitle(),
exampleCodeGroup: 'upload',
desc: '上传组件',
children: [
ExampleModule(
title: '组件类型',
children: [
ExampleItem(desc: '单选上传', builder: _uploadSingle),
ExampleItem(desc: '多选上传', builder: _uploadMultiple),
],
),
ExampleModule(
title: '组件状态',
children: [
ExampleItem(desc: '加载状态', builder: _uploadLoading),
ExampleItem(desc: '重新上传', builder: _uploadRetry),
ExampleItem(desc: '上传失败', builder: _uploadError),
],
),
]);
}

Widget wrapDemoContainer(String title, {required Widget child}) {
return Container(
padding: const EdgeInsets.all(16),
decoration: const BoxDecoration(color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TDText(
title,
style: const TextStyle(fontSize: 16),
),
const SizedBox(
height: 16,
),
child
],
),
);
}

@Demo(group: 'upload')
Widget _uploadSingle(BuildContext context) {
return wrapDemoContainer('单选上传',
child: TDUpload(
files: files1,
onClick: onClick,
onCancel: onCancel,
onError: print,
onValidate: print,
onChange: ((files, type) => onVaueChanged(files1, files, type)),

Check warning on line 139 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
));
}

@Demo(group: 'upload')
Widget _uploadMultiple(BuildContext context) {
return wrapDemoContainer('多选上传',
child: TDUpload(
files: files2,
multiple: true,
max: 9,
onClick: onClick,
onCancel: onCancel,
onError: print,
onValidate: print,
onChange: ((files, type) => onVaueChanged(files2, files, type)),

Check warning on line 154 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
));
}

@Demo(group: 'upload')
Widget _uploadLoading(BuildContext context) {
return wrapDemoContainer('上传图片',
child: TDUpload(
files: files3,
multiple: true,
max: 9,
onClick: onClick,
onCancel: onCancel,
onError: print,
onValidate: print,
onChange: ((files, type) => onVaueChanged(files3, files, type)),

Check warning on line 169 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
));
}

@Demo(group: 'upload')
Widget _uploadRetry(BuildContext context) {
return wrapDemoContainer('上传图片',
child: TDUpload(
files: files4,
multiple: true,
max: 9,
onClick: onClick,
onCancel: onCancel,
onError: print,
onValidate: print,
onChange: ((files, type) => onVaueChanged(files4, files, type)),

Check warning on line 184 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
));
}

@Demo(group: 'upload')
Widget _uploadError(BuildContext context) {
return wrapDemoContainer('上传图片',
child: TDUpload(
files: files5,
multiple: true,
max: 9,
onClick: onClick,
onCancel: onCancel,
onError: print,
onValidate: print,
onChange: ((files, type) => onVaueChanged(files5, files, type)),

Check warning on line 199 in tdesign-component/example/lib/page/td_upload_page.dart

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Vaue" should be "Value".
));
}
}
Loading
Loading