diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk
new file mode 120000
index 000000000..10d6e348b
--- /dev/null
+++ b/.fvm/flutter_sdk
@@ -0,0 +1 @@
+/Users/broadli/fvm/3.3.0
\ No newline at end of file
diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json
new file mode 100644
index 000000000..e44645b53
--- /dev/null
+++ b/.fvm/fvm_config.json
@@ -0,0 +1,4 @@
+{
+ "flutterSdkVersion": "3.3.0",
+ "flavors": {}
+}
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/bug-report.zh-CN.yml b/.github/ISSUE_TEMPLATE/bug-report.zh-CN.yml
index e30a7bba4..8a87371a7 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.zh-CN.yml
+++ b/.github/ISSUE_TEMPLATE/bug-report.zh-CN.yml
@@ -6,11 +6,13 @@ body:
attributes:
value: |
# 欢迎你的参与
- tdesign-flutter 的 Issue 列表接受 bug 报告或是新功能请求。也可加入官方社区:
+ tdesign-flutter 的 Issue 列表接受 bug 报告或是新功能请求。也可加入官方社区:
+
+
在发布一个 Issue 前,请确保:
- - 在 [常见问题](https://tdesign.tencent.com/about/faq)、[更新日志](https://github.com/TDesignOteam/tdesign-flutter/blob/main/CHANGELOG.md) 和 [旧Issue列表](https://github.com/TDesignOteam/tdesign-flutter/issues?q=is%3Aissue) 中搜索过你的问题。(你的问题可能已有人提出,也可能已在最新版本中被修正)
- - 如果你发现一个已经关闭的旧 Issue 在最新版本中仍然存在,不要在旧 Issue 下面留言,请建一个新的 issue。
+ - 在 [常见问题](https://github.com/Tencent/tdesign-flutter/blob/main/tdesign-site/FAQ.md)、[更新日志](https://tdesign.tencent.com/flutter/changelog) 和 [Issue列表](https://github.com/Tencent/tdesign-flutter/issues) 中搜索过你的问题。(你的问题可能已有人提出,也可能已在最新版本中被修正)
+ - 如果你发现一个已经关闭的旧 Issue 在最新版本中仍然存在,不要在旧 Issue 下面留言,请建一个新的 issue。
- type: input
id: version
@@ -31,7 +33,7 @@ body:
- type: textarea
id: reproduceSteps
attributes:
- label: 重现步骤
+ label: 重现步骤/代码
description: 请清晰的描述重现该 Issue 的步骤,这能帮助我们快速定位问题。没有清晰重现步骤将不会被修复,标有 'need reproduction' 的 Issue 在 7 天内不提供相关步骤,将被关闭。
placeholder: 请填写
diff --git a/.github/ISSUE_TEMPLATE/doc-report.zh-CN.yml b/.github/ISSUE_TEMPLATE/doc-report.zh-CN.yml
new file mode 100644
index 000000000..24ee02e3e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/doc-report.zh-CN.yml
@@ -0,0 +1,23 @@
+name: 反馈文档
+description: 通过 github 模板进行文档反馈。
+title: "[文档名称] 描述问题的标题"
+body:
+ - type: markdown
+ attributes:
+ value: |
+ # 欢迎你的参与
+ tdesign-flutter 的 Issue 列表接受 bug 报告或是新功能请求。也可加入官方社区:
+
+
+
+ 在发布一个 Issue 前,请确保:
+ - 在 [常见问题](https://github.com/Tencent/tdesign-flutter/blob/main/tdesign-site/FAQ.md)、[更新日志](https://tdesign.tencent.com/flutter/changelog) 和 [Issue列表](https://github.com/Tencent/tdesign-flutter/issues) 中搜索过你的问题。(你的问题可能已有人提出,也可能已在最新版本中被修正)
+ - 如果你发现一个已经关闭的旧 Issue 在最新版本中仍然存在,不要在旧 Issue 下面留言,请建一个新的 issue。
+
+ - type: textarea
+ id: docModificationPlan
+ attributes:
+ label: 你建议的文案是什么
+ placeholder: 请填写
+ validations:
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/feature-report.zh-CN.yml b/.github/ISSUE_TEMPLATE/feature-report.zh-CN.yml
index 3d23ab0a1..8c3eed530 100644
--- a/.github/ISSUE_TEMPLATE/feature-report.zh-CN.yml
+++ b/.github/ISSUE_TEMPLATE/feature-report.zh-CN.yml
@@ -6,11 +6,13 @@ body:
attributes:
value: |
# 欢迎你的参与
- tdesign-flutter 的 Issue 列表接受 bug 报告或是新功能请求。也可加入官方社区:
-
+ tdesign-flutter 的 Issue 列表接受 bug 报告或是新功能请求。也可加入官方社区:
+
+
+
在发布一个 Issue 前,请确保:
- - 在 [常见问题](https://tdesign.tencent.com/about/faq)、[更新日志](https://github.com/TDesignOteam/tdesign-flutter/blob/main/CHANGELOG.md) 和 [旧Issue列表](https://github.com/TDesignOteam/tdesign-flutter/issues?q=is%3Aissue) 中搜索过你的问题。(你的问题可能已有人提出,也可能已在最新版本中被修正)
- - 如果你发现一个已经关闭的旧 Issue 在最新版本中仍然存在,不要在旧 Issue 下面留言,请建一个新的 issue。
+ - 在 [常见问题](https://github.com/Tencent/tdesign-flutter/blob/main/tdesign-site/FAQ.md)、[更新日志](https://tdesign.tencent.com/flutter/changelog) 和 [Issue列表](https://github.com/Tencent/tdesign-flutter/issues) 中搜索过你的问题。(你的问题可能已有人提出,也可能已在最新版本中被修正)
+ - 如果你发现一个已经关闭的旧 Issue 在最新版本中仍然存在,不要在旧 Issue 下面留言,请建一个新的 issue。
- type: textarea
id: functionContent
diff --git a/.github/ISSUE_TEMPLATE/new-component.zh-CN.md b/.github/ISSUE_TEMPLATE/new-component.zh-CN.md
index 3408d6b90..25095c74c 100644
--- a/.github/ISSUE_TEMPLATE/new-component.zh-CN.md
+++ b/.github/ISSUE_TEMPLATE/new-component.zh-CN.md
@@ -13,18 +13,22 @@ issue label 需要设置为 help wanted,发起招募
-->
## 组件名称中英文
-
+
+
### 设计稿
设计稿:
+截图:
+
### 参与贡献
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index d7e832812..8e2b679f0 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,4 +1,8 @@
### 🤔 这个 PR 的性质是?
+> 勾选规则:
+> 1.只要有新增参数,就勾选”新特性提交“
+> 2.只修改内部bug,未新增参数,才勾选”日常 bug 修复“
+> 3.其他选项视具体改动判断
- [ ] 日常 bug 修复
- [ ] 新特性提交
@@ -40,7 +44,7 @@
⚠️ 请自检并全部**勾选全部选项**。⚠️
-- [ ] 文档已补充或无须补充
-- [ ] 代码演示已提供或无须提供
-- [ ] TypeScript 定义已补充或无须补充
-- [ ] Changelog 已提供或无须提供
+- [ ] pr目标分支为develop分支,请勿直接往main分支合并
+- [ ] 标题格式为:`组件类名`: 修改描述(示例:`TDBottomTabBar`: 修复iconText模式,底部溢出2.5像素)
+- [ ] ”相关issue“处带上修复的issue链接
+- [ ] 相关文档已补充或无须补充
diff --git a/.github/_workflows/issue-stale-close.temp.yml b/.github/_workflows/issue-stale-close.temp.yml
new file mode 100644
index 000000000..c8f8111ef
--- /dev/null
+++ b/.github/_workflows/issue-stale-close.temp.yml
@@ -0,0 +1,28 @@
+## 忽略当前 ci 功能,待修复
+## force copy from tencent/tdesign
+## 国际标准时间+8
+#name: Close stale issues and PRs
+#on:
+# schedule:
+# - cron: "50 5 * * *"
+#
+#jobs:
+# close-issues:
+# runs-on: ubuntu-latest
+# permissions:
+# issues: write
+# pull-requests: write
+# steps:
+# - uses: actions/stale@v4
+# with:
+# stale-issue-message: "这个 Issue 被标记为了过时 stale ,因为它已经持续 30 天没有任何活动了。删除 stale 标签或评论,否则将在 7 天内关闭。"
+# stale-pr-message: '这个 PR 已经过时了,因为它已经持续 45 天没有任何活动了。 删除 stale 的标签或评论,否则将在 10 天内关闭。'
+# close-issue-message: "此 Issue 被自动关闭,因为它自被标记为过时 stale 以来已闲置 7 天。"
+# close-pr-message: "此 PR 被自动关闭,因为它已经 stable 停滞了 10 天,没有任何活动。"
+# days-before-stale: 30
+# days-before-close: 7
+# days-before-pr-stale: 45
+# days-before-pr-close: 10
+# repo-token: ${{ secrets.GITHUB_TOKEN }}
+# exempt-issue-labels: 'WIP'
+# exempt-pr-labels: 'WIP'
\ No newline at end of file
diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml
new file mode 100644
index 000000000..1ed575905
--- /dev/null
+++ b/.github/workflows/auto-release.yml
@@ -0,0 +1,98 @@
+name: Auto Release
+
+on:
+ pull_request:
+ branches: [develop]
+ types: [opened, synchronize, reopened, closed]
+ paths:
+ - "tdesign-component/pubspec.yaml"
+ issue_comment:
+ types: [edited]
+
+jobs:
+ generator:
+ runs-on: ubuntu-latest
+ if: >
+ github.event_name == 'pull_request' &&
+ github.event.pull_request.merged == false &&
+ startsWith(github.head_ref, 'release/')
+ steps:
+ - run: echo "The head of this PR starts with 'release/'"
+ - uses: actions/checkout@v4
+ - uses: TDesignOteam/tdesign-tag-action@main
+ id: tag-action
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ version_file: ./tdesign-component/pubspec.yaml
+ - uses: TDesignOteam/tdesign-changelog-action@main
+ id: changelog
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag: ${{ steps.tag-action.outputs.version }}
+ - name: Add comment
+ uses: peter-evans/create-or-update-comment@v1
+ with:
+ issue-number: ${{ github.event.pull_request.number }}
+ body: |
+ ${{ steps.changelog.outputs.changelog }}
+ comment_add_log:
+ runs-on: ubuntu-latest
+ if: >
+ github.event_name == 'issue_comment'
+ && github.event.issue.pull_request
+ && github.event.sender.login == github.event.issue.user.login
+ && startsWith(github.event.comment.body, '## 🌈 ')
+ steps:
+ - id: comment
+ shell: bash
+ run: |
+ result=$(curl ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}")
+ headrefreg='"ref": "(release/[[:digit:]]{1,2}\.[[:digit:]]{1,2}\.[[:digit:]]{1,2})",'
+ if [[ $result =~ $headrefreg ]]
+ then
+ echo "属于 release pr 的 comment ${BASH_REMATCH[1]}"
+ else
+ echo "不属于 release pr 的 comment" && exit 1
+ fi
+ echo "::set-output name=branch::${BASH_REMATCH[1]}"
+ # zsh $match[1]
+ - uses: actions/checkout@v3
+ with:
+ ref: ${{ steps.comment.outputs.branch }}
+ - name: Commit and push if needed
+ env:
+ BODY: ${{ github.event.comment.body }}
+ run: |
+ txt=$(cat tdesign-site/CHANGELOG.md)
+ echo "${txt%%##*}$BODY${txt##*---}" > tdesign-site/CHANGELOG.md
+ git add .
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
+ git config --local user.name "github-actions[bot]"
+ git commit -m "chore: changelog's changes"
+ git push
+ echo "💾 pushed changelog's changes"
+ merge_tag:
+ runs-on: ubuntu-latest
+ if: >
+ github.event_name == 'pull_request' &&
+ github.event.pull_request.merged == true &&
+ startsWith(github.head_ref, 'release/')
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: develop
+ token: ${{ secrets.PERSONAL_TOKEN }}
+ - uses: TDesignOteam/tdesign-tag-action@main
+ id: tag-action
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ version_file: ./tdesign-component/pubspec.yaml
+ - name: tag and push if needed
+ run: |
+ echo "${{ steps.tag-action.outputs.version }}"
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
+ git config --local user.name "github-actions[bot]"
+ git tag ${{ steps.tag-action.outputs.version }}
+ git push origin ${{ steps.tag-action.outputs.version }}
+ echo "pushed tag ${{ steps.tag-action.outputs.version }}"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..19e6fb48b
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,119 @@
+name: ci
+
+on:
+ pull_request:
+ branches: [develop, main]
+ types: [opened, synchronize, reopened]
+
+jobs:
+ build-apk:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ flutter-version:
+ - 3.16.9
+ - 3.x
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: subosito/flutter-action@v2
+ with:
+ channel: "stable"
+ flutter-version: ${{ matrix.flutter-version }}
+ cache: true
+
+ - run: flutter --version
+
+ - name: init.sh
+ working-directory: ./tdesign-component
+ run: |
+ chmod +x ./init.sh
+ ./init.sh
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component
+ run: flutter pub get
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component/example
+ run: flutter pub get
+
+ - name: flutter build
+ working-directory: ./tdesign-component/example
+ run: flutter build apk -t ./lib/main.dart --release
+
+
+ build-ios:
+ runs-on: macos-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ flutter-version:
+ - 3.16.9
+ - 3.x
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: subosito/flutter-action@v2
+ with:
+ channel: "stable"
+ flutter-version: ${{ matrix.flutter-version }}
+ cache: true
+
+ - run: flutter --version
+
+ - name: init.sh
+ working-directory: ./tdesign-component
+ run: |
+ chmod +x ./init.sh
+ ./init.sh
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component
+ run: flutter pub get
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component/example
+ run: flutter pub get
+
+ - name: flutter build
+ working-directory: ./tdesign-component/example
+ run: flutter build ios --release --no-codesign
+
+ build-web:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ flutter-version:
+ - 3.16.9
+ - 3.x
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: subosito/flutter-action@v2
+ with:
+ channel: "stable"
+ flutter-version: ${{ matrix.flutter-version }}
+ cache: true
+
+ - run: flutter --version
+
+ - name: init.sh
+ working-directory: ./tdesign-component
+ run: |
+ chmod +x ./init.sh
+ ./init.sh
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component
+ run: flutter pub get
+
+ - name: flutter pub get
+ working-directory: ./tdesign-component/example
+ run: flutter pub get
+
+ - name: flutter build
+ working-directory: ./tdesign-component/example
+ run: flutter build web
diff --git a/.github/workflows/issue-stale-close.temp.yml b/.github/workflows/issue-stale-close.temp.yml
deleted file mode 100644
index 14e04f4b5..000000000
--- a/.github/workflows/issue-stale-close.temp.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-# force copy from tencent/tdesign
-# 国际标准时间+8
-name: Close stale issues and PRs
-on:
- schedule:
- - cron: "50 5 * * *"
-
-jobs:
- close-issues:
- runs-on: ubuntu-latest
- permissions:
- issues: write
- pull-requests: write
- steps:
- - uses: actions/stale@v4
- with:
- stale-issue-message: "这个 Issue 被标记为了过时 stale ,因为它已经持续 30 天没有任何活动了。删除 stale 标签或评论,否则将在 7 天内关闭。"
- stale-pr-message: '这个 PR 已经过时了,因为它已经持续 45 天没有任何活动了。 删除 stale 的标签或评论,否则将在 10 天内关闭。'
- close-issue-message: "此 Issue 被自动关闭,因为它自被标记为过时 stale 以来已闲置 7 天。"
- close-pr-message: "此 PR 被自动关闭,因为它已经 stable 停滞了 10 天,没有任何活动。"
- days-before-stale: 30
- days-before-close: 7
- days-before-pr-stale: 45
- days-before-pr-close: 10
- repo-token: ${{ secrets.GITHUB_TOKEN }}
- exempt-issue-labels: 'WIP'
- exempt-pr-labels: 'WIP'
\ No newline at end of file
diff --git a/.github/workflows/pr-spelling.template.yml b/.github/workflows/pr-spelling.template.yml
new file mode 100644
index 000000000..d6237cdd1
--- /dev/null
+++ b/.github/workflows/pr-spelling.template.yml
@@ -0,0 +1,13 @@
+name: pr-spell-check
+on: [pull_request]
+
+jobs:
+ run:
+ name: Spell Check with Typos
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Check spelling
+ uses: crate-ci/typos@master
+ with:
+ config: .github/workflows/typos-config.toml
diff --git a/.github/workflows/tag-push.yml b/.github/workflows/tag-push.yml
new file mode 100644
index 000000000..064d55e58
--- /dev/null
+++ b/.github/workflows/tag-push.yml
@@ -0,0 +1,24 @@
+# 文件名建议统一为 tag-push.yml
+# 应用 publish.yml 的 demo
+
+name: TAG_PUSH
+
+on: create
+
+jobs:
+ TAG_PUSH:
+ runs-on: ubuntu-latest
+ if: github.event.ref_type == 'tag'
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: main
+ fetch-depth: 0
+ token: ${{ secrets.PERSONAL_TOKEN }}
+ - run: |
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
+ git config --local user.name "github-actions[bot]"
+ git status
+ git fetch origin
+ git merge origin/develop
+ git push origin main
diff --git a/.github/workflows/typos-config.toml b/.github/workflows/typos-config.toml
new file mode 100644
index 000000000..d9918c1e2
--- /dev/null
+++ b/.github/workflows/typos-config.toml
@@ -0,0 +1,6 @@
+default.check-filename = true
+
+[default.extend-words]
+
+[files]
+extend-exclude = ["project.pbxproj","aop_flutter_sdk.patch"]
diff --git a/.gitignore b/.gitignore
index d7fe93933..9a90b4cb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,8 @@
.history
.svn/
+tdesign-site/node_modules/
+
# IntelliJ related
*.iml
*.ipr
@@ -71,4 +73,8 @@ build/
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
-!**/ios/**/default.perspectivev3
\ No newline at end of file
+!**/ios/**/default.perspectivev3
+/.fvm/
+/tdesign-component/local_dependency_override.yaml
+/tdesign-component/pubspec_overrides.yaml
+/tdesign-component/example/pubspec_overrides.yaml
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..f93c480d0
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "tdesign-site/src/_common"]
+ path = tdesign-site/src/_common
+ url = https://github.com/Tencent/tdesign-common.git
+ branch = develop
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000..f95d69073
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,128 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder](https://github.com/mozilla/diversity).
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see the FAQ at
+https://www.contributor-covenant.org/faq. Translations are available at
+https://www.contributor-covenant.org/translations.
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..0ea942569
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,27 @@
+# CONTRIBUTING
+
+## 目录结构
+
+```text
+tdesign-component/
+├── demo_tool // API和演示代码
+├── examples // 组件使用示例
+├── lib // 组件库
+└── tests // 组件测试
+
+tdesign-site/ // tdesign flutter站点
+```
+
+## 开发规范
+
+- 组件命名规范:以TD为前缀,组件名称、API名称参考TDesign现有组件和API命名,可以根据flutter原生Widget的特点进行修改。组件API以满足设计要求和使用为准,可根据flutter特点做精简或定制。
+- 组件库用到的所有色值、圆角、字体字号等样式属性需全部定义在主题中。
+- 代码规范遵循腾讯Dart代码规范。
+- 对于系统原有组件,如Text,Image等,应兼容系统原组件功能,只能扩展,不能阉割,以免业务需要使用系统功能时,必须放弃TDesign控件。
+- 示例页面尽量使用ExamplePage+ExampleModule+ExampleItem组合,按照示例稿的布局实现;页面写完后,在main.dart中修改exampleMap对应组件的isTodo属性即可。
+- 组件API和演示代码,请参考demo_tool/README.md文件。
+- 组件内部的固定文案,都应该抽离到TDResourceDelegate中统一管理,方便业务进行国际化适配
+- 如果使用的组件TD有封装,尽量使用TD已有组件,而非直接使用系统组件
+
+## 更多
+更多内容请参考:[贡献指南](https://tdesign.tencent.com/flutter/develop)
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 789cbde93..018620472 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,9 +1,9 @@
MIT License
-Copyright (c) 2021-present TDesign
+Copyright (c) 2023-present TDesign, tdesign@tencent.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/PUBLISH.md b/PUBLISH.md
new file mode 100644
index 000000000..ca6de13e0
--- /dev/null
+++ b/PUBLISH.md
@@ -0,0 +1,10 @@
+# 版本发布流程
+
+## 发布流程
+
+- 从 `develop` 新建 `release/x.y.z` 分支,并修改 `tdesign-component/pubspec.yaml` 中的`version`版本号,推送分支至远程仓库,并提交一个合入`develop`的 Pull Request 到仓库
+- 仓库的 Github Action 会自动整理上个版本至今 commit 对应的 CHANGELOG,并将 CHANGELOG 的 draft 作为一个评论推送到该 Pull Request 上
+- 发布人检查 CHANGELOG,并优化内容逻辑结构,确认无误后删除对于评论首行提示,Github Action 会将优化后的内容写入 CHANGELOG.md 内
+- 确认无误后,合并分支入`develop`
+- 合入 `develop` 后,仓库会触发 Github Action 合入`main`分支,并将版本号作为 `tag` 打在仓库上,并触发 Github Action 执行版本发布流程
+- 合入 `main` 分支后,站点的部署流水线 web hook 会监听到 `main` 分支的新增 commit,并触发流水线,官网更新站点
diff --git a/README.md b/README.md
index 6d14a6801..421c197df 100644
--- a/README.md
+++ b/README.md
@@ -4,49 +4,103 @@
-TDesign Flutter技术栈组件库,适合在移动端项目中使用。
-
-# 特性
-
-- 提供TDesign设计风格的Flutter UI组件库
-- 支持根据App设计风格定制主题
-- 提供常用Icon库,支持定制替换
-- 根据TDesign规范定义颜色组,可在TDColors中查看,方便适配TDesign规范的组件
-- 色值声明类可以添加默认颜色,实时查看色值默认显示效果
-
-# 使用方法
-- 在pubbspec.yaml引入依赖。
-
- dependencies:
- tdesign_flutter:
- git: https://github.com/TDesignOteam/tdesign-flutter.git
-
-- 在文件头部引入:import 'package:tdesign_flutter/td_export.dart'; // 组件库相关的,只需要引入这个文件,里面暴露td前缀所有需要的类
-- 可通过json文件配置颜色/字体尺寸/字体样式/圆角/阴影等主题样式。通过TDTheme.of(context)或者TDTheme.defaultData()获取主题数据。建议组件都使用TDTheme.of(context)的,不需要跟随局部主题的组件,才可以使用TDTheme.defaultData()。
-
- 颜色,字体,圆角等使用示例:
- TDTheme.of(context).brandNormalColor
- TDTheme.defaultData().fontM
-- TDesign的Icon不跟随主题,都是ttf格式:
-
- 使用示例:
- TDIcon(TDIcons.activity)
-
-- 使用示例:example/lib/tdesign/page
-
-# 开发规范
-- 组件命名规范:以TD为前缀,组件名称、API名称参考TDesign现有组件和API命名,可以根据flutter原生Widget的特点进行修改。组件API以满足设计要求和使用为准,可根据flutter特点做精简或定制。
-- 组件库用到的所有色值、圆角、字体字号等样式属性需全部定义在主题中。
-- 代码规范遵循腾讯Dart代码规范。
-- 对于系统原有组件,如Text,Image等,应兼容系统原组件功能,只能扩展,不能阉割,以免业务需要使用系统功能时,必须放弃TDesign控件。
-- 示例页面尽量使用ExampleWidget+ExampleItem组合,在ExampleItem的desc写明示例描述;页面写完后,在main.dart中将页面注册进examplePageList即可。
-
-
-# 其他技术栈实现
-- 桌面端 Vue 3 实现:[web-vue-next](https://github.com/Tencent/tdesign-vue-next)
-- 桌面端 Vue 实现: [web-react](https://github.com/Tencent/tdesign-vue)
-- 移动端小程序实现: [小程序](https://github.com/Tencent/tdesign-miniprogram)
-
-# 开源协议
-
-TDesign 遵循 [MIT 协议](https://github.com/TDesignOteam/tdesign-flutter/blob/main/LICENSE)
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+English | [简体中文](README_zh_CN.md)
+
+Tencent TDesign UI component library of Flutter, suitable for use in mobile projects.
+
+
+# 🎉 Features
+
+- Provides Flutter UI component library in TDesign design style
+- Support customizing themes according to App design style
+- Provides commonly used Icon library and supports customized replacement
+- Define color groups according to the TDesign specification, which can be viewed in TDColors to facilitate the adaptation of components to the TDesign specification.
+- The color value declaration class can add default colors and view the default display effect of color values in real time.
+
+
+# 🔨 Usage
+- SDK dependency version
+```yaml
+dart: ">=2.19.0 <4.0.0"
+flutter: ">=3.7.0"
+```
+
+- Add the dependency in `pubspec.yaml`
+
+```yaml
+dependencies:
+ tdesign_flutter: ^0.0.6
+```
+
+- Import at the top of your file:
+
+```dart
+import 'package:tdesign_flutter/tdesign_flutter.dart';
+```
+
+- You can configure theme styles such as colors, font sizes, font styles, corner radius, and shadows through a json file.
+Retrieve theme data using `TDTheme.of(context)` or `TDTheme.defaultData()`. It is recommended
+that components use `TDTheme.of(context)` unless the component does not need to follow local themes,
+in which case `TDTheme.defaultData()` can be used.
+
+Examples of using colors, fonts, and corner radius:
+
+```dart
+TDTheme.of(context).brandNormalColor
+TDTheme.defaultData().fontBodyLarge
+```
+
+- TDesign's icons do not follow the theme, they are all in ttf format, usage examples:
+
+```dart
+Icon(TDIcons.activity)
+```
+
+- For more use examples, please refer to [example/lib/page](tdesign-component/example/lib/page)
+
+
+# TDesign component libraries
+
+TDesign also provides component libraries for other platforms and frameworks.
+
+- component library for Vue 2.x : [tdesign-vue](https://github.com/Tencent/tdesign-vue)
+- component library for Vue 3.x : [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next)
+- component library for React : [tdesign-react](https://github.com/Tencent/tdesign-react)
+- component library for Vue 3.x Mobile : [tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue)
+- component library for React Mobile : [tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react)
+- component library for Wechat miniprogram : [tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram)
+
+# Acknowledgements
+
+TDesign Flutter depends on the following component libraries. We appreciate the authors for their open-source contributions:
+
+- [easy_refresh](https://pub-web.flutter-io.cn/packages/easy_refresh)
+- [flutter_swiper](https://pub-web.flutter-io.cn/packages/flutter_swiper)
+- [flutter_slidable](https://pub-web.flutter-io.cn/packages/flutter_slidable)
+- [image_picker](https://pub-web.flutter-io.cn/packages/image_picker)
+
+# Contributing
+
+Contributing is welcome. Read [guidelines for contributing](CONTRIBUTING.md) before submitting your [Pull Request](https://github.com/Tencent/tdesign-flutter/pulls).
+
+# Feedback
+
+Create your [Github issues](https://github.com/Tencent/tdesign-flutter/issues) or scan the QR code below to join our user groups
+
+
+
+# License
+
+The MIT License. Please see [the license file](LICENSE) for more information.
\ No newline at end of file
diff --git a/README_zh_CN.md b/README_zh_CN.md
new file mode 100644
index 000000000..4902a1136
--- /dev/null
+++ b/README_zh_CN.md
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+简体中文 | [English](README.md)
+
+腾讯TDesign Flutter技术栈组件库,适合在移动端项目中使用。
+
+
+# 🎉 特性
+
+- 提供 TDesign 设计风格的 Flutter UI 组件库。
+- 支持根据 App 设计风格定制主题。
+- 提供常用 Icon 库,支持定制替换。
+- 根据 TDesign 规范定义颜色组,可在 TDColors 中查看,方便适配 TDesign 规范的组件。
+- 色值声明类可以添加默认颜色,实时查看色值默认显示效果。
+
+
+# 🔨 使用
+- SDK 版本依赖
+```yaml
+dart: ">=2.19.0 <4.0.0"
+flutter: ">=3.7.0"
+```
+
+- 在 `pubspec.yaml` 添加依赖。
+
+```yaml
+dependencies:
+ tdesign_flutter: ^0.0.6
+```
+
+- 在文件头部引入:
+
+```dart
+import 'package:tdesign_flutter/tdesign_flutter.dart';
+```
+
+- 您可以通过json文件配置主题样式,如颜色、字体大小、字体样式、角半径和阴影。使用 `TDTheme.of(context)` 或 `TDTheme.defaultData()` 获取主题数据。
+ 建议组件使用 `TDTheme.of(context)`,除非组件不需要遵循本地主题,在这种情况下可以使用 `TDTheme.defaultData()`。
+
+颜色,字体,圆角等使用示例:
+
+```dart
+TDTheme.of(context).brandNormalColor
+TDTheme.defaultData().fontBodyLarge
+```
+
+- TDesign的图标不遵循主题,它们都是ttf格式,使用示例:
+
+```dart
+Icon(TDIcons.activity)
+```
+
+- 有关更多使用示例,请参阅 [example/lib/page](tdesign-component/example/lib/page)
+
+
+# 其他技术栈实现
+
+- 桌面端 Vue 2.X 版本实现:[tdesign-vue](https://github.com/Tencent/tdesign-vue)
+- 桌面端 Vue 3.X 版本实现:[tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next)
+- 桌面端 React 实现:[tdesign-react](https://github.com/Tencent/tdesign-react)
+- 手机端 Vue 3.X 版本实现:[tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue)
+- 手机端 React 实现:[tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react)
+- 移动端小程序实现:[tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram)
+
+# 致谢
+
+TDesign Flutter 依赖以下组件库,感谢作者的开源贡献:
+
+- [easy_refresh](https://pub-web.flutter-io.cn/packages/easy_refresh)
+- [flutter_swiper](https://pub-web.flutter-io.cn/packages/flutter_swiper)
+- [flutter_slidable](https://pub-web.flutter-io.cn/packages/flutter_slidable)
+- [image_picker](https://pub-web.flutter-io.cn/packages/image_picker)
+
+# Contributing
+
+Contributing is welcome. Read [guidelines for contributing](CONTRIBUTING.md) before submitting your [Pull Request](https://github.com/Tencent/tdesign-flutter/pulls).
+
+# 反馈
+
+有任何问题,建议通过 [Github issues](https://github.com/Tencent/tdesign-flutter/issues) 反馈或扫码加入用户微信群。
+
+
+
+# 开源协议
+
+TDesign 遵循 [MIT 协议](LICENSE)。
\ No newline at end of file
diff --git a/analysis_options.yaml b/analysis_options.yaml
deleted file mode 100644
index 660a4e245..000000000
--- a/analysis_options.yaml
+++ /dev/null
@@ -1,208 +0,0 @@
-analyzer:
- enable-experiment:
- - extension-methods
- errors:
- unused_import: ignore
- camel_case_types: warning
- missing_required_param: error
- missing_return: warning
- todo: ignore
- non_constant_identifier_names: warning
- constant_identifier_names: warning
- library_names: warning
- file_names: warning
- avoid_setters_without_getters: warning
- avoid_return_types_on_setters: warning
- avoid_returning_null: warning
- avoid_returning_this: warning
- prefer_generic_function_type_aliases: warning
- always_declare_return_types: warning
- hash_and_equals: warning
- avoid_equals_and_hash_code_on_mutable_classes: warning
- avoid_null_checks_in_equality_operators: warning
- prefer_interpolation_to_compose_strings: warning
- prefer_collection_literals: warning
- prefer_is_empty: warning
- unnecessary_lambdas: warning
- prefer_equal_for_default_values: warning
- avoid_init_to_null: warning
-
-linter:
- rules:
- - avoid_unnecessary_containers
- - no_logic_in_create_state
- - prefer_const_constructors
- - prefer_const_constructors_in_immutables
- - prefer_const_declarations
- - prefer_const_literals_to_create_immutables
- - sized_box_for_whitespace
- - use_full_hex_values_for_flutter_colors
- - use_key_in_widget_constructors
- # 1.11 使用大驼峰命名类型
- - camel_case_types
- # 1.11 使用大驼峰命名拓展
- - camel_case_extensions
- # 1.12 类成员,顶级定义,变量,参数,命名参数和命名构造函数
- - non_constant_identifier_names
- # 1.12 常量变量,包括枚举的名称规范
- - constant_identifier_names
- #倒入import library的名字规范
- - library_names
- #1.13 import dart文件的规范
- - file_names
- #1.21 【可选】顺序
- - directives_ordering
- #2.22 【推荐】 公开接口要有注释
- - package_api_docs
- #3.32【必须】组合字符串统一使用插值的形式${param},并避免在字符串插值中使用不必要的大括号
- - prefer_interpolation_to_compose_strings
- #3.41 【必须】尽可能使用字面量初始化集合
- - prefer_collection_literals
- #3.42【必须】使用.isEmpty/.isNotEmpty判空
- - prefer_is_empty
- #3.51 【必须】不要使用lambda表达式来替代tear-off
- - unnecessary_lambdas
- #3.61 【必须】参数默认值用=号
- - prefer_equal_for_default_values
- #3.71 【必须】不要把变量初始化为null
- - avoid_init_to_null
- #3.82 【必须】去掉不必要的setter和getter
- - unnecessary_getters_setters
- #4.35 mixin的使用规范
- - prefer_mixin
- #4.54【必须】避免单独使用setter或者getters
- - avoid_setters_without_getters
- #4.55【必须】不给setter方法指定返回值
- - avoid_return_types_on_setters
- #4.56【必须】基础数据类型的返回值不要返回null
- - avoid_returning_null
- #4.57 【必须】不要返回this来实现链式调用
- - avoid_returning_this
- #4.61 【必须】添加必要的类型注解 TODO 讨论是否有替代方案
- # - type_annotate_public_apis
- #4.66 【必须】不要使用旧的typedef语法
- - prefer_generic_function_type_aliases
- #4.67 【必须】正确使用Future返回值 TODO 这个lint是说所有方法都必须需要返回类型而不是仅仅Future
- # - always_declare_return_types
- #4.81 【必须】必须重写 hashCode 方法
- - hash_and_equals
- #4.83 【必须】可变类不要重载==
- - avoid_equals_and_hash_code_on_mutable_classes
- #4.84 【必须】重载==时不必判空
- - avoid_null_checks_in_equality_operators
- # 声明返回类型 TODO============ 以下规则对齐codecc代码扫描 =====================================
- # - always_declare_return_types
- # separate the control structure expression from its statement
- - always_put_control_body_on_new_line
- # 声明了@required的参数,需要有assert(param != null)
- - always_require_non_null_named_parameters
- # 注释重写的方法和参数
- - annotate_overrides
- # 避免空的else
- - avoid_empty_else
- # 避免使用print方法
- # - avoid_print
- # 避免以相对路径方式引入文件
- - avoid_relative_lib_imports
- # 避免返回null给future
- - avoid_returning_null_for_future
- # 避免复写相同的参数类型
- - avoid_shadowing_type_parameters
- # 避免使用同步的文件操作
- - avoid_slow_async_io
- # 避免参数名和类型名相同
- - avoid_types_as_parameter_names
- # 避免使用web的库在flutter终端中,这些库不支持在web以外使用
- - avoid_web_libraries_in_flutter
- # dart.async.StreamSubscription的实例不用时,触发cancel方法
- - cancel_subscriptions
- # dart.core.Sink的实例不用时,触发cancel方法
- - close_sinks
- # 评论只引用在作用域的变量
- - comment_references
- # 避免在finally语句中结束控制流
- - control_flow_in_finally
- # 控制结构用大括号来区分,除非没有else语句且可放在一行的
- - curly_braces_in_flow_control_structures
- # 在debug方法中引用所有的公共属性
- # - diagnostic_describe_all_properties
- # 避免空的catch
- - empty_catches
- # 用;替代空的构造方法体
- - empty_constructor_bodies
- # 避免使用空语句
- - empty_statements
- # 不要出现可以在编译阶段推算出恒true或者false的条件判断
- - invariant_booleans
- # 当containns方法的参数和可枚举的类型不同,不要触发可枚举类型的contains方法
- - iterable_contains_unrelated_type
- # 用小写加下划线做库的命名
- - library_prefixes
- # 当remove方法的参数和List的类型不同,不要触发remove方法
- - list_remove_unrelated_type
- # 不要出现只有一种情况的boolean表达式
- - literal_only_boolean_expressions
- # 不要在list内用临近字符串方式
- - no_adjacent_strings_in_list
- # 不要用重复值的case语句
- - no_duplicate_case_values
- # 不要传null值给闭包语句
- - null_closures
- # 省略对本地参数的类型声明
- - omit_local_variable_types
- # 用相邻的string去减少string操作符
- - prefer_adjacent_string_concatenation
- # 尽量用??=来判定null
- - prefer_conditional_assignment
- # 不要用indexOf来判定一个集合是否包含某元素
- - prefer_contains
- # 用final来声明在类中不会被改变的私有参数
- - prefer_final_fields
- # 当由iterables构建map时,用for语句
- - prefer_for_elements_to_map_fromIterable
- # 用?? 替代null的检查
- - prefer_if_null_operators
- # 用isNotEmpty替代!isEmpty
- - prefer_is_not_empty
- # 用iterable.whereType() 替代 iterable.where((e) => e is T).
- - prefer_iterable_whereType
- # 在lib路径下,建议使用相对路径引入
- - prefer_relative_imports
- # 用单引号替代双引号
- - prefer_single_quotes
- # 尽量用扩展符
- - prefer_spread_collections
- # 在void可以的时候不要用null
- - prefer_void_to_null
- # 多余的getter
- - recursive_getters
- # 用/// 作为注释
- - slash_for_doc_comments
- # 在重载==运算符时,判定入参的类型
- - test_types_in_equals
- # 避免在finally语句中抛出错误
- - throw_in_finally
- # 不要对已申明类型的变量在初始化时再声明
- - type_init_formals
- # 在async的方法中await返回为future的方法
- - unawaited_futures
- # 避免重复的const语句
- - unnecessary_const
- # 避免在创建对象时用new
- - unnecessary_new
- # 避免在if null语句中用null
- - unnecessary_null_in_if_null_operators
- # 避免不必要的语句
- - unnecessary_statements
- # 当不需要避免重复时不要用this
- - unnecessary_this
- # 避免无关类型的相等检查
- - unrelated_type_equality_checks
- # 避免直接插入html
- - unsafe_html
- # 用类函数语法作为参数
- - use_function_type_syntax_for_parameters
- # 用rethrow去重新抛出错误
- - use_rethrow_when_possible
- # 用正确的正则去创建正则
- - valid_regexps
diff --git a/assets/tdesign/td_icons.ttf b/assets/tdesign/td_icons.ttf
deleted file mode 100644
index 3ad6e027e..000000000
Binary files a/assets/tdesign/td_icons.ttf and /dev/null differ
diff --git a/demo_tool/README.md b/demo_tool/README.md
deleted file mode 100644
index 3899f04c2..000000000
--- a/demo_tool/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# demo_tool
-# 基于smart_cli实现的组件库生成工具
-
-## 组件注释规范
-### 注:生成工具有待完善,目前先按工具代码规范编写代码,如有不满足的场景,再修改工具
-编写规范需注意:
-- 构造方法为类名下的第一行代码,且不能有注释。成员字段需写在构造方法后面
-- 成员变量的注释需要用///,不能用//
-- 构造方法不能标注@override
-
-#### 组件widget注释示例:
-```
-/// 组件简介(必须)
-```
-#### 组件属性注释示例:
-```
-/// 属性简介(必须)
-```
-#### 组件demo注释示例:
-```
-/// demo名称(可以为空,为空的时候默认显示组件名称)
-/// demo示例介绍(可以为空)
-```
-
-## 组件库工具使用方法
-### 初始化工具调用命令
-```
-dart tools/smart_cli/bin/main.dart generate
- --file 相对ui_component目录的组件文件路径
- --folder 相对ui_component目录的组件文件夹路径
- --name 组件名,多个组件名之间用英文,分割
- --folder-name [可选]生成的组件示例文件夹名称,默认生成的文件夹名称是第一个name参数的下划线表示
- --[no-]only-api 是否只更新api文件
- --[no-]use-grammar 是否采用语法分析器,默认采用词法分析
-```
----
-### 一、 初始化命令
-
-【前置】:在demo_tool/version中填入对应dart_sdk的版本号
-
-初始化命令有以下 3 种使用方式:
-
-1、初始化一个组件文件中的一个组件示例,没有--folder-name的时候,默认文件夹名称是第一个name的下划线表示,示例:
-
-```
-./demo_tool/bin/demo_tool generate --file lib/src/components/tags/td_tag.dart --name TDTag --folder-name tag --only-api
-```
-
-2、 把一个文件中的多个组件合并生成一份示例数据(api说明生成在一个文件中),没有--folder-name的时候,默认文件夹名称是第一个name的下划线表示
-```
-./demo_tool/bin/demo_tool generate --file lib/checkbox/custom_check_box.dart --name SquareCheckbox,TECheckBox --folder-name checkbox2
-```
-3、 把一个文件夹中的多个组件合并生成一份示例数据(api说明生成在一个文件中),没有--folder-name的时候,默认文件夹名称是第一个name的下划线表示
-```
-./demo_tool/bin/demo_tool generate --folder lib/setting --name SettingItemWidget,SettingTowRowCellWidget,SettingLeftTextCellWidget,SettingCheckBoxCellWidget,SettingTowTextCellWidget,SettingTowLineTextCellWidget,SettingGroupWidget,SettingGroupTextWidget --folder-name setting
-```
-
-如果想只更新API文档,那么在上述初始化的命令之后增加参数 `--only-api` 即可
-
-默认采用词法分析,如果想采用语法分析的方式生成代码,那么在上述初始化的命令之后增加参数 `--use-grammar` 即可
-`
\ No newline at end of file
diff --git a/demo_tool/all_build.sh b/demo_tool/all_build.sh
deleted file mode 100644
index 922eca073..000000000
--- a/demo_tool/all_build.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-./bin/demo_tool generate --file ../lib/src/components/avatar/td_avatar.dart --name TDAvatar --folder-name avatar --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/badge/td_badge.dart --name TDBadge --folder-name badge --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/bottom_nav_bar/td_bottom_nav_bar.dart --name TDBottomNavBar --folder-name bottom_nav_bar --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/button/td_button.dart --name TDButton --folder-name button --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/checkbox/td_check_box.dart --name TDCheckbox --folder-name checkbox --output ../example/assets/api/ --only-api
-# Dialog 需要多个文件生成一个api
-#./bin/demo_tool generate --file ../lib/src/components/check_box/td_check_box.dart --name TDCheckbox --folder-name check_box --output ../example/assets/api/ --only-api
-
-./bin/demo_tool generate --file ../lib/src/components/divider/td_divider.dart --name TDDivider --folder-name divider --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/empty/td_empty.dart --name TDEmpty --folder-name empty --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/image/td_image.dart --name TDImage --folder-name image --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/input/td_input.dart --name TDInput --folder-name input --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/loading/td_loading.dart --name TDLoading --folder-name loading --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/navbar/td_nav_bar.dart --name TDNavBar --folder-name navbar --output ../example/assets/api/ --only-api
-# picker需多个文件生成一个api
-#./bin/demo_tool generate --file ../lib/src/components/picker/td_nav_bar.dart --name TDNavBar --folder-name nav_bar --output ../example/assets/api/ --only-api
-
-./bin/demo_tool generate --file ../lib/src/components/popup/td_popup_route.dart --name TDSlidePopupRoute --folder-name popup --output ../example/assets/api/ --only-api
-# 需多个文件生成一个api,透彻父类参数需处理
-./bin/demo_tool generate --file ../lib/src/components/radio/td_radio.dart --name TDRadio --folder-name radio --output ../example/assets/api/ --only-api
-# 有三方组件
-#./bin/demo_tool generate --file ../lib/src/components/refresh/td_refresh_header.dart --name TDRefreshHeader --folder-name refresh --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/search/td_search_bar.dart --name TDSearchBar --folder-name search --output ../example/assets/api/ --only-api
-# 有三方组件
-#./bin/demo_tool generate --file ../lib/src/components/swiper/td_swiper.dart --name TDSwiperPagination --folder-name swiper --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/switch/td_switch.dart --name TDSwitch --folder-name switch --output ../example/assets/api/ --only-api
-# 多个类生成一个api, 注释未生效
-./bin/demo_tool generate --file ../lib/src/components/tabbar/td_tab_bar.dart --name TDTabBar --folder-name tabbar --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/tag/td_tag.dart --name TDTag --folder-name tag --output ../example/assets/api/ --only-api
-./bin/demo_tool generate --file ../lib/src/components/text/td_text.dart --name TDText --folder-name text --output ../example/assets/api/ --only-api
-# 只有方法,没有变量
-./bin/demo_tool generate --file ../lib/src/components/toast/td_toast.dart --name TDToast --folder-name toast --output ../example/assets/api/ --only-api
-
-
-./bin/demo_tool generate --file ../lib/src/theme/td_theme.dart --name TDTheme --folder-name theme --output ../example/assets/api/ --only-api
\ No newline at end of file
diff --git a/demo_tool/bin/demo_tool b/demo_tool/bin/demo_tool
deleted file mode 100755
index 6f8ace585..000000000
Binary files a/demo_tool/bin/demo_tool and /dev/null differ
diff --git a/demo_tool/version b/demo_tool/version
deleted file mode 100644
index fb2c0766b..000000000
--- a/demo_tool/version
+++ /dev/null
@@ -1 +0,0 @@
-2.13.0
diff --git a/example/.gitignore b/example/.gitignore
deleted file mode 100644
index a1345d017..000000000
--- a/example/.gitignore
+++ /dev/null
@@ -1,45 +0,0 @@
-# Miscellaneous
-*.class
-*.log
-*.pyc
-*.swp
-.DS_Store
-.atom/
-.buildlog/
-.history
-.svn/
-
-# IntelliJ related
-*.iml
-*.ipr
-*.iws
-.idea/
-
-# The .vscode folder contains launch configuration and tasks you configure in
-# VS Code which you may wish to be included in version control, so this line
-# is commented out by default.
-#.vscode/
-
-# Flutter/Dart/Pub related
-**/doc/api/
-**/ios/Flutter/.last_build_id
-.dart_tool/
-.flutter-plugins
-.flutter-plugins-dependencies
-.packages
-.pub-cache/
-.pub/
-/build/
-
-# Web related
-
-# Symbolication related
-app.*.symbols
-
-# Obfuscation related
-app.*.map.json
-
-# Android Studio will place build artifacts here
-/android/app/debug
-/android/app/profile
-/android/app/release
diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml
deleted file mode 100644
index 660a4e245..000000000
--- a/example/analysis_options.yaml
+++ /dev/null
@@ -1,208 +0,0 @@
-analyzer:
- enable-experiment:
- - extension-methods
- errors:
- unused_import: ignore
- camel_case_types: warning
- missing_required_param: error
- missing_return: warning
- todo: ignore
- non_constant_identifier_names: warning
- constant_identifier_names: warning
- library_names: warning
- file_names: warning
- avoid_setters_without_getters: warning
- avoid_return_types_on_setters: warning
- avoid_returning_null: warning
- avoid_returning_this: warning
- prefer_generic_function_type_aliases: warning
- always_declare_return_types: warning
- hash_and_equals: warning
- avoid_equals_and_hash_code_on_mutable_classes: warning
- avoid_null_checks_in_equality_operators: warning
- prefer_interpolation_to_compose_strings: warning
- prefer_collection_literals: warning
- prefer_is_empty: warning
- unnecessary_lambdas: warning
- prefer_equal_for_default_values: warning
- avoid_init_to_null: warning
-
-linter:
- rules:
- - avoid_unnecessary_containers
- - no_logic_in_create_state
- - prefer_const_constructors
- - prefer_const_constructors_in_immutables
- - prefer_const_declarations
- - prefer_const_literals_to_create_immutables
- - sized_box_for_whitespace
- - use_full_hex_values_for_flutter_colors
- - use_key_in_widget_constructors
- # 1.11 使用大驼峰命名类型
- - camel_case_types
- # 1.11 使用大驼峰命名拓展
- - camel_case_extensions
- # 1.12 类成员,顶级定义,变量,参数,命名参数和命名构造函数
- - non_constant_identifier_names
- # 1.12 常量变量,包括枚举的名称规范
- - constant_identifier_names
- #倒入import library的名字规范
- - library_names
- #1.13 import dart文件的规范
- - file_names
- #1.21 【可选】顺序
- - directives_ordering
- #2.22 【推荐】 公开接口要有注释
- - package_api_docs
- #3.32【必须】组合字符串统一使用插值的形式${param},并避免在字符串插值中使用不必要的大括号
- - prefer_interpolation_to_compose_strings
- #3.41 【必须】尽可能使用字面量初始化集合
- - prefer_collection_literals
- #3.42【必须】使用.isEmpty/.isNotEmpty判空
- - prefer_is_empty
- #3.51 【必须】不要使用lambda表达式来替代tear-off
- - unnecessary_lambdas
- #3.61 【必须】参数默认值用=号
- - prefer_equal_for_default_values
- #3.71 【必须】不要把变量初始化为null
- - avoid_init_to_null
- #3.82 【必须】去掉不必要的setter和getter
- - unnecessary_getters_setters
- #4.35 mixin的使用规范
- - prefer_mixin
- #4.54【必须】避免单独使用setter或者getters
- - avoid_setters_without_getters
- #4.55【必须】不给setter方法指定返回值
- - avoid_return_types_on_setters
- #4.56【必须】基础数据类型的返回值不要返回null
- - avoid_returning_null
- #4.57 【必须】不要返回this来实现链式调用
- - avoid_returning_this
- #4.61 【必须】添加必要的类型注解 TODO 讨论是否有替代方案
- # - type_annotate_public_apis
- #4.66 【必须】不要使用旧的typedef语法
- - prefer_generic_function_type_aliases
- #4.67 【必须】正确使用Future返回值 TODO 这个lint是说所有方法都必须需要返回类型而不是仅仅Future
- # - always_declare_return_types
- #4.81 【必须】必须重写 hashCode 方法
- - hash_and_equals
- #4.83 【必须】可变类不要重载==
- - avoid_equals_and_hash_code_on_mutable_classes
- #4.84 【必须】重载==时不必判空
- - avoid_null_checks_in_equality_operators
- # 声明返回类型 TODO============ 以下规则对齐codecc代码扫描 =====================================
- # - always_declare_return_types
- # separate the control structure expression from its statement
- - always_put_control_body_on_new_line
- # 声明了@required的参数,需要有assert(param != null)
- - always_require_non_null_named_parameters
- # 注释重写的方法和参数
- - annotate_overrides
- # 避免空的else
- - avoid_empty_else
- # 避免使用print方法
- # - avoid_print
- # 避免以相对路径方式引入文件
- - avoid_relative_lib_imports
- # 避免返回null给future
- - avoid_returning_null_for_future
- # 避免复写相同的参数类型
- - avoid_shadowing_type_parameters
- # 避免使用同步的文件操作
- - avoid_slow_async_io
- # 避免参数名和类型名相同
- - avoid_types_as_parameter_names
- # 避免使用web的库在flutter终端中,这些库不支持在web以外使用
- - avoid_web_libraries_in_flutter
- # dart.async.StreamSubscription的实例不用时,触发cancel方法
- - cancel_subscriptions
- # dart.core.Sink的实例不用时,触发cancel方法
- - close_sinks
- # 评论只引用在作用域的变量
- - comment_references
- # 避免在finally语句中结束控制流
- - control_flow_in_finally
- # 控制结构用大括号来区分,除非没有else语句且可放在一行的
- - curly_braces_in_flow_control_structures
- # 在debug方法中引用所有的公共属性
- # - diagnostic_describe_all_properties
- # 避免空的catch
- - empty_catches
- # 用;替代空的构造方法体
- - empty_constructor_bodies
- # 避免使用空语句
- - empty_statements
- # 不要出现可以在编译阶段推算出恒true或者false的条件判断
- - invariant_booleans
- # 当containns方法的参数和可枚举的类型不同,不要触发可枚举类型的contains方法
- - iterable_contains_unrelated_type
- # 用小写加下划线做库的命名
- - library_prefixes
- # 当remove方法的参数和List的类型不同,不要触发remove方法
- - list_remove_unrelated_type
- # 不要出现只有一种情况的boolean表达式
- - literal_only_boolean_expressions
- # 不要在list内用临近字符串方式
- - no_adjacent_strings_in_list
- # 不要用重复值的case语句
- - no_duplicate_case_values
- # 不要传null值给闭包语句
- - null_closures
- # 省略对本地参数的类型声明
- - omit_local_variable_types
- # 用相邻的string去减少string操作符
- - prefer_adjacent_string_concatenation
- # 尽量用??=来判定null
- - prefer_conditional_assignment
- # 不要用indexOf来判定一个集合是否包含某元素
- - prefer_contains
- # 用final来声明在类中不会被改变的私有参数
- - prefer_final_fields
- # 当由iterables构建map时,用for语句
- - prefer_for_elements_to_map_fromIterable
- # 用?? 替代null的检查
- - prefer_if_null_operators
- # 用isNotEmpty替代!isEmpty
- - prefer_is_not_empty
- # 用iterable.whereType() 替代 iterable.where((e) => e is T).
- - prefer_iterable_whereType
- # 在lib路径下,建议使用相对路径引入
- - prefer_relative_imports
- # 用单引号替代双引号
- - prefer_single_quotes
- # 尽量用扩展符
- - prefer_spread_collections
- # 在void可以的时候不要用null
- - prefer_void_to_null
- # 多余的getter
- - recursive_getters
- # 用/// 作为注释
- - slash_for_doc_comments
- # 在重载==运算符时,判定入参的类型
- - test_types_in_equals
- # 避免在finally语句中抛出错误
- - throw_in_finally
- # 不要对已申明类型的变量在初始化时再声明
- - type_init_formals
- # 在async的方法中await返回为future的方法
- - unawaited_futures
- # 避免重复的const语句
- - unnecessary_const
- # 避免在创建对象时用new
- - unnecessary_new
- # 避免在if null语句中用null
- - unnecessary_null_in_if_null_operators
- # 避免不必要的语句
- - unnecessary_statements
- # 当不需要避免重复时不要用this
- - unnecessary_this
- # 避免无关类型的相等检查
- - unrelated_type_equality_checks
- # 避免直接插入html
- - unsafe_html
- # 用类函数语法作为参数
- - use_function_type_syntax_for_parameters
- # 用rethrow去重新抛出错误
- - use_rethrow_when_possible
- # 用正确的正则去创建正则
- - valid_regexps
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
deleted file mode 100644
index 042d840d2..000000000
--- a/example/android/app/build.gradle
+++ /dev/null
@@ -1,62 +0,0 @@
-apply from: "version.gradle"
-
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
-}
-
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
-
-android {
-
- compileSdkVersion 31
-
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
- }
-
- defaultConfig {
- // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.tdesign.tdesign_flutter_example"
- minSdkVersion 21
- targetSdkVersion 31
- versionCode createVersionCode()
- versionName createVersionName()
- }
-
- buildTypes {
- release {
- // TODO: Add your own signing config for the release build.
- // Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig signingConfigs.debug
- }
- }
-}
-
-flutter {
- source '../..'
-}
-
-dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-}
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
deleted file mode 100644
index 10972f45b..000000000
--- a/example/android/app/src/debug/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 5ad14c9a8..000000000
--- a/example/android/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
deleted file mode 100644
index 10972f45b..000000000
--- a/example/android/app/src/profile/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/example/android/app/version.gradle b/example/android/app/version.gradle
deleted file mode 100644
index 14e822a48..000000000
--- a/example/android/app/version.gradle
+++ /dev/null
@@ -1,27 +0,0 @@
-import java.text.SimpleDateFormat
-
-def cfg = rootProject.ext.config
-ext.createVersionCode = { ->
- Date now = new Date()
- SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd")
- String nowStr = sf.format(now)
- int nowInt = Integer.valueOf(nowStr)
- //20210408//在指挥官全量之前,保证指挥官灰度版本大于线上全量版本,避免指挥官灰度版本被应用市场覆盖。指挥官版本最低2021041211,线上5.7.6.81版本是2021040781
- if (cfg.isCI != null && cfg.isCI.toBoolean()) {
- // 蓝盾环境
- nowInt * 100 + Integer.parseInt(cfg.BuildNo) % 100
- } else {
- // 本地环境
- nowInt * 100 + 1
- }
-}
-
-ext.createVersionName = { ->
- if (cfg.isCI != null && cfg.isCI.toBoolean()) {
- // 蓝盾环境
- cfg.MajorVersion + "." + cfg.MinorVersion + "." + cfg.FixVersion + "." + cfg.BuildNo
- } else {
- // 本地环境
- "0.0.0.1"
- }
-}
\ No newline at end of file
diff --git a/example/android/build.gradle b/example/android/build.gradle
deleted file mode 100644
index 05e6b9778..000000000
--- a/example/android/build.gradle
+++ /dev/null
@@ -1,60 +0,0 @@
-buildscript {
- ext.kotlin_version = '1.6.21'
-
- ext {
-
- config = [
- // 蓝盾自带变量
- isCI : System.env.isCI // 是否在RMD的持续集成构建环境中
- , VersionCode : System.env.VersionCode // VersionCode,每次发版本+2
- , devopsUUID : System.env.uuid //蓝盾构建UUID
- , MajorVersion : System.env.MajorVersion // 主版本号
- , MinorVersion : System.env.MinorVersion // 特性版本号
- , FixVersion : System.env.FixVersion // 修正版本号
- , BuildNo : System.env.BuildNo // 构建号
- , isPublish : System.env.isPublish // 是否是外发版本,用来控制调试入口等
- , isBeta : System.env.isBeta // 是否是灰度版本
- , gitVersion : System.env.gitVersion // git提交hash
- , keyAlias : System.env.keyAlias // 签名信息
- , storePassword: System.env.storePassword // storePassword
- , abi_filters: System.env.abi_filters // abi类型配置
- ]
-
- def dir = System.getProperty("user.dir")
- def file = new File(dir, 'local.properties')
- Properties properties = new Properties()
- if (file.exists()) {
- properties.load(file.newDataInputStream())
- }
- enableWatchman = Boolean.valueOf(properties.getProperty('enableWatchman', ""))
- }
-
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- }
-}
-
-rootProject.buildDir = '../build'
-subprojects {
- project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
- project.evaluationDependsOn(':app')
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
deleted file mode 100644
index 44e62bcf0..000000000
--- a/example/android/settings.gradle
+++ /dev/null
@@ -1,11 +0,0 @@
-include ':app'
-
-def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
-def properties = new Properties()
-
-assert localPropertiesFile.exists()
-localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
-
-def flutterSdkPath = properties.getProperty("flutter.sdk")
-assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
-apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
diff --git a/example/assets/api/avatar_api.md b/example/assets/api/avatar_api.md
deleted file mode 100644
index 287742ecf..000000000
--- a/example/assets/api/avatar_api.md
+++ /dev/null
@@ -1,14 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| size | TDAvatarSize | TDAvatarSize.medium | 头像尺寸 |
-| type | TDAvatarType | TDAvatarType.normal | 头像类型 |
-| text | String? | - | 自定义文字 |
-| avatarUrl | String? | - | 头像地址 |
-| avatarSize | double? | - | 自定义头像大小 |
-| avatarDisplayList | List? | - | 带操作\展示的头像列表 |
-| displayText | String? | - | 纯展示类型末尾文字 |
-| onTap | Function()? | - | 操作点击事件 |
-| defaultUrl | String | '' | 默认图片 |
diff --git a/example/assets/api/badge_api.md b/example/assets/api/badge_api.md
deleted file mode 100644
index a01b56be4..000000000
--- a/example/assets/api/badge_api.md
+++ /dev/null
@@ -1,15 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| type | TDBadgeType | type | 红点样式 |
-| key | Key | - | |
-| count | String? | - | 红点数量 |
-| border | TDBadgeBorder | TDBadgeBorder.large | 红点圆角大小 |
-| color | Color? | - | 红点颜色 |
-| textColor | Color? | - | 文字颜色 |
-| redPointSize | double | 10 | 红点大小 |
-| message | String? | - | 消息内容 |
-| widthLarge | double | 32 | 角标大三角形宽 |
-| widthSmall | double | 12 | 角标小三角形宽 |
-| padding | EdgeInsetsGeometry? | - | 角标自定义padding |
diff --git a/example/assets/api/bottom_nav_bar_api.md b/example/assets/api/bottom_nav_bar_api.md
deleted file mode 100644
index 29a179a16..000000000
--- a/example/assets/api/bottom_nav_bar_api.md
+++ /dev/null
@@ -1,14 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| type | TDBottomNavBarType | type | |
-| key | Key | - | |
-| navigationTabs | List | - | tab |
-| barHeight | double? | _kDefaultNavBarHeight | tab高度 |
-| useVerticalDivider | bool? | - | 是否使用竖线分隔 |
-| dividerHeight | double? | - | 分割线高度(可选) |
-| dividerThickness | double? | - | 分割线厚度(可选) |
-| dividerColor | Color? | - | 分割线颜色(可选) |
-| showTopBorder | bool? | true | 是否展示bar上边线(设置为true 但是topBorder样式未设置,则使用默认值) |
-| topBorder | BorderSide? | - | 上边线样式 |
diff --git a/example/assets/api/button_api.md b/example/assets/api/button_api.md
deleted file mode 100644
index 06f0bcf33..000000000
--- a/example/assets/api/button_api.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| content | String? | - | 文本内容 |
-| size | TDButtonSize | TDButtonSize.medium | 尺寸 |
-| child | Widget? | - | 自控件 |
-| disabled | bool | false | 禁止点击 |
-| style | TDButtonStyle? | - | 样式,强按钮,弱按钮,警告按钮等 |
-| textStyle | TextStyle? | - | 自定义可点击状态文本样式 |
-| disableTextStyle | TextStyle? | - | 自定义不可点击状态文本样式 |
-| width | double? | - | 自定义宽度 |
-| height | double? | - | 自定义高度 |
-| onTap | TDButtonEvent? | - | 点击事件 |
-| icon | IconData? | - | 图标icon |
-| onLongPress | TDButtonEvent? | - | 长按事件 |
-| padding | EdgeInsetsGeometry? | - | 自定义padding |
diff --git a/example/assets/api/checkbox_api.md b/example/assets/api/checkbox_api.md
deleted file mode 100644
index 5b676d000..000000000
--- a/example/assets/api/checkbox_api.md
+++ /dev/null
@@ -1,20 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| id | String? | - | id |
-| key | Key | - | |
-| title | String? | - | 文本 |
-| subTitle | String? | - | 辅助文字 |
-| enable | bool | true | 不可用 |
-| checked | bool | false | 选中状态。默认为`false` |
-| titleMaxLine | int? | - | 标题的行数 |
-| subTitleMaxLine | int? | 1 | 辅助文字的行数 |
-| customIconBuilder | IconBuilder? | - | 自定义Checkbox显示样式 |
-| customContentBuilder | ContentBuilder? | - | 完全自定义内容 |
-| style | TDCheckboxStyle? | - | 复选框样式:圆形或方形 |
-| spacing | double? | - | icon和文字的距离 |
-| backgroundColor | Color? | - | 背景颜色 |
-| size | TDCheckBoxSize | TDCheckBoxSize.small | 复选框大小 |
-| contentDirection | TDContentDirection | TDContentDirection.right | 文字相对icon的方位 |
-| onCheckBoxChanged | OnCheckValueChanged? | - | 切换监听 |
diff --git a/example/assets/api/default_api.md b/example/assets/api/default_api.md
deleted file mode 100644
index 0d957df5f..000000000
--- a/example/assets/api/default_api.md
+++ /dev/null
@@ -1,3 +0,0 @@
-## API
-
-暂无对应api
diff --git a/example/assets/api/empty_api.md b/example/assets/api/empty_api.md
deleted file mode 100644
index 436dda9fa..000000000
--- a/example/assets/api/empty_api.md
+++ /dev/null
@@ -1,10 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| type | TDEmptyType | TDEmptyType.plain | |
-| image | Widget? | - | |
-| emptyText | String? | - | |
-| operationText | String? | - | |
-| onTapEvent | TDTapEvent? | - | 点击事件 |
-| key | Key | - | |
diff --git a/example/assets/api/image_api.md b/example/assets/api/image_api.md
deleted file mode 100644
index 1df8cb495..000000000
--- a/example/assets/api/image_api.md
+++ /dev/null
@@ -1,29 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| imgUrl | String | imgUrl | 图片地址 |
-| key | Key | - | |
-| size | TDImageSize | TDImageSize.l | 图片大小 |
-| type | TDImageType | TDImageType.roundedSquare | 图片类型 |
-| errorWidget | Widget? | - | 失败自定义提示 |
-| loadingWidget | Widget? | - | 加载自定义提示 |
-| width | double? | - | 自定义宽 |
-| height | double? | - | 自定义高 |
-| frameBuilder | ImageFrameBuilder? | - | 以下系统Image属性,释义请参考系统[Image]中注释 |
-| loadingBuilder | ImageLoadingBuilder? | - | |
-| errorBuilder | ImageErrorWidgetBuilder? | - | |
-| semanticLabel | String? | - | |
-| excludeFromSemantics | bool | false | |
-| color | Color? | - | |
-| opacity | Animation? | - | |
-| colorBlendMode | BlendMode? | - | |
-| alignment | AlignmentGeometry | Alignment.center | |
-| repeat | ImageRepeat | ImageRepeat.noRepeat | |
-| centerSlice | Rect? | - | |
-| matchTextDirection | bool | false | |
-| gaplessPlayback | bool | false | |
-| isAntiAlias | bool | false | |
-| filterQuality | FilterQuality | FilterQuality.low | |
-| cacheHeight | int? | - | |
-| cacheWidth | int? | - | |
diff --git a/example/assets/api/input_api.md b/example/assets/api/input_api.md
deleted file mode 100644
index 1decfbbd8..000000000
--- a/example/assets/api/input_api.md
+++ /dev/null
@@ -1,37 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| width | double? | - | 输入框宽度 |
-| textStyle | TextStyle? | - | 文本颜色 |
-| backgroundColor | Color? | - | 输入框背景色 |
-| decoration | Decoration? | - | 输入框样式 |
-| leftLabel | String? | - | 输入框左侧文案 |
-| readOnly | bool | false | 是否只读 |
-| autofocus | bool | false | 是否自动获取焦点 |
-| obscureText | bool | false | 是否隐藏输入的文字,一般用在密码输入框中 |
-| onEditingComplete | VoidCallback? | - | 点击键盘完成按钮时触发的回调 |
-| onSubmitted | ValueChanged? | - | 点击键盘完成按钮时触发的回调, 参数值为输入的内容 |
-| hintText | String? | - | 提示文案 |
-| inputType | TextInputType? | - | 键盘类型,数字、字母 |
-| onChanged | ValueChanged? | - | 输入文本变化时回调 |
-| inputFormatters | List? | - | 显示输入内容,如限制长度(LengthLimitingTextInputFormatter(6)) |
-| inputDecoration | InputDecoration? | - | 自定义输入框样式,默认圆角 |
-| maxLines | int | 1 | 最大输入行数 |
-| focusNode | FocusNode? | - | 获取或者取消焦点使用 |
-| controller | TextEditingController? | - | controller 用户获取或者赋值输入内容 |
-| cursorColor | Color? | - | 游标颜色 |
-| rightBtn | Widget? | - | 右侧按钮 |
-| hintTextStyle | TextStyle? | - | 提示文本颜色,默认为文本颜色 |
-| onTapBtn | GestureTapCallback? | - | 右侧按钮点击 |
-| labelWidget | Widget? | - | leftLabel右侧组件,支持自定义 |
-| textInputBackgroundColor | Color? | - | 文本框背景色 |
-| contentPadding | EdgeInsetsGeometry? | - | textInput内边距 |
-| type | TDInputType | TDInputType.normal | 输入框类型 |
-| size | TDInputSize | TDInputSize.small | 输入框规格 |
-| inputWidth | double? | 81 | 输入框宽度 |
-| maxNum | int? | 500 | 最大字数限制 |
-| errorText | String? | '' | 错误提示信息 |
-| textAlign | TextAlign? | - | 文字对齐方向 |
-| rightWidget | Widget? | - | 右侧自定义组件 特殊类型时生效 |
diff --git a/example/assets/api/loading_api.md b/example/assets/api/loading_api.md
deleted file mode 100644
index 65c5375e7..000000000
--- a/example/assets/api/loading_api.md
+++ /dev/null
@@ -1,12 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| size | TDLoadingSize | - | |
-| icon | TDLoadingIcon? | - | |
-| iconColor | Color? | - | |
-| axis | Axis | Axis.vertical | |
-| text | String? | - | |
-| customIcon | Widget? | - | |
-| textColor | Color | Colors.black | |
diff --git a/example/assets/api/navbar_api.md b/example/assets/api/navbar_api.md
deleted file mode 100644
index aec8521c6..000000000
--- a/example/assets/api/navbar_api.md
+++ /dev/null
@@ -1,24 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| leftBarItems | List? | - | |
-| rightBarItems | List? | - | |
-| titleWidget | Widget? | - | |
-| title | String? | - | |
-| titleColor | Color? | - | |
-| titleFont | Font? | - | |
-| titleFontFamily | FontFamily? | - | |
-| titleFontWeight | FontWeight? | FontWeight.w500 | |
-| centerTitle | bool | true | |
-| opacity | double | 1.0 | |
-| backgroundColor | Color? | - | |
-| titleMargin | double | 16 | 中间文案左右两边间距 |
-| padding | EdgeInsetsGeometry? | - | |
-| height | double | 44 | |
-| screenAdaptation | bool | true | 是否进行屏幕适配,默认true |
-| useDefaultBack | bool | true | 是否使用默认的返回 |
-| onBack | VoidCallback? | - | 返回事件 |
-| useBorderStyle | bool | false | 是否使用边框模式 |
-| border | TDNavBarItemBorder? | - | 边框 |
diff --git a/example/assets/api/popup_api.md b/example/assets/api/popup_api.md
deleted file mode 100644
index ec3de0555..000000000
--- a/example/assets/api/popup_api.md
+++ /dev/null
@@ -1,10 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| builder | WidgetBuilder | - | |
-| barrierLabel | String? | - | |
-| modalBarrierColor | Color? | - | |
-| isDismissible | bool | true | |
-| transitionAnimationController | AnimationController? | - | |
-| slideTransitionFrom | SlideTransitionFrom | SlideTransitionFrom.bottom | |
diff --git a/example/assets/api/radio_api.md b/example/assets/api/radio_api.md
deleted file mode 100644
index 4885d98a3..000000000
--- a/example/assets/api/radio_api.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| id | | - | |
-| key | Key | - | |
-| title | | - | |
-| subTitle | | - | |
-| enable | | true | |
-| subTitleMaxLine | | 1 | |
-| titleMaxLine | | 1 | |
-| checkedColor | | - | |
-| customContentBuilder | | - | |
-| spacing | | - | |
-| size | | TDCheckBoxSize.small | |
-| radioStyle | | TDRadioStyle.circle | |
-| contentDirection | | TDContentDirection.right | |
-| customIconBuilder | | - | |
diff --git a/example/assets/api/refresh_api.md b/example/assets/api/refresh_api.md
deleted file mode 100644
index 0df556242..000000000
--- a/example/assets/api/refresh_api.md
+++ /dev/null
@@ -1,3 +0,0 @@
-## web示例暂不可操作,请在移动端体验
-
-
diff --git a/example/assets/api/search_api.md b/example/assets/api/search_api.md
deleted file mode 100644
index 452bdcd28..000000000
--- a/example/assets/api/search_api.md
+++ /dev/null
@@ -1,11 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| placeHolder | String? | - | |
-| onTextChanged | TDSearchBarEvent? | - | |
-| onSubmitted | TDSearchBarEvent? | - | |
-| onEditComplete | TDSearchBarCallBack? | - | |
-| autoFocus | bool | false | |
-| backgroundColor | Color? | Colors.white | |
diff --git a/example/assets/api/switch_api.md b/example/assets/api/switch_api.md
deleted file mode 100644
index 12b34867d..000000000
--- a/example/assets/api/switch_api.md
+++ /dev/null
@@ -1,10 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| enable | bool | true | 是否可点击 |
-| isOn | bool | false | 是否打开 |
-| onColor | Color? | - | 开启颜色 |
-| offColor | Color? | - | 关闭颜色 |
-| onChanged | ValueChanged? | - | 改变事件 |
diff --git a/example/assets/api/tabbar_api.md b/example/assets/api/tabbar_api.md
deleted file mode 100644
index 5942d6f74..000000000
--- a/example/assets/api/tabbar_api.md
+++ /dev/null
@@ -1,26 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| key | Key | - | |
-| tabs | List | - | tab数组 |
-| controller | TabController? | - | tab控制器 |
-| decoration | Decoration? | - | tabBar修饰 |
-| backgroundColor | Color? | - | tabBar背景色 |
-| indicatorColor | Color? | - | tabBar下标颜色 |
-| indicatorWidth | double? | - | tabBar下标宽度 |
-| indicatorHeight | double? | - | tabBar下标高度 |
-| labelColor | Color? | - | tabBar 已选标签颜色 |
-| unselectedLabelColor | Color? | - | tabBar未选标签颜色 |
-| isScrollable | bool | false | 是否滚动 |
-| unselectedLabelStyle | TextStyle? | - | unselectedLabel字体 |
-| labelStyle | TextStyle? | - | 已选label字体 |
-| width | double? | - | tabBar宽度 |
-| height | double? | - | tabBar高度 |
-| indicatorPadding | EdgeInsets? | - | 引导padding |
-| labelPadding | EdgeInsetsGeometry? | - | tab间距 |
-| indicator | Decoration? | - | 自定义引导控件 |
-| physics | ScrollPhysics? | - | 自定义滑动 |
-| onTap | Function(int)? | - | 点击事件 |
-| isVertical | bool | false | 是否是竖向 |
-| showIndicator | bool | false | 是否展示引导控件 |
diff --git a/example/assets/api/tag_api.md b/example/assets/api/tag_api.md
deleted file mode 100644
index 52dafc464..000000000
--- a/example/assets/api/tag_api.md
+++ /dev/null
@@ -1,17 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| text | String | text | 标签内容 |
-| textColor | Color? | - | 文字颜色, 优先级高于style的textColor |
-| backgroundColor | Color? | - | 背景颜色, 优先级高于style的backgroundColor |
-| font | Font? | - | 字体尺寸, 优先级高于style的font |
-| fontWeight | FontWeight? | - | 字体粗细, 优先级高于style的fontWeight |
-| style | TDTagStyle? | - | 标签样式 |
-| size | TDTagSize | TDTagSize.middle | 标签大小 |
-| padding | EdgeInsets? | - | 自定义模式下的间距 |
-| forceVerticalCenter | bool | true | 是否强制中文文字居中 |
-| needCloseIcon | bool | false | 关闭图标 |
-| onCloseTap | GestureTapCallback? | - | 关闭图标点击事件 |
-| overflow | TextOverflow? | - | 文字溢出处理 |
-| key | Key | - | |
diff --git a/example/assets/api/text_api.md b/example/assets/api/text_api.md
deleted file mode 100644
index f2e06eff2..000000000
--- a/example/assets/api/text_api.md
+++ /dev/null
@@ -1,27 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| data | null | data | 以下系统text属性,释义请参考系统[Text]中注释 |
-| font | Font? | - | 字体尺寸,包含大小size和行高height |
-| fontWeight | FontWeight? | FontWeight.w400 | 字体粗细 |
-| fontFamily | FontFamily? | - | 字体ttf |
-| textColor | Color | Colors.black | 文本颜色 |
-| backgroundColor | Color? | - | 背景颜色 |
-| isTextThrough | bool? | false | 是否是横线穿过样式(删除线) |
-| lineThroughColor | Color? | Colors.white | 删除线颜色,对应TestStyle的decorationColor |
-| package | String? | - | 字体包名 |
-| style | TextStyle? | - | 自定义的TextStyle,其中指定的属性,将覆盖扩展的外层属性 |
-| strutStyle | StrutStyle? | - | |
-| textAlign | TextAlign? | - | |
-| textDirection | TextDirection? | - | |
-| locale | Locale? | - | |
-| softWrap | bool? | - | |
-| overflow | TextOverflow? | - | |
-| textScaleFactor | double? | - | |
-| maxLines | int? | - | |
-| semanticsLabel | String? | - | |
-| textWidthBasis | TextWidthBasis? | - | |
-| textHeightBehavior | ui.TextHeightBehavior? | - | |
-| forceVerticalCenter | bool | false | |
-| key | Key | - | |
diff --git a/example/assets/api/theme_api.md b/example/assets/api/theme_api.md
deleted file mode 100644
index 3ebd06886..000000000
--- a/example/assets/api/theme_api.md
+++ /dev/null
@@ -1,8 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
-| data | TDThemeData | - | |
-| child | Widget | - | |
-| systemData | ThemeData? | - | Flutter系统主题数据 |
-| key | Key | - | |
diff --git a/example/assets/api/toast_api.md b/example/assets/api/toast_api.md
deleted file mode 100644
index 7a330802e..000000000
--- a/example/assets/api/toast_api.md
+++ /dev/null
@@ -1,4 +0,0 @@
-## API
-
-| 参数 | 类型 | 默认值 | 说明 |
-| --- | --- | --- | --- |
diff --git a/example/assets/version b/example/assets/version
deleted file mode 100644
index b87eee815..000000000
--- a/example/assets/version
+++ /dev/null
@@ -1 +0,0 @@
-0.0.0.1
\ No newline at end of file
diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig
deleted file mode 100644
index ec97fc6f3..000000000
--- a/example/ios/Flutter/Debug.xcconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
-#include "Generated.xcconfig"
diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig
deleted file mode 100644
index c4855bfe2..000000000
--- a/example/ios/Flutter/Release.xcconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
-#include "Generated.xcconfig"
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
deleted file mode 100644
index 309cd00c4..000000000
--- a/example/ios/Podfile.lock
+++ /dev/null
@@ -1,16 +0,0 @@
-PODS:
- - Flutter (1.0.0)
-
-DEPENDENCIES:
- - Flutter (from `Flutter`)
-
-EXTERNAL SOURCES:
- Flutter:
- :path: Flutter
-
-SPEC CHECKSUMS:
- Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
-
-PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
-
-COCOAPODS: 1.10.1
diff --git a/example/lib/main.dart b/example/lib/main.dart
deleted file mode 100644
index a706297a0..000000000
--- a/example/lib/main.dart
+++ /dev/null
@@ -1,297 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:tdesign_flutter/src/util/platform_util.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import 'tdesign/example_base.dart';
-import 'tdesign/example_route.dart';
-import 'tdesign/page/td_avatar_page.dart';
-import 'tdesign/page/td_badge_page.dart';
-import 'tdesign/page/td_bottom_nav_bar_page.dart';
-import 'tdesign/page/td_button_page.dart';
-import 'tdesign/page/td_checkbox_page.dart';
-import 'tdesign/page/td_date_picker_page.dart';
-import 'tdesign/page/td_dialog_page.dart';
-import 'tdesign/page/td_divider_page.dart';
-import 'tdesign/page/td_empty_page.dart';
-import 'tdesign/page/td_icon_page.dart';
-import 'tdesign/page/td_image_page.dart';
-import 'tdesign/page/td_input_page.dart';
-import 'tdesign/page/td_loading_page.dart';
-import 'tdesign/page/td_navbar_page.dart';
-import 'tdesign/page/td_picker_page.dart';
-import 'tdesign/page/td_popup_page.dart';
-import 'tdesign/page/td_radio_page.dart';
-import 'tdesign/page/td_refresh_page.dart';
-import 'tdesign/page/td_search_bar_page.dart';
-import 'tdesign/page/td_swiper_page.dart';
-import 'tdesign/page/td_switch_page.dart';
-import 'tdesign/page/td_tabbar_page.dart';
-import 'tdesign/page/td_tag_page.dart';
-import 'tdesign/page/td_text_page.dart';
-import 'tdesign/page/td_theme_page.dart';
-import 'tdesign/page/td_toast_page.dart';
-import 'web/web.dart' if(dart.library.io) 'web/web_replace.dart' as web;
-
-PageBuilder _wrapInheritedTheme(WidgetBuilder builder){
- return (context, model){
- return ExamplePageInheritedTheme(model: model, child: builder(context));
- };
-}
-
-/// 新增的示例页面,在此增加模型即可,会自动注册增加按钮。示例页面编写参考TDTextPage()
-List examplePageList = [
- ExamplePageModel(
- text: '文本控件--基础',
- path: 'TDTextPage',
- apiPath: 'text',
- pageBuilder: _wrapInheritedTheme((context) => const TDTextPage())),
- ExamplePageModel(
- text: '图标--基础',
- path: 'TDIconPage',
- codePath: 'icon',
- pageBuilder: _wrapInheritedTheme((context) => const TDIconPage())),
- ExamplePageModel(
- text: '主题--基础',
- path: 'TDThemePage',
- apiPath: 'theme',
- pageBuilder: _wrapInheritedTheme((context) => const TDThemePage())),
- ExamplePageModel(
- text: '按钮 Button',
- path: 'TDButtonPage',
- apiPath: 'button',
- pageBuilder: _wrapInheritedTheme((context) => const TDButtonPage())),
- ExamplePageModel(
- text: '分割线 Divider',
- path: 'TDDividerPage',
- apiPath: 'divider',
- pageBuilder: _wrapInheritedTheme((context) => const TDDividerPage())),
- ExamplePageModel(
- text: '头像 Avatar',
- path: 'TDAvatarPage',
- apiPath: 'avatar',
- pageBuilder: _wrapInheritedTheme((context) => const TDAvatarPage())),
- ExamplePageModel(
- text: '徽标 Badge',
- path: 'TDBadgePage',
- apiPath: 'badge',
- pageBuilder: _wrapInheritedTheme((context) => const TDBadgePage())),
- ExamplePageModel(
- text: '空状态 Empty',
- path: 'TDEmptyPage',
- apiPath: 'empty',
- pageBuilder: _wrapInheritedTheme((context) => const TDEmptyPage())),
- ExamplePageModel(
- text: '图片 Image',
- path: 'TDImagePage',
- apiPath: 'image',
- pageBuilder: _wrapInheritedTheme((context) => const TDImagePage())),
- ExamplePageModel(
- text: '轮播图 Swiper',
- path: 'TDSwiperPage',
- apiPath: 'swiper',
- pageBuilder: _wrapInheritedTheme((context) => const TDSwiperPage())),
- ExamplePageModel(
- text: '标签 Tag',
- path: 'TDTagPage',
- apiPath: 'tag',
- pageBuilder: _wrapInheritedTheme((context) => const TDTagPage())),
- ExamplePageModel(
- text: '多选框 Checkbox',
- path: 'TDCheckboxPage',
- apiPath: 'checkbox',
- pageBuilder: _wrapInheritedTheme((context) => const TDCheckboxPage())),
- ExamplePageModel(
- text: '时间选择器 DatePicker',
- path: 'TDDatePickerPage',
- codePath: 'date_picker',
- pageBuilder: _wrapInheritedTheme((context) => const TDDatePickerPage())),
- ExamplePageModel(
- text: '输入框 Input',
- path: 'TDInputViewPag',
- apiPath: 'input',
- pageBuilder: _wrapInheritedTheme((context) => const TDInputViewPage())),
- ExamplePageModel(
- text: '选择器 Picker',
- path: 'TDPickerPage',
- codePath: 'picker',
- pageBuilder: _wrapInheritedTheme((context) => const TDPickerPage())),
- ExamplePageModel(
- text: '单选框 Radio',
- path: 'TDRadioPage',
- apiPath: 'radio',
- pageBuilder: _wrapInheritedTheme((context) => const TDRadioPage())),
- ExamplePageModel(
- text: '搜索框 Search',
- path: 'TDSearchBarPage',
- apiPath: 'search',
- codePath: 'search_bar',
- pageBuilder: _wrapInheritedTheme((context) => const TDSearchBarPage())),
- ExamplePageModel(
- text: '开关 Switch',
- path: 'TDSwitchPage',
- apiPath: 'switch',
- pageBuilder: _wrapInheritedTheme((context) => const TDSwitchPage())),
- ExamplePageModel(
- text: '导航栏 NavBar',
- path: 'TDNavBarPage',
- apiPath: 'navbar',
- pageBuilder: _wrapInheritedTheme((context) => const TDNavBarPage())),
- ExamplePageModel(
- text: '标签栏 TabBar',
- path: 'TDBottomNavBarPage',
- apiPath: 'bottom_nav_bar',
- pageBuilder: _wrapInheritedTheme((context) => const TDBottomNavBarPage())),
- ExamplePageModel(
- text: '选项卡 Tabs',
- path: 'TDTabBarPage',
- apiPath: 'tabbar',
- pageBuilder: _wrapInheritedTheme((context) => const TDTabBarPage())),
- ExamplePageModel(
- text: '对话框 Dialog',
- path: 'TDDialogPage',
- apiPath: 'dialog',
- pageBuilder: _wrapInheritedTheme((context) => const TDDialogPage())),
- ExamplePageModel(
- text: '加载 Loading',
- path: 'TDLoadingPage',
- apiPath: 'loading',
- pageBuilder: _wrapInheritedTheme((context) => const TDLoadingPage())),
- ExamplePageModel(
- text: '弹出层 PopUp',
- path: 'TDPopUpPage',
- codePath: 'popup',
- pageBuilder: _wrapInheritedTheme((context) => const TDPopupPage())),
- ExamplePageModel(
- text: '下拉刷新 PullDownRefresh',
- path: 'TdPullDownRefreshPage',
- apiPath: 'refresh',
- pageBuilder: _wrapInheritedTheme((context) => const TdPullDownRefreshPage())),
- ExamplePageModel(
- text: '轻提示 Toast',
- path: 'TDToastPage',
- codePath: 'toast',
- pageBuilder: _wrapInheritedTheme((context) => const TDToastPage())),
-];
-
-void main() {
- runApp(const MyApp());
-
- SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
- statusBarColor: Colors.transparent,
- systemNavigationBarColor: Colors.transparent,
- systemNavigationBarDividerColor: Colors.transparent,
- ));
-}
-
-class MyApp extends StatelessWidget {
- const MyApp({Key? key}) : super(key: key);
-
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return
- // 在此处导入默认主题
- TDTheme(
- data: TDThemeData.defaultData(),
- child: MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- colorScheme: ColorScheme.light(
- primary: TDTheme.of(context).brandNormalColor)),
- home: const MyHomePage(title: 'TDesgin Flutter 组件库'),
- onGenerateRoute: TDExampleRoute.onGenerateRoute,
- // TODO:所有路径指向首页,需区分
- routes: {
- for(var model in examplePageList)
- model.path: (context)=>model.pageBuilder.call(context, model)
- },
- ),
- );
- }
-}
-
-class MyHomePage extends StatefulWidget {
- const MyHomePage({Key? key, required this.title}) : super(key: key);
-
- final String title;
-
- @override
- _MyHomePageState createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State {
- bool useConch = false;
-
- @override
- void initState() {
- super.initState();
- TDExampleRoute.init();
- }
-
- @override
- Widget build(BuildContext context) {
- // This method is rerun every time setState is called, for instance as done
- // by the _incrementCounter method above.
- //
- // The Flutter framework has been optimized to make rerunning build methods
- // fast, so that you can just rebuild anything that needs updating rather
- // than having to individually change instances of widgets.
- return Scaffold(
- appBar: AppBar(
- // Here we take the value from the MyHomePage object that was created by
- // the App.build method, and use it to set our appbar title.
- title: Text(widget.title),
- actions: PlatformUtil.isWeb ? null : [
- GestureDetector(
- child: Container(
- alignment: Alignment.centerRight,
- padding: const EdgeInsets.only(
- right: 16,
- ),
- child: TDText(
- '关于',
- textColor: TDTheme.of(context).whiteColor1,
- ),
- ),
- onTap: () {
- Navigator.pushNamed(context, TDExampleRoute.aboutPath);
- },
- )
- ],
- ),
- body: _buildBody(context));
- }
-
- Widget _buildBody(BuildContext context) {
- if (PlatformUtil.isWeb) {
- return const web.WebMainBody();
- }
- return Center(
- // Center is a layout widget. It takes a single child and positions it
- // in the middle of the parent.
- child: SingleChildScrollView(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: _buildChildren(context),
- ),
- ),
- );
- }
-
- List _buildChildren(BuildContext context) {
- return [
- for (var model in examplePageList)
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: TDButton(
- style: TDButtonStyle.weakly(),
- size: TDButtonSize.small,
- onTap: () {
- Navigator.pushNamed(context, model.path);
- },
- content: model.text),
- )
- ];
- }
-}
diff --git a/example/lib/tdesign/api_widget.dart b/example/lib/tdesign/api_widget.dart
deleted file mode 100644
index 165b6eb76..000000000
--- a/example/lib/tdesign/api_widget.dart
+++ /dev/null
@@ -1,67 +0,0 @@
-
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_markdown/flutter_markdown.dart';
-import 'package:markdown/markdown.dart' as md;
-import 'package:tdesign_flutter/td_export.dart';
-
-class ApiWidget extends StatefulWidget {
- const ApiWidget({Key? key, required this.apiName, this.visible = false}) : super(key: key);
-
- final bool visible;
-
- final String? apiName;
-
- @override
- State createState() => _ApiWidgetState();
-}
-
-class _ApiWidgetState extends State {
-
- String? result;
- String? lastApiName;
-
- @override
- Widget build(BuildContext context) {
- return Visibility(
- visible: widget.visible,
- child: FutureBuilder(
- future: getApiData(),
- builder: (context, AsyncSnapshot snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- return Markdown(
- padding: EdgeInsets.zero,
- physics: const NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- selectable: true,
- data: snapshot.data ?? '',
- extensionSet: md.ExtensionSet(
- md.ExtensionSet.gitHubWeb.blockSyntaxes,
- [md.EmojiSyntax(), ...md.ExtensionSet.gitHubWeb.inlineSyntaxes],
- ),
- );
- } else {
- return Container(
- alignment: Alignment.topLeft,
- child: const TDText('加载中…'),
- );
- }
- },
- ));
- }
-
- Future getApiData() async {
- const defaultResult = '加载失败';
- if(widget.apiName == lastApiName && result != null && result != defaultResult){
- return result!;
- }
- try {
- var apiName = widget.apiName ?? 'default';
- result = await rootBundle.loadString('assets/api/${apiName}_api.md');
- lastApiName = widget.apiName;
- } catch (e) {
- print('getApiData error: $e');
- }
- return result ?? defaultResult;
- }
-}
\ No newline at end of file
diff --git a/example/lib/tdesign/example_base.dart b/example/lib/tdesign/example_base.dart
deleted file mode 100644
index 2b580e2f0..000000000
--- a/example/lib/tdesign/example_base.dart
+++ /dev/null
@@ -1,132 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/src/util/platform_util.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import 'api_widget.dart';
-
-
-typedef PageBuilder = Widget Function(BuildContext context, ExamplePageModel model);
-
-/// 示例页面数据
-class ExamplePageModel{
-
- ExamplePageModel({required this.text,required this.path, this.apiPath, this.codePath,required this.pageBuilder,});
-
- final String text;
- final String path;
- final String? apiPath;
- final String? codePath;
- final PageBuilder pageBuilder;
-}
-
-/// 示例页面控件,建议每个页面返回一个ExampleWidget即可,不用独自封装
-class ExampleWidget extends StatefulWidget {
- const ExampleWidget({Key? key, required this.title, required this.children, this.padding, this.backgroundColor,}) : super(key: key);
-
- final String title;
- final List children;
- final EdgeInsetsGeometry? padding;
- final Color? backgroundColor;
-
- @override
- State createState() => _ExampleWidgetState();
-}
-
-class _ExampleWidgetState extends State {
-
- late var list;
- bool apiVisible = false;
- ExamplePageModel? model;
-
- @override
- void initState() {
- super.initState();
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
-
- var modelTheme = context.dependOnInheritedWidgetOfExactType();
- model = modelTheme?.model;
-
- });
- list = [
- for(var item in widget.children)
- Container(
- padding: widget.padding ?? const EdgeInsets.all(16),
- child: item,
- )
- ];
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: widget.backgroundColor,
- appBar: AppBar(title: Text('${widget.title}示例页'),
- actions: PlatformUtil.isWeb ? null : [
- GestureDetector(
- child: Container(
- alignment: Alignment.centerRight,
- padding: const EdgeInsets.only(right: 32),
- child: TDText('Api >>',textColor: TDTheme.of(context).whiteColor1,),
- ),
- onTap: (){
- setState(() {
- apiVisible = !apiVisible;
- });
- },
- )
- ],
- ),
- body: Align(
- alignment: Alignment.topCenter,
- child: ScrollbarTheme(
- data: ScrollbarThemeData(trackVisibility: MaterialStateProperty.all(true)),
- child: SingleChildScrollView(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- ApiWidget(apiName: model?.apiPath,visible: apiVisible,), ...list,
- ],
- ),),
- ),
- ),
- );
- }
-}
-
-
-/// 示例样例,建议尽量使用该控件,写清晰说明内容
-class ExampleItem extends StatelessWidget{
-
- const ExampleItem({Key? key, required this.desc, required this.builder}) : super(key: key);
-
- final String desc;
-
- final WidgetBuilder builder;
-
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text('示例——$desc', style: const TextStyle(color: Colors.black45),),
- builder(context),
- ],
- );
- }
-}
-
-/// 存储主题数据的内部控件
-class ExamplePageInheritedTheme extends InheritedWidget {
- final ExamplePageModel model;
-
- const ExamplePageInheritedTheme(
- {required this.model, Key? key, required Widget child})
- : super(key: key, child: child);
-
- @override
- bool updateShouldNotify(covariant ExamplePageInheritedTheme oldWidget) {
- return model != oldWidget.model;
- }
-}
-
diff --git a/example/lib/tdesign/example_route.dart b/example/lib/tdesign/example_route.dart
deleted file mode 100644
index 6351135fc..000000000
--- a/example/lib/tdesign/example_route.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter_example/about.dart';
-import '../main.dart';
-import 'example_base.dart';
-
-
-class TDExampleRoute {
- static final Map pageModelList = {};
- static const String aboutPath = 'about';
-
- static void init(){
- for(var model in examplePageList){
- pageModelList[model.path] = model;
- }
- // 添加关于页路由
- pageModelList[aboutPath] = ExamplePageModel(
- text: '关于',
- path: 'AboutPage',
- pageBuilder: (context,model)=> const AboutPage());
- }
-
- static Route? onGenerateRoute(RouteSettings settings) {
- final name = settings.name ?? 'unknown';
- var model = pageModelList[name];
- if (model != null) {
- final Route route = MaterialPageRoute(
- settings: settings,
- builder: (context) => model.pageBuilder(context, model));
- return route;
- } else {
- return MaterialPageRoute(
- settings: settings,
- builder: (context) => const Center(
- child: Text('error'),
- ));
- }
- }
-}
diff --git a/example/lib/tdesign/page/td_avatar_page.dart b/example/lib/tdesign/page/td_avatar_page.dart
deleted file mode 100644
index 39f0d9f25..000000000
--- a/example/lib/tdesign/page/td_avatar_page.dart
+++ /dev/null
@@ -1,196 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-
-class TDAvatarPage extends StatefulWidget {
- const TDAvatarPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDAvatarPageState();
-}
-
-class _TDAvatarPageState extends State {
- @override
- Widget build(BuildContext context) {
- var imgUrl = 'https://photo.16pic.com/00/53/26/16pic_5326745_b.jpg';
- return ExampleWidget(
- backgroundColor: TDTheme.of(context).whiteColor1,
- title: '头像 Avatar',
- children: [
- ExampleItem(
- desc: '类型--默认',
- builder: (_) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.normal,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.normal,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.normal,
- avatarUrl: imgUrl),
- ],
- );
- }),
- ExampleItem(
- desc: '类型-圆形',
- builder: (_) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.circle,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.circle,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.circle,
- avatarUrl: imgUrl),
- ],
- );
- }),
- ExampleItem(
- desc: '类型-方形',
- builder: (_) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.square,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.square,
- avatarUrl: imgUrl),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.square,
- avatarUrl: imgUrl),
- ],
- );
- }),
- ExampleItem(
- desc: '类型-自定义文字',
- builder: (_) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: const [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.customText,
- text: 'A',
- ),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.customText,
- text: 'A',
- ),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.customText,
- text: 'A',
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '特殊类型-带操作',
- builder: (_) {
- return Column(
- mainAxisSize: MainAxisSize.max,
- children: [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.operation,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- onTap: (){
- TDToast.showText('点击了操作', context: context);
- }
- ),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.operation,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- onTap: (){
- TDToast.showText('点击了操作', context: context);
- }
- ),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.operation,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- onTap: (){
- TDToast.showText('点击了操作', context: context);
- }
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '特殊类型-纯展示',
- builder: (_) {
- return Column(
- mainAxisSize: MainAxisSize.max,
- children: [
- TDAvatar(
- size: TDAvatarSize.large,
- type: TDAvatarType.display,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- displayText: '+5',
- ),
- TDAvatar(
- size: TDAvatarSize.medium,
- type: TDAvatarType.display,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- displayText: '+5',
- ),
- TDAvatar(
- size: TDAvatarSize.small,
- type: TDAvatarType.display,
- avatarDisplayList: [
- imgUrl,
- imgUrl,
- imgUrl
- ],
- displayText: '+5',
- ),
- ],
- );
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_badge_page.dart b/example/lib/tdesign/page/td_badge_page.dart
deleted file mode 100644
index 353719c81..000000000
--- a/example/lib/tdesign/page/td_badge_page.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-
-class TDBadgePage extends StatefulWidget {
- const TDBadgePage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDBadgePageState();
-}
-
-class _TDBadgePageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '徽标 Badge',
- children: [
- ExampleItem(
- desc: '红点徽标',
- builder: (_) {
- return const TDBadge(
- TDBadgeType.redPoint,
- );
- }),
- ExampleItem(
- desc: '提醒徽标',
- builder: (_) {
- return const TDBadge(
- TDBadgeType.remind,
- );
- }),
- ExampleItem(
- desc: '消息徽标-个位数',
- builder: (_) {
- return const TDBadge(
- TDBadgeType.message,
- count: '2',
- );
- }),
- ExampleItem(
- desc: '消息徽标-两位数',
- builder: (_) {
- return const TDBadge(TDBadgeType.message, count: '16');
- }),
- ExampleItem(
- desc: '消息徽标-三位数',
- builder: (_) {
- return const TDBadge(TDBadgeType.message, count: '128');
- }),
- ExampleItem(
- desc: '消息徽标-自定义内容',
- builder: (_) {
- return const TDBadge(
- TDBadgeType.message,
- message: '新消息提醒',
- );
- }),
- ExampleItem(
- desc: '消息徽标-自定义内容-方形',
- builder: (_) {
- return const TDBadge(
- TDBadgeType.message,
- message: 'New',
- border: TDBadgeBorder.small,
- );
- }),
- ExampleItem(
- desc: '消息徽标-自定义内容-角标',
- builder: (_) {
- return Stack(
- alignment: Alignment.topRight,
- children: [
- Container(
- padding: const EdgeInsets.only(left: 16),
- alignment: Alignment.centerLeft,
- child: TDText(
- '单行标题',
- textColor: TDTheme.of(context).fontGyColor1,
- font: TDTheme.of(context).fontM,
- ),
- color: Colors.white,
- height: 48,
- width: MediaQuery.of(context).size.width,
- ),
- const TDBadge(
- TDBadgeType.subscript,
- message: 'NEW',
- ),
- ],
- );
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_bottom_nav_bar_page.dart b/example/lib/tdesign/page/td_bottom_nav_bar_page.dart
deleted file mode 100644
index 79fabaf62..000000000
--- a/example/lib/tdesign/page/td_bottom_nav_bar_page.dart
+++ /dev/null
@@ -1,584 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDBottomNavBarPage extends StatelessWidget {
- const TDBottomNavBarPage({Key? key}) : super(key: key);
-
- void onTapTab(BuildContext context, String tabName) {
- TDToast.showText('点击了 $tabName', context: context);
- }
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '标签栏 TDBottomNavBar',
- padding: const EdgeInsets.symmetric(vertical: 16),
- children: [
- ExampleItem(
- desc: '单层级纯文本标签栏',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.text,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏一',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏一',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- onTap: () {
- onTapTab(context, '标签栏一');
- }),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏二',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏二',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- onTap: () {
- onTapTab(context, '标签栏二');
- },
- ),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '单层级纯文本标签栏',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.text,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏一',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏一',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- onTap: () {
- onTapTab(context, '标签栏一');
- }),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏二',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏二',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- onTap: () {
- onTapTab(context, '标签栏二');
- },
- ),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏三',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏三',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- onTap: () {
- onTapTab(context, '标签栏三');
- },
- ),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '文本加图标标签栏',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.iconText,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏一',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏一',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏一');
- },
- ),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏二',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏二',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏二');
- }),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏三',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏三',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏三');
- }),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '文本加图标标签栏',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.iconText,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏一',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏一',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏一');
- },
- ),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏二',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏二',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏二');
- }),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏三',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏三',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏三');
- }),
- TDBottomNavBarTabConfig(
- selectedText: Text(
- '标签栏四',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8, fontSize: 16),
- ),
- unselectedText: const Text(
- '标签栏四',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- ),
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- onTap: () {
- onTapTab(context, '标签栏四');
- }),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '纯图标标签栏',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.icon,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 30,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 30,
- ),
- onTap: () {
- onTapTab(context, '第一个图标');
- }),
- TDBottomNavBarTabConfig(
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 30,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 30,
- ),
- onTap: () {
- onTapTab(context, '第二个图标');
- },
- ),
- TDBottomNavBarTabConfig(
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 30,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 30,
- ),
- onTap: () {
- onTapTab(context, '第三个图标');
- }),
- TDBottomNavBarTabConfig(
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 30,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 30,
- ),
- onTap: () {
- onTapTab(context, '第四个图标');
- }),
- TDBottomNavBarTabConfig(
- selectedIcon: Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 30,
- ),
- unselectedIcon: const Icon(
- Icons.home,
- color: Colors.grey,
- size: 30,
- ),
- onTap: () {
- onTapTab(context, '第五个图标');
- }),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '底部导航栏自定义布局',
- builder: (BuildContext context) {
- return TDBottomNavBar(
- TDBottomNavBarType.customLayout,
- useVerticalDivider: true,
- navigationTabs: [
- TDBottomNavBarTabConfig(
- showBadge: true,
- tdBadge: const TDBadge(
- TDBadgeType.remind,
- ),
- badgeTopOffset: -2,
- badgeRightOffset: -20,
- selectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.home,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- Text(
- '首页',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8,
- fontSize: 16),
- )
- ],
- ),
- unSelectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- Icon(
- Icons.home,
- color: Colors.grey,
- size: 20,
- ),
- Text(
- '首页',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- )
- ],
- ),
- onTap: () {
- onTapTab(context, '首页');
- },
- ),
- TDBottomNavBarTabConfig(
- showBadge: true,
- tdBadge: const TDBadge(
- TDBadgeType.message,
- message: 'New',
- ),
- badgeTopOffset: -2,
- badgeRightOffset: -20,
- selectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.category,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- Text(
- '分类',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8,
- fontSize: 16),
- )
- ],
- ),
- unSelectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- Icon(
- Icons.category,
- color: Colors.grey,
- size: 20,
- ),
- Text(
- '分类',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- )
- ],
- ),
- onTap: () {
- onTapTab(context, '分类');
- },
- ),
- TDBottomNavBarTabConfig(
- showBadge: true,
- tdBadge: const TDBadge(TDBadgeType.message, count: '16'),
- badgeTopOffset: -2,
- badgeRightOffset: -10,
- selectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- Icon(
- Icons.shopping_cart,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- Text(
- '购物车',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8,
- fontSize: 16),
- )
- ],
- ),
- unSelectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: const [
- Icon(
- Icons.shopping_cart,
- color: Colors.grey,
- size: 20,
- ),
- Text(
- '购物车',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- )
- ],
- ),
- onTap: () {
- onTapTab(context, '购物车');
- },
- ),
- TDBottomNavBarTabConfig(
- showBadge: true,
- tdBadge: const TDBadge(TDBadgeType.redPoint),
- badgeTopOffset: -2,
- badgeRightOffset: -10,
- selectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.settings,
- color: TDTheme.of(context).brandColor8,
- size: 20,
- ),
- Text(
- '展开',
- style: TextStyle(
- color: TDTheme.of(context).brandColor8,
- fontSize: 16),
- )
- ],
- ),
- unSelectWidget: Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- Icon(
- Icons.settings,
- color: Colors.grey,
- size: 20,
- ),
- Text(
- '展开',
- style: TextStyle(color: Colors.grey, fontSize: 16),
- )
- ],
- ),
- onTap: () {
- onTapTab(context, '展开');
- },
- popUpButtonConfig: TDBottomNavBarPopUpBtnConfig(
- popUpDialogConfig: TDBottomNavBarPopUpShapeConfig(
- radius: 10,
- arrowWidth: 16,
- arrowHeight: 8,
- ),
- items: [
- '展开项一',
- '展开项二',
- '展开项三',
- '展开项四',
- '展开项五',
- '展开项六',
- '展开项七',
- '展开项八',
- ]
- .map((e) => PopUpMenuItem(
- value: e,
- itemWidget: SizedBox(
- //height: 30,
- child: Text(
- e,
- style: TextStyle(
- color: TDTheme.of(context).grayColor7,
- fontSize: 16),
- ),
- ),
- ))
- .toList(),
- onChanged: (v) {
- TDToast.showText('点击了 $v', context: context);
- })),
- ],
- );
- },
- ),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_button_page.dart b/example/lib/tdesign/page/td_button_page.dart
deleted file mode 100644
index d03fcf2f5..000000000
--- a/example/lib/tdesign/page/td_button_page.dart
+++ /dev/null
@@ -1,313 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDButtonPage extends StatefulWidget {
- const TDButtonPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDButtonPageState();
-}
-
-class _TDButtonPageState extends State {
-
- void onTap() {
- TDToast.showText('点击了按钮',context: context);
- }
-
- void onLongPress() {
- TDToast.showText('长按了按钮', context: context);
- }
-
- @override
- Widget build(BuildContext context) {
- return Container(
- color: TDTheme.of(context).grayColor2,
- child: ExampleWidget(
- title: '按钮 Button',
- padding: const EdgeInsets.only(top: 8,bottom: 8),
- children: [
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '强按钮',
- style: TDButtonStyle.primary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '强按钮',
- style: TDButtonStyle.primary(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '弱按钮',
- style: TDButtonStyle.weakly(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '弱按钮',
- style: TDButtonStyle.weakly(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '次按钮',
- style: TDButtonStyle.secondary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '次按钮',
- style: TDButtonStyle.secondary(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '带图标按钮',
- style: TDButtonStyle.weakly(),
- icon: TDIcons.app,
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '带图标按钮',
- style: TDButtonStyle.weakly(),
- icon: TDIcons.app,
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '强警告按钮',
- style: TDButtonStyle.warningPrimary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '强警告按钮',
- style: TDButtonStyle.warningPrimary(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '弱警告按钮',
- style: TDButtonStyle.warningWeakly(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '弱警告按钮',
- style: TDButtonStyle.warningWeakly(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return Container(
- width: MediaQuery.of(context).size.width,
- padding: const EdgeInsets.all(10),
- color: Colors.black12,
- child: Stack(
- alignment: Alignment.center,
- children: [
- TDButton(content: '幽灵按钮',
- style: TDButtonStyle.ghost(),
- onTap: onTap,
- onLongPress: onLongPress,
- )
- ],),
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return Container(
- width: MediaQuery.of(context).size.width,
- padding: const EdgeInsets.all(10),
- color: Colors.black12,
- child: Stack(
- alignment: Alignment.center,
- children: [
- TDButton(content: '幽灵按钮',
- style: TDButtonStyle.ghost(),
- // width: 343,
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,)
- ],),
- );
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDTextButton('文字按钮',
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDTextButton('文字按钮',
- onTap: onTap,
- onLongPress: onLongPress,
- disabled: true,
- );
- }),
-
-
- ExampleItem(desc: '可点击', builder: (context){
- return TDButton(content: '通栏按钮',
- style: TDButtonStyle.full(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '不可点击', builder: (context){
- return TDButton(content: '通栏按钮',
- style: TDButtonStyle.full(),
- disabled: true,
- onTap: onTap,
- onLongPress: onLongPress,);
- }),
-
-
- ExampleItem(desc: '两个按钮', builder: (context){
- return Row(
- children: [
- Expanded(child: TDButton(content: '次按钮',
- style: TDButtonStyle.fullSecondary(),
- onTap: onTap,
- onLongPress: onLongPress,
- )),
- Expanded(child: TDButton(content: '主按钮',
- style: TDButtonStyle.full(),
- onTap: onTap,
- onLongPress: onLongPress,
- )),
- ],
- );
- }),
-
-
-
-
-
- ExampleItem(desc: '尺寸', builder: (context){
- return SizedBox(
- height: 50,
- child: TDText(
- '下方是尺寸示例',
- font: TDTheme.of().fontL,
- textColor: TDTheme.of().warningNormalColor,
- ),
- );
- }),
-
-
- ExampleItem(desc: '大', builder: (context){
- return TDButton(content: '强按钮',
- style: TDButtonStyle.primary(),
- size: TDButtonSize.large,
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '中(默认)', builder: (context){
- return TDButton(content: '强按钮',
- size: TDButtonSize.medium,
- style: TDButtonStyle.primary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '强按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.primary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '弱按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.weakly(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '次按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.secondary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '带图标按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.weakly(),
- icon: TDIcons.app,
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '强警告按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.warningPrimary(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return TDButton(content: '弱警告按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.warningWeakly(),
- onTap: onTap,
- onLongPress: onLongPress,
- );
- }),
- ExampleItem(desc: '小(宽度自适应)', builder: (context){
- return Container(
- width: 200,
- padding: const EdgeInsets.all(10),
- color: Colors.black12,
- child: Stack(
- alignment: Alignment.center,
- children: [
- TDButton(content: '幽灵按钮',
- size: TDButtonSize.small,
- style: TDButtonStyle.ghost(),
- onTap: onTap,
- onLongPress: onLongPress,
- )
- ],),
- );
- }),
-
-
- ]),
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_checkbox_page.dart b/example/lib/tdesign/page/td_checkbox_page.dart
deleted file mode 100644
index d7540d2cc..000000000
--- a/example/lib/tdesign/page/td_checkbox_page.dart
+++ /dev/null
@@ -1,197 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-///
-/// TDCheckbox演示
-///
-class TDCheckboxPage extends StatefulWidget {
- const TDCheckboxPage({Key? key}) : super(key: key);
-
- @override
- State createState() {
- return TDCheckboxPageState();
- }
-}
-
-class TDCheckboxPageState extends State {
-
- List? checkIds;
-
- TDCheckboxGroupController? controller;
-
- @override
- void initState() {
- super.initState();
- controller = TDCheckboxGroupController();
- }
-
- @override
- Widget build(BuildContext context) {
- const itemCount = 4;
- Widget getAllIcon(bool checked, bool halfSelected) {
- return Icon(
- checked ? TDIcons.check_circle_filled : halfSelected ? TDIcons.minus_circle_filled : TDIcons.circle,
- size: 24,
- color: (checked || halfSelected) ? TDTheme.of(context).brandColor8 : TDTheme.of(context).grayColor4
- );
- }
-
- return ExampleWidget(
- title: '多选框 Checkbox',
- children: [
- ExampleItem(desc: '基础多选框', builder: (context){
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- TDCheckbox(
- title: '多选',
- checked: true,
- ),
- TDCheckbox(
- title: '多选',
- ),
- TDCheckbox(
- title: '禁用状态',
- enable: false,
- checked: true,
- ),
- TDCheckbox(
- title: '多选多选多选多选多选多选多选多选多选多选多选多选',
- titleMaxLine: 2,
- subTitleMaxLine: 2,
- enable: false,
- ),
- TDCheckbox(
- title: '多选',
- subTitle: '单选单选单选单选单选单选单选单选单选单选单选单选',
- titleMaxLine: 2,
- subTitleMaxLine: 2,
- ),
- ],
- );
- }),
- ExampleItem(desc: '右侧多选框', builder: (context){
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- TDCheckbox(
- contentDirection: TDContentDirection.left,
- title: '多选',
- checked: true,
- ),
- TDCheckbox(
- contentDirection: TDContentDirection.left,
- title: '多选',
- checked: true,
- ),
- TDCheckbox(
- contentDirection: TDContentDirection.left,
- title: '多选多选多选多选多选多选多选多选多选多选多选多选多选',
- ),
- TDCheckbox(
- contentDirection: TDContentDirection.left,
- title: '多选',
- subTitle: '单选单选单选单选单选单选单选单选单选单选单选单选',
- ),
- ],
- );
- }),
- ExampleItem(desc: '自定义图标多框类型', builder: (context){
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- TDCheckbox(
- style: TDCheckboxStyle.square,
- title: '多选',
- ),
- TDCheckbox(
- style: TDCheckboxStyle.square,
- title: '多选',
- checked: true,
- ),
- TDCheckbox(
- style: TDCheckboxStyle.square,
- title: '多选',
- checked: true,
- ),
- ],
- );
- }),
- ExampleItem(desc: '规格', builder: (context){
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: const [
- TDCheckbox(
- title: '多选 H48',
- checked: true,
- ),
- TDCheckbox(
- title: '多选 H56',
- size: TDCheckBoxSize.large,
- ),
- ],
- );
- }),
- ExampleItem(desc: '带全选多选框', builder: (context){
- return TDCheckboxGroup(
- controller: controller,
- onChangeGroup: (checkedId) {
- checkIds = checkedId;
- setState(() {});
- },
- checkedIds: checkIds,
- onOverloadChecked: () {
- TDToast.showText('最大只能勾选3个选项', context: context);
- },
- child: ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: itemCount,
- itemBuilder: (BuildContext context, int index) {
- if(index == 0) {
- return TDCheckbox(
- contentDirection: TDContentDirection.right,
- title: '全选',
- id: '0',
- customIconBuilder: (context, checked) {
- var length = controller!.allChecked().length - (controller!.checked('0') ? 1 : 0);
- var allCheck = itemCount - 1 == length;
- var halfSelected =
- controller != null
- && !allCheck
- && length > 0;
- return getAllIcon(allCheck, halfSelected);
- },
- onCheckBoxChanged: (checked){
- if (checked) {
- controller?.toggleAll(true);
- } else {
- controller?.toggleAll(false);
- }
- },
- );
- }
- return TDCheckbox(
- contentDirection: TDContentDirection.right,
- title: '多选${index}',
- id: '$index',
- onCheckBoxChanged: (checked) {
- var length = controller!.allChecked().length - (controller!.checked('0') ? 1 : 0);
- var allCheck = itemCount - 1 == length;
- var halfSelected =
- controller != null
- && !allCheck
- && length > 0;
- controller!.toggle('0', allCheck);
- getAllIcon(allCheck, halfSelected);
- },
- );
- },
- ));
- })
- ]
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_date_picker_page.dart b/example/lib/tdesign/page/td_date_picker_page.dart
deleted file mode 100644
index a07fb32a7..000000000
--- a/example/lib/tdesign/page/td_date_picker_page.dart
+++ /dev/null
@@ -1,156 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-
-class TDDatePickerPage extends StatefulWidget {
- const TDDatePickerPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDDatePickerPageState();
-}
-
-class _TDDatePickerPageState extends State {
- String selected_1 = '';
- String selected_2 = '';
- String selected_3 = '';
- String selected_4 = '';
- String selected_5 = '';
- String selected_6 = '';
-
- @override
- void initState() {
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '时间选择器 DatePicker',
- children: [
- ExampleItem(desc: '年月日', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择时间',
- onConfirm: (selected) {
- setState(() {
- selected_1 = '日期: $selected';
- });
- },
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_1,
- ),
- ]);
- }),
- ExampleItem(desc: '年月', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择时间',
- onConfirm: (selected) {
- setState(() {
- selected_2 = '日期: $selected';
- });
- },
- useDay: false,
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_2,
- ),
- ]);
- }),
- ExampleItem(desc: '月日', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择时间',
- onConfirm: (selected) {
- setState(() {
- selected_3 = '日期: $selected';
- });
- },
- useYear: false,
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_3,
- ),
- ]);
- }),
- ExampleItem(desc: '时分秒', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择时间',
- onConfirm: (selected) {
- setState(() {
- selected_4 = '日期: $selected';
- });
- },
- useYear: false,
- useMonth: false,
- useDay: false,
- useHour: true,
- useMinute: true,
- useSecond: true,
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_4,
- ),
- ]);
- }),
- ExampleItem(desc: '年月日时分秒', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择时间',
- onConfirm: (selected) {
- setState(() {
- selected_5 = '日期: $selected';
- });
- },
- useHour: true,
- useMinute: true,
- useSecond: true,
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_5,
- ),
- ]);
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_dialog_page.dart b/example/lib/tdesign/page/td_dialog_page.dart
deleted file mode 100644
index 2ff1bc984..000000000
--- a/example/lib/tdesign/page/td_dialog_page.dart
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/17/22.
- * td_dialog_page.dart
- *
- */
-
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-
-class TDDialogPage extends StatefulWidget {
- const TDDialogPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDDialogPageState();
-}
-
-class _TDDialogPageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '对话框 Dialog',
- padding: const EdgeInsets.all(3),
- children: [
- _dividerWidget('确认弹框'),
- ElevatedButton(
- onPressed: () {
- _showDialog(const TDConfirmDialog(
- title: '对话框标题',
- ));
- },
- child: const Text('只有标题')),
- ElevatedButton(
- onPressed: () {
- _showDialog(const TDConfirmDialog(
- title: '对话框标题长,对话框标题长,对话框标题长长长长长长长长',
- ));
- },
- child: const Text('长标题')),
- ElevatedButton(
- onPressed: () {
- _showDialog(const TDConfirmDialog(
- content:
- '告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内,告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内',
- ));
- },
- child: const Text('只有内容')),
- ElevatedButton(
- onPressed: () {
- _showDialog(TDConfirmDialog(
- title: '对话框标题',
- content:
- '告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内,告知当前状态、信息和解决方法,等内容。',
- action: () {
- print('知道了');
- },
- ));
- },
- child: const Text('标题+内容')),
- ElevatedButton(
- onPressed: () {
- _showDialog(const TDConfirmDialog(
- contentMaxHeight: 100,
- title: '对话框标题',
- content:
- '告知当前状态、信息和解决方法,等内容。描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很多描述文案很',
- ));
- },
- child: const Text('标题+可滚动内容')),
- _dividerWidget('多选项弹窗'),
- ElevatedButton(
- onPressed: () {
- _showDialog(TDAlertDialog(
- title: '对话框标题',
- content:
- '告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内,告知当前状态、信息和解决方法,等内容。',
- rightBtn: TDDialogButton(
- title: '确定',
- action: () {
- print('点击了确定按钮');
- }),
- ));
- },
- child: const Text('左右选择')),
- ElevatedButton(
- onPressed: () {
- _showDialog(TDAlertDialog.vertical(
- title: '对话框标题',
- content:
- '告知当前状态、信息和解决方法,等内容。描述文案尽可能控制在三行内,告知当前状态、信息和解决方法,等内容。',
- buttons: [
- TDDialogButton(
- title: '第一行',
- action: () {
- print('点击了第一行');
- }),
- TDDialogButton(
- title: '第二行',
- action: () {
- print('点击了第二行');
- }),
- TDDialogButton(
- title: '取消',
- action: () {
- print('点击了取消');
- },
- titleColor: Colors.black87,
- fontWeight: FontWeight.w400)
- ],
- ));
- },
- child: const Text('上下选择')),
- _dividerWidget('输入类弹窗'),
- ElevatedButton(
- onPressed: () {
- _showDialog(TDInputDialog(
- title: '对话框标题',
- content: '告知当前状态、信息和解决方法',
- textEditingController: TextEditingController(),
- rightBtn: TDDialogButton(
- title: '确定',
- action: () {
- print('点击了确定按钮');
- }),
- ));
- },
- child: const Text('输入类对话框')),
- _dividerWidget('带图片弹窗'),
- ElevatedButton(
- onPressed: () {
- _showDialog(TDImageDialog(
- title: '对话框标题',
- content: '告知当前状态、信息和解决方法',
- image: Image.network(
- 'http://static.runoob.com/images/demo/demo2.jpg',
- // fit: BoxFit.cover,
- ),
- rightBtn: TDDialogButton(
- title: '确定',
- action: () {
- print('点击了确定按钮');
- }),
- ));
- },
- child: const Text('带图片弹窗')),
- ]);
- }
-
- void _showDialog(Widget dialog,{bool useRootNavigator = false}) {
- showGeneralDialog(
- context: context,
- pageBuilder: (BuildContext buildContext, Animation animation,
- Animation secondaryAnimation) {
- return dialog;
- },
- useRootNavigator: useRootNavigator,
- barrierDismissible: true,
- barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
- barrierColor: Colors.black54,
- transitionDuration: const Duration(milliseconds: 100),
- );
- }
-
- Widget _dividerWidget(String title) {
- return Row(
- children: [
- const Spacer(),
- const TDDivider(
- height: 1,
- width: 100,
- ),
- const SizedBox(
- width: 10,
- ),
- TDText(title),
- const SizedBox(
- width: 10,
- ),
- const TDDivider(
- height: 1,
- width: 100,
- ),
- const Spacer(),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_divider_page.dart b/example/lib/tdesign/page/td_divider_page.dart
deleted file mode 100644
index 510a73858..000000000
--- a/example/lib/tdesign/page/td_divider_page.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDDividerPage extends StatelessWidget {
- const TDDividerPage({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '分割线 Divider',
- padding: const EdgeInsets.only(top: 16, bottom: 16),
- children: [
- ExampleItem(desc: '直线拉通', builder: (_){
- return const TDDivider();
- }),
- ExampleItem(desc: '虚线拉通', builder: (_){
- return const TDDivider(isDashed: true,);
- }),
- ExampleItem(desc: '左右间距', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 16, right: 16),);
- }),
- ExampleItem(desc: '左侧拉通', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 16, ),);
- }),
- ExampleItem(desc: '自定义左侧间距', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 76, ),);
- }),
- ExampleItem(desc: '左右间距(虚线)', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 16, right: 16),isDashed: true,);
- }),
- ExampleItem(desc: '自定义左侧间距(虚线)', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 76, ),isDashed: true,);
- }),
- ExampleItem(desc: '垂直分割', builder: (_){
- return Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- TDText('文字信息', textColor: TDTheme.of(context).fontGyColor3,),
- const TDDivider(width: 0.5, height: 12, margin: EdgeInsets.only(left: 8, right: 8),),
- TDText('文字信息', textColor: TDTheme.of(context).fontGyColor3),
- const TDDivider(width: 0.5, height: 12, margin: EdgeInsets.only(left: 8, right: 8),isDashed: true, direction: Axis.vertical,),
- TDText('文字信息', textColor: TDTheme.of(context).fontGyColor3),
- ],
- );
- }),
- ExampleItem(desc: '文字+直线', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 16, right: 16), text: '文字信息',);
- }),
- ExampleItem(desc: '文字+虚线', builder: (_){
- return const TDDivider(margin: EdgeInsets.only(left: 16, right: 16), text: '文字信息',isDashed: true,);
- }),
- ExampleItem(desc: '纯文字', builder: (_){
- return const TDDivider(hideLine: true, text: '文字信息',);
- }),
- ]);
- }
-}
-
-
diff --git a/example/lib/tdesign/page/td_empty_page.dart b/example/lib/tdesign/page/td_empty_page.dart
deleted file mode 100644
index 31c30f658..000000000
--- a/example/lib/tdesign/page/td_empty_page.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import 'package:tdesign_flutter_example/tdesign/example_base.dart';
-
-
-class TDEmptyPage extends StatefulWidget {
- const TDEmptyPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDEmptyPageState();
-}
-
-class _TDEmptyPageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '空状态 Empty',
- children: [
- Container(
- height: 720,
- color: Colors.white,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDEmpty(
- type: TDEmptyType.operation,
- operationText: '操作按钮',
- emptyText: '描述文字',
- image: Icon(
- TDIcons.info_circle_filled,
- size: 84,
- color: TDTheme.of(context).fontGyColor3,
- ),
- ),
- ],
- ),
- )
- ]);
- }
-}
diff --git a/example/lib/tdesign/page/td_icon_page.dart b/example/lib/tdesign/page/td_icon_page.dart
deleted file mode 100644
index 9474a8acf..000000000
--- a/example/lib/tdesign/page/td_icon_page.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-
-class TDIconPage extends StatefulWidget {
- const TDIconPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDIconPageState();
-}
-
-class _TDIconPageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(title: 'icon图标',
- children: [
- Container(
- color: Colors.white,
- alignment: Alignment.center,
- child: Wrap(
- children: [
- for (var iconData in TDIcons.all.values) Container(
- height: 100,
- width: 175,
-
- child: Column(
- children: [
- Icon(iconData),
- TDText(iconData.name)
- ],
- ),
- )
- ],
- ),
- )
- ]);
-
- }
-}
diff --git a/example/lib/tdesign/page/td_image_page.dart b/example/lib/tdesign/page/td_image_page.dart
deleted file mode 100644
index 9fc15fb8b..000000000
--- a/example/lib/tdesign/page/td_image_page.dart
+++ /dev/null
@@ -1,212 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDImagePage extends StatefulWidget {
- const TDImagePage({Key? key}) : super(key: key);
- @override
- State createState() => TDImageState();
-}
-
-class TDImageState extends State with SingleTickerProviderStateMixin {
- late Animation animation;
- late AnimationController animationController;
-
- @override
- void initState() {
- super.initState();
- animationController =
- AnimationController(vsync: this, duration: const Duration(seconds: 4));
- animation = Tween(begin: 0.0, end: 4.0).animate(animationController);
- animationController.repeat();
- }
-
- @override
- void dispose() {
- animationController.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- var loadingUrl = 'https://images7.alphacoders.com/691/thumbbig-691004.webp';
- var url = 'http://www.zmaomao.com/uploads/201204/11-20120416014B36.jpg';
- return ExampleWidget(
- title: '图片 Image',
- children: [
- ExampleItem(
- desc: '状态-加载默认',
- builder: (_) {
- return TDImage(
- loadingUrl,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '状态-加载自定义',
- builder: (_) {
- return TDImage(
- loadingUrl,
- loadingWidget: RotationTransition(
- turns: animation,
- alignment: Alignment.center,
- child: const Icon(TDIcons.loading, size: 22,)
- ),
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '状态-失败默认',
- builder: (_) {
- return const TDImage(
- 'error',
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '状态-失败自定义',
- builder: (_) {
- return TDImage(
- 'error',
- errorWidget: TDText(
- '加载失败',
- forceVerticalCenter: true,
- font: TDTheme.of(context).fontXXS,
- fontWeight: FontWeight.w500,
- textColor: TDTheme
- .of(context)
- .fontGyColor3,
- ),
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '类型-裁剪',
- builder: (_) {
- return TDImage(
- url,
- type: TDImageType.clip,
- );
- }
- ),
- ExampleItem(
- desc: '类型-适应高',
- builder: (_) {
- return TDImage(
- url,
- width: 89,
- height: 72,
- type: TDImageType.fitHeight,
- );
- }
- ),
- ExampleItem(
- desc: '类型-拉伸',
- builder: (_) {
- return TDImage(
- url,
- width: 134,
- height: 72,
- type: TDImageType.stretch,
- );
- }
- ),
- ExampleItem(
- desc: '类型-方形',
- builder: (_) {
- return TDImage(
- url,
- type: TDImageType.square,
- );
- }
- ),
- ExampleItem(
- desc: '类型-圆角方形',
- builder: (_) {
- return TDImage(
- url,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '类型-圆形',
- builder: (_) {
- return TDImage(
- url,
- type: TDImageType.circle,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片120',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.xl,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片72',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.l,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片56',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.m,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片48',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.s,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片32',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.xs,
- type: TDImageType.roundedSquare,
- );
- }
- ),
- ExampleItem(
- desc: '规格-图片24',
- builder: (_) {
- return TDImage(
- url,
- size: TDImageSize.xxs,
- type: TDImageType.roundedSquare,
- );
- }
- ),
-
- ],
- );
- }
-}
-
-
diff --git a/example/lib/tdesign/page/td_input_page.dart b/example/lib/tdesign/page/td_input_page.dart
deleted file mode 100644
index 987bfcba4..000000000
--- a/example/lib/tdesign/page/td_input_page.dart
+++ /dev/null
@@ -1,238 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDInputViewPage extends StatefulWidget {
- const TDInputViewPage({Key? key}) : super(key: key);
-
- @override
- _TDInputViewPageState createState() => _TDInputViewPageState();
-}
-
-class _TDInputViewPageState extends State {
- String inputText = '请输入...';
- var controller = TextEditingController();
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- backgroundColor: const Color(0xFFF0F2F5),
- title: '输入框 Input',
- children: [
- ExampleItem(
- desc: '基础文本框',
- builder: (_) {
- return TDInput(
- leftLabel: '标签文字',
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- );
- }),
- ExampleItem(
- desc: '无标题文本框',
- builder: (_) {
- return TDInput(
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- );
- }),
- ExampleItem(
- desc: '带提示信息文本框',
- builder: (_) {
- return TDInput(
- leftLabel: '标签文字',
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- rightBtn: Icon(
- TDIcons.error_circle_filled,
- color: TDTheme.of(context).fontGyColor3,
- ),
- );
- }),
- ExampleItem(
- desc: '两行样式文本框',
- builder: (_) {
- return TDInput(
- leftLabel: '标签文字',
- type: TDInputType.twoLine,
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- );
- }),
- ExampleItem(
- desc: '长标题文本框',
- builder: (_) {
- return TDInput(
- leftLabel: '超长需换行的标签',
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- );
- }),
- ExampleItem(
- desc: '长文本输入文本框-无标题',
- builder: (_) {
- return TDInput(
- type: TDInputType.longText,
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- maxLines: 8,
- );
- }),
- ExampleItem(
- desc: '长文本输入文本框',
- builder: (_) {
- return TDInput(
- type: TDInputType.longText,
- leftLabel: '标签文字',
- controller: controller,
- backgroundColor: Colors.white,
- hintText: '请输入文字',
- maxLines: 8,
- );
- }),
- ExampleItem(
- desc: '状态--不可编辑文字',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- leftLabel: '标签文字',
- readOnly: true,
- controller: controller,
- hintText: '不可编辑文字',
- hintTextStyle: TextStyle(color: TDTheme.of(context).fontGyColor1),
- backgroundColor: Colors.white,
- );
- }),
- ExampleItem(
- desc: '状态--一段错误填写的内容',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- leftLabel: '标签文字',
- readOnly: true,
- controller: controller,
- hintText: '一段错误填写的内容',
- errorText: '提示信息',
- hintTextStyle: TextStyle(color: TDTheme.of(context).errorColor6),
- backgroundColor: Colors.white,
- );
- }),
- ExampleItem(
- desc: '小规格H48',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- leftLabel: '小规格H48',
- controller: controller,
- hintText: '请填写内容',
- backgroundColor: Colors.white,
- );
- }),
- ExampleItem(
- desc: '大规格H56',
- builder: (_) {
- return TDInput(
- size: TDInputSize.large,
- type: TDInputType.normal,
- leftLabel: '大规格H56',
- controller: controller,
- hintText: '请填写内容',
- backgroundColor: Colors.white,
- );
- }),
- ExampleItem(
- desc: '特殊类型',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- controller: controller,
- hintText: '请输入手机号码',
- backgroundColor: Colors.white,
- rightBtn: Row(
- children: [
- Container(width: 0.5, height: 24, color: TDTheme.of(context).grayColor3,),
- const SizedBox(width: 16,),
- TDText('发送验证码', textColor: TDTheme.of(context).brandColor8),
- ],
- ),
- onTapBtn: (){
- TDToast.showText('点击了发送验证码', context: context);
- },
- );
- }),
- ExampleItem(
- desc: '特殊类型',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- size: TDInputSize.small,
- controller: controller,
- leftLabel: '验证码',
- hintText: '输入验证码',
- backgroundColor: Colors.white,
- rightBtn: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(width: 0.5, height: 36, color: TDTheme.of(context).grayColor3,),
- const SizedBox(width: 16,),
- Image.network('https://img2018.cnblogs.com/blog/736399/202001/736399-20200108170302307-1377487770.jpg', width: 72, height: 36,)
- ],
- ),
- onTapBtn: (){
- TDToast.showText('点击了发送验证码', context: context);
- },
- );
- }),
- ExampleItem(
- desc: '特殊类型',
- builder: (_) {
- return TDInput(
- type: TDInputType.normal,
- controller: controller,
- obscureText: true,
- leftLabel: '输入密码',
- hintText: '请输入密码',
- backgroundColor: Colors.white,
- rightBtn: Icon(TDIcons.close_circle_filled, color: TDTheme.of(context).fontGyColor3,),
- onTapBtn: (){
- controller.clear();
- },
- );
- }),
- ExampleItem(
- desc: '特殊类型',
- builder: (_) {
- return TDInput(
- type: TDInputType.special,
- controller: controller,
- leftLabel: '价格',
- hintText: '0.00',
- backgroundColor: Colors.white,
- textAlign: TextAlign.end,
- rightWidget: TDText('元', textColor: TDTheme.of(context).fontGyColor1),
- );
- }),
- ExampleItem(
- desc: '特殊类型',
- builder: (_) {
- return TDInput(
- type: TDInputType.special,
- controller: controller,
- leftLabel: '数量',
- hintText: '输入数量',
- backgroundColor: Colors.white,
- textAlign: TextAlign.end,
- rightWidget: TDText('个', textColor: TDTheme.of(context).fontGyColor1),
- );
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_loading_page.dart b/example/lib/tdesign/page/td_loading_page.dart
deleted file mode 100644
index 97f44a24c..000000000
--- a/example/lib/tdesign/page/td_loading_page.dart
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/28/22.
- * td_loading_page.dart
- *
- */
-
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDLoadingPage extends StatefulWidget {
-
- const TDLoadingPage({Key? key}):super(key: key);
-
- @override
- State createState() => _TDLoadingPageState();
-}
-
-class _TDLoadingPageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '加载 Loading',
- children: [
-
- TDText('类型', font: TDTheme.of(context).fontXL,),
- ExampleItem(desc: '纯图标', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- ),
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.activity,
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.point,
- iconColor: TDTheme.of(context).brandColor8,
- ),
- ],
- );
- }),
- ExampleItem(desc: '图标加文字横向', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中…',
- axis: Axis.horizontal,
- ),
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.activity,
- text: '加载中…',
- axis: Axis.horizontal,
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中…',
- axis: Axis.horizontal,
- textColor: TDTheme.of(context).brandHoverColor,
- ),
- ],
- );
- }),
- ExampleItem(desc: '图标加文字竖向', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中…',
- axis: Axis.vertical,
- ),
- const TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.activity,
- text: '加载中…',
- axis: Axis.vertical,
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中…',
- axis: Axis.vertical,
- textColor: TDTheme.of(context).brandHoverColor,
- ),
- ],
- );
- }),
- ExampleItem(desc: '纯文字', builder: (_){
- // TODO: 加载失败和刷新
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: const [
- TDLoading(
- size: TDLoadingSize.medium,
- text: '加载中…',
- ),
- ],
- );
- }),
-
- TDText('规格', font: TDTheme.of(context).fontXL,),
-
- ExampleItem(desc: '图标加文字横向-circle', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: const [
- TDLoading(
- size: TDLoadingSize.large,
- icon: TDLoadingIcon.circle,
- text: '加载中(大)…',
- axis: Axis.horizontal,
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中(中)…',
- axis: Axis.horizontal,
- ),
- TDLoading(
- size: TDLoadingSize.small,
- icon: TDLoadingIcon.circle,
- text: '加载中(小)…',
- axis: Axis.horizontal,
- ),
- ],
- );
- }),
- ExampleItem(desc: '图标加文字横向-activity', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- TDLoading(
- size: TDLoadingSize.large,
- icon: TDLoadingIcon.activity,
- text: '加载中(大)…',
- iconColor: TDTheme.of(context).brandColor8 ,
- axis: Axis.horizontal,
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.activity,
- text: '加载中(中)…',
- iconColor: TDTheme.of(context).brandColor8 ,
- axis: Axis.horizontal,
- ),
- TDLoading(
- size: TDLoadingSize.small,
- icon: TDLoadingIcon.activity,
- text: '加载中(小)…',
- iconColor: TDTheme.of(context).brandColor8 ,
- axis: Axis.horizontal,
- ),
- ],
- );
- }),
-
- ExampleItem(desc: '图标加文字竖向', builder: (_){
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: const [
- TDLoading(
- size: TDLoadingSize.large,
- icon: TDLoadingIcon.circle,
- text: '加载中(大)…',
- ),
- TDLoading(
- size: TDLoadingSize.medium,
- icon: TDLoadingIcon.circle,
- text: '加载中(中)…',
- ),
- TDLoading(
- size: TDLoadingSize.small,
- icon: TDLoadingIcon.circle,
- text: '加载中(小)…',
- ),
- ],
- );
- }),
- ]);
- }
-}
diff --git a/example/lib/tdesign/page/td_navbar_page.dart b/example/lib/tdesign/page/td_navbar_page.dart
deleted file mode 100644
index edf921739..000000000
--- a/example/lib/tdesign/page/td_navbar_page.dart
+++ /dev/null
@@ -1,155 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDNavBarPage extends StatelessWidget {
- const TDNavBarPage({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '导航栏 NavBar',
- children: [
- ExampleItem(
- desc: '基础导航栏',
- builder: (_) {
- return const TDNavBar(title: '标题');
- },
- ),
- ExampleItem(
- desc: '左侧双操作导航栏',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- useDefaultBack: false,
- leftBarItems: [
- TDNavBarItem(icon: TDIcons.chevron_left),
- TDNavBarItem(icon: TDIcons.close),
- ],
- rightBarItems: [TDNavBarItem(icon: TDIcons.ellipsis)],
- );
- },
- ),
- ExampleItem(
- desc: '右侧双操作导航栏',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.notification),
- TDNavBarItem(icon: TDIcons.ellipsis),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '基础小程序导航栏',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- useDefaultBack: false,
- useBorderStyle: true,
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '带返回导航栏',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- useBorderStyle: true,
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '带返回、主页按钮导航栏',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- useDefaultBack: false,
- useBorderStyle: true,
- leftBarItems: [
- TDNavBarItem(icon: TDIcons.chevron_left),
- TDNavBarItem(icon: TDIcons.home),
- ],
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '自定义品牌导航栏',
- builder: (_) {
- return TDNavBar(
- title: '品牌名称',
- useDefaultBack: false,
- useBorderStyle: true,
- centerTitle: false,
- titleFontWeight: FontWeight.w600,
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '自定义图片导航栏',
- builder: (_) {
- return TDNavBar(
- titleWidget: Container(
- width: 200,
- color: Colors.red,
- height: 20,
- ),
- useDefaultBack: false,
- useBorderStyle: true,
- centerTitle: false,
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '品牌超长文字导航栏',
- builder: (_) {
- return TDNavBar(
- title: '品牌名称最长最长最长最长最长最长最长最长最长最长最长',
- useDefaultBack: false,
- useBorderStyle: true,
- centerTitle: false,
- titleFontWeight: FontWeight.w600,
- rightBarItems: [
- TDNavBarItem(icon: TDIcons.ellipsis),
- TDNavBarItem(icon: TDIcons.add_circle),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '自定义背景色',
- builder: (_) {
- return TDNavBar(
- title: '标题',
- titleColor: Colors.white,
- backgroundColor: TDTheme.of(context).brandColor8,
- useDefaultBack: false,
- );
- },
- ),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_picker_page.dart b/example/lib/tdesign/page/td_picker_page.dart
deleted file mode 100644
index 3f1fbcc93..000000000
--- a/example/lib/tdesign/page/td_picker_page.dart
+++ /dev/null
@@ -1,237 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-
-class TDPickerPage extends StatefulWidget {
- const TDPickerPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDPickerPageState();
-}
-
-class _TDPickerPageState extends State {
- String selected_1 = '';
- List data_1 = ['广州市', '韶关市', '深圳市', '珠海区', '汕头市'];
- String selected_2 = '';
- String selected_3 = '';
- List> data_3 = [];
- String selected_4 = '';
- Map data_4 = {
- '广东省': {
- '深圳市': ['南山区', '宝安区', '罗湖区', '福田区'],
- '佛山市': [''],
- '广州市': ['花都区']
- },
- '重庆市': {
- '重庆市': ['九龙坡区', '江北区']
- },
- '浙江省': {
- '杭州市': ['西湖区', '余杭区', '萧山区'],
- '宁波市': ['江东区', '北仑区', '奉化市']
- },
- '香港': {
- '香港': ['九龙城区', '黄大仙区', '离岛区', '湾仔区']
- }
- };
-
- String selected_5 = '';
- String selected_6 = '';
- String selected_7 = '';
- String selected_8 = '';
-
- @override
- void initState() {
- var list = [];
- for(var i = 2022; i >= 2000; i--) {
- list.add('${i}年');
- }
- data_3.add(list);
- data_3.add(['春', '夏', '秋', '冬']);
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '选择器 Picker',
- children: [
- ExampleItem(
- desc: '基础选择器--城市',
- builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择城市',
- onTap: () => TDPicker.showMultiPicker(context, title: '',
- onConfirm: (selected) {
- setState(() {
- selected_1 = '城市: ${data_1[selected[0]]}';
- });
- }, data: [data_1], pickerHeight: 168, pickerItemCount: 4),
- ),
- TDText(
- selected_1,
- ),
- ]);
- }),
- ExampleItem(desc: '基础选择器--年份和季节', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择年份和季节',
- onTap: () => TDPicker.showMultiPicker(context, title: '',
- onConfirm: (selected) {
- setState(() {
- selected_3 =
- '年份和季节: ${data_3[0][selected[0]]} ${data_3[1][selected[1]]}';
- });
- }, data: data_3, initialIndexes: [1, 2]),
- ),
- TDText(
- selected_3,
- ),
- ]);
- }),
- ExampleItem(desc: '基础选择器--日期', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '',
- onConfirm: (selected) {
- setState(() {
- selected_2 = '日期: $selected';
- });
- },
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_2,
- ),
- ]);
- }),
- ExampleItem(desc: '基础选择器--地区--联动', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '选择地区',
- onTap: () => TDPicker.showMultiLinkedPicker(context, title: '',
- onConfirm: (selected) {
- setState(() {
- selected_4 = '组合: ${selected[0]} ${selected[1]} ${selected[2]}';
- });
- },
- pickerHeight: 168,
- data: data_4,
- pickerItemCount: 4,
- columnNum: 3,
- initialData: ['浙江省', '杭州市', '西湖区']),
- ),
- TDText(
- selected_4,
- ),
- ]);
- }),
- ExampleItem(
- desc: '带标题--城市',
- builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '带标题-选择城市',
- onTap: () => TDPicker.showMultiPicker(context, title: '选择城市',
- onConfirm: (selected) {
- setState(() {
- selected_5 = '城市: ${data_1[selected[0]]}';
- });
- }, data: [data_1], pickerHeight: 168, pickerItemCount: 4),
- ),
- TDText(
- selected_5,
- ),
- ]);
- }),
- ExampleItem(desc: '带标题--年份和四季', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '带标题-年份和季节',
- onTap: () => TDPicker.showMultiPicker(context, title: '选择年份和季节',
- onConfirm: (selected) {
- setState(() {
- selected_6 =
- '年份和季节: ${data_3[0][selected[0]]} ${data_3[1][selected[1]]}';
- });
- }, data: data_3, initialIndexes: [1, 2]),
- ),
- TDText(
- selected_6,
- ),
- ]);
- }),
- ExampleItem(desc: '带标题--日期', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '带标题-选择日期',
- onTap: () => TDPicker.showDatePicker(context, title: '选择日期',
- onConfirm: (selected) {
- setState(() {
- selected_7 = '日期: $selected';
- });
- },
- dateStart: [2010, 12, 20],
- dateEnd: [2022, 2, 28],
- initialDate: [2012, 1, 1]),
- ),
- TDText(
- selected_7,
- ),
- ]);
- }),
- ExampleItem(desc: '基础选择器--地区--联动', builder: (_) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDButton(
- width: 200,
- content: '带标题-选择地区',
- onTap: () => TDPicker.showMultiLinkedPicker(context, title: '选择地区',
- onConfirm: (selected) {
- setState(() {
- selected_8 = '组合: ${selected[0]} ${selected[1]} ${selected[2]}';
- });
- },
- pickerHeight: 168,
- data: data_4,
- pickerItemCount: 4,
- columnNum: 3,
- initialData: ['浙江省', '杭州市', '西湖区']),
- ),
- TDText(
- selected_8,
- ),
- ]);
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_popup_page.dart b/example/lib/tdesign/page/td_popup_page.dart
deleted file mode 100644
index 4fa4946b1..000000000
--- a/example/lib/tdesign/page/td_popup_page.dart
+++ /dev/null
@@ -1,105 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import 'package:tdesign_flutter_example/tdesign/example_base.dart';
-
-///
-/// TDPopup掩饰
-///
-class TDPopupPage extends StatefulWidget {
- const TDPopupPage({Key? key}) : super(key: key);
-
- @override
- State createState() {
- return TDPopupPageState();
- }
-}
-
-class TDPopupPageState extends State {
- @override
- void initState() {
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- Widget current = Column(
- children: [
- TDButton(
- content: '顶部Popup',
- onTap: () {
- Navigator.of(context).push(TDSlidePopupRoute(
- slideTransitionFrom: SlideTransitionFrom.top,
- builder: (context) {
- return Container(
- color: Colors.white,
- height: 300,
- );
- }));
- },
- ),
-
- const SizedBox(height: 10,),
-
- TDButton(
- content: '底部Popup',
- onTap: () {
- Navigator.of(context).push(TDSlidePopupRoute(
- slideTransitionFrom: SlideTransitionFrom.bottom,
- builder: (context) {
- return Container(
- color: Colors.white,
- height: 300,
- );
- }));
- },
- ),
-
- const SizedBox(height: 10,),
-
- TDButton(
- content: '左侧Popup',
- onTap: () {
- Navigator.of(context).push(TDSlidePopupRoute(
- slideTransitionFrom: SlideTransitionFrom.left,
- builder: (context) {
- return Container(
- color: Colors.white,
- width: 300,
- );
- }));
- },
- ),
-
-
- const SizedBox(height: 10,),
-
- TDButton(
- content: '右侧Popup',
- onTap: () {
- Navigator.of(context).push(TDSlidePopupRoute(
- slideTransitionFrom: SlideTransitionFrom.right,
- builder: (context) {
- return Container(
- color: Colors.white,
- width: 300,
- );
- }));
- },
- ),
- ],
- );
-
- current = Padding(
- padding: const EdgeInsets.all(20),
- child: current,
- );
-
- current = ExampleWidget(
- title: '弹出层 PopUp',
- children: [
- current,
- ],
- );
- return current;
- }
-}
diff --git a/example/lib/tdesign/page/td_radio_page.dart b/example/lib/tdesign/page/td_radio_page.dart
deleted file mode 100644
index ba9241004..000000000
--- a/example/lib/tdesign/page/td_radio_page.dart
+++ /dev/null
@@ -1,250 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-///
-/// TDRadio演示
-///
-class TDRadioPage extends StatefulWidget {
- const TDRadioPage({Key? key}) : super(key: key);
-
- @override
- State createState() {
- return TDRadioPageState();
- }
-}
-
-class TDRadioPageState extends State {
-
- @override
- void initState() {
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '单选框 Radio',
- children: [
- ExampleItem(desc: '基础文本框', builder: (context){
- return TDRadioGroup(
- selectId: 'index:0',
- child: ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemBuilder: (BuildContext context, int index) {
- var title = '单选';
- var subTitle = '';
- if(index == 2){
- title = '单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选';
- }
- if(index == 3){
- subTitle = '单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选';
- }
- return TDRadio(
- id: 'index:$index',
- title: title,
- titleMaxLine: 2,
- subTitleMaxLine: 2,
- subTitle: subTitle,
- );
- },
- itemCount: 4,
- ),
- );
- }),
- ExampleItem(desc: '左边勾选样式', builder: (context){
- return TDRadioGroup(
- radioStyle: TDRadioStyle.check,
- selectId: 'index:1',
- child: ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemBuilder: (BuildContext context, int index) {
- var title = '单选';
- var subTitle = '';
- if(index == 2){
- title = '单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选';
- }
- if(index == 3){
- subTitle = '单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选';
- }
- return TDRadio(
- id: 'index:$index',
- title: title,
- titleMaxLine: 2,
- subTitleMaxLine: 2,
- subTitle: subTitle,
- );
- },
- itemCount: 4,
- ),
- );
- }),
- ExampleItem(desc: '右侧勾选样式', builder: (context) {
- return TDRadioGroup(
- radioStyle: TDRadioStyle.check,
- contentDirection: TDContentDirection.left,
- selectId: 'index:0',
- child: ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemBuilder: (BuildContext context, int index) {
- return TDRadio(
- id: 'index:$index',
- title: '单选$index',
- );
- },
- itemCount: 4,
- ),
- );
- }),
- ExampleItem(desc: '右侧圆形单选框', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.left,
- selectId: 'index:0',
- child: ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemBuilder: (BuildContext context, int index) {
- return TDRadio(
- id: 'index:$index',
- title: '单选$index',
- );
- },
- itemCount: 4,
- ),
- );
- }),
- ExampleItem(desc: '自定义图标单选框', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.right,
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选',
- radioStyle: TDRadioStyle.square,
- ),
- TDRadio(
- id: '1',
- title: '单选',
- radioStyle: TDRadioStyle.square,
- ),
- ],
- ),
- );
- }),
- ExampleItem(desc: '规格', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.right,
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选 H48',
- radioStyle: TDRadioStyle.circle,
- ),
- TDRadio(
- id: '1',
- size: TDCheckBoxSize.large,
- title: '单选 H56',
- radioStyle: TDRadioStyle.circle,
- ),
- ],
- ),
- );
- }),
- ExampleItem(desc: '状态', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.right,
- selectId: '0',
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选',
- radioStyle: TDRadioStyle.circle,
- enable: false,
- ),
- TDRadio(
- id: '1',
- title: '单选',
- radioStyle: TDRadioStyle.circle,
- enable: false,
- ),
- ],
- ),
- );
- }),
- ExampleItem(desc: '状态', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.right,
- selectId: '0',
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选',
- radioStyle: TDRadioStyle.check,
- enable: false,
- ),
- TDRadio(
- id: '1',
- title: '单选',
- radioStyle: TDRadioStyle.check,
- enable: false,
- ),
- ],
- ),
- );
- }),
- ExampleItem(desc: '状态', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.left,
- selectId: '0',
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选',
- radioStyle: TDRadioStyle.circle,
- enable: false,
- ),
- TDRadio(
- id: '1',
- title: '单选',
- radioStyle: TDRadioStyle.circle,
- enable: false,
- ),
- ],
- ),
- );
- }),
- ExampleItem(desc: '状态', builder: (context){
- return TDRadioGroup(
- contentDirection: TDContentDirection.left,
- selectId: '0',
- child: Column(
- children: const [
- TDRadio(
- id: '0',
- title: '单选',
- radioStyle: TDRadioStyle.check,
- enable: false,
- ),
- TDRadio(
- id: '1',
- title: '单选',
- radioStyle: TDRadioStyle.check,
- enable: false,
- ),
- ],
- ),
- );
- }),
- ]
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_refresh_page.dart b/example/lib/tdesign/page/td_refresh_page.dart
deleted file mode 100644
index 047762736..000000000
--- a/example/lib/tdesign/page/td_refresh_page.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/28/22.
- * td_loading_page.dart
- *
- */
-
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_easyrefresh/easy_refresh.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TdPullDownRefreshPage extends StatefulWidget {
- const TdPullDownRefreshPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TdPullDownRefreshPageState();
-}
-
-class _TdPullDownRefreshPageState extends State {
- var itemCount = 10;
-
- var dataList = List.generate(10, (index) => '首页$index');
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '下拉刷新 PullDownRefresh',
- children: [
- SizedBox(
- height: 1000,
- child: Stack(
- children: [
- EasyRefresh(
- // 下拉样式
- header: TDRefreshHeader(),
- child: ListView.builder(
- itemBuilder: (context, index) => Text('${dataList[index]}'),
- itemCount: dataList.length,
- ),
- // 下拉刷新回调
- onRefresh: () async {
- await Future.delayed(const Duration(seconds: 2), () {
- dataList.addAll(
- List.generate(10, (index) => ' 下拉添加的第$index个item'));
- setState(() {});
- });
- },
- )
- ],
- ),
- )
- ]);
- }
-}
diff --git a/example/lib/tdesign/page/td_search_bar_page.dart b/example/lib/tdesign/page/td_search_bar_page.dart
deleted file mode 100644
index 8368760ca..000000000
--- a/example/lib/tdesign/page/td_search_bar_page.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDSearchBarPage extends StatefulWidget {
- const TDSearchBarPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDSearchBarPageState();
-}
-
-class _TDSearchBarPageState extends State {
- String? inputText;
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '搜索框 Search',
- children: [
- TDSearchBar(
- placeHolder: '搜索预设文案',
- onTextChanged: (String text) {
- setState(() {
- inputText = text;
- });
- },
- ),
- Row(
- children: [
- TDText(
- '输入文案:',
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).fontGyColor1,
- ),
- TDText(
- '${inputText ?? ''}',
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).fontGyColor1,
- ),
- ],
- )
- ],
- backgroundColor: TDTheme.of(context).whiteColor1,
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_swiper_page.dart b/example/lib/tdesign/page/td_swiper_page.dart
deleted file mode 100644
index 53dd78cf5..000000000
--- a/example/lib/tdesign/page/td_swiper_page.dart
+++ /dev/null
@@ -1,156 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDSwiperPage extends StatelessWidget {
- const TDSwiperPage({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '轮播图 Swiper',
- children: [
- ExampleItem(
- desc: '圆点指示器',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: true,
- pagination: const SwiperPagination(
- alignment: Alignment.bottomCenter,
- builder: TDSwiperPagination.dots),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ExampleItem(
- desc: '圆角矩形指示器(默认100ms动画)',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: true,
- pagination: const SwiperPagination(
- alignment: Alignment.bottomCenter,
- builder: TDSwiperPagination.roundedRectangle),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ExampleItem(
- desc: '数字指示器',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: true,
- pagination: const SwiperPagination(
- alignment: Alignment.bottomCenter,
- builder: TDSwiperPagination.fraction),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ExampleItem(
- desc: '数字指示器指定位置',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: true,
- pagination: const SwiperPagination(
- alignment: Alignment.topRight,
- builder: TDSwiperPagination.fraction),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ExampleItem(
- desc: '箭头指示器',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: true,
- pagination: const SwiperPagination(
- alignment: Alignment.center,
- builder: TDSwiperPagination.arrow),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ExampleItem(
- desc: '箭头指示器非循环,边界箭头隐藏',
- builder: (_) {
- return Container(
- height: 100,
- decoration: BoxDecoration(
- color: Colors.blueAccent.withOpacity(0.8),
- borderRadius: BorderRadius.circular(10)),
- child: Swiper(
- autoplay: true,
- itemCount: 6,
- loop: false,
- pagination: const SwiperPagination(
- alignment: Alignment.center,
- builder: TDSwiperPagination.arrow),
- itemBuilder: (BuildContext context, int index) {
- return FlutterLogo(
- size: MediaQuery.of(context).size.width,
- );
- },
- ),
- );
- }),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_switch_page.dart b/example/lib/tdesign/page/td_switch_page.dart
deleted file mode 100644
index 0ae89cdd3..000000000
--- a/example/lib/tdesign/page/td_switch_page.dart
+++ /dev/null
@@ -1,148 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import 'package:tdesign_flutter_example/tdesign/example_base.dart';
-
-///
-/// TdSwitchPage演示
-///
-class TDSwitchPage extends StatefulWidget {
- const TDSwitchPage({Key? key}) : super(key: key);
-
- @override
- State createState() {
- return TDSwitchPageState();
- }
-}
-
-class TDSwitchPageState extends State {
- @override
- Widget build(BuildContext context) {
- Widget current = ListView(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- children: [
- _title('基础开关'),
- Container(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- demoRow(context, '开关', on: true),
- _divider(),
- demoRow(context, '开关', on: false),
- _divider(),
- demoRow(context, '自定义颜色', on: true, onColor: Colors.green),
- _divider(),
- demoRow(context, '自定义颜色',
- on: false, onColor: Colors.green, offColor: Colors.brown),
- _divider(),
- demoRow(context, '异步操作', on: true),
- ],
- ),
- padding: const EdgeInsets.only(left: 16, right: 16),
- color: Colors.white,
- ),
- _title('带描述状态开关'),
- Container(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- demoRow(context, '开关', desc: '描述信息', on: true),
- _divider(),
- demoRow(context, '开关', desc: '描述信息', on: false),
- _divider(),
- demoRow(context, '自定义颜色',
- desc: '描述信息', on: true, onColor: Colors.green),
- ],
- ),
- padding: const EdgeInsets.only(left: 16, right: 16),
- color: Colors.white,
- ),
- _title('状态'),
- Container(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- demoRow(context, '开关开启禁用', on: true, enable: false),
- _divider(),
- demoRow(context, '开关开启禁用', on: false, enable: false),
- _divider(),
- demoRow(context, '开关开启禁用',
- on: true, onColor: Colors.green, enable: false),
- _divider(),
- demoRow(context, '开关开启禁用',
- desc: '描述信息', on: false, enable: false),
- _divider(),
- demoRow(context, '开关开启禁用', desc: '描述信息', on: true, enable: false),
- ],
- ),
- padding: const EdgeInsets.only(left: 16, right: 16),
- color: Colors.white,
- ),
- ],
- );
-
- current = Container(
- child: current,
- color: TDTheme.of(context).grayColor1,
- );
-
-
- current = ExampleWidget(
- title: '开关 Switch',
- children: [
- current
- ],
- );
- return current;
- }
-
- Widget _divider() {
- return Container(height: 0.5, color: const Color(0x33999999));
- }
-
- Widget _title(String title) {
- return Container(
- height: 40,
- padding: const EdgeInsets.only(left: 10),
- alignment: Alignment.centerLeft,
- child: Text(title),
- );
- }
-
- Widget demoRow(
- BuildContext context,
- String? title, {
- String? desc,
- bool on = true,
- bool enable = true,
- Color? onColor,
- Color? offColor,
- }) {
- final theme = TDTheme.of(context);
- Widget current = Row(
- children: [
- Expanded(
- child: TDText(
- title,
- textColor: theme.fontGyColor1,
- )),
- TDText(
- desc ?? '',
- textColor: theme.grayColor6,
- ),
- TDSwitch(
- isOn: on,
- onColor: onColor,
- enable: enable,
- offColor: offColor,
- )
- ],
- );
- current = SizedBox(
- child: current,
- height: 44,
- );
- return current;
- }
-}
diff --git a/example/lib/tdesign/page/td_tabbar_page.dart b/example/lib/tdesign/page/td_tabbar_page.dart
deleted file mode 100644
index 4b7e8310c..000000000
--- a/example/lib/tdesign/page/td_tabbar_page.dart
+++ /dev/null
@@ -1,157 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-
-class TDTabBarPage extends StatefulWidget {
- const TDTabBarPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDTabBarPageState();
-}
-
-class _TDTabBarPageState extends State
- with TickerProviderStateMixin {
- TabController? _tabController;
- TabController? _tabController1;
- TabController? _tabController2;
- TabController? _tabController3;
- TabController? _tabController4;
- TabController? _tabController5;
- List tabs = [];
- List tabViews = [];
-
- List _getTabs() {
- tabs = const [
- TDTab(text: '标签页一'),
- TDTab(text: '标签页二'),
- TDTab(text: '标签页三'),
- TDTab(text: '标签页四'),
- TDTab(text: '标签页五'),
- ];
- return tabs;
- }
-
- List _getTabViews() {
- tabViews = const [
- Center(child: TDText('内容一')),
- Center(child: TDText('内容二')),
- Center(child: TDText('内容三')),
- Center(child: TDText('内容四')),
- ];
- return tabViews;
- }
-
- @override
- void initState() {
- _initTabController();
- _getTabs();
- super.initState();
- }
-
- List subList(int length) {
- var temp = [];
- for(var i = 0; i < length; i++) {
- temp.add(tabs[i]);
- }
- return temp;
- }
-
- //初始化tab
- void _initTabController() {
- _tabController1 = TabController(length: 2, vsync: this);
- _tabController2 = TabController(length: 3, vsync: this);
- _tabController3 = TabController(length: 4, vsync: this);
- _tabController4 = TabController(length: 5, vsync: this);
- _tabController5 = TabController(length: 4, vsync: this);
- _tabController = TabController(length: 5, vsync: this);
- }
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(
- title: '选项卡 Tabs TDTabBar',
- padding: const EdgeInsets.symmetric(vertical: 16),
- children: [
- ExampleItem(
- desc: '横向选项卡',
- builder: (BuildContext context) {
- return Column(
- children: [
- TDTabBar(
- tabs: subList(2),
- controller: _tabController1,
- backgroundColor: Colors.white,
- showIndicator: true,
- ),
- TDTabBar(
- tabs: subList(3),
- controller: _tabController2,
- backgroundColor: Colors.white,
- showIndicator: true,
- ),
- TDTabBar(
- tabs: subList(4),
- controller: _tabController3,
- backgroundColor: Colors.white,
- showIndicator: true,
- ),
- TDTabBar(
- tabs: _getTabs(),
- controller: _tabController4,
- backgroundColor: Colors.white,
- showIndicator: true,
- isScrollable: true,
- ),
- ],
- );
- },
- ),
- ExampleItem(
- desc: '无下划线横向选项卡',
- builder: (BuildContext context) {
- return TDTabBar(
- tabs: _getTabs(),
- controller: _tabController,
- backgroundColor: Colors.white,
- isScrollable: true,
- );
- },
- ),
- ExampleItem(
- desc: '竖向选项卡',
- builder: (BuildContext context) {
- return LayoutBuilder(builder: (context, constraints){
-
- return SizedBox(
- width: constraints.maxWidth,
- height: 4 * 54,
- child: Row(
- children: [
- TDTabBar(
- width: 104,
- tabs: subList(4),
- controller: _tabController5,
- showIndicator: true,
- backgroundColor: Colors.white,
- isScrollable: false,
- isVertical: true
- ),
- Container(
- width: constraints.maxWidth - 104,
- color: Colors.white,
- child: TDTabBarVerticalView(
- children: _getTabViews(),
- controller: _tabController5,
- ),
- )
- ],
- ),
- );
- });
- },
- ),
- ],
- );
- }
-}
diff --git a/example/lib/tdesign/page/td_tag_page.dart b/example/lib/tdesign/page/td_tag_page.dart
deleted file mode 100644
index 9b591e1da..000000000
--- a/example/lib/tdesign/page/td_tag_page.dart
+++ /dev/null
@@ -1,229 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDTagPage extends StatelessWidget {
- const TDTagPage({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(title: '标签 Tag',
- // padding: EdgeInsets.zero,
- children: [
- ExampleItem(
- desc: '展示标签',
- builder: (context) {
- return Wrap(
- spacing: 16,
- runSpacing: 16,
- children: [
- const TDTag(
- '标签',
- ),
- const TDTag('成功',
- style: RoundRectTagStyle(type: TDTagType.success)),
- const TDTag('警告',
- style: RoundRectTagStyle(type: TDTagType.warning)),
- const TDTag('危险',
- style: RoundRectTagStyle(type: TDTagType.error)),
- const TDTag('信息',
- style: RoundRectTagStyle(type: TDTagType.message)),
- const TDTag('浅色', style: RoundRectTagStyle(isLight: true)),
- const TDTag('描边', style: WireframeRoundRectTagStyle()),
- const TDTag('浅色描边',
- style: WireframeRoundRectTagStyle(isLight: true)),
- const TDTag(
- 'English',
- ),
- const TDTag('English',
- style: WireframeRoundRectTagStyle(isLight: true)),
- const TDTag(
- 'ABC',
- ),
- const TDTag('ABC',
- style: WireframeRoundRectTagStyle(isLight: true)),
- const TDTag(
- '中English混合',
- ),
- const TDTag('中English混合',
- style: WireframeRoundRectTagStyle(isLight: true)),
- TDTag(
- '圆角',
- style: CircleRectTagStyle(),
- ),
- TDTag(
- '半圆',
- style: SemicircleRectTagStyle(),
- ),
- TDTag(
- '标签',
- needCloseIcon: true,
- onCloseTap: () {
- TDToast.showText('点击了关闭图标', context: context);
- },
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '点击控件',
- builder: (context) {
- return Wrap(
- spacing: 16,
- runSpacing: 16,
- children: [
- TDSelectTag(
- '标签',
- isSelected: true,
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- ),
- TDSelectTag(
- '标签',
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- ),
- TDSelectTag(
- '标签',
- style: CircleRectTagStyle(),
- unSelectStyle: CircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor1,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- ),
- TDSelectTag(
- '标签',
- style: SemicircleRectTagStyle(),
- unSelectStyle: SemicircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor1,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- ),
- TDSelectTag(
- '标签',
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- enableSelect: false,
- ),
- TDSelectTag(
- '标签',
- style: CircleRectTagStyle(),
- unSelectStyle: CircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor1,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- unEnableSelectStyle: CircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor4,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- enableSelect: false,
- ),
-
- TDSelectTag(
- '标签',
- onSelectChanged: (isSelect) {
- TDToast.showText('标签选中:$isSelect', context: context);
- },
- needCloseIcon: true,
- onCloseTap: (){
- TDToast.showText('点击关闭标签', context: context);
- },
- ),
- TDSelectTag(
- '标签',
- style: CircleRectTagStyle(),
- unSelectStyle: CircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor1,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- unEnableSelectStyle: CircleRectTagStyle(
- textColor: TDTheme.of(context).fontGyColor4,
- backgroundColor: TDTheme.of(context).grayColor3,
- ),
- needCloseIcon: true,
- onCloseTap: (){
- TDToast.showText('点击关闭标签', context: context);
- },
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '尺寸规格-大,正常,小',
- builder: (context) {
- return Wrap(
- spacing: 16,
- runSpacing: 16,
- children: const [
- TDTag(
- '标签',
- size: TDTagSize.large,
- ),
- TDTag('标签', size: TDTagSize.middle),
- TDTag(
- '标签',
- size: TDTagSize.small,
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '圆角尺寸规格-大,正常,小',
- builder: (context) {
- return Wrap(
- spacing: 16,
- runSpacing: 16,
- children: [
- TDTag(
- '圆角',
- style: CircleRectTagStyle(),
- size: TDTagSize.large,
- ),
- TDTag(
- '圆角',
- style: CircleRectTagStyle(),
- ),
- TDTag(
- '圆角',
- style: CircleRectTagStyle(),
- size: TDTagSize.small,
- ),
- ],
- );
- }),
- ExampleItem(
- desc: '半圆尺寸规格-大,正常,小',
- builder: (context) {
- return Wrap(
- spacing: 16,
- runSpacing: 16,
- children: [
- TDTag(
- '半圆',
- style: SemicircleRectTagStyle(),
- size: TDTagSize.large,
- ),
- TDTag(
- '半圆',
- style: SemicircleRectTagStyle(),
- ),
- TDTag(
- '半圆',
- style: SemicircleRectTagStyle(),
- size: TDTagSize.small,
- ),
- ],
- );
- }),
- ]);
- }
-}
diff --git a/example/lib/tdesign/page/td_text_page.dart b/example/lib/tdesign/page/td_text_page.dart
deleted file mode 100644
index b0d1fd80a..000000000
--- a/example/lib/tdesign/page/td_text_page.dart
+++ /dev/null
@@ -1,154 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../example_base.dart';
-
-class TDTextPage extends StatelessWidget {
- const TDTextPage({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- var exampleTxt = '文本Text';
- // debugPaintBaselinesEnabled = true;
- return ExampleWidget(
- padding: const EdgeInsets.all(8),
- title: 'TDText',
- children: [
- ExampleItem(
- desc: '系统Text:',
- builder: (_) {
- return Text(
- exampleTxt,
- );
- }),
- ExampleItem(
- desc: '普通TDText:',
- builder: (_) {
- return TDText(
- exampleTxt,
- );
- }),
- ExampleItem(
- desc: '指定常用属性:',
- builder: (_) {
- return TDText(
- exampleTxt,
- font: TDTheme.of(context).fontXL,
- textColor: TDTheme.of(context).brandNormalColor,
- backgroundColor: TDTheme.of(context).successHoverColor,
- );
- }),
- ExampleItem(
- desc: 'style覆盖textColor,不覆盖font:',
- builder: (_) {
- return TDText(
- exampleTxt,
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).brandNormalColor,
- style:
- TextStyle(color: TDTheme.of(context).errorNormalColor),
- );
- }),
- ExampleItem(
- desc: 'style覆盖textColor和font:',
- builder: (_) {
- return TDText(
- exampleTxt,
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).brandNormalColor,
- );
- }),
- ExampleItem(
- desc: 'TDText.rich测试:',
- builder: (_) {
- return TDText.rich(
- TextSpan(children: [
- TDTextSpan(
- text: 'TDTextSpan1',
- font: TDTheme.of(context).fontL,
- textColor: TDTheme.of(context).warningNormalColor,
- isTextThrough: true,
- lineThroughColor: TDTheme.of(context).brandNormalColor,
- style: TextStyle(
- color: TDTheme.of(context).errorNormalColor)),
- TextSpan(
- text: 'TextSpan2',
- style: TextStyle(
- fontSize: 14,
- color: TDTheme.of(context).brandNormalColor)),
- const WidgetSpan(
- child: Icon(TDIcons.setting, size: 24,)
- ),
- ]),
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).brandNormalColor,
- style: TextStyle(
- color: TDTheme.of(context).errorNormalColor, fontSize: 32),
- );
- }),
- ExampleItem(
- desc: '获取系统Text:',
- builder: (_) {
- return TDText(
- exampleTxt,
- backgroundColor: TDTheme.of(context).successHoverColor,
- ).getRawText(context: context);
- }),
- ExampleItem(
- desc: '中文居中:(带有英文可能不居中)',
- builder: (_) {
- return const TDText(
- '中华人民共和国腾讯科技',
- // font: Font(size: 100, lineHeight: 100),
- forceVerticalCenter: true,
- backgroundColor: Colors.orange,
- );
- }),
- ExampleItem(
- desc: '自定义内部padding:',
- builder: (_) {
- return TDTextConfiguration(
- paddingConfig: CustomTextPaddingConfig(),
- child: const CustomPaddingText(),
- );
- }),
- ],
- );
- }
-}
-
-/// 自定义控件,内部的context可拿到外部TDTextConfiguration的配置信息
-class CustomPaddingText extends StatelessWidget {
- const CustomPaddingText({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const TDText(
- '中华人民共和国腾讯科技fgjpqy',
- // font: Font(size: 100, lineHeight: 100),
- forceVerticalCenter: true,
- backgroundColor: Colors.orange,
- ),
- TDText(
- 'English',
- font: TDTheme.of(context).fontXL,
- forceVerticalCenter: true,
- backgroundColor: Colors.orange,
- ),
- ],
- );
- }
-}
-
-/// 重写内部padding方法
-class CustomTextPaddingConfig extends TDTextPaddingConfig {
- @override
- EdgeInsetsGeometry getPadding(String data, double fontSize, double height) {
- var supperPadding = super.getPadding(data, fontSize, height);
- return EdgeInsets.only(left: 30, top: supperPadding.vertical.toDouble());
- }
-}
-
diff --git a/example/lib/tdesign/page/td_theme_page.dart b/example/lib/tdesign/page/td_theme_page.dart
deleted file mode 100644
index 532865de9..000000000
--- a/example/lib/tdesign/page/td_theme_page.dart
+++ /dev/null
@@ -1,122 +0,0 @@
-import 'package:flutter/material.dart';
-
-/// 组件库相关的,只需要引入这个文件,里面暴露td前缀所有需要的类
-import 'package:tdesign_flutter/td_export.dart';
-import 'package:tdesign_flutter_example/tdesign/example_base.dart';
-
-/// 主题示例页
-
-class TDThemePage extends StatefulWidget {
- const TDThemePage({Key? key}) : super(key: key);
-
- @override
- _TDThemePageState createState() => _TDThemePageState();
-}
-
-class _TDThemePageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(title: '主题示例', children: [
- Container(
- color: Colors.white,
- alignment: Alignment.center,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- /// 使用示例
- TDText(
- '使用外层待赋值主题',
- font:
- TDTheme.of(context).fontM, // 业务方使用时,如果明确跟随全局主题,可以不传context
- textColor:
- TDTheme.of(context).brandNormalColor, // 点击颜色可查看具体设置和显示效果
- ),
-
- /// 使用示例
- TDText(
- '使用外层不赋值主题',
- font:
- TDTheme.of(context).fontL, // 业务方使用时,如果明确跟随全局主题,可以不传context
- textColor:
- TDTheme.of(context).successNormalColor, // 点击颜色可查看具体设置和显示效果
- ),
-
- /// 此处替换主题
- TDTheme(
- // 替换fonts和colors,其他主题从父类拷贝
- data: TDTheme.of(context).copyWith('custom', fontMap: {
- 'fontM': Font(size: 40, lineHeight: 80),
- }, colorMap: {
- 'brandNormalColor': Colors.red
- }),
- // 不能直接在此处使用contxt,这里虽然被包裹在TGTheme中,但是context未更新,因此阿不到最新数据
- child: const TestWidget()),
- ],
- ))
- ]);
- }
-}
-
-/// 测试控件
-class TestWidget extends StatelessWidget {
- const TestWidget({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return Container(
- alignment: Alignment.center,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- TDText(
- '使用内层赋值主题',
- font: TDTheme.of(context).fontM, //明确使用内层主题,必须传context
- textColor:
- TDTheme.of(context).brandNormalColor, // 明确使用内层主题,必须传context
- ),
- TDText(
- '使用内层不赋值主题',
- font: TDTheme.of(context).fontL, //明确使用内层主题,必须传context
- textColor:
- TDTheme.of(context).successNormalColor, // 明确使用内层主题,必须传context
- ),
- TDText(
- '使用默认主题',
- font: TDTheme.defaultData().fontM, //不传context,使用默认主题,此处是外层的主题
- textColor: TDTheme.defaultData().brandNormalColor,
- ),
- ],
- ),
- );
- }
-}
-
-/// 扩展主题属性示例
-extension TGLayouts on TDThemeData {
- /// 因为扩展中不能声明字段,只能借助TDExtraThemeData
- double get layout1 => ofExtra()?.layouts['layout1'] ?? 0;
-
- Data2? get data2 => ofExtra()?.data2;
-}
-
-class LayoutExtra extends TDExtraThemeData {
- Map layouts = {};
- Data2? data2;
-
- @override
- void parse(String name, Map curThemeMap) {
- // TODO: implement parse
- }
-}
-
-/// 二级扩展测试
-class Data2 {}
-
-extension Data2Ext on Data2 {
- String get test => 'test';
-}
-
-void test() {
- TDTheme.of(null).layout1;
- TDTheme.of(null).data2!.test;
-}
diff --git a/example/lib/tdesign/page/td_toast_page.dart b/example/lib/tdesign/page/td_toast_page.dart
deleted file mode 100644
index 15d0a6c55..000000000
--- a/example/lib/tdesign/page/td_toast_page.dart
+++ /dev/null
@@ -1,77 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:tdesign_flutter/td_export.dart';
-import '../example_base.dart';
-
-class TDToastPage extends StatefulWidget {
- const TDToastPage({Key? key}) : super(key: key);
-
- @override
- State createState() => _TDToastPageState();
-}
-
-class _TDToastPageState extends State {
- @override
- Widget build(BuildContext context) {
- return ExampleWidget(title: '轻提示 Toast', children: [
- ElevatedButton(
- onPressed: () {
- TDToast.showText('我是Toast', context: context);
- },
- child: const Text('普通toast')),
- ElevatedButton(
- onPressed: () {
- TDToast.showIconText('带图标横向',
- icon: TDIcons.check_circle, context: context);
- },
- child: const Text('带图标横向')),
- ElevatedButton(
- onPressed: () {
- TDToast.showIconText('带图标竖向',
- icon: TDIcons.check_circle,
- direction: IconTextDirection.vertical,
- context: context);
- },
- child: const Text('带图标竖向')),
- ElevatedButton(
- onPressed: () {
- TDToast.showSuccess('成功文案',
- direction: IconTextDirection.vertical, context: context);
- },
- child: const Text('成功文案')),
- ElevatedButton(
- onPressed: () {
- TDToast.showWarning('警告文案',
- direction: IconTextDirection.horizontal, context: context);
- },
- child: const Text('警告文案')),
- ElevatedButton(
- onPressed: () {
- TDToast.showLoading(context: context);
- },
- child: const Text('加载中...')),
- const ElevatedButton(
- onPressed: TDToast.dismissLoading, child: Text('停止loading')),
- ElevatedButton(
- onPressed: () {
- var sb = StringBuffer('我是');
- for (var i = 0; i < 20; i++) {
- sb.write('很长$i');
- }
- sb.write('toast');
- TDToast.showText(sb.toString(), context: context);
- },
- child: const Text('超长toast')),
- ElevatedButton(
- onPressed: () {
- var sb = StringBuffer('我是');
- for (var i = 0; i < 20; i++) {
- sb.write('很长$i');
- }
- sb.write('toast');
- TDToast.showText(sb.toString(),
- context: context, duration: const Duration(seconds: 10));
- },
- child: const Text('10秒再消失toast')),
- ]);
- }
-}
diff --git a/example/lib/web/code_widget.dart b/example/lib/web/code_widget.dart
deleted file mode 100644
index ebd33a4d8..000000000
--- a/example/lib/web/code_widget.dart
+++ /dev/null
@@ -1,111 +0,0 @@
-import 'dart:io';
-
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_markdown/flutter_markdown.dart';
-import 'package:http/http.dart' as http;
-import 'package:markdown/markdown.dart' as md;
-import 'package:tdesign_flutter/td_export.dart';
-
-import 'syntax_highlighter.dart';
-
-class CodeWidget extends StatefulWidget {
- const CodeWidget({Key? key, this.codePath}) : super(key: key);
-
- final String? codePath;
-
- @override
- State createState() => _CodeWidgetState();
-}
-
-class _CodeWidgetState extends State {
- String? result;
- String? lastApiName;
-
- @override
- void initState() {
- super.initState();
- getCodeData();
- }
-
- Future getCodeData() async {
- const defaultResult = '加载失败';
- if (widget.codePath == lastApiName &&
- result != null &&
- result != defaultResult) {
- return result!;
- }
- try {
- var url =
- 'https://raw.githubusercontent.com/TDesignOteam/tdesign-flutter/main/example/lib/tdesign/page/td_${widget.codePath}_page.dart';
-
- print('getCodeData url:$url');
- var resp = await http.get(Uri.parse(url));
- result = String.fromCharCodes(resp.body.codeUnits);
- lastApiName = widget.codePath;
- } catch (e) {
- print('getCodeData error: $e');
- }
- return result ?? defaultResult;
- }
-
- @override
- Widget build(BuildContext context) {
- return Container(
- alignment: Alignment.topLeft,
- child: FutureBuilder(
- future: getCodeData(),
- builder: (context, AsyncSnapshot snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- return Column(
- children: [
- Container(
- height: 36,
- color: TDTheme.of(context).brandColor1,
- child: Row(
- children: [
- GestureDetector(
- child: const Icon(TDIcons.file_copy),
- onTap: () {
- if (result != null) {
- Clipboard.setData(ClipboardData(text: result!));
- TDToast.showText('复制成功', context: context);
- } else {
- TDToast.showText('复制失败', context: context);
- }
- },
- ),
- ],
- ),
- ),
- Expanded(
- child: Markdown(
- padding: EdgeInsets.zero,
- selectable: true,
- shrinkWrap: true,
- syntaxHighlighter: DartSyntaxHighlighter(),
- data: '''
-```dart
-${snapshot.data}
-```
- ''',
- extensionSet: md.ExtensionSet(
- md.ExtensionSet.gitHubWeb.blockSyntaxes,
- [
- md.EmojiSyntax(),
- ...md.ExtensionSet.gitHubWeb.inlineSyntaxes
- ],
- ),
- ))
- ],
- );
- } else {
- return Container(
- alignment: Alignment.topLeft,
- child: const TDText('加载中…'),
- );
- }
- },
- ));
- }
-}
diff --git a/example/lib/web/web.dart b/example/lib/web/web.dart
deleted file mode 100644
index bcddc323b..000000000
--- a/example/lib/web/web.dart
+++ /dev/null
@@ -1,311 +0,0 @@
-import 'dart:html' if(dart.library.io) 'web_replace.dart' as html;
-import 'dart:ui' as ui;
-
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:tdesign_flutter/td_export.dart';
-
-import '../main.dart';
-import '../tdesign/api_widget.dart';
-import '../tdesign/example_base.dart';
-import 'code_widget.dart';
-
-class WebMainBody extends StatefulWidget {
- const WebMainBody({Key? key}) : super(key: key);
-
-
- @override
- State createState() => _WebMainBodyState();
-}
-
-class _WebMainBodyState extends State {
- static const menuWidth = 260.0;
-
- var screenSizeList = [
- const Size(520, 1080),
- const Size(480, 720),
- ];
-
- String version = 'unknown';
- String? apiPath = 'text';
- String? codePath = 'text';
- String? mobilePath;
-
-
- @override
- void initState() {
- super.initState();
- WebApiController._state = this;
- _getVersion();
- }
-
- Future _getVersion() async {
- version = await rootBundle.loadString('assets/version');
- setState(() {});
- }
-
- @override
- void dispose() {
- WebApiController._state = null;
- super.dispose();
- }
-
- void setApiPath({required String? apiPath,required String? mobilePath,String? codePath}){
- Future.delayed(const Duration(milliseconds: 500,), (){
- setState(() {
- this.apiPath = apiPath;
- this.mobilePath = mobilePath;
- this.codePath = codePath;
- });
- });
- }
-
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- Expanded(child: Container(
- color: TDTheme.of().grayColor2,
- child: Stack(
- children: [
-
- // 菜单放到最上方,防止被屏幕外内容遮挡
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- width: menuWidth,
- color: TDTheme.of(context).brandColor1,
- child: _buildMenu(),
- ),
- Expanded(child: Container(
- color: TDTheme.of(context).whiteColor1,
- alignment: Alignment.topLeft,
- padding: const EdgeInsets.only(left: 32,top: 32),
- child: DetailLayout(apiPath: apiPath, codePath: codePath,),
- )),
-
- Container(
- margin: const EdgeInsets.only(left:32, top: 32,right: 32),
- child: MobileWidget(page: mobilePath ?? 'TDTextPage',),
- )
- ],
- ),
-
- ],
- ),
- )),
-
- // 通底
- Container(
- height: 50,
- color: TDTheme.of(context).brandColor2,
- alignment: Alignment.center,
- child: TDText('版本号:$version', textColor: TDTheme.of(context).fontGyColor1,),
- )
- ],
- );
- }
-
-
- Widget _buildMenu(){
- return Column(
- children: [
- Container(
- height: 75,
- alignment: Alignment.centerLeft,
- padding: const EdgeInsets.only(left: 16),
- color: TDTheme.of(context).brandHoverColor,
- child: TDText('TDesign 组件', textColor: TDTheme.of(context).whiteColor1,font: TDTheme.of(context).fontXL,),
- ) ,
- Expanded(child: ListView.builder(
- itemCount: examplePageList.length,
- shrinkWrap: true,
- itemBuilder: (context, index) {
- var model = examplePageList[index];
- return Container(
- padding: const EdgeInsets.only(
- left: 16, right: 16, top: 8, bottom: 8),
- alignment: Alignment.topLeft,
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: TDTheme
- .of(context)
- .grayColor4, width: 0.5))),
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: () {
- WebApiController.setApiPath(apiPath: model.apiPath,mobilePath: model.path, codePath: model.codePath ?? model.apiPath, );
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- TDText(model.text),
- Icon(TDIcons.chevron_right, color: TDTheme
- .of(context)
- .brandHoverColor,)
- ],
- )),
- );
- }))
-
- ],
- );
- }
-
-}
-
-class WebHome extends StatelessWidget {
- const WebHome({Key? key}) : super(key: key);
-
- static NavigatorState? navigator;
-
- @override
- Widget build(BuildContext context) {
- navigator = Navigator.of(context);
- return Container(
- color: TDTheme.of(context).whiteColor1,
- alignment: Alignment.center,
- child: const TDText('Hello World'),
- );
- }
-}
-
-class DetailLayout extends StatefulWidget {
- const DetailLayout({Key? key, required this.apiPath, this.codePath}) : super(key: key);
-
- final String? apiPath;
- final String? codePath;
-
- @override
- State createState() => _DetailLayoutState();
-}
-
-class _DetailLayoutState extends State with TickerProviderStateMixin {
-
-
- TabController? _tabController;
-
- @override
- void initState() {
- super.initState();
- _tabController = TabController(length: 2, vsync: this);
- }
-
- @override
- Widget build(BuildContext context) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TDTabBar(
- tabs: _getTabs(),
- controller: _tabController,
- backgroundColor: Colors.white,
- showIndicator: true,
- isScrollable: true,
- ),
- Expanded(child: TDTabBarView(
- children: _getTabViews(),
- controller: _tabController,
- ))
- ],
- );
- }
-
- List _getTabs() {
- var tabs = const [
- TDTab(text: 'Api'),
- TDTab(text: 'Code'),
- ];
- return tabs;
- }
-
- List _getTabViews() {
- var tabViews = [
- ApiWidget(apiName: widget.apiPath,visible: true,),
- CodeWidget(codePath: widget.codePath,),
- ];
- return tabViews;
- }
-}
-
-class MobileWidget extends StatefulWidget {
- const MobileWidget({Key? key,required this.page}) : super(key: key);
-
- final String page;
-
- @override
- State createState() => _MobileWidgetState();
-}
-
-class _MobileWidgetState extends State {
-
- double screenWidth = 520;
- double screenHeight = 1080;
- String? lastPage;
-
- Widget? lastWidget;
-
- @override
- void initState() {
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return getWebView();
- }
-
- Widget getWebView() {
- if(widget.page == lastPage && lastWidget != null){
- return lastWidget!;
- }
- lastPage = widget.page;
- var _iframeElement = html.IFrameElement();
- // ignore: unsafe_html
- _iframeElement.src = _getSrc();
- _iframeElement.style.border = 'none';
- var id = 'iframeElement$lastPage';
-// ignore: undefined_prefixed_name
- ui.platformViewRegistry.registerViewFactory(
- id,
- (int viewId) => _iframeElement,
- );
- Widget _iframeWidget;
- _iframeWidget = HtmlElementView(
- key: UniqueKey(),
- viewType: id,
- );
-
-
- lastWidget = SizedBox(
- width: screenWidth,
- height: screenHeight,
- child: Stack(
- children: [
- IgnorePointer(
- ignoring: true,
- child: Center(
- child: _iframeWidget,
- ),
- ),
- ],
- ),
- );
- return lastWidget!;
- }
-
- String? _getSrc() {
- var href = html.window.location.href;
- return href.replaceFirst('#/', '#$lastPage');
- }
-}
-
-
-
-class WebApiController {
- static _WebMainBodyState? _state;
-
- static setApiPath({required String? apiPath,required String? mobilePath, String? codePath}){
- _state?.setApiPath(apiPath: apiPath, mobilePath:mobilePath, codePath: codePath);
- }
-}
\ No newline at end of file
diff --git a/example/lib/web/web_replace.dart b/example/lib/web/web_replace.dart
deleted file mode 100644
index dbbad266e..000000000
--- a/example/lib/web/web_replace.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-import 'package:flutter/material.dart';
-
-class WebMainBody extends StatelessWidget {
- const WebMainBody({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return Container();
- }
-}
diff --git a/example/pubspec.lock b/example/pubspec.lock
deleted file mode 100644
index 19bd263c1..000000000
--- a/example/pubspec.lock
+++ /dev/null
@@ -1,231 +0,0 @@
-# Generated by pub
-# See https://dart.dev/tools/pub/glossary#lockfile
-packages:
- args:
- dependency: transitive
- description:
- name: args
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.3.1"
- async:
- dependency: transitive
- description:
- name: async
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.9.0"
- boolean_selector:
- dependency: transitive
- description:
- name: boolean_selector
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.1.0"
- characters:
- dependency: transitive
- description:
- name: characters
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.2.1"
- charcode:
- dependency: transitive
- description:
- name: charcode
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.3.1"
- clock:
- dependency: transitive
- description:
- name: clock
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.1.1"
- collection:
- dependency: transitive
- description:
- name: collection
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.16.0"
- cupertino_icons:
- dependency: "direct main"
- description:
- name: cupertino_icons
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.5"
- fake_async:
- dependency: transitive
- description:
- name: fake_async
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.3.1"
- flutter:
- dependency: "direct main"
- description: flutter
- source: sdk
- version: "0.0.0"
- flutter_easyrefresh:
- dependency: transitive
- description:
- name: flutter_easyrefresh
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.2.2"
- flutter_lints:
- dependency: "direct dev"
- description:
- name: flutter_lints
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.4"
- flutter_markdown:
- dependency: "direct main"
- description:
- name: flutter_markdown
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.6.10"
- flutter_swiper_null_safety:
- dependency: "direct main"
- description:
- name: flutter_swiper_null_safety
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.2"
- flutter_test:
- dependency: "direct dev"
- description: flutter
- source: sdk
- version: "0.0.0"
- http:
- dependency: "direct main"
- description:
- name: http
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.13.5"
- http_parser:
- dependency: transitive
- description:
- name: http_parser
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "4.0.2"
- lints:
- dependency: transitive
- description:
- name: lints
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.1"
- markdown:
- dependency: transitive
- description:
- name: markdown
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "5.0.0"
- matcher:
- dependency: transitive
- description:
- name: matcher
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.12.12"
- material_color_utilities:
- dependency: transitive
- description:
- name: material_color_utilities
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.1.5"
- meta:
- dependency: transitive
- description:
- name: meta
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.8.0"
- path:
- dependency: transitive
- description:
- name: path
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.8.2"
- sky_engine:
- dependency: transitive
- description: flutter
- source: sdk
- version: "0.0.99"
- source_span:
- dependency: transitive
- description:
- name: source_span
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.9.0"
- stack_trace:
- dependency: transitive
- description:
- name: stack_trace
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.10.0"
- stream_channel:
- dependency: transitive
- description:
- name: stream_channel
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.1.0"
- string_scanner:
- dependency: transitive
- description:
- name: string_scanner
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.1.1"
- tdesign_flutter:
- dependency: "direct main"
- description:
- path: ".."
- relative: true
- source: path
- version: "0.0.1"
- term_glyph:
- dependency: transitive
- description:
- name: term_glyph
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.2.1"
- test_api:
- dependency: transitive
- description:
- name: test_api
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.4.12"
- typed_data:
- dependency: transitive
- description:
- name: typed_data
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.3.1"
- vector_math:
- dependency: transitive
- description:
- name: vector_math
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.1.2"
-sdks:
- dart: ">=2.17.0-0 <3.0.0"
- flutter: ">=1.24.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
deleted file mode 100644
index 79fd01aca..000000000
--- a/example/pubspec.yaml
+++ /dev/null
@@ -1,100 +0,0 @@
-name: tdesign_flutter_example
-description: A new Flutter application.
-
-# The following line prevents the package from being accidentally published to
-# pub.dev using `flutter pub publish`. This is preferred for private packages.
-publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-
-# The following defines the version and build number for your application.
-# A version number is three numbers separated by dots, like 1.2.43
-# followed by an optional build number separated by a +.
-# Both the version and the builder number may be overridden in flutter
-# build by specifying --build-name and --build-number, respectively.
-# In Android, build-name is used as versionName while build-number used as versionCode.
-# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
-# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
-# Read more about iOS versioning at
-# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.0.0+1
-
-environment:
- sdk: ">=2.12.0 <3.0.0"
-
-# Dependencies specify other packages that your package needs in order to work.
-# To automatically upgrade your package dependencies to the latest versions
-# consider running `flutter pub upgrade --major-versions`. Alternatively,
-# dependencies can be manually updated by changing the version numbers below to
-# the latest version available on pub.dev. To see which dependencies have newer
-# versions available, run `flutter pub outdated`.
-dependencies:
- flutter:
- sdk: flutter
-
- #轮播图组件
- flutter_swiper_null_safety: ^1.0.2
-
-
- # The following adds the Cupertino Icons font to your application.
- # Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^1.0.2
- flutter_markdown: ^0.6.1
- http: ^0.13.5
- tdesign_flutter:
- path: ../
-
-dev_dependencies:
- flutter_test:
- sdk: flutter
-
- # The "flutter_lints" package below contains a set of recommended lints to
- # encourage good coding practices. The lint set provided by the package is
- # activated in the `analysis_options.yaml` file located at the root of your
- # package. See that file for information about deactivating specific lint
- # rules and activating additional ones.
- flutter_lints: ^1.0.0
-
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter.
-flutter:
-
- # The following line ensures that the Material Icons font is
- # included with your application, so that you can use the icons in
- # the material Icons class.
- uses-material-design: true
-
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware.
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.dev/assets-and-images/#from-packages
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.dev/custom-fonts/#from-packages
-
- assets:
- - assets/api/
- - assets/version
\ No newline at end of file
diff --git a/example/shell/build_web.sh b/example/shell/build_web.sh
deleted file mode 100644
index 2bf47ef84..000000000
--- a/example/shell/build_web.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-# 构建web应用
-cd ..
-flutter build web --web-renderer html --base-href /tdesign_example/ --source-maps
\ No newline at end of file
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
deleted file mode 100644
index d2638d8d5..000000000
--- a/example/test/widget_test.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-// This is a basic Flutter widget test.
-//
-// To perform an interaction with a widget in your test, use the WidgetTester
-// utility that Flutter provides. For example, you can send tap and scroll
-// gestures. You can also use WidgetTester to find child widgets in the widget
-// tree, read text, and verify that the values of widget properties are correct.
-
-import 'package:flutter/material.dart';
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:tdesign_flutter_example/main.dart';
-
-void main() {
- testWidgets('Counter increments smoke test', (WidgetTester tester) async {
- // Build our app and trigger a frame.
- await tester.pumpWidget(const MyApp());
-
- // Verify that our counter starts at 0.
- expect(find.text('0'), findsOneWidget);
- expect(find.text('1'), findsNothing);
-
- // Tap the '+' icon and trigger a frame.
- await tester.tap(find.byIcon(Icons.add));
- await tester.pump();
-
- // Verify that our counter has incremented.
- expect(find.text('0'), findsNothing);
- expect(find.text('1'), findsOneWidget);
- });
-}
diff --git a/lib/src/components/avatar/td_avatar.dart b/lib/src/components/avatar/td_avatar.dart
deleted file mode 100644
index cdbbd1b35..000000000
--- a/lib/src/components/avatar/td_avatar.dart
+++ /dev/null
@@ -1,306 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-enum TDAvatarSize { large, medium, small }
-
-enum TDAvatarType {
- normal,
- user,
- circle,
- square,
- customText,
- display,
- operation
-}
-
-/// 用于头像显示
-class TDAvatar extends StatelessWidget {
- const TDAvatar(
- {Key? key,
- this.size = TDAvatarSize.medium,
- this.type = TDAvatarType.normal,
- this.text,
- this.avatarUrl,
- this.avatarSize,
- this.avatarDisplayList,
- this.displayText,
- this.onTap,
- this.defaultUrl = ''})
- : super(key: key);
-
- /// 头像地址
- final String? avatarUrl;
-
- /// 头像尺寸
- final TDAvatarSize size;
-
- /// 头像类型
- final TDAvatarType type;
-
- /// 自定义文字
- final String? text;
-
- /// 自定义头像大小
- final double? avatarSize;
-
- /// 默认图片
- final String defaultUrl;
-
- /// 带操作\展示的头像列表
- final List? avatarDisplayList;
-
- /// 纯展示类型末尾文字
- final String? displayText;
-
- /// 操作点击事件
- final Function()? onTap;
-
-
- double _getAvatarWidth() {
- double width;
- switch (size) {
- case TDAvatarSize.large:
- width = 64;
- break;
- case TDAvatarSize.medium:
- width = 48;
- break;
- case TDAvatarSize.small:
- width = 32;
- break;
- }
- return avatarSize ?? width;
- }
-
- Font _getTextFont() {
- Font font;
- switch (size) {
- case TDAvatarSize.large:
- font = Font(size: 16, lineHeight: 24);
- break;
- case TDAvatarSize.medium:
- font = Font(size: 14, lineHeight: 22);
- break;
- case TDAvatarSize.small:
- font = Font(size: 12, lineHeight: 20);
- break;
- }
- return font;
- }
-
- double _getIconWidth() {
- double width;
- switch (size) {
- case TDAvatarSize.large:
- width = 32;
- break;
- case TDAvatarSize.medium:
- width = 24;
- break;
- case TDAvatarSize.small:
- width = 16;
- break;
- }
- return width;
- }
-
- @override
- Widget build(BuildContext context) {
- switch (type) {
- case TDAvatarType.normal:
- return CircleAvatar(
- radius: _getAvatarWidth() / 2,
- backgroundColor: TDTheme.of(context).brandColor2,
- child: Icon(TDIcons.user,
- size: _getIconWidth(), color: TDTheme.of(context).brandColor8),
- );
- case TDAvatarType.user:
- return CircleAvatar(
- radius: _getAvatarWidth() / 2,
- backgroundColor: TDTheme.of(context).brandColor2,
- backgroundImage: avatarUrl != null
- ? NetworkImage(avatarUrl!)
- : NetworkImage(defaultUrl));
- case TDAvatarType.circle:
- return CircleAvatar(
- radius: _getAvatarWidth() / 2,
- backgroundColor: TDTheme.of(context).brandColor2,
- backgroundImage: avatarUrl != null
- ? NetworkImage(avatarUrl!)
- : NetworkImage(defaultUrl));
- case TDAvatarType.square:
- return Container(
- width: _getAvatarWidth(),
- height: _getAvatarWidth(),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- image: DecorationImage(
- image: avatarUrl != null
- ? NetworkImage(avatarUrl!)
- : NetworkImage(defaultUrl))),
- );
- case TDAvatarType.customText:
- return CircleAvatar(
- radius: _getAvatarWidth() / 2,
- backgroundColor: TDTheme.of(context).brandColor8,
- child: TDText(
- text,
- forceVerticalCenter: true,
- textAlign: TextAlign.center,
- font: _getTextFont(),
- textColor: TDTheme.of(context).whiteColor1,
- ),
- );
- case TDAvatarType.display:
- return buildDisplayAvatar(context);
- case TDAvatarType.operation:
- return buildOperationAvatar(context);
- }
- }
-
- double _getDisplayPadding() {
- double padding;
- switch (size) {
- case TDAvatarSize.large:
- padding = 10;
- break;
- case TDAvatarSize.medium:
- padding = 8;
- break;
- case TDAvatarSize.small:
- padding = 6;
- break;
- }
- return padding;
- }
-
- Widget buildOperationAvatar(BuildContext context) {
- var list = [];
- if(avatarDisplayList == null || avatarDisplayList!.isEmpty) {
- return Container();
- }
-
- for(var i = 0; i < avatarDisplayList!.length + 1; i ++) {
- var left = (_getAvatarWidth() - _getDisplayPadding()) * i;
- if(i == avatarDisplayList!.length) {
- list.add(
- Positioned(
- left: left,
- child:
- GestureDetector(
- onTap: () {
- if(onTap != null) {
- onTap!();
- }
- },
- child: Container(
- child: Center(
- child: Icon(TDIcons.user_add,
- size: _getIconWidth(), color: TDTheme.of(context).brandColor8),
- ),
- width: _getAvatarWidth(),
- height: _getAvatarWidth(),
- clipBehavior: Clip.hardEdge,
- decoration: BoxDecoration(
- color: TDTheme.of(context).brandColor2,
- borderRadius: BorderRadius.circular(_getAvatarWidth() - _getDisplayPadding()),
- border: Border.all(color: Colors.white, width: _getDisplayPadding() / 2)
- )
- ),
- )
- )
- );
- } else {
- list.add(
- Positioned(
- left: left,
- child: Container(
- width: _getAvatarWidth(),
- height: _getAvatarWidth(),
- clipBehavior: Clip.antiAlias,
- decoration: ShapeDecoration(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(_getAvatarWidth() - _getDisplayPadding()),
- side: BorderSide(color: Colors.white, width: _getDisplayPadding() / 2)
- ),
- image: DecorationImage(image: NetworkImage(avatarDisplayList![i]), fit: BoxFit.cover)
- )
- )
- )
- );
- }
- }
- return SizedBox(
- height: _getAvatarWidth(),
- width: _getAvatarWidth() * ((avatarDisplayList?.length ?? 0) + 1)
- - (avatarDisplayList?.length ?? 0) * _getDisplayPadding(),
- child: Stack(
- children: list
- ),
- );
- }
-
- Widget buildDisplayAvatar(BuildContext context) {
- var list = [];
- if(avatarDisplayList == null || avatarDisplayList!.isEmpty) {
- return Container();
- }
-
- for(var i = avatarDisplayList!.length; i >= 0; i --) {
- var left = (_getAvatarWidth() - _getDisplayPadding()) * i;
- if(i == avatarDisplayList!.length) {
- list.add(
- Positioned(
- left: left,
- child:
- Container(
- child: Center(
- child: TDText(
- displayText,
- forceVerticalCenter: true,
- textAlign: TextAlign.center,
- font: _getTextFont(),
- textColor: TDTheme.of(context).brandColor8,
- ),
- ),
- width: _getAvatarWidth(),
- height: _getAvatarWidth(),
- clipBehavior: Clip.hardEdge,
- decoration: BoxDecoration(
- color: TDTheme.of(context).brandColor2,
- borderRadius: BorderRadius.circular(_getAvatarWidth() - _getDisplayPadding()),
- border: Border.all(color: Colors.white, width: _getDisplayPadding() / 2)
- )
- )
- )
- );
- } else {
- list.add(
- Positioned(
- left: left,
- child: Container(
- width: _getAvatarWidth(),
- height: _getAvatarWidth(),
- clipBehavior: Clip.antiAlias,
- decoration: ShapeDecoration(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(_getAvatarWidth() - _getDisplayPadding()),
- side: BorderSide(color: Colors.white, width: _getDisplayPadding() / 2)
- ),
- image: DecorationImage(image: NetworkImage(avatarDisplayList![i]), fit: BoxFit.cover)
- )
- )
- )
- );
- }
- }
- return SizedBox(
- height: _getAvatarWidth(),
- width: _getAvatarWidth() * ((avatarDisplayList?.length ?? 0) + 1)
- - (avatarDisplayList?.length ?? 0) * _getDisplayPadding(),
- child: Stack(
- children: list
- ),
- );
- }
-}
diff --git a/lib/src/components/badge/td_badge.dart b/lib/src/components/badge/td_badge.dart
deleted file mode 100644
index a684b6ca4..000000000
--- a/lib/src/components/badge/td_badge.dart
+++ /dev/null
@@ -1,182 +0,0 @@
-import 'dart:math';
-
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-
-enum TDBadgeType {
- /// 红点样式
- redPoint,
-
- /// 提醒样式
- remind,
-
- /// 消息样式
- message,
-
- /// 角标样式
- subscript
-}
-
-enum TDBadgeBorder {
- /// 大圆角 8px
- large,
-
- /// 小圆角 4px
- small
-}
-
-class TDBadge extends StatefulWidget {
-
- const TDBadge(
- this.type, {
- Key? key,
- this.count,
- this.border = TDBadgeBorder.large,
- this.color,
- this.textColor,
- this.redPointSize = 10,
- this.message,
- this.widthLarge = 32,
- this.widthSmall = 12,
- this.padding
- }) : super(key: key);
-
- /// 红点数量
- final String? count;
-
- /// 红点样式
- final TDBadgeType type;
-
- /// 红点圆角大小
- final TDBadgeBorder border;
-
- /// 红点颜色
- final Color? color;
-
- /// 文字颜色
- final Color? textColor;
-
- /// 红点大小
- final double redPointSize;
-
- /// 消息内容
- final String? message;
-
- /// 角标大三角形宽
- final double widthLarge;
-
- /// 角标小三角形宽
- final double widthSmall;
-
- /// 角标自定义padding
- final EdgeInsetsGeometry? padding;
-
- @override
- State createState() => _TDBadgeState();
-}
-
-class _TDBadgeState extends State {
- String badgeNum = '';
-
- void updateBadgeNum(String? newCount) {
- if (newCount == null) {
- return;
- }
- setState(() {
- badgeNum = newCount;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- updateBadgeNum(widget.count);
- switch (widget.type) {
- case TDBadgeType.redPoint:
- return Container(
- alignment: Alignment.center,
- height: widget.redPointSize,
- width: widget.redPointSize,
- decoration: BoxDecoration(
- color: widget.color ?? TDTheme.of(context).errorColor6,
- borderRadius: BorderRadius.circular(widget.redPointSize / 2)),
- );
- case TDBadgeType.remind:
- return Container(
- alignment: Alignment.center,
- height: 16,
- width: 20,
- decoration: BoxDecoration(
- color: widget.color ?? TDTheme.of(context).errorColor6,
- borderRadius: BorderRadius.circular(8)),
- child: Icon(
- TDIcons.ellipsis,
- color: widget.textColor ?? TDTheme.of(context).whiteColor1,
- size: 12,
- ));
- case TDBadgeType.message:
- return Container(
- height: 16,
- padding: const EdgeInsets.only(left: 5, right: 5),
- decoration: BoxDecoration(
- color: widget.color ?? TDTheme.of(context).errorColor6,
- borderRadius: widget.border == TDBadgeBorder.large
- ? BorderRadius.circular(8)
- : BorderRadius.circular(4),
- ),
- child: TDText(
- widget.message ?? '$badgeNum',
- forceVerticalCenter: true,
- font: Font(size: 10, lineHeight: 16),
- fontWeight: FontWeight.w500,
- textColor: widget.textColor ?? TDTheme.of(context).whiteColor1,
- textAlign: TextAlign.center,
- ));
- case TDBadgeType.subscript:
- return ClipPath(
- clipper: TrapezoidPath(widget.widthLarge, widget.widthSmall),
- child: Container(
- alignment: Alignment.topRight,
- color: widget.color ?? TDTheme.of(context).errorColor6,
- height: 32,
- width: 32,
- child: Transform.rotate(
- angle: pi / 4,
- child: Padding(
- padding: widget.padding ?? const EdgeInsets.only(left: 4, bottom: 8),
- child: TDText(
- widget.message ?? '$badgeNum',
- font: Font(size: 10, lineHeight: 16),
- fontWeight: FontWeight.w500,
- textColor: widget.textColor ?? TDTheme.of(context).whiteColor1,
- textAlign: TextAlign.center,
- ),
- )
- ),
- ),
- );
- }
- }
-}
-
-class TrapezoidPath extends CustomClipper {
- final double widthLarge;
- final double widthSmall;
- TrapezoidPath(this.widthLarge, this.widthSmall);
- @override
- Path getClip(Size size) {
- var path = Path();
- path.moveTo(0, 0);
- path.lineTo(widthLarge - widthSmall, 0);
- path.lineTo(widthLarge, widthSmall);
- path.lineTo(widthLarge, widthLarge);
- path.lineTo(0, 0);
- return path;
- }
-
- @override
- bool shouldReclip(CustomClipper oldClipper) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/lib/src/components/bottom_nav_bar/td_bottom_nav_bar.dart b/lib/src/components/bottom_nav_bar/td_bottom_nav_bar.dart
deleted file mode 100644
index f761f3d25..000000000
--- a/lib/src/components/bottom_nav_bar/td_bottom_nav_bar.dart
+++ /dev/null
@@ -1,670 +0,0 @@
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-
-// 向下箭头宽高
-const double _kArrowWidth = 13.5;
-// 向下箭头宽高
-const double _kArrowHeight = 8;
-// 选项弹窗 单个item最低高度
-const double _kMenuItemMinHeight = 23;
-// 选项弹窗 单个item默认高度
-const double _kDefaultMenuItemHeight = 48;
-// 选项弹窗 单个item默认宽度为按钮宽度-20
-const double _kDefaultMenuItemWidthShrink = 20;
-// 底部弹窗默认高度
-const double _kDefaultNavBarHeight = 48;
-// 弹窗弹出动画时间
-const Duration _kPopupMenuDuration = Duration(milliseconds: 10);
-
-enum TDBottomNavBarType {
- /// 单层级纯文本标签栏
- text,
-
- /// 文本加图标标签栏
- iconText,
-
- /// 纯图标标签栏
- icon,
-
- /// 双层级纯文本标签栏
- expansionPanel,
-
- // 自定义布局
- customLayout,
-}
-
-class TDBottomNavBarTabConfig {
- /// 自定义未选中状态widget
- final Widget? unSelectWidget;
-
- /// 自定义选中状态widget
- final Widget? selectWidget;
-
- /// 图标
- final Widget? selectedIcon;
-
- /// 未选中图标
- final Widget? unselectedIcon;
-
- /// 选中文本
- final Text? selectedText;
-
- /// 未选中文本
- final Text? unselectedText;
-
- /// 点击事件
- final GestureTapCallback? onTap;
-
- /// 是否展示消息样式
- final bool? showBadge;
-
- /// 自定义消息样式
- final Widget? customBadgeWidget;
-
- /// 使用TDBadge消息样式
- final TDBadge? tdBadge;
-
- /// 消息顶部偏移量
- final double? badgeTopOffset;
-
- /// 消息右侧偏移量
- final double? badgeRightOffset;
-
- final TDBottomNavBarPopUpBtnConfig? popUpButtonConfig;
-
- TDBottomNavBarTabConfig({
- required this.onTap,
- this.unSelectWidget,
- this.selectWidget,
- this.selectedIcon,
- this.unselectedIcon,
- this.selectedText,
- this.unselectedText,
- this.showBadge,
- this.customBadgeWidget,
- this.tdBadge,
- this.badgeTopOffset,
- this.badgeRightOffset,
- this.popUpButtonConfig,
- }) : assert(() {
- if (showBadge != null && showBadge) {
- if (customBadgeWidget == null && tdBadge == null) {
- throw FlutterError('[NavigationTab] if set showBadge = true, '
- 'you must set customBadgeWidget or tdBadge');
- }
- }
- return true;
- }());
-}
-
-class TDBottomNavBar extends StatefulWidget {
-
- TDBottomNavBar(
- this.type, {
- Key? key,
- required this.navigationTabs,
- this.barHeight = _kDefaultNavBarHeight,
- this.useVerticalDivider,
- this.dividerHeight,
- this.dividerThickness,
- this.dividerColor,
- this.showTopBorder = true,
- this.topBorder,
- }) : assert(() {
- if (navigationTabs.isEmpty) {
- throw FlutterError(
- '[TDBottomNavigationBar] please set at least one tab!');
- }
- if (type == TDBottomNavBarType.customLayout) {
- for (final item in navigationTabs) {
- if (item.selectWidget == null || item.unSelectWidget == null) {
- throw FlutterError(
- '[TDBottomNavigationBar] customLayout request selectWidget and unSelectWidget,'
- 'but get null.');
- }
- }
- }
- if (type == TDBottomNavBarType.text) {
- for (final item in navigationTabs) {
- if (item.selectedText == null || item.unselectedText == null) {
- throw FlutterError(
- '[TDBottomNavigationBar] type is TDBottomBarType.text, but not set text.');
- }
- }
- }
- if (type == TDBottomNavBarType.icon) {
- for (final item in navigationTabs) {
- if (item.selectedIcon == null || item.unselectedIcon == null) {
- throw FlutterError(
- '[TDBottomNavigationBar] type is TDBottomBarType.icon,'
- 'but not set icon.');
- }
- }
- }
- if (type == TDBottomNavBarType.iconText) {
- for (final item in navigationTabs) {
- if (item.selectedIcon == null ||
- item.unselectedIcon == null ||
- item.selectedText == null ||
- item.unselectedText == null) {
- throw FlutterError(
- '[TDBottomNavigationBar] type is TDBottomBarType.iconText,'
- 'but not set icon or text.');
- }
- }
- }
- return true;
- }()),
- super(key: key);
-
- final TDBottomNavBarType type;
-
- /// tab
- final List navigationTabs;
-
- /// tab高度
- final double? barHeight;
-
- /// 是否使用竖线分隔
- final bool? useVerticalDivider;
-
- /// 分割线高度(可选)
- final double? dividerHeight;
-
- /// 分割线厚度(可选)
- final double? dividerThickness;
-
- /// 分割线颜色(可选)
- final Color? dividerColor;
-
- /// 是否展示bar上边线(设置为true 但是topBorder样式未设置,则使用默认值)
- final bool? showTopBorder;
-
- /// 上边线样式
- final BorderSide? topBorder;
-
- @override
- State createState() => _TDBottomNavBarState();
-}
-
-class _TDBottomNavBarState extends State {
- int selectedIndex = 0;
-
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(
- builder: (BuildContext context, BoxConstraints constraints) {
- var maxWidth =
- double.parse(constraints.biggest.width.toStringAsFixed(1));
- var itemWidth = maxWidth / widget.navigationTabs.length;
- return Container(
- decoration: widget.showTopBorder!
- ? BoxDecoration(
- border: Border(
- top: widget.topBorder ??
- BorderSide(
- width: 0.5,
- color: TDTheme.of(context).grayColor3)))
- : null,
- child: Stack(alignment: Alignment.center, children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children:
- List.generate(widget.navigationTabs.length, (index) {
- return _item(index, itemWidth);
- })),
- _verticalDivider(),
- ]));
- },
- );
- }
-
- void _onTap(int index) {
- setState(() {
- if (selectedIndex != index) {
- selectedIndex = index;
- widget.navigationTabs[index].onTap?.call();
- }
- });
- }
-
- Widget _item(int index, double itemWidth) {
- return Container(
- height: widget.barHeight ?? _kDefaultNavBarHeight,
- width: itemWidth,
- alignment: Alignment.center,
- child: TDBottomNavBarItemWithBadge(
- item: _constructItem(index),
- itemHeight: widget.barHeight ?? _kDefaultNavBarHeight,
- itemWidth: itemWidth,
- onTap: () {
- _onTap(index);
- },
- showBage: widget.navigationTabs[index].showBadge ?? false,
- badge: _badge(index),
- rightOffset: widget.navigationTabs[index].badgeRightOffset,
- topOffset: widget.navigationTabs[index].badgeTopOffset,
- popUpButtonConfig: widget.navigationTabs[index].popUpButtonConfig,
- ));
- }
-
- Widget _constructItem(int index) {
- if (widget.type == TDBottomNavBarType.customLayout) {
- return index == selectedIndex
- ? widget.navigationTabs[index].selectWidget!
- : widget.navigationTabs[index].unSelectWidget!;
- }
- if (widget.type == TDBottomNavBarType.text) {
- return index == selectedIndex
- ? widget.navigationTabs[index].selectedText!
- : widget.navigationTabs[index].unselectedText!;
- }
- if (widget.type == TDBottomNavBarType.icon) {
- return index == selectedIndex
- ? widget.navigationTabs[index].selectedIcon!
- : widget.navigationTabs[index].unselectedIcon!;
- }
-
- if (widget.type == TDBottomNavBarType.iconText) {
- return index == selectedIndex
- ? Column(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- widget.navigationTabs[index].selectedIcon!,
- widget.navigationTabs[index].selectedText!
- ],
- )
- : Column(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- widget.navigationTabs[index].unselectedIcon!,
- widget.navigationTabs[index].unselectedText!
- ],
- );
- }
- return Container();
- }
-
- Widget _badge(int index) {
- if (widget.navigationTabs[index].showBadge ?? false) {
- if (widget.navigationTabs[index].tdBadge != null) {
- return widget.navigationTabs[index].tdBadge!;
- } else if (widget.navigationTabs[index].customBadgeWidget != null) {
- return widget.navigationTabs[index].customBadgeWidget!;
- }
- }
- return Container();
- }
-
- Widget _verticalDivider() {
- return Visibility(
- visible: widget.useVerticalDivider ?? false,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: List.generate(widget.navigationTabs.length - 1, (index) {
- return SizedBox(
- width: widget.dividerThickness ?? 0.5,
- height: widget.dividerHeight ?? 32,
- child: VerticalDivider(
- color: widget.dividerColor ?? TDTheme.of(context).grayColor3,
- thickness: widget.dividerThickness ?? 0.5,
- ),
- );
- }),
- ),
- );
- }
-}
-
-class TDBottomNavBarItemWithBadge extends StatelessWidget {
- final Widget item;
- final double itemHeight;
- final double itemWidth;
- final GestureTapCallback onTap;
- final bool showBage;
- final Widget badge;
- final double? rightOffset;
- final double? topOffset;
- final TDBottomNavBarPopUpBtnConfig? popUpButtonConfig;
-
- const TDBottomNavBarItemWithBadge({
- Key? key,
- required this.item,
- required this.itemHeight,
- required this.itemWidth,
- required this.onTap,
- required this.showBage,
- required this.badge,
- this.rightOffset,
- this.topOffset,
- this.popUpButtonConfig,
- }) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- onTap.call();
- if (popUpButtonConfig != null) {
- Navigator.push(
- context,
- PopRoute(
- child: PopupDialog(
- itemWidth - _kDefaultMenuItemWidthShrink,
- btnContext: context,
- config: popUpButtonConfig!.popUpDialogConfig,
- items: popUpButtonConfig!.items,
- onClickMenu: (value) {
- popUpButtonConfig!.onChanged(value);
- },
- ),
- ));
- }
- },
- child: Container(
- height: itemHeight,
- alignment: Alignment.center,
- child: Stack(
- alignment: Alignment.center,
- clipBehavior: Clip.none,
- children: [
- item,
- Visibility(
- visible: showBage,
- child: Positioned(
- top: topOffset ?? -5,
- right: rightOffset ?? -10,
- child: badge),
- )
- ],
- ),
- ),
- );
- }
-}
-
-class TDBottomNavBarPopUpBtnConfig {
- // 选项list
- final List items;
-
- // 统一在 onChanged 中处理各item点击事件
- final ValueChanged onChanged;
-
- final TDBottomNavBarPopUpShapeConfig? popUpDialogConfig;
-
- TDBottomNavBarPopUpBtnConfig(
- {required this.items, required this.onChanged, this.popUpDialogConfig})
- : assert(() {
- if (popUpDialogConfig != null) {
- if ((popUpDialogConfig.arrowHeight != null &&
- popUpDialogConfig.arrowHeight! <= 0.0) ||
- (popUpDialogConfig.arrowWidth != null &&
- popUpDialogConfig.arrowWidth! <= 0.0)) {
- throw FlutterError(
- '[TDBottomNavBarPopUpBtnConfig] arrowHeight or arrowHeight can '
- 'not set less than or equal to zero');
- }
- }
- return true;
- }());
-}
-
-class TDBottomNavBarPopUpShapeConfig {
- // 弹窗宽度(不设置,默认为按钮宽度 - 20)
- final double? popUpWidth;
-
- // 单个选项高度 所有选项等高 不设置则使用默认值 48
- final double? popUpitemHeight;
-
- // 弹窗背景颜色
- Color? backgroundColor;
-
- /// pannel圆角 默认0
- double? radius;
-
- /// 箭头宽度 默认13.5
- double? arrowWidth;
-
- // 箭头高度 默认8
- double? arrowHeight;
-
- TDBottomNavBarPopUpShapeConfig(
- {this.popUpWidth,
- this.popUpitemHeight = _kDefaultMenuItemHeight,
- this.backgroundColor,
- this.radius,
- this.arrowWidth,
- this.arrowHeight});
-}
-
-class PopUpMenuItem extends StatelessWidget {
- // 选项widget
- final Widget? itemWidget;
-
- // 选项值
- final String value;
-
- // 对齐方式
- final AlignmentGeometry alignment;
-
- const PopUpMenuItem({
- Key? key,
- this.itemWidget,
- required this.value,
- this.alignment = AlignmentDirectional.center,
- }) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- return Container(
- constraints: const BoxConstraints(minHeight: _kMenuItemMinHeight),
- alignment: alignment,
- child: itemWidget ??
- Text(
- value,
- style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
- ),
- );
- }
-}
-
-class PopRoute extends PopupRoute {
- Widget child;
-
- PopRoute({required this.child});
-
- @override
- Color? get barrierColor => Colors.transparent;
-
- @override
- bool get barrierDismissible => true;
-
- @override
- String? get barrierLabel => 'popUpMenuBarrierLabel';
-
- @override
- Widget buildPage(BuildContext context, Animation animation,
- Animation secondaryAnimation) {
- return child;
- }
-
- @override
- Duration get transitionDuration => _kPopupMenuDuration;
-}
-
-class PopupDialog extends StatefulWidget {
- // 按钮context
- final BuildContext btnContext;
-
- // 点击事件
- final ValueChanged onClickMenu;
-
- // 弹窗选项列表
- final List items;
-
- // 弹窗配置
- final TDBottomNavBarPopUpShapeConfig? config;
-
- // 默认弹窗宽度
- final double defaultPopUpWidth;
-
- const PopupDialog(this.defaultPopUpWidth,
- {Key? key,
- required this.btnContext,
- required this.onClickMenu,
- required this.items,
- required this.config})
- : super(key: key);
-
- @override
- PopupDialogState createState() => PopupDialogState();
-}
-
-class PopupDialogState extends State {
- RenderBox? button;
- RenderBox? overlay;
- RelativeRect? position;
- Size? size;
-
- @override
- void initState() {
- super.initState();
- button = widget.btnContext.findRenderObject() as RenderBox;
- size = button!.size;
- overlay =
- Overlay.of(widget.btnContext)?.context.findRenderObject() as RenderBox;
- position = RelativeRect.fromRect(
- Rect.fromPoints(
- button!.localToGlobal(Offset.zero, ancestor: overlay),
- button!.localToGlobal(Offset.zero, ancestor: overlay),
- ),
- Offset.zero & overlay!.size,
- );
- }
-
- @override
- Widget build(BuildContext context) {
- var popUpitemHeight =
- widget.config?.popUpitemHeight ?? _kDefaultMenuItemHeight;
- var popUpItemWidth = widget.config?.popUpWidth ?? widget.defaultPopUpWidth;
- var menuItems = widget.items
- .map((e) => GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- widget.onClickMenu(e.value);
- Navigator.of(context).pop();
- },
- child: SizedBox(
- height: popUpitemHeight,
- child: e,
- )))
- .toList();
-
- return Material(
- type: MaterialType.transparency,
- child: GestureDetector(
- onTap: () => Navigator.of(context).pop(),
- child: Stack(
- children: [
- Container(
- width: MediaQuery.of(context).size.width,
- height: MediaQuery.of(context).size.height,
- color: Colors.transparent,
- ),
- Positioned(
- top: position!.top -
- (popUpitemHeight * widget.items.length +
- (widget.config?.arrowHeight ?? _kArrowHeight)),
- right: position!.right - (popUpItemWidth + size!.width) / 2,
- child: SizedBox(
- width: popUpItemWidth,
- height: popUpitemHeight * widget.items.length +
- (widget.config?.arrowHeight ?? _kArrowHeight),
- child: CustomPaint(
- painter: PannelWithDownArrow(config: widget.config),
- child: Container(
- alignment: Alignment.topCenter,
- height: popUpitemHeight * widget.items.length,
- child: Container(
- constraints: BoxConstraints(
- maxHeight: popUpitemHeight * widget.items.length),
- child: Stack(
- children: [
- Column(children: menuItems),
- Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: List.generate(
- widget.items.length - 1,
- (index) => Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 8.0),
- child: Divider(
- thickness: 0.5,
- height: 0.5,
- color: TDTheme.of(context).grayColor3,
- ),
- )),
- )
- ],
- ),
- ),
- ),
- ),
- ))
- ],
- ),
- ),
- );
- }
-}
-
-/// 带下箭头的展开pannel
-class PannelWithDownArrow extends CustomPainter {
- TDBottomNavBarPopUpShapeConfig? config;
-
- PannelWithDownArrow({
- this.config,
- });
-
- @override
- void paint(Canvas canvas, Size size) {
- var paint = Paint()
- ..isAntiAlias = true
- ..color = config?.backgroundColor ?? Colors.white
- ..style = PaintingStyle.fill;
- var path = Path();
- var pannelWidth = size.width;
- var pannelHeight = size.height - (config?.arrowHeight ?? _kArrowHeight);
-
- canvas.drawRRect(
- RRect.fromRectAndRadius(Rect.fromLTWH(0, 0, pannelWidth, pannelHeight),
- Radius.circular(config?.radius ?? 0.0)),
- paint);
-
- // 下方箭头
- if (config?.arrowWidth != 0.0 && config?.arrowHeight != 0.0) {
- var left = (pannelWidth - _kArrowWidth) / 2;
- var right = (pannelWidth + _kArrowWidth) / 2;
- var bottom = pannelHeight + _kArrowHeight;
- if (config?.arrowWidth != null) {
- left = (pannelWidth - config!.arrowWidth!) / 2;
- right = (pannelWidth + config!.arrowWidth!) / 2;
- }
- if (config?.arrowHeight != null) {
- bottom = pannelHeight + config!.arrowHeight!;
- }
-
- path.moveTo(left, pannelHeight);
- path.lineTo(pannelWidth / 2, bottom);
- path.lineTo(right, pannelHeight);
- canvas.drawPath(path, paint);
- }
- }
-
- @override
- bool shouldRepaint(covariant CustomPainter oldDelegate) {
- return false;
- }
-}
diff --git a/lib/src/components/button/td_button.dart b/lib/src/components/button/td_button.dart
deleted file mode 100644
index b6afad369..000000000
--- a/lib/src/components/button/td_button.dart
+++ /dev/null
@@ -1,304 +0,0 @@
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-
-enum TDButtonSize { small, medium, large }
-
-typedef TDButtonEvent = void Function();
-
-/// TD常规按钮
-class TDButton extends StatefulWidget {
-
- const TDButton(
- {Key? key,
- required this.content,
- this.size = TDButtonSize.medium,
- this.child,
- this.disabled = false,
- this.style,
- this.textStyle,
- this.disableTextStyle,
- this.width,
- this.height,
- this.onTap,
- this.icon,
- this.onLongPress,
- this.padding})
- : super(key: key);
-
- /// 自控件
- final Widget? child;
- /// 文本内容
- final String? content;
- /// 禁止点击
- final bool disabled;
- /// 自定义宽度
- final double? width;
- /// 自定义高度
- final double? height;
- /// 尺寸
- final TDButtonSize size;
- /// 样式,强按钮,弱按钮,警告按钮等
- final TDButtonStyle? style;
- /// 自定义可点击状态文本样式
- final TextStyle? textStyle;
- /// 自定义不可点击状态文本样式
- final TextStyle? disableTextStyle;
- /// 点击事件
- final TDButtonEvent? onTap;
- /// 长按事件
- final TDButtonEvent? onLongPress;
- /// 图标icon
- final IconData? icon;
- /// 自定义padding
- final EdgeInsetsGeometry? padding;
-
- @override
- State createState() => _TDButtonState();
-}
-
-class _TDButtonState extends State {
-
- TDButtonStyle? _innerStyle;
-
- TDButtonStyle get style {
- if(_innerStyle != null){
- return _innerStyle!;
- }
- _innerStyle = widget.style ?? TDButtonStyle.primary(context: context);
- return _innerStyle!;
- }
-
- @override
- void initState() {
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- var width = widget.width ?? _getWidth();
-
- Widget display = Container(
- width: width,
- height: widget.height ?? _getHeight(),
- alignment: style.isFullWidth ? Alignment.center : null,
- padding: _getPadding(),
- decoration: BoxDecoration(
- color: style.getBackgroundColor(context:context, disable: widget.disabled),
- border: _getBorder(context),
- borderRadius: BorderRadius.all(style.radius ?? Radius.zero),
- ),
- child: widget.child ?? _getChild(),
- );
-
- if(widget.disabled){
- return display;
- }
- return GestureDetector(
- child: display,
- onTap: widget.onTap,
- onLongPress: widget.onLongPress,
- );
- }
-
- Border? _getBorder(BuildContext context) {
- if( style.frameWidth != null && style.frameWidth != 0){
- return Border.all(color: style.getFrameColor(context:context, disable: widget.disabled), width: style.frameWidth!);
- }
- }
-
- Widget _getChild() {
- if(widget.content == null && widget.icon == null){
- return Container();
- }
- var children = [];
- // 系统Icon会导致不居中,因此自绘icon指定height
- if (widget.icon != null) {
- var icon = RichText(
- overflow: TextOverflow.visible,
- text: TextSpan(
- text: String.fromCharCode(widget.icon!.codePoint),
- style: TextStyle(
- inherit: false,
- color: style.getTextColor(context: context, disable: widget.disabled),
- height: 1,
- fontSize: _getIconSize(),
- fontFamily:widget.icon!.fontFamily,
- package: widget.icon!.fontPackage,
- ),
- ),
- );
- children.add(icon);
- }
- if(widget.content != null){
- var text = TDText(widget.content!,
- font: _getTextFont(),
- textColor: style.getTextColor(context: context, disable: widget.disabled),
- style: widget.disabled ? widget.disableTextStyle : widget.textStyle,
- forceVerticalCenter: true,
- );
- children.add(text);
- }
-
- if(children.length == 2){
- children.insert(1, const SizedBox(width: 8,),);
- }
- return Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: children,
- );
- }
-
- Font _getTextFont() {
- switch(widget.size){
- case TDButtonSize.large:
- return TDTheme.of(context).fontM ?? Font(size: 16, lineHeight: 24);
- case TDButtonSize.medium:
- return TDTheme.of(context).fontS ?? Font(size: 14, lineHeight: 22);
- case TDButtonSize.small:
- return TDTheme.of(context).fontS ?? Font(size: 14, lineHeight: 22);
- }
- }
-
- double? _getWidth() {
- if(!style.isFullWidth){
- switch(widget.size){
- case TDButtonSize.large:
- return 343;
- case TDButtonSize.medium:
- return 343;
- case TDButtonSize.small:
- default:
- }
- }
- }
-
- double _getHeight() {
- switch(widget.size){
- case TDButtonSize.large:
- return 44;
- case TDButtonSize.medium:
- return 40;
- case TDButtonSize.small:
- return 36;
- }
- }
-
- double _getIconSize() {
- switch(widget.size){
- case TDButtonSize.large:
- return 24;
- case TDButtonSize.medium:
- return 22;
- case TDButtonSize.small:
- return 20;
- }
- }
-
-
- EdgeInsetsGeometry? _getPadding() {
- if(widget.padding != null){
- return widget.padding;
- }
- double topBottomPadding;
- switch(widget.size){
- case TDButtonSize.large:
- topBottomPadding = 10;
- break;
- case TDButtonSize.medium:
- topBottomPadding = 9;
- break;
- case TDButtonSize.small:
- topBottomPadding = 7;
- break;
- }
- return EdgeInsets.only(left: 16,right: 16,bottom: topBottomPadding,top: topBottomPadding);
- }
-
- @override
- void didUpdateWidget(covariant TDButton oldWidget) {
- super.didUpdateWidget(oldWidget);
- _innerStyle = widget.style ?? _innerStyle ;
- }
-
-}
-
-/// TD文字按钮
-class TDTextButton extends StatefulWidget {
- final TDButtonSize size;
- final String? content;
- final bool disabled;
- final double? width;
- final double? height;
- final TextStyle? style;
- final TextStyle? disableStyle;
- final TDButtonEvent? onTap;
- final TDButtonEvent? onLongPress;
-
- const TDTextButton(
- this.content,{
- Key? key,
- this.size = TDButtonSize.medium,
- this.disabled = false,
- this.style,
- this.disableStyle,
- this.width,
- this.height,
- this.onTap,
- this.onLongPress
-}) : super(key: key);
-
- @override
- State createState() => _TDTextButtonState();
-}
-
-class _TDTextButtonState extends State {
-
-
- late TextStyle? style;
- late TextStyle? disableStyle;
-
- @override
- void initState() {
- super.initState();
- style = widget.style ?? TextStyle(color: TDTheme.of().brandNormalColor);
- disableStyle = widget.disableStyle ?? TextStyle(color: TDTheme.of().brandDisabledColor);
- }
-
- @override
- Widget build(BuildContext context) {
-
- Widget display = SizedBox(
- width: widget.width,
- height: widget.height ,
- child: TDText(widget.content!,
- font: _getTextFont(),
- style: widget.disabled ? disableStyle : style,
- forceVerticalCenter: true,
- ),
- );
-
- if(widget.disabled){
- return display;
- }
- return GestureDetector(
- child: display,
- onTap: widget.onTap,
- onLongPress: widget.onLongPress,
- );
- }
-
- Font _getTextFont() {
- switch(widget.size){
- case TDButtonSize.large:
- return TDTheme.of(context).fontM ?? Font(size: 16, lineHeight: 24);
- case TDButtonSize.medium:
- return TDTheme.of(context).fontS ?? Font(size: 14, lineHeight: 22);
- case TDButtonSize.small:
- return TDTheme.of(context).fontS ?? Font(size: 14, lineHeight: 22);
- }
- }
-}
-
diff --git a/lib/src/components/button/td_button_style.dart b/lib/src/components/button/td_button_style.dart
deleted file mode 100644
index bd04a681b..000000000
--- a/lib/src/components/button/td_button_style.dart
+++ /dev/null
@@ -1,144 +0,0 @@
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-
-/// TDButton按钮样式
-class TDButtonStyle {
- Color? backgroundColor;
- Color? frameColor;
- Color? textColor;
- Color? disableBackgroundColor;
- Color? disableFrameColor;
- Color? disableTextColor;
- Radius? radius;
- double? frameWidth;
- bool isFullWidth = false;
-
- Color getBackgroundColor({BuildContext? context, bool disable = false}){
- return (disable ? disableBackgroundColor : backgroundColor) ?? TDTheme.of(context).brandNormalColor;
- }
-
- Color getFrameColor({BuildContext? context, bool disable = false}){
- return (disable ? disableFrameColor : frameColor) ?? TDTheme.of(context).brandNormalColor;
- }
-
- Color getTextColor({BuildContext? context, bool disable = false}){
- return (disable ? disableTextColor : textColor) ?? TDTheme.of(context).fontWhColor1;
- }
-
- TDButtonStyle(
- {this.backgroundColor,
- this.frameColor,
- this.textColor,
- this.disableBackgroundColor,
- this.disableFrameColor,
- this.disableTextColor,
- this.frameWidth,
- this.radius});
-
- TDButtonStyle.primary({BuildContext? context}){
- var themeData = TDTheme.of(context);
- backgroundColor = themeData.brandNormalColor;
- textColor = themeData.fontWhColor1;
- frameColor = backgroundColor;
- disableBackgroundColor = themeData.brandDisabledColor;
- disableTextColor = themeData.fontWhColor1;
- disableFrameColor = disableBackgroundColor;
- radius = const Radius.circular(4);
- }
-
- TDButtonStyle.weakly({BuildContext? context}){
- var themeData = TDTheme.of(context);
- textColor = themeData.brandNormalColor;
- frameColor = themeData.brandNormalColor;
- backgroundColor = themeData.whiteColor1;
- disableTextColor = themeData.brandDisabledColor;
- disableFrameColor = themeData.brandDisabledColor;
- disableBackgroundColor = themeData.whiteColor1;
- radius = const Radius.circular(4);
- frameWidth = 0.5;
- }
-
- TDButtonStyle.secondary({BuildContext? context}){
- var themeData = TDTheme.of(context);
- disableTextColor = themeData.fontGyColor4;
- disableFrameColor = themeData.grayColor4;
- textColor = themeData.fontGyColor1;
- frameColor = themeData.grayColor4;
- backgroundColor = themeData.whiteColor1;
- disableBackgroundColor = themeData.whiteColor1;
- radius = const Radius.circular(4);
- frameWidth = 0.5;
- }
-
- TDButtonStyle.warningPrimary({BuildContext? context}){
- var themeData = TDTheme.of(context);
- disableBackgroundColor = themeData.errorDisabledColor;
- disableTextColor = themeData.fontWhColor1;
- backgroundColor = themeData.errorNormalColor;
- textColor = themeData.fontWhColor1;
- frameColor = backgroundColor;
- disableFrameColor = backgroundColor;
- radius = const Radius.circular(4);
- }
-
- TDButtonStyle.warningWeakly({BuildContext? context}){
- var themeData = TDTheme.of(context);
- disableTextColor = themeData.errorDisabledColor;
- disableFrameColor = themeData.errorDisabledColor;
- textColor = themeData.errorNormalColor;
- frameColor = themeData.errorNormalColor;
- backgroundColor = themeData.whiteColor1;
- disableBackgroundColor = themeData.whiteColor1;
- radius = const Radius.circular(4);
- frameWidth = 0.5;
- }
-
- TDButtonStyle.ghost({BuildContext? context}){
- var themeData = TDTheme.of(context);
- textColor = themeData.fontWhColor1;
- frameColor = themeData.whiteColor1;
- backgroundColor = Colors.transparent;
- disableTextColor = themeData.fontWhColor3;
- disableFrameColor = themeData.fontWhColor3;
- disableBackgroundColor = Colors.transparent;
- radius = const Radius.circular(4);
- frameWidth = 0.5;
- }
-
- TDButtonStyle.text({BuildContext? context,
- Color? textColor,
- Color? disableTextColor}){
- this.textColor = textColor ?? TDTheme.of(context).brandNormalColor;
- this.disableTextColor = disableTextColor ?? TDTheme.of(context).brandDisabledColor;
- frameColor = Colors.transparent;
- backgroundColor = Colors.transparent;
- disableFrameColor = Colors.transparent;
- disableBackgroundColor = Colors.transparent;
- radius = const Radius.circular(4);
- }
-
- TDButtonStyle.full({BuildContext? context}){
- var themeData = TDTheme.of(context);
- textColor = themeData.fontWhColor1;
- frameColor = themeData.brandNormalColor;
- backgroundColor = themeData.brandNormalColor;
- disableTextColor = themeData.fontWhColor1;
- disableFrameColor = themeData.brandDisabledColor;
- disableBackgroundColor = themeData.brandDisabledColor;
- radius = const Radius.circular(0);
- isFullWidth = true;
- }
-
- TDButtonStyle.fullSecondary({BuildContext? context}){
- var themeData = TDTheme.of(context);
- textColor = themeData.fontGyColor1;
- frameColor = themeData.whiteColor1;
- backgroundColor = themeData.whiteColor1;
- disableTextColor = themeData.fontGyColor4;
- disableFrameColor = themeData.whiteColor1;
- disableBackgroundColor = themeData.whiteColor1;
- radius = const Radius.circular(0);
- isFullWidth = true;
- }
-}
\ No newline at end of file
diff --git a/lib/src/components/checkbox/td_check_box.dart b/lib/src/components/checkbox/td_check_box.dart
deleted file mode 100644
index baed15ca4..000000000
--- a/lib/src/components/checkbox/td_check_box.dart
+++ /dev/null
@@ -1,395 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-
-import '../../theme/td_colors.dart';
-import '../../theme/td_fonts.dart';
-import '../../theme/td_theme.dart';
-import '../divider/td_divider.dart';
-import '../icon/td_icons.dart';
-import '../text/td_text.dart';
-import 'td_check_box_group.dart';
-
-///
-/// 选择框的样式
-///
-enum TDCheckboxStyle {
- circle, // 圆形
- square, // 方形
-}
-
-///
-/// 内容相对icon的位置,上、下、左、右,默认内容在icon的右边
-///
-enum TDContentDirection {
- left, // content在icon的左边
- right, // content在icon的右边
-}
-
-enum TDCheckBoxSize {
- large, // 大 高度56
- small, // 小 高度48
-}
-
-///
-/// 自定义Icon
-///
-typedef IconBuilder = Widget? Function(BuildContext context, bool checked);
-
-///
-/// 自定义Content
-///
-typedef ContentBuilder = Widget Function(BuildContext context, bool checked, String? content);
-
-
-typedef OnCheckValueChanged = void Function(bool selected);
-
-///
-/// 复选框组件。
-///
-/// FuiCheckbox支持3种内置样式的的复选框,还支持各种自定义样式,除了提供勾选之外还提供了内
-/// 容选项,内容包含一个主标题和副标题,并且支持完全自定义内容,支持指定内容的方向等等
-///
-///
-class TDCheckbox extends StatefulWidget {
-
- const TDCheckbox(
- {this.id,
- Key? key,
- this.title,
- this.subTitle,
- this.enable = true,
- this.checked = false,
- this.titleMaxLine,
- this.subTitleMaxLine = 1,
- this.customIconBuilder,
- this.customContentBuilder,
- this.style,
- this.spacing,
- this.backgroundColor,
- this.size = TDCheckBoxSize.small,
- this.contentDirection = TDContentDirection.right,
- this.onCheckBoxChanged}): super(key: key);
-
- /// id
- /// 当FuiCheckBox嵌入到FuiCheckBoxGroup内时,这个值需要赋值,否则不会被纳入Group管理
- final String? id;
-
- /// 文本
- final String? title;
-
- /// 辅助文字
- final String? subTitle;
-
- /// 不可用
- final bool enable;
-
- /// 选中状态。默认为`false`
- /// 当FuiCheckBox嵌入到FuiCheckBoxGroup的时候,这个值表示初始状态,后续的状态会由Group管理
- final bool checked;
-
- /// 标题的行数
- final int? titleMaxLine;
-
- /// 辅助文字的行数
- final int? subTitleMaxLine;
-
- /// icon和文字的距离
- final double? spacing;
-
- /// 复选框样式:圆形或方形
- final TDCheckboxStyle? style;
-
- /// 复选框大小
- final TDCheckBoxSize size;
-
- /// 文字相对icon的方位
- final TDContentDirection contentDirection;
-
- /// 切换监听
- final OnCheckValueChanged? onCheckBoxChanged;
-
- /// 自定义Checkbox显示样式
- final IconBuilder? customIconBuilder;
-
- /// 完全自定义内容
- final ContentBuilder? customContentBuilder;
-
- /// 背景颜色
- final Color? backgroundColor;
-
- @override
- State createState() => TDCheckboxState();
-
- /// 默认的checkBox icon
- Widget buildDefaultIcon(BuildContext context, TDCheckboxGroupState? groupState, bool isChecked) {
- Widget current;
- var size = 24.0;
- final style = this.style ?? groupState?.widget.style ?? TDCheckboxStyle.circle;
- final theme = TDTheme.of(context);
- current = Icon(
- style == TDCheckboxStyle.circle
- ? isChecked ? TDIcons.check_circle_filled : TDIcons.circle
- : isChecked ? TDIcons.check_rectangle_filled : TDIcons.rectangle,
- size: size,
- color: isChecked && enable ? theme.brandColor8 : theme.grayColor4
- );
- return current;
- }
-}
-
-class TDCheckboxState extends State {
- bool checked = false;
- bool _pressed = false;
-
- /// 不可取消勾选,在radioButton的严格模式下,只能切换不能取消勾选
- bool canNotCancel = false;
-
- @override
- void initState() {
- checked = widget.checked;
- super.initState();
- }
-
- @override
- void didUpdateWidget(TDCheckbox oldWidget) {
- checked = widget.checked;
- super.didUpdateWidget(oldWidget);
- }
-
- double _spacing(TDCheckboxGroupState? groupState) {
- return widget.spacing ?? groupState?.widget.spacing ?? 8;
- }
-
- EdgeInsets _getPadding(TDCheckBoxSize size) {
- switch(size) {
- case TDCheckBoxSize.small:
- return const EdgeInsets.only(top: 12, bottom: 12);
- case TDCheckBoxSize.large:
- return const EdgeInsets.only(top: 16, bottom: 16);
- }
- }
-
- @override
- Widget build(BuildContext context) {
- // 检查是否包含在FuiCheckBoxGroup内,如果是的话,状态由Group管理
- final groupState = TDCheckboxGroupInherited.of(context)?.state;
- final id = widget.id;
- // 只有设置了id的CheckBox才会纳入Group管理
- if (groupState != null && id != null) {
- // CheckBox嵌入在CheckBoxGroup的勾选状态的获取优先级:
- // 1.CheckBoxGroup里设置的checkedIds包含当前id
- // 2.没有checkedIds属性,且没有勾选过,使用当前CheckedBox设置的checked属性
- // 3.用户勾选之后的状态
- checked = groupState.getCheckBoxStateById(id, checked);
- }
-
- // 构建icon
- var icon = _buildCheckboxIcon(context, groupState, checked);
-
- // 内容
- var content = _buildContent(context, groupState, checked);
-
-
- if (icon == null && content == null) {
- throw Exception('Icon and content cannot both be null!');
- }
-
- Widget? current ;
-
- if (icon == null) {
- current = content!;
- } else {
-
- current = icon;
-
- if (content != null) {
- final spacing = _spacing(groupState);
- var contentDirection = groupState?.widget.contentDirection ?? widget.contentDirection;
- switch (contentDirection) {
- case TDContentDirection.left:
- current = Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Padding(
- padding: _getPadding(widget.size),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Expanded(child: Padding(
- padding: const EdgeInsets.only(left: 16),
- child: content,
- )),
- SizedBox(width: spacing,),
- Padding(
- padding: const EdgeInsets.only(right: 16),
- child: icon,
- ),
- ],
- ),
- Visibility(
- visible: widget.subTitle != null && widget.subTitle != '',
- child: Padding(
- padding: const EdgeInsets.only(left: 16, right: 16),
- child: TDText(
- widget.subTitle ?? '',
- maxLines:
- widget.subTitleMaxLine,
- overflow: TextOverflow.ellipsis,
- textColor: widget.enable ? TDTheme.of(context).fontGyColor3 : TDTheme.of(context).fontGyColor4,
- font:TDTheme.of(context).fontS),
- ),
- )
- ],
- ),
- ),
- const TDDivider(margin: EdgeInsets.only(left: 16),)
- ],
- );
- break;
- case TDContentDirection.right:
- current = Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Padding(
- padding: _getPadding(widget.size),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.only(left: 16),
- child: icon,
- ),
- SizedBox(width: spacing,),
- Expanded(child: Padding(
- padding: const EdgeInsets.only(right: 16),
- child: content,
- )),
- ],
- ),
- Visibility(
- visible: widget.subTitle != null && widget.subTitle != '',
- child: Padding(
- padding: const EdgeInsets.only(left: 48, right: 16),
- child: TDText(
- widget.subTitle ?? '',
- maxLines:
- widget.subTitleMaxLine,
- overflow: TextOverflow.ellipsis,
- textColor: widget.enable ? TDTheme.of(context).fontGyColor3 : TDTheme.of(context).fontGyColor4,
- font:TDTheme.of(context).fontS),
- ),
- )
- ],
- ),
- ),
- const TDDivider(margin: EdgeInsets.only(left: 48),)
- ],
- );
- break;
- }
- }
- }
-
- if (!(canNotCancel && checked)) {
- if (_pressed) {
- // 点击效果
- current = Opacity(
- opacity: 0.68,
- child: current,
- );
- }
-
- // 开关样式的话自己会处理点击事件
- current = GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTapDown: (detail) {
- _pressState(true);
- },
- onTapUp: (detail) {
- _pressState(false);
- },
- onTapCancel: () {
- _pressState(false);
- },
- onTap: () {
- onValueChange(id, !checked, groupState);
- },
- child: current,
- );
- }
-
- return Container(child: current, color: widget.backgroundColor ?? TDTheme.of(context).whiteColor1,);
- }
-
- /// 点击效果
- void _pressState(bool pressed) {
- if(!widget.enable) {
- return;
- }
- _pressed = pressed;
- setState(() {});
- }
-
- /// 选中状态的变化
- void onValueChange(
- String? id,
- bool value,
- TDCheckboxGroupState? groupState,
- ) {
- if(!widget.enable) {
- return;
- }
- setState(() {
- checked = value;
- if (groupState != null && id != null) {
- groupState.toggle(id, checked);
- }
- widget.onCheckBoxChanged?.call(checked);
- });
- }
-
- ///
- /// 构建选择框边上的文本内容
- ///
- Widget? _buildContent(
- BuildContext context,
- TDCheckboxGroupState? groupState,
- bool checked,
- ) {
-
- final title = widget.title;
- final customContent =
- widget.customContentBuilder ?? groupState?.widget.customContentBuilder;
-
- var content = customContent?.call(context, checked, title);
- if (content == null) {
- if (title != null || customContent != null && title != null) {
- content = TDText(
- title,
- maxLines:
- widget.titleMaxLine ?? groupState?.widget.titleMaxLine,
- overflow: TextOverflow.ellipsis,
- textColor: widget.enable ? TDTheme.of(context).fontGyColor1 : TDTheme.of(context).fontGyColor4,
- font:TDTheme.of(context).fontM);
- }
- }
- return content;
- }
-
- /// 构建icon
- Widget? _buildCheckboxIcon(BuildContext context, TDCheckboxGroupState? groupState, bool isCheck) {
- final iconBuilder = widget.customIconBuilder ?? groupState?.widget.customIconBuilder;
- if (iconBuilder != null) {
- return iconBuilder.call(context, isCheck);
- }
- return widget.buildDefaultIcon(context, groupState, isCheck);
- }
-}
diff --git a/lib/src/components/checkbox/td_check_box_group.dart b/lib/src/components/checkbox/td_check_box_group.dart
deleted file mode 100644
index 8fd7d1ebd..000000000
--- a/lib/src/components/checkbox/td_check_box_group.dart
+++ /dev/null
@@ -1,293 +0,0 @@
-import 'package:flutter/cupertino.dart';
-
-import '../../util/map_ext.dart';
-import 'td_check_box.dart';
-
-///
-/// CheckBoxGroup变化监听器
-///
-typedef OnGroupChange = void Function(List checkedIds);
-
-///
-/// 控制CheckBoxGroup
-///
-class TDCheckboxGroupController {
- TDCheckboxGroupState? _state;
-
- ///
- /// 选择全部
- /// 这个方法会忽略最大可够选数
- ///
- void toggleAll(bool check) {
- _state?.toggleAll(check);
- }
-
- ///
- /// 反选
- ///
- void reverseAll() {
- _state?._reverseAll();
- }
-
- ///
- /// 选中某一个选项
- ///
- void toggle(String id, bool check) {
- _state?.toggle(id, check, true);
- }
-
- ///
- /// 打勾的选项
- ///
- List allChecked() {
- return _state?.checkBoxStates.where((k, v) => v).keys.toList() ?? [];
- }
-
- ///
- /// 某一项的选中状态
- ///
- bool checked(String id) {
- var list = allChecked();
- return list.contains(id);
- }
-}
-
-///
-/// CheckBox组,可以通过控制器控制组内的多个CheckBox的选择状态
-///
-/// child的属性可以是任意包含TDCheckBox的容器组件,例如:
-/// ```dart
-/// TDCheckboxGroup(
-/// child: Row(
-/// children: [
-/// TDCheckBox(),
-/// Column(
-/// children: [
-/// TDCheckBox()
-/// ...
-/// ]
-/// )
-/// ...
-/// ]
-/// )
-/// )
-/// ```
-///
-///
-class TDCheckboxGroup extends StatefulWidget {
- ///
- /// 可以是任意包含TDCheckBox的容器,比如:
- /// ```
- /// Row(
- /// children: [
- /// TDCheckBox(),
- /// TDCheckBox(),
- /// ...
- /// ]
- /// )
- /// ```
- ///
- final Widget child;
-
- ///
- /// 状态变化监听器
- ///
- final OnGroupChange? onChangeGroup;
-
- ///
- /// 可以通过控制器操作勾选状态
- ///
- final TDCheckboxGroupController? controller;
-
- ///
- /// 最多可以勾选多少
- ///
- final int? maxChecked;
-
- ///
- /// 勾选的CheckBox id列表
- ///
- final List? checkedIds;
-
- ///
- /// 超过最大可勾选的个数
- ///
- final VoidCallback? onOverloadChecked;
-
- /// CheckBox标题的行数
- final int? titleMaxLine;
-
-
- /// CheckBox完全自定义内容
- final ContentBuilder? customContentBuilder;
-
- /// CheckBoxicon和文字的距离
- final double? spacing;
-
- /// CheckBox复选框样式:圆形或方形
- final TDCheckboxStyle? style;
-
- ///
- /// 文字相对icon的方位
- ///
- final TDContentDirection? contentDirection;
-
- /// 自定义选择icon的样式
- final IconBuilder? customIconBuilder;
-
- const TDCheckboxGroup(
- {required this.child,
- Key? key,
- this.onChangeGroup,
- this.controller,
- this.checkedIds,
- this.maxChecked,
- this.titleMaxLine,
- this.customContentBuilder,
- this.contentDirection,
- this.style,
- this.spacing,
- this.customIconBuilder,
- this.onOverloadChecked}) : super(key: key);
-
- @override
- State createState() {
- return TDCheckboxGroupState();
- }
-}
-
-
-class TDCheckboxGroupState extends State {
- ///
- /// 管理所有子CheckBox的状态
- ///
- Map checkBoxStates = {};
-
- @override
- void initState() {
- super.initState();
- // 如果有controller的话,把state设置给controller
- widget.controller?._state = this;
-
- _syncCheckState(widget.checkedIds);
- }
-
- /// 把group中配置的默认选中id,同步到状态中
- void _syncCheckState(List? checkIds) {
- checkBoxStates.clear();
- checkIds?.forEach((element) {
- checkBoxStates[element] = true;
- });
- }
-
-
- @override
- void didUpdateWidget(TDCheckboxGroup oldWidget) {
- super.didUpdateWidget(oldWidget);
- final oldCheckIds = oldWidget.checkedIds;
- final newCheckIds = widget.checkedIds;
- if (oldCheckIds != newCheckIds) {
- _syncCheckState(newCheckIds);
- }
- }
-
-
- ///
- /// 根据id获取CheckBox的勾选状态
- ///
- ///
- bool getCheckBoxStateById(String id, bool checked) {
- if (checkBoxStates[id] == null) {
- // checkBox本身的状态
- checkBoxStates[id] = checked;
- }
- return checkBoxStates[id]!;
- }
-
- /// 勾选单个CheckBox
- bool toggle(String id, bool check, [bool notify = false]) {
- // 检查是否超过用户设置的最大可勾选数
- if (widget.maxChecked != null && check) {
- if (checkBoxStates.count((k, v) => v) >= widget.maxChecked!) {
- widget.onOverloadChecked?.call();
- return false;
- }
- }
- checkBoxStates[id] = check;
- if (notify) {
- setState(() {});
- }
- _notifyChange();
- return true;
- }
-
- /// 操作所有CheckBox
- void toggleAll(bool check, [bool notify = true]) {
- var isChanged = false;
- checkBoxStates.forEachCanBreak((k, v) {
- if (check) {
- if (!toggle(k, check)) {
- // 勾选失败,退出循环
- return true;
- }
- } else {
- toggle(k, check);
- }
- isChanged = true;
- return false;
- });
-
- if (isChanged && notify) {
- setState(() {});
- _notifyChange();
- }
- }
-
- /// 反选
- void _reverseAll() {
- final reverseValue =
- checkBoxStates.map((key, value) => MapEntry(key, !value));
- checkBoxStates.forEach((key, value) {
- checkBoxStates[key] = false;
- });
- checkBoxStates.forEach((k, v) {
- var check = reverseValue[k] ?? false;
- toggle(k, check);
- });
- setState(() {});
- _notifyChange();
- }
-
- void _notifyChange() {
- final change = widget.onChangeGroup;
- if (change != null) {
- final checkedIds = checkBoxStates.where((k, v) => v).keys.toList();
- change.call(checkedIds);
- }
- }
-
- @override
- Widget build(BuildContext context) {
- return TDCheckboxGroupInherited(this, widget.child);
- }
-}
-
-class TDCheckboxGroupInherited extends InheritedWidget {
- final TDCheckboxGroupState state;
-
- ///
- /// 获取树上的Group节点
- ///
- static TDCheckboxGroupInherited? of(BuildContext context) {
- return context.dependOnInheritedWidgetOfExactType();
- }
-
- const TDCheckboxGroupInherited(this.state, Widget child, {Key? key}) : super(child: child, key: key);
-
- @override
- bool updateShouldNotify(covariant TDCheckboxGroupInherited oldWidget) {
- var notify =
- oldWidget.state.checkBoxStates.keys != state.checkBoxStates.keys;
- return true;
- }
-}
diff --git a/lib/src/components/dialog/td_alert_dialog.dart b/lib/src/components/dialog/td_alert_dialog.dart
deleted file mode 100644
index 9cff0331b..000000000
--- a/lib/src/components/dialog/td_alert_dialog.dart
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/20/22.
- * td_alert_dialog.dart
- *
- */
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import '../../util/auto_size.dart';
-import 'td_dialog_widget.dart';
-
-/// 弹窗控件
-class TDAlertDialog extends StatelessWidget {
- const TDAlertDialog({
- Key? key,
- this.backgroundColor = Colors.white,
- this.radius = 8.0,
- this.title,
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.contentMaxHeight = 0,
- this.leftBtn,
- this.rightBtn,
- }) : assert((title != null || content != null)),
- _vertical = false,
- _buttons = null,
- super(key: key);
-
- /// 背景颜色
- final Color backgroundColor;
-
- /// 圆角
- final double radius;
-
- /// 标题
- final String? title;
-
- /// 标题颜色
- final Color titleColor;
-
- /// 内容
- final String? content;
-
- /// 内容颜色
- final Color? contentColor;
-
- /// 内容的最大高度,默认为0,也就是不限制高度
- final double contentMaxHeight;
-
- // 选项是否是垂直排布,默认是左右排布
- final bool _vertical;
- // 垂直排布的按钮列表
- final List? _buttons;
-
- final TDDialogButton? leftBtn;
- final TDDialogButton? rightBtn;
-
- const TDAlertDialog.vertical({
- Key? key,
- required List buttons,
- this.backgroundColor = Colors.white,
- this.radius = 8.0,
- this.title,
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.contentMaxHeight = 0,
- }) : _vertical = true,
- leftBtn = null,
- rightBtn = null,
- _buttons = buttons,
- super(key: key);
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- return Center(
- child: Container(
- width: 320.scale,
- decoration: BoxDecoration(
- color: backgroundColor, // 底色
- borderRadius: BorderRadius.all(Radius.circular(radius)),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- TDInfoWidget(
- title: title,
- titleColor: titleColor,
- content: content,
- contentColor: contentColor,
- contentMaxHeight: contentMaxHeight,
- ),
- const TDDivider(
- height: 1,
- ),
- _vertical
- ? _verticalButtons(context)
- : _horizontalButtons(context),
- ])));
- }
-
- Widget _horizontalButtons(BuildContext context) {
- final left = leftBtn ?? TDDialogButton(title: '取消', action: () {});
- final right =
- rightBtn ?? TDDialogButton(title: '好的', action: () {});
- return HorizontalButtons(
- leftBtn: left,
- rightBtn: right,
- );
- }
-
- Widget _verticalButtons(BuildContext context) {
- var widgets = [];
- _buttons!.asMap().forEach((index, value) {
- Widget btn = TDDialogTextButton(
- buttonText: value.title,
- buttonTextColor: value.titleColor,
- onPressed: (){
- Navigator.pop(context);
- value.action();
- },
- );
- widgets.add(btn);
- if (index != _buttons!.length - 1) {
- widgets.add(
- const TDDivider(
- height: 1,
- ),
- );
- }
- });
- return Column(
- children: widgets,
- );
- }
-}
-
-/// 弹窗按钮
-class TDDialogButton {
- Color? titleColor;
- FontWeight? fontWeight;
- final String title;
- final Function() action;
-
- TDDialogButton({
- required this.title,
- required this.action,
- this.titleColor,
- this.fontWeight,
- });
-}
diff --git a/lib/src/components/dialog/td_confirm_dialog.dart b/lib/src/components/dialog/td_confirm_dialog.dart
deleted file mode 100644
index 3cbad9dd9..000000000
--- a/lib/src/components/dialog/td_confirm_dialog.dart
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/20/22.
- * td_confirm_dialog.dart
- *
- */
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import '../../util/auto_size.dart';
-import 'td_dialog_widget.dart';
-
-/// 弹窗控件
-class TDConfirmDialog extends StatelessWidget {
- const TDConfirmDialog({
- Key? key,
- this.action,
- this.backgroundColor = Colors.white,
- this.radius = 8.0,
- this.title,
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.contentMaxHeight = 0,
- this.buttonText = '知道了',
- this.buttonTextColor,
- }) : super(key: key);
-
- /// 标题
- final String? title;
-
- /// 标题颜色
- final Color titleColor;
-
- /// 内容
- final String? content;
-
- /// 内容颜色
- final Color? contentColor;
-
- /// 内容的最大高度,默认为0,也就是不限制高度
- final double contentMaxHeight;
-
- /// 按钮文字
- final String? buttonText;
-
- /// 按钮文字颜色
- final Color? buttonTextColor;
-
- /// 点击
- final Function()? action;
-
- /// 背景颜色
- final Color backgroundColor;
-
- /// 圆角
- final double radius;
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- assert((title != null || content != null));
- return Center(
- child: Container(
- width: 320.scale,
- decoration: BoxDecoration(
- color: backgroundColor, // 底色
- borderRadius: BorderRadius.all(Radius.circular(radius)),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- TDInfoWidget(
- title: title,
- titleColor: titleColor,
- content: content,
- contentColor: contentColor,
- contentMaxHeight: contentMaxHeight,
- ),
- const TDDivider(
- height: 1,
- ),
- TDDialogTextButton(
- buttonText: buttonText,
- buttonTextColor: buttonTextColor,
- onPressed: () {
- Navigator.pop(context);
- if (action != null) {
- action!();
- }
- },
- ),
- ])));
- }
-}
diff --git a/lib/src/components/dialog/td_dialog.dart b/lib/src/components/dialog/td_dialog.dart
deleted file mode 100644
index da63806d5..000000000
--- a/lib/src/components/dialog/td_dialog.dart
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/17/22.
- * td_dialog.dart
- *
- */
-
-
-export 'td_alert_dialog.dart';
-export 'td_confirm_dialog.dart';
-export 'td_image_dialog.dart';
-export 'td_input_dialog.dart';
-
diff --git a/lib/src/components/dialog/td_dialog_widget.dart b/lib/src/components/dialog/td_dialog_widget.dart
deleted file mode 100644
index f47dc12a6..000000000
--- a/lib/src/components/dialog/td_dialog_widget.dart
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/20/22.
- * td_dialog_widget.dart
- *
- */
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-
-/// 弹窗标题
-class TDDialogTitle extends StatelessWidget {
- const TDDialogTitle({
- Key? key,
- this.title = '对话框标题',
- this.titleColor = Colors.black,
- }) : super(key: key);
-
- /// 标题颜色
- final Color titleColor;
-
- /// 标题文字
- final String title;
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- return TDText(
- title,
- textColor: titleColor,
- fontWeight: FontWeight.w600,
- font: Font(size: 16, lineHeight: 24),
- textAlign: TextAlign.center,
- );
- }
-}
-
-/// 弹窗内容
-class TDDialogContent extends StatelessWidget {
- const TDDialogContent({
- Key? key,
- this.content = '当前弹窗内容',
- this.contentColor = const Color(0x66000000),
- }) : super(key: key);
-
- /// 标题颜色
- final Color contentColor;
-
- /// 标题文字
- final String content;
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- return TDText(
- content,
- textColor: contentColor,
- font: Font(size: 16, lineHeight: 24),
- textAlign: TextAlign.center,
- );
- }
-}
-
-/// 弹窗信息
-class TDInfoWidget extends StatelessWidget {
- const TDInfoWidget({
- Key? key,
- this.title,
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.contentMaxHeight = 0,
- }) : super(key: key);
-
- /// 标题
- final String? title;
-
- /// 标题颜色
- final Color titleColor;
-
- /// 内容
- final String? content;
-
- /// 内容颜色
- final Color? contentColor;
-
- /// 内容的最大高度,默认为0,也就是不限制高度
- final double contentMaxHeight;
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- assert((title != null || content != null));
- return Container(
- padding: const EdgeInsets.fromLTRB(24, 32, 24, 32),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- title != null
- ? TDText(
- title,
- textColor: titleColor,
- fontWeight: FontWeight.w600,
- font: Font(size: 16, lineHeight: 24),
- textAlign: TextAlign.center,
- )
- : Container(),
- content == null
- ? Container()
- : Container(
- padding: EdgeInsets.fromLTRB(
- 0, (title != null && content != null) ? 8.0 : 0, 0, 0),
- constraints: contentMaxHeight > 0
- ? BoxConstraints(
- maxHeight: contentMaxHeight,
- )
- : null,
- child: Scrollbar(
- child: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: TDDialogContent(
- content: content!,
- ),
- ),
- ),
- ),
- ],
- ));
- }
-}
-
-/// 水平按钮
-class HorizontalButtons extends StatelessWidget {
- const HorizontalButtons({
- Key? key,
- required this.leftBtn,
- required this.rightBtn,
- }) : super(key: key);
-
- /// 标题颜色
- final TDDialogButton leftBtn;
-
- /// 标题文字
- final TDDialogButton rightBtn;
-
- @override
- Widget build(BuildContext context) {
- // 标题和内容不能同时为空
- return Row(
- children: [
- Expanded(
- child: TDDialogTextButton(
- buttonText: leftBtn.title,
- buttonTextColor: leftBtn.titleColor ?? const Color(0xe6000000),
- onPressed: () {
- Navigator.pop(context);
- leftBtn.action();
- },
- ),
- ),
- const TDDivider(
- height: 57,
- width: 1,
- direction: Axis.vertical,
- ),
- Expanded(
- child: TDDialogTextButton(
- buttonText: rightBtn.title,
- buttonTextColor:
- rightBtn.titleColor ?? TDTheme.of(context).brandColor8,
- onPressed: () {
- Navigator.pop(context);
- rightBtn.action();
- },
- ),
- ),
- ],
- );
- }
-}
-
-/// 弹窗标题
-class TDDialogTextButton extends StatelessWidget {
- const TDDialogTextButton({
- Key? key,
- this.buttonText = '按钮',
- this.buttonTextColor,
- required this.onPressed,
- this.height = 56.0,
- this.width,
- }) : super(key: key);
-
- /// 按钮文字
- final String? buttonText;
-
- /// 按钮文字颜色
- final Color? buttonTextColor;
-
- /// 按钮宽度
- final double? width;
-
- /// 按钮高度
- final double? height;
-
- /// 点击
- final Function() onPressed;
-
- @override
- Widget build(BuildContext context) {
- return TextButton(
- onPressed: onPressed,
- style: TextButton.styleFrom(
- primary: buttonTextColor ?? TDTheme.of(context).brandColor8,
- padding: const EdgeInsets.all(0),
- ),
- child: SizedBox(
- height: height,
- width: width,
- child: Center(
- child: TDText(
- buttonText,
- textColor: buttonTextColor ?? TDTheme.of(context).brandColor8,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- );
- }
-}
diff --git a/lib/src/components/dialog/td_image_dialog.dart b/lib/src/components/dialog/td_image_dialog.dart
deleted file mode 100644
index 073ab8447..000000000
--- a/lib/src/components/dialog/td_image_dialog.dart
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/20/22.
- * td_image_dialog.dart
- *
- */
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import '../../util/auto_size.dart';
-import 'td_dialog_widget.dart';
-
-/// 弹窗控件
-class TDImageDialog extends StatelessWidget {
- const TDImageDialog({
- Key? key,
- required this.image,
- this.backgroundColor = Colors.white,
- this.radius = 8.0,
- this.title = '对话框标题',
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.leftBtn,
- this.rightBtn,
- }) : assert((title != null || content != null)),
- super(key: key);
-
- /// 背景颜色
- final Color backgroundColor;
-
- /// 圆角
- final double radius;
-
- /// 标题
- final String? title;
-
- /// 标题颜色
- final Color titleColor;
-
- /// 内容
- final String? content;
-
- /// 内容颜色
- final Color? contentColor;
-
- final TDDialogButton? leftBtn;
- final TDDialogButton? rightBtn;
-
- final Image image;
-
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Container(
- width: 320.scale,
- decoration: BoxDecoration(
- color: backgroundColor, // 底色
- borderRadius: BorderRadius.all(Radius.circular(radius)),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- ClipRRect(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(radius),
- topRight: Radius.circular(radius)),
- child: SizedBox(
- width: 320.scale,
- height: 140.scale,
- child: FittedBox(
- fit: BoxFit.cover,
- child: image,
- ),
- ),
- ),
- TDInfoWidget(
- title: title,
- titleColor: titleColor,
- content: content,
- contentColor: contentColor,
- ),
- const TDDivider(
- height: 1,
- ),
- _horizontalButtons(context),
- ])),
- );
- }
-
- Widget _horizontalButtons(BuildContext context) {
- final left = leftBtn ?? TDDialogButton(title: '取消', action: () {});
- final right =
- rightBtn ?? TDDialogButton(title: '好的', action: () {});
- return HorizontalButtons(
- leftBtn: left,
- rightBtn: right,
- );
- }
-}
diff --git a/lib/src/components/dialog/td_input_dialog.dart b/lib/src/components/dialog/td_input_dialog.dart
deleted file mode 100644
index 587e20433..000000000
--- a/lib/src/components/dialog/td_input_dialog.dart
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/20/22.
- * td_input_dialog.dart
- *
- */
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import '../../util/auto_size.dart';
-import 'td_dialog_widget.dart';
-
-/// 弹窗控件
-class TDInputDialog extends StatelessWidget {
- const TDInputDialog({
- Key? key,
- required this.textEditingController,
- this.backgroundColor = Colors.white,
- this.radius = 8.0,
- this.title = '输入框标题',
- this.titleColor = Colors.black,
- this.content,
- this.contentColor,
- this.leftBtn,
- this.rightBtn,
- }) : assert((title != null || content != null)),
- super(key: key);
-
- /// 背景颜色
- final Color backgroundColor;
-
- /// 圆角
- final double radius;
-
- /// 标题
- final String? title;
-
- /// 标题颜色
- final Color titleColor;
-
- /// 内容
- final String? content;
-
- /// 内容颜色
- final Color? contentColor;
-
- /// 输入controller
- final TextEditingController textEditingController;
-
- final TDDialogButton? leftBtn;
- final TDDialogButton? rightBtn;
-
- @override
- Widget build(BuildContext context) {
- return AlertDialog(
- contentPadding: EdgeInsets.zero,
- content: Container(
- width: 320.scale,
- decoration: BoxDecoration(
- color: backgroundColor, // 底色
- borderRadius: BorderRadius.all(Radius.circular(radius)),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- TDInfoWidget(
- title: title,
- titleColor: titleColor,
- content: content,
- contentColor: contentColor,
- ),
- Container(
- color: Colors.white,
- height: 80,
- padding: const EdgeInsets.fromLTRB(24, 0, 24, 24),
- child: TextField(
- controller: textEditingController,
- autofocus: true,
- decoration: InputDecoration(
- contentPadding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(3),
- borderSide: BorderSide.none),
- hintText: '请输入',
- fillColor: const Color(0xfff0f0f0),
- filled: true,
- // labelText: '左上角',
- ),
- ),
- ),
- const TDDivider(
- height: 1,
- ),
- _horizontalButtons(context),
- ])),
- );
- }
-
- Widget _horizontalButtons(BuildContext context) {
- final left = leftBtn ?? TDDialogButton(title: '取消', action: () {});
- final right =
- rightBtn ?? TDDialogButton(title: '好的', action: () {});
- return HorizontalButtons(
- leftBtn: left,
- rightBtn: right,
- );
- }
-}
diff --git a/lib/src/components/divider/td_divider.dart b/lib/src/components/divider/td_divider.dart
deleted file mode 100644
index 6a946889d..000000000
--- a/lib/src/components/divider/td_divider.dart
+++ /dev/null
@@ -1,139 +0,0 @@
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import 'dashed_widget.dart';
-
-/// 分割线
-/// 对于非flutter原有的控件,则只需满足TDesign规范即可;
-/// 如果有业务在实际使用,还需兼容实际业务场景。
-class TDDivider extends StatelessWidget {
- const TDDivider({
- Key? key,
- this.color,
- this.margin,
- this.width,
- this.height,
- this.text,
- this.widget,
- this.gapPadding,
- this.hideLine = false,
- this.isDashed = false,
- this.direction = Axis.horizontal,
- }) : super(key: key);
-
- /// 线条颜色
- final Color? color;
-
- /// 外部填充
- final EdgeInsetsGeometry? margin;
-
- /// 线条和中间文本之间的填充
- final EdgeInsetsGeometry? gapPadding;
-
- /// 宽度,需要竖向线条时使用
- final double? width;
-
- /// 高度,横向线条使用
- final double? height;
-
- /// 文本字符串,使用默认样式
- final String? text;
-
- /// 中间控件,可自定义样式
- final Widget? widget;
-
- /// 隐藏线条,使用纯文本分割
- final bool hideLine;
-
- /// 是否为虚线
- final bool isDashed;
-
- /// 方向,竖直虚线必须传
- final Axis direction;
-
- @override
- Widget build(BuildContext context) {
- // 普通直线
- if (widget == null && text == null) {
- return _buildLine(context,
- width: width, height: height, margin: margin, color: color);
- }
-
- // 隐藏线条,纯文本分割
- if (hideLine) {
- return Container(
- width: width,
- height: height,
- margin: margin,
- child: _buildMiddleWidget(context),
- );
- }
-
- // 文本+线条
- return Container(
- width: width,
- margin: margin,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Expanded(
- child: Center(
- child: _buildLine(
- context,
- height: height ?? 0.5,
- color: color ?? TDTheme.of(context).grayColor3,
- ),
- )),
- Padding(
- padding: gapPadding ?? const EdgeInsets.only(left: 12, right: 12),
- child: _buildMiddleWidget(context)),
- Expanded(
- child: Center(
- child: _buildLine(
- context,
- height: height ?? 0.5,
- color: color ?? TDTheme.of(context).grayColor3,
- ))),
- ],
- ),
- );
- }
-
- /// 绘制线条
- Container _buildLine(BuildContext context,
- {double? width,
- double? height,
- EdgeInsetsGeometry? margin,
- Color? color}) {
- if (isDashed) {
- return Container(
- width: width,
- margin: margin,
- child: DashedWidget(
- width: width,
- height: height,
- color: color ?? TDTheme.of(context).grayColor3,
- direction: direction,
- ),
- );
- } else {
- return Container(
- width: width,
- height: height ?? 0.5,
- margin: margin,
- color: color ?? TDTheme.of(context).grayColor3,
- );
- }
- }
-
- /// 构建中间控件
- Widget _buildMiddleWidget(BuildContext context) {
- return widget ??
- TDText(
- text,
- font: TDTheme.of(context).fontXS,
- textColor: TDTheme.of(context).fontGyColor3,
- forceVerticalCenter: true,
- );
- }
-}
diff --git a/lib/src/components/empty/td_empty.dart b/lib/src/components/empty/td_empty.dart
deleted file mode 100644
index 87f9c5cbf..000000000
--- a/lib/src/components/empty/td_empty.dart
+++ /dev/null
@@ -1,59 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-typedef TDTapEvent = void Function();
-
-enum TDEmptyType { plain, operation }
-
-class TDEmpty extends StatelessWidget {
- const TDEmpty(
- {this.type = TDEmptyType.plain,
- this.image,
- this.emptyText,
- this.operationText,
- this.onTapEvent,
- Key? key})
- : super(key: key);
-
- /// 点击事件
- final TDTapEvent? onTapEvent;
- final Widget? image;
- final String? emptyText;
- final String? operationText;
- final TDEmptyType type;
-
- @override
- Widget build(BuildContext context) {
- return Container(
- alignment: Alignment.center,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- image ?? Container(),
- const Padding(padding: EdgeInsets.only(top: 30)),
- TDText(
- emptyText ?? '',
- fontWeight: FontWeight.w400,
- font: TDTheme.of(context).fontS,
- textColor: TDTheme.of(context).fontGyColor3,
- ),
- (type == TDEmptyType.operation)
- ? Padding(
- padding: const EdgeInsets.only(top: 24),
- child: TDButton(
- content: operationText ?? '',
- size: TDButtonSize.small,
- width: 160,
- onTap: () {
- if (onTapEvent != null) {
- onTapEvent!();
- }
- },
- ))
- : Container()
- ],
- ),
- );
- }
-}
diff --git a/lib/src/components/icon/td_icons.dart b/lib/src/components/icon/td_icons.dart
deleted file mode 100644
index 8ab1e6bc4..000000000
--- a/lib/src/components/icon/td_icons.dart
+++ /dev/null
@@ -1,513 +0,0 @@
-import 'package:flutter/widgets.dart';
-
-// GENERATED CODE - DO NOT MODIFY BY HAND
-// ignore_for_file: non_constant_identifier_names
-// ignore_for_file: constant_identifier_names
-@immutable
-class _TDIconsData extends IconData {
- const _TDIconsData(int codePoint, this.name)
- : super(
- codePoint,
- fontFamily: 'TDIcons',
- fontPackage: 'tdesign_flutter',
- );
-
- final String name;
-}
-
-@immutable
-class TDIcons {
- const TDIcons._();
-
- static const add_circle = _TDIconsData(0xf101, 'add_circle');
- static const add_rectangle = _TDIconsData(0xf102, 'add_rectangle');
- static const add = _TDIconsData(0xf103, 'add');
- static const app = _TDIconsData(0xf104, 'app');
- static const arrow_down_rectangle =
- _TDIconsData(0xf105, 'arrow_down_rectangle');
- static const arrow_down = _TDIconsData(0xf106, 'arrow_down');
- static const arrow_left = _TDIconsData(0xf107, 'arrow_left');
- static const arrow_right = _TDIconsData(0xf108, 'arrow_right');
- static const arrow_up = _TDIconsData(0xf109, 'arrow_up');
- static const attach = _TDIconsData(0xf10a, 'attach');
- static const backtop_rectangle = _TDIconsData(0xf10b, 'backtop_rectangle');
- static const backtop = _TDIconsData(0xf10c, 'backtop');
- static const backward = _TDIconsData(0xf10d, 'backward');
- static const barcode = _TDIconsData(0xf10e, 'barcode');
- static const books = _TDIconsData(0xf10f, 'books');
- static const browse_off = _TDIconsData(0xf110, 'browse_off');
- static const browse = _TDIconsData(0xf111, 'browse');
- static const bulletpoint = _TDIconsData(0xf112, 'bulletpoint');
- static const calendar = _TDIconsData(0xf113, 'calendar');
- static const call = _TDIconsData(0xf114, 'call');
- static const caret_down_small = _TDIconsData(0xf115, 'caret_down_small');
- static const caret_down = _TDIconsData(0xf116, 'caret_down');
- static const caret_left_small = _TDIconsData(0xf117, 'caret_left_small');
- static const caret_left = _TDIconsData(0xf118, 'caret_left');
- static const caret_right_small = _TDIconsData(0xf119, 'caret_right_small');
- static const caret_right = _TDIconsData(0xf11a, 'caret_right');
- static const caret_up_small = _TDIconsData(0xf11b, 'caret_up_small');
- static const caret_up = _TDIconsData(0xf11c, 'caret_up');
- static const cart = _TDIconsData(0xf11d, 'cart');
- static const chart_bar = _TDIconsData(0xf11e, 'chart_bar');
- static const chart_bubble = _TDIconsData(0xf11f, 'chart_bubble');
- static const chart_pie = _TDIconsData(0xf120, 'chart_pie');
- static const chart = _TDIconsData(0xf121, 'chart');
- static const chat = _TDIconsData(0xf122, 'chat');
- static const check_circle_filled =
- _TDIconsData(0xf123, 'check_circle_filled');
- static const check_circle = _TDIconsData(0xf124, 'check_circle');
- static const check_rectangle_filled =
- _TDIconsData(0xf125, 'check_rectangle_filled');
- static const check_rectangle = _TDIconsData(0xf126, 'check_rectangle');
- static const check = _TDIconsData(0xf127, 'check');
- static const chevron_down_circle =
- _TDIconsData(0xf128, 'chevron_down_circle');
- static const chevron_down_rectangle =
- _TDIconsData(0xf129, 'chevron_down_rectangle');
- static const chevron_down = _TDIconsData(0xf12a, 'chevron_down');
- static const chevron_left_circle =
- _TDIconsData(0xf12b, 'chevron_left_circle');
- static const chevron_left_rectangle =
- _TDIconsData(0xf12c, 'chevron_left_rectangle');
- static const chevron_left_double =
- _TDIconsData(0xf12d, 'chevron_left_double');
- static const chevron_left = _TDIconsData(0xf12e, 'chevron_left');
- static const chevron_right_circle =
- _TDIconsData(0xf12f, 'chevron_right_circle');
- static const chevron_right_rectangle =
- _TDIconsData(0xf130, 'chevron_right_rectangle');
- static const chevron_right_double =
- _TDIconsData(0xf131, 'chevron_right_double');
- static const chevron_right = _TDIconsData(0xf132, 'chevron_right');
- static const chevron_up_circle = _TDIconsData(0xf133, 'chevron_up_circle');
- static const chevron_up_rectangle =
- _TDIconsData(0xf134, 'chevron_up_rectangle');
- static const chevron_up = _TDIconsData(0xf135, 'chevron_up');
- static const circle = _TDIconsData(0xf136, 'circle');
- static const clear = _TDIconsData(0xf137, 'clear');
- static const close_circle_filled =
- _TDIconsData(0xf138, 'close_circle_filled');
- static const close_circle = _TDIconsData(0xf139, 'close_circle');
- static const close_rectangle = _TDIconsData(0xf13a, 'close_rectangle');
- static const close = _TDIconsData(0xf13b, 'close');
- static const cloud_download = _TDIconsData(0xf13c, 'cloud_download');
- static const cloud_upload = _TDIconsData(0xf13d, 'cloud_upload');
- static const cloud = _TDIconsData(0xf13e, 'cloud');
- static const code = _TDIconsData(0xf13f, 'code');
- static const control_platform = _TDIconsData(0xf140, 'control_platform');
- static const creditcard = _TDIconsData(0xf141, 'creditcard');
- static const dashboard = _TDIconsData(0xf142, 'dashboard');
- static const delete = _TDIconsData(0xf143, 'delete');
- static const desktop = _TDIconsData(0xf144, 'desktop');
- static const discount_filled = _TDIconsData(0xf145, 'discount_filled');
- static const discount = _TDIconsData(0xf146, 'discount');
- static const download = _TDIconsData(0xf147, 'download');
- static const edit_1 = _TDIconsData(0xf148, 'edit_1');
- static const edit = _TDIconsData(0xf149, 'edit');
- static const ellipsis = _TDIconsData(0xf14a, 'ellipsis');
- static const enter = _TDIconsData(0xf14b, 'enter');
- static const error_circle_filled =
- _TDIconsData(0xf14c, 'error_circle_filled');
- static const error_circle = _TDIconsData(0xf14d, 'error_circle');
- static const error = _TDIconsData(0xf14e, 'error');
- static const file_add = _TDIconsData(0xf14f, 'file_add');
- static const file_copy = _TDIconsData(0xf150, 'file_copy');
- static const file_excel = _TDIconsData(0xf151, 'file_excel');
- static const file_icon = _TDIconsData(0xf152, 'file_icon');
- static const file_image = _TDIconsData(0xf153, 'file_image');
- static const file_paste = _TDIconsData(0xf154, 'file_paste');
- static const file_pdf = _TDIconsData(0xf155, 'file_pdf');
- static const file_powerpoint = _TDIconsData(0xf156, 'file_powerpoint');
- static const file_unknown = _TDIconsData(0xf157, 'file_unknown');
- static const file_word = _TDIconsData(0xf158, 'file_word');
- static const file = _TDIconsData(0xf159, 'file');
- static const filter_clear = _TDIconsData(0xf15a, 'filter_clear');
- static const filter = _TDIconsData(0xf15b, 'filter');
- static const flag = _TDIconsData(0xf15c, 'flag');
- static const folder_add = _TDIconsData(0xf15d, 'folder_add');
- static const folder_open = _TDIconsData(0xf15e, 'folder_open');
- static const folder = _TDIconsData(0xf15f, 'folder');
- static const fork = _TDIconsData(0xf160, 'fork');
- static const format_horizontal_align_bottom =
- _TDIconsData(0xf161, 'format_horizontal_align_bottom');
- static const format_horizontal_align_center =
- _TDIconsData(0xf162, 'format_horizontal_align_center');
- static const format_horizontal_align_top =
- _TDIconsData(0xf163, 'format_horizontal_align_top');
- static const format_vertical_align_center =
- _TDIconsData(0xf164, 'format_vertical_align_center');
- static const format_vertical_align_left =
- _TDIconsData(0xf165, 'format_vertical_align_left');
- static const format_vertical_align_right =
- _TDIconsData(0xf166, 'format_vertical_align_right');
- static const forward = _TDIconsData(0xf167, 'forward');
- static const fullscreen_exit = _TDIconsData(0xf168, 'fullscreen_exit');
- static const fullsreen = _TDIconsData(0xf169, 'fullsreen');
- static const gender_female = _TDIconsData(0xf16a, 'gender_female');
- static const gender_male = _TDIconsData(0xf16b, 'gender_male');
- static const gift = _TDIconsData(0xf16c, 'gift');
- static const heart_filled = _TDIconsData(0xf16d, 'heart_filled');
- static const heart = _TDIconsData(0xf16e, 'heart');
- static const help_circle_filled = _TDIconsData(0xf16f, 'help_circle_filled');
- static const help_circle = _TDIconsData(0xf170, 'help_circle');
- static const help = _TDIconsData(0xf171, 'help');
- static const history = _TDIconsData(0xf172, 'history');
- static const home = _TDIconsData(0xf173, 'home');
- static const hourglass = _TDIconsData(0xf174, 'hourglass');
- static const image = _TDIconsData(0xf175, 'image');
- static const info_circle_filled_1 =
- _TDIconsData(0xf176, 'info_circle_filled_1');
- static const info_circle_filled = _TDIconsData(0xf177, 'info_circle_filled');
- static const info_circle = _TDIconsData(0xf178, 'info_circle');
- static const internet = _TDIconsData(0xf179, 'internet');
- static const jump = _TDIconsData(0xf17a, 'jump');
- static const laptop = _TDIconsData(0xf17b, 'laptop');
- static const layers = _TDIconsData(0xf17c, 'layers');
- static const link_unlink = _TDIconsData(0xf17d, 'link_unlink');
- static const link = _TDIconsData(0xf17e, 'link');
- static const loading_blue = _TDIconsData(0xf17f, 'loading_blue');
- static const loading = _TDIconsData(0xf180, 'loading');
- static const location = _TDIconsData(0xf181, 'location');
- static const lock_off = _TDIconsData(0xf182, 'lock_off');
- static const lock_on = _TDIconsData(0xf183, 'lock_on');
- static const login = _TDIconsData(0xf184, 'login');
- static const logo_android = _TDIconsData(0xf185, 'logo_android');
- static const logo_apple_filled = _TDIconsData(0xf186, 'logo_apple_filled');
- static const logo_apple = _TDIconsData(0xf187, 'logo_apple');
- static const logo_chrome_filled = _TDIconsData(0xf188, 'logo_chrome_filled');
- static const logo_chrome = _TDIconsData(0xf189, 'logo_chrome');
- static const logo_codepen = _TDIconsData(0xf18a, 'logo_codepen');
- static const logo_github_filled = _TDIconsData(0xf18b, 'logo_github_filled');
- static const logo_github = _TDIconsData(0xf18c, 'logo_github');
- static const logo_ie_filled = _TDIconsData(0xf18d, 'logo_ie_filled');
- static const logo_ie = _TDIconsData(0xf18e, 'logo_ie');
- static const logo_windows_filled =
- _TDIconsData(0xf18f, 'logo_windows_filled');
- static const logo_windows = _TDIconsData(0xf190, 'logo_windows');
- static const logout = _TDIconsData(0xf191, 'logout');
- static const mail = _TDIconsData(0xf192, 'mail');
- static const menu_fold = _TDIconsData(0xf193, 'menu_fold');
- static const menu_unfold = _TDIconsData(0xf194, 'menu_unfold');
- static const minus_circle_filled =
- _TDIconsData(0xf195, 'minus_circle_filled');
- static const minus_circle = _TDIconsData(0xf196, 'minus_circle');
- static const minus_rectangle = _TDIconsData(0xf197, 'minus_rectangle');
- static const mobile_vibrate = _TDIconsData(0xf198, 'mobile_vibrate');
- static const mobile = _TDIconsData(0xf199, 'mobile');
- static const money_circle = _TDIconsData(0xf19a, 'money_circle');
- static const more = _TDIconsData(0xf19b, 'more');
- static const move = _TDIconsData(0xf19c, 'move');
- static const next = _TDIconsData(0xf19d, 'next');
- static const notification_filled =
- _TDIconsData(0xf19e, 'notification_filled');
- static const notification = _TDIconsData(0xf19f, 'notification');
- static const order_adjustment_column =
- _TDIconsData(0xf1a0, 'order_adjustment_column');
- static const order_ascending = _TDIconsData(0xf1a1, 'order_ascending');
- static const order_descending = _TDIconsData(0xf1a2, 'order_descending');
- static const page_first = _TDIconsData(0xf1a3, 'page_first');
- static const page_last = _TDIconsData(0xf1a4, 'page_last');
- static const pause_circle_filled =
- _TDIconsData(0xf1a5, 'pause_circle_filled');
- static const photo = _TDIconsData(0xf1a6, 'photo');
- static const pin = _TDIconsData(0xf1a7, 'pin');
- static const play_circle_filled = _TDIconsData(0xf1a8, 'play_circle_filled');
- static const play_circle_stroke = _TDIconsData(0xf1a9, 'play_circle_stroke');
- static const play_circle = _TDIconsData(0xf1aa, 'play_circle');
- static const play = _TDIconsData(0xf1ab, 'play');
- static const poweroff = _TDIconsData(0xf1ac, 'poweroff');
- static const precise_monitor = _TDIconsData(0xf1ad, 'precise_monitor');
- static const previous = _TDIconsData(0xf1ae, 'previous');
- static const print = _TDIconsData(0xf1af, 'print');
- static const qrcode = _TDIconsData(0xf1b0, 'qrcode');
- static const queue = _TDIconsData(0xf1b1, 'queue');
- static const rectangle = _TDIconsData(0xf1b2, 'rectangle');
- static const refresh = _TDIconsData(0xf1b3, 'refresh');
- static const remove = _TDIconsData(0xf1b4, 'remove');
- static const rollback = _TDIconsData(0xf1b5, 'rollback');
- static const root_list = _TDIconsData(0xf1b6, 'root_list');
- static const round = _TDIconsData(0xf1b7, 'round');
- static const save = _TDIconsData(0xf1b8, 'save');
- static const scan = _TDIconsData(0xf1b9, 'scan');
- static const search = _TDIconsData(0xf1ba, 'search');
- static const secured = _TDIconsData(0xf1bb, 'secured');
- static const server = _TDIconsData(0xf1bc, 'server');
- static const service = _TDIconsData(0xf1bd, 'service');
- static const setting = _TDIconsData(0xf1be, 'setting');
- static const share = _TDIconsData(0xf1bf, 'share');
- static const shop = _TDIconsData(0xf1c0, 'shop');
- static const slash = _TDIconsData(0xf1c1, 'slash');
- static const sound = _TDIconsData(0xf1c2, 'sound');
- static const star_filled = _TDIconsData(0xf1c3, 'star_filled');
- static const star = _TDIconsData(0xf1c4, 'star');
- static const stop_circle_1 = _TDIconsData(0xf1c5, 'stop_circle_1');
- static const stop_circle_filled = _TDIconsData(0xf1c6, 'stop_circle_filled');
- static const stop_circle = _TDIconsData(0xf1c7, 'stop_circle');
- static const stop = _TDIconsData(0xf1c8, 'stop');
- static const swap_left = _TDIconsData(0xf1c9, 'swap_left');
- static const swap_right = _TDIconsData(0xf1ca, 'swap_right');
- static const swap = _TDIconsData(0xf1cb, 'swap');
- static const thumb_down = _TDIconsData(0xf1cc, 'thumb_down');
- static const thumb_up = _TDIconsData(0xf1cd, 'thumb_up');
- static const time_filled = _TDIconsData(0xf1ce, 'time_filled');
- static const time = _TDIconsData(0xf1cf, 'time');
- static const tips = _TDIconsData(0xf1d0, 'tips');
- static const tools = _TDIconsData(0xf1d1, 'tools');
- static const unfold_less = _TDIconsData(0xf1d2, 'unfold_less');
- static const unfold_more = _TDIconsData(0xf1d3, 'unfold_more');
- static const upload = _TDIconsData(0xf1d4, 'upload');
- static const usb = _TDIconsData(0xf1d5, 'usb');
- static const user_add = _TDIconsData(0xf1d6, 'user_add');
- static const user_avatar = _TDIconsData(0xf1d7, 'user_avatar');
- static const user_circle = _TDIconsData(0xf1d8, 'user_circle');
- static const user_clear = _TDIconsData(0xf1d9, 'user_clear');
- static const user_talk = _TDIconsData(0xf1da, 'user_talk');
- static const user = _TDIconsData(0xf1db, 'user');
- static const user2 = _TDIconsData(0xf1dc, 'user2');
- static const usergroup_add = _TDIconsData(0xf1dd, 'usergroup_add');
- static const usergroup_clear = _TDIconsData(0xf1de, 'usergroup_clear');
- static const usergroup = _TDIconsData(0xf1df, 'usergroup');
- static const video = _TDIconsData(0xf1e0, 'video');
- static const view_column = _TDIconsData(0xf1e1, 'view_column');
- static const view_list = _TDIconsData(0xf1e2, 'view_list');
- static const view_module = _TDIconsData(0xf1e3, 'view_module');
- static const wallet = _TDIconsData(0xf1e4, 'wallet');
- static const wifi = _TDIconsData(0xf1e5, 'wifi');
- static const zoom_in = _TDIconsData(0xf1e6, 'zoom_in');
- static const zoom_out = _TDIconsData(0xf1e7, 'zoom_out');
-
- static const all = {
- 'add_circle': add_circle,
- 'add_rectangle': add_rectangle,
- 'add': add,
- 'app': app,
- 'arrow_down_rectangle': arrow_down_rectangle,
- 'arrow_down': arrow_down,
- 'arrow_left': arrow_left,
- 'arrow_right': arrow_right,
- 'arrow_up': arrow_up,
- 'attach': attach,
- 'backtop_rectangle': backtop_rectangle,
- 'backtop': backtop,
- 'backward': backward,
- 'barcode': barcode,
- 'books': books,
- 'browse_off': browse_off,
- 'browse': browse,
- 'bulletpoint': bulletpoint,
- 'calendar': calendar,
- 'call': call,
- 'caret_down_small': caret_down_small,
- 'caret_down': caret_down,
- 'caret_left_small': caret_left_small,
- 'caret_left': caret_left,
- 'caret_right_small': caret_right_small,
- 'caret_right': caret_right,
- 'caret_up_small': caret_up_small,
- 'caret_up': caret_up,
- 'cart': cart,
- 'chart_bar': chart_bar,
- 'chart_bubble': chart_bubble,
- 'chart_pie': chart_pie,
- 'chart': chart,
- 'chat': chat,
- 'check_circle_filled': check_circle_filled,
- 'check_circle': check_circle,
- 'check_rectangle_filled': check_rectangle_filled,
- 'check_rectangle': check_rectangle,
- 'check': check,
- 'chevron_down_circle': chevron_down_circle,
- 'chevron_down_rectangle': chevron_down_rectangle,
- 'chevron_down': chevron_down,
- 'chevron_left_circle': chevron_left_circle,
- 'chevron_left_rectangle': chevron_left_rectangle,
- 'chevron_left_double': chevron_left_double,
- 'chevron_left': chevron_left,
- 'chevron_right_circle': chevron_right_circle,
- 'chevron_right_rectangle': chevron_right_rectangle,
- 'chevron_right_double': chevron_right_double,
- 'chevron_right': chevron_right,
- 'chevron_up_circle': chevron_up_circle,
- 'chevron_up_rectangle': chevron_up_rectangle,
- 'chevron_up': chevron_up,
- 'circle': circle,
- 'clear': clear,
- 'close_circle_filled': close_circle_filled,
- 'close_circle': close_circle,
- 'close_rectangle': close_rectangle,
- 'close': close,
- 'cloud_download': cloud_download,
- 'cloud_upload': cloud_upload,
- 'cloud': cloud,
- 'code': code,
- 'control_platform': control_platform,
- 'creditcard': creditcard,
- 'dashboard': dashboard,
- 'delete': delete,
- 'desktop': desktop,
- 'discount_filled': discount_filled,
- 'discount': discount,
- 'download': download,
- 'edit_1': edit_1,
- 'edit': edit,
- 'ellipsis': ellipsis,
- 'enter': enter,
- 'error_circle_filled': error_circle_filled,
- 'error_circle': error_circle,
- 'error': error,
- 'file_add': file_add,
- 'file_copy': file_copy,
- 'file_excel': file_excel,
- 'file_icon': file_icon,
- 'file_image': file_image,
- 'file_paste': file_paste,
- 'file_pdf': file_pdf,
- 'file_powerpoint': file_powerpoint,
- 'file_unknown': file_unknown,
- 'file_word': file_word,
- 'file': file,
- 'filter_clear': filter_clear,
- 'filter': filter,
- 'flag': flag,
- 'folder_add': folder_add,
- 'folder_open': folder_open,
- 'folder': folder,
- 'fork': fork,
- 'format_horizontal_align_bottom': format_horizontal_align_bottom,
- 'format_horizontal_align_center': format_horizontal_align_center,
- 'format_horizontal_align_top': format_horizontal_align_top,
- 'format_vertical_align_center': format_vertical_align_center,
- 'format_vertical_align_left': format_vertical_align_left,
- 'format_vertical_align_right': format_vertical_align_right,
- 'forward': forward,
- 'fullscreen_exit': fullscreen_exit,
- 'fullsreen': fullsreen,
- 'gender_female': gender_female,
- 'gender_male': gender_male,
- 'gift': gift,
- 'heart_filled': heart_filled,
- 'heart': heart,
- 'help_circle_filled': help_circle_filled,
- 'help_circle': help_circle,
- 'help': help,
- 'history': history,
- 'home': home,
- 'hourglass': hourglass,
- 'image': image,
- 'info_circle_filled_1': info_circle_filled_1,
- 'info_circle_filled': info_circle_filled,
- 'info_circle': info_circle,
- 'internet': internet,
- 'jump': jump,
- 'laptop': laptop,
- 'layers': layers,
- 'link_unlink': link_unlink,
- 'link': link,
- 'loading_blue': loading_blue,
- 'loading': loading,
- 'location': location,
- 'lock_off': lock_off,
- 'lock_on': lock_on,
- 'login': login,
- 'logo_android': logo_android,
- 'logo_apple_filled': logo_apple_filled,
- 'logo_apple': logo_apple,
- 'logo_chrome_filled': logo_chrome_filled,
- 'logo_chrome': logo_chrome,
- 'logo_codepen': logo_codepen,
- 'logo_github_filled': logo_github_filled,
- 'logo_github': logo_github,
- 'logo_ie_filled': logo_ie_filled,
- 'logo_ie': logo_ie,
- 'logo_windows_filled': logo_windows_filled,
- 'logo_windows': logo_windows,
- 'logout': logout,
- 'mail': mail,
- 'menu_fold': menu_fold,
- 'menu_unfold': menu_unfold,
- 'minus_circle_filled': minus_circle_filled,
- 'minus_circle': minus_circle,
- 'minus_rectangle': minus_rectangle,
- 'mobile_vibrate': mobile_vibrate,
- 'mobile': mobile,
- 'money_circle': money_circle,
- 'more': more,
- 'move': move,
- 'next': next,
- 'notification_filled': notification_filled,
- 'notification': notification,
- 'order_adjustment_column': order_adjustment_column,
- 'order_ascending': order_ascending,
- 'order_descending': order_descending,
- 'page_first': page_first,
- 'page_last': page_last,
- 'pause_circle_filled': pause_circle_filled,
- 'photo': photo,
- 'pin': pin,
- 'play_circle_filled': play_circle_filled,
- 'play_circle_stroke': play_circle_stroke,
- 'play_circle': play_circle,
- 'play': play,
- 'poweroff': poweroff,
- 'precise_monitor': precise_monitor,
- 'previous': previous,
- 'print': print,
- 'qrcode': qrcode,
- 'queue': queue,
- 'rectangle': rectangle,
- 'refresh': refresh,
- 'remove': remove,
- 'rollback': rollback,
- 'root_list': root_list,
- 'round': round,
- 'save': save,
- 'scan': scan,
- 'search': search,
- 'secured': secured,
- 'server': server,
- 'service': service,
- 'setting': setting,
- 'share': share,
- 'shop': shop,
- 'slash': slash,
- 'sound': sound,
- 'star_filled': star_filled,
- 'star': star,
- 'stop_circle_1': stop_circle_1,
- 'stop_circle_filled': stop_circle_filled,
- 'stop_circle': stop_circle,
- 'stop': stop,
- 'swap_left': swap_left,
- 'swap_right': swap_right,
- 'swap': swap,
- 'thumb_down': thumb_down,
- 'thumb_up': thumb_up,
- 'time_filled': time_filled,
- 'time': time,
- 'tips': tips,
- 'tools': tools,
- 'unfold_less': unfold_less,
- 'unfold_more': unfold_more,
- 'upload': upload,
- 'usb': usb,
- 'user_add': user_add,
- 'user_avatar': user_avatar,
- 'user_circle': user_circle,
- 'user_clear': user_clear,
- 'user_talk': user_talk,
- 'user': user,
- 'user2': user2,
- 'usergroup_add': usergroup_add,
- 'usergroup_clear': usergroup_clear,
- 'usergroup': usergroup,
- 'video': video,
- 'view_column': view_column,
- 'view_list': view_list,
- 'view_module': view_module,
- 'wallet': wallet,
- 'wifi': wifi,
- 'zoom_in': zoom_in,
- 'zoom_out': zoom_out,
- };
-}
diff --git a/lib/src/components/image/image_widget.dart b/lib/src/components/image/image_widget.dart
deleted file mode 100644
index 38edfe3f3..000000000
--- a/lib/src/components/image/image_widget.dart
+++ /dev/null
@@ -1,210 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-///封装图片加载控件,增加图片加载失败时加载默认图片
-class ImageWidget extends StatefulWidget {
- /// 图片地址
- final String src;
-
- /// 图片宽度
- final double width;
-
- /// 图片高度
- final double height;
-
- /// 加载错误时展示Widget
- final Widget? errorWidget;
-
- /// 加载中展示Widget
- final Widget? loadingWidget;
-
- /// 适配样式
- final BoxFit fit;
-
- /// 以下系统Image属性,释义请参考系统[Image]中注释
- final ImageProvider image;
-
- final ImageFrameBuilder? frameBuilder;
-
- final ImageLoadingBuilder? loadingBuilder;
-
- final ImageErrorWidgetBuilder? errorBuilder;
-
- final Color? color;
-
- final Animation? opacity;
-
- final FilterQuality filterQuality;
-
- final BlendMode? colorBlendMode;
-
- final AlignmentGeometry alignment;
-
- final ImageRepeat repeat;
-
- final Rect? centerSlice;
-
- final bool matchTextDirection;
-
- final bool gaplessPlayback;
-
- final String? semanticLabel;
-
- final bool excludeFromSemantics;
-
- final bool isAntiAlias;
-
- final int? cacheWidth;
-
- final int? cacheHeight;
-
- const ImageWidget({
- Key? key,
- required this.image,
- this.frameBuilder,
- this.loadingBuilder,
- this.errorBuilder,
- this.semanticLabel,
- this.excludeFromSemantics = false,
- required this.width,
- required this.height,
- this.color,
- this.opacity,
- this.colorBlendMode,
- required this.fit,
- this.alignment = Alignment.center,
- this.repeat = ImageRepeat.noRepeat,
- this.centerSlice,
- this.matchTextDirection = false,
- this.gaplessPlayback = false,
- this.isAntiAlias = false,
- this.filterQuality = FilterQuality.low,
- required this.src,
- this.errorWidget,
- this.loadingWidget,
- this.cacheWidth,
- this.cacheHeight
- }) : super(key: key);
-
- ImageWidget.network(this.src, {
- Key? key,
- required this.width,
- required this.height,
- double scale = 1.0,
- this.errorWidget,
- this.fit = BoxFit.none,
- this.loadingWidget,
- this.frameBuilder,
- this.loadingBuilder,
- this.errorBuilder,
- this.semanticLabel,
- this.excludeFromSemantics = false,
- this.color,
- this.opacity,
- this.colorBlendMode,
- this.alignment = Alignment.center,
- this.repeat = ImageRepeat.noRepeat,
- this.centerSlice,
- this.matchTextDirection = false,
- this.gaplessPlayback = false,
- this.filterQuality = FilterQuality.low,
- this.isAntiAlias = false,
- Map? headers,
- this.cacheWidth, this.cacheHeight}) : image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, NetworkImage(src, scale: scale, headers: headers)),
- assert(cacheWidth == null || cacheWidth > 0),
- assert(cacheHeight == null || cacheHeight > 0),
- super(key: key);
-
- @override
- State createState() {
- return _StateImageWidget();
- }
-}
-
-class _StateImageWidget extends State {
- late Image _image;
- bool error = false;
- bool loading = true;
-
- @override
- void initState() {
- super.initState();
- _image = Image.network(
- widget.src,
- width: widget.width,
- height: widget.height,
- fit: widget.fit,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheWidth: widget.cacheWidth,
- cacheHeight: widget.cacheHeight,
- );
- var resolve = _image.image.resolve(const ImageConfiguration());
- resolve.addListener(ImageStreamListener((_, __) {
-
- /// 加载成功
- setState(() {
- loading = false;
- error = false;
- });
- }, onChunk: (ImageChunkEvent event) {
- /// 加载中
- if (loading == false) {
- setState(() {
- loading = true;
- error = false;
- });
- }
- }, onError: (dynamic exception, StackTrace? stackTrace) {
- /// 加载失败
- if (error == false) {
- setState(() {
- error = true;
- loading = false;
- });
- }
- }));
- }
-
- @override
- Widget build(BuildContext context) {
- if (error == false && loading == true) {
- return Container(
- alignment: widget.alignment,
- color: widget.color ?? TDTheme.of(context).grayColor2,
- child: widget.loadingWidget ?? Icon(
- TDIcons.ellipsis,
- size: 22,
- color: TDTheme.of(context).fontGyColor3,
- )
- );
- }
- if (error == true && loading == false) {
- return Container(
- alignment: widget.alignment,
- color: widget.color ?? TDTheme.of(context).grayColor2,
- child: widget.errorWidget ?? Icon(
- TDIcons.close,
- size: 22,
- color: TDTheme.of(context).fontGyColor3,
- ),
- );
- }
- if (loading == false && error == false) {
- return _image;
- }
- return Container();
- }
-}
diff --git a/lib/src/components/image/td_image.dart b/lib/src/components/image/td_image.dart
deleted file mode 100644
index d64b8da3c..000000000
--- a/lib/src/components/image/td_image.dart
+++ /dev/null
@@ -1,360 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-import '../../util/string_util.dart';
-import 'image_widget.dart';
-
-enum TDImageSize {
- /// 120*120px
- xl,
-
- /// 72*72
- l,
-
- /// 56*56
- m,
-
- /// 48*48
- s,
-
- /// 32*32
- xs,
-
- /// 24*24
- xxs
-}
-
-enum TDImageType {
- /// 裁剪
- clip,
-
- /// 适应高
- fitHeight,
-
- /// 拉伸
- stretch,
-
- /// 方形,
- square,
-
- /// 圆角方形
- roundedSquare,
-
- /// 圆形
- circle,
-}
-
-class TDImage extends StatefulWidget {
-
- const TDImage(
- this.imgUrl, {
- Key? key,
- this.size = TDImageSize.l,
- this.type = TDImageType.roundedSquare,
- this.errorWidget,
- this.loadingWidget,
- this.width,
- this.height,
- this.frameBuilder,
- this.loadingBuilder,
- this.errorBuilder,
- this.semanticLabel,
- this.excludeFromSemantics = false,
- this.color,
- this.opacity,
- this.colorBlendMode,
- this.alignment = Alignment.center,
- this.repeat = ImageRepeat.noRepeat,
- this.centerSlice,
- this.matchTextDirection = false,
- this.gaplessPlayback = false,
- this.isAntiAlias = false,
- this.filterQuality = FilterQuality.low,
- this.cacheHeight,
- this.cacheWidth,
- }) : super(key: key);
-
- /// 图片地址
- final String imgUrl;
-
- /// 图片类型
- final TDImageType type;
-
- /// 图片大小
- final TDImageSize size;
-
- /// 加载自定义提示
- final Widget? loadingWidget;
-
- /// 失败自定义提示
- final Widget? errorWidget;
-
- /// 自定义宽
- final double? width;
-
- /// 自定义高
- final double? height;
-
- /// 以下系统Image属性,释义请参考系统[Image]中注释
-
- final ImageFrameBuilder? frameBuilder;
-
- final ImageLoadingBuilder? loadingBuilder;
-
- final ImageErrorWidgetBuilder? errorBuilder;
-
- final Color? color;
-
- final Animation? opacity;
-
- final FilterQuality filterQuality;
-
- final BlendMode? colorBlendMode;
-
- final AlignmentGeometry alignment;
-
- final ImageRepeat repeat;
-
- final Rect? centerSlice;
-
- final bool matchTextDirection;
-
- final bool gaplessPlayback;
-
- final String? semanticLabel;
-
- final bool excludeFromSemantics;
-
- final bool isAntiAlias;
-
- final int? cacheHeight;
-
- final int? cacheWidth;
-
- @override
- State createState() => _TDImageState();
-}
-
-class _TDImageState extends State {
- double _getImageWidth() {
- double width;
- switch (widget.size) {
- case TDImageSize.xl:
- width = 120;
- break;
- case TDImageSize.l:
- width = 72;
- break;
- case TDImageSize.m:
- width = 56;
- break;
- case TDImageSize.s:
- width = 48;
- break;
- case TDImageSize.xs:
- width = 32;
- break;
- case TDImageSize.xxs:
- width = 24;
- break;
- default:
- width = 72;
- break;
- }
- return widget.width ?? width;
- }
-
- double _getImageHeight() {
- double height;
- height = _getImageWidth();
- return widget.height ?? height;
- }
-
- @override
- Widget build(BuildContext context) {
- switch (widget.type) {
- case TDImageType.clip:
- return SizedBox(
- width: _getImageWidth(),
- height: _getImageHeight(),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.cover,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ),
- );
- case TDImageType.fitHeight:
- return SizedBox(
- width: _getImageWidth(),
- height: _getImageHeight(),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.fitHeight,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ),
- );
- case TDImageType.stretch:
- return SizedBox(
- width: _getImageWidth(),
- height: _getImageHeight(),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.fill,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ),
- );
- case TDImageType.square:
- return SizedBox(
- width: _getImageWidth(),
- height: _getImageHeight(),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.cover,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ),
- );
- case TDImageType.roundedSquare:
- return Container(
- width: _getImageWidth(),
- height: _getImageHeight(),
- clipBehavior: Clip.hardEdge,
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(4)),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.cover,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ));
- case TDImageType.circle:
- return Container(
- width: _getImageWidth(),
- height: _getImageHeight(),
- clipBehavior: Clip.hardEdge,
- decoration: const BoxDecoration(shape: BoxShape.circle),
- child: ImageWidget.network(
- widget.imgUrl,
- height: _getImageHeight(),
- width: _getImageWidth(),
- errorWidget: widget.errorWidget,
- loadingWidget: widget.loadingWidget,
- fit: BoxFit.cover,
- color: widget.color,
- frameBuilder: widget.frameBuilder,
- loadingBuilder: widget.loadingBuilder,
- errorBuilder: widget.errorBuilder,
- semanticLabel: widget.semanticLabel,
- excludeFromSemantics: widget.excludeFromSemantics,
- opacity: widget.opacity,
- colorBlendMode: widget.colorBlendMode,
- alignment: widget.alignment,
- repeat: widget.repeat,
- centerSlice: widget.centerSlice,
- matchTextDirection: widget.matchTextDirection,
- gaplessPlayback: widget.gaplessPlayback,
- filterQuality: widget.filterQuality,
- isAntiAlias: widget.isAntiAlias,
- cacheHeight: widget.cacheHeight,
- cacheWidth: widget.cacheWidth,
- ));
- }
- }
-}
diff --git a/lib/src/components/input/td_input.dart b/lib/src/components/input/td_input.dart
deleted file mode 100644
index 82e12d274..000000000
--- a/lib/src/components/input/td_input.dart
+++ /dev/null
@@ -1,511 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import '../../../td_export.dart';
-
-enum TDInputType {
- normal,
- twoLine,
- longText,
- special
-}
-
-enum TDInputSize {
- small,
- large
-}
-
-class TDInput extends StatelessWidget {
- const TDInput({
- Key? key,
- this.width,
- this.textStyle,
- this.backgroundColor,
- this.decoration,
- this.leftLabel,
- this.readOnly = false,
- this.autofocus = false,
- this.obscureText = false,
- this.onEditingComplete,
- this.onSubmitted,
- this.hintText,
- this.inputType,
- this.onChanged,
- this.inputFormatters,
- this.inputDecoration,
- this.maxLines = 1,
- this.focusNode,
- this.controller,
- this.cursorColor,
- this.rightBtn,
- this.hintTextStyle,
- this.onTapBtn,
- this.labelWidget,
- this.textInputBackgroundColor,
- this.contentPadding,
- this.type = TDInputType.normal,
- this.size = TDInputSize.small,
- this.inputWidth = 81,
- this.maxNum = 500,
- this.errorText = '',
- this.textAlign,
- this.rightWidget
- }) : super(key: key);
-
- /// 输入框宽度
- final double? width;
-
- /// 输入框背景色
- final Color? backgroundColor;
-
- /// 输入框样式
- final Decoration? decoration;
-
- /// 输入框左侧文案
- final String? leftLabel;
-
- /// leftLabel右侧组件,支持自定义
- final Widget? labelWidget;
-
- /// 是否只读
- final bool readOnly;
-
- /// 提示文案
- final String? hintText;
-
- /// 键盘类型,数字、字母
- final TextInputType? inputType;
-
- /// 输入文本变化时回调
- final ValueChanged? onChanged;
-
- /// 显示输入内容,如限制长度(LengthLimitingTextInputFormatter(6))
- final List? inputFormatters;
-
- /// controller 用户获取或者赋值输入内容
- final TextEditingController? controller;
-
- /// 最大输入行数
- final int maxLines;
-
- /// 获取或者取消焦点使用
- final FocusNode? focusNode;
-
- /// 是否自动获取焦点
- final bool autofocus;
-
- /// 是否隐藏输入的文字,一般用在密码输入框中
- final bool obscureText;
-
- /// 点击键盘完成按钮时触发的回调
- final VoidCallback? onEditingComplete;
-
- /// 点击键盘完成按钮时触发的回调, 参数值为输入的内容
- final ValueChanged? onSubmitted;
-
- /// 自定义输入框样式,默认圆角
- final InputDecoration? inputDecoration;
-
- /// 文本颜色
- final TextStyle? textStyle;
-
- /// 提示文本颜色,默认为文本颜色
- final TextStyle? hintTextStyle;
-
- /// 文本框背景色
- final Color? textInputBackgroundColor;
-
- /// 游标颜色
- final Color? cursorColor;
-
- /// 右侧按钮
- final Widget? rightBtn;
-
- /// 右侧按钮点击
- final GestureTapCallback? onTapBtn;
-
- /// textInput内边距
- final EdgeInsetsGeometry? contentPadding;
-
- /// 输入框类型
- final TDInputType type;
-
- /// 输入框规格
- final TDInputSize size;
-
- /// 输入框宽度
- final double? inputWidth;
-
- /// 最大字数限制
- final int? maxNum;
-
- /// 错误提示信息
- final String? errorText;
-
- /// 文字对齐方向
- final TextAlign? textAlign;
-
- /// 右侧自定义组件 特殊类型时生效
- final Widget? rightWidget;
-
-
- /// 获取输入框规格
- double getInputPadding() {
- switch(size) {
- case TDInputSize.small:
- return 12;
- case TDInputSize.large:
- return 16;
- }
- }
-
- Widget buildInputView(BuildContext context) {
- switch(type) {
- case TDInputType.normal:
- return buildNormalInput(context);
- case TDInputType.twoLine:
- return buildTwoLineInput(context);
- case TDInputType.special:
- return buildSpecialInput(context);
- case TDInputType.longText:
- return buildLongTextInput(context);
- }
- }
-
- Widget buildNormalInput(BuildContext context){
- return Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Container(
- alignment: Alignment.centerLeft,
- color: decoration != null ? null : backgroundColor,
- decoration: decoration,
- child: Row(
- crossAxisAlignment: errorText != '' ? CrossAxisAlignment.start : CrossAxisAlignment.center,
- children: [
- Visibility(
- visible: leftLabel != null,
- child: Padding(
- padding: EdgeInsets.only(left: 16, top: getInputPadding(), bottom: getInputPadding()),
- child: inputWidth != null ? SizedBox(
- width: inputWidth,
- child: TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontM,
- fontWeight: FontWeight.w400,
- ),
- ) : TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontM,
- fontWeight: FontWeight.w400,
- ),
- ),
- ),
- Visibility(
- visible: labelWidget != null,
- child: labelWidget ?? const SizedBox.shrink(),
- ),
- Expanded(
- flex: 1,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TDInputView(
- textStyle: textStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor1),
- readOnly: readOnly,
- autofocus: autofocus,
- obscureText: obscureText,
- onEditingComplete: onEditingComplete,
- onSubmitted: onSubmitted,
- hintText: hintText,
- inputType: inputType,
- onChanged: onChanged,
- inputFormatters: inputFormatters,
- inputDecoration: inputDecoration,
- maxLines: maxLines,
- focusNode: focusNode,
- isCollapsed: true,
- textAlign: textAlign,
- hintTextStyle: hintTextStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor3),
- cursorColor: cursorColor,
- textInputBackgroundColor: textInputBackgroundColor,
- controller: controller,
- contentPadding: contentPadding ?? EdgeInsets.only(left: 16, right: 16, bottom: errorText != '' ? 4 : getInputPadding(), top: getInputPadding()),
- ),
- Visibility(child: Padding(
- padding: EdgeInsets.only(left: 16, bottom: getInputPadding()),
- child: TDText(errorText, font: TDTheme.of(context).fontXS, textColor: TDTheme.of(context).fontGyColor3,),
- ), visible: errorText != '',)
- ],
- ),
- ),
- Visibility(
- visible: rightBtn != null,
- child: GestureDetector(
- onTap: onTapBtn,
- child: Container(
- margin: const EdgeInsets.only(left: 17.5, right: 17.5),
- child: rightBtn,
- ),
- ),
- ),
- ],
- ),
- ),
- const Visibility(child: TDDivider(margin: EdgeInsets.only(left: 16, ),),),
- ],
- );
- }
-
- Widget buildTwoLineInput(BuildContext context){
- return Container(
- alignment: Alignment.centerLeft,
- color: decoration != null ? null : backgroundColor,
- decoration: decoration,
- child: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Visibility(
- visible: leftLabel != null,
- child: Padding(
- padding: const EdgeInsets.only(left: 16, top: 12),
- child: inputWidth != null ? SizedBox(
- width: inputWidth,
- child: TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- ),
- ) : TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- ),
- ),
- ),
- Container(
- padding: const EdgeInsets.only(bottom: 12, top: 7),
- alignment: Alignment.center,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Visibility(
- visible: labelWidget != null,
- child: labelWidget ?? const SizedBox.shrink(),
- ),
- Expanded(
- flex: 1,
- child: TDInputView(
- textStyle: textStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor1),
- readOnly: readOnly,
- autofocus: autofocus,
- obscureText: obscureText,
- onEditingComplete: onEditingComplete,
- onSubmitted: onSubmitted,
- hintText: hintText,
- inputType: inputType,
- onChanged: onChanged,
- textAlign: textAlign,
- inputFormatters: inputFormatters,
- inputDecoration: inputDecoration,
- isCollapsed: true,
- maxLines: maxLines,
- focusNode: focusNode,
- hintTextStyle: hintTextStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor3),
- cursorColor: cursorColor,
- textInputBackgroundColor: textInputBackgroundColor,
- controller: controller,
- contentPadding: contentPadding ?? const EdgeInsets.only(left: 16, right: 16),
- ),
- ),
- Visibility(
- visible: rightBtn != null,
- child: GestureDetector(
- onTap: onTapBtn,
- child: Container(
- margin: const EdgeInsets.only(left: 17.5, right: 13.5),
- child: rightBtn,
- ),
- ),
- )
- ],
- ),
- ),
- ],
- ),
- const Visibility(child: TDDivider(margin: EdgeInsets.only(left: 16, ),),),
- ],
- ),
- );
- }
-
- Widget buildLongTextInput(BuildContext context){
- return Container(
- alignment: Alignment.centerLeft,
- color: decoration != null ? null : backgroundColor,
- decoration: decoration,
- height: leftLabel != null ? 197 : 148,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Visibility(
- visible: leftLabel != null,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: EdgeInsets.only(left: 16, top: getInputPadding(), bottom: getInputPadding()),
- child: TDText(
- leftLabel,
- maxLines: 2,
- fontWeight: FontWeight.w400,
- )
- ),
- const TDDivider(margin: EdgeInsets.only(left: 16, ),),
- ],
- ),
- ),
- Expanded(
- flex: 1,
- child: TDInputView(
- textStyle: textStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor1),
- readOnly: readOnly,
- autofocus: autofocus,
- obscureText: obscureText,
- onEditingComplete: onEditingComplete,
- onSubmitted: onSubmitted,
- hintText: hintText,
- inputType: inputType,
- textAlign: textAlign,
- onChanged: onChanged,
- inputFormatters: inputFormatters ?? [LengthLimitingTextInputFormatter(maxNum)],
- inputDecoration: inputDecoration,
- maxLines: maxLines,
- focusNode: focusNode,
- hintTextStyle: hintTextStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor3),
- cursorColor: cursorColor,
- textInputBackgroundColor: textInputBackgroundColor,
- controller: controller,
- contentPadding: contentPadding ?? const EdgeInsets.only(left: 16, right: 16, top: 12, bottom: 12),
- ),
- ),
- Container(
- alignment: Alignment.bottomRight,
- padding: const EdgeInsets.only(left: 16, right: 16, bottom: 12),
- child: TDText(
- '${controller?.text.length}/${maxNum}',
- font: TDTheme.of(context).fontXS,
- textColor: TDTheme.of(context).fontGyColor3,
- ),
- ),
- ],
- ),
- );
- }
-
- Widget buildSpecialInput(BuildContext context){
- return Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Container(
- alignment: Alignment.centerLeft,
- color: decoration != null ? null : backgroundColor,
- decoration: decoration,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Visibility(
- visible: leftLabel != null,
- child: Padding(
- padding: EdgeInsets.only(left: 16, top: getInputPadding(), bottom: getInputPadding()),
- child: inputWidth != null ? SizedBox(
- width: inputWidth,
- child: TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontM,
- fontWeight: FontWeight.w400,
- ),
- ) : TDText(
- leftLabel,
- maxLines: 1,
- font: TDTheme.of(context).fontM,
- fontWeight: FontWeight.w400,
- ),
- ),
- ),
- Visibility(
- visible: labelWidget != null,
- child: labelWidget ?? const SizedBox.shrink(),
- ),
- Row(
- children: [
- SizedBox(
- width: getTextSize(
- hintText ?? '',
- textStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor1, fontSize: 16),
- ).width + 12,
- child: TDInputView(
- textStyle: textStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor1),
- readOnly: readOnly,
- autofocus: autofocus,
- obscureText: obscureText,
- onEditingComplete: onEditingComplete,
- onSubmitted: onSubmitted,
- hintText: hintText,
- inputType: inputType,
- onChanged: onChanged,
- inputFormatters: inputFormatters,
- inputDecoration: inputDecoration,
- maxLines: maxLines,
- focusNode: focusNode,
- isCollapsed: true,
- hintTextStyle: hintTextStyle ?? TextStyle(color: TDTheme.of(context).fontGyColor3),
- cursorColor: cursorColor,
- textInputBackgroundColor: textInputBackgroundColor,
- controller: controller,
- textAlign: textAlign,
- contentPadding: contentPadding ?? EdgeInsets.only(right: 12, bottom: getInputPadding(), top: getInputPadding()),
- ),
- ),
- Visibility(
- visible: rightWidget != null,
- child: Container(
- margin: EdgeInsets.only(top: getInputPadding(), bottom: getInputPadding(), right: 12),
- child: rightWidget,
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- const Visibility(child: TDDivider(margin: EdgeInsets.only(left: 16, ),),),
- ],
- );
- }
-
- Size getTextSize(String text, [TextStyle? style]) {
- var painter = TextPainter(
- text: TextSpan(text: text, style: style),
- textDirection: TextDirection.ltr,
- maxLines: 1,
- ellipsis: '...',
- );
- painter.layout();
- return painter.size;
- }
-
- @override
- Widget build(BuildContext context) {
- var screenWidth = MediaQuery.of(context).size.width;
- return SizedBox(child: buildInputView(context), width: width ?? screenWidth, );
- }
-}
diff --git a/lib/src/components/loading/td_circle_indicator.dart b/lib/src/components/loading/td_circle_indicator.dart
deleted file mode 100644
index c0c6a5ac0..000000000
--- a/lib/src/components/loading/td_circle_indicator.dart
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/28/22.
- * td_circle_indicator.dart
- *
- */
-
-import 'dart:math';
-import 'dart:ui' as ui;
-
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-class TDCircleIndicator extends StatefulWidget {
- const TDCircleIndicator({
- Key? key,
- this.color,
- this.size = 20.0,
- this.lineWidth = 3.0
- }) : super(key: key);
-
- final Color? color;
- final double size;
- final double lineWidth;
-
- @override
- _TDCircleIndicatorState createState() => _TDCircleIndicatorState();
-}
-
-class _TDCircleIndicatorState extends State
- with SingleTickerProviderStateMixin {
- late AnimationController _controller;
- late Animation _animation1;
-
- @override
- void initState() {
- super.initState();
-
- _controller = AnimationController(
- vsync: this, duration: const Duration(milliseconds: 2000))
- ..addListener(() => setState(() {}))
- ..repeat();
- _animation1 = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
- parent: _controller,
- curve: const Interval(0.0, 1.0, curve: Curves.linear)));
- }
-
- @override
- void dispose() {
- _controller.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- var value = (_animation1.value) * 2 * pi;
- var paintColor = widget.color ?? TDTheme.of(context).brandColor8;
- return Transform(
- transform: Matrix4.identity()..rotateZ(value),
- alignment: FractionalOffset.center,
- child: SizedBox.fromSize(
- size: Size.square(widget.size),
- child: CustomPaint(
- painter: _CirclePaint(color: paintColor, width: widget.lineWidth),
- ),
- ),
- );
- }
-}
-
-
-class _CirclePaint extends CustomPainter {
- final Color color;
- final double width;
-
- _CirclePaint({required this.color, required this.width});
-
- final _paint = Paint()..style = PaintingStyle.stroke;
-
- @override
- void paint(Canvas canvas, Size size) {
- var minLength = min(size.width, size.height);
- _paint.strokeWidth = width;
- _paint.shader = ui.Gradient.sweep(Offset(size.width / 2, size.height / 2),
- [const Color(0x01ffffff), color]);
- if(minLength == size.width){
- canvas.drawArc(
- Rect.fromLTWH(0, (size.height - size.width) / 2, size.width, size.width), 0, pi * 2, false, _paint);
- } else {
- canvas.drawArc(
- Rect.fromLTWH((size.width - size.height) / 2, 0, size.height, size.height ), 0, pi * 2, false, _paint);
- }
- }
-
- @override
- bool shouldRepaint(CustomPainter oldDelegate) {
- return true;
- }
-}
diff --git a/lib/src/components/loading/td_loading.dart b/lib/src/components/loading/td_loading.dart
deleted file mode 100644
index 534112a67..000000000
--- a/lib/src/components/loading/td_loading.dart
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Created by haozhicao@tencent.com on 6/29/22.
- * td_loading.dart
- *
- */
-
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import 'td_activity_indicator.dart';
-import 'td_circle_indicator.dart';
-import 'td_point_indicator.dart';
-
-/// Loading 尺寸
-enum TDLoadingSize {
- small,
- medium,
- large,
-}
-
-/// Loading的图标
-enum TDLoadingIcon {
- circle,
- point,
- activity,
-}
-
-class TDLoading extends StatelessWidget {
- const TDLoading(
- {Key? key,
- required this.size,
- this.icon,
- this.iconColor,
- this.axis = Axis.vertical,
- this.text,
- this.customIcon,
- this.textColor = Colors.black})
- : super(key: key);
-
- final TDLoadingSize size;
- final TDLoadingIcon? icon;
- final Color? iconColor;
- final String? text;
- final Color textColor;
- final Axis axis;
- final Widget? customIcon;
-
- @override
- Widget build(BuildContext context) {
- return Material(
- type: MaterialType.transparency, //透明类型
- child: Center(
- //保证控件居中效果
- child: _contentWidget(),
- ),
- );
- }
-
- Widget _contentWidget() {
- if (icon == null) {
- return textWidget();
- } else {
- if(customIcon != null){
- return customIcon!;
- }
- Widget? indicator;
- switch (icon!) {
- case TDLoadingIcon.activity:
- indicator = TDCupertinoActivityIndicator(
- activeColor: iconColor,
- radius: size == TDLoadingSize.small
- ? 10
- : (size == TDLoadingSize.medium ? 11 : 13),
- );
- break;
- case TDLoadingIcon.circle:
- indicator = _getCircleIndicator();
- break;
- case TDLoadingIcon.point:
- indicator = TDPointBounceIndicator(
- color: iconColor,
- size: size == TDLoadingSize.small
- ? 12
- : (size == TDLoadingSize.medium ? 16 : 20),
- );
- break;
- default:
- indicator = _getCircleIndicator();
- break;
- }
-
- if (text == null) {
- return indicator;
- } else if (axis == Axis.vertical) {
- return Column(mainAxisAlignment: MainAxisAlignment.center, children: [
- indicator,
- SizedBox(
- height: _getPaddingWidth(),
- ),
- textWidget(),
- ]);
- } else {
- return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
- indicator,
- SizedBox(
- width: _getPaddingWidth(),
- ),
- textWidget()
- ]);
- }
- }
- }
-
- Widget _getCircleIndicator() {
- switch(size){
- case TDLoadingSize.large:
- return TDCircleIndicator(
- color: iconColor,
- size: 24,
- lineWidth: 3 * 4/3, // 根据small等等比缩放
- );
- case TDLoadingSize.medium:
- return TDCircleIndicator(
- color: iconColor,
- size: 21,
- lineWidth: 3 * 7/6, // 根据small等等比缩放
- );
- case TDLoadingSize.small:
- return TDCircleIndicator(
- color: iconColor,
- size: 18, // 设计稿框位24,图形宽位19.5,推导lineWidth为3时,size位18
- lineWidth: 3,
- );
- }
- }
-
- double _getPaddingWidth() {
- switch(size){
- case TDLoadingSize.large:
- return 10;
- case TDLoadingSize.medium:
- return 8;
- case TDLoadingSize.small:
- return 6;
- }
- }
-
- Font fitFont() {
- switch(size){
- case TDLoadingSize.large:
- return TDTheme.of().fontM ?? Font(size: 16, lineHeight: 24);
- case TDLoadingSize.medium:
- return TDTheme.of().fontS ?? Font(size: 14, lineHeight: 22);
- case TDLoadingSize.small:
- return TDTheme.of().fontXS ?? Font(size: 12, lineHeight: 20);
- }
- }
-
- Widget textWidget() {
- return TDText(
- text,
- textColor: textColor,
- fontWeight: FontWeight.w400,
- font: fitFont(),
- textAlign: TextAlign.center,
- );
- }
-}
diff --git a/lib/src/components/navbar/td_nav_bar.dart b/lib/src/components/navbar/td_nav_bar.dart
deleted file mode 100644
index 990475a28..000000000
--- a/lib/src/components/navbar/td_nav_bar.dart
+++ /dev/null
@@ -1,248 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-import '../../theme/td_spacers.dart';
-
-typedef TDBarItemAction = void Function();
-
-class TDNavBar extends StatefulWidget implements PreferredSizeWidget {
-
- const TDNavBar({
- Key? key,
- this.leftBarItems,
- this.rightBarItems,
- this.titleWidget,
- this.title,
- this.titleColor,
- this.titleFont,
- this.titleFontFamily,
- this.titleFontWeight = FontWeight.w500,
- this.centerTitle = true,
- this.opacity = 1.0,
- this.backgroundColor,
- this.titleMargin = 16,
- this.padding,
- this.height = 44,
- this.screenAdaptation = true,
- this.useDefaultBack = true,
- this.onBack,
- this.useBorderStyle = false,
- this.border,
- }) : super(key: key);
-
- final List? leftBarItems;
- final List? rightBarItems;
- final Widget? titleWidget;
- final String? title;
- final Color? titleColor;
- final Font? titleFont;
- final FontWeight? titleFontWeight;
- final FontFamily? titleFontFamily;
- final bool centerTitle;
- final double opacity;
- final Color? backgroundColor;
- final EdgeInsetsGeometry? padding;
-
- /// 中间文案左右两边间距
- final double titleMargin;
- final double height;
-
- /// 是否进行屏幕适配,默认true
- final bool screenAdaptation;
-
- /// 是否使用默认的返回
- final bool useDefaultBack;
-
- /// 返回事件
- final VoidCallback? onBack;
-
- /// 是否使用边框模式
- final bool useBorderStyle;
-
- /// 边框
- final TDNavBarItemBorder? border;
-
- @override
- State createState() => _TDNavBarState();
-
- @override
- Size get preferredSize => Size.fromHeight(height);
-}
-
-class _TDNavBarState extends State {
- Widget _addBorder(List items) {
- var border = widget.border ?? TDNavBarItemBorder();
- var borderColor = border.color ?? TDTheme.of(context).grayColor3;
- var children = [];
- for (var i = 0; i < items.length; i++) {
- children.add(items[i]);
- if (widget.useBorderStyle && i != items.length - 1) {
- children.add(
- Container(
- width: border.width,
- height: 16.0,
- color: borderColor,
- ),
- );
- }
- }
- var child = Row(
- children: children,
- mainAxisSize: MainAxisSize.min,
- );
- return Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(border.radius),
- border: Border.all(
- color: borderColor,
- width: border.width,
- ),
- ),
- padding: border.padding ??
- EdgeInsets.symmetric(horizontal: TDTheme.of(context).spacer4),
- child: child,
- );
- }
-
- Widget get backButton {
- return TDNavBarItem(
- icon: Icons.arrow_back_ios,
- action: () {
- widget.onBack?.call();
- Navigator.maybePop(context);
- },
- ).toWidget(context);
- }
-
- Widget _buildTitleBarItems(bool isLeft) {
- var barItems =
- (isLeft ? widget.leftBarItems : widget.rightBarItems) ?? [];
- var children = barItems
- .map(
- (e) => e.toWidget(context),
- )
- .toList();
-
- return Row(
- children: [
- if (isLeft && widget.useDefaultBack)
- backButton,
- if (children.isNotEmpty)
- widget.useBorderStyle
- ? _addBorder(children)
- : Row(
- children: children,
- mainAxisSize: MainAxisSize.min,
- ),
- ],
- mainAxisSize: MainAxisSize.min,
- );
- }
-
- TextStyle _getTitleStyle(BuildContext context) {
- var titleColor = widget.titleColor ?? TDTheme.of(context).fontGyColor1;
-
- var titleFont = widget.titleFont ?? TDTheme.of(context).fontM;
-
- return widget.titleFontFamily == null
- ? TextStyle(
- fontSize: titleFont?.size,
- color: titleColor,
- fontWeight: widget.titleFontWeight ?? FontWeight.w500,
- decoration: TextDecoration.none,
- )
- : TextStyle(
- fontSize: titleFont?.size,
- color: titleColor,
- fontWeight: widget.titleFontWeight ?? FontWeight.w500,
- decoration: TextDecoration.none,
- fontFamily: widget.titleFontFamily!.fontFamily,
- package: 'tdesign_flutter');
- }
-
- Widget _getTitleWidget(BuildContext context) {
- return widget.titleWidget ??
- Text(
- widget.title ?? '',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: _getTitleStyle(context),
- );
- }
-
- late final top = MediaQuery.of(context).padding.top;
-
- @override
- Widget build(BuildContext context) {
- var bcc = widget.backgroundColor ?? TDTheme.of(context).whiteColor1;
- if (bcc != Colors.transparent) {
- bcc = bcc.withOpacity(widget.opacity);
- }
-
- var paddingTop = widget.screenAdaptation ? top : 0.0;
- var padding = widget.padding ??
- EdgeInsets.symmetric(
- horizontal: TDTheme.of(context).spacer16,
- vertical: TDTheme.of(context).spacer4,
- );
-
- return Container(
- color: bcc,
- height: widget.height + paddingTop,
- padding: padding.add(EdgeInsets.only(top: paddingTop)),
- child: NavigationToolbar(
- leading: _buildTitleBarItems(true),
- middle: _getTitleWidget(context),
- trailing: _buildTitleBarItems(false),
- middleSpacing: widget.titleMargin,
- centerMiddle: widget.centerTitle,
- ),
- );
- }
-}
-
-class TDNavBarItem {
- IconData? icon;
- Color? iconColor;
- TDBarItemAction? action;
- double? iconSize;
- EdgeInsetsGeometry? padding;
- Widget? iconWidget;
-
- TDNavBarItem({
- this.icon,
- this.iconColor,
- this.action,
- this.iconSize = 16.0,
- this.padding,
- this.iconWidget,
- });
-
- Widget toWidget(BuildContext context) => GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: action,
- child: Padding(
- padding:
- padding ?? EdgeInsets.all(TDTheme.of(context).spacer8),
- child: iconWidget ??
- Icon(
- icon,
- size: iconSize,
- color: iconColor,
- ),
- ),
- );
-}
-
-class TDNavBarItemBorder {
- double width;
- double radius;
- Color? color;
- EdgeInsetsGeometry? padding;
-
- TDNavBarItemBorder({
- this.width = 1.0,
- this.radius = 22.0,
- this.color,
- this.padding,
- });
-}
diff --git a/lib/src/components/picker/no_wave_behavior.dart b/lib/src/components/picker/no_wave_behavior.dart
deleted file mode 100644
index edb46f938..000000000
--- a/lib/src/components/picker/no_wave_behavior.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'dart:io';
-
-import 'package:flutter/material.dart';
-import '../../util/platform_util.dart';
-
-/// 去掉ListView上下滑动的波纹
-class NoWaveBehavior extends ScrollBehavior {
- @override
- Widget buildOverscrollIndicator(
- BuildContext context, Widget child, ScrollableDetails details) {
- if (PlatformUtil.isAndroid || PlatformUtil.isFuchsia) {
- return child;
- } else {
- return super.buildOverscrollIndicator(context, child, details);
- }
- }
-}
diff --git a/lib/src/components/picker/td_date_picker.dart b/lib/src/components/picker/td_date_picker.dart
deleted file mode 100644
index e5596ad98..000000000
--- a/lib/src/components/picker/td_date_picker.dart
+++ /dev/null
@@ -1,519 +0,0 @@
-import 'dart:math';
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import 'no_wave_behavior.dart';
-
-typedef DatePickerCallback = void Function(Map selected);
-
-/// 时间选择器
-class TDDatePicker extends StatefulWidget {
- final String title; // 选择器标题
- final DatePickerCallback? onConfirm; // 选择器确认按钮回调
- final DatePickerCallback? onCancel; // 选择器取消按钮回调
- final Color? backgroundColor;
- final Color? titleDividerColor;
- final double? topRadius;
- final double? titleHeight;
- final double? leftPadding;
- final double? rightPadding;
-
- /// 根据距离计算字体颜色、透明度、粗细
- final ItemDistanceCalculator? itemDistanceCalculator;
-
- /// 选择器List的视窗高度,默认200
- final double pickerHeight;
-
- /// 选择器List视窗中item个数,pickerHeight / pickerItemCount即item高度
- final int pickerItemCount;
-
- /// 自定义选择框样式
- final Widget? customSelectWidget;
-
- /// 自定义左侧文案样式
- final TextStyle? leftTextStyle;
-
- /// 自定义右侧文案样式
- final TextStyle? rightTextStyle;
-
- /// 自定义中间文案样式
- final TextStyle? centerTextStyle;
-
- /// 适配padding
- final EdgeInsets? padding;
-
- /// 是否展示标题
- final bool showTitle;
-
- final DatePickerModel model;
-
-
- const TDDatePicker(
- {required this.title,
- required this.onConfirm,
- this.onCancel,
- this.backgroundColor,
- this.titleDividerColor,
- this.topRadius,
- this.titleHeight,
- this.padding,
- this.leftPadding,
- this.rightPadding,
- this.leftTextStyle,
- this.rightTextStyle,
- this.centerTextStyle,
- this.customSelectWidget,
- this.itemDistanceCalculator,
- required this.model,
- this.showTitle = true,
- this.pickerHeight = 200,
- required this.pickerItemCount,
- Key? key})
- : super(key: key);
-
- @override
- State createState() => _TDDatePickerState();
-}
-
-class _TDDatePickerState extends State {
-
- double pickerHeight = 0;
-
- @override
- void initState() {
- super.initState();
- pickerHeight = widget.pickerHeight;
- }
-
- @override
- Widget build(BuildContext context) {
- var maxWidth = MediaQuery.of(context).size.width;
- return Container(
- width: maxWidth,
- padding: widget.padding ?? EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
- decoration: BoxDecoration(
- color: widget.backgroundColor ?? TDTheme.of(context).whiteColor1,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(widget.topRadius ?? 0),
- topRight: Radius.circular(widget.topRadius ?? 0),
- ),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Visibility(child: buildTitle(context), visible: widget.showTitle == true,),
- Container(
- width: maxWidth,
- height: 0.5,
- color: widget.titleDividerColor ?? TDTheme.of(context).fontGyColor3,
- ),
- SizedBox(
- height: pickerHeight,
- child: Stack(
- alignment: Alignment.center,
- children: [
- widget.customSelectWidget ?? Container(
- height: 40,
- decoration: BoxDecoration(
- border: Border(
- top: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- bottom: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- )),
- ),
- SizedBox(
- height: pickerHeight,
- width: maxWidth,
- child: Row(
- children: [
- widget.model.useYear
- ? Expanded(child: buildList(context, 0))
- : Container(),
- widget.model.useMonth
- ? Expanded(child: buildList(context, 1))
- : Container(),
- widget.model.useDay
- ? Expanded(child: buildList(context, 2))
- : Container(),
- widget.model.useHour
- ? Expanded(child: buildList(context, 3))
- : Container(),
- widget.model.useMinute
- ? Expanded(child: buildList(context, 4))
- : Container(),
- widget.model.useSecond
- ? Expanded(child: buildList(context, 5))
- : Container(),
- ],
- ))
- ],
- ),
- )
- ],
- ),
- );
- }
-
- Widget buildList(context, int whichline) {
- /// whichline参数表示这个列表表示的是年,还是月还是日......
- var maxWidth = MediaQuery.of(context).size.width;
- return MediaQuery.removePadding(
- context: context,
- removeTop: true,
- child: ScrollConfiguration(
- behavior: NoWaveBehavior(),
- child: ListWheelScrollView.useDelegate(
- itemExtent: pickerHeight / widget.pickerItemCount,
- diameterRatio: 100,
- controller: widget.model.controllers[whichline],
- physics: const FixedExtentScrollPhysics(),
- onSelectedItemChanged: (index) {
- if (whichline == 0 || whichline == 1) {
- // 年月的改变会引起日的改变, 年的改变会引起月的改变
- setState(() {
- if (whichline == 0) {
- widget.model.refreshMonthDataAndController();
- }
- widget.model.refreshDayDataAndController();
-
- /// 使用动态高度,强制列表组件的state刷新,以展现更新的数据,详见下方链接
- /// FIX:https://github.com/flutter/flutter/issues/22999
- pickerHeight =
- pickerHeight - Random().nextDouble() / 100000000;
- });
- }
- },
- childDelegate: ListWheelChildBuilderDelegate(
- childCount: widget.model.data[whichline].length,
- builder: (context, index) {
- return Container(
- alignment: Alignment.center,
- height: pickerHeight / widget.pickerItemCount,
- width: maxWidth,
- child: TDItemWidget(
- index: index,
- itemHeight: pickerHeight / widget.pickerItemCount,
- content: widget.model.data[whichline][index].toString() +
- widget.model.mapping[whichline],
- fixedExtentScrollController:
- widget.model.controllers[whichline],
- itemDistanceCalculator: widget.itemDistanceCalculator,
- ));
- })),
- ));
- }
-
- Widget buildTitle(BuildContext context) {
- return Container(
- padding: EdgeInsets.only(
- left: widget.leftPadding ?? 16, right: widget.rightPadding ?? 16),
-
- /// 减去分割线的空间
- height: getTitleHeight() - 0.5,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- /// 左边按钮
- GestureDetector(
- onTap: () {
- if (widget.onCancel != null) {
- var selected = {
- 'year': widget.model.useYear
- ? widget.model.yearFixedExtentScrollController.selectedItem +
- widget.model.data[0][0]
- : -1,
- 'month': widget.model.useMonth
- ? widget.model.monthFixedExtentScrollController.selectedItem +
- widget.model.data[1][0]
- : -1,
- 'day': widget.model.useDay
- ? widget.model.dayFixedExtentScrollController.selectedItem +
- widget.model.data[2][0]
- : -1,
- 'hour': widget.model.useHour
- ? widget.model.hourFixedExtentScrollController.selectedItem
- : -1,
- 'minute': widget.model.useMinute
- ? widget.model.minuteFixedExtentScrollController.selectedItem
- : -1,
- 'second': widget.model.useSecond
- ? widget.model.secondFixedExtentScrollController.selectedItem
- : -1,
- };
- widget.onCancel!(selected);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '取消',
- style: widget.leftTextStyle?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).fontGyColor2
- )
- )),
-
- /// 中间title
- Expanded(
- child: Center(
- child: TDText(
- widget.title,
- style: widget.centerTextStyle ?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- fontWeight: FontWeight.w600,
- color: TDTheme.of(context).fontGyColor1,
- ),
- ),
- ),
- ),
-
- /// 右边按钮
- GestureDetector(
- onTap: () {
- if (widget.onConfirm != null) {
- var selected = {
- 'year': widget.model.useYear
- ? widget.model.yearFixedExtentScrollController.selectedItem +
- widget.model.data[0][0]
- : -1,
- 'month': widget.model.useMonth
- ? widget.model.monthFixedExtentScrollController.selectedItem +
- widget.model.data[1][0]
- : -1,
- 'day': widget.model.useDay
- ? widget.model.dayFixedExtentScrollController.selectedItem +
- widget.model.data[2][0]
- : -1,
- 'hour': widget.model.useHour
- ? widget.model.hourFixedExtentScrollController.selectedItem
- : -1,
- 'minute': widget.model.useMinute
- ? widget.model.minuteFixedExtentScrollController.selectedItem
- : -1,
- 'second': widget.model.useSecond
- ? widget.model.secondFixedExtentScrollController.selectedItem
- : -1,
- };
- widget.onConfirm!(selected);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '确认',
- style: widget.rightTextStyle?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).brandNormalColor
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- double getTitleHeight() => widget.titleHeight ?? 48;
-}
-
-// 时间选择器的数据类
-class DatePickerModel {
- bool useYear;
- bool useMonth;
- bool useDay;
- bool useHour;
- bool useMinute;
- bool useSecond;
- List dateStart;
- List dateEnd;
- List? dateInitial;
-
- final mapping = ['年', '月', '日', '时', '分', '秒'];
-
- late DateTime initialTime;
-
- /// 这三项随滑动而更新,注意初始化
- late int yearIndex;
- late int monthIndex;
- late int dayIndex;
-
- late List> data = [
- List.generate(
- dateEnd[0] - dateStart[0] + 1, (index) => index + dateStart[0]),
- [],
- [],
- List.generate(24, (index) => index),
- List.generate(60, (index) => index),
- List.generate(60, (index) => index),
- ];
- late var controllers;
- late FixedExtentScrollController yearFixedExtentScrollController;
- late FixedExtentScrollController monthFixedExtentScrollController;
- late FixedExtentScrollController dayFixedExtentScrollController;
- late FixedExtentScrollController hourFixedExtentScrollController;
- late FixedExtentScrollController minuteFixedExtentScrollController;
- late FixedExtentScrollController secondFixedExtentScrollController;
-
- DatePickerModel({
- required this.useYear,
- required this.useMonth,
- required this.useDay,
- required this.useHour,
- required this.useMinute,
- required this.useSecond,
- required this.dateStart,
- required this.dateEnd,
- this.dateInitial
- }) {
- setInitialTime();
- setInitialMonthData();
- setInitialDayData();
- setControllers();
- addListener();
- }
-
- void setInitialTime() {
- var startTime = DateTime(dateStart[0], dateStart[1], dateStart[2], 0, 0, 0);
- var endTime = DateTime(dateEnd[0], dateEnd[1], dateEnd[2], 0, 0, 0);
- if (dateInitial != null) {
- initialTime = DateTime(dateInitial![0], dateInitial![1], dateInitial![2], 0, 0, 0);
- if (initialTime.isBefore(startTime)) {
- initialTime = startTime;
- } else if (initialTime.isAfter(endTime)) {
- initialTime = endTime;
- }
- return;
- }
- var now = DateTime.now();
- if (now.year * 500 + now.month * 40 + now.day <
- dateStart[0] * 500 + dateStart[1] * 40 + dateStart[2]) {
- initialTime = DateTime(dateStart[0], dateStart[1], dateStart[2], now.hour,
- now.minute, now.second);
- } else if (now.year * 500 + now.month * 40 + now.day >
- dateEnd[0] * 500 + dateEnd[1] * 40 + dateEnd[2]) {
- initialTime = DateTime(
- dateEnd[0], dateEnd[1], dateEnd[2], now.hour, now.minute, now.second);
- } else {
- initialTime = now;
- }
- }
-
- void setInitialMonthData() {
- if (dateEnd[0] == dateStart[0]) {
- data[1] = List.generate(
- dateEnd[1] - dateStart[1] + 1, (index) => index + dateStart[1]);
- } else if (initialTime.year == dateStart[0]) {
- data[1] =
- List.generate(12 - dateStart[1] + 1, (index) => index + dateStart[1]);
- } else if (initialTime.year == dateEnd[0]) {
- data[1] = List.generate(dateEnd[1], (index) => index + 1);
- } else {
- data[1] = List.generate(12, (index) => index + 1);
- }
- }
-
- void setInitialDayData() {
- if (dateEnd[0] == dateStart[0] && dateEnd[1] == dateStart[1]) {
- data[2] = List.generate(
- dateEnd[2] - dateStart[2] + 1, (index) => index + dateStart[2]);
- } else if (initialTime.year == dateStart[0] &&
- initialTime.month == dateStart[1]) {
- data[2] = List.generate(
- DateTime(initialTime.year, initialTime.month + 1, 0).day -
- dateStart[2] +
- 1,
- (index) => index + dateStart[2]);
- } else if (initialTime.year == dateEnd[0] &&
- initialTime.month == dateEnd[1]) {
- data[2] = List.generate(dateEnd[2], (index) => index + 1);
- } else {
- data[2] = List.generate(
- DateTime(initialTime.year, initialTime.month + 1, 0).day,
- (index) => index + 1);
- }
- }
-
- void setControllers() {
- /// 初始化Index
- yearIndex = initialTime.year - data[0][0];
- monthIndex = initialTime.month - data[1][0];
- dayIndex = initialTime.day - data[2][0];
- controllers = [
- FixedExtentScrollController(initialItem: yearIndex),
- FixedExtentScrollController(initialItem: monthIndex),
- FixedExtentScrollController(initialItem: dayIndex),
- FixedExtentScrollController(initialItem: initialTime.hour),
- FixedExtentScrollController(initialItem: initialTime.minute),
- FixedExtentScrollController(initialItem: initialTime.second)
- ];
- yearFixedExtentScrollController = controllers[0];
- monthFixedExtentScrollController = controllers[1];
- dayFixedExtentScrollController = controllers[2];
- hourFixedExtentScrollController = controllers[3];
- minuteFixedExtentScrollController = controllers[4];
- secondFixedExtentScrollController = controllers[5];
- }
-
- void addListener() {
- /// 给年月日加上监控
- yearFixedExtentScrollController.addListener(() {
- yearIndex = yearFixedExtentScrollController.selectedItem;
- });
- monthFixedExtentScrollController.addListener(() {
- monthIndex = monthFixedExtentScrollController.selectedItem;
- });
- dayFixedExtentScrollController.addListener(() {
- dayIndex = dayFixedExtentScrollController.selectedItem;
- });
- }
-
- void refreshMonthDataAndController() {
- var selectedYear = yearIndex + data[0][0];
- if (dateEnd[0] == dateStart[0]) {
- data[1] = List.generate(
- dateEnd[1] - dateStart[1] + 1, (index) => index + dateStart[1]);
- } else if (selectedYear == dateStart[0]) {
- data[1] =
- List.generate(12 - dateStart[1] + 1, (index) => index + dateStart[1]);
- } else if (selectedYear == dateEnd[0]) {
- data[1] = List.generate(dateEnd[1], (index) => index + 1);
- } else {
- data[1] = List.generate(12, (index) => index + 1);
- }
- monthFixedExtentScrollController.jumpToItem(
- monthIndex > data[1].length - 1 ? data[1].length - 1 : monthIndex);
- }
-
- void refreshDayDataAndController() {
- /// 在刷新日数据时,年月数据已经是最新的
- var selectedYear = yearIndex + data[0][0];
- var selectedMonth = monthIndex + data[1][0];
- if (dateEnd[0] == dateStart[0] && dateEnd[1] == dateStart[1]) {
- data[2] = List.generate(
- dateEnd[2] - dateStart[2] + 1, (index) => index + dateStart[2]);
- } else if (selectedYear == dateStart[0] && selectedMonth == dateStart[1]) {
- data[2] = List.generate(
- DateTime(selectedYear, selectedMonth + 1, 0).day - dateStart[2] + 1,
- (index) => index + dateStart[2]);
- } else if (selectedYear == dateEnd[0] && selectedMonth == dateEnd[1]) {
- data[2] = List.generate(dateEnd[2], (index) => index + 1);
- } else {
- data[2] = List.generate(DateTime(selectedYear, selectedMonth + 1, 0).day,
- (index) => index + 1);
- }
- dayFixedExtentScrollController.jumpToItem(
- dayIndex > data[2].length - 1 ? data[2].length - 1 : dayIndex);
- }
-
- Map getSelectedMap() {
- var map = {
- 'year': yearIndex + data[0][0],
- 'month': monthIndex + data[1][0],
- 'day' : dayIndex + data[2][0],
- };
- return map;
- }
-
-}
-
diff --git a/lib/src/components/picker/td_item_widget.dart b/lib/src/components/picker/td_item_widget.dart
deleted file mode 100644
index e7fb8eed5..000000000
--- a/lib/src/components/picker/td_item_widget.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-/// 所有选择器的子项组件
-
-class TDItemWidget extends StatefulWidget {
- final String content;
- final FixedExtentScrollController fixedExtentScrollController;
- final int index;
- final double itemHeight;
- final ItemDistanceCalculator? itemDistanceCalculator;
-
-
- const TDItemWidget(
- {required this.fixedExtentScrollController,
- required this.index,
- required this.content,
- required this.itemHeight,
- this.itemDistanceCalculator,
- Key? key})
- : super(key: key);
-
- @override
- _TDItemWidgetState createState() => _TDItemWidgetState();
-}
-
-class _TDItemWidgetState extends State {
- /// 子项监听滚动,从而刷新自身的颜色
- VoidCallback? listener;
- ItemDistanceCalculator? _itemDistanceCalculator;
-
- @override
- void initState() {
- super.initState();
- listener = () => setState(() {});
- _itemDistanceCalculator = widget.itemDistanceCalculator;
-
- /// 子项注册滚动监听
- widget.fixedExtentScrollController.addListener(listener!);
- }
-
- @override
- Widget build(BuildContext context) {
- /// 子项此时离中心的距离
- /// 不要使用widget.fixedExtentScrollController.selectedItem
- /// 其中selectedItem会报错,原因是一开始minScrollExtent为空
- var distance =
- (widget.fixedExtentScrollController.offset / widget.itemHeight -
- widget.index)
- .abs()
- .toDouble();
- _itemDistanceCalculator ??= ItemDistanceCalculator();
- return TDText(widget.content,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontWeight: _itemDistanceCalculator!.calculateFontWeight(context, distance),
- fontSize: _itemDistanceCalculator!.calculateFont(context, distance),
- color: _itemDistanceCalculator!.calculateColor(context, distance)
- ));
- }
-
- @override
- void dispose() {
- /// 在销毁前完成监听注销
- widget.fixedExtentScrollController.removeListener(listener!);
- super.dispose();
- }
-}
-
-class ItemDistanceCalculator {
-
- ItemDistanceCalculator();
-
- Color calculateColor(BuildContext context, double distance) {
- /// 线性插值
- if (distance < 0.5) {
- return TDTheme.of(context).fontGyColor1;
- } else {
- return TDTheme.of(context).fontGyColor4;
- }
- }
-
- FontWeight calculateFontWeight(BuildContext context, double distance) {
- return FontWeight.w400;
- }
-
- double calculateFont(BuildContext context, double distance) {
- return TDTheme.of(context).fontM!.size;
- }
-}
diff --git a/lib/src/components/picker/td_multi_picker.dart b/lib/src/components/picker/td_multi_picker.dart
deleted file mode 100644
index 01add76f5..000000000
--- a/lib/src/components/picker/td_multi_picker.dart
+++ /dev/null
@@ -1,664 +0,0 @@
-import 'dart:math';
-
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-import 'no_wave_behavior.dart';
-
-typedef MultiPickerCallback = void Function(List selected);
-
-/// 项之间无联动的多项选择器
-class TDMultiPicker extends StatelessWidget {
- /// 选择器标题
- final String? title;
-
- /// 选择器确认按钮回调
- final MultiPickerCallback? onConfirm;
-
- /// 选择器取消按钮回调
- final MultiPickerCallback? onCancel;
-
- /// 选择器的数据源
- final List> data;
-
- /// 选择器List的视窗高度,默认200
- final double pickerHeight;
-
- /// 选择器List视窗中item个数,pickerHeight / pickerItemCount即item高度
- final int pickerItemCount;
-
- /// 自定义选择框样式
- final Widget? customSelectWidget;
-
- /// 自定义左侧文案样式
- final TextStyle? leftTextStyle;
-
- /// 自定义右侧文案样式
- final TextStyle? rightTextStyle;
-
- /// 自定义中间文案样式
- final TextStyle? centerTextStyle;
-
- final double? titleHeight;
- final double? topPadding;
- final double? leftPadding;
- final double? rightPadding;
- final Color? titleDividerColor;
- final Color? backgroundColor;
- final double? topRadius;
- final ItemDistanceCalculator? itemDistanceCalculator;
-
- /// 适配padding
- final EdgeInsets? padding;
-
- /// 若为null表示全部从零开始
- final List? initialIndexes;
-
-
-
- const TDMultiPicker(
- {required this.title,
- required this.onConfirm,
- this.onCancel,
- required this.data,
- required this.pickerHeight,
- required this.pickerItemCount,
- this.initialIndexes,
- this.leftTextStyle,
- this.rightTextStyle,
- this.centerTextStyle,
- this.titleHeight,
- this.topPadding,
- this.leftPadding,
- this.rightPadding,
- this.titleDividerColor,
- this.backgroundColor,
- this.topRadius,
- this.padding,
- this.itemDistanceCalculator,
- this.customSelectWidget,
- Key? key})
- : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- var lines = data.length;
- var indexes = initialIndexes ?? [for (var i = 0; i < lines; i++) 0];
- var controllers = [
- for (var i = 0; i < lines; i++)
- FixedExtentScrollController(initialItem: indexes[i])
- ];
- var maxWidth = MediaQuery.of(context).size.width;
- return Container(
- width: maxWidth,
- padding: padding ?? EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
- decoration: BoxDecoration(
- color: backgroundColor ?? TDTheme.of(context).whiteColor1,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(topRadius ?? 0),
- topRight: Radius.circular(topRadius ?? 0),
- ),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- buildTitle(context, controllers),
- Container(
- width: maxWidth,
- height: 0.5,
- color: titleDividerColor ?? TDTheme.of(context).fontGyColor3,
- ),
- Stack(
- alignment: Alignment.center,
- children: [
- customSelectWidget?? Container(
- height: 40,
- decoration: BoxDecoration(
- border: Border(
- top: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- bottom: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- )),
- ),
-
- // 列表
- SizedBox(
- height: pickerHeight,
- width: maxWidth,
- child: Row(
- children: [
- for (var i = 0; i < data.length; i++)
- Expanded(
- child: buildList(context, i, controllers),
- )
- ],
- )),
- ],
- ),
- ],
- ),
- );
- }
-
- Widget buildTitle(BuildContext context, List controllers) {
- return Container(
- padding:
- EdgeInsets.only(left: leftPadding ?? 16, right: rightPadding ?? 16),
-
- // 减去分割线的空间
- height: getTitleHeight() - 0.5,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- // 左边按钮
- GestureDetector(
- onTap: () {
- if (onCancel != null) {
- onCancel!([
- for (var i = 0; i < controllers.length; i++)
- controllers[i].selectedItem
- ]);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '取消',
- style: leftTextStyle?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).fontGyColor2
- ),
- )),
-
- // 中间title
- Expanded(
- child: title == null
- ? Container()
- : Center(
- child: TDText(
- title,
- style: centerTextStyle ?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- fontWeight: FontWeight.w600,
- color: TDTheme.of(context).fontGyColor1
- ),
- ),
- ),
- ),
-
- // 右边按钮
- GestureDetector(
- onTap: () {
- if (onConfirm != null) {
- onConfirm!([
- for (var i = 0; i < controllers.length; i++)
- controllers[i].selectedItem
- ]);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '确定',
- style: rightTextStyle?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).brandNormalColor
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- double getTitleHeight() => titleHeight ?? 48;
-
- Widget buildList(context, int position, List controllers) {
- var maxWidth = MediaQuery.of(context).size.width;
- return MediaQuery.removePadding(
- context: context,
- removeTop: true,
- child: ScrollConfiguration(
- behavior: NoWaveBehavior(),
- child: ListWheelScrollView.useDelegate(
- itemExtent: pickerHeight / pickerItemCount,
- diameterRatio: 100,
- controller: controllers[position],
- physics: const FixedExtentScrollPhysics(),
- childDelegate: ListWheelChildBuilderDelegate(
- childCount: data[position].length,
- builder: (context, index) {
- return Container(
- alignment: Alignment.center,
- height: pickerHeight / pickerItemCount,
- width: maxWidth,
- child: TDItemWidget(
- index: index,
- itemHeight: pickerHeight / pickerItemCount,
- content: data[position][index],
- itemDistanceCalculator: itemDistanceCalculator,
- fixedExtentScrollController: controllers[position],
- ));
- })),
- ));
- }
-}
-
-/// 多项联动选择器
-class TDMultiLinkedPicker extends StatefulWidget {
- /// 选择器标题
- final String? title;
-
- /// 选择器确认按钮回调
- final MultiPickerCallback? onConfirm;
-
- /// 选择器取消按钮回调
- final MultiPickerCallback? onCancel;
-
- /// 选中数据
- final List selectedData;
-
- /// 选择器的数据源
- final Map data;
-
- /// 最大列数
- final int columnNum;
-
- /// 选择器List的视窗高度
- final double pickerHeight;
-
- /// 选择器List视窗中item个数,pickerHeight / pickerItemCount即item高度
- final int pickerItemCount;
-
- /// 自定义选择框样式
- final Widget? customSelectWidget;
-
- /// 自定义左侧文案样式
- final TextStyle? leftTextStyle;
-
- /// 自定义右侧文案样式
- final TextStyle? rightTextStyle;
-
- /// 自定义中间文案样式
- final TextStyle? centerTextStyle;
-
- /// 适配padding
- final EdgeInsets? padding;
-
- final double? titleHeight;
- final double? topPadding;
- final double? leftPadding;
- final double? rightPadding;
- final Color? titleDividerColor;
- final Color? backgroundColor;
- final double? topRadius;
- final ItemDistanceCalculator? itemDistanceCalculator;
-
- const TDMultiLinkedPicker({
- this.title,
- required this.onConfirm,
- this.onCancel,
- required this.selectedData,
- required this.data,
- required this.columnNum,
- this.pickerHeight = 200,
- this.pickerItemCount = 5,
- this.customSelectWidget,
- this.leftTextStyle,
- this.rightTextStyle,
- this.centerTextStyle,
- this.titleHeight,
- this.topPadding,
- this.leftPadding,
- this.rightPadding,
- this.titleDividerColor,
- this.backgroundColor,
- this.topRadius,
- this.padding,
- this.itemDistanceCalculator,
- Key? key,
- }) : super(key: key);
-
- @override
- State createState() => _TDMultiLinkedPickerState();
-}
-
-class _TDMultiLinkedPickerState extends State {
- late MultiLinkedPickerModel model;
-
- double pickerHeight = 0;
-
- @override
- void initState() {
- super.initState();
- pickerHeight = widget.pickerHeight;
- model = MultiLinkedPickerModel(
- data: widget.data, columnNum: widget.columnNum, initialData: widget.selectedData);
- }
-
- @override
- Widget build(BuildContext context) {
- var maxWidth = MediaQuery.of(context).size.width;
- return Container(
- width: maxWidth,
- padding: widget.padding ?? EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
- decoration: BoxDecoration(
- color: widget.backgroundColor ?? TDTheme.of(context).whiteColor1,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(widget.topRadius ?? 0),
- topRight: Radius.circular(widget.topRadius ?? 0),
- ),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- buildTitle(context),
- Container(
- width: maxWidth,
- height: 0.5,
- color: widget.titleDividerColor ?? TDTheme.of(context).fontGyColor3,
- ),
- SizedBox(
- height: widget.pickerHeight,
- child: Stack(
- alignment: Alignment.center,
- children: [
- widget.customSelectWidget ?? Container(
- height: 40,
- decoration: BoxDecoration(
- border: Border(
- top: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- bottom: BorderSide(
- color: TDTheme.of(context).fontGyColor3, width: 0.5),
- )),
- ),
-
- // 列表
- SizedBox(
- height: pickerHeight,
- width: maxWidth,
- child: Row(
- children: [
- for (var i = 0; i < widget.columnNum; i++)
- Expanded(
- child: buildList(context, i),
- )
- ],
- )),
- ],
- ),
- )
- ],
- ),
- );
- }
-
- Widget buildList(context, int position) {
- // position参数表示这个第几列
- var maxWidth = MediaQuery.of(context).size.width;
- return MediaQuery.removePadding(
- context: context,
- removeTop: true,
- child: ScrollConfiguration(
- behavior: NoWaveBehavior(),
- child: ListWheelScrollView.useDelegate(
- itemExtent: pickerHeight / widget.pickerItemCount,
- diameterRatio: 100,
- controller: model.controllers[position],
- physics: const FixedExtentScrollPhysics(),
- onSelectedItemChanged: (index) {
- setState(() {
- // 刷新此列右边的所有数据
- model.refreshPresentDataAndController(position, index, false);
-
- // 使用动态高度,强制列表组件的state刷新,以展现更新的数据,详见下方链接
- // FIX:https://github.com/flutter/flutter/issues/22999
- pickerHeight =
- pickerHeight - Random().nextDouble() / 100000000;
- });
- },
- childDelegate: ListWheelChildBuilderDelegate(
- childCount: model.presentData[position].length,
- builder: (context, index) {
- return Container(
- alignment: Alignment.center,
- height: pickerHeight / widget.pickerItemCount,
- width: maxWidth,
- child: TDItemWidget(
- index: index,
- itemHeight: pickerHeight / widget.pickerItemCount,
- content:
- model.presentData[position][index].toString(),
- fixedExtentScrollController:
- model.controllers[position],
- itemDistanceCalculator: widget.itemDistanceCalculator,
- ));
- })),
- ));
- }
-
- Widget buildTitle(BuildContext context) {
- return Container(
- padding: EdgeInsets.only(
- left: widget.leftPadding ?? 16, right: widget.rightPadding ?? 16),
- height: getTitleHeight() - 0.5,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- // 左边按钮
- GestureDetector(
- onTap: () {
- if (widget.onCancel != null) {
- widget.onCancel!(model.selectedData);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '取消',
- style: widget.leftTextStyle ?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).fontGyColor2,
- ),
- )),
-
- // 中间title
- Expanded(
- child: widget.title == null
- ? Container()
- : Center(
- child: TDText(
- widget.title,
- style: widget.centerTextStyle ?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- fontWeight: FontWeight.w600,
- color: TDTheme.of(context).fontGyColor1
- ),
- ),
- ),
- ),
-
- // 右边按钮
- GestureDetector(
- onTap: () {
- if (widget.onConfirm != null) {
- widget.onConfirm!(model.selectedData);
- }
- Navigator.of(context).pop();
- },
- behavior: HitTestBehavior.opaque,
- child: TDText(
- '确定',
- style: widget.rightTextStyle ?? TextStyle(
- fontSize: TDTheme.of(context).fontM!.size,
- color: TDTheme.of(context).brandNormalColor,
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- double getTitleHeight() => widget.titleHeight ?? 48;
-}
-
-class MultiLinkedPickerModel {
- /// 占位字符
- static const placeData = '';
-
- /// 总的数据
- late Map data;
-
- /// 选中数据下标
- late List selectedIndexes;
-
- /// 总列数
- late int columnNum;
-
- /// 选中数据
- late List selectedData;
-
- late List controllers = [];
-
- /// 每一列展示的数据
- late List presentData = [];
-
- MultiLinkedPickerModel({
- required this.data,
- required this.columnNum,
- required List initialData,
- }) {
- selectedData = [];
- selectedIndexes = [];
- for (var i = 0; i < columnNum; ++i) {
- if (i >= initialData.length) {
- selectedData.add('');
- } else {
- selectedData.add(initialData[i]);
- }
- selectedIndexes.add(0);
- }
- _init(initialData);
- }
-
- void _init(List initialData) {
- int pIndex;
- controllers.clear();
- presentData.clear();
- for (var i = 0; i < columnNum; ++i) {
- pIndex = 0;
- if (i == 0) {
- // 第一列
- pIndex = data.keys.toList().indexOf(selectedData[i]);
- if (pIndex < 0) {
- selectedData[i] = data.keys.first;
- pIndex = 0;
- }
- selectedIndexes[i] = pIndex;
- presentData.add(data.keys.toList());
- } else {
- // 其他列
- dynamic date = findNextData(i);
- if (date is Map) {
- pIndex = date.keys.toList().indexOf(selectedData[i]);
- if (pIndex < 0) {
- selectedData[i] = date.keys.first;
- pIndex = 0;
- }
- presentData.add(date.keys.toList());
- } else if (date is List) {
- pIndex = date.indexOf(selectedData[i]);
- if (pIndex < 0) {
- selectedData[i] = date.first;
- pIndex = 0;
- }
- presentData.add(date);
- } else {
- selectedData[i] = date;
- pIndex = 0;
- presentData.add([date]);
- }
- selectedIndexes[i] = pIndex;
- }
- controllers.add(FixedExtentScrollController(initialItem: pIndex));
- }
- }
- /// 对应位置的下一列数据
- dynamic findNextData(int position) {
- dynamic nextData;
- for (var i = 0; i < position; i++) {
- if (i == 0) {
- nextData = data[selectedData[0]];
- } else {
- dynamic data = nextData[selectedData[i]];
- if (data is Map) {
- nextData = data;
- } else if (data is List) {
- nextData = data;
- } else {
- nextData = [data];
- }
- }
- if (!(nextData is Map) && (i < position - 1)) {
- return [placeData];
- }
- }
- return nextData;
- }
-
- /// [position] 变动的列
- /// [selectedIndex] 对应选中的index
- /// [jump] 是否需要jumpToItem
- void refreshPresentDataAndController(int position, int selectedIndex, bool jump) {
- // 新选中的数据
- var selectValue = presentData[position][selectedIndex];
- // 更新选中的数据
- selectedData[position] = selectValue;
- selectedIndexes[position] = selectedIndex;
- if (jump) {
- controllers[position].jumpToItem(selectedIndex);
- }
- // 如果不是最后一列 数据的变动都会造成剩下列的更新
- if (position < columnNum - 1) {
- if (presentData[position].length == 1 && presentData[position].first == placeData) {
- presentData[position + 1] = [placeData];
- } else {
- presentData[position + 1] = findColumnData(position + 1);
- }
- refreshPresentDataAndController(position + 1, 0, true);
- }
- }
-
- /// 寻找对应位置数据
- List findColumnData(int position) {
- dynamic nextData;
- for (var i = 0; i < position; i++) {
- if (i == 0) {
- nextData = data[selectedData[0]];
- } else {
- dynamic data = nextData[selectedData[i]];
- if (data is Map) {
- nextData = data;
- } else if (data is List) {
- nextData = data;
- } else {
- nextData = [data];
- }
- }
- // 如果是map并且是最后一列 返回对应key
- if ((nextData is Map) && (i == position - 1)) {
- return nextData.keys.toList();
- }
-
- // 如果数据还没有到最后就已经不是Map
- if (!(nextData is Map) && (i < position - 1)) {
- return [placeData];
- }
- }
- return nextData;
- }
-
-}
diff --git a/lib/src/components/picker/td_picker.dart b/lib/src/components/picker/td_picker.dart
deleted file mode 100644
index 66da68428..000000000
--- a/lib/src/components/picker/td_picker.dart
+++ /dev/null
@@ -1,104 +0,0 @@
-import 'package:flutter/material.dart';
-
-import 'td_date_picker.dart';
-import 'td_multi_picker.dart';
-
-class TDPicker {
- static void showDatePicker(context,
- {required String title,
- required DatePickerCallback? onConfirm,
- DatePickerCallback? onCancel,
- bool useYear = true,
- bool useMonth = true,
- bool useDay = true,
- bool useHour = false,
- bool useMinute = false,
- bool useSecond = false,
- List dateStart = const [1970, 1, 1],
- List? dateEnd,
- List? initialDate,
- Duration duration = const Duration(milliseconds: 100),
- double pickerHeight = 270,
- int pickerItemCount = 7}) {
- if (dateEnd == null || initialDate == null) {
- var now = DateTime.now();
- // 如果未指定结束时间,则取当前时间
- dateEnd ??= [now.year, now.month, now.day];
- initialDate ??= [now.year, now.month, now.day];
- }
- showModalBottomSheet(
- context: context,
- barrierColor: Colors.transparent,
- builder: (context) {
- return TDDatePicker(
- title: title,
- onConfirm: onConfirm,
- onCancel: onCancel,
- model: DatePickerModel(
- useYear: useYear,
- useMonth: useMonth,
- useDay: useDay,
- useHour: useHour,
- useMinute: useMinute,
- useSecond: useSecond,
- dateStart: dateStart,
- dateEnd: dateEnd!,
- dateInitial: initialDate
- ),
- pickerHeight: pickerHeight,
- pickerItemCount: pickerItemCount);
- });
- }
-
- static void showMultiPicker(context,
- {String? title,
- required MultiPickerCallback? onConfirm,
- MultiPickerCallback? onCancel,
- required List> data,
- List? initialIndexes,
- Duration duration = const Duration(milliseconds: 100),
- double pickerHeight = 270,
- int pickerItemCount = 7}) {
- showModalBottomSheet(
- context: context,
- barrierColor: Colors.transparent,
- builder: (context) {
- return TDMultiPicker(
- title: title,
- onConfirm: onConfirm,
- onCancel: onCancel,
- data: data,
- initialIndexes: initialIndexes,
- pickerHeight: pickerHeight,
- pickerItemCount: pickerItemCount,
- );
- });
- }
-
- static void showMultiLinkedPicker(context,
- {String? title,
- required MultiPickerCallback? onConfirm,
- MultiPickerCallback? onCancel,
- required Map data,
- required int columnNum,
- required List initialData,
- Duration duration = const Duration(milliseconds: 100),
- double pickerHeight = 248,
- int pickerItemCount = 7}) {
- showModalBottomSheet(
- context: context,
- barrierColor: Colors.transparent,
- builder: (context) {
- return TDMultiLinkedPicker(
- title: title,
- onConfirm: onConfirm,
- onCancel: onCancel,
- data: data,
- pickerHeight: pickerHeight,
- pickerItemCount: pickerItemCount,
- columnNum: columnNum,
- selectedData: initialData,
- );
- });
- }
-}
diff --git a/lib/src/components/popup/td_popup_route.dart b/lib/src/components/popup/td_popup_route.dart
deleted file mode 100644
index 78b94a103..000000000
--- a/lib/src/components/popup/td_popup_route.dart
+++ /dev/null
@@ -1,115 +0,0 @@
-import 'package:flutter/material.dart';
-
-const Duration _bottomSheetEnterDuration = Duration(milliseconds: 250);
-const Duration _bottomSheetExitDuration = Duration(milliseconds: 200);
-
-/// 从屏幕弹出的方向
-enum SlideTransitionFrom { top, right, left, bottom }
-
-///
-/// 从屏幕的某个方向滑动弹出的Dialog框的路由,比如从顶部、底部、左、右滑出页面
-///
-class TDSlidePopupRoute extends PopupRoute {
- TDSlidePopupRoute(
- {required this.builder,
- this.barrierLabel,
- this.modalBarrierColor,
- this.isDismissible = true,
- this.transitionAnimationController,
- this.slideTransitionFrom = SlideTransitionFrom.bottom});
-
- final WidgetBuilder builder;
- final Color? modalBarrierColor;
- final bool isDismissible;
- final AnimationController? transitionAnimationController;
-
- // 设置从屏幕的哪个方向滑出
- final SlideTransitionFrom slideTransitionFrom;
-
- @override
- Duration get transitionDuration => _bottomSheetEnterDuration;
-
- @override
- Duration get reverseTransitionDuration => _bottomSheetExitDuration;
-
- @override
- bool get barrierDismissible => isDismissible;
-
- @override
- final String? barrierLabel;
-
- @override
- Color get barrierColor => modalBarrierColor ?? Colors.black54;
-
- // 实现转场动画
- @override
- Widget buildTransitions(BuildContext context, Animation animation,
- Animation secondaryAnimation, Widget child) {
- var animValue = decelerateEasing.transform(animation.value);
-
- return AnimatedBuilder(
- animation: animation,
- child: child,
- builder: (context, child) {
- return CustomSingleChildLayout(
- delegate:
- SlideTransitionLayout(animValue, slideTransitionFrom),
- child: child,
- );
- });
- }
-
- @override
- Widget buildPage(BuildContext context, Animation animation,
- Animation secondaryAnimation) {
- return Material(
- child: builder.call(context),
- ) ;
- }
-}
-
-/// 从各个方向弹出的Transition
-/// progress为0到1区间的变化值
-///
-class SlideTransitionLayout extends SingleChildLayoutDelegate {
- final double progress;
- final SlideTransitionFrom slideTransitionFrom;
-
- SlideTransitionLayout(this.progress, this.slideTransitionFrom);
-
- @override
- BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
- return BoxConstraints(
- // minWidth: constraints.maxWidth,
- maxWidth: constraints.maxWidth,
- maxHeight: constraints.maxHeight);
- }
-
- @override
- Offset getPositionForChild(Size size, Size childSize) {
- var posY = 0.0;
- var posX = 0.0;
- // 弹出的方向
- switch (slideTransitionFrom) {
- case SlideTransitionFrom.top:
- posY = -(childSize.height - childSize.height * progress);
- break;
- case SlideTransitionFrom.left:
- posX = -(childSize.width - childSize.width * progress);
- break;
- case SlideTransitionFrom.right:
- posX = size.width - childSize.width * progress;
- break;
- case SlideTransitionFrom.bottom:
- posY = size.height - childSize.height * progress;
- break;
- }
- return Offset(posX, posY);
- }
-
- @override
- bool shouldRelayout(SlideTransitionLayout oldDelegate) {
- return progress != oldDelegate.progress ||
- slideTransitionFrom != oldDelegate.slideTransitionFrom;
- }
-}
diff --git a/lib/src/components/radio/td_radio.dart b/lib/src/components/radio/td_radio.dart
deleted file mode 100644
index 200663999..000000000
--- a/lib/src/components/radio/td_radio.dart
+++ /dev/null
@@ -1,167 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-enum TDRadioStyle {
- circle, // 圆形
- square, // 方形
- check, // 对号样式
-}
-
-///
-/// 单选框按钮
-///
-class TDRadio extends TDCheckbox {
- final TDRadioStyle radioStyle;
-
- const TDRadio({
- String? id,
- Key? key,
- String? title,
- String? subTitle,
- bool enable = true,
- int subTitleMaxLine = 1,
- int titleMaxLine = 1,
- Color? checkedColor,
- ContentBuilder? customContentBuilder,
- double? spacing,
- TDCheckBoxSize size = TDCheckBoxSize.small,
- this.radioStyle = TDRadioStyle.circle,
- TDContentDirection contentDirection = TDContentDirection.right,
- IconBuilder? customIconBuilder,
- }) : super(
- id: id,
- key: key,
- title: title,
- subTitle: subTitle,
- subTitleMaxLine: subTitleMaxLine,
- enable: enable,
- size: size,
- titleMaxLine: titleMaxLine,
- customContentBuilder: customContentBuilder,
- contentDirection: contentDirection,
- spacing: spacing,
- customIconBuilder: customIconBuilder,
- );
-
- @override
- Widget buildDefaultIcon(
- BuildContext context, TDCheckboxGroupState? groupState, bool isSelected) {
-
- TDRadioStyle? style ;
- if (groupState is TDRadioGroupState) {
- style = (groupState.widget as TDRadioGroup).radioStyle;
- }
-
- style = style ?? radioStyle;
-
- var size = 24.0;
- final theme = TDTheme.of(context);
- IconData? iconData;
- switch (style) {
- case TDRadioStyle.check:
- iconData = isSelected ? TDIcons.check : null;
- break;
- case TDRadioStyle.square:
- iconData = isSelected
- ? TDIcons.check_rectangle_filled
- : TDIcons.rectangle;
- break;
- default:
- iconData = isSelected
- ? TDIcons.check_circle_filled
- : TDIcons.circle;
- break;
- }
- if (iconData != null) {
- return Icon(
- iconData,
- size: size,
- color: !enable ? theme.grayColor4 : isSelected ? theme.brandColor8 : theme.grayColor4);
- } else {
- return SizedBox(width: size, height: size,);
- }
-
- }
-
- @override
- State createState() {
- return TDRadioState();
- }
-}
-
-class TDRadioState extends TDCheckboxState {
- @override
- Widget build(BuildContext context) {
- // 检查是否包含在FuiCheckBoxGroup内,如果是的话,状态由Group管理
- final groupState = TDCheckboxGroupInherited.of(context)?.state;
- if (groupState is TDRadioGroupState) {
- final strictMode = (groupState.widget as TDRadioGroup).strictMode;
- // 严格模式下不能取消选项,只能切换
- if (strictMode == true) {
- canNotCancel = true;
- }
- }
- return super.build(context);
- }
-}
-
-///
-/// RadioGroup分组对象
-///
-/// RadioGroup应该嵌套在RadioGroup内,所有在RadioGroup的RadioButton只能有一个被选中
-///
-///
-///
-class TDRadioGroup extends TDCheckboxGroup {
- ///
- /// 严格模式下,用户不能取消勾选,只能切换选择项,
- ///
- final bool strictMode;
- final TDRadioStyle? radioStyle;
-
- TDRadioGroup(
- {required Widget child,
- Key? key,
- String? selectId, // 默认选择项的id
- this.strictMode = true,
- this.radioStyle,
- int? titleMaxLine, // item的行数
- IconBuilder? customIconBuilder,
- ContentBuilder? customContentBuilder,
- double? spacing, // icon和文字距离
- TDContentDirection? contentDirection,
- OnRadioGroupChange? onRadioGroupChange}) // 切换监听
- : super(
- child: child,
- key: key,
- onChangeGroup: (ids) {
- onRadioGroupChange?.call(ids.isNotEmpty ? ids[0] : null);
- },
- controller: null,
- checkedIds: selectId != null ? [selectId] : null,
- maxChecked: 1,
- titleMaxLine: titleMaxLine,
- contentDirection: contentDirection,
- customIconBuilder: customIconBuilder,
- customContentBuilder: customContentBuilder,
- style: null,
- spacing: spacing,
- );
-
- @override
- State createState() {
- return TDRadioGroupState();
- }
-}
-
-class TDRadioGroupState extends TDCheckboxGroupState {
- @override
- bool toggle(String id, bool check, [bool notify = false]) {
- checkBoxStates.forEach((key, value) {
- checkBoxStates[key] = false;
- });
- return super.toggle(id, check, true);
- }
-}
-
-typedef OnRadioGroupChange = void Function(String? selectedId);
diff --git a/lib/src/components/radio/td_radio2.dart b/lib/src/components/radio/td_radio2.dart
deleted file mode 100644
index 80b4431b7..000000000
--- a/lib/src/components/radio/td_radio2.dart
+++ /dev/null
@@ -1,100 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-typedef OnCheckValueChanged = void Function(bool selected);
-
-enum TDRadioType {
- circle,
- square,
- check,
-}
-
-// ignore: must_be_immutable
-class TDRadio extends StatefulWidget {
- final TDRadioType type;
- bool? selected;
- final bool? disabled;
- final OnCheckValueChanged? onCheckValueChanged;
-
- TDRadio(
- {Key? key,
- this.type = TDRadioType.circle,
- this.selected = false,
- this.disabled = false,
- this.onCheckValueChanged})
- : super(key: key);
-
- @override
- State createState() => _TDRadioState();
-}
-
-class _TDRadioState extends State {
- bool selected = false;
-
- @override
- void initState() {
- selected = widget.selected ?? false;
- super.initState();
- }
-
- Color _getIconColor(BuildContext context) {
- if (widget.disabled == true) {
- return TDTheme.of(context).grayColor4;
- }
-
- return selected
- ? TDTheme.of(context).brandColor8
- : TDTheme.of(context).grayColor4;
- }
-
- Widget? _getRadioIcon(BuildContext context) {
- Widget? icon;
- switch (widget.type) {
- case TDRadioType.circle:
- icon = Icon(selected ? TDIcons.check_circle_filled : TDIcons.circle,
- size: 24, color: _getIconColor(context));
- break;
- case TDRadioType.square:
- icon = Icon(
- selected ? TDIcons.check_rectangle_filled : TDIcons.rectangle,
- size: 24,
- color: _getIconColor(context));
- break;
- case TDRadioType.check:
- icon = selected
- ? Icon(TDIcons.check, size: 24, color: _getIconColor(context))
- : const SizedBox(
- width: 0,
- height: 0,
- );
- break;
- }
-
- return icon;
- }
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- child: Container(
- width: 24,
- height: 24,
- color: Colors.transparent,
- child: _getRadioIcon(context),
- ),
- onTap: () {
- if (widget.disabled == true){
- return;
- }
-
- setState(() {
- selected = !selected;
- widget.selected = selected;
- if (widget.onCheckValueChanged != null) {
- widget.onCheckValueChanged!(selected);
- }
- });
- },
- );
- }
-}
diff --git a/lib/src/components/refresh/td_refresh_header.dart b/lib/src/components/refresh/td_refresh_header.dart
deleted file mode 100644
index 7830c572b..000000000
--- a/lib/src/components/refresh/td_refresh_header.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_easyrefresh/easy_refresh.dart';
-
-import '../../../td_export.dart';
-
-/// TDesign刷新头部
-class TDRefreshHeader extends Header {
-
- TDRefreshHeader({
- this.key,
- double extent = 48.0,
- double triggerDistance = 48.0,
- bool float = false,
- Duration? completeDuration,
- bool enableHapticFeedback = true,
- bool enableInfiniteRefresh = false,
- bool overScroll = true,
- this.loadingIcon = TDLoadingIcon.circle,
- }) : super(
- extent: extent,
- triggerDistance: triggerDistance,
- float: float,
- completeDuration: completeDuration,
- enableHapticFeedback: enableHapticFeedback,
- enableInfiniteRefresh: enableInfiniteRefresh,
- overScroll: overScroll,
- );
-
- /// Key
- final Key? key;
-
- /// loading样式
- final TDLoadingIcon loadingIcon;
-
- @override
- Widget contentBuilder(
- BuildContext context,
- RefreshMode refreshState,
- double pulledExtent,
- double refreshTriggerPullDistance,
- double refreshIndicatorExtent,
- AxisDirection axisDirection,
- bool float,
- Duration? completeDuration,
- bool enableInfiniteRefresh,
- bool success,
- bool noMore) {
- // 不能为水平方向
- assert(
- axisDirection == AxisDirection.down ||
- axisDirection == AxisDirection.up,
- 'Widget cannot be horizontal');
-
- return TDLoading(
- key: key,
- size: TDLoadingSize.medium,
- icon: loadingIcon,
- iconColor: TDTheme.of(context).brandColor8,
- );
- }
-}
diff --git a/lib/src/components/search/td_search_bar.dart b/lib/src/components/search/td_search_bar.dart
deleted file mode 100644
index c22865f41..000000000
--- a/lib/src/components/search/td_search_bar.dart
+++ /dev/null
@@ -1,289 +0,0 @@
-
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-typedef TDSearchBarEvent = void Function(String value);
-typedef TDSearchBarCallBack = void Function();
-
-class TDSearchBar extends StatefulWidget {
-
- const TDSearchBar({
- Key? key,
- this.placeHolder,
- this.onTextChanged,
- this.onSubmitted,
- this.onEditComplete,
- this.autoFocus = false,
- this.backgroundColor = Colors.white,
- }) : super(key: key);
-
- final String? placeHolder;
- final Color? backgroundColor;
- final bool autoFocus;
- final TDSearchBarEvent? onTextChanged;
- final TDSearchBarEvent? onSubmitted;
- final TDSearchBarCallBack? onEditComplete;
-
- @override
- State createState() => _TDSearchBarState();
-}
-
-enum _TDSearchBarStatus {
- unFocus,
- animatingToFocus,
- focused,
- animatingToUnFocus
-}
-
-class _TDSearchBarState extends State with TickerProviderStateMixin {
- final FocusNode focusNode = FocusNode();
- final TextEditingController controller = TextEditingController();
- final GlobalKey _textFieldKey = GlobalKey();
- final GlobalKey _phKey = GlobalKey();
-
- late AnimationController _animationController;
- Animation? _animation;
- bool clearBtnHide = true;
- bool cancelBtnHide = true;
- late _TDSearchBarStatus _status;
- @override
- void initState() {
- super.initState();
- _status = widget.autoFocus ? _TDSearchBarStatus.focused : _TDSearchBarStatus.unFocus;
- controller.addListener(() {
- var clearVisible = controller.text.isNotEmpty;
- _updateClearBtnVisible(clearVisible);
- });
- focusNode.addListener(() {
- setState(() {
- _status = focusNode.hasFocus ? _TDSearchBarStatus.focused : _TDSearchBarStatus.unFocus;
- });
- _updateCancelBtnVisible(focusNode.hasFocus);
- });
- _animationController = AnimationController(duration: const Duration(milliseconds: 200), vsync: this);
- _animationController.addStatusListener((status) {
- if(status == AnimationStatus.completed) {
- setState(() {
- if(_status == _TDSearchBarStatus.animatingToFocus) {
- _status = _TDSearchBarStatus.focused;
- focusNode.requestFocus();
- } else if(_status == _TDSearchBarStatus.animatingToUnFocus) {
- _status = _TDSearchBarStatus.unFocus;
- }
- });
- }
- });
- WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
- var box = _textFieldKey.currentContext?.findRenderObject() as RenderBox?;
- var phBox = _phKey.currentContext?.findRenderObject() as RenderBox?;
- if (box != null && phBox != null) {
- setState(() {
- var dx = (box.size.width / 2 + 16.5 - phBox.size.width / 2) / phBox.size.width;
- if(dx < 0) {
- return;
- }
- _animation ??=
- Tween(begin: Offset.zero, end: Offset(-dx, 0))
- .animate(_animationController);
- });
- }
- });
- }
-
- void _updateClearBtnVisible(bool visible) {
- setState(() {
- clearBtnHide = !visible;
- });
- }
-
- void _updateCancelBtnVisible(bool visible) {
- setState(() {
- cancelBtnHide = !visible;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
- height: 56,
- color: widget.backgroundColor,
- child: Stack(
- alignment: AlignmentDirectional.center,
- children: [
- Row(
- children: [
- Expanded(
- flex: 1,
- child: Container(
- height: double.infinity,
- decoration: BoxDecoration(
- color: TDTheme.of(context).grayColor1,
- borderRadius: BorderRadius.circular(4)),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- const SizedBox(
- width: 12,
- ),
- Visibility(
- visible: _status == _TDSearchBarStatus.focused || controller.text.isNotEmpty,
- child: Icon(
- TDIcons.search,
- size: 24,
- color: TDTheme.of(context).fontGyColor3,
- ),
- ),
- const Padding(padding: EdgeInsets.only(left: 3)),
- Expanded(
- flex: 1,
- child: TextField(
- key: _textFieldKey,
- controller: controller,
- autofocus: widget.autoFocus,
- cursorColor: TDTheme.of(context).brandColor8,
- cursorWidth: 1,
- cursorHeight: 18,
- focusNode: focusNode,
- onChanged: widget.onTextChanged,
- onSubmitted: widget.onSubmitted,
- style: TextStyle(
- fontSize: TDTheme.of(context).fontM?.size,
- color: TDTheme.of(context).fontGyColor1),
- decoration: InputDecoration(
- hintText:(_status != _TDSearchBarStatus.focused) ? '' : widget.placeHolder,
- hintStyle: TextStyle(
- fontSize: TDTheme.of(context).fontM?.size,
- color: TDTheme.of(context).fontGyColor3),
- border: InputBorder.none,
- isCollapsed: true,
- filled: true,
- fillColor: TDTheme.of(context).grayColor1,
- ),
- maxLines: 1,
- ),
- ),
- const Padding(padding: EdgeInsets.only(right: 9)),
- Offstage(
- offstage: clearBtnHide,
- child: GestureDetector(
- onTap: () {
- controller.clear();
- if (widget.onTextChanged != null) {
- widget.onTextChanged!('');
- }
- },
- child: Icon(
- TDIcons.close_circle_filled,
- size: 21,
- color: TDTheme.of(context).fontGyColor3,
- )),
- ),
- const Padding(padding: EdgeInsets.only(right: 9)),
- ],),),),
- Offstage(
- offstage: cancelBtnHide,
- child: GestureDetector(
- onTap: () {
- controller.clear();
- if (widget.onTextChanged != null) {
- widget.onTextChanged!('');
- }
- if(_animation == null) {
- focusNode.unfocus();
- setState(() {
- _status = _TDSearchBarStatus.unFocus;
- });
- return;
- }
- setState(() {
- _status = _TDSearchBarStatus.animatingToUnFocus;
- });
- focusNode.unfocus();
- _animationController.reverse(from: _animationController.upperBound);
- },
- child: Container(
- padding: const EdgeInsets.only(left: 16),
- child: Text('取消',
- style: TextStyle(
- fontSize: TDTheme.of(context).fontM?.size,
- color: TDTheme.of(context).brandColor8)),
- ),),),
- ],
- ),
- Offstage(offstage: (_status == _TDSearchBarStatus.focused || controller.text.isNotEmpty), child: GestureDetector(
- onTap: () {
- if(_status == _TDSearchBarStatus.animatingToFocus
- || _status == _TDSearchBarStatus.animatingToUnFocus) {
- return;
- }
- if(_animation == null) {
- focusNode.requestFocus();
- setState(() {
- _status = _TDSearchBarStatus.focused;
- });
- return;
- }
- setState(() {
- _status = _TDSearchBarStatus.animatingToFocus;
- _animationController.forward();
- });
- },
- child: Stack(children: [
- Container(color: TDTheme.of(context).grayColor1,),
- Center(child: _getPlaceHolderWidgets(),)
- ],)
- ),),
- ]),
- );
- }
-
- Widget _getPlaceHolderWidgets() {
- return LayoutBuilder(builder: (BuildContext context, BoxConstraints box) {
- if(_animation != null) {
- return SlideTransition(
- position: _animation!,
- child: Row(
- key: _phKey,
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(
- TDIcons.search,
- size: 24,
- color: TDTheme.of(context).fontGyColor3,
- ),
- Padding(
- padding: const EdgeInsets.only(left: 3),
- child: ConstrainedBox(constraints: BoxConstraints(maxWidth: box.maxWidth - 51,), child: TDText(
- widget.placeHolder,
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).fontGyColor3,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),),)],),
- );
- } else {
- return Row(
- key: _phKey,
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(
- TDIcons.search,
- size: 24,
- color: TDTheme.of(context).fontGyColor3,
- ),
- Padding(
- padding: const EdgeInsets.only(left: 3),
- child: ConstrainedBox(constraints: BoxConstraints(maxWidth: box.maxWidth - 51,), child: TDText(
- widget.placeHolder,
- font: TDTheme.of(context).fontM,
- textColor: TDTheme.of(context).fontGyColor3,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),),)],);
- }
- });
- }
-}
diff --git a/lib/src/components/switch/td_switch.dart b/lib/src/components/switch/td_switch.dart
deleted file mode 100644
index a0fd58554..000000000
--- a/lib/src/components/switch/td_switch.dart
+++ /dev/null
@@ -1,79 +0,0 @@
-import 'package:flutter/cupertino.dart';
-
-import '../../../td_export.dart';
-
-class TDSwitch extends StatefulWidget {
-
- const TDSwitch({
- Key? key,
- this.enable = true,
- this.isOn = false,
- this.onColor,
- this.offColor,
- this.onChanged,
- }): super(key: key);
-
- /// 是否可点击
- final bool enable;
-
- /// 是否打开
- final bool isOn;
-
- /// 开启颜色
- final Color? onColor;
-
- /// 关闭颜色
- final Color? offColor;
-
- ///改变事件
- final ValueChanged? onChanged;
-
- @override
- State createState() {
- return TDSwitchState();
- }
-}
-
-class TDSwitchState extends State {
-
- bool isOn = false;
-
- @override
- void initState() {
- super.initState();
- isOn = widget.isOn;
- }
-
- @override
- void didUpdateWidget(covariant TDSwitch oldWidget) {
- super.didUpdateWidget(oldWidget);
- isOn = widget.isOn;
- }
-
- @override
- Widget build(BuildContext context) {
- final theme = TDTheme.of(context);
- Widget current = CupertinoSwitch(
- value: isOn,
- activeColor: widget.onColor ?? theme.brandColor8,
- trackColor: widget.offColor ?? theme.grayColor4,
- onChanged: (value) {
- widget.onChanged?.call(value);
- isOn = value;
- setState(() {
-
- });
- },
- );
- if (!widget.enable) {
- current = Opacity(
- opacity: 0.4,
- child: IgnorePointer(
- ignoring: !widget.enable,
- child: current,
- ),
- );
- }
- return current;
- }
-}
diff --git a/lib/src/components/tabbar/td_tab.dart b/lib/src/components/tabbar/td_tab.dart
deleted file mode 100644
index 5d371e4ba..000000000
--- a/lib/src/components/tabbar/td_tab.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-import 'package:flutter/material.dart';
-
-class TDTab extends Tab {
- /// 文字内容
- @override
- final String? text;
-
- /// 子widget
- @override
- final Widget? child;
-
- /// 图标
- @override
- final Widget? icon;
-
- /// 图标间距
- @override
- final EdgeInsetsGeometry iconMargin;
-
- /// tab高度
- @override
- final double? height;
-
- @override
- const TDTab(
- {Key? key,
- this.text,
- this.child,
- this.icon,
- this.height,
- this.iconMargin = const EdgeInsets.only(bottom: 10.0)})
- : super(
- key: key,
- text: text,
- child: child,
- icon: icon,
- height: height,
- iconMargin: iconMargin);
-
- @override
- Widget build(BuildContext context) {
- return Tab(
- key: key,
- text: text,
- child: child,
- icon: icon,
- iconMargin: iconMargin,
- height: height,
- );
- }
-}
diff --git a/lib/src/components/tabbar/td_tab_bar.dart b/lib/src/components/tabbar/td_tab_bar.dart
deleted file mode 100644
index 49a16f042..000000000
--- a/lib/src/components/tabbar/td_tab_bar.dart
+++ /dev/null
@@ -1,324 +0,0 @@
-import 'dart:ui' as ui;
-
-import 'package:flutter/material.dart';
-
-import '../../../td_export.dart';
-import 'td_vertical_tab_bar.dart';
-
-bool isCustomStyle = false;
-
-class TDTabBar extends StatefulWidget {
-
- const TDTabBar(
- {Key? key,
- required this.tabs,
- this.controller,
- this.decoration,
- this.backgroundColor,
- this.indicatorColor,
- this.indicatorWidth,
- this.indicatorHeight,
- this.labelColor,
- this.unselectedLabelColor,
- this.isScrollable = false,
- this.unselectedLabelStyle,
- this.labelStyle,
- this.width,
- this.height,
- this.indicatorPadding,
- this.labelPadding,
- this.indicator,
- this.physics,
- this.onTap,
- this.isVertical = false,
- this.showIndicator = false})
- : assert(
- backgroundColor == null || decoration == null,
- 'Cannot provide both a backgroundColor and a decoration\n'
- 'To provide both, use "decoration: BoxDecoration(color: color)".',
- ),
- super(key: key);
-
- /// tab数组
- final List tabs;
-
- /// tab控制器
- final TabController? controller;
-
- /// tabBar修饰
- final Decoration? decoration;
-
- /// tabBar背景色
- final Color? backgroundColor;
-
- /// tabBar下标颜色
- final Color? indicatorColor;
-
- /// tabBar下标高度
- final double? indicatorHeight;
-
- /// tabBar下标宽度
- final double? indicatorWidth;
-
- /// tabBar 已选标签颜色
- final Color? labelColor;
-
- /// tabBar未选标签颜色
- final Color? unselectedLabelColor;
-
- /// 是否滚动
- final bool isScrollable;
-
- /// 已选label字体
- final TextStyle? labelStyle;
-
- /// unselectedLabel字体
- final TextStyle? unselectedLabelStyle;
-
- /// tabBar宽度
- final double? width;
-
- /// tabBar高度
- final double? height;
-
- /// 引导padding
- final EdgeInsets? indicatorPadding;
-
- /// 自定义引导控件
- final Decoration? indicator;
-
- /// 是否展示引导控件
- final bool showIndicator;
-
- /// 自定义滑动
- final ScrollPhysics? physics;
-
- /// 点击事件
- final Function(int)? onTap;
-
- /// tab间距
- final EdgeInsetsGeometry? labelPadding;
-
- /// 是否是竖向
- final bool isVertical;
-
- @override
- State createState() => _TDTabBarState();
-}
-
-class _TDTabBarState extends State {
- /// 默认高度
- static const double _defaultHeight = 46;
- static const double _defaultVerticalHeight = 54;
-
- @override
- Widget build(BuildContext context) {
- return Container(
- width: widget.width ?? MediaQuery.of(context).size.width,
- height: widget.isVertical
- ? widget.height ?? _defaultVerticalHeight * widget.tabs.length
- : widget.height ?? _defaultHeight,
- decoration:
- widget.decoration ?? BoxDecoration(color: widget.backgroundColor),
- child: widget.isVertical
- ? VerticalTabBar(
- selectedBackgroundColor: TDTheme.of(context).whiteColor1,
- physics: widget.physics,
- isScrollable: widget.isScrollable,
- indicator: widget.indicator ?? _getIndicator(context),
- indicatorColor:
- widget.indicatorColor ?? TDTheme.of(context).brandNormalColor,
- unselectedLabelColor: widget.unselectedLabelColor ??
- TDTheme.of(context).fontGyColor2,
- labelColor:
- widget.labelColor ?? TDTheme.of(context).brandNormalColor,
- labelStyle: widget.labelStyle ?? _getLabelStyle(context),
- labelPadding: widget.labelPadding,
- unselectedLabelStyle: widget.unselectedLabelStyle ??
- _getUnSelectLabelStyle(context),
- tabs: widget.tabs,
- indicatorPadding: widget.indicatorPadding ?? EdgeInsets.zero,
- controller: widget.controller,
- onTap: (index) {
- widget.onTap?.call(index);
- },
- )
- : TabBar(
- physics: widget.physics,
- isScrollable: widget.isScrollable,
- indicator: widget.indicator ?? _getIndicator(context),
- indicatorColor:
- widget.indicatorColor ?? TDTheme.of(context).brandNormalColor,
- unselectedLabelColor: widget.unselectedLabelColor ??
- TDTheme.of(context).fontGyColor2,
- labelColor:
- widget.labelColor ?? TDTheme.of(context).brandNormalColor,
- labelStyle: widget.labelStyle ?? _getLabelStyle(context),
- labelPadding: widget.labelPadding,
- unselectedLabelStyle: widget.unselectedLabelStyle ??
- _getUnSelectLabelStyle(context),
- tabs: widget.tabs,
- indicatorPadding: widget.indicatorPadding ?? EdgeInsets.zero,
- controller: widget.controller,
- onTap: (index) {
- widget.onTap?.call(index);
- },
- ),
- );
- }
-
- TextStyle _getUnSelectLabelStyle(BuildContext context) {
- return TextStyle(
- fontWeight: FontWeight.w400,
- fontSize: TDTheme.of(context).fontXS?.size ?? 14,
- color: TDTheme.of(context).fontGyColor2);
- }
-
- TextStyle _getLabelStyle(BuildContext context) {
- return TextStyle(
- fontWeight: FontWeight.w600,
- fontSize: TDTheme.of(context).fontXS?.size ?? 14,
- color: TDTheme.of(context).fontGyColor2);
- }
-
- Decoration _getIndicator(BuildContext context) {
- return widget.showIndicator
- ? widget.isVertical
- ? TDTabBarVerticalIndicator(
- context: context,
- indicatorHeight: widget.indicatorHeight,
- indicatorWidth: widget.indicatorWidth)
- : TDTabBarIndicator(
- context: context,
- indicatorHeight: widget.indicatorHeight,
- indicatorWidth: widget.indicatorWidth)
- : TDNoneIndicator();
- }
-}
-
-/// TDesign自定义下标
-class TDTabBarIndicator extends Decoration {
- final BuildContext? context;
- final double? indicatorWidth;
- final double? indicatorHeight;
-
- const TDTabBarIndicator(
- {this.context, this.indicatorWidth, this.indicatorHeight});
-
- @override
- BoxPainter createBoxPainter([VoidCallback? onChanged]) =>
- _TDTabBarIndicatorPainter(this, onChanged!);
-}
-
-class _TDTabBarIndicatorPainter extends BoxPainter {
- /// 下标宽度
- static const double _defaultIndicatorWidth = 56;
-
- /// 下标高度
- static const double _defaultIndicatorHeight = 1.5;
-
- final TDTabBarIndicator decoration;
-
- final _paint = Paint();
-
- _TDTabBarIndicatorPainter(this.decoration, VoidCallback onChanged) {
- if (isCustomStyle) {
- _paint.shader = ui.Gradient.linear(Offset.zero, Offset.zero, [
- TDTheme.of(decoration.context).brandNormalColor,
- TDTheme.of(decoration.context).brandNormalColor,
- ]);
- } else {
- /// 下标颜色
- _paint.color = TDTheme.of(decoration.context).brandNormalColor;
- }
- _paint.strokeCap = StrokeCap.round;
- }
-
- @override
- void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
- canvas.drawLine(
- Offset(offset.dx + (configuration.size!.width - _indicatorWidth()) / 2,
- configuration.size!.height - _indicatorHeight()),
- Offset(offset.dx + (configuration.size!.width + _indicatorWidth()) / 2,
- configuration.size!.height - _indicatorHeight()),
- _paint..strokeWidth = _indicatorHeight());
- }
-
- double _indicatorHeight() =>
- decoration.indicatorHeight ?? _defaultIndicatorHeight;
-
- double _indicatorWidth() =>
- decoration.indicatorWidth ?? _defaultIndicatorWidth;
-}
-
-/// TDesign自定义下标 竖向
-class TDTabBarVerticalIndicator extends Decoration {
- final BuildContext? context;
- final double? indicatorWidth;
- final double? indicatorHeight;
-
- const TDTabBarVerticalIndicator(
- {this.context, this.indicatorWidth, this.indicatorHeight});
-
- @override
- BoxPainter createBoxPainter([VoidCallback? onChanged]) =>
- _TDTabBarVerticalIndicatorPainter(this, onChanged!);
-}
-
-class _TDTabBarVerticalIndicatorPainter extends BoxPainter {
- /// 下标宽度
- static const double _defaultIndicatorWidth = 1.5;
-
- /// 下标高度
- static const double _defaultIndicatorHeight = 54;
-
- final TDTabBarVerticalIndicator decoration;
-
- final _paint = Paint();
-
- _TDTabBarVerticalIndicatorPainter(this.decoration, VoidCallback onChanged) {
- if (isCustomStyle) {
- _paint.shader = ui.Gradient.linear(Offset.zero, Offset.zero, [
- TDTheme.of(decoration.context).brandNormalColor,
- TDTheme.of(decoration.context).brandNormalColor,
- ]);
- } else {
- /// 下标颜色
- _paint.color = TDTheme.of(decoration.context).brandNormalColor;
- }
- _paint.strokeCap = StrokeCap.round;
- }
-
- @override
- void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
-
- canvas.drawLine(
- Offset(
- 0 + _indicatorWidth() / 2,
- offset.dx + (configuration.size!.width - _indicatorHeight()) / 2,
- ),
- Offset(
- 0 + _indicatorWidth() / 2,
- offset.dx + (configuration.size!.width + _indicatorHeight()) / 2,
- ),
- _paint..strokeWidth = _indicatorWidth());
- }
-
- double _indicatorHeight() =>
- decoration.indicatorHeight ?? _defaultIndicatorHeight;
-
- double _indicatorWidth() =>
- decoration.indicatorWidth ?? _defaultIndicatorWidth;
-}
-
-/// TDesign不展示下标
-class TDNoneIndicator extends Decoration {
- @override
- BoxPainter createBoxPainter([VoidCallback? onChanged]) =>
- _TDNoneIndicatorPainter();
-}
-
-class _TDNoneIndicatorPainter extends BoxPainter {
- @override
- void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {}
-}
diff --git a/lib/src/components/tabbar/td_tab_bar_vertical_view.dart b/lib/src/components/tabbar/td_tab_bar_vertical_view.dart
deleted file mode 100644
index f6114c7da..000000000
--- a/lib/src/components/tabbar/td_tab_bar_vertical_view.dart
+++ /dev/null
@@ -1,216 +0,0 @@
-import 'package:flutter/gestures.dart';
-import 'package:flutter/material.dart';
-
-class TDTabBarVerticalView extends StatefulWidget {
- const TDTabBarVerticalView({
- Key? key,
- required this.children,
- this.controller,
- this.physics,
- this.dragStartBehavior = DragStartBehavior.start,
- }) : super(key: key);
-
- final TabController? controller;
-
- final List children;
-
- final ScrollPhysics? physics;
-
- final DragStartBehavior dragStartBehavior;
-
- @override
- State createState() => _TDTabBarVerticalViewState();
-}
-
-class _TDTabBarVerticalViewState extends State {
- TabController? _controller;
- late PageController _pageController;
- late List _children;
- late List _childrenWithKey;
- int? _currentIndex;
- int _warpUnderwayCount = 0;
-
- // If the TabBarView is rebuilt with a new tab controller, the caller should
- // dispose the old one. In that case the old controller's animation will be
- // null and should not be accessed.
- bool get _controllerIsValid => _controller?.animation != null;
-
- void _updateTabController() {
- final newController = widget.controller ?? DefaultTabController.of(context);
- assert(() {
- if (newController == null) {
- throw FlutterError(
- 'No TabController for ${widget.runtimeType}.\n'
- 'When creating a ${widget.runtimeType}, you must either provide an explicit '
- 'TabController using the "controller" property, or you must ensure that there '
- 'is a DefaultTabController above the ${widget.runtimeType}.\n'
- 'In this case, there was neither an explicit controller nor a default controller.',
- );
- }
- return true;
- }());
-
- if (newController == _controller) {
- return;
- }
-
- if (_controllerIsValid) {
- _controller!.animation!.removeListener(_handleTabControllerAnimationTick);
- }
- _controller = newController;
- if (_controller != null) {
- _controller!.animation!.addListener(_handleTabControllerAnimationTick);
- }
- }
-
- @override
- void initState() {
- super.initState();
- _updateChildren();
- }
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- _updateTabController();
- _currentIndex = _controller?.index;
- _pageController = PageController(initialPage: _currentIndex ?? 0);
- }
-
- @override
- void didUpdateWidget(TDTabBarVerticalView oldWidget) {
- super.didUpdateWidget(oldWidget);
- if (widget.controller != oldWidget.controller) {
- _updateTabController();
- }
- if (widget.children != oldWidget.children && _warpUnderwayCount == 0) {
- _updateChildren();
- }
- }
-
- @override
- void dispose() {
- if (_controllerIsValid) {
- _controller!.animation!.removeListener(_handleTabControllerAnimationTick);
- }
- _controller = null;
- // We don't own the _controller Animation, so it's not disposed here.
- super.dispose();
- }
-
- void _updateChildren() {
- _children = widget.children;
- _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(widget.children);
- }
-
- void _handleTabControllerAnimationTick() {
- if (_warpUnderwayCount > 0 || !_controller!.indexIsChanging) {
- return;
- } // This widget is driving the controller's animation.
-
- if (_controller!.index != _currentIndex) {
- _currentIndex = _controller!.index;
- _warpToCurrentIndex();
- }
- }
-
- Future _warpToCurrentIndex() async {
- if (!mounted) {
- return Future.value();
- }
-
- if (_pageController.page == _currentIndex!.toDouble()) {
- return Future.value();
- }
-
- final previousIndex = _controller!.previousIndex;
- if ((_currentIndex! - previousIndex).abs() == 1) {
- _warpUnderwayCount += 1;
- await _pageController.animateToPage(_currentIndex!, duration: kTabScrollDuration, curve: Curves.ease);
- _warpUnderwayCount -= 1;
- return Future.value();
- }
-
- assert((_currentIndex! - previousIndex).abs() > 1);
- final initialPage = _currentIndex! > previousIndex
- ? _currentIndex! - 1
- : _currentIndex! + 1;
- final originalChildren = _childrenWithKey;
- setState(() {
- _warpUnderwayCount += 1;
-
- _childrenWithKey = List.from(_childrenWithKey, growable: false);
- final temp = _childrenWithKey[initialPage];
- _childrenWithKey[initialPage] = _childrenWithKey[previousIndex];
- _childrenWithKey[previousIndex] = temp;
- });
- _pageController.jumpToPage(initialPage);
-
- await _pageController.animateToPage(_currentIndex!, duration: kTabScrollDuration, curve: Curves.ease);
- if (!mounted) {
- return Future.value();
- }
- setState(() {
- _warpUnderwayCount -= 1;
- if (widget.children != _children) {
- _updateChildren();
- } else {
- _childrenWithKey = originalChildren;
- }
- });
- }
-
- // Called when the PageView scrolls
- bool _handleScrollNotification(ScrollNotification notification) {
- if (_warpUnderwayCount > 0) {
- return false;
- }
-
- if (notification.depth != 0) {
- return false;
- }
-
- _warpUnderwayCount += 1;
- if (notification is ScrollUpdateNotification && !_controller!.indexIsChanging) {
- if ((_pageController.page! - _controller!.index).abs() > 1.0) {
- _controller!.index = _pageController.page!.round();
- _currentIndex =_controller!.index;
- }
- _controller!.offset = (_pageController.page! - _controller!.index).clamp(-1.0, 1.0);
- } else if (notification is ScrollEndNotification) {
- _controller!.index = _pageController.page!.round();
- _currentIndex = _controller!.index;
- if (!_controller!.indexIsChanging) {
- _controller!.offset = (_pageController.page! - _controller!.index).clamp(-1.0, 1.0);
- }
- }
- _warpUnderwayCount -= 1;
-
- return false;
- }
-
- @override
- Widget build(BuildContext context) {
- assert(() {
- if (_controller!.length != widget.children.length) {
- throw FlutterError(
- "Controller's length property (${_controller!.length}) does not match the "
- "number of tabs (${widget.children.length}) present in TabBar's tabs property.",
- );
- }
- return true;
- }());
- return NotificationListener(
- onNotification: _handleScrollNotification,
- child: PageView(
- scrollDirection: Axis.vertical,
- dragStartBehavior: widget.dragStartBehavior,
- controller: _pageController,
- physics: widget.physics == null
- ? const NeverScrollableScrollPhysics()
- : const PageScrollPhysics().applyTo(widget.physics),
- children: _childrenWithKey,
- ),
- );
- }
-}
diff --git a/lib/src/components/tabbar/td_vertical_tab_bar.dart b/lib/src/components/tabbar/td_vertical_tab_bar.dart
deleted file mode 100644
index 0598c1610..000000000
--- a/lib/src/components/tabbar/td_vertical_tab_bar.dart
+++ /dev/null
@@ -1,940 +0,0 @@
-import 'dart:math' as math;
-import 'dart:ui' show lerpDouble;
-
-import 'package:flutter/foundation.dart';
-import 'package:flutter/gestures.dart' show DragStartBehavior;
-import 'package:flutter/material.dart';
-import 'package:flutter/rendering.dart';
-
-
-const double _kTabHeight = 54.0;
-const double _kTextAndIconTabHeight = 80.0;
-
-enum TabBarIndicatorSize {
- tab,
- label,
-}
-
-class Tab extends StatelessWidget implements PreferredSizeWidget {
- const Tab({
- Key? key,
- this.text,
- this.icon,
- this.iconMargin = const EdgeInsets.only(bottom: 10.0),
- this.height,
- this.child,
- }) : assert(text != null || child != null || icon != null),
- assert(text == null || child == null),
- super(key: key);
-
- final String? text;
- final Widget? child;
- final Widget? icon;
- final EdgeInsetsGeometry iconMargin;
- final double? height;
-
- Widget _buildLabelText() {
- return child ?? Text(text!, softWrap: false, overflow: TextOverflow.fade);
- }
-
- @override
- Widget build(BuildContext context) {
- assert(debugCheckHasMaterial(context));
-
- final double calculatedHeight;
- final Widget label;
- if (icon == null) {
- calculatedHeight = _kTabHeight;
- label = _buildLabelText();
- } else if (text == null && child == null) {
- calculatedHeight = _kTabHeight;
- label = icon!;
- } else {
- calculatedHeight = _kTextAndIconTabHeight;
- label = Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Container(
- margin: iconMargin,
- child: icon,
- ),
- _buildLabelText(),
- ],
- );
- }
-
- return SizedBox(
- height: height ?? calculatedHeight,
- child: Center(
- widthFactor: 1.0,
- child: label,
- ),
- );
- }
-
- @override
- void debugFillProperties(DiagnosticPropertiesBuilder properties) {
- super.debugFillProperties(properties);
- properties.add(StringProperty('text', text, defaultValue: null));
- properties.add(DiagnosticsProperty('icon', icon, defaultValue: null));
- }
-
- @override
- Size get preferredSize {
- if (height != null) {
- return Size.fromHeight(height!);
- } else if ((text != null || child != null) && icon != null) {
- return const Size.fromHeight(_kTextAndIconTabHeight);
- } else {
- return const Size.fromHeight(_kTabHeight);
- }
- }
-}
-
-class _TabStyle extends AnimatedWidget {
- const _TabStyle({
- Key? key,
- required Animation animation,
- required this.selected,
- required this.labelColor,
- required this.unselectedLabelColor,
- required this.labelStyle,
- required this.unselectedLabelStyle,
- required this.child,
- required this.selectedBackgroundColor,
- required this.unSelectedBackgroundColor,
- }) : super(key: key, listenable: animation);
-
- final TextStyle? labelStyle;
- final TextStyle? unselectedLabelStyle;
- final bool selected;
- final Color? labelColor;
- final Color? unselectedLabelColor;
- final Widget child;
- final Color? selectedBackgroundColor;
- final Color? unSelectedBackgroundColor;
-
- @override
- Widget build(BuildContext context) {
- final themeData = Theme.of(context);
- final tabBarTheme = TabBarTheme.of(context);
- final animation = listenable as Animation;
-
- // To enable TextStyle.lerp(style1, style2, value), both styles must have
- // the same value of inherit. Force that to be inherit=true here.
- final defaultStyle = (labelStyle
- ?? tabBarTheme.labelStyle
- ?? themeData.primaryTextTheme.bodyText1!
- ).copyWith(inherit: true);
- final defaultUnselectedStyle = (unselectedLabelStyle
- ?? tabBarTheme.unselectedLabelStyle
- ?? labelStyle
- ?? themeData.primaryTextTheme.bodyText1!
- ).copyWith(inherit: true);
- final textStyle = selected
- ? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value)!
- : TextStyle.lerp(defaultUnselectedStyle, defaultStyle, animation.value)!;
-
- final selectedColor = labelColor
- ?? tabBarTheme.labelColor
- ?? themeData.primaryTextTheme.bodyText1!.color!;
- final unselectedColor = unselectedLabelColor
- ?? tabBarTheme.unselectedLabelColor
- ?? selectedColor.withAlpha(0xB2); // 70% alpha
- final color = selected
- ? Color.lerp(selectedColor, unselectedColor, animation.value)!
- : Color.lerp(unselectedColor, selectedColor, animation.value)!;
- final backgroundColor = selected? selectedBackgroundColor ?? Colors.white : unSelectedBackgroundColor ?? const Color(0xFFF3F3F3);
-
- return Container(
- color: backgroundColor,
- child: DefaultTextStyle(
- style: textStyle.copyWith(color: color),
- child: IconTheme.merge(
- data: IconThemeData(
- size: 24.0,
- color: color,
- ),
- child: child,
- ),
- ),
- );
- }
-}
-
-typedef _LayoutCallback = void Function(List yOffsets, TextDirection textDirection, double width);
-
-class _TabLabelBarRenderer extends RenderFlex {
- _TabLabelBarRenderer({
- List? children,
- required Axis direction,
- required MainAxisSize mainAxisSize,
- required MainAxisAlignment mainAxisAlignment,
- required CrossAxisAlignment crossAxisAlignment,
- required TextDirection textDirection,
- required VerticalDirection verticalDirection,
- required this.onPerformLayout,
- }) : super(
- children: children,
- direction: direction,
- mainAxisSize: mainAxisSize,
- mainAxisAlignment: mainAxisAlignment,
- crossAxisAlignment: crossAxisAlignment,
- textDirection: textDirection,
- verticalDirection: verticalDirection,
- );
-
- _LayoutCallback onPerformLayout;
-
- @override
- void performLayout() {
- super.performLayout();
- var child = firstChild;
- final yOffsets = [];
- while (child != null) {
- final childParentData = child.parentData! as FlexParentData;
- yOffsets.add(childParentData.offset.dy);
- assert(child.parentData == childParentData);
- child = childParentData.nextSibling;
- }
- assert(textDirection != null);
- switch (textDirection!) {
- case TextDirection.rtl:
- yOffsets.insert(0, size.height);
- break;
- case TextDirection.ltr:
- yOffsets.add(size.height);
- break;
- }
- onPerformLayout(yOffsets, textDirection!, size.height);
- }
-}
-
-class _TabLabelBar extends Flex {
- _TabLabelBar({
- Key? key,
- List children = const [],
- required this.onPerformLayout,
- }) : super(
- key: key,
- children: children,
- direction: Axis.vertical,
- mainAxisSize: MainAxisSize.max,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- verticalDirection: VerticalDirection.down,
- );
-
- final _LayoutCallback onPerformLayout;
-
- @override
- RenderFlex createRenderObject(BuildContext context) {
- return _TabLabelBarRenderer(
- direction: direction,
- mainAxisAlignment: mainAxisAlignment,
- mainAxisSize: mainAxisSize,
- crossAxisAlignment: crossAxisAlignment,
- textDirection: getEffectiveTextDirection(context)!,
- verticalDirection: verticalDirection,
- onPerformLayout: onPerformLayout,
- );
- }
-
- @override
- void updateRenderObject(BuildContext context, _TabLabelBarRenderer renderObject) {
- super.updateRenderObject(context, renderObject);
- renderObject.onPerformLayout = onPerformLayout;
- }
-}
-
-double _indexChangeProgress(TabController controller) {
- final controllerValue = controller.animation!.value;
- final previousIndex = controller.previousIndex.toDouble();
- final currentIndex = controller.index.toDouble();
-
- if (!controller.indexIsChanging) {
- return (currentIndex - controllerValue).abs().clamp(0.0, 1.0);
- }
-
- return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs();
-}
-
-class _IndicatorPainter extends CustomPainter {
- _IndicatorPainter({
- required this.controller,
- required this.indicator,
- required this.indicatorSize,
- required this.tabKeys,
- required _IndicatorPainter? old,
- required this.indicatorPadding,
- }) : super(repaint: controller.animation) {
- if (old != null) {
- saveTabOffsets(old._currentTabOffsets, old._currentTextDirection);
- }
- }
-
- final TabController controller;
- final Decoration indicator;
- final TabBarIndicatorSize? indicatorSize;
- final EdgeInsetsGeometry indicatorPadding;
- final List tabKeys;
-
- List? _currentTabOffsets;
- TextDirection? _currentTextDirection;
-
- Rect? _currentRect;
- BoxPainter? _painter;
- bool _needsPaint = false;
- void markNeedsPaint() {
- _needsPaint = true;
- }
-
- void dispose() {
- _painter?.dispose();
- }
-
- void saveTabOffsets(List? tabOffsets, TextDirection? textDirection) {
- _currentTabOffsets = tabOffsets;
- _currentTextDirection = textDirection;
- }
-
- int get maxTabIndex => _currentTabOffsets!.length - 2;
-
- double centerOf(int tabIndex) {
- assert(_currentTabOffsets != null);
- assert(_currentTabOffsets!.isNotEmpty);
- assert(tabIndex >= 0);
- assert(tabIndex <= maxTabIndex);
- return (_currentTabOffsets![tabIndex] + _currentTabOffsets![tabIndex + 1]) / 2.0;
- }
-
- Rect indicatorRect(Size tabBarSize, int tabIndex) {
- assert(_currentTabOffsets != null);
- assert(_currentTextDirection != null);
- assert(_currentTabOffsets!.isNotEmpty);
- assert(tabIndex >= 0);
- assert(tabIndex <= maxTabIndex);
- double tabLeft, tabRight;
- switch (_currentTextDirection!) {
- case TextDirection.rtl:
- tabLeft = _currentTabOffsets![tabIndex + 1];
- tabRight = _currentTabOffsets![tabIndex];
- break;
- case TextDirection.ltr:
- tabLeft = _currentTabOffsets![tabIndex];
- tabRight = _currentTabOffsets![tabIndex + 1];
- break;
- }
-
- if (indicatorSize == TabBarIndicatorSize.label) {
- final tabHeight = tabKeys[tabIndex].currentContext!.size!.height;
- final delta = ((tabRight - tabLeft) - tabHeight) / 2.0;
- tabLeft += delta;
- tabRight -= delta;
- }
-
- final insets = indicatorPadding.resolve(_currentTextDirection);
- final rect = Rect.fromLTWH(tabLeft, 0.0, tabRight - tabLeft, tabBarSize.height);
-
- if (!(rect.size >= insets.collapsedSize)) {
- throw FlutterError(
- 'indicatorPadding insets should be less than Tab Size\n'
- 'Rect Size : ${rect.size}, Insets: ${insets.toString()}',
- );
- }
- return insets.deflateRect(rect);
- }
-
- @override
- void paint(Canvas canvas, Size size) {
- _needsPaint = false;
- _painter ??= indicator.createBoxPainter(markNeedsPaint);
-
- final index = controller.index.toDouble();
- final value = controller.animation!.value;
- final ltr = index > value;
- final from = (ltr ? value.floor() : value.ceil()).clamp(0, maxTabIndex);
- final to = (ltr ? from + 1 : from - 1).clamp(0, maxTabIndex);
- final fromRect = indicatorRect(size, from);
- final toRect = indicatorRect(size, to);
- _currentRect = Rect.lerp(fromRect, toRect, (value - from).abs());
- assert(_currentRect != null);
-
- final configuration = ImageConfiguration(
- size: _currentRect!.size,
- textDirection: _currentTextDirection,
- );
- _painter!.paint(canvas, _currentRect!.topLeft, configuration);
- }
-
- @override
- bool shouldRepaint(_IndicatorPainter old) {
- return _needsPaint
- || controller != old.controller
- || indicator != old.indicator
- || tabKeys.length != old.tabKeys.length
- || (!listEquals(_currentTabOffsets, old._currentTabOffsets))
- || _currentTextDirection != old._currentTextDirection;
- }
-}
-
-class _ChangeAnimation extends Animation with AnimationWithParentMixin {
- _ChangeAnimation(this.controller);
-
- final TabController controller;
-
- @override
- Animation get parent => controller.animation!;
-
- @override
- void removeStatusListener(AnimationStatusListener listener) {
- if (controller.animation != null) {
- super.removeStatusListener(listener);
- }
- }
-
- @override
- void removeListener(VoidCallback listener) {
- if (controller.animation != null) {
- super.removeListener(listener);
- }
- }
-
- @override
- double get value => _indexChangeProgress(controller);
-}
-
-class _DragAnimation extends Animation with AnimationWithParentMixin {
- _DragAnimation(this.controller, this.index);
-
- final TabController controller;
- final int index;
-
- @override
- Animation get parent => controller.animation!;
-
- @override
- void removeStatusListener(AnimationStatusListener listener) {
- if (controller.animation != null) {
- super.removeStatusListener(listener);
- }
- }
-
- @override
- void removeListener(VoidCallback listener) {
- if (controller.animation != null) {
- super.removeListener(listener);
- }
- }
-
- @override
- double get value {
- assert(!controller.indexIsChanging);
- final controllerMaxValue = (controller.length - 1).toDouble();
- final controllerValue = controller.animation!.value.clamp(0.0, controllerMaxValue);
- return (controllerValue - index.toDouble()).abs().clamp(0.0, 1.0);
- }
-}
-
-class _TabBarScrollPosition extends ScrollPositionWithSingleContext {
- _TabBarScrollPosition({
- required ScrollPhysics physics,
- required ScrollContext context,
- required ScrollPosition? oldPosition,
- required this.tabBar,
- }) : super(
- physics: physics,
- context: context,
- initialPixels: null,
- oldPosition: oldPosition,
- );
-
- final _TabBarState tabBar;
-
- bool? _initialViewportDimensionWasZero;
-
- @override
- bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) {
- var result = true;
- if (_initialViewportDimensionWasZero != true) {
- _initialViewportDimensionWasZero = viewportDimension != 0.0;
- correctPixels(tabBar._initialScrollOffset(viewportDimension, minScrollExtent, maxScrollExtent));
- result = false;
- }
- return super.applyContentDimensions(minScrollExtent, maxScrollExtent) && result;
- }
-}
-
-class _TabBarScrollController extends ScrollController {
- _TabBarScrollController(this.tabBar);
-
- final _TabBarState tabBar;
-
- @override
- ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition? oldPosition) {
- return _TabBarScrollPosition(
- physics: physics,
- context: context,
- oldPosition: oldPosition,
- tabBar: tabBar,
- );
- }
-}
-
-class VerticalTabBar extends StatefulWidget implements PreferredSizeWidget {
- const VerticalTabBar({
- Key? key,
- required this.tabs,
- this.selectedBackgroundColor,
- this.unSelectedBackgroundColor,
- this.controller,
- this.isScrollable = false,
- this.padding,
- this.indicatorColor,
- this.automaticIndicatorColorAdjustment = true,
- this.indicatorWeight = 2.0,
- this.indicatorPadding = EdgeInsets.zero,
- this.indicator,
- this.indicatorSize,
- this.labelColor,
- this.labelStyle,
- this.labelPadding,
- this.unselectedLabelColor,
- this.unselectedLabelStyle,
- this.dragStartBehavior = DragStartBehavior.start,
- this.overlayColor,
- this.mouseCursor,
- this.enableFeedback,
- this.onTap,
- this.physics,
- }) : assert(indicator != null || (indicatorWeight > 0.0)),
- super(key: key);
-
- final Color? selectedBackgroundColor;
-
- final Color? unSelectedBackgroundColor;
-
- final List tabs;
-
- final TabController? controller;
-
- final bool isScrollable;
-
- final EdgeInsetsGeometry? padding;
-
- final Color? indicatorColor;
-
- final double indicatorWeight;
-
- final EdgeInsetsGeometry indicatorPadding;
-
- final Decoration? indicator;
-
- final bool automaticIndicatorColorAdjustment;
-
- final TabBarIndicatorSize? indicatorSize;
-
- final Color? labelColor;
-
- final Color? unselectedLabelColor;
-
- final TextStyle? labelStyle;
-
- final EdgeInsetsGeometry? labelPadding;
-
- final TextStyle? unselectedLabelStyle;
-
- final MaterialStateProperty? overlayColor;
-
- final DragStartBehavior dragStartBehavior;
-
- final MouseCursor? mouseCursor;
-
- final bool? enableFeedback;
-
- final ValueChanged? onTap;
-
- final ScrollPhysics? physics;
-
- @override
- Size get preferredSize {
- var maxHeight = _kTabHeight;
- for (final item in tabs) {
- if (item is PreferredSizeWidget) {
- final itemHeight = item.preferredSize.height;
- maxHeight = math.max(itemHeight, maxHeight);
- }
- }
- return Size.fromHeight(maxHeight);
- }
-
- bool get tabHasTextAndIcon {
- for (final item in tabs) {
- if (item is PreferredSizeWidget) {
- if (item.preferredSize.height == _kTextAndIconTabHeight) {
- return true;
- }
- }
- }
- return false;
- }
-
- @override
- State createState() => _TabBarState();
-}
-
-class _TabBarState extends State {
- ScrollController? _scrollController;
- TabController? _controller;
- _IndicatorPainter? _indicatorPainter;
- int? _currentIndex;
- late double _tabStripWidth;
- late List _tabKeys;
-
- @override
- void initState() {
- super.initState();
- _tabKeys = widget.tabs.map((Widget tab) => GlobalKey()).toList();
- }
-
- Decoration get _indicator {
- if (widget.indicator != null) {
- return widget.indicator!;
- }
- final tabBarTheme = TabBarTheme.of(context);
- if (tabBarTheme.indicator != null) {
- return tabBarTheme.indicator!;
- }
-
- var color = widget.indicatorColor ?? Theme.of(context).indicatorColor;
- if (widget.automaticIndicatorColorAdjustment && color.value == Material.of(context)?.color?.value) {
- color = Colors.white;
- }
-
- return UnderlineTabIndicator(
- borderSide: BorderSide(
- width: widget.indicatorWeight,
- color: color,
- ),
- );
- }
-
- bool get _controllerIsValid => _controller?.animation != null;
-
- void _updateTabController() {
- final newController = widget.controller ?? DefaultTabController.of(context);
- assert(() {
- if (newController == null) {
- throw FlutterError(
- 'No TabController for ${widget.runtimeType}.\n'
- 'When creating a ${widget.runtimeType}, you must either provide an explicit '
- 'TabController using the "controller" property, or you must ensure that there '
- 'is a DefaultTabController above the ${widget.runtimeType}.\n'
- 'In this case, there was neither an explicit controller nor a default controller.',
- );
- }
- return true;
- }());
-
- if (newController == _controller) {
- return;
- }
-
- if (_controllerIsValid) {
- _controller!.animation!.removeListener(_handleTabControllerAnimationTick);
- _controller!.removeListener(_handleTabControllerTick);
- }
- _controller = newController;
- if (_controller != null) {
- _controller!.animation!.addListener(_handleTabControllerAnimationTick);
- _controller!.addListener(_handleTabControllerTick);
- _currentIndex = _controller!.index;
- }
- }
-
- void _initIndicatorPainter() {
- _indicatorPainter = !_controllerIsValid ? null : _IndicatorPainter(
- controller: _controller!,
- indicator: _indicator,
- indicatorSize: widget.indicatorSize ?? TabBarIndicatorSize.label,
- indicatorPadding: widget.indicatorPadding,
- tabKeys: _tabKeys,
- old: _indicatorPainter,
- );
- }
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- assert(debugCheckHasMaterial(context));
- _updateTabController();
- _initIndicatorPainter();
- }
-
- @override
- void didUpdateWidget(VerticalTabBar oldWidget) {
- super.didUpdateWidget(oldWidget);
- if (widget.controller != oldWidget.controller) {
- _updateTabController();
- _initIndicatorPainter();
- } else if (widget.indicatorColor != oldWidget.indicatorColor ||
- widget.indicatorWeight != oldWidget.indicatorWeight ||
- widget.indicatorSize != oldWidget.indicatorSize ||
- widget.indicator != oldWidget.indicator) {
- _initIndicatorPainter();
- }
-
- if (widget.tabs.length > oldWidget.tabs.length) {
- final delta = widget.tabs.length - oldWidget.tabs.length;
- _tabKeys.addAll(List.generate(delta, (int n) => GlobalKey()));
- } else if (widget.tabs.length < oldWidget.tabs.length) {
- _tabKeys.removeRange(widget.tabs.length, oldWidget.tabs.length);
- }
- }
-
- @override
- void dispose() {
- _indicatorPainter!.dispose();
- if (_controllerIsValid) {
- _controller!.animation!.removeListener(_handleTabControllerAnimationTick);
- _controller!.removeListener(_handleTabControllerTick);
- }
- _controller = null;
- // We don't own the _controller Animation, so it's not disposed here.
- super.dispose();
- }
-
- int get maxTabIndex => _indicatorPainter!.maxTabIndex;
-
- double _tabScrollOffset(int index, double viewportWidth, double minExtent, double maxExtent) {
- if (!widget.isScrollable) {
- return 0.0;
- }
- var tabCenter = _indicatorPainter!.centerOf(index);
- switch (Directionality.of(context)) {
- case TextDirection.rtl:
- tabCenter = _tabStripWidth - tabCenter;
- break;
- case TextDirection.ltr:
- break;
- }
- return (tabCenter - viewportWidth / 2.0).clamp(minExtent, maxExtent);
- }
-
- double _tabCenteredScrollOffset(int index) {
- final position = _scrollController!.position;
- return _tabScrollOffset(index, position.viewportDimension, position.minScrollExtent, position.maxScrollExtent);
- }
-
- double _initialScrollOffset(double viewportWidth, double minExtent, double maxExtent) {
- return _tabScrollOffset(_currentIndex!, viewportWidth, minExtent, maxExtent);
- }
-
- void _scrollToCurrentIndex() {
- final offset = _tabCenteredScrollOffset(_currentIndex!);
- _scrollController!.animateTo(offset, duration: kTabScrollDuration, curve: Curves.ease);
- }
-
- void _scrollToControllerValue() {
- final leadingPosition = _currentIndex! > 0 ? _tabCenteredScrollOffset(_currentIndex! - 1) : null;
- final middlePosition = _tabCenteredScrollOffset(_currentIndex!);
- final trailingPosition = _currentIndex! < maxTabIndex ? _tabCenteredScrollOffset(_currentIndex! + 1) : null;
-
- final index = _controller!.index.toDouble();
- final value = _controller!.animation!.value;
- final double offset;
- if (value == index - 1.0) {
- offset = leadingPosition ?? middlePosition;
- } else if (value == index + 1.0) {
- offset = trailingPosition ?? middlePosition;
- } else if (value == index) {
- offset = middlePosition;
- } else if (value < index) {
- offset = leadingPosition == null ? middlePosition : lerpDouble(middlePosition, leadingPosition, index - value)!;
- } else {
- offset = trailingPosition == null ? middlePosition : lerpDouble(middlePosition, trailingPosition, value - index)!;
- }
-
- _scrollController!.jumpTo(offset);
- }
-
- void _handleTabControllerAnimationTick() {
- assert(mounted);
- if (!_controller!.indexIsChanging && widget.isScrollable) {
- // Sync the TabBar's scroll position with the TabBarView's PageView.
- _currentIndex = _controller!.index;
- _scrollToControllerValue();
- }
- }
-
- void _handleTabControllerTick() {
- if (_controller!.index != _currentIndex) {
- _currentIndex = _controller!.index;
- if (widget.isScrollable) {
- _scrollToCurrentIndex();
- }
- }
- setState(() {});
- }
-
- void _saveTabOffsets(List tabOffsets, TextDirection textDirection, double width) {
- _tabStripWidth = width;
- _indicatorPainter?.saveTabOffsets(tabOffsets, textDirection);
- }
-
- void _handleTap(int index) {
- assert(index >= 0 && index < widget.tabs.length);
- _controller!.animateTo(index);
- widget.onTap?.call(index);
- }
-
- Widget _buildStyledTab(Widget child, bool selected, Animation animation) {
- return _TabStyle(
- animation: animation,
- selected: selected,
- selectedBackgroundColor: widget.selectedBackgroundColor,
- unSelectedBackgroundColor: widget.unSelectedBackgroundColor,
- labelColor: widget.labelColor,
- unselectedLabelColor: widget.unselectedLabelColor,
- labelStyle: widget.labelStyle,
- unselectedLabelStyle: widget.unselectedLabelStyle,
- child: child,
- );
- }
-
- @override
- Widget build(BuildContext context) {
- assert(debugCheckHasMaterialLocalizations(context));
- assert(() {
- if (_controller!.length != widget.tabs.length) {
- throw FlutterError(
- "Controller's length property (${_controller!.length}) does not match the "
- "number of tabs (${widget.tabs.length}) present in TabBar's tabs property.",
- );
- }
- return true;
- }());
- final localizations = MaterialLocalizations.of(context);
- if (_controller!.length == 0) {
- return Container(
- height: _kTabHeight,
- );
- }
-
- final tabBarTheme = TabBarTheme.of(context);
-
- final wrappedTabs = List.generate(widget.tabs.length, (int index) {
- const verticalAdjustment = (_kTextAndIconTabHeight - _kTabHeight)/2.0;
- EdgeInsetsGeometry? adjustedPadding;
-
- if (widget.tabs[index] is PreferredSizeWidget) {
- final tab = widget.tabs[index] as PreferredSizeWidget;
- if (widget.tabHasTextAndIcon && tab.preferredSize.height == _kTabHeight) {
- if (widget.labelPadding != null || tabBarTheme.labelPadding != null) {
- adjustedPadding = (widget.labelPadding ?? tabBarTheme.labelPadding!).add(const EdgeInsets.symmetric(vertical: verticalAdjustment));
- }
- else {
- adjustedPadding = const EdgeInsets.symmetric(vertical: verticalAdjustment, horizontal: 16.0);
- }
- }
- }
-
- return Center(
- child: Padding(
- padding: adjustedPadding ?? widget.labelPadding ?? tabBarTheme.labelPadding ?? kTabLabelPadding,
- child: KeyedSubtree(
- key: _tabKeys[index],
- child: widget.tabs[index],
- ),
- ),
- );
- });
-
- if (_controller != null) {
- final previousIndex = _controller!.previousIndex;
-
- if (_controller!.indexIsChanging) {
- // The user tapped on a tab, the tab controller's animation is running.
- assert(_currentIndex != previousIndex);
- final Animation animation = _ChangeAnimation(_controller!);
- wrappedTabs[_currentIndex!] = _buildStyledTab(wrappedTabs[_currentIndex!], true, animation);
- wrappedTabs[previousIndex] = _buildStyledTab(wrappedTabs[previousIndex], false, animation);
- } else {
- // The user is dragging the TabBarView's PageView left or right.
- final tabIndex = _currentIndex!;
- final Animation centerAnimation = _DragAnimation(_controller!, tabIndex);
- wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, centerAnimation);
- if (_currentIndex! > 0) {
- final tabIndex = _currentIndex! - 1;
- final Animation previousAnimation = ReverseAnimation(_DragAnimation(_controller!, tabIndex));
- wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, previousAnimation);
- }
- if (_currentIndex! < widget.tabs.length - 1) {
- final tabIndex = _currentIndex! + 1;
- final Animation nextAnimation = ReverseAnimation(_DragAnimation(_controller!, tabIndex));
- wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, nextAnimation);
- }
- }
- }
-
- final tabCount = widget.tabs.length;
- for (var index = 0; index < tabCount; index += 1) {
- wrappedTabs[index] = InkWell(
- mouseCursor: widget.mouseCursor ?? SystemMouseCursors.click,
- onTap: () { _handleTap(index); },
- enableFeedback: widget.enableFeedback ?? true,
- overlayColor: widget.overlayColor,
- child: Stack(
- children: [
- wrappedTabs[index],
- Semantics(
- selected: index == _currentIndex,
- label: localizations.tabLabel(tabIndex: index + 1, tabCount: tabCount),
- ),
- ],
- ),
- );
- if (!widget.isScrollable) {
- wrappedTabs[index] = Expanded(child: wrappedTabs[index]);
- }
- }
-
- Widget tabBar = CustomPaint(
- foregroundPainter: _indicatorPainter,
- child: _TabStyle(
- selectedBackgroundColor: widget.selectedBackgroundColor,
- unSelectedBackgroundColor: widget.unSelectedBackgroundColor,
- animation: kAlwaysDismissedAnimation,
- selected: false,
- labelColor: widget.labelColor,
- unselectedLabelColor: widget.unselectedLabelColor,
- labelStyle: widget.labelStyle,
- unselectedLabelStyle: widget.unselectedLabelStyle,
- child: _TabLabelBar(
- onPerformLayout: _saveTabOffsets,
- children: wrappedTabs,
- ),
- ),
- );
-
- if (widget.isScrollable) {
- _scrollController ??= _TabBarScrollController(this);
- tabBar = SingleChildScrollView(
- dragStartBehavior: widget.dragStartBehavior,
- scrollDirection: Axis.vertical,
- controller: _scrollController,
- padding: widget.padding,
- physics: widget.physics,
- child: tabBar,
- );
- } else if (widget.padding != null) {
- tabBar = Padding(
- padding: widget.padding!,
- child: tabBar,
- );
- }
-
- return tabBar;
- }
-}
-
diff --git a/lib/src/components/tag/td_tag.dart b/lib/src/components/tag/td_tag.dart
deleted file mode 100644
index 150062920..000000000
--- a/lib/src/components/tag/td_tag.dart
+++ /dev/null
@@ -1,254 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-/// 标签尺寸
-enum TDTagSize { large, middle, small, custom }
-
-/// 展示型标签组件,仅展示,内部不可更改自身状态
-/// 支持样式:方形/圆角/半圆/带关闭图标
-///
-class TDTag extends StatelessWidget {
-
- const TDTag(this.text,
- {
- this.textColor,
- this.backgroundColor,
- this.font,
- this.fontWeight,
- this.style,
- this.size = TDTagSize.middle,
- this.padding,
- this.forceVerticalCenter = true,
- this.needCloseIcon = false,
- this.onCloseTap,
- this.overflow,
- Key? key})
- : super(key: key);
-
- /// 标签内容
- final String text;
-
- /// 文字颜色, 优先级高于style的textColor
- final Color? textColor;
-
- /// 背景颜色, 优先级高于style的backgroundColor
- final Color? backgroundColor;
-
- /// 字体尺寸, 优先级高于style的font
- final Font? font;
-
- /// 字体粗细, 优先级高于style的fontWeight
- final FontWeight? fontWeight;
-
- /// 标签样式
- final TDTagStyle? style;
-
- /// 标签大小
- final TDTagSize size;
-
- /// 自定义模式下的间距
- final EdgeInsets? padding;
-
- /// 是否强制中文文字居中
- final bool forceVerticalCenter;
-
- /// 关闭图标
- final bool needCloseIcon;
-
- /// 文字溢出处理
- final TextOverflow? overflow;
-
- /// 关闭图标点击事件
- final GestureTapCallback? onCloseTap;
-
- @override
- Widget build(BuildContext context) {
- var innerStyle = style ?? RoundRectTagStyle(context: context);
-
- Widget child = TDText(
- text,
- overflow: overflow,
- forceVerticalCenter: forceVerticalCenter,
- textColor: textColor ?? innerStyle.getTextColor,
- font: font ?? innerStyle.font ?? _getFont(context),
- fontWeight: fontWeight ?? innerStyle.fontWeight,
- );
-
- if(needCloseIcon){
- child = Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- child,
- GestureDetector(
- onTap: onCloseTap,
- child: Container(
- margin: const EdgeInsets.only(left: 2),
- child: Icon(TDIcons.close, color: innerStyle.getTextColor, size: 12,),
- ),
- ),
- ],);
- }
-
- return Container(
- padding: padding ?? _getPadding(),
- decoration: BoxDecoration(
- color: backgroundColor ?? innerStyle.getBackgroundColor,
- border: Border.all(
- width: innerStyle.border,
- color: innerStyle.getWireFrameColor),
- borderRadius: innerStyle.getBorderRadius),
- child: child,
- );
- }
-
- Font? _getFont(BuildContext context) {
- switch (size) {
- case TDTagSize.large:
- return TDTheme.of(context).fontS;
- case TDTagSize.small:
- return TDTheme.of(context).fontXXS;
- default:
- return TDTheme.of(context).fontXS;
- }
- }
-
- EdgeInsets _getPadding() {
- /// 为了文本居中,修改了padding的值
- switch (size) {
- case TDTagSize.large:
- return const EdgeInsets.only(left: 15, right: 15, top: 3, bottom: 3);
- case TDTagSize.small:
- return const EdgeInsets.only(left: 7, right: 7, top: 1, bottom: 1);
- default:
- return const EdgeInsets.only(left: 11, right: 11, top: 1, bottom: 1);
- }
- }
-}
-
-/// 点击型标签组件,点击时内部更改自身状态
-/// 支持样式:方形/圆角/半圆/带关闭图标
-class TDSelectTag extends StatefulWidget {
- const TDSelectTag(this.text,{
- this.style,
- this.unSelectStyle,
- this.unEnableSelectStyle,
- this.onSelectChanged,
- this.isSelected = false,
- this.enableSelect = true,
- this.size = TDTagSize.middle,
- this.padding,
- this.forceVerticalCenter = true,
- this.needCloseIcon = false,
- this.onCloseTap,
- Key? key}) : super(key: key);
-
-
- /// 标签内容
- final String text;
-
- /// 标签样式
- final TDTagStyle? style;
-
- /// 未选中标签样式
- final TDTagStyle? unSelectStyle;
-
- /// 不可选标签样式
- final TDTagStyle? unEnableSelectStyle;
-
- /// 标签点击,选中状态改变时的回调
- final ValueChanged? onSelectChanged;
-
- /// 是否选中
- final bool isSelected;
-
- /// 是否可点击选择
- final bool enableSelect;
-
- /// 标签大小
- final TDTagSize size;
-
- /// 自定义模式下的间距
- final EdgeInsets? padding;
-
- /// 是否强制中文文字居中
- final bool forceVerticalCenter;
-
- /// 关闭图标
- final bool needCloseIcon;
-
- /// 关闭图标点击事件
- final GestureTapCallback? onCloseTap;
-
- @override
- _TDClickTagState createState() => _TDClickTagState();
-}
-
-class _TDClickTagState extends State {
-
- bool _isSelected = false;
-
- @override
- void initState() {
- super.initState();
- _isSelected = widget.isSelected;
- }
-
- @override
- Widget build(BuildContext context) {
- Widget result = TDTag(widget.text,
- style: _getStyle(),
- size: widget.size,
- padding: widget.padding,
- forceVerticalCenter: widget.forceVerticalCenter,
- needCloseIcon: widget.needCloseIcon,
- onCloseTap: widget.onCloseTap,);
- if(widget.enableSelect){
- result = GestureDetector(
- onTap: (){
- setState(() {
- _isSelected = !_isSelected;
- widget.onSelectChanged?.call(_isSelected);
- });
- },
- child: result,
- );
- }
- return result;
- }
-
- TDTagStyle? _getStyle() {
- if(!widget.enableSelect){
- return _getUnEnableSelectStyle();
- }
- return _isSelected ? widget.style : _getUnSelectStyle();
- }
-
- TDTagStyle _getUnEnableSelectStyle() {
- if(widget.unEnableSelectStyle != null){
- return widget.unEnableSelectStyle!;
- }
- return RoundRectTagStyle(
- context: context,
- textColor: TDTheme.of(context).fontGyColor4,
- backgroundColor: TDTheme.of(context).grayColor3,
- );
- }
-
- TDTagStyle _getUnSelectStyle() {
- if(widget.unSelectStyle != null){
- return widget.unSelectStyle!;
- }
- return RoundRectTagStyle(
- context: context,
- textColor: TDTheme.of(context).fontGyColor1,
- backgroundColor: TDTheme.of(context).grayColor3,
- );
- }
-
- @override
- void didUpdateWidget(covariant TDSelectTag oldWidget) {
- super.didUpdateWidget(oldWidget);
- _isSelected = widget.isSelected;
- }
-}
-
diff --git a/lib/src/components/tag/td_tag_styles.dart b/lib/src/components/tag/td_tag_styles.dart
deleted file mode 100644
index b4d2f8337..000000000
--- a/lib/src/components/tag/td_tag_styles.dart
+++ /dev/null
@@ -1,227 +0,0 @@
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-
-/// 标签样式
-class TDTagStyle {
- const TDTagStyle(
- {this.context,
- this.textColor,
- this.backgroundColor,
- this.font,
- this.fontWeight,
- this.border = 0,
- this.wireFrameColor,
- this.borderRadius});
-
- /// 上下文,方便获取主题内容
- final BuildContext? context;
-
- /// 文字颜色
- final Color? textColor;
-
- /// 背景颜色
- final Color? backgroundColor;
-
- /// 边框颜色
- final Color? wireFrameColor;
-
- /// 圆角
- final BorderRadiusGeometry? borderRadius;
-
- /// 字体尺寸
- final Font? font;
-
- /// 字体粗细
- final FontWeight? fontWeight;
-
- /// 线框粗细
- final double border;
-
- /// 字体颜色,与属性不同名,方便子类自定义处理
- Color get getTextColor => textColor ?? TDTheme.of(context).fontWhColor1;
-
- /// 背景颜色,与属性不同名,方便子类自定义处理
- Color get getBackgroundColor =>
- backgroundColor ?? TDTheme.of(context).brandNormalColor;
-
- /// 线框颜色,与属性不同名,方便子类自定义处理
- Color get getWireFrameColor => Colors.transparent;
-
- /// 圆角,,与属性不同名,方便子类自定义处理
- BorderRadiusGeometry get getBorderRadius => BorderRadius.circular(0);
-}
-
-
-/// 两端圆弧Style
-class CircleRectTagStyle extends TDTagStyle {
- CircleRectTagStyle({
- BuildContext? context,
- Color? textColor,
- Color? backgroundColor,
- Font? font,
- FontWeight? fontWeight,
- }) : super(
- context: context,
- textColor: textColor,
- backgroundColor: backgroundColor,
- font: font,
- fontWeight: fontWeight,
- );
-
- @override
- BorderRadiusGeometry get getBorderRadius => BorderRadius.circular(1000);
-}
-
-/// 右边端圆弧Style
-class SemicircleRectTagStyle extends TDTagStyle {
- SemicircleRectTagStyle({
- BuildContext? context,
- Color? textColor,
- Color? backgroundColor,
- Font? font,
- FontWeight? fontWeight,
- }) : super(
- context: context,
- textColor: textColor,
- backgroundColor: backgroundColor,
- font: font,
- fontWeight: fontWeight,
- );
-
- @override
- BorderRadiusGeometry get getBorderRadius =>
- const BorderRadius.horizontal(right: Radius.circular(1000));
-}
-
-
-/// 描边圆角矩形Style
-class WireframeRoundRectTagStyle extends TDTagStyle {
- /// 圆角半径
- final double radius;
-
- /// 是否为浅色背景
- final bool isLight;
-
- const WireframeRoundRectTagStyle({
- BuildContext? context,
- Color? textColor,
- Color? backgroundColor,
- Font? font,
- FontWeight? fontWeight,
- Color? wireFrameColor,
- double border = 1,
- this.isLight = false,
- this.radius = 2,
- }) : super(
- context: context,
- textColor: textColor,
- backgroundColor: backgroundColor,
- font: font,
- fontWeight: fontWeight,
- wireFrameColor: wireFrameColor,
- border: border,
- );
-
- @override
- Color get getBackgroundColor {
- if (backgroundColor != null) {
- return backgroundColor!;
- }
- return isLight
- ? TDTheme.of(context).brandColor2
- : TDTheme.of(context).whiteColor1;
- }
-
- @override
- BorderRadiusGeometry get getBorderRadius => BorderRadius.circular(radius);
-
- @override
- Color get getTextColor => textColor ?? TDTheme.of(context).brandNormalColor;
-
- @override
- Color get getWireFrameColor =>
- wireFrameColor ?? TDTheme.of(context).brandNormalColor;
-}
-
-/// Tag展示类型
-enum TDTagType {
- /// 常规
- normal,
-
- /// 成功
- success,
-
- /// 警告
- warning,
-
- /// 错误
- error,
-
- /// 信息
- message,
-}
-
-/// 常规圆角矩形Style
-class RoundRectTagStyle extends WireframeRoundRectTagStyle {
- /// 展示类型
- final TDTagType type;
-
- const RoundRectTagStyle(
- {BuildContext? context,
- Color? textColor,
- Color? backgroundColor,
- Font? font,
- FontWeight? fontWeight,
- this.type = TDTagType.normal,
- double radius = 2,
- bool isLight = false})
- : super(
- context: context,
- textColor: textColor,
- backgroundColor: backgroundColor,
- font: font,
- fontWeight: fontWeight,
- radius: radius,
- isLight: isLight,
- border: 0,
- );
-
- @override
- Color get getBackgroundColor {
- if (backgroundColor != null) {
- return backgroundColor!;
- }
- if (isLight) {
- return TDTheme.of(context).brandColor2;
- }
- switch (type) {
- case TDTagType.normal:
- return TDTheme.of(context).brandNormalColor;
- case TDTagType.success:
- return TDTheme.of(context).successNormalColor;
- case TDTagType.warning:
- return TDTheme.of(context).warningNormalColor;
- case TDTagType.error:
- return TDTheme.of(context).errorNormalColor;
- case TDTagType.message:
- return TDTheme.of(context).grayColor7;
- default:
- return TDTheme.of(context).whiteColor1;
- }
- }
-
- @override
- Color get getTextColor {
- if (textColor != null) {
- return textColor!;
- }
- if (isLight) {
- return TDTheme.of(context).brandNormalColor;
- } else {
- return TDTheme.of(context).fontWhColor1;
- }
- }
-
- @override
- Color get getWireFrameColor => Colors.transparent;
-}
diff --git a/lib/src/components/text/td_text.dart b/lib/src/components/text/td_text.dart
deleted file mode 100644
index ce62f5617..000000000
--- a/lib/src/components/text/td_text.dart
+++ /dev/null
@@ -1,394 +0,0 @@
-import 'dart:math';
-import 'dart:ui' as ui show TextHeightBehavior;
-
-import 'package:flutter/gestures.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-
-import '../../../td_export.dart';
-import '../../util/platform_util.dart';
-
-/// 文本控件
-/// 设计原则:
-/// 1.为了使用更方便,所以对系统组件进行的扩展,需兼容系统控件所有功能,不能让用户使用TDesign时,因不能满足系统功能而弃用。
-/// 2.非系统已有属性,尽量添加注释
-///
-/// 需求:把一部分在TextStyle中的属性扁平化,放到外层。
-/// 1.暴露系统的所有属性,支持系统所有操作
-/// 2.约束使用主题配置的几种字体
-/// 3.提供转换为系统Text的方法,以使某些系统组件指定接收系统Text时可使用。(Image组件同理)
-/// 4.支持自定义TextStyle
-/// 5.兼容TextSpan形式
-///
-/// 技巧:
-/// 命名参数替换属性的正则:
-/// 第一步,把Text中的可选参数拷贝过来,变成如下格式:
-/// Text(data,
-/// this.style,
-/// this.strutStyle,
-/// ……)
-/// 第二步,正则替换如下:
-/// 匹配(前半有默认值,后半无默认值):this\.([a-z|A-Z]+)[ ]*[\=]+[ ]*[a-z|A-Z]+\,|this\.([a-z|A-Z]+)\,
-/// 替换:$1$2: this.$1$2,
-///
-class TDText extends StatelessWidget {
-
- const TDText(this.data,
- {
- this.font,
- this.fontWeight = FontWeight.w400,
- this.fontFamily,
- this.textColor = Colors.black,
- this.backgroundColor,
- this.isTextThrough = false,
- this.lineThroughColor = Colors.white,
- this.package,
- this.style,
- this.strutStyle,
- this.textAlign,
- this.textDirection,
- this.locale,
- this.softWrap,
- this.overflow,
- this.textScaleFactor,
- this.maxLines,
- this.semanticsLabel,
- this.textWidthBasis,
- this.textHeightBehavior,
- this.forceVerticalCenter = false,
- Key? key,})
- : textSpan = null,
- super(key: key);
-
- const TDText.rich(
- InlineSpan this.textSpan, {
- this.font,
- this.fontWeight = FontWeight.w400,
- this.fontFamily,
- this.textColor = Colors.black,
- this.backgroundColor,
- this.isTextThrough = false,
- this.lineThroughColor = Colors.white,
- this.package = 'tdesign_flutter',
- Key? key,
- this.style,
- this.strutStyle,
- this.textAlign,
- this.textDirection,
- this.locale,
- this.softWrap,
- this.overflow,
- this.textScaleFactor,
- this.maxLines,
- this.semanticsLabel,
- this.textWidthBasis,
- this.textHeightBehavior,
- this.forceVerticalCenter = false,
- }) :
- data = null,
- super(key: key);
-
- /// 字体尺寸,包含大小size和行高height
- final Font? font;
-
- /// 字体粗细
- final FontWeight? fontWeight;
-
- /// 字体ttf
- final FontFamily? fontFamily;
-
- /// 文本颜色
- final Color textColor;
-
- /// 背景颜色
- final Color? backgroundColor;
-
- /// 字体包名
- final String? package;
-
- /// 是否是横线穿过样式(删除线)
- final bool? isTextThrough;
-
- /// 删除线颜色,对应TestStyle的decorationColor
- final Color? lineThroughColor;
-
- /// 自定义的TextStyle,其中指定的属性,将覆盖扩展的外层属性
- final TextStyle? style;
-
- /// 以下系统text属性,释义请参考系统[Text]中注释
- final data;
-
- final StrutStyle? strutStyle;
-
- final TextAlign? textAlign;
-
- final TextDirection? textDirection;
-
- final Locale? locale;
-
- final bool? softWrap;
-
- final TextOverflow? overflow;
-
- final double? textScaleFactor;
-
- final int? maxLines;
-
- final String? semanticsLabel;
-
- final TextWidthBasis? textWidthBasis;
-
- final ui.TextHeightBehavior? textHeightBehavior;
-
- final InlineSpan? textSpan;
-
- final bool forceVerticalCenter;
-
-
-
-
- @override
- Widget build(BuildContext context) {
- if(forceVerticalCenter){
- var config = getConfiguration(context);
- var paddingConfig = config?.paddingConfig;
-
- var textFont =
- font ?? TDTheme.of(context).fontM ?? Font(size: 16, lineHeight: 24);
- var fontSize = style?.fontSize ?? textFont.size;
- var height = style?.height ?? textFont.height;
-
- paddingConfig ??= TDTextPaddingConfig.getDefaultConfig();
- var showHeight = min(paddingConfig.heightRate, height);
- return Container(
- color: style?.backgroundColor ?? backgroundColor,
- height: fontSize * height,
- padding: paddingConfig.getPadding(data, fontSize, height),
- child: _getRawText(context: context, textStyle: getTextStyle(context, height: showHeight)),
- );
- }
- return Container(
- color: style?.backgroundColor ?? backgroundColor,
- child: _getRawText(context: context),
- );
- }
-
- /// 提取成方法,允许业务定义自己的TDTextConfiguration
- TDTextConfiguration? getConfiguration(BuildContext context){
- return context.dependOnInheritedWidgetOfExactType();
- }
-
-
-
- TextStyle? getTextStyle(BuildContext? context,{ double? height, Color? backgroundColor}) {
- var textFont =
- font ?? TDTheme.of(context).fontM ?? Font(size: 16, lineHeight: 24);
- return TextStyle(
- inherit: style?.inherit ?? true,
- color: style?.color ?? textColor,
- /// 不使用系统本身的背景色,因为系统属性存在中英文是,会导致颜色出现阶梯状
- backgroundColor: backgroundColor,
- fontSize: style?.fontSize ?? textFont.size,
- fontWeight: style?.fontWeight ?? fontWeight,
- fontStyle: style?.fontStyle,
- letterSpacing: style?.letterSpacing,
- wordSpacing: style?.wordSpacing,
- textBaseline: style?.textBaseline,
- height: height ?? style?.height ?? textFont.height,
- leadingDistribution: style?.leadingDistribution,
- locale: style?.locale,
- foreground: style?.foreground,
- background: style?.background,
- shadows: style?.shadows,
- fontFeatures: style?.fontFeatures,
- decoration: style?.decoration ?? (isTextThrough! ? TextDecoration.lineThrough : TextDecoration.none),
- decorationColor: style?.decorationColor ?? lineThroughColor,
- decorationStyle: style?.decorationStyle,
- decorationThickness: style?.decorationThickness,
- debugLabel: style?.debugLabel,
- fontFamily: style?.fontFamily ?? fontFamily?.fontFamily,
- fontFamilyFallback: style?.fontFamilyFallback,
- package: package,
- );
- }
-
- /// 获取系统原始Text,以便使用到只能接收系统Text组件的地方
- /// 转化为系统原始Text后,将失去padding和background属性
- Text getRawText({BuildContext? context}){
- return _getRawText(context: context, backgroundColor: backgroundColor);
- }
-
- Text _getRawText({BuildContext? context, TextStyle? textStyle, Color? backgroundColor}){
- return textSpan == null ? Text(
- data,
- key: key,
- style: textStyle ?? getTextStyle(context, backgroundColor: backgroundColor),
- strutStyle: strutStyle,
- textAlign: textAlign,
- textDirection: textDirection,
- locale: locale,
- softWrap: softWrap,
- overflow: overflow,
- textScaleFactor: textScaleFactor,
- maxLines: maxLines,
- semanticsLabel: semanticsLabel,
- textWidthBasis: textWidthBasis,
- textHeightBehavior: textHeightBehavior,
- ) : Text.rich(textSpan!,
- style: textStyle ?? getTextStyle(context, backgroundColor: backgroundColor),
- strutStyle: strutStyle,
- textAlign: textAlign,
- textDirection: textDirection,
- locale: locale,
- softWrap: softWrap,
- overflow: overflow,
- textScaleFactor: textScaleFactor,
- maxLines: maxLines,
- semanticsLabel: semanticsLabel,
- textWidthBasis: textWidthBasis,
- textHeightBehavior: textHeightBehavior,
- );
- }
-}
-
-/// TextSpan的TDesign扩展,将部分TextStyle中的参数扁平化。
-class TDTextSpan extends TextSpan{
-
- /// 构造参数,扩展参数释义可参考[TDText]中字段注释
- TDTextSpan({
- BuildContext? context, // 如果未设置font,且不想使用默认的fontM尺寸时,需设置context,否则可省略
- Font? font,
- FontWeight fontWeight = FontWeight.w400,
- FontFamily? fontFamily,
- Color textColor = Colors.black,
- bool? isTextThrough = false,
- Color? lineThroughColor = Colors.white,
- String package = 'tdesign_flutter',
- String? text,
- List? children,
- TextStyle? style,
- GestureRecognizer? recognizer,
- MouseCursor? mouseCursor,
- PointerEnterEventListener? onEnter,
- PointerExitEventListener? onExit,
- String? semanticsLabel,
- }) : super(
- text: text,
- children: children,
- style: _getTextStyle(
- context,
- style,
- font,
- fontWeight,
- fontFamily,
- textColor,
- isTextThrough,
- lineThroughColor,
- package),
- recognizer: recognizer,
- mouseCursor: mouseCursor,
- onEnter: onEnter,
- onExit: onExit,
- semanticsLabel: semanticsLabel,
- );
-
- static TextStyle? _getTextStyle(
- BuildContext? context,
- TextStyle? style,
- Font? font,
- FontWeight fontWeight,
- FontFamily? fontFamily,
- Color textColor,
- bool? isTextThrough,
- Color? lineThroughColor,
- String package,
- ) {
- var textFont =
- font ?? TDTheme.of(context).fontM ?? Font(size: 16, lineHeight: 24);
- return TextStyle(
- inherit: style?.inherit ?? true,
- color: style?.color ?? textColor,
- backgroundColor: style?.backgroundColor,
- fontSize: style?.fontSize ?? textFont.size,
- fontWeight: style?.fontWeight ?? fontWeight,
- fontStyle: style?.fontStyle,
- letterSpacing: style?.letterSpacing,
- wordSpacing: style?.wordSpacing,
- textBaseline: style?.textBaseline,
- height: style?.height ?? textFont.height,
- leadingDistribution: style?.leadingDistribution,
- locale: style?.locale,
- foreground: style?.foreground,
- background: style?.background,
- shadows: style?.shadows,
- fontFeatures: style?.fontFeatures,
- decoration: style?.decoration ??
- (isTextThrough! ? TextDecoration.lineThrough : TextDecoration.none),
- decorationColor: style?.decorationColor ?? lineThroughColor,
- decorationStyle: style?.decorationStyle,
- decorationThickness: style?.decorationThickness,
- debugLabel: style?.debugLabel,
- fontFamily: style?.fontFamily ?? fontFamily?.fontFamily,
- fontFamilyFallback: style?.fontFamilyFallback,
- package: package,
- );
- }
-}
-
-/// 存储可以自定义TDText居中算法数据的内部控件
-class TDTextConfiguration extends InheritedWidget {
- final TDTextPaddingConfig? paddingConfig;
-
- const TDTextConfiguration(
- {this.paddingConfig, Key? key, required Widget child})
- : super(key: key, child: child);
-
- @override
- bool updateShouldNotify(covariant TDTextConfiguration oldWidget) {
- return paddingConfig != oldWidget.paddingConfig;
- }
-
-
-}
-
-/// 通过Padding自定义TDText居中算法
-class TDTextPaddingConfig {
-
- static TDTextPaddingConfig? _defaultConfig;
-
- /// 获取默认配置
- static TDTextPaddingConfig getDefaultConfig(){
- _defaultConfig ??= TDTextPaddingConfig();
- return _defaultConfig!;
- }
-
- /// 获取padding
- EdgeInsetsGeometry getPadding(String data, double fontSize, double height){
- var paddingFont = fontSize * paddingRate;
- var paddingLeading ;
- if(height < heightRate){
- paddingLeading = 0;
- } else {
- if(PlatformUtil.isIOS || PlatformUtil.isAndroid){
- paddingLeading = (height * 0.5 - paddingExtraRate) * fontSize;
- } else {
- paddingLeading = 0;
- }
- }
- var paddingTop = paddingFont + paddingLeading;
- if(paddingTop < 0) {
- paddingTop = 0;
- }
- return EdgeInsets.only(top: paddingTop);
- }
-
- /// 以多个汉字测量计算的平均值,Android为Pixel 4模拟器,iOS为iphone 8 plus 模拟器
- double get paddingRate => PlatformUtil.isWeb? 3/8 : PlatformUtil.isAndroid? - 7/128 : 0;
-
- /// 以多个汉字测量计算的平均值,Android为Pixel 4模拟器,iOS为iphone 8 plus 模拟器
- double get paddingExtraRate => PlatformUtil.isAndroid? 115/256 : 97/240;
-
- /// height比率,因为设置1时,Android文字可能显示不全,默认为1.1
- double get heightRate => PlatformUtil.isAndroid ? 1.1 : 1;
-
-}
\ No newline at end of file
diff --git a/lib/src/components/toast/td_toast.dart b/lib/src/components/toast/td_toast.dart
deleted file mode 100644
index 7b487c3b4..000000000
--- a/lib/src/components/toast/td_toast.dart
+++ /dev/null
@@ -1,214 +0,0 @@
-import 'dart:async';
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import '../../../td_export.dart';
-import '../loading/td_circle_indicator.dart';
-
-enum IconTextDirection {
- horizontal, //横向
- vertical //竖向
-}
-class TDToast {
- static void showText(String? text, {required BuildContext context,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _showOverlay(_TDTextToast(text: text,), context: context);
- }
-
- static void showIconText(String? text, {
- IconData? icon,
- IconTextDirection direction = IconTextDirection.horizontal,
- required BuildContext context,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _showOverlay(_TDIconTextToast(text: text, iconData: icon, iconTextDirection: direction,), context: context);
- }
-
- static void showSuccess(String? text, {
- IconTextDirection direction = IconTextDirection.horizontal,
- required BuildContext context,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _showOverlay(_TDIconTextToast(text: text, iconData: TDIcons.check_circle, iconTextDirection: direction,), context: context);
- }
-
- static void showWarning(String? text, {
- IconTextDirection direction = IconTextDirection.horizontal,
- required BuildContext context,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _showOverlay(_TDIconTextToast(text: text, iconData: TDIcons.error_circle, iconTextDirection: direction,), context: context);
- }
-
- static void showLoading({required BuildContext context,
- String? text,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _showOverlay(_TDToastLoading(text: text,), context: context, duration: TDToast._infinteDuration);
- }
-
- static void dismissLoading() {
- _cancel();
- }
-
- static void _showOverlay(Widget? widget, {required BuildContext context,
- Duration duration = TDToast._defaultDisPlayDuration}) {
- _cancel();
- _showing = true;
- var overlayState = Overlay.of(context);
- _overlayEntry = OverlayEntry(
- builder: (BuildContext context) => Center(
- child: AnimatedOpacity(
- opacity: _showing ? 1.0 : 0.0,
- duration: _showing
- ? const Duration(milliseconds: 100)
- : const Duration(milliseconds: 200),
- child: widget,
- ),
- ));
- if (_overlayEntry != null) {
- overlayState?.insert(_overlayEntry!);
- }
- _startTimer(duration);
- }
-
- static void _cancel() {
- _timer?.cancel();
- _timer = null;
- _disposeTimer?.cancel();
- _disposeTimer = null;
- _overlayEntry?.remove();
- _overlayEntry = null;
- _showing = false;
- }
-
- static void _startTimer(Duration duration) {
- _timer?.cancel();
- _disposeTimer?.cancel();
- _timer = Timer(duration, () {
- _showing = false;
- _overlayEntry?.markNeedsBuild();
- _timer = null;
- _disposeTimer = Timer(const Duration(milliseconds: 200), () {
- _overlayEntry?.remove();
- _overlayEntry = null;
- _disposeTimer = null;
- });
- });
- }
-
- static OverlayEntry? _overlayEntry;
- static bool _showing = false;
- static Timer? _timer;
- static Timer? _disposeTimer;
- static const Duration _defaultDisPlayDuration = Duration(milliseconds: 3000);
- static const Duration _infinteDuration = Duration(seconds: 99999999);
-}
-
-class _TDIconTextToast extends StatelessWidget {
- final String? text;
- final IconData? iconData;
- final IconTextDirection iconTextDirection;
- const _TDIconTextToast({this.text, this.iconData, this.iconTextDirection = IconTextDirection.horizontal});
-
- Widget buildHorizontalWidgets(BuildContext context) {
- return ConstrainedBox(constraints: const BoxConstraints(maxWidth: 191, maxHeight: 94), child: Container(
- padding: const EdgeInsets.fromLTRB(24, 14, 24, 14),
- decoration: BoxDecoration(
- color: TDTheme.of(context).fontGyColor2,
- borderRadius: BorderRadius.circular(4),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(iconData, size: 21, color: TDTheme.of(context).whiteColor1,),
- const SizedBox(width: 10,),
- TDText(text ?? '',
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textColor: TDTheme.of(context).whiteColor1,)
- ],)
- ),);
- }
-
- Widget buildVerticalWidgets(BuildContext context) {
- return ConstrainedBox(constraints: const BoxConstraints(maxWidth: 136, maxHeight: 130), child: Container(
- width: 136,
- height: 130,
- padding: const EdgeInsets.fromLTRB(24, 24, 24, 24),
- decoration: BoxDecoration(
- color: TDTheme.of(context).fontGyColor2,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(iconData, size: 42, color: TDTheme.of(context).whiteColor1,),
- const SizedBox(height: 15,),
- TDText(text ?? '',
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textColor: TDTheme.of(context).whiteColor1,)
- ],)
- ));
- }
-
- @override
- Widget build(BuildContext context) {
- return iconTextDirection == IconTextDirection.horizontal ? buildHorizontalWidgets(context) : buildVerticalWidgets(context);
- }
-}
-
-class _TDToastLoading extends StatelessWidget {
- final String? text;
- const _TDToastLoading({this.text});
-
- @override
- Widget build(BuildContext context) {
- return Container(
- width: 136,
- height: 130,
- padding: const EdgeInsets.fromLTRB(24, 24, 24, 24),
- decoration: BoxDecoration(
- color: TDTheme.of(context).fontGyColor2,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TDCircleIndicator(color: TDTheme.of(context).whiteColor1, size: 36, lineWidth: 6,),
- const SizedBox(height: 15,),
- TDText(text ?? '加载中...',
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textColor: TDTheme.of(context).whiteColor1,)
- ],)
- );
- }
-}
-
-class _TDTextToast extends StatelessWidget {
- final String? text;
- const _TDTextToast({this.text});
-
- @override
- Widget build(BuildContext context) {
- return ConstrainedBox(constraints: const BoxConstraints(maxWidth: 191, maxHeight: 94), child: Container(
- padding: const EdgeInsets.fromLTRB(24, 14, 24, 14),
- decoration: BoxDecoration(
- color: TDTheme.of(context).fontGyColor2,
- borderRadius: BorderRadius.circular(4),
- ),
- child: TDText(text ?? '',
- font: TDTheme.of(context).fontS,
- fontWeight: FontWeight.w400,
- maxLines: 3,
- overflow: TextOverflow.ellipsis,
- textColor: TDTheme.of(context).whiteColor1,)
- ),);
- }
-}
-
diff --git a/lib/src/theme/basic.dart b/lib/src/theme/basic.dart
deleted file mode 100644
index b41b0981a..000000000
--- a/lib/src/theme/basic.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-/// 字体宽高数据
-class Font {
- late double size;
- late double height;
-
- Font({required int size, required int lineHeight}) {
- this.size = size.toDouble();
- height = lineHeight.toDouble() / size;
- }
-
- factory Font.fromJson(Map map) =>
- Font(size: map['size'], lineHeight: map['lineHeight']);
-}
-
-/// 字体样式
-class FontFamily {
- late String fontFamily;
-
- FontFamily({required this.fontFamily});
-
- factory FontFamily.fromJson(Map map) =>
- FontFamily(fontFamily: map['fontFamily']);
-}
diff --git a/lib/src/theme/td_corners.dart b/lib/src/theme/td_corners.dart
deleted file mode 100644
index 0efd67e94..000000000
--- a/lib/src/theme/td_corners.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-import 'package:flutter/material.dart';
-
-import 'td_theme.dart';
-
-/// 内置圆角数据
-extension TDCorners on TDThemeData {
- /// 基础圆角数据
- double? get baseBorderRadius => cornerMap['baseBorderRadius'];
-}
diff --git a/lib/src/theme/td_default_theme.dart b/lib/src/theme/td_default_theme.dart
deleted file mode 100644
index 968fd609e..000000000
--- a/lib/src/theme/td_default_theme.dart
+++ /dev/null
@@ -1,235 +0,0 @@
-/// TDesign默认主题
-class TDDefaultTheme {
- static String defaultThemeConfig = '''
- {
- "default": {
- "color": {
- "brandColor1": "#ECF2FE",
- "brandColor2": "#D4E3FC",
- "brandColor3": "#BBD3FB",
- "brandColor4": "#96BBF8",
- "brandColor5": "#699EF5",
- "brandColor6": "#4787F0",
- "brandColor7": "#266FE8",
- "brandColor8": "#0052D9",
- "brandColor9": "#0034B5",
- "brandColor10": "#001F97",
- "brandLightColor": "#ECF2FE",
- "brandFocusColor": "#D4E3FC",
- "brandDisabledColor": "#BBD3FB",
- "brandHoverColor": "#266FE8",
- "brandNormalColor": "#0052D9",
- "brandClickColor": "#0034B5",
- "errorColor1": "#FDECEE",
- "errorColor2": "#F9D7D9",
- "errorColor3": "#F8B9BE",
- "errorColor4": "#F78D94",
- "errorColor5": "#F36D78",
- "errorColor6": "#E34D59",
- "errorColor7": "#C9353F",
- "errorColor8": "#B11F26",
- "errorColor9": "#951114",
- "errorColor10": "#680506",
- "errorLightColor": "#FDECEE",
- "errorFocusColor": "#F9D7D9",
- "errorDisabledColor": "#F8B9BE",
- "errorHoverColor": "#F36D78",
- "errorNormalColor": "#E34D59",
- "errorClickColor": "#C9353F",
- "warningColor1": "#FEF3E6",
- "warningColor2": "#F9E0C7",
- "warningColor3": "#F7C797",
- "warningColor4": "#F2995F",
- "warningColor5": "#ED7B2F",
- "warningColor6": "#D35A21",
- "warningColor7": "#BA431B",
- "warningColor8": "#9E3610",
- "warningColor9": "#842B0B",
- "warningColor10": "#5A1907",
- "warningLightColor": "#FEF3E6",
- "warningFocusColor": "#F9E0C7",
- "warningDisabledColor": "#F7C797",
- "warningHoverColor": "#F2995F",
- "warningNormalColor": "#ED7B2F",
- "warningClickColor": "#D35A21",
- "successColor1": "#E8F8F2",
- "successColor2": "#BCEBDC",
- "successColor3": "#85DBBE",
- "successColor4": "#48C79C",
- "successColor5": "#00A870",
- "successColor6": "#078D5C",
- "successColor7": "#067945",
- "successColor8": "#056334",
- "successColor9": "#044F2A",
- "successColor10": "#033017",
- "successLightColor": "#E8F8F2",
- "successFocusColor": "#BCEBDC",
- "successDisabledColor": "#85DBBE",
- "successHoverColor": "#48C79C",
- "successNormalColor": "#00A870",
- "successClickColor": "#078D5C",
- "fontGyColor1": "#E6000000",
- "fontGyColor2": "#99000000",
- "fontGyColor3": "#66000000",
- "fontGyColor4": "#42000000",
- "fontWhColor1": "#FFFFFFFF",
- "fontWhColor2": "#8CFFFFFF",
- "fontWhColor3": "#59FFFFFF",
- "fontWhColor4": "#38FFFFFF",
- "whiteColor1": "#FFFFFF",
- "grayColor1": "#F3F3F3",
- "grayColor2": "#EEEEEE",
- "grayColor3": "#E7E7E7",
- "grayColor4": "#DCDCDC",
- "grayColor5": "#C5C5C5",
- "grayColor6": "#A6A6A6",
- "grayColor7": "#8B8B8B",
- "grayColor8": "#777777",
- "grayColor9": "#5E5E5E",
- "grayColor10": "#4B4B4B",
- "grayColor11": "#383838",
- "grayColor12": "#2C2C2C",
- "grayColor13": "#242424",
- "grayColor14": "#181818"
- },
- "font": {
- "fontXL": {
- "size": 36,
- "lineHeight": 44
- },
- "fontL": {
- "size": 20,
- "lineHeight": 28
- },
- "fontM": {
- "size": 16,
- "lineHeight": 24
- },
- "fontS": {
- "size": 14,
- "lineHeight": 22
- },
- "fontXS": {
- "size": 12,
- "lineHeight": 20
- },
- "fontXXS": {
- "size": 10,
- "lineHeight": 16
- }
- },
- "fontFamily": {
- "numberFontFamily": {
- "fontFamily": "DINAlternate-B"
- }
- },
- "corner": {
- "baseBorderRadius": 8
- },
- "shadow": {
- "baseShadows": [
- {
- "color": "#0D000000",
- "blurRadius": 10,
- "spreadRadius": 1,
- "offset":{
- "x":0,
- "y":1
- }
- },
- {
- "color": "#14000000",
- "blurRadius": 5,
- "spreadRadius": 1,
- "offset":{
- "x":0,
- "y":4
- }
- },
- {
- "color": "#1F000000",
- "blurRadius": 4,
- "spreadRadius": -1,
- "offset":{
- "x":0,
- "y":2
- }
- }
- ],
- "middleShadows": [
- {
- "color": "#0D000000",
- "blurRadius": 14,
- "spreadRadius": 2,
- "offset":{
- "x":0,
- "y":3
- }
- },
- {
- "color": "#0F000000",
- "blurRadius": 10,
- "spreadRadius": 1,
- "offset":{
- "x":0,
- "y":8
- }
- },
- {
- "color": "#1A000000",
- "blurRadius": 5,
- "spreadRadius": -3,
- "offset":{
- "x":0,
- "y":0
- }
- }
- ],
- "topShadows": [
- {
- "color": "#0D000000",
- "blurRadius": 30,
- "spreadRadius": 5,
- "offset":{
- "x":0,
- "y":6
- }
- },
- {
- "color": "#0A000000",
- "blurRadius": 24,
- "spreadRadius": 2,
- "offset":{
- "x":0,
- "y":16
- }
- },
- {
- "color": "#14000000",
- "blurRadius": 10,
- "spreadRadius": -5,
- "offset":{
- "x":0,
- "y":8
- }
- }
- ]
- },
- "spacer": {
- "spacer4": 4,
- "spacer8": 8,
- "spacer12": 12,
- "spacer16": 16,
- "spacer24": 24,
- "spacer32": 32,
- "spacer40": 40,
- "spacer48": 48,
- "spacer64": 64,
- "spacer96": 96,
- "spacer160": 160
- }
- }
-}
-
- ''';
-}
diff --git a/lib/src/theme/td_fonts.dart b/lib/src/theme/td_fonts.dart
deleted file mode 100644
index 4d1799b41..000000000
--- a/lib/src/theme/td_fonts.dart
+++ /dev/null
@@ -1,24 +0,0 @@
-import 'basic.dart';
-import 'td_theme.dart';
-
-/// 内置字体数据
-extension TDFonts on TDThemeData {
- /// 字体大小/行高
- /// 36/44
- Font? get fontXL => fontMap['fontXL'];
-
- /// 20/28
- Font? get fontL => fontMap['fontL'];
-
- /// 16/24
- Font? get fontM => fontMap['fontM'];
-
- /// 14/22
- Font? get fontS => fontMap['fontS'];
-
- /// 12/20
- Font? get fontXS => fontMap['fontXS'];
-
- /// 10/16
- Font? get fontXXS => fontMap['fontXXS'];
-}
diff --git a/lib/src/theme/td_shadows.dart b/lib/src/theme/td_shadows.dart
deleted file mode 100644
index dacf2c73a..000000000
--- a/lib/src/theme/td_shadows.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-import 'package:flutter/material.dart';
-import 'td_theme.dart';
-
-/// 内置投影
-extension TDBoxShadows on TDThemeData {
- /// 基础投影
- List