diff --git a/.ci/Dockerfile b/.ci/Dockerfile new file mode 100644 index 00000000..eb7247dc --- /dev/null +++ b/.ci/Dockerfile @@ -0,0 +1,30 @@ +FROM cirrusci/flutter:stable + +RUN sudo apt-get update -y + +RUN sudo apt-get install -y --no-install-recommends gnupg + +# Add repo for gcloud sdk and install it +RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \ + sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ + sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - + +RUN sudo apt-get update && sudo apt-get install -y google-cloud-sdk && \ + gcloud config set core/disable_usage_reporting true && \ + gcloud config set component_manager/disable_update_check true + +RUN yes | sdkmanager \ + "platforms;android-29" \ + "build-tools;29.0.2" \ + "extras;google;m2repository" \ + "extras;android;m2repository" + +RUN yes | sdkmanager \ + "platforms;android-28" \ + "build-tools;28.0.3" \ + "extras;google;m2repository" \ + "extras;android;m2repository" + +RUN yes | sdkmanager --licenses diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..8ddb027e --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,32 @@ +task: + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_PR == '' + container: + dockerfile: .ci/Dockerfile + cpu: 8 + memory: 16G + pub_cache: + folder: ~/.pub-cache + setup_script: + - flutter channel stable + - flutter upgrade + build_script: + - flutter build apk + test_script: flutter test + +task: + use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' + osx_instance: + #image: mojave-xcode-10.2-flutter + image: mojave-flutter + pub_cache: + folder: ~/.pub-cache + setup_script: + - pod repo update + - flutter channel stable + - flutter upgrade + create_simulator_script: + - xcrun simctl list + - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-12-2 | xargs xcrun simctl boot + build_script: + - flutter build ios --no-codesign + test_script: flutter test diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index e69de29b..00000000 diff --git a/.gitignore b/.gitignore index e99c7b82..bdc2c7bc 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ # IntelliJ related -*.iml + *.ipr *.iws .idea/ diff --git a/CHANGE-LOG.md b/CHANGE-LOG.md index a625fbfe..88b73e46 100644 --- a/CHANGE-LOG.md +++ b/CHANGE-LOG.md @@ -1,86 +1,358 @@ ## 更新日志 - +#### 8/28/2019 + - [x] Modify: IsOpen 的移步判断 + - [x] Update index.md + - [x] Update index.dart +#### 5/28/2019 + - [x] change:async master + - [x] modfiy:应用商店 + - [x] Merge pull request #222 from DeckeDeng/develop + - [x] add home scaffold +#### 8/22/2019 + - [x] Merge pull request #322 from alibaba/beta + - [x] Modify: web view 方法回退 + - [x] Merge pull request #321 from alibaba/beta + - [x] Merge pull request #317 from alibaba/beta + - [x] Merge branch 'master' into beta + - [x] Update contribute.md +#### 8/12/2019 + - [x] update: doc & tpl + - [x] Update tpl.md + - [x] Merge pull request #313 from Nealyang/beta + - [x] 添加登陆错误提醒 +#### 3/11/2019 + - [x] Update README-en.md +#### 8/15/2019 + - [x] update: router path + - [x] ci + - [x] update: view remote code + - [x] 整理文件 +#### 8/13/2019 + - [x] Modify + - [x] Modfiy: + - [x] update: page issue template +#### 8/1/2019 + - [x] merge code +#### 7/29/2019 + - [x] Merge branch 'master' of github.com:alibaba/flutter-go into beta + - [x] delete .github no use file + - [x] docs(update: pr template): + - [x] del: no use file + - [x] Merge branch 'master' of github.com:alibaba/flutter-go + - [x] docs(add widget about issue): + - [x] Merge branch 'temp' into beta + - [x] 迁移位置 + - [x] update: template + - [x] update: 处理合并导致的总理2 +#### 8/7/2019 + - [x] fix bug + - [x] Merge pull request #302 from Nealyang/beta + - [x] remove get collection + - [x] tep + - [x] update: 完成markdown动态更新 +#### 8/8/2019 + - [x] remove user appBar + - [x] bottomBar 添加个人中心 + - [x] Merge pull request #309 from DeckeDeng/beta2 + - [x] ios project.pbxproj + - [x] Merge pull request #308 from DeckeDeng/beta2 + - [x] Merge pull request #304 from Nealyang/beta + - [x] 修改 ios 配置文件 + - [x] update: 临时增加code-review页 +#### 6/28/2019 + - [x] Merge pull request #264 from DeckeDeng/beta2 + - [x] Merge pull request #263 from DeckeDeng/beta2 + - [x] Merge branch 'beta' into beta2 + - [x] 消息反馈页面 +#### 2/1/2019 + - [x] Merge branch 'develop' of https://github.com/alibaba/flutter-go into develop + - [x] feat:android splash + - [x] feat:add android splash + - [x] Merge pull request #116 from hanxu317317/develop + - [x] docs(更新Readme中环境信息): + - [x] Merge pull request #115 from hanxu317317/develop + - [x] feat(首页欢迎图, 加入第一次访问判断.): + - [x] Merge branch 'develop' into sptil + - [x] update: ios启动图描述 + - [x] fix:yaml + - [x] fix: + - [x] Merge pull request #113 from hanxu317317/develop + - [x] fix:mtl buidl apk test + - [x] refactor(conflict): + - [x] add sp + - [x] fix(解决由于flutter 版本问题导致的报错): + - [x] fix:back + - [x] fix:package err + - [x] fix:modify github package name fail and test + - [x] fix:build before modify package's name +#### 7/12/2019 + - [x] Merge pull request #279 from Nealyang/beta + - [x] add + - [x] d +#### 8/6/2019 + - [x] issuse message + - [x] Merge pull request #294 from Nealyang/beta + - [x] 修改为线上地址 + - [x] 个人中心、收藏、搜索 +#### 7/25/2019 + - [x] Merge branch 'beta' of github.com:alibaba/flutter-go +#### 7/23/2019 + - [x] zefyr +#### 7/22/2019 + - [x] feature:个人设置 +#### 7/15/2019 + - [x] appstore 反馈错误 + - [x] readme错误 + - [x] 标题错误,跳转错误 +#### 7/11/2019 + - [x] update: 迁移新老数据结构与收藏 + - [x] update: 增加环境配置. 挂载在application静态属性上 + - [x] update: 修改文章 +#### 4/8/2019 + - [x] flutter project switch ios or android by androidstudio + - [x] android permission + - [x] remove extra files +#### 6/18/2019 + - [x] 推送,ios/android,test +#### 6/15/2019 + - [x] 删除node相关 + - [x] Merge branch 'develop' of github.com:alibaba/flutter-common-widgets-app into web + - [x] update: 完善demo + - [x] update: 界面增加title属性 + - [x] add: cli使用说明 +#### 6/11/2019 + - [x] update: 替换markdown包引入方式 + - [x] add: 加入标准page模板 + - [x] 加入标准page + - [x] 加入初始化demo + - [x] 引入三方flutter_markdown gi +#### 6/10/2019 + - [x] Merge pull request #249 from Nealyang/beta + - [x] 添加收藏功能 + - [x] update: 标准化代码. + - [x] goCli 完成90% +#### 6/4/2019 + - [x] markdown + - [x] 加入初始gocli + - [x] add page demo + - [x] 增加page的统一入口 + - [x] add demos packges + - [x] Merge pull request #240 from Nealyang/beta + - [x] 退出登陆、feedback 测试 +#### 5/31/2019 + - [x] 添加个人中心 +#### 5/30/2019 + - [x] 首页不刷新 + - [x] Merge pull request #1 from forever-713/zuston-patch-1 + - [x] Fix App name error +#### 5/29/2019 + - [x] 添加 github oAuth 认证,添加错误提醒 +#### 5/23/2019 + - [x] readme.md + - [x] Merge pull request #219 from weikx/develop + - [x] Merge pull request #215 from DeckeDeng/develop + - [x] delete firstPage + - [x] de + - [x] Test:测试分支 + - [x] Merge branch 'develop' of https://github.com/weikx/flutter-go into develop + - [x] Change word 'Free' into 'Three' + - [x] Chang word 'Free' into 'Three' +#### 5/17/2019 + - [x] Merge pull request #216 from alibaba/master +#### 5/14/2019 + - [x] update version +#### 2/3/2019 + - [x] fix(解决ios报错): + - [x] Merge pull request #119 from Nealyang/master + - [x] fix:fix code conflic + - [x] fix: code conflict + - [x] Merge branch 'develop' into master + - [x] fix:view code + - [x] Merge pull request #118 from alibaba/dev/yisheng +#### 5/9/2019 + - [x] test version +#### 5/7/2019 + - [x] merge origin + - [x] add update test + - [x] Merge branch 'develop' of github.com:alibaba/flutter-go + - [x] cookie 校验 + - [x] modify home.dart bottom tab + - [x] session 验证 + - [x] merge develop + - [x] 登陆 + - [x] Merge pull request #205 from alibaba/dev/sanl + - [x] modify bottom tab + - [x] delete ios file + - [x] add apk + - [x] Login 登陆界面 +#### 5/6/2019 + - [x] add login +#### 5/1/2019 + - [x] Modfiy: 改造业内资讯页面 +#### 4/30/2019 + - [x] Add:二期开发-重构首页布局 + - [x] gradle 4.10.2 包添加AndroidX配置 +#### 2/19/2019 + - [x] packagename + - [x] Merge pull request #148 from alibaba/dev/yisheng + - [x] refactor:按照代码规范调整import 文件 + - [x] update: 规范 + - [x] Merge pull request #147 from Nealyang/master + - [x] fix:修复TabBar demo + - [x] Merge pull request #146 from Nealyang/master + - [x] refactor: 根据规范重构代码 + - [x] Merge pull request #145 from alibaba/dev/yisheng + - [x] refactor:按照代码规范调整markdow解析 + - [x] refactor(规范化代码): + - [x] Merge pull request #143 from Nealyang/master + - [x] refactor:按规范修改代码、注释等 + - [x] Merge pull request #142 from Nealyang/master + - [x] commit + - [x] Merge pull request #141 from Nealyang/master + - [x] Merge pull request #140 from Nealyang/master + - [x] Merge pull request #135 from hanxu317317/develop + - [x] Merge branch 'develop' into develop + - [x] Merge pull request #139 from Nealyang/master + - [x] Merge branch 'develop' of github.com:alibaba/flutter-common-widgets-app + - [x] refactor:根据规范,重构代码 + - [x] modify code comments + - [x] Merge pull request #138 from alibaba/dev/yisheng + - [x] refactor:按照代码规范调整注释文件 +#### 4/29/2019 + - [x] test app store + - [x] Merge branch 'master' into dev/sanl + - [x] 修改bug +#### 4/26/2019 + - [x] Debug: GoogleService-Info.plist 位置问题 导致错误 + - [x] change LICENSE date + - [x] 变更许可 + - [x] Merge pull request #189 from alibaba/develop + - [x] change License +#### 4/22/2019 + - [x] release apk + - [x] Merge pull request #192 from alibaba/dev/yisheng + - [x] 格式化 + - [x] Merge pull request #191 from alibaba/dev/yisheng + - [x] Delete:删除 .gradle 文件夹 + - [x] Merge pull request #188 from alibaba/dev/yisheng +#### 4/17/2019 + - [x] gridView 网格效果 图片流 + - [x] 添加渐变效果/网络图片覆盖图层渲染/图片填充 +#### 1/31/2019 + - [x] Merge pull request #112 from alibaba/dev/yisheng + - [x] Debug:canvas 路由问题 + - [x] Merge pull request #111 from alibaba/dev/yisheng + - [x] feat: Canvas 细化各种方法 + - [x] add file + - [x] fix:code + - [x] feat(加入启动图, 时间2秒): +#### 4/12/2019 + - [x] update: 修改错字 + - [x] Merge pull request #180 from alibaba/develop + - [x] add: doc roadmap +#### 4/1/2019 + - [x] remove recruit + - [x] move recruit +#### 3/31/2019 + - [x] 增加模板 + - [x] Create pull_request_template.md + - [x] Delete .github + - [x] Create .github + - [x] Merge pull request #173 from alibaba/master +#### 2/2/2019 + - [x] fix: 部分代码添加 mounted + - [x] Merge pull request #117 from alibaba/dev/yisheng + - [x] fix:修复Canvas组件收藏的bug +#### 2/20/2019 + - [x] 同步文件 + - [x] Merge pull request #152 from hanxu317317/develop + - [x] 更新跳转页方式 + - [x] modify logo + - [x] Merge pull request #149 from hanxu317317/develop + - [x] fix(解决返回首页报错的问题): +#### 2/11/2019 + - [x] fix: 部分代码 analysis 解决 #### 2019-2-5 - - [x] 处理因为flutter版本导致的项目运行不起来 - - [x] 更新readme, 加入开发日志, 与相关说明 - - [x] 加入 首页欢迎效果图 - - [x] refactor(整理richText的说明): - - [x] 解决一些页面的code演示打不开的问题 - - [x] add:开发规范 - - [x] add:版本更新历史链接 - - [x] Update README.md - - [x] add:添加版本号 - - [x] feat:添加代码开发规范 - - [x] refactor(update: version & fiexed warns): - - [x] fix(solve conflict): - - [x] modify:toast and andrid apk label - - [x] Add:自动 pr 工具抓取器,抓取两周前至今的,提交数据,并去重 - - [x] fix:fluttetToast backHome - - [x] fix:modified the style of toast && remote files - - [x] chore(删除tools/log.json): - - [x] 重构文件结构 - - [x] 关于手册图标更换 - - [x] 增加demo: CupertinoNavigationBar CupertinoPageRoute CupertinoPageScaffold CupertinoPicker,CupertinoPopupSurface CupertinoTimerPickerDemo +- [x] 处理因为flutter版本导致的项目运行不起来 +- [x] 更新readme, 加入开发日志, 与相关说明 +- [x] 加入 首页欢迎效果图 +- [x] refactor(整理richText的说明): +- [x] 解决一些页面的code演示打不开的问题 +- [x] add:开发规范 +- [x] add:版本更新历史链接 +- [x] Update README.md +- [x] add:添加版本号 +- [x] feat:添加代码开发规范 +- [x] refactor(update: version & fiexed warns): +- [x] fix(solve conflict): +- [x] modify:toast and andrid apk label +- [x] Add:自动 pr 工具抓取器,抓取两周前至今的,提交数据,并去重 +- [x] fix:fluttetToast backHome +- [x] fix:modified the style of toast && remote files +- [x] chore(删除tools/log.json): +- [x] 重构文件结构 +- [x] 关于手册图标更换 +- [x] 增加demo: CupertinoNavigationBar CupertinoPageRoute CupertinoPageScaffold CupertinoPicker,CupertinoPopupSurface CupertinoTimerPickerDemo #### 2019-1-24 - - [x] 功能:更新小部件的图标 - - [x] 功能:添加CupertinoTimerPickerDemo - - [x] 调试:消除警告 - - [x] 修复:关于手册图标更换 - - [x] 添加:文案描述 - - [x] 添加:CupertinoPicker,CupertinoPopupSurface +- [x] 功能:更新小部件的图标 +- [x] 功能:添加CupertinoTimerPickerDemo +- [x] 调试:消除警告 +- [x] 修复:关于手册图标更换 +- [x] 添加:文案描述 +- [x] 添加:CupertinoPicker,CupertinoPopupSurface #### 2019-1-23 - - [x] 修复: 导航栏home返回报错 - - [x] 修复:收集错误 - - [x] 添加:CupertinoNavigationBar CupertinoPageRoute CupertinoPageScaffold +- [x] 修复: 导航栏home返回报错 +- [x] 修复:收集错误 +- [x] 添加:CupertinoNavigationBar CupertinoPageRoute CupertinoPageScaffold #### 2019-1-22 - - [x] 功能:在Allsimon拉请求中添加英文简介 +- [x] 功能:在Allsimon拉请求中添加英文简介 #### 2019-1-21 - - [x] 功能:Cupertino的子项 +- [x] 功能:Cupertino的子项 #### 2019-1-20 - - [x] 功能:CupertinoSwitch演示 - - [x] 功能:为搜索列表加入图标 - - [x] 功能:CupertinoSliverRefreshControl演示 - - [x] 功能:CupertinoSliverNavigationBar演示 +- [x] 功能:CupertinoSwitch演示 +- [x] 功能:为搜索列表加入图标 +- [x] 功能:CupertinoSliverRefreshControl演示 +- [x] 功能:CupertinoSliverNavigationBar演示 #### 2019-1-18 - - [x] 更新:SharedPreferences保存数据和android设备布局溢出 - - [x] 功能:添加CupertinoScrollbar演示 - - [x] 功能:第四页暂时用欢迎页替代。后期再开发 +- [x] 更新:SharedPreferences保存数据和android设备布局溢出 +- [x] 功能:添加CupertinoScrollbar演示 +- [x] 功能:第四页暂时用欢迎页替代。后期再开发 #### 2019-1-17 - - [x] 添加:+许可证 +- [x] 添加:+许可证 #### 2019-1-16 - - [x] 转换:将README翻译为En语言环境 - - [x] 功能:CupertinoScrollbar演示 +- [x] 转换:将README翻译为En语言环境 +- [x] 功能:CupertinoScrollbar演示 #### 2019-1-14 - - [x] 添加:增加手册页面 - - [x] 功能:文字演示 - - [x] 重构:修改过的图标 - - [x] 重构:文档,文章,组件收藏,新增webView - - [x] 重构:修改过的演示 - - [x] 重构:代码视图 - - [x] 更新:版本 和readme.md - - [x] 修改:添加代码视图 - - [x] 功能:添加搜索历史记录板 - - [x] 修改:列出加标头错误 +- [x] 添加:增加手册页面 +- [x] 功能:文字演示 +- [x] 重构:修改过的图标 +- [x] 重构:文档,文章,组件收藏,新增webView +- [x] 重构:修改过的演示 +- [x] 重构:代码视图 +- [x] 更新:版本 和readme.md +- [x] 修改:添加代码视图 +- [x] 功能:添加搜索历史记录板 +- [x] 修改:列出加标头错误 #### 2019-1-15 - - [x] 功能:welcomepage +- [x] 功能:welcomepage #### 2019-1-13 - - [x] 添加:一些输入描述 - - [x] 功能:加入GridPaper&SliverGrid - - [x] 重构:修改db - - [x] 重构:删除数据库 TabBarView - - [x] 添加:网格视图 - - [x] 修改:checkbosListTile 错误 - - [x] 修改:自动提示文案 - - [x] 功能:增加免责声明,声明组件,自动弹出,左上角入口 - - [x] 重构:整理数据库初始逻辑,判断数据库完整性,判断是否存在已知的cat,widget,collection 三张表。 - - [x] 修复:DialogDemo,无法关闭的问题 +- [x] 添加:一些输入描述 +- [x] 功能:加入GridPaper&SliverGrid +- [x] 重构:修改db +- [x] 重构:删除数据库 TabBarView +- [x] 添加:网格视图 +- [x] 修改:checkbosListTile 错误 +- [x] 修改:自动提示文案 +- [x] 功能:增加免责声明,声明组件,自动弹出,左上角入口 +- [x] 重构:整理数据库初始逻辑,判断数据库完整性,判断是否存在已知的cat,widget,collection 三张表。 +- [x] 修复:DialogDemo,无法关闭的问题 #### 2019-1-12 - - [x] 修复:icon没有,但内容有的,组件,给补充了icon - - [x] 修改:1.整理文件 2.修正分析 - - [x] 更新:flutter_rookie_book => flutter_go - - [x] 更新:更新SearchInput文件名=> search_input - - [x] 修改:文件名称的大小写规范 - - [x] 修改:修正bottomNavigationBar iconButton警告 +- [x] 修复:icon没有,但内容有的,组件,给补充了icon +- [x] 修改:1.整理文件 2.修正分析 +- [x] 更新:flutter_rookie_book => flutter_go +- [x] 更新:更新SearchInput文件名=> search_input +- [x] 修改:文件名称的大小写规范 +- [x] 修改:修正bottomNavigationBar iconButton警告 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..905b4fab --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, 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. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers 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, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at zhu.yan@alibaba-inc.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..fc13245c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +[Flutter Go 共建](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md) diff --git a/README-en.md b/README-en.md index 7862edad..3f540afd 100644 --- a/README-en.md +++ b/README-en.md @@ -1,24 +1,97 @@ -## Flutter Go +# Flutter Go +[中文简体](https://github.com/alibaba/flutter-go/blob/master/README.md) | Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en.md) ![https://img.alicdn.com/tfs/TB1OJkeHNYaK1RjSZFnXXa80pXa-229-229.png](https://img.alicdn.com/tfs/TB1OJkeHNYaK1RjSZFnXXa80pXa-229-229.png) -> Help developers get started quickly Flutter **Flutter Go 1.0 Android has been released** +> Help developers get started quickly Flutter +## News +### 🔥 `Flutter Go 2.0` released +> Flutter Go 2.0 according to [The Flutter-Go Roadmap for 2019](https://github.com/alibaba/flutter-go#the-flutter-go-roadmap%E8%B7%AF%E7%BA%BF%E5%9B%BE-for-2019) beginning of the year, the new feature is: -## Download URL +
mark:✔ is this version
-Android download URL: +- [x] [ `Flutter Go` website ](https://flutter-go.pub/website/) (news,publish,learn) +- [x] [ `Flutter Go web` ](https://github.com/alibaba/flutter-go/tree/web/flutter-go-web-0.0.1) (web version to learn) + - [online preview ](https://flutter-go.pub/flutter_go_web/) + - [resource ](https://github.com/alibaba/flutter-go/tree/web/flutter-go-web-0.0.1) - +- [x] [ `Flutter Go Widget` `pull request` rules ( the third )](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md) -Iphone download URL: -No +- [x] user center (yourself `widget`) + - login (with `GitHub`) + - search (search about `Flutter`) + - favorite component (save online) + - issues (APP online `ISSUES`) + - favorite (APP favorite) +- [x] [ `go-cli` tool ](https://github.com/alibaba/flutter-go/blob/master/docs/widget.md) + - `Flutter Go` `pull request` tools + - [ build `Flutter Go Widget` standard template with terminal ](https://github.com/alibaba/flutter-go/blob/beta/docs/widget.md) + - `markdown` template (when merge master breach) +- [x] ` Flutter Go ` `APP` auto upgrade +- [ ] template sync ( pc, native ) +- [ ] `Flutter Go` store + +## Third part build + +Because the content of ** flutter ** is updated faster, we can't enrich the content of the project faster, If you are willing to contribute to the development and learning of flutter, please see the [build instructions](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md) before you start, we will put the builder's avatar and nick to the websit. + +## Logs + +[resource](https://github.com/alibaba/flutter-go/blob/develop/CHANGE-LOG.md) + +## Development specification +> we are based on the official [dart language specification](https://www.dartlang.org)。 + +[<< Flutter Go development specification >>](https://github.com/alibaba/flutter-go/blob/develop/Flutter_Go%20%E4%BB%A3%E7%A0%81%E5%BC%80%E5%8F%91%E8%A7%84%E8%8C%83.md) + +## The Flutter-Go Roadmap for 2019 +> Considering Flutter's future changes and strategy variability, roadmap does not rule out some adjustments, but overall it will not change much. + + + +## How to use + +- checkout version +```dart + flutter --version +``` +- run doctor +```dart + flutter doctor +``` +- start app +```dart + flutter packages get + flutter run +``` + +- other issues + - https://flutterchina.club/setup-macos/ + - https://flutter.dev/docs/get-started/install/macos + +## Release + +### Android: + +- [Download](https://github.com/alibaba/flutter-go/blob/master/android/app/release/app-release.apk) + +### Ios: + +- AppStore search "Fluttergo" ## Development Environment This Project need latest package, please update regularly. -- dart(version: 2.0.0) -- flutter(version: v1.0.0) +```dart +flutter --version +dart --version +pub --version + +// Flutter (Channel beta, v1.7.8) +// Dart VM version: 2.4.0 +// Pub 2.4.0 +``` ### Background @@ -85,4 +158,4 @@ The advantages of Flutter mainly include: -Powered by Alibaba Auction Front-end Team +Powered by Alibaba Auction Front-end Team \ No newline at end of file diff --git a/README.md b/README.md index 33ed6406..1f1eae24 100644 --- a/README.md +++ b/README.md @@ -1,192 +1,17 @@ -# Flutter Go -Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en.md) | [中文简体](https://github.com/alibaba/flutter-go/blob/master/README.md) +# FlutterGo -![https://img.alicdn.com/tfs/TB1OJkeHNYaK1RjSZFnXXa80pXa-229-229.png](https://img.alicdn.com/tfs/TB1OJkeHNYaK1RjSZFnXXa80pXa-229-229.png) +感谢大家一直以来对 FlutterGo 的支持与反馈。 -> 一个帮助开发者快速上手的 `APP` -## 最新动态 -### 🔥 `Flutter Go 2.0` 即将发布 -> Flutter Go 2.0 秉承年初发布的 [The Flutter-Go Roadmap(路线图) for 2019](https://github.com/alibaba/flutter-go#the-flutter-go-roadmap%E8%B7%AF%E7%BA%BF%E5%9B%BE-for-2019) 已经做了新版本的迭代,新版本如下新功能: -
注:✔是本次发布内容
+但是 **由于团队内部组织调整变更**,很遗憾的宣布 FlutterGo 目前**暂停维护**。 -- [x] [ `Flutter Go` 官方网站 ](https://flutter-go.pub/website/) (官方消息,发布,学习) -- [x] [ `Flutter Go web` 版本](https://github.com/alibaba/flutter-go/tree/web/flutter-go-web-0.0.1) (web 版本学习帮助) - - [线上预览版 ](https://flutter-go.pub/flutter_go_web/) - - [项目地址 ](https://github.com/alibaba/flutter-go/tree/web/flutter-go-web-0.0.1) -- [x] [ `Flutter Go Widget` 的 `pull request` 提交规范(第三方共建)](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md) -- [x] 用户中心 (专属个人的`widget`案例) - - 用户登录(通过`GitHub`账户) - - 全网搜索 (全网搜索 `Flutter` 资讯) - - 收藏个人组件(保存到远端) - - 反馈建议 (APP 在线 `ISSUES`) - - 分享链接 (APP分享) -- [x] [ `go-cli` 工具 ](https://github.com/alibaba/flutter-go/blob/master/docs/widget.md) - - `Flutter Go` 的 `pull request` 工具 - - [命令行 生成 `Flutter Go Widget` 标准公共模版](https://github.com/alibaba/flutter-go/blob/beta/docs/widget.md) - - `markdown` 模版动态化生成(合并到master分支后) -- [x] ` Flutter Go ` 官方 `APP` 版本自动升级 -- [ ] 多端模版同步( pc端,native端同步 ) -- [ ] `Flutter Go` store +但是后期我们会再升级迭代 FlutterGo 新版本,也同时希望更多Flutter爱好者参与加入。 -## 三方共建说明 - -由于 **flutter** 内容更新较快. 我们无法更快的丰富项目的内容. 如果您愿意为国内flutter的发展与学习贡献自己的力量, 请参考我们的 [共建说明](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md), 我们会将共建者的头像姓名贡献至我们的官网. - - - -## 版本更新历史 -> 按时间顺序,展示重要的提交更新内容。 - -[地址](https://github.com/alibaba/flutter-go/blob/develop/CHANGE-LOG.md) - -## 开发规范 -> 由于类似 javascript, java, object-c,等开发者的语言习惯不同而产生歧义,我们依据官方提供的 [dart 语言规范](https://www.dartlang.org) 定制。 - -[<< Flutter Go 开发规范第一版 >>](https://github.com/alibaba/flutter-go/blob/develop/Flutter_Go%20%E4%BB%A3%E7%A0%81%E5%BC%80%E5%8F%91%E8%A7%84%E8%8C%83.md) - -## The Flutter-Go Roadmap(路线图) for 2019 -> 考虑到 Flutter 未来的变化和策略的可变性, roadmap 不排除有一定调整,但总体不会变化太大。 - - - -## 运行方式 - -- 查看一下版本号是否正确 -```dart - flutter --version -``` -- 运行以下命令查看是否需要安装其它依赖项来完成安装 -```dart - flutter doctor -``` -- 运行启动您的应用 -```dart - flutter packages get - flutter run -``` - -- 如果有其他问题,请参考 - - https://flutterchina.club/setup-macos/ - - https://flutter.dev/docs/get-started/install/macos - -## Release安装包下载地址 - -### android正式版,下载地址: - -- 华为市场已上线,华为应用市场搜索 "Fluttergo"或者直接[点击下载](https://appstore.huawei.com/search/fluttergo) -- [直接 apk 文件下载](https://github.com/alibaba/flutter-go/releases/download/0.0.5/app-release.apk) - - -### iphone正式版,下载地址: - -- AppStore 搜索 "Fluttergo" 或者直接[点击下载](https://itunes.apple.com/cn/app/flutter-go/id1462026296?mt=8) - - - -## 基础环境 -本项目环境持续更新. 请定期更新各依赖包. - -```dart -// 运行如下命令 -flutter --version -dart --version -pub --version - -// 正确环境如下 -// Flutter (Channel beta, v1.7.8) -// Dart VM version: 2.4.0 -// Pub 2.4.0 -``` - - -### 背景 - -#### Flutter 是什么? - -2018年6月21日Google发布Flutter首个release预览版,作为Google 大力推出的一种全新的响应式,跨平台,高性能的移动开发框架。Flutter是一个跨平台的移动UI框架,旨在帮助开发者使用一套代码开发高性能、高保真的Android和iOS应用。 - -flutter优点主要包括: -- 跨平台 -- 开源 -- Hot Reload、响应式框架、及其丰富的控件以及开发工具 -- 灵活的界面设计以及控件组合 -- 借助可以移植的GPU加速的渲染引擎以及高性能ARM代码运行时已达到高质量的用户体验 - -#### Flutter Go 的由来 - -- Flutter学习资料太少,对于英文不好的同学相对来说比较困难 -- 官网文档示例不够健全,不够直观 -- 各个 widget 的用法各异,属性纷繁,要运行一个 widget 的 demo 往往要到处翻阅各种资料 - -#### Flutter Go 的优势 - -- 详解常用 widget 多达 **140+** 个 -- 配套 Demo 详解 widget 常规用法 -- 集中整合 widget 案例,一个 APP 搞定所有常用 widget 的用法 -- 持续迭代 ‘追新’ 官方版本 - -### app 预览 - - - - -### Core Team - - - - - - - - - - - -
- -
- @minghe -
- -
- @ryan730 -
- -
- @Nealyang -
- -
- @hanxu317317 -
- -
- @DeckeDeng -
- -### 版权说明 -- 感谢大家对 `flutter go` 的支持和下载,但近期发现,有类似直接被发布到苹果 app store 上的行为,并未注明真实来源,copyright 和 项目的 github 地址,以及开发者的版权相关信息( 包括删除"首页栏的版权声明"和"关于我们"的行为 ); - -- 上述行为,打击了 `flutter go` 开发者的积极性,同时干扰了 flutter go app 的正常发布渠道,基于 app 开源项目的发布特殊性,特更新 [LICENSE](LICENSE) 「 开源许可证 」,由 MIT 协议 更改为 BSD 协议, 同时建议不要随意发布到公共渠道的应用商店,影响官方 `flutter go` 的app版本迭代; - -- 大家可以继续放心的开源使用,但是要求注意和遵守以下许可前提: -``` - * 版权声明样式 - //Copyright (c) 2018-present, Alibaba Group Holding Limited. All rights reserved. - - * 源代码的重新分发必须保留上述版权声明,条件清单和免责声明。 - - * 二进制形式的再分发必须复制上述版权声明,此条件列表以及文档中的以下免责声明和/或随分发提供的其他材料。 -``` -- 由于本开源项目是供大家学习和交流 flutter 之用,里面耗费了开发人员大量的心血,精力和热情,请尊重开发者的劳动成果,以及相关许可证之规定; - -- 大家的互相信任,尊重与支持,才是开源社区前进的动力和来源. - -Powered by 阿里拍卖前端团队 - +- 简历投递 邮箱:yifeng.yl@alibaba-inc.com +- 钉钉扫码直接连接: +- diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..25bfbc4e --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,45 @@ +analyzer: + strong-mode: + implicit-casts: false + errors: + avoid_returning_null_for_future: warning + cancel_subscriptions: warning + dead_code: warning + override_on_non_overriding_method: warning + unused_element: warning + unused_import: warning + avoid_empty_else: warning + exclude: + - test/** +linter: + rules: + - camel_case_types + - library_names + - library_prefixes + - file_names + - package_names + - non_constant_identifier_names + - constant_identifier_names + - sort_pub_dependencies + - directives_ordering + - curly_braces_in_flow_control_structures + - slash_for_doc_comments + - package_api_docs + - public_member_api_docs + - comment_references + - prefer_adjacent_string_concatenation + - prefer_interpolation_to_compose_strings + - unnecessary_brace_in_string_interps + - prefer_collection_literals + - prefer_is_empty + - prefer_is_not_empty + - prefer_for_elements_to_map_fromIterable + - avoid_function_literals_in_foreach_calls + - prefer_equal_for_default_values + - avoid_init_to_null + - unnecessary_getters_setters + - unnecessary_this + - prefer_initializing_formals + - unnecessary_new + - unnecessary_await_in_return + - avoid_void_async \ No newline at end of file diff --git a/docs/needWidget.md b/docs/needWidget.md new file mode 100644 index 00000000..c17d73e6 --- /dev/null +++ b/docs/needWidget.md @@ -0,0 +1,39 @@ +#待加入的组件 + +以下是flutter go 中缺失的部分组件. 欢迎大家共建.参与方式请看[共建说明](https://github.com/alibaba/flutter-go/blob/master/docs/contribute.md) +
注:✔表明已加入
+ +- [x] Scaffold +- [ ] Hero +- [ ] Listener +- [ ] Safearea +- [ ] ClipRect +- [ ] WillPopScope +- [ ] FutureBuilder +- [ ] StreamBuilder +- [ ] Notification +- [ ] runZoned +- [ ] IgnorePointer +- [ ] AbsorbPointer +- [ ] FlutterLogo +- [ ] Placeholder +- [ ] Offstage +- [ ] Visibility +- [ ] Baseline +- [ ] CustomPainter +- [ ] Border +- [ ] Wrap +- [ ] Transform +- [ ] SingleChildScrollView +- [ ] Positioned +- [ ] InheritedWidget +- [ ] PageView +- [ ] LayoutBuilder +- [ ] MediaQuery +- [ ] RefreshIndicator +- [ ] Opacity +- [ ] ExcludeSemantics +- [ ] DataTable +- [ ] Tooltip +- [ ] Form +- [ ] FormField \ No newline at end of file diff --git a/docs/widget.md b/docs/widget.md index 715b3e85..08fe6492 100644 --- a/docs/widget.md +++ b/docs/widget.md @@ -109,7 +109,7 @@ lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b0 当我们的本地功能调试没有问题. 想要申请合并到主分支时.需要按以下流程进行 -1.新建issue, 按照widget page类型模板, 填写需要的相关数据 +1.新建issue, 按照page about类型模板, 填写需要的相关数据 ![](https://img.alicdn.com/tfs/TB1YMkCdUH1gK0jSZSyXXXtlpXa-805-354.png) diff --git a/go-cli/src/cli_command_runder.dart b/go-cli/src/cli_command_runder.dart index 4fea5a2f..5a42f5f8 100644 --- a/go-cli/src/cli_command_runder.dart +++ b/go-cli/src/cli_command_runder.dart @@ -1,5 +1,5 @@ import 'dart:async'; - +import 'dart:io'; import 'package:args/args.dart'; import 'package:args/command_runner.dart'; //import './version.dart'; @@ -20,11 +20,18 @@ class _CommandRunner extends CommandRunner { addCommand(CreatePageCommand()); addCommand(WatchCommand()); addCommand(Build()); - } @override Future runCommand(ArgResults topLevelResults) async { + bool isProject = await Directory('./go-cli').exists(); + // 防止用户在gocli下运行 + + if (!isProject) { + print("请在fluttergo项目根目录中运行,而不是go-cli目录中"); + return 0; + } + if (topLevelResults['version'] as bool) { return 0; } diff --git a/go-cli/src/command/create_page.dart b/go-cli/src/command/create_page.dart index aa7b4f62..d3ebdb21 100644 --- a/go-cli/src/command/create_page.dart +++ b/go-cli/src/command/create_page.dart @@ -74,7 +74,7 @@ void createPage() async { // 创建root文件 await createFile(demoPath); - pageMarkdown = await readeFile("${environmentVars['PWD']}/go-cli/utils/tpl.md"); + pageMarkdown = await readeFile("go-cli/utils/tpl.md"); writeContent2Path('$demoPath/', 'index.dart', """ String getMd() { diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 00000000..c9c6343b --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/xj.deng/development/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/xj.deng/alibaba/xj_fluttergo/flutter-go" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_FRAMEWORK_DIR=/Users/xj.deng/development/flutter/bin/cache/artifacts/engine/ios-release" +export "FLUTTER_BUILD_NAME=1.0.6" +export "FLUTTER_BUILD_NUMBER=1.0.6" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2b500e72..110536b3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -352,7 +352,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", + "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( @@ -553,7 +553,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + CURRENT_PROJECT_VERSION = 125; DEVELOPMENT_TEAM = 4WLT68XRNA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -566,11 +566,12 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); + MARKETING_VERSION = 1.2.5; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -584,7 +585,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + CURRENT_PROJECT_VERSION = 125; DEVELOPMENT_TEAM = 4WLT68XRNA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -597,11 +598,12 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); + MARKETING_VERSION = 1.2.5; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/1024*1024@as.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/1024x1024@as.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/1024*1024@as.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/1024x1024@as.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/120*120@2x-1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/120x120@2x-1.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/120*120@2x-1.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/120x120@2x-1.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/120*120@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/120x120@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/120*120@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/120x120@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/152*152.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/152x152.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/152*152.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/152x152.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/167*167.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/167x167.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/167*167.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/167x167.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/180*180@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/180x180@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/180*180@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/180x180@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/20*20.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/20x20.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/20*20.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/20x20.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/29*29@1x-2.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/29x29@1x-2.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/29*29@1x-2.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/29x29@1x-2.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/29*29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/29x29@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/29*29@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/29x29@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x-1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x-1.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x-1.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x-1.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x-2.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x-2.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x-2.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x-2.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/40*40@1x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/40x40@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/58*58@2x-1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/58x58@2x-1.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/58*58@2x-1.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/58x58@2x-1.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/58*58@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/58x58@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/58*58@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/58x58@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/60*60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/60x60@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/60*60@3x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/60x60@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/76*76.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/76x76.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/76*76.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/76x76.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/80*80@2x-1.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/80x80@2x-1.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/80*80@2x-1.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/80x80@2x-1.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/80*80@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/80x80@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/80*80@2x.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/80x80@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/87*87.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/87x87.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/87*87.png rename to ios/Runner/Assets.xcassets/AppIcon.appiconset/87x87.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json index 7fbfe11e..07cf334f 100644 --- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -3,115 +3,115 @@ { "size" : "20x20", "idiom" : "iphone", - "filename" : "40*40@1x.png", + "filename" : "40x40@1x.png", "scale" : "2x" }, { "size" : "20x20", "idiom" : "iphone", - "filename" : "60*60@3x.png", + "filename" : "60x60@3x.png", "scale" : "3x" }, { "size" : "29x29", "idiom" : "iphone", - "filename" : "29*29@1x.png", + "filename" : "29x29@1x.png", "scale" : "1x" }, { "size" : "29x29", "idiom" : "iphone", - "filename" : "58*58@2x.png", + "filename" : "58x58@2x.png", "scale" : "2x" }, { "size" : "29x29", "idiom" : "iphone", - "filename" : "87*87.png", + "filename" : "87x87.png", "scale" : "3x" }, { "size" : "40x40", "idiom" : "iphone", - "filename" : "80*80@2x.png", + "filename" : "80x80@2x.png", "scale" : "2x" }, { "size" : "40x40", "idiom" : "iphone", - "filename" : "120*120@2x.png", + "filename" : "120x120@2x.png", "scale" : "3x" }, { "size" : "60x60", "idiom" : "iphone", - "filename" : "120*120@2x-1.png", + "filename" : "120x120@2x-1.png", "scale" : "2x" }, { "size" : "60x60", "idiom" : "iphone", - "filename" : "180*180@3x.png", + "filename" : "180x180@3x.png", "scale" : "3x" }, { "size" : "20x20", "idiom" : "ipad", - "filename" : "20*20.png", + "filename" : "20x20.png", "scale" : "1x" }, { "size" : "20x20", "idiom" : "ipad", - "filename" : "40*40@1x-2.png", + "filename" : "40x40@1x-2.png", "scale" : "2x" }, { "size" : "29x29", "idiom" : "ipad", - "filename" : "29*29@1x-2.png", + "filename" : "29x29@1x-2.png", "scale" : "1x" }, { "size" : "29x29", "idiom" : "ipad", - "filename" : "58*58@2x-1.png", + "filename" : "58x58@2x-1.png", "scale" : "2x" }, { "size" : "40x40", "idiom" : "ipad", - "filename" : "40*40@1x-1.png", + "filename" : "40x40@1x-1.png", "scale" : "1x" }, { "size" : "40x40", "idiom" : "ipad", - "filename" : "80*80@2x-1.png", + "filename" : "80x80@2x-1.png", "scale" : "2x" }, { "size" : "76x76", "idiom" : "ipad", - "filename" : "76*76.png", + "filename" : "76x76.png", "scale" : "1x" }, { "size" : "76x76", "idiom" : "ipad", - "filename" : "152*152.png", + "filename" : "152x152.png", "scale" : "2x" }, { "size" : "83.5x83.5", "idiom" : "ipad", - "filename" : "167*167.png", + "filename" : "167x167.png", "scale" : "2x" }, { "size" : "1024x1024", "idiom" : "ios-marketing", - "filename" : "1024*1024@as.png", + "filename" : "1024x1024@as.png", "scale" : "1x" } ], diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index c6bb52b8..68c927b9 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -17,23 +17,37 @@ CFBundlePackageType APPL CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion - $(FLUTTER_BUILD_NUMBER) + $(CURRENT_PROJECT_VERSION) LSApplicationCategoryType LSRequiresIPhoneOS + NSAppleMusicUsageDescription + Apple音乐 + NSCalendarsUsageDescription + 测试所用相机权限 NSCameraUsageDescription 测试拍照 + NSContactsUsageDescription + 测试所用用户权限 + NSLocationAlwaysUsageDescription + 测试所用地理权限 + NSLocationWhenInUseUsageDescription + 测试所用位置权限 NSMicrophoneUsageDescription 测试麦克风 + NSMotionUsageDescription + 测试所用内存权限 NSPhotoLibraryAddUsageDescription 测试选择图片 NSPhotoLibraryUsageDescription - + 测试所用照片权限 + NSSpeechRecognitionUsageDescription + 测试所用语音识别权限 UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -53,5 +67,7 @@ UIViewControllerBasedStatusBarAppearance + kTCCServiceMediaLibrary + 测试所用音乐权限 diff --git a/lib/api/api.dart b/lib/api/api.dart index 748e3422..65c9d0ae 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -1,36 +1,36 @@ -class Api{ +class Api { // static const String BASE_URL = 'http://flutter-go.alibaba.net/'; static const String BASE_URL = 'https://flutter-go.pub/api/'; - static const String DO_LOGIN = BASE_URL+'doLogin';//登陆 + static const String DO_LOGIN = BASE_URL + 'doLogin'; //登陆 - static const String CHECK_LOGIN = BASE_URL+'checkLogin';//验证登陆 - - static const String LOGOUT = BASE_URL+'logout';//退出登陆 + static const String CHECK_LOGIN = BASE_URL + 'checkLogin'; //验证登陆 - static const String GET_USER_INFO = BASE_URL+'getUserInfo';//获取用户信息 + static const String LOGOUT = BASE_URL + 'logout'; //退出登陆 + static const String GET_USER_INFO = BASE_URL + 'getUserInfo'; //获取用户信息 - static const String VERSION = BASE_URL+'getAppVersion';//检查版本 + static const String VERSION = BASE_URL + 'getAppVersion'; //检查版本 - static const String FEEDBACK = BASE_URL+'auth/feedback';//建议反馈 + static const String FEEDBACK = BASE_URL + 'auth/feedback'; //建议反馈 // static const String LOTOUT = BASE_URL+'logout';//退出登陆 - static const String GET_ALL_COLLECTION = BASE_URL+'auth/getAllUserCollection';//获取全部收藏 + static const String GET_ALL_COLLECTION = + BASE_URL + 'auth/getAllUserCollection'; //获取全部收藏 - static const String REMOVE_COLLECTION = BASE_URL+'auth/removeCollection';//移除收藏 + static const String REMOVE_COLLECTION = + BASE_URL + 'auth/removeCollection'; //移除收藏 - static const String ADD_COLLECTION = BASE_URL+'auth/addCollection';//添加收藏 - - static const String CHECK_COLLECTED = BASE_URL+'checkCollected';//校验收藏 + static const String ADD_COLLECTION = BASE_URL + 'auth/addCollection'; //添加收藏 - static const String SET_THEMECOLOR = BASE_URL+'auth/setThemeColor';//设置主题颜色 + static const String CHECK_COLLECTED = BASE_URL + 'checkCollected'; //校验收藏 - static const String GET_THEMECOLOR = BASE_URL +'/getThemeColor';//获取主题颜色 + static const String SET_THEMECOLOR = BASE_URL + 'auth/setThemeColor'; //设置主题颜色 - static const String GET_WIDGET_TREE = BASE_URL + 'getCateList';//获取widget列表树 + static const String GET_THEMECOLOR = BASE_URL + '/getThemeColor'; //获取主题颜色 - static const String SEARCH_WIDGET = BASE_URL+'searchWidget';//搜索组件 -} + static const String GET_WIDGET_TREE = BASE_URL + 'getCateList'; //获取widget列表树 + static const String SEARCH_WIDGET = BASE_URL + 'searchWidget'; //搜索组件 +} diff --git a/lib/blocs/industry_api.dart b/lib/blocs/industry_api.dart index 7b271ca0..0dac3431 100644 --- a/lib/blocs/industry_api.dart +++ b/lib/blocs/industry_api.dart @@ -12,6 +12,7 @@ import 'package:html/parser.dart' show parse; import './search_result.dart'; var dio = new Dio(); + //class Api2 { // /// 关键字提示(起点) // Future> suggestion(String query) async { @@ -42,9 +43,11 @@ class Api { // http.Response response = await http.get( // "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query"); /// var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {}); - var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter"); + var response = + await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter"); var document = parse(response.data); var app = document.querySelectorAll('.res-title a'); + ///print('1=====>${query}'); ///print('2=====>${response.data}'); ////print('3=====>${app}'); @@ -59,11 +62,11 @@ class Api { ); }); - return Future.delayed(Duration(seconds:2), () { + return Future.delayed(Duration(seconds: 2), () { return res; }); //return suggestion; } } -Api api = Api(); \ No newline at end of file +Api api = Api(); diff --git a/lib/blocs/industry_bloc.dart b/lib/blocs/industry_bloc.dart index 1757f3b4..06a065aa 100644 --- a/lib/blocs/industry_bloc.dart +++ b/lib/blocs/industry_bloc.dart @@ -16,8 +16,8 @@ class SuggestionBloc extends Bloc { @override SuggestionState get initialState => SuggestionUninitialized(); @override - Stream mapEventToState(SuggestionEvent event)async* { - //Stream mapEventToState(SuggestionState currentState, SuggestionEvent event,) async* { + Stream mapEventToState(SuggestionEvent event) async* { + //Stream mapEventToState(SuggestionState currentState, SuggestionEvent event,) async* { if (event is SuggestionFetch) { //print('event==>${event}'); try { diff --git a/lib/blocs/industry_event.dart b/lib/blocs/industry_event.dart index b54e7940..e606a24c 100644 --- a/lib/blocs/industry_event.dart +++ b/lib/blocs/industry_event.dart @@ -23,4 +23,4 @@ class SuggestionClearFetch extends SuggestionEvent { @override String toString() => 'SuggestionClearFetch:清空界面'; -} \ No newline at end of file +} diff --git a/lib/blocs/industry_main.dart b/lib/blocs/industry_main.dart index fa49fac5..e331babb 100644 --- a/lib/blocs/industry_main.dart +++ b/lib/blocs/industry_main.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import './industry_bloc.dart'; + /// import './industry_event.dart'; import './industry_state.dart'; @@ -15,7 +16,7 @@ final SuggestionBloc suggestion = SuggestionBloc(); class IndustryPage extends StatefulWidget { final Function itemTitle; - IndustryPage({Key key,this.itemTitle}) : super(key: key); + IndustryPage({Key key, this.itemTitle}) : super(key: key); @override _IndustryState createState() => _IndustryState(); @@ -40,15 +41,13 @@ class _IndustryState extends State { return Center( child: Text('没有适合的结果,更换查询条件试试'), ); - }else { + } else { if (widget.itemTitle is Function) { return widget.itemTitle(state); } } } - return Center( - child: Text('没有适合的结果,更换查询条件试试') - ); + return Center(child: Text('没有适合的结果,更换查询条件试试')); } @override @@ -59,7 +58,7 @@ class _IndustryState extends State { Expanded( child: BlocBuilder( bloc: suggestion, - builder: (BuildContext context, SuggestionState state){ + builder: (BuildContext context, SuggestionState state) { /// print('BlocBuilder----${state}'); return renderItem(state); }, @@ -75,4 +74,4 @@ class _IndustryState extends State { //suggestion.dispose();//添加这个第二次进入会失灵 super.dispose(); } -} \ No newline at end of file +} diff --git a/lib/blocs/industry_model.dart b/lib/blocs/industry_model.dart index 550d29c7..74577c07 100644 --- a/lib/blocs/industry_model.dart +++ b/lib/blocs/industry_model.dart @@ -69,4 +69,4 @@ class Data { data['category'] = this.category; return data; } -} \ No newline at end of file +} diff --git a/lib/blocs/search_result.dart b/lib/blocs/search_result.dart index bf64d1b1..753619df 100644 --- a/lib/blocs/search_result.dart +++ b/lib/blocs/search_result.dart @@ -11,4 +11,4 @@ class SearchResult { String source; SearchResult({this.title, this.source}); -} \ No newline at end of file +} diff --git a/lib/components/cate_card.dart b/lib/components/cate_card.dart index aab9fa48..108a5e76 100644 --- a/lib/components/cate_card.dart +++ b/lib/components/cate_card.dart @@ -21,8 +21,6 @@ class _CateCardState extends State { _firstChildList = widget.category.children; } - - @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; @@ -100,14 +98,11 @@ class _CateCardState extends State { padding: const EdgeInsets.only(bottom: 10.0, top: 5.0), decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/paimaiLogo.png'), - alignment: Alignment.bottomRight - ), + image: AssetImage('assets/images/paimaiLogo.png'), + alignment: Alignment.bottomRight), ), child: WidgetItemContainer( - commonItems: this._firstChildList, - columnCount: 3 - ), + commonItems: this._firstChildList, columnCount: 3), ); } } diff --git a/lib/components/category.dart b/lib/components/category.dart index eee1035e..c6c20ca6 100644 --- a/lib/components/category.dart +++ b/lib/components/category.dart @@ -3,18 +3,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import '../routers/application.dart'; + /// import '../model/cat.dart'; import '../model/widget.dart'; import '../widgets/index.dart'; import '../components/widget_item_container.dart'; - - class CategoryHome extends StatefulWidget { CategoryHome(this.token); final String token; - @override _CategoryHome createState() => new _CategoryHome(); } @@ -26,7 +24,6 @@ class _CategoryHome extends State { List widgetPoints = []; List catHistory = new List(); - // 所有的可用demos; List widgetDemosList = new WidgetDemoList().getDemos(); @@ -39,26 +36,13 @@ class _CategoryHome extends State { CommonItem targetGroup = Application.widgetTree.find(widget.token) ?? []; print("targetGroup::: $targetGroup"); - catHistory.add( - targetGroup - ); + catHistory.add(targetGroup); this.setState(() { items = targetGroup.children; }); searchCatOrWidget(); } - - - Future back() { -// if (catHistory.length == 1) { -// return Future.value(true); -// } -// catHistory.removeLast(); -// searchCatOrWidget(); - return Future.value(true); - } - void go(CommonItem cat) { catHistory.add(cat); searchCatOrWidget(); @@ -66,10 +50,9 @@ class _CategoryHome extends State { void searchCatOrWidget() async { /// CommonItem widgetTree = Application.widgetTree; - // 假设进入这个界面的parent一定存在 + // 假设进入这个界面的parent一定存在 CommonItem targetGroup = catHistory.last; - this.setState(() { title = targetGroup.name; }); @@ -79,14 +62,9 @@ class _CategoryHome extends State { go(cat); } - - Widget _buildContent() { - WidgetItemContainer wiContaienr = WidgetItemContainer( - columnCount: 3, - commonItems: items - ); - + WidgetItemContainer wiContaienr = + WidgetItemContainer(columnCount: 3, commonItems: items); return Container( padding: const EdgeInsets.only(bottom: 10.0, top: 5.0), @@ -102,26 +80,15 @@ class _CategoryHome extends State { @override Widget build(BuildContext context) { - - return Scaffold( appBar: AppBar( title: Text("$title"), ), - body: WillPopScope( - - onWillPop: () { - return back(); - }, - - child: ListView( - children: [ - _buildContent(), - ], - ), - // child: Container(color: Colors.blue,child: Text('123'),), + body: ListView( + children: [ + _buildContent(), + ], ), ); } } - diff --git a/lib/components/disclaimer_msg.dart b/lib/components/disclaimer_msg.dart index 78ebb0a5..a2383815 100644 --- a/lib/components/disclaimer_msg.dart +++ b/lib/components/disclaimer_msg.dart @@ -9,7 +9,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; - const disclaimerText1 = '\r\r\r\r\r\r本APP属于个人的非赢利性开源项目,以供开源社区使用,凡本APP转载的所有的文章 、图片、音频、视频文件等资料的版权归版权所有人所有,本APP采用的非本站原创文章及图片等内容无法一一和版权者联系,如果本网所选内容的文章作者及编辑认为其作品不宜上网供大家浏览,或不应无偿使用请及时用电子邮件或电话通知我们,以迅速采取适当措施,避免给双方造成不必要的经济损失。'; const disclaimerText2 = @@ -33,9 +32,12 @@ class DisclaimerMsgState extends State { void refs(bool value) async { final SharedPreferences prefs = await _prefs; final bool unKnow = value; + _valBool = value; + _readed = value; if (mounted) { setState(() { - _unKnow = prefs.setBool("disclaimer::Boolean", unKnow).then((bool success) { + _unKnow = + prefs.setBool("disclaimer::Boolean", unKnow).then((bool success) { return unKnow; }); }); @@ -60,51 +62,66 @@ class DisclaimerMsgState extends State { context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { - return AlertDialog( - //title: Text('免责声明'), - content: SingleChildScrollView( - child: ListBody( - children: [ - Container( - padding: EdgeInsets.fromLTRB(5.0, 5.0, 10.0, 10.0), - //width: 100, - height: 35, - child: Text('免责声明', - style: TextStyle( - fontSize: 18, fontWeight: FontWeight.w700)), - decoration: BoxDecoration( - //color: Colors.blue, - image: DecorationImage( - fit: BoxFit.fitWidth, - image: AssetImage('assets/images/paimaiLogo.png')), - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - //alignment: Alignment.bottomRight, - )), - SizedBox(height: 20), - Text(disclaimerText1), - Text(disclaimerText2), - ], - ), - ), - shape: RoundedRectangleBorder( - borderRadius: new BorderRadius.circular(20.0)), // 圆角 - - actions: [ - new Container( - width: 250, - child: _create(), - ) - ], - ); + return DisclaimerMsgDialog(_valBool, _readed, (b) { + refs(b); + }); }, ); } + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + showAlertDialog(context); + }, + child: Stack( + //alignment: const Alignment(1.6, 1.6), + children: [ + Container( + width: 90.0, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.horizontal(right: Radius.circular(10)), + color: Colors.black45, + ), + child: Text( + '🔔 免责声明', + style: TextStyle( + fontSize: 14.0, + //fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ], + )); + } +} + +class DisclaimerMsgDialog extends StatefulWidget { + final bool valBool; + final bool readed; + final ValueChanged onValueChanged; + + DisclaimerMsgDialog(this.valBool, this.readed, this.onValueChanged); + + @override + _DisclaimerMsgDialogState createState() => _DisclaimerMsgDialogState(); +} + +class _DisclaimerMsgDialogState extends State { + bool readBool; + + @override + void initState() { + super.initState(); + readBool = widget.valBool; + } + Row _create() { //已读 - if (_readed) { + if (widget.readed) { return Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -125,72 +142,91 @@ class DisclaimerMsgState extends State { ); } + /// 选中状态更新,并返回数据 + checkChanged() { + if (mounted) { + setState(() { + readBool = !readBool; + }); + } + } + //第一次读取 return Row(mainAxisAlignment: MainAxisAlignment.spaceAround, //crossAxisAlignment:CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Checkbox( - activeColor: Theme.of(context).primaryColor, - tristate: false, - value: _valBool, - onChanged: (bool bol) { - if(mounted) { - setState(() { - _valBool = bol; - }); - } - Navigator.of(context).pop(); // here I pop to avoid multiple Dialogs - showAlertDialog(context); //here i call the same function - }), - Text('不再自动提示', style: TextStyle(fontSize: 14)), - ], + GestureDetector( + onTap: () { + checkChanged(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Checkbox( + activeColor: Theme.of(context).primaryColor, + tristate: false, + value: readBool, + onChanged: (bool bol) { + checkChanged(); + }), + Text('不再自动提示', style: TextStyle(fontSize: 14)), + ], + ), ), FlatButton( child: Text('知道了', style: TextStyle(fontSize: 16, color: Colors.white)), //可点击 - color: _valBool + color: readBool ? Theme.of(context).primaryColor : Theme.of(context).primaryColor.withAlpha(800), onPressed: () { - // if (_valBool) { - refs(_valBool); + widget.onValueChanged(readBool); Navigator.of(context).pop(); - // } }, ), ]); } + @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () { - showAlertDialog(context); - }, - child: Stack( - //alignment: const Alignment(1.6, 1.6), - children: [ + return AlertDialog( + //title: Text('免责声明'), + content: SingleChildScrollView( + child: ListBody( + children: [ Container( - width: 90.0, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: - BorderRadius.horizontal(right: Radius.circular(10)), - color: Colors.black45, - ), - child: Text( - '🔔 免责声明', - style: TextStyle( - fontSize: 14.0, - //fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - ), + padding: EdgeInsets.fromLTRB(5.0, 5.0, 10.0, 10.0), + //width: 100, + height: 35, + child: Text('免责声明', + style: + TextStyle(fontSize: 18, fontWeight: FontWeight.w700)), + decoration: BoxDecoration( + //color: Colors.blue, + image: DecorationImage( + fit: BoxFit.fitWidth, + image: AssetImage('assets/images/paimaiLogo.png')), + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + //alignment: Alignment.bottomRight, + )), + SizedBox(height: 20), + Text(disclaimerText1), + Text(disclaimerText2), ], - )); + ), + ), + shape: RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(20.0)), // 圆角 + + actions: [ + new Container( + width: 250, + child: _create(), + ) + ], + ); } } diff --git a/lib/components/flutter_markdown/lib/src/builder.dart b/lib/components/flutter_markdown/lib/src/builder.dart index 089e83c3..ba1f533f 100644 --- a/lib/components/flutter_markdown/lib/src/builder.dart +++ b/lib/components/flutter_markdown/lib/src/builder.dart @@ -44,18 +44,18 @@ class _BlockElement { /// A collection of widgets that should be placed adjacent to (inline with) /// other inline elements in the same parent block. -/// -/// Inline elements can be textual (a/em/strong) represented by [RichText] +/// +/// Inline elements can be textual (a/em/strong) represented by [RichText] /// widgets or images (img) represented by [Image.network] widgets. -/// +/// /// Inline elements can be nested within other inline elements, inheriting their /// parent's style along with the style of the block they are in. -/// -/// When laying out inline widgets, first, any adjacent RichText widgets are +/// +/// When laying out inline widgets, first, any adjacent RichText widgets are /// merged, then, all inline widgets are enclosed in a parent [Wrap] widget. class _InlineElement { _InlineElement(this.tag, {this.style}); - + final String tag; /// Created by merging the style defined for this element's [tag] in the @@ -85,12 +85,8 @@ abstract class MarkdownBuilderDelegate { /// * [Markdown], which is a widget that parses and displays Markdown. class MarkdownBuilder implements md.NodeVisitor { /// Creates an object that builds a [Widget] tree from parsed Markdown. - MarkdownBuilder({ - this.delegate, - this.styleSheet, - this.imageDirectory, - this.demoParser - }); + MarkdownBuilder( + {this.delegate, this.styleSheet, this.imageDirectory, this.demoParser}); /// A delegate that controls how link and `pre` elements behave. final MarkdownBuilderDelegate delegate; @@ -99,6 +95,7 @@ class MarkdownBuilder implements md.NodeVisitor { final MarkdownStyleSheet styleSheet; final DemoBuilder demoParser; + /// The base directory holding images referenced by Img tags with local file paths. final Directory imageDirectory; @@ -107,7 +104,6 @@ class MarkdownBuilder implements md.NodeVisitor { final List<_InlineElement> _inlines = <_InlineElement>[]; final List _linkHandlers = []; - /// Returns widgets that display the given Markdown nodes. /// /// The returned widgets are typically used as children in a [ListView]. @@ -136,12 +132,12 @@ class MarkdownBuilder implements md.NodeVisitor { _addParentInlineIfNeeded(_blocks.last.tag); final TextSpan span = _blocks.last.tag == 'pre' - ? delegate.formatText(styleSheet, text.text) - : new TextSpan( - style: _inlines.last.style, - text: text.text, - recognizer: _linkHandlers.isNotEmpty ? _linkHandlers.last : null, - ); + ? delegate.formatText(styleSheet, text.text) + : new TextSpan( + style: _inlines.last.style, + text: text.text, + recognizer: _linkHandlers.isNotEmpty ? _linkHandlers.last : null, + ); _inlines.last.children.add(new RichText( textScaleFactor: styleSheet.textScaleFactor, @@ -155,8 +151,7 @@ class MarkdownBuilder implements md.NodeVisitor { final String tag = element.tag; if (_isBlockTag(tag)) { _addAnonymousBlockIfNeeded(styleSheet.styles[tag]); - if (_isListTag(tag)) - _listIndents.add(tag); + if (_isListTag(tag)) _listIndents.add(tag); _blocks.add(new _BlockElement(tag)); } else { _addParentInlineIfNeeded(_blocks.last.tag); @@ -232,7 +227,6 @@ class MarkdownBuilder implements md.NodeVisitor { } _addBlockChild(child); } else { - final _InlineElement current = _inlines.removeLast(); final _InlineElement parent = _inlines.last; @@ -245,12 +239,12 @@ class MarkdownBuilder implements md.NodeVisitor { current.children.add(_buildGoDemos(element.attributes)); } - if (current.children.isNotEmpty) { parent.children.addAll(current.children); } } } + Widget _buildGoDemos(Map attrs) { Widget targetGoDemos; @@ -263,8 +257,7 @@ class MarkdownBuilder implements md.NodeVisitor { Widget _buildImage(String src) { final List parts = src.split('#'); - if (parts.isEmpty) - return const SizedBox(); + if (parts.isEmpty) return const SizedBox(); final String path = parts.first; double width; @@ -300,10 +293,12 @@ class MarkdownBuilder implements md.NodeVisitor { } } - Widget _handleDataSchemeUri(Uri uri, final double width, final double height) { + Widget _handleDataSchemeUri( + Uri uri, final double width, final double height) { final String mimeType = uri.data.mimeType; if (mimeType.startsWith('image/')) { - return new Image.memory(uri.data.contentAsBytes(), width: width, height: height); + return new Image.memory(uri.data.contentAsBytes(), + width: width, height: height); } else if (mimeType.startsWith('text/')) { return new Text(uri.data.contentAsString()); } @@ -312,12 +307,14 @@ class MarkdownBuilder implements md.NodeVisitor { Widget _buildBullet(String listTag) { if (listTag == 'ul') - return new Text('•', textAlign: TextAlign.center, style: styleSheet.styles['li']); + return new Text('•', + textAlign: TextAlign.center, style: styleSheet.styles['li']); final int index = _blocks.last.nextListIndex; return new Padding( padding: const EdgeInsets.only(right: 5.0), - child: new Text('${index + 1}.', textAlign: TextAlign.right, style: styleSheet.styles['li']), + child: new Text('${index + 1}.', + textAlign: TextAlign.right, style: styleSheet.styles['li']), ); } @@ -356,7 +353,9 @@ class MarkdownBuilder implements md.NodeVisitor { List _mergeInlineChildren(_InlineElement inline) { List mergedTexts = []; for (Widget child in inline.children) { - if (mergedTexts.isNotEmpty && mergedTexts.last is RichText && child is RichText) { + if (mergedTexts.isNotEmpty && + mergedTexts.last is RichText && + child is RichText) { RichText previous = mergedTexts.removeLast(); List children = previous.text.children != null ? new List.from(previous.text.children) diff --git a/lib/components/flutter_markdown/lib/src/style_sheet.dart b/lib/components/flutter_markdown/lib/src/style_sheet.dart index 6c44b773..4750284d 100644 --- a/lib/components/flutter_markdown/lib/src/style_sheet.dart +++ b/lib/components/flutter_markdown/lib/src/style_sheet.dart @@ -7,45 +7,45 @@ import 'package:flutter/material.dart'; /// Defines which [TextStyle] objects to use for which Markdown elements. class MarkdownStyleSheet { /// Creates an explicit mapping of [TextStyle] objects to Markdown elements. - MarkdownStyleSheet({ - this.a, - this.p, - this.code, - this.h1, - this.h2, - this.h3, - this.h4, - this.h5, - this.h6, - this.em, - this.strong, - this.blockquote, - this.img, - this.blockSpacing, - this.listIndent, - this.blockquotePadding, - this.blockquoteDecoration, - this.codeblockPadding, - this.codeblockDecoration, - this.horizontalRuleDecoration, - this.textScaleFactor = 1.0 - }) : _styles = { - 'a': a, - 'p': p, - 'li': p, - 'code': code, - 'pre': p, - 'h1': h1, - 'h2': h2, - 'h3': h3, - 'h4': h4, - 'h5': h5, - 'h6': h6, - 'em': em, - 'strong': strong, - 'blockquote': blockquote, - 'img': img, - }; + MarkdownStyleSheet( + {this.a, + this.p, + this.code, + this.h1, + this.h2, + this.h3, + this.h4, + this.h5, + this.h6, + this.em, + this.strong, + this.blockquote, + this.img, + this.blockSpacing, + this.listIndent, + this.blockquotePadding, + this.blockquoteDecoration, + this.codeblockPadding, + this.codeblockDecoration, + this.horizontalRuleDecoration, + this.textScaleFactor = 1.0}) + : _styles = { + 'a': a, + 'p': p, + 'li': p, + 'code': code, + 'pre': p, + 'h1': h1, + 'h2': h2, + 'h3': h3, + 'h4': h4, + 'h5': h5, + 'h6': h6, + 'em': em, + 'strong': strong, + 'blockquote': blockquote, + 'img': img, + }; /// Creates a [MarkdownStyleSheet] from the [TextStyle]s in the provided [ThemeData]. factory MarkdownStyleSheet.fromTheme(ThemeData theme) { @@ -54,10 +54,9 @@ class MarkdownStyleSheet { a: const TextStyle(color: Colors.blue), p: theme.textTheme.body1, code: new TextStyle( - color: Colors.grey.shade700, - fontFamily: "monospace", - fontSize: theme.textTheme.body1.fontSize * 0.85 - ), + color: Colors.grey.shade700, + fontFamily: "monospace", + fontSize: theme.textTheme.body1.fontSize * 0.85), h1: theme.textTheme.headline, h2: theme.textTheme.title, h3: theme.textTheme.subhead, @@ -72,18 +71,15 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - color: Colors.blue.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.blue.shade100, + borderRadius: new BorderRadius.circular(2.0)), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - color: Colors.grey.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.grey.shade100, + borderRadius: new BorderRadius.circular(2.0)), horizontalRuleDecoration: new BoxDecoration( border: new Border( - top: new BorderSide(width: 5.0, color: Colors.grey.shade300) - ), + top: new BorderSide(width: 5.0, color: Colors.grey.shade300)), ), ); } @@ -97,10 +93,9 @@ class MarkdownStyleSheet { a: const TextStyle(color: Colors.blue), p: theme.textTheme.body1, code: new TextStyle( - color: Colors.grey.shade700, - fontFamily: "monospace", - fontSize: theme.textTheme.body1.fontSize * 0.85 - ), + color: Colors.grey.shade700, + fontFamily: "monospace", + fontSize: theme.textTheme.body1.fontSize * 0.85), h1: theme.textTheme.display3, h2: theme.textTheme.display2, h3: theme.textTheme.display1, @@ -115,18 +110,15 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - color: Colors.blue.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.blue.shade100, + borderRadius: new BorderRadius.circular(2.0)), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - color: Colors.grey.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.grey.shade100, + borderRadius: new BorderRadius.circular(2.0)), horizontalRuleDecoration: new BoxDecoration( border: new Border( - top: new BorderSide(width: 5.0, color: Colors.grey.shade300) - ), + top: new BorderSide(width: 5.0, color: Colors.grey.shade300)), ), ); } @@ -176,8 +168,9 @@ class MarkdownStyleSheet { blockquoteDecoration: blockquoteDecoration ?? this.blockquoteDecoration, codeblockPadding: codeblockPadding ?? this.codeblockPadding, codeblockDecoration: codeblockDecoration ?? this.codeblockDecoration, - horizontalRuleDecoration: horizontalRuleDecoration ?? this.horizontalRuleDecoration, - textScaleFactor : textScaleFactor ?? this.textScaleFactor, + horizontalRuleDecoration: + horizontalRuleDecoration ?? this.horizontalRuleDecoration, + textScaleFactor: textScaleFactor ?? this.textScaleFactor, ); } @@ -250,32 +243,30 @@ class MarkdownStyleSheet { @override bool operator ==(dynamic other) { - if (identical(this, other)) - return true; - if (other.runtimeType != MarkdownStyleSheet) - return false; + if (identical(this, other)) return true; + if (other.runtimeType != MarkdownStyleSheet) return false; final MarkdownStyleSheet typedOther = other; - return typedOther.a == a - && typedOther.p == p - && typedOther.code == code - && typedOther.h1 == h1 - && typedOther.h2 == h2 - && typedOther.h3 == h3 - && typedOther.h4 == h4 - && typedOther.h5 == h5 - && typedOther.h6 == h6 - && typedOther.em == em - && typedOther.strong == strong - && typedOther.blockquote == blockquote - && typedOther.img == img - && typedOther.blockSpacing == blockSpacing - && typedOther.listIndent == listIndent - && typedOther.blockquotePadding == blockquotePadding - && typedOther.blockquoteDecoration == blockquoteDecoration - && typedOther.codeblockPadding == codeblockPadding - && typedOther.codeblockDecoration == codeblockDecoration - && typedOther.horizontalRuleDecoration == horizontalRuleDecoration - && typedOther.textScaleFactor == textScaleFactor; + return typedOther.a == a && + typedOther.p == p && + typedOther.code == code && + typedOther.h1 == h1 && + typedOther.h2 == h2 && + typedOther.h3 == h3 && + typedOther.h4 == h4 && + typedOther.h5 == h5 && + typedOther.h6 == h6 && + typedOther.em == em && + typedOther.strong == strong && + typedOther.blockquote == blockquote && + typedOther.img == img && + typedOther.blockSpacing == blockSpacing && + typedOther.listIndent == listIndent && + typedOther.blockquotePadding == blockquotePadding && + typedOther.blockquoteDecoration == blockquoteDecoration && + typedOther.codeblockPadding == codeblockPadding && + typedOther.codeblockDecoration == codeblockDecoration && + typedOther.horizontalRuleDecoration == horizontalRuleDecoration && + typedOther.textScaleFactor == textScaleFactor; } @override diff --git a/lib/components/flutter_markdown/lib/src/widget.dart b/lib/components/flutter_markdown/lib/src/widget.dart index c9d5cbaf..269e7bbb 100644 --- a/lib/components/flutter_markdown/lib/src/widget.dart +++ b/lib/components/flutter_markdown/lib/src/widget.dart @@ -11,6 +11,7 @@ import 'package:meta/meta.dart'; import 'builder.dart'; import 'style_sheet.dart'; + // typedef Widget ItemDemoBuilder(Map attrs); @@ -22,7 +23,8 @@ typedef void MarkdownTapLinkCallback(String href); /// Creates a format [TextSpan] given a string. /// /// Used by [MarkdownWidget] to highlight the contents of `pre` elements. -abstract class SyntaxHighlighter { // ignore: one_member_abstracts +abstract class SyntaxHighlighter { + // ignore: one_member_abstracts /// Returns the formated [TextSpan] for the given string. TextSpan format(String source); } @@ -49,8 +51,8 @@ abstract class MarkdownWidget extends StatefulWidget { this.onTapLink, this.imageDirectory, this.demoBuilder, - }) : assert(data != null), - super(key: key); + }) : assert(data != null), + super(key: key); /// The Markdown to display. final String data; @@ -72,6 +74,7 @@ abstract class MarkdownWidget extends StatefulWidget { final Directory imageDirectory; final ItemDemoBuilder demoBuilder; + /// Subclasses should override this function to display the given children, /// which are the parsed representation of [data]. @protected @@ -91,7 +94,8 @@ class DemosSyntax extends md.InlineSyntax { } } -class _MarkdownWidgetState extends State implements MarkdownBuilderDelegate { +class _MarkdownWidgetState extends State + implements MarkdownBuilderDelegate { List _children; final List _recognizers = []; @@ -104,9 +108,8 @@ class _MarkdownWidgetState extends State implements MarkdownBuil @override void didUpdateWidget(MarkdownWidget oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.data != oldWidget.data - || widget.styleSheet != oldWidget.styleSheet) - _parseMarkdown(); + if (widget.data != oldWidget.data || + widget.styleSheet != oldWidget.styleSheet) _parseMarkdown(); } @override @@ -116,44 +119,43 @@ class _MarkdownWidgetState extends State implements MarkdownBuil } void _parseMarkdown() { - final MarkdownStyleSheet styleSheet = widget.styleSheet ?? new MarkdownStyleSheet.fromTheme(Theme.of(context)); + final MarkdownStyleSheet styleSheet = widget.styleSheet ?? + new MarkdownStyleSheet.fromTheme(Theme.of(context)); _disposeRecognizers(); // TODO: This can be optimized by doing the split and removing \r at the same time final List lines = widget.data.replaceAll('\r\n', '\n').split('\n'); final md.ExtensionSet extens = new md.ExtensionSet([ - md.FencedCodeBlockSyntax() + md.FencedCodeBlockSyntax() ], [ new DemosSyntax(), new md.InlineHtmlSyntax(), ]); - final md.Document document = new md.Document(encodeHtml: false, extensionSet: extens); + final md.Document document = + new md.Document(encodeHtml: false, extensionSet: extens); final MarkdownBuilder builder = new MarkdownBuilder( - delegate: this, - styleSheet: styleSheet, - imageDirectory: widget.imageDirectory, - demoParser: widget.demoBuilder - ); + delegate: this, + styleSheet: styleSheet, + imageDirectory: widget.imageDirectory, + demoParser: widget.demoBuilder); _children = builder.build(document.parseLines(lines)); } void _disposeRecognizers() { - if (_recognizers.isEmpty) - return; - final List localRecognizers = new List.from(_recognizers); + if (_recognizers.isEmpty) return; + final List localRecognizers = + new List.from(_recognizers); _recognizers.clear(); - for (GestureRecognizer recognizer in localRecognizers) - recognizer.dispose(); + for (GestureRecognizer recognizer in localRecognizers) recognizer.dispose(); } @override GestureRecognizer createLink(String href) { final TapGestureRecognizer recognizer = new TapGestureRecognizer() ..onTap = () { - if (widget.onTapLink != null) - widget.onTapLink(href); - }; + if (widget.onTapLink != null) widget.onTapLink(href); + }; _recognizers.add(recognizer); return recognizer; } @@ -189,19 +191,17 @@ class MarkdownBody extends MarkdownWidget { Directory imageDirectory, ItemDemoBuilder demoBuilder, }) : super( - key: key, - data: data, - styleSheet: styleSheet, - syntaxHighlighter: syntaxHighlighter, - onTapLink: onTapLink, - imageDirectory: imageDirectory, - demoBuilder: demoBuilder - ); + key: key, + data: data, + styleSheet: styleSheet, + syntaxHighlighter: syntaxHighlighter, + onTapLink: onTapLink, + imageDirectory: imageDirectory, + demoBuilder: demoBuilder); @override Widget build(BuildContext context, List children) { - if (children.length == 1) - return children.single; + if (children.length == 1) return children.single; return new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: children, @@ -229,13 +229,13 @@ class Markdown extends MarkdownWidget { Directory imageDirectory, this.padding: const EdgeInsets.all(16.0), }) : super( - key: key, - data: data, - styleSheet: styleSheet, - syntaxHighlighter: syntaxHighlighter, - onTapLink: onTapLink, - imageDirectory: imageDirectory, - ); + key: key, + data: data, + styleSheet: styleSheet, + syntaxHighlighter: syntaxHighlighter, + onTapLink: onTapLink, + imageDirectory: imageDirectory, + ); /// The amount of space by which to inset the children. final EdgeInsets padding; diff --git a/lib/components/full_screen_code_dialog.dart b/lib/components/full_screen_code_dialog.dart index 5a40d9cf..c9eddcce 100644 --- a/lib/components/full_screen_code_dialog.dart +++ b/lib/components/full_screen_code_dialog.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:32 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 14:42:00 @@ -24,7 +24,8 @@ class _FullScreenCodeDialogState extends State { void didChangeDependencies() { print('widget.filePath=======${widget.filePath}'); if (widget.filePath != null) { - getExampleCode(context,'${widget.filePath}', DefaultAssetBundle.of(context)) + getExampleCode( + context, '${widget.filePath}', DefaultAssetBundle.of(context)) .then((String code) { if (mounted) { setState(() { @@ -48,6 +49,7 @@ class _FullScreenCodeDialogState extends State { }); } } + @override Widget build(BuildContext context) { final SyntaxHighlighterStyle style = @@ -60,16 +62,17 @@ class _FullScreenCodeDialogState extends State { body = const Center(child: CircularProgressIndicator()); } else { Widget _codeWidget; - try{ + try { DartSyntaxHighlighter(style).format(_exampleCode); _codeWidget = RichText( text: TextSpan( - style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0), - children: [ - DartSyntaxHighlighter(style).format(_exampleCode) - ],), + style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0), + children: [ + DartSyntaxHighlighter(style).format(_exampleCode) + ], + ), ); - }catch (err){ + } catch (err) { _codeWidget = Text(_exampleCode); } body = SingleChildScrollView( diff --git a/lib/components/home_banner.dart b/lib/components/home_banner.dart index 36345cbe..23d46e69 100644 --- a/lib/components/home_banner.dart +++ b/lib/components/home_banner.dart @@ -8,8 +8,7 @@ class HomeBanner extends StatefulWidget { final List bannerStories; final OnTapBannerItem onTap; - HomeBanner(this.bannerStories, this.onTap, {Key key}) - :super(key: key); + HomeBanner(this.bannerStories, this.onTap, {Key key}) : super(key: key); @override State createState() { @@ -27,11 +26,11 @@ class _BannerState extends State { void initState() { super.initState(); controller = PageController(initialPage: realIndex); - timer = Timer.periodic(Duration(seconds: 5), (timer) { // 自动滚动 + timer = Timer.periodic(Duration(seconds: 5), (timer) { + // 自动滚动 /// print(realIndex); controller.animateToPage(realIndex + 1, - duration: Duration(milliseconds: 300), - curve: Curves.linear); + duration: Duration(milliseconds: 300), curve: Curves.linear); }); } @@ -50,7 +49,10 @@ class _BannerState extends State { margin: EdgeInsets.only(top: 10.0, right: 5.0), padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 2.0), child: Text("${++index}/$itemCount", - style: TextStyle( color: Colors.white70, fontSize: 12.0, fontWeight:FontWeight.bold )), + style: TextStyle( + color: Colors.white70, + fontSize: 12.0, + fontWeight: FontWeight.bold)), ); } @@ -58,43 +60,45 @@ class _BannerState extends State { Widget build(BuildContext context) { return Container( height: 226.0, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - PageView( - controller: controller, - onPageChanged: _onPageChanged, - children: _buildItems(),), - _buildIndicator(), // 下面的小点 - Positioned(//方法二 - top: 0.0, - right: 0.0, - child: _numberIndicator(context,virtualIndex,widget.bannerStories.length), - ) - ]), + child: Stack(alignment: Alignment.bottomCenter, children: [ + PageView( + controller: controller, + onPageChanged: _onPageChanged, + children: _buildItems(), + ), + _buildIndicator(), // 下面的小点 + Positioned( + //方法二 + top: 0.0, + right: 0.0, + child: _numberIndicator( + context, virtualIndex, widget.bannerStories.length), + ) + ]), ); } - List _buildItems() { // 排列轮播数组 + List _buildItems() { + // 排列轮播数组 List items = []; if (widget.bannerStories.length > 0) { // 头部添加一个尾部Item,模拟循环 items.add( _buildItem(widget.bannerStories[widget.bannerStories.length - 1])); // 正常添加Item - items.addAll( - widget.bannerStories.map((story) => _buildItem(story)).toList( - growable: false)); + items.addAll(widget.bannerStories + .map((story) => _buildItem(story)) + .toList(growable: false)); // 尾部 - items.add( - _buildItem(widget.bannerStories[0])); + items.add(_buildItem(widget.bannerStories[0])); } return items; } Widget _buildItem(StoryModel story) { return GestureDetector( - onTap: () { // 按下 + onTap: () { + // 按下 if (widget.onTap != null) { widget.onTap(story); } @@ -102,14 +106,17 @@ class _BannerState extends State { child: Stack( fit: StackFit.expand, children: [ - Image.network(story.image, fit: BoxFit.cover), + Image.network(story.image, fit: BoxFit.cover), _buildItemTitle(story.title), // 内容文字,大意 - ],),); + ], + ), + ); } Widget _buildItemTitle(String title) { return Container( - decoration: BoxDecoration( /// 背景的渐变色 + decoration: BoxDecoration( + /// 背景的渐变色 gradient: LinearGradient( begin: Alignment.bottomCenter, end: const Alignment(0.0, -0.8), @@ -120,7 +127,10 @@ class _BannerState extends State { child: Container( margin: EdgeInsets.symmetric(vertical: 22.0, horizontal: 16.0), child: Text( - title, style: TextStyle(color: Colors.white, fontSize: 18.0),),), + title, + style: TextStyle(color: Colors.white, fontSize: 18.0), + ), + ), ); } @@ -136,8 +146,7 @@ class _BannerState extends State { color: i == virtualIndex ? Colors.white : Colors.grey))); } return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: indicators); + mainAxisAlignment: MainAxisAlignment.center, children: indicators); } _onPageChanged(int index) { @@ -156,4 +165,4 @@ class _BannerState extends State { } } -typedef void OnTapBannerItem(StoryModel story); \ No newline at end of file +typedef void OnTapBannerItem(StoryModel story); diff --git a/lib/components/list_refresh.dart b/lib/components/list_refresh.dart index c5d3b0d8..22229de3 100644 --- a/lib/components/list_refresh.dart +++ b/lib/components/list_refresh.dart @@ -14,7 +14,8 @@ class ListRefresh extends StatefulWidget { final requestApi; final headerView; - const ListRefresh([this.requestApi, this.renderItem, this.headerView]) : super(); + const ListRefresh([this.requestApi, this.renderItem, this.headerView]) + : super(); @override State createState() => _ListRefreshState(); @@ -91,6 +92,7 @@ class _ListRefreshState extends State { }); } } + // 下拉加载的事件,清空之前list内容,取前X个 // 其实就是列表重置 Future _handleRefresh() async { @@ -158,9 +160,9 @@ class _ListRefreshState extends State { itemCount: items.length + 1, itemBuilder: (context, index) { if (index == 0 && index != items.length) { - if(widget.headerView is Function){ + if (widget.headerView is Function) { return widget.headerView(); - }else { + } else { return Container(height: 0); } } diff --git a/lib/components/list_view_item.dart b/lib/components/list_view_item.dart index c8aa682d..58d515ed 100644 --- a/lib/components/list_view_item.dart +++ b/lib/components/list_view_item.dart @@ -1,5 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 17:53:54 +import 'package:fluro/fluro.dart'; + +/// @Author: 一凨 +/// @Date: 2019-01-14 17:53:54 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 17:57:51 @@ -8,7 +10,6 @@ import '../routers/application.dart'; import '../routers/routers.dart'; import 'dart:core'; - class ListViewItem extends StatelessWidget { final String itemUrl; final String itemTitle; @@ -17,7 +18,6 @@ class ListViewItem extends StatelessWidget { const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data}) : super(key: key); - @override Widget build(BuildContext context) { return Card( @@ -27,7 +27,11 @@ class ListViewItem extends StatelessWidget { child: ListTile( onTap: () { // _launchURL(itemUrl, context); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}', + transition: TransitionType.nativeModal, + ); }, title: Padding( child: Text( diff --git a/lib/components/loading.dart b/lib/components/loading.dart index 659b2ff8..b2c30719 100644 --- a/lib/components/loading.dart +++ b/lib/components/loading.dart @@ -19,11 +19,11 @@ class NetLoadingDialog extends StatefulWidget { NetLoadingDialog( {Key key, - this.loadingText = "loading...", - this.outsideDismiss = true, - this.dismissCallback, - this.loading, - this.requestCallBack}) + this.loadingText = "loading...", + this.outsideDismiss = true, + this.dismissCallback, + this.loading, + this.requestCallBack}) : super(key: key); @override diff --git a/lib/components/markdown.dart b/lib/components/markdown.dart index af055381..6a70666e 100644 --- a/lib/components/markdown.dart +++ b/lib/components/markdown.dart @@ -6,21 +6,18 @@ import 'package:flutter_go/utils/high_light_code.dart'; /// 使用方法 /// MarkdownBody(markdown) final hightlighter = new HighLight(); + class HighLight extends md.SyntaxHighlighter { @override TextSpan format(String source) { - final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle(); + final SyntaxHighlighterStyle style = + SyntaxHighlighterStyle.lightThemeStyle(); return TextSpan( style: const TextStyle(fontSize: 10.0), - children: [ - DartSyntaxHighlighter(style).format(source) - ] - ); + children: [DartSyntaxHighlighter(style).format(source)]); } } - - class MarkdownBody extends StatelessWidget { final String data; MarkdownBody(this.data); @@ -28,4 +25,4 @@ class MarkdownBody extends StatelessWidget { Widget build(BuildContext context) { return md.MarkdownBody(data: data, syntaxHighlighter: new HighLight()); } -} \ No newline at end of file +} diff --git a/lib/components/pagination.dart b/lib/components/pagination.dart index e7fdd379..8b8f579d 100644 --- a/lib/components/pagination.dart +++ b/lib/components/pagination.dart @@ -20,10 +20,39 @@ class Pagination extends StatelessWidget { ]; final List arr = [ - {'image': 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', 'type': 0, 'id': 9695909, 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?'}, - {'image': 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', 'type': 0, 'id': 9695859, 'url': 'https://zhuanlan.zhihu.com/p/51696594', 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'}, - {'image': 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', 'type': 0, 'id': 96956491409, 'url':'https://zhuanlan.zhihu.com/p/53497167','title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'}, - {'image': 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', 'type': 0, 'id': 9695816, 'url': 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用'} + { + 'image': + 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', + 'type': 0, + 'id': 9695909, + 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', + 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', + 'type': 0, + 'id': 9695859, + 'url': 'https://zhuanlan.zhihu.com/p/51696594', + 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', + 'type': 0, + 'id': 96956491409, + 'url': 'https://zhuanlan.zhihu.com/p/53497167', + 'title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', + 'type': 0, + 'id': 9695816, + 'url': + 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', + 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用' + } ]; void _launchURL(String url) async { @@ -37,12 +66,12 @@ class Pagination extends StatelessWidget { List _pageSelector(BuildContext context) { List list = []; List bannerStories = []; + /// super.initState(); arr.forEach((item) { bannerStories.add(StoryModel.fromJson(item)); }); - if (arr.length > 0) { list.add(HomeBanner(bannerStories, (story) { _launchURL('${story.url}'); @@ -53,12 +82,10 @@ class Pagination extends StatelessWidget { @override Widget build(BuildContext context) { - return - Column( - key:Key('__header__'), + return Column( + key: Key('__header__'), //physics: AlwaysScrollableScrollPhysics(), //padding: EdgeInsets.only(), - children: _pageSelector(context) - ); + children: _pageSelector(context)); } } diff --git a/lib/components/search_input.dart b/lib/components/search_input.dart index 9fdc3eff..9d9bfe9f 100644 --- a/lib/components/search_input.dart +++ b/lib/components/search_input.dart @@ -15,13 +15,9 @@ typedef void OnSubmit(String value); ///搜索结果内容显示面板 class MaterialSearchResult extends StatelessWidget { - const MaterialSearchResult({ - Key key, - this.value, - this.text, - this.icon, - this.onTap - }) : super(key: key); + const MaterialSearchResult( + {Key key, this.value, this.text, this.icon, this.onTap}) + : super(key: key); final String value; final VoidCallback onTap; @@ -30,7 +26,6 @@ class MaterialSearchResult extends StatelessWidget { @override Widget build(BuildContext context) { - return new InkWell( onTap: this.onTap, child: new Container( @@ -38,8 +33,14 @@ class MaterialSearchResult extends StatelessWidget { padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 10.0), child: new Row( children: [ - new Container(width: 30.0, margin: EdgeInsets.only(right: 10), child: new Icon(icon)) ?? null, - new Expanded(child: new Text(value, style: Theme.of(context).textTheme.subhead)), + new Container( + width: 30.0, + margin: EdgeInsets.only(right: 10), + child: new Icon(icon)) ?? + null, + new Expanded( + child: new Text(value, + style: Theme.of(context).textTheme.subhead)), new Text(text, style: Theme.of(context).textTheme.subhead) ], ), @@ -124,6 +125,7 @@ class _MaterialSearchState extends State { } Timer _resultsTimer; + Future _getResultsDebounced() async { if (_results.length == 0) { setState(() { @@ -164,6 +166,7 @@ class _MaterialSearchState extends State { super.dispose(); _resultsTimer?.cancel(); } + Widget buildBody(List results) { if (_criteria.isEmpty) { return History(); @@ -171,16 +174,11 @@ class _MaterialSearchState extends State { return new Center( child: new Padding( padding: const EdgeInsets.only(top: 50.0), - child: new CircularProgressIndicator() - ) - ); + child: new CircularProgressIndicator())); } if (results.isNotEmpty) { - var content = new SingleChildScrollView( - child: new Column( - children: results - ) - ); + var content = + new SingleChildScrollView(child: new Column(children: results)); return content; } return Center(child: Text("暂无数据")); @@ -241,7 +239,7 @@ class _MaterialSearchState extends State { ], ), body: buildBody(results), - ); + ); } } @@ -405,34 +403,35 @@ class SearchInput extends StatelessWidget { } // wigdet干掉.=> componets - class History extends StatefulWidget { const History() : super(); @override - _History createState() => _History(); + _History createState() => _History(); } // AppBar 默认的实例,有状态 class _History extends State { SearchHistoryList searchHistoryList = new SearchHistoryList(); + bool refreshFlag; @override void initState() { super.initState(); + this.refreshFlag = true; } @override void dispose() { super.dispose(); } + buildChips(BuildContext context) { List list = []; List historyList = searchHistoryList.getList(); print("historyList> $historyList"); Color bgColor = Theme.of(context).primaryColor; historyList.forEach((SearchHistory value) { - Widget icon = CircleAvatar( backgroundColor: bgColor, child: Text( @@ -445,20 +444,28 @@ class _History extends State { } String targetRouter = value.targetRouter; - list.add( - InkWell( - onTap: () { - Application.router.navigateTo(context, "${targetRouter.toLowerCase()}", transition: TransitionType.inFromRight); - }, - child: Chip( - avatar: icon, - label: Text("${value.name}"), - ), - ) - ); + list.add(InkWell( + onTap: () { + Application.router.navigateTo( + context, "${targetRouter.toLowerCase()}", + transition: TransitionType.native); + }, + child: Chip( + avatar: icon, + label: Text("${value.name}"), + ), + )); }); return list; } + + _clearHistory() { + searchHistoryList.clear(); + this.setState(() { + this.refreshFlag = !this.refreshFlag; + }); + } + @override Widget build(BuildContext context) { List childList = buildChips(context); @@ -470,25 +477,38 @@ class _History extends State { return Column( children: [ Container( - alignment: Alignment.centerLeft, - padding: EdgeInsets.fromLTRB(12.0, 12, 12, 0), - child: InkWell( - onLongPress: () { - searchHistoryList.clear(); - }, - child: Text('历史搜索'), - ), - ), + alignment: Alignment.centerLeft, + padding: EdgeInsets.fromLTRB(12.0, 12, 12, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onLongPress: () { + searchHistoryList.clear(); + }, + child: Text('历史搜索'), + ), + GestureDetector( + onTap: _clearHistory, + child: Container( + child: new Icon(Icons.delete, + size: 24.0, color: Theme.of(context).accentColor), + width: 30, + height: 30, + ), + ) + ], + )), Container( padding: EdgeInsets.only(left: 10), alignment: Alignment.topLeft, child: Wrap( - spacing: 6.0, // gap between adjacent chips - runSpacing: 0.0, // gap between lines - children: childList - ), + spacing: 6.0, // gap between adjacent chips + runSpacing: 0.0, // gap between lines + children: childList), ) ], ); } -} \ No newline at end of file +} diff --git a/lib/components/single_theme_color.dart b/lib/components/single_theme_color.dart index 8a9088a0..5ab67e73 100644 --- a/lib/components/single_theme_color.dart +++ b/lib/components/single_theme_color.dart @@ -13,10 +13,11 @@ class SingleThemeColor extends StatelessWidget { @override Widget build(BuildContext context) { return InkWell( - onTap: (){ - if(ApplicationEvent.event != null){ + onTap: () { + if (ApplicationEvent.event != null) { print('fire ${this.themeColor}'); - ApplicationEvent.event.fire(UserSettingThemeColorEvent(this.themeColor)); + ApplicationEvent.event + .fire(UserSettingThemeColorEvent(this.themeColor)); Navigator.of(context).pop(); } }, diff --git a/lib/components/widget_demo.dart b/lib/components/widget_demo.dart index e2c783d3..befb6aeb 100644 --- a/lib/components/widget_demo.dart +++ b/lib/components/widget_demo.dart @@ -3,12 +3,14 @@ import 'dart:core'; +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter_go/utils/data_utils.dart'; import '../routers/application.dart'; import '../routers/routers.dart'; import '../components/markdown.dart'; + /// import '../model/collection.dart'; import '../widgets/index.dart'; import '../event/event_bus.dart'; @@ -35,6 +37,7 @@ class WidgetDemo extends StatefulWidget { class _WidgetDemoState extends State { bool _hasCollected = false; + /// CollectionControlModel _collectionControl = new CollectionControlModel(); var _collectionIcons; List widgetDemosList = new WidgetDemoList().getDemos(); @@ -134,45 +137,49 @@ class _WidgetDemoState extends State { void _selectValue(value) { if (value == 'doc') { // _launchURL(widget.docUrl); - Application.router.navigateTo(context, - '${Routes.webViewPage}?title=${Uri.encodeComponent(widget.title)} Doc&&url=${Uri.encodeComponent(widget.docUrl)}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(widget.title)} Doc&&url=${Uri.encodeComponent(widget.docUrl)}', + transition: TransitionType.nativeModal, + ); } else if (value == 'code') { - Application.router.navigateTo(context, - '${Routes.codeView}?filePath=${Uri.encodeComponent(widget.codeUrl)}'); + Application.router.navigateTo( + context, + '${Routes.codeView}?filePath=${Uri.encodeComponent(widget.codeUrl)}', + transition: TransitionType.nativeModal, + ); } } + List> buildPopupMenu() { List> comps = []; if (widget.docUrl != null) { - comps.add( - PopupMenuItem( - value: 'doc', - child: ListTile( - leading: Icon( - Icons.library_books, - size: 22.0, - ), - title: Text('查看文档'), - ), - ) - ); + comps.add(PopupMenuItem( + value: 'doc', + child: ListTile( + leading: Icon( + Icons.library_books, + size: 22.0, + ), + title: Text('查看文档'), + ), + )); } if (widget.codeUrl != null) { - comps.add( - PopupMenuItem( - value: 'code', - child: ListTile( - leading: Icon( - Icons.code, - size: 22.0, - ), - title: Text('查看Demo'), - ), - ) - ); + comps.add(PopupMenuItem( + value: 'code', + child: ListTile( + leading: Icon( + Icons.code, + size: 22.0, + ), + title: Text('查看Demo'), + ), + )); } return comps; } + @override Widget build(BuildContext context) { if (_hasCollected) { @@ -185,7 +192,7 @@ class _WidgetDemoState extends State { new IconButton( tooltip: 'goBack home', onPressed: () { - Navigator.popUntil(context, ModalRoute.withName('/')); + Navigator.popUntil(context, ModalRoute.withName(Routes.root)); }, icon: Icon(Icons.home), ), @@ -196,12 +203,10 @@ class _WidgetDemoState extends State { ), ]; if (menus.length > 0) { - actions.add( - PopupMenuButton( - onSelected: _selectValue, - itemBuilder: (BuildContext context) => menus, - ) - ); + actions.add(PopupMenuButton( + onSelected: _selectValue, + itemBuilder: (BuildContext context) => menus, + )); } return Scaffold( key: _scaffoldKey, diff --git a/lib/components/widget_item_container.dart b/lib/components/widget_item_container.dart index d7438790..1cca41c1 100644 --- a/lib/components/widget_item_container.dart +++ b/lib/components/widget_item_container.dart @@ -13,23 +13,21 @@ class WidgetItemContainer extends StatelessWidget { // 所有的可用demos; final List widgetDemosList = new WidgetDemoList().getDemos(); - WidgetItemContainer( - {Key key, - @required this.commonItems, - @required this.columnCount, + WidgetItemContainer({ + Key key, + @required this.commonItems, + @required this.columnCount, // @required this.isWidgetPoint - }) - : super(key: key); + }) : super(key: key); /// 跳转goup void tapToGroup(CategoryComponent cate, BuildContext context) { - Application.router - .navigateTo(context, "/category/${cate.token}", transition: TransitionType.inFromRight); + Application.router.navigateTo(context, "/category/${cate.token}", + transition: TransitionType.native); } /// 跳转到老的widget界面 void tapToOldWidget(WidgetLeaf leaf, BuildContext context) { - String targetName = leaf.name; String targetRouter = '/category/error/404'; widgetDemosList.forEach((item) { @@ -38,13 +36,21 @@ class WidgetItemContainer extends StatelessWidget { targetRouter = targetRouter.toLowerCase(); } }); - Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight); + Application.router.navigateTo( + context, + targetRouter, + transition: TransitionType.native, + ); } /// 跳转到新的标准页 void tapToStandardPage(WidgetLeaf leaf, BuildContext context) { String targetRouter = '/standard-page/${leaf.pageId}'; - Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight); + Application.router.navigateTo( + context, + targetRouter, + transition: TransitionType.native, + ); } List _buildColumns(context) { @@ -58,37 +64,37 @@ class WidgetItemContainer extends StatelessWidget { if (addI < length) { CommonItem item = commonItems[addI]; - _listRows.add( Expanded( flex: 1, child: WidgetItem( - title: item.name, - onTap: () { - String type = item.type; + title: item.name, + onTap: () { + String type = item.type; - if (type == "category") { - return tapToGroup(item as CategoryComponent, context); - } - if (type == "widget") { - WidgetLeaf leaf = item as WidgetLeaf; + if (type == "category") { + return tapToGroup(item as CategoryComponent, context); + } + if (type == "widget") { + WidgetLeaf leaf = item as WidgetLeaf; - if (leaf.display == "standard") { - return tapToStandardPage(leaf, context); - } else { - return tapToOldWidget(leaf, context); + if (leaf.display == "standard") { + return tapToStandardPage(leaf, context); + } else { + return tapToOldWidget(leaf, context); + } } - } - Application.router - .navigateTo(context, "/category/error/404", transition: TransitionType.inFromRight); - }, - index: addI, - totalCount: length, - rowLength: columnCount, - /// textSize: true ? 'middle' : 'small', - textSize: 'middle' - ), + Application.router.navigateTo( + context, "/category/error/404", + transition: TransitionType.native); + }, + index: addI, + totalCount: length, + rowLength: columnCount, + + /// textSize: true ? 'middle' : 'small', + textSize: 'middle'), ), ); } else { @@ -116,4 +122,3 @@ class WidgetItemContainer extends StatelessWidget { ); } } - diff --git a/lib/event/event_bus.dart b/lib/event/event_bus.dart index d51e9b10..aafb908e 100644 --- a/lib/event/event_bus.dart +++ b/lib/event/event_bus.dart @@ -1,5 +1,5 @@ import 'package:event_bus/event_bus.dart'; -class ApplicationEvent{ +class ApplicationEvent { static EventBus event; } diff --git a/lib/event/event_model.dart b/lib/event/event_model.dart index ca753ec9..f8062688 100644 --- a/lib/event/event_model.dart +++ b/lib/event/event_model.dart @@ -1,19 +1,19 @@ -class CollectionEvent{ +class CollectionEvent { final String widgetName; final String router; final bool isRemove; // token uid... - CollectionEvent(this.widgetName,this.router,this.isRemove); + CollectionEvent(this.widgetName, this.router, this.isRemove); } -class UserGithubOAuthEvent{ +class UserGithubOAuthEvent { final String loginName; final String token; final bool isSuccess; - UserGithubOAuthEvent(this.loginName,this.token,this.isSuccess); + UserGithubOAuthEvent(this.loginName, this.token, this.isSuccess); } -class UserSettingThemeColorEvent{ +class UserSettingThemeColorEvent { final int settingThemeColor; UserSettingThemeColorEvent(this.settingThemeColor); -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 2a5a944d..ea351b28 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,14 +54,17 @@ class _MyAppState extends State { Future _reqsMainPageIsOpen() async { const reqs = 'https://flutter-go.pub/api/isInfoOpen'; var response; - try{ + try { response = await NetUtils.get(reqs, {}); - print('response-$response'); - if(response['status'] == 200 && response['success'] ==true && response['data'] is Map && response['data']['isOpen'] == true) { + print('response-$response'); + if (response['status'] == 200 && + response['success'] == true && + response['data'] is Map && + response['data']['isOpen'] == true) { Application.pageIsOpen = true; print('是否需要展开【业界动态】${Application.pageIsOpen}'); } - }catch(e){ + } catch (e) { print('response-$e'); } return response; @@ -203,17 +206,18 @@ void _startupJpush() async { } void main() async { + WidgetsFlutterBinding.ensureInitialized(); final provider = new Provider(); await provider.init(true); sp = await SpUtil.getInstance(); new SearchHistoryList(sp); await DataUtils.getWidgetTreeList().then((List json) { - List data = WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList()); + List data = + WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList()); Application.widgetTree = WidgetTree.buildWidgetTree(data); print("Application.widgetTree>>>> ${Application.widgetTree}"); }); db = Provider.db; runApp(new MyApp()); } - diff --git a/lib/model/base.dart b/lib/model/base.dart index 43cb7a55..626409b9 100644 --- a/lib/model/base.dart +++ b/lib/model/base.dart @@ -1,10 +1,10 @@ import 'package:sqflite/sqflite.dart'; -class BaseModel{ - Database db; - final String table = ''; - var query; - BaseModel(this.db){ - query = db.query; - } -} \ No newline at end of file +class BaseModel { + Database db; + final String table = ''; + var query; + BaseModel(this.db) { + query = db.query; + } +} diff --git a/lib/model/collection.dart b/lib/model/collection.dart index 49233bbe..cdc90642 100644 --- a/lib/model/collection.dart +++ b/lib/model/collection.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-07 16:24:42 +/// @Author: 一凨 +/// @Date: 2019-01-07 16:24:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-08 17:37:42 @@ -18,8 +18,8 @@ class Collection implements CollectionInterface { Collection({this.name, this.router}); - factory Collection.fromJSON(Map json){ - return Collection(name: json['name'],router: json['router']); + factory Collection.fromJSON(Map json) { + return Collection(name: json['name'], router: json['router']); } Object toMap() { @@ -48,7 +48,7 @@ class CollectionControlModel { Future> getAllCollection() async { List list = await sql.getByCondition(); List resultList = []; - list.forEach((item){ + list.forEach((item) { print('collection item =>> $item'); resultList.add(Collection.fromJSON(item)); }); @@ -68,11 +68,12 @@ class CollectionControlModel { } // 删除 - Future deleteByName(String name) async{ - return await sql.delete(name,'name'); + Future deleteByName(String name) async { + return await sql.delete(name, 'name'); } + // 通过path删除 - Future deleteByPath(String path) async{ - return await sql.delete(path,'router'); + Future deleteByPath(String path) async { + return await sql.delete(path, 'router'); } } diff --git a/lib/model/responseData.dart b/lib/model/responseData.dart index 1b5327e5..b311138c 100644 --- a/lib/model/responseData.dart +++ b/lib/model/responseData.dart @@ -1,25 +1,20 @@ -class ResponseData{ +class ResponseData { int status; bool success; String message; - ResponseData(this.status, this.success,this.message); + ResponseData(this.status, this.success, this.message); ResponseData.fromJson(Map json) : status = json['status'], success = json['success'], - message=json['message']; + message = json['message']; Map toJson() => - { - 'status': status, - 'success': success, - 'messsage': message - }; - + {'status': status, 'success': success, 'messsage': message}; + @override String toString() { return 'status: $status ,success: $success,message: ${message.toString()}'; } - -} \ No newline at end of file +} diff --git a/lib/model/search_history.dart b/lib/model/search_history.dart index da2e4cdd..26f761db 100644 --- a/lib/model/search_history.dart +++ b/lib/model/search_history.dart @@ -12,7 +12,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; - class SearchHistory { final String name; final String targetRouter; @@ -73,7 +72,7 @@ class SearchHistoryList { } add(SearchHistory item) { - print("_searchHistoryList> ${_searchHistoryList.length}"); + print("add item to serach history ${item.targetRouter}"); for (SearchHistory value in _searchHistoryList) { if (value.name == item.name) { return; diff --git a/lib/model/story.dart b/lib/model/story.dart index c8bfbab2..6080d255 100644 --- a/lib/model/story.dart +++ b/lib/model/story.dart @@ -4,20 +4,21 @@ class StoryModel { final int id; final String url; - StoryModel(this.id, this.title, {this.image,this.url}); + StoryModel(this.id, this.title, {this.image, this.url}); StoryModel.fromJson(Map json) - : this(json['id'], json['title'], - image: json['image'] != null ? json['image'] : (json['images'] != null ? json['images'][0] : null), - url: json['url'] != null ? json['url'] : (json['url'] != null ? json['url'][0] : null), - ); + : this( + json['id'], + json['title'], + image: json['image'] != null + ? json['image'] + : (json['images'] != null ? json['images'][0] : null), + url: json['url'] != null + ? json['url'] + : (json['url'] != null ? json['url'][0] : null), + ); Map toJson() { - return { - 'id': id, - 'title': title, - 'image': image, - 'url':url - }; + return {'id': id, 'title': title, 'image': image, 'url': url}; } -} \ No newline at end of file +} diff --git a/lib/model/user_info.dart b/lib/model/user_info.dart index 5007e512..39db2b10 100644 --- a/lib/model/user_info.dart +++ b/lib/model/user_info.dart @@ -14,13 +14,13 @@ class UserInformation { factory UserInformation.fromJson(Map json) { print('fromJOSN $json ${json['id'].runtimeType}'); String name = json['name']; - int userId ; - if(json['name'] == null){ + int userId; + if (json['name'] == null) { name = json['url_name']; } - if(json['id'].runtimeType == int){ + if (json['id'].runtimeType == int) { userId = json['id']; - }else{ + } else { userId = int.parse(json['id']); } return UserInformation( diff --git a/lib/model/user_info_cache.dart b/lib/model/user_info_cache.dart index 8bfe018c..20112882 100644 --- a/lib/model/user_info_cache.dart +++ b/lib/model/user_info_cache.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-07 16:24:42 +/// @Author: 一凨 +/// @Date: 2019-01-07 16:24:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-08 17:37:42 @@ -18,8 +18,8 @@ class UserInfo implements UserInfoInterface { UserInfo({this.username, this.password}); - factory UserInfo.fromJSON(Map json){ - return UserInfo(username: json['username'],password: json['password']); + factory UserInfo.fromJSON(Map json) { + return UserInfo(username: json['username'], password: json['password']); } Object toMap() { @@ -39,8 +39,8 @@ class UserInfoControlModel { // 插入新的缓存 Future insert(UserInfo userInfo) { - var result = - sql.insert({'username': userInfo.username, 'password': userInfo.password}); + var result = sql + .insert({'username': userInfo.username, 'password': userInfo.password}); return result; } @@ -48,7 +48,7 @@ class UserInfoControlModel { Future> getAllInfo() async { List list = await sql.getByCondition(); List resultList = []; - list.forEach((item){ + list.forEach((item) { print(item); resultList.add(UserInfo.fromJSON(item)); }); @@ -56,9 +56,7 @@ class UserInfoControlModel { } // 清空表中数据 - Future deleteAll() async{ + Future deleteAll() async { return await sql.deleteAll(); } - - } diff --git a/lib/model/widget.dart b/lib/model/widget.dart index c0f37d0d..936b01da 100644 --- a/lib/model/widget.dart +++ b/lib/model/widget.dart @@ -1,14 +1,10 @@ - import 'dart:async'; import "package:flutter/material.dart"; import "package:flutter_go/routers/application.dart"; import 'package:flutter_go/utils/sql.dart'; -enum treeNode { - CategoryComponent, - WidgetLeaf -} +enum treeNode { CategoryComponent, WidgetLeaf } //typedef aaa @@ -135,6 +131,7 @@ class WidgetControlModel { } return new WidgetPoint.fromJSON(json.first); } + Future> search(String name) async { List json = await sql.search(conditions: {'name': name}); @@ -149,6 +146,7 @@ class WidgetControlModel { return widgets; } } + // 抽象类 abstract class CommonItem { int id; @@ -179,19 +177,17 @@ class CategoryComponent extends CommonItem { CommonItem parent; String token; - List children = []; String type = 'category'; - CategoryComponent({ - @required this.id, - @required this.name, - @required this.parentId, - this.type = 'categoryw', - this.children, - this.parent - }); + CategoryComponent( + {@required this.id, + @required this.name, + @required this.parentId, + this.type = 'categoryw', + this.children, + this.parent}); CategoryComponent.fromJson(Map json) { if (json['id'] != null && json['id'].runtimeType == String) { this.id = int.parse(json['id']); @@ -206,27 +202,25 @@ class CategoryComponent extends CommonItem { if (item is CategoryComponent) { CategoryComponent cate = item; cate.parent = this; - this.children.add( - cate - ); + this.children.add(cate); } if (item is WidgetLeaf) { WidgetLeaf widget = item; widget.parent = this; - this.children.add( - widget - ); + this.children.add(widget); } } + @override CommonItem getChild(String token) { - return children.firstWhere((CommonItem item) => item.token == token, orElse: () => null); + return children.firstWhere((CommonItem item) => item.token == token, + orElse: () => null); } @override CommonItem find(String token, [CommonItem node]) { CommonItem ret; - if (node !=null) { + if (node != null) { if (node.token == token) { return node; } else { @@ -260,14 +254,13 @@ class WidgetLeaf extends CommonItem { CommonItem parent; String type = 'widget'; - WidgetLeaf({ - @required this.id, - @required this.name, - @required this.display, - this.author, - this.path, - this.pageId - }); + WidgetLeaf( + {@required this.id, + @required this.name, + @required this.display, + this.author, + this.path, + this.pageId}); WidgetLeaf.fromJson(Map json) { if (json['id'] != null && json['id'].runtimeType == String) { @@ -286,25 +279,27 @@ class WidgetLeaf extends CommonItem { CommonItem getChild(String token) { return null; } + @override addChildren(Object item) { // TODO: implement addChildren return null; } - CommonItem find(String token, [CommonItem node]){ + CommonItem find(String token, [CommonItem node]) { return null; } } class WidgetTree { // 构建树型结构 - static CategoryComponent buildWidgetTree(List json, [parent]){ + static CategoryComponent buildWidgetTree(List json, [parent]) { CategoryComponent current; if (parent != null) { current = parent; } else { - current = CategoryComponent(id: 0, name: 'root', parentId: null, children: []); + current = + CategoryComponent(id: 0, name: 'root', parentId: null, children: []); } json.forEach((item) { // 归属分类级别 @@ -357,10 +352,13 @@ class WidgetTree { }); return list; } - static CategoryComponent getCommonItemById(List path, CategoryComponent root) { + + static CategoryComponent getCommonItemById( + List path, CategoryComponent root) { print("getCommonItemByPath $path"); print("root $root"); CommonItem childLeaf; + /// int first = path.first; path = path.sublist(1); print("path:::: $path"); @@ -368,7 +366,6 @@ class WidgetTree { // childLeaf = root.getChild(path.first); } - return childLeaf; } -} \ No newline at end of file +} diff --git a/lib/page_demo_package/.demo.json b/lib/page_demo_package/.demo.json index 1967c339..ff076189 100644 --- a/lib/page_demo_package/.demo.json +++ b/lib/page_demo_package/.demo.json @@ -1 +1 @@ -[{"name":"demoName","screenShot":"","author":"yourName","email":"yourEmail","desc":"这是一个测试的标准demo","id":"1a29aa8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"ab","email":"email","desc":"ags","id":"2c1d57d0_42ae_4241_9c8a_5c9e1f92b096"}] \ No newline at end of file +[{"name":"PullToRefresh","screenShot":"","author":"chenfeihu","email":"763551832@qq.com","desc":"刷新组件","id":"5553db80_52ae_4241_9c8a_5c9e1f92b096"},{"name":"RangeSlider","screenShot":"","author":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget demo","id":"e5f958bc_52ae_4241_9c8a_5c9e1f92b096"},{"name":"demoName","screenShot":"","author":"yourName","email":"yourEmail","desc":"这是一个测试的标准demo","id":"1a29aa8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"ab","email":"email","desc":"ags","id":"2c1d57d0_42ae_4241_9c8a_5c9e1f92b096"}] \ No newline at end of file diff --git a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/.demo.json b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/.demo.json new file mode 100644 index 00000000..1fe09bd0 --- /dev/null +++ b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/.demo.json @@ -0,0 +1,9 @@ +{ + "name": "PullToRefresh", + "screenShot": "", + "author":"chenfeihu", + "email": "763551832@qq.com", + "desc": "刷新组件", + "id": "5553db80_52ae_4241_9c8a_5c9e1f92b096" +} + \ No newline at end of file diff --git a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart new file mode 100644 index 00000000..18597449 --- /dev/null +++ b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -0,0 +1,11 @@ +// +// Created with flutter go cli +// User: chenfeihu +// Time: 2019-09-24 12:11:14.085126 +// email: 763551832@qq.com +// desc: 刷新组件 +// + +import 'src/index.dart'; + +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart new file mode 100644 index 00000000..2ebe44e3 --- /dev/null +++ b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -0,0 +1,246 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; + +class Demo extends StatefulWidget { + @override + _State createState() => _State(); +} + +class _State extends State { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.all(5.0), + width: double.infinity, + height: 600.0, + child: Pulltorefresh(), + ); + } +} + +class Pulltorefresh extends StatefulWidget { + @override + _PulltorefreshState createState() => _PulltorefreshState(); +} + +class _PulltorefreshState extends State { + List datas = ListData.getList(); + RefreshController _controller = RefreshController(initialRefresh: false); + + void _onRefresh() async { + await Future.delayed(Duration(milliseconds: 1000)); + _controller.refreshCompleted(); + } + + void _onLoading() async { + await Future.delayed(Duration(milliseconds: 1500)); + ItemModel model = ItemModel(getRandomColor(), Icons.airplanemode_active, + "军事新闻", "俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000); + + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + if (mounted) setState(() {}); + _controller.loadComplete(); + } + + @override + Widget build(BuildContext context) { + Widget _itemBuilder(BuildContext context, int position) { + return Card(child: this.datas[position]); + } + + return Scaffold( + appBar: AppBar( + title: Text("Pulltorefresh"), + ), + body: SmartRefresher( + enablePullDown: true, + enablePullUp: true, + header: WaterDropHeader(), + footer: ClassicFooter( + loadStyle: LoadStyle.ShowAlways, + completeDuration: Duration(microseconds: 50), + ), + onRefresh: _onRefresh, + onLoading: _onLoading, + controller: _controller, + child: ListView.builder( + itemBuilder: _itemBuilder, itemCount: this.datas.length), + ), + ); + } + + Color getRandomColor() { + List colors = [ + Colors.deepOrange, + Colors.amber, + Colors.cyan, + Colors.green, + Colors.red, + Colors.yellow + ]; + int randomValue = Random().nextInt(colors.length); + if (randomValue == colors.length) { + randomValue = colors.length - 1; + } + return colors[randomValue]; + } +} + +class Item extends StatelessWidget { + Color color; + IconData icon; + String mainTitle; + String subTitle; + String des; + int readCount; + + Item(this.color, this.icon, this.mainTitle, this.subTitle, this.des, + this.readCount); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.fromLTRB(10.0, 5.0, 10.0, 5.0), + height: 90.0, + child: Row( + children: [ + Container( + width: 90.0, + color: color, + alignment: Alignment.center, + child: Icon(icon, color: Colors.white), + ), + SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text(mainTitle, + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18.0))), + Expanded(child: Text(subTitle, style: TextStyle(fontSize: 14.0))), + Expanded( + child: Text( + des, + style: TextStyle(fontSize: 13.0), + overflow: TextOverflow.ellipsis, + )), + Expanded( + child: Text("阅读量:${readCount.toString()}", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + color: Colors.redAccent))), + ], + )) + ], + ), + ); + } +} + +class ItemModel { + Color _color; + IconData _icon; + String _mainTitle; + String _subTitle; + String _des; + int _readCount; + + ItemModel(this._color, this._icon, this._mainTitle, this._subTitle, this._des, + this._readCount); + + int get readCount => _readCount; + + set readCount(int value) { + _readCount = value; + } + + String get des => _des; + + set des(String value) { + _des = value; + } + + String get subTitle => _subTitle; + + set subTitle(String value) { + _subTitle = value; + } + + String get mainTitle => _mainTitle; + + set mainTitle(String value) { + _mainTitle = value; + } + + IconData get icon => _icon; + + set icon(IconData value) { + _icon = value; + } + + Color get color => _color; + + set color(Color value) { + _color = value; + } +} + +class ListData { + static List getList() { + List models = []; + ItemModel model1 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999); + ItemModel model2 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "俄“中部”演习", "俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588); + ItemModel model3 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "中国2.7万吨坞登舰", "据印度新德里电视台16日报道,印度海军发现7艘中国军舰在印度洋", 7777); + ItemModel model4 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "针对中国?", "美国空军着力打造军用5G网络,5G+VR,飞行员无需上天就能操控战机;美军濒海", 8888); + ItemModel model5 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "“凯旋”防空导弹系统", "俄罗斯卫星通讯社报道,俄罗斯北方舰队(Russian Northern Fleet)新闻处", 9999); + ItemModel model6 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "火箭军还有骑兵连", "迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754); + ItemModel model7 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "侦察兵跨越冰川", "在海拔5000多米的雪域高原,第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545); + ItemModel model8 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "香港被护商船", "新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574); + + models.add(Item(model1.color, model1.icon, model1.mainTitle, + model1.subTitle, model1.des, model1.readCount)); + models.add(Item(model2.color, model2.icon, model2.mainTitle, + model2.subTitle, model2.des, model2.readCount)); + models.add(Item(model3.color, model3.icon, model3.mainTitle, + model3.subTitle, model3.des, model3.readCount)); + models.add(Item(model4.color, model4.icon, model4.mainTitle, + model4.subTitle, model4.des, model4.readCount)); + models.add(Item(model5.color, model5.icon, model5.mainTitle, + model5.subTitle, model5.des, model5.readCount)); + models.add(Item(model6.color, model6.icon, model6.mainTitle, + model6.subTitle, model6.des, model6.readCount)); + models.add(Item(model7.color, model7.icon, model7.mainTitle, + model7.subTitle, model7.des, model7.readCount)); + models.add(Item(model8.color, model8.icon, model8.mainTitle, + model8.subTitle, model8.des, model8.readCount)); + return models; + } +} diff --git a/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/.demo.json b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/.demo.json new file mode 100644 index 00000000..10444611 --- /dev/null +++ b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/.demo.json @@ -0,0 +1,8 @@ +{ + "name": "RangeSlider", + "screenShot": "", + "author":"RangeSlider", + "email": "hanxu317@qq.com", + "desc": "RangeSlider widget demo", + "id": "e5f958bc_52ae_4241_9c8a_5c9e1f92b096" +} diff --git a/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart new file mode 100644 index 00000000..210ca1e5 --- /dev/null +++ b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -0,0 +1,11 @@ +// +// Created with flutter go cli +// User: RangeSlider +// Time: 2019-09-12 15:11:05.512158 +// email: hanxu317@qq.com +// desc: RangeSlider widget demo +// + +import 'src/index.dart'; + +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/src/index.dart new file mode 100644 index 00000000..bc34bf8f --- /dev/null +++ b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class Demo extends StatefulWidget { + @override + _State createState() => _State(); +} + +class _State extends State { + RangeValues valuess = RangeValues(20.0, 50.0); + @override + Widget build(BuildContext context) { + return RangeSlider( + values: valuess, + //实际进度的位置 + inactiveColor: Colors.black12, + //进度中不活动部分的颜色 + labels: RangeLabels('12', '23'), + min: 0.0, + max: 100.0, + divisions: 1000, + activeColor: Colors.blue, + //进度中活动部分的颜色 + onChanged: (rangeValues) { + setState(() { + valuess = rangeValues; + }); + }, + ); + } +} diff --git a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart index 68193686..e2767909 100644 --- a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart index e2992379..331dc4c9 100644 --- a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart +++ b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -9,8 +9,6 @@ class _State extends State { @override Widget build(BuildContext context) { return Container( - child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo')) - ); + child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo'))); } } - \ No newline at end of file diff --git a/lib/page_demo_package/index.dart b/lib/page_demo_package/index.dart index 1e6a4966..42fb0c10 100644 --- a/lib/page_demo_package/index.dart +++ b/lib/page_demo_package/index.dart @@ -1,6 +1,20 @@ -import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096; -import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096; -var demoObjects = { - '1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets, - '2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets -}; \ No newline at end of file +import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096; +import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096; +import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096; +import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096; + +var demoObjects = { + '5553db80_52ae_4241_9c8a_5c9e1f92b096': + StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096 + .demoWidgets, + 'e5f958bc_52ae_4241_9c8a_5c9e1f92b096': + StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets, + '1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': + StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets, + '2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': + StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets +}; diff --git a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart index 4e315373..75063a13 100644 --- a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart index d0d3921e..510fb6de 100644 --- a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart +++ b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -13,4 +13,3 @@ class _State extends State { ); } } - \ No newline at end of file diff --git a/lib/resources/icon_names.dart b/lib/resources/icon_names.dart index e7562778..a2764f14 100644 --- a/lib/resources/icon_names.dart +++ b/lib/resources/icon_names.dart @@ -9,9 +9,1110 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; class IconNames { - static List names = [Icons.ac_unit,Icons.access_alarm,Icons.access_alarms,Icons.access_time,Icons.accessibility,Icons.accessibility_new,Icons.accessible,Icons.accessible_forward,Icons.account_balance,Icons.account_balance_wallet,Icons.account_box,Icons.account_circle,Icons.adb,Icons.add,Icons.add_a_photo,Icons.add_alarm,Icons.add_alert,Icons.add_box,Icons.add_call,Icons.add_circle,Icons.add_circle_outline,Icons.add_comment,Icons.add_location,Icons.add_photo_alternate,Icons.add_shopping_cart,Icons.add_to_home_screen,Icons.add_to_photos,Icons.add_to_queue,Icons.adjust,Icons.airline_seat_flat,Icons.airline_seat_flat_angled,Icons.airline_seat_individual_suite,Icons.airline_seat_legroom_extra,Icons.airline_seat_legroom_normal,Icons.airline_seat_legroom_reduced,Icons.airline_seat_recline_extra,Icons.airline_seat_recline_normal,Icons.airplanemode_active,Icons.airplanemode_inactive,Icons.airplay,Icons.airport_shuttle,Icons.alarm,Icons.alarm_add,Icons.alarm_off,Icons.alarm_on,Icons.album,Icons.all_inclusive,Icons.all_out,Icons.alternate_email,Icons.android,Icons.announcement,Icons.apps,Icons.archive,Icons.arrow_back,Icons.arrow_back_ios,Icons.arrow_downward,Icons.arrow_drop_down,Icons.arrow_drop_down_circle,Icons.arrow_drop_up,Icons.arrow_forward,Icons.arrow_forward_ios,Icons.arrow_left,Icons.arrow_right,Icons.arrow_upward,Icons.art_track,Icons.aspect_ratio,Icons.assessment,Icons.assignment,Icons.assignment_ind,Icons.assignment_late,Icons.assignment_return,Icons.assignment_returned,Icons.assignment_turned_in,Icons.assistant,Icons.assistant_photo,Icons.atm,Icons.attach_file,Icons.attach_money,Icons.attachment,Icons.audiotrack,Icons.autorenew,Icons.av_timer,Icons.backspace,Icons.backup,Icons.battery_alert,Icons.battery_charging_full,Icons.battery_full,Icons.battery_std,Icons.battery_unknown,Icons.beach_access,Icons.beenhere,Icons.block,Icons.bluetooth,Icons.bluetooth_audio,Icons.bluetooth_connected,Icons.bluetooth_disabled,Icons.bluetooth_searching,Icons.blur_circular,Icons.blur_linear,Icons.blur_off,Icons.blur_on,Icons.book,Icons.bookmark,Icons.bookmark_border,Icons.border_all,Icons.border_bottom,Icons.border_clear,Icons.border_color,Icons.border_horizontal,Icons.border_inner,Icons.border_left,Icons.border_outer,Icons.border_right,Icons.border_style,Icons.border_top,Icons.border_vertical,Icons.branding_watermark,Icons.brightness_1,Icons.brightness_2,Icons.brightness_3,Icons.brightness_4,Icons.brightness_5,Icons.brightness_6,Icons.brightness_7,Icons.brightness_auto,Icons.brightness_high,Icons.brightness_low,Icons.brightness_medium,Icons.broken_image,Icons.brush,Icons.bubble_chart,Icons.bug_report,Icons.build,Icons.burst_mode,Icons.business,Icons.business_center,Icons.cached,Icons.cake,Icons.calendar_today,Icons.calendar_view_day,Icons.call,Icons.call_end,Icons.call_made,Icons.call_merge,Icons.call_missed,Icons.call_missed_outgoing,Icons.call_received,Icons.call_split,Icons.call_to_action,Icons.camera,Icons.camera_alt,Icons.camera_enhance,Icons.camera_front,Icons.camera_rear,Icons.camera_roll,Icons.cancel,Icons.card_giftcard,Icons.card_membership,Icons.card_travel,Icons.casino,Icons.cast,Icons.cast_connected,Icons.category,Icons.center_focus_strong,Icons.center_focus_weak,Icons.change_history,Icons.chat,Icons.chat_bubble,Icons.chat_bubble_outline,Icons.check,Icons.check_box,Icons.check_box_outline_blank,Icons.check_circle,Icons.check_circle_outline,Icons.chevron_left,Icons.chevron_right,Icons.child_care,Icons.child_friendly,Icons.chrome_reader_mode,Icons.class_,Icons.clear,Icons.clear_all,Icons.close,Icons.closed_caption,Icons.cloud,Icons.cloud_circle,Icons.cloud_done,Icons.cloud_download,Icons.cloud_off,Icons.cloud_queue,Icons.cloud_upload,Icons.code,Icons.collections,Icons.collections_bookmark,Icons.color_lens,Icons.colorize,Icons.comment,Icons.compare,Icons.compare_arrows,Icons.computer,Icons.confirmation_number,Icons.contact_mail,Icons.contact_phone,Icons.contacts,Icons.content_copy,Icons.content_cut,Icons.content_paste,Icons.control_point,Icons.control_point_duplicate,Icons.copyright,Icons.create,Icons.create_new_folder,Icons.credit_card,Icons.crop,Icons.crop_3_2,Icons.crop_5_4,Icons.crop_7_5,Icons.crop_16_9,Icons.crop_din,Icons.crop_free,Icons.crop_landscape,Icons.crop_original,Icons.crop_portrait,Icons.crop_rotate,Icons.crop_square,Icons.dashboard,Icons.data_usage,Icons.date_range,Icons.dehaze,Icons.delete,Icons.delete_forever,Icons.delete_outline,Icons.delete_sweep,Icons.departure_board,Icons.description,Icons.desktop_mac,Icons.desktop_windows,Icons.details,Icons.developer_board,Icons.developer_mode,Icons.device_hub,Icons.device_unknown,Icons.devices,Icons.devices_other,Icons.dialer_sip,Icons.dialpad,Icons.directions,Icons.directions_bike,Icons.directions_boat,Icons.directions_bus,Icons.directions_car,Icons.directions_railway,Icons.directions_run,Icons.directions_subway,Icons.directions_transit,Icons.directions_walk,Icons.disc_full,Icons.dns,Icons.do_not_disturb,Icons.do_not_disturb_alt,Icons.do_not_disturb_off,Icons.do_not_disturb_on,Icons.dock,Icons.domain,Icons.done,Icons.done_all,Icons.done_outline,Icons.donut_large,Icons.donut_small,Icons.drafts,Icons.drag_handle,Icons.drive_eta,Icons.dvr,Icons.edit,Icons.edit_attributes,Icons.edit_location,Icons.eject,Icons.email,Icons.enhanced_encryption,Icons.equalizer,Icons.error,Icons.error_outline,Icons.euro_symbol,Icons.ev_station,Icons.event,Icons.event_available,Icons.event_busy,Icons.event_note,Icons.event_seat,Icons.exit_to_app,Icons.expand_less,Icons.expand_more,Icons.explicit,Icons.explore,Icons.exposure,Icons.exposure_neg_1,Icons.exposure_neg_2,Icons.exposure_plus_1,Icons.exposure_plus_2,Icons.exposure_zero,Icons.extension,Icons.face,Icons.fast_forward,Icons.fast_rewind,Icons.fastfood,Icons.favorite,Icons.favorite_border,Icons.featured_play_list,Icons.featured_video,Icons.feedback,Icons.fiber_dvr,Icons.fiber_manual_record,Icons.fiber_new,Icons.fiber_pin,Icons.fiber_smart_record,Icons.file_download,Icons.file_upload,Icons.filter,Icons.filter_1,Icons.filter_2,Icons.filter_3,Icons.filter_4,Icons.filter_5,Icons.filter_6,Icons.filter_7,Icons.filter_8,Icons.filter_9,Icons.filter_9_plus,Icons.filter_b_and_w,Icons.filter_center_focus,Icons.filter_drama,Icons.filter_frames,Icons.filter_hdr,Icons.filter_list,Icons.filter_none,Icons.filter_tilt_shift,Icons.filter_vintage,Icons.find_in_page,Icons.find_replace,Icons.fingerprint,Icons.first_page,Icons.fitness_center,Icons.flag,Icons.flare,Icons.flash_auto,Icons.flash_off,Icons.flash_on,Icons.flight,Icons.flight_land,Icons.flight_takeoff,Icons.flip,Icons.flip_to_back,Icons.flip_to_front,Icons.folder,Icons.folder_open,Icons.folder_shared,Icons.folder_special,Icons.font_download,Icons.format_align_center,Icons.format_align_justify,Icons.format_align_left,Icons.format_align_right,Icons.format_bold,Icons.format_clear,Icons.format_color_fill,Icons.format_color_reset,Icons.format_color_text,Icons.format_indent_decrease,Icons.format_indent_increase,Icons.format_italic,Icons.format_line_spacing,Icons.format_list_bulleted,Icons.format_list_numbered,Icons.format_list_numbered_rtl,Icons.format_paint,Icons.format_quote,Icons.format_shapes,Icons.format_size,Icons.format_strikethrough,Icons.format_textdirection_l_to_r,Icons.format_textdirection_r_to_l,Icons.format_underlined,Icons.forum,Icons.forward,Icons.forward_5,Icons.forward_10,Icons.forward_30,Icons.four_k,Icons.free_breakfast,Icons.fullscreen,Icons.fullscreen_exit,Icons.functions,Icons.g_translate,Icons.gamepad,Icons.games,Icons.gavel,Icons.gesture,Icons.get_app,Icons.gif,Icons.golf_course,Icons.gps_fixed,Icons.gps_not_fixed,Icons.gps_off,Icons.grade,Icons.gradient,Icons.grain,Icons.graphic_eq,Icons.grid_off,Icons.grid_on,Icons.group,Icons.group_add,Icons.group_work,Icons.hd,Icons.hdr_off,Icons.hdr_on,Icons.hdr_strong,Icons.hdr_weak,Icons.headset,Icons.headset_mic,Icons.headset_off,Icons.healing,Icons.hearing,Icons.help,Icons.help_outline,Icons.high_quality,Icons.highlight,Icons.highlight_off,Icons.history,Icons.home,Icons.hot_tub,Icons.hotel,Icons.hourglass_empty,Icons.hourglass_full,Icons.http,Icons.https,Icons.image,Icons.image_aspect_ratio,Icons.import_contacts,Icons.import_export,Icons.important_devices,Icons.inbox,Icons.indeterminate_check_box,Icons.info,Icons.info_outline,Icons.input,Icons.insert_chart,Icons.insert_comment,Icons.insert_drive_file,Icons.insert_emoticon,Icons.insert_invitation,Icons.insert_link,Icons.insert_photo,Icons.invert_colors,Icons.invert_colors_off,Icons.iso,Icons.keyboard,Icons.keyboard_arrow_down,Icons.keyboard_arrow_left,Icons.keyboard_arrow_right,Icons.keyboard_arrow_up,Icons.keyboard_backspace,Icons.keyboard_capslock,Icons.keyboard_hide,Icons.keyboard_return,Icons.keyboard_tab,Icons.keyboard_voice,Icons.kitchen,Icons.label,Icons.label_important,Icons.label_outline,Icons.landscape,Icons.language,Icons.laptop,Icons.laptop_chromebook,Icons.laptop_mac,Icons.laptop_windows,Icons.last_page,Icons.launch,Icons.layers,Icons.layers_clear,Icons.leak_add,Icons.leak_remove,Icons.lens,Icons.library_add,Icons.library_books,Icons.library_music,Icons.lightbulb_outline,Icons.line_style,Icons.line_weight,Icons.linear_scale,Icons.link,Icons.link_off,Icons.linked_camera,Icons.list,Icons.live_help,Icons.live_tv,Icons.local_activity,Icons.local_airport,Icons.local_atm,Icons.local_bar,Icons.local_cafe,Icons.local_car_wash,Icons.local_convenience_store,Icons.local_dining,Icons.local_drink,Icons.local_florist,Icons.local_gas_station,Icons.local_grocery_store,Icons.local_hospital,Icons.local_hotel,Icons.local_laundry_service,Icons.local_library,Icons.local_mall,Icons.local_movies,Icons.local_offer,Icons.local_parking,Icons.local_pharmacy,Icons.local_phone,Icons.local_pizza,Icons.local_play,Icons.local_post_office,Icons.local_printshop,Icons.local_see,Icons.local_shipping,Icons.local_taxi,Icons.location_city,Icons.location_disabled,Icons.location_off,Icons.location_on,Icons.location_searching,Icons.lock,Icons.lock_open,Icons.lock_outline,Icons.looks,Icons.looks_3,Icons.looks_4,Icons.looks_5,Icons.looks_6,Icons.looks_one,Icons.looks_two,Icons.loop,Icons.loupe,Icons.low_priority,Icons.loyalty,Icons.mail,Icons.mail_outline,Icons.map,Icons.markunread,Icons.markunread_mailbox,Icons.maximize,Icons.memory,Icons.menu,Icons.merge_type,Icons.message,Icons.mic,Icons.mic_none,Icons.mic_off,Icons.minimize,Icons.missed_video_call,Icons.mms,Icons.mobile_screen_share,Icons.mode_comment,Icons.mode_edit,Icons.monetization_on,Icons.money_off,Icons.monochrome_photos,Icons.mood,Icons.mood_bad,Icons.more,Icons.more_horiz,Icons.more_vert,Icons.motorcycle,Icons.mouse,Icons.move_to_inbox,Icons.movie,Icons.movie_creation,Icons.movie_filter,Icons.multiline_chart,Icons.music_note,Icons.music_video,Icons.my_location,Icons.nature,Icons.nature_people,Icons.navigate_before,Icons.navigate_next,Icons.navigation,Icons.near_me,Icons.network_cell,Icons.network_check,Icons.network_locked,Icons.network_wifi,Icons.new_releases,Icons.next_week,Icons.nfc,Icons.no_encryption,Icons.no_sim,Icons.not_interested,Icons.not_listed_location,Icons.note,Icons.note_add,Icons.notification_important,Icons.notifications,Icons.notifications_active,Icons.notifications_none,Icons.notifications_off,Icons.notifications_paused,Icons.offline_bolt,Icons.offline_pin,Icons.ondemand_video,Icons.opacity,Icons.open_in_browser,Icons.open_in_new,Icons.open_with,Icons.outlined_flag,Icons.pages,Icons.pageview,Icons.palette,Icons.pan_tool,Icons.panorama,Icons.panorama_fish_eye,Icons.panorama_horizontal,Icons.panorama_vertical,Icons.panorama_wide_angle,Icons.party_mode,Icons.pause,Icons.pause_circle_filled,Icons.pause_circle_outline,Icons.payment,Icons.people,Icons.people_outline,Icons.perm_camera_mic,Icons.perm_contact_calendar,Icons.perm_data_setting,Icons.perm_device_information,Icons.perm_identity,Icons.perm_media,Icons.perm_phone_msg,Icons.perm_scan_wifi,Icons.person,Icons.person_add,Icons.person_outline,Icons.person_pin,Icons.person_pin_circle,Icons.personal_video,Icons.pets,Icons.phone,Icons.phone_android,Icons.phone_bluetooth_speaker,Icons.phone_forwarded,Icons.phone_in_talk,Icons.phone_iphone,Icons.phone_locked,Icons.phone_missed,Icons.phone_paused,Icons.phonelink,Icons.phonelink_erase,Icons.phonelink_lock,Icons.phonelink_off,Icons.phonelink_ring,Icons.phonelink_setup,Icons.photo,Icons.photo_album,Icons.photo_camera,Icons.photo_filter,Icons.photo_library,Icons.photo_size_select_actual,Icons.photo_size_select_large,Icons.photo_size_select_small,Icons.picture_as_pdf,Icons.picture_in_picture,Icons.picture_in_picture_alt,Icons.pie_chart,Icons.pie_chart_outlined,Icons.pin_drop,Icons.place,Icons.play_arrow,Icons.play_circle_filled,Icons.play_circle_outline,Icons.play_for_work,Icons.playlist_add,Icons.playlist_add_check,Icons.playlist_play,Icons.plus_one,Icons.poll,Icons.polymer,Icons.pool,Icons.portable_wifi_off,Icons.portrait,Icons.power,Icons.power_input,Icons.power_settings_new,Icons.pregnant_woman,Icons.present_to_all,Icons.print,Icons.priority_high,Icons.public,Icons.publish,Icons.query_builder,Icons.question_answer,Icons.queue,Icons.queue_music,Icons.queue_play_next,Icons.radio,Icons.radio_button_checked,Icons.radio_button_unchecked,Icons.rate_review,Icons.receipt,Icons.recent_actors,Icons.record_voice_over,Icons.redeem,Icons.redo,Icons.refresh,Icons.remove,Icons.remove_circle,Icons.remove_circle_outline,Icons.remove_from_queue,Icons.remove_red_eye,Icons.remove_shopping_cart,Icons.reorder,Icons.repeat,Icons.repeat_one,Icons.replay,Icons.replay_5,Icons.replay_10,Icons.replay_30,Icons.reply,Icons.reply_all,Icons.report,Icons.report_off,Icons.report_problem,Icons.restaurant,Icons.restaurant_menu,Icons.restore,Icons.restore_from_trash,Icons.restore_page,Icons.ring_volume,Icons.room,Icons.room_service,Icons.rotate_90_degrees_ccw,Icons.rotate_left,Icons.rotate_right,Icons.rounded_corner,Icons.router,Icons.rowing,Icons.rss_feed,Icons.rv_hookup,Icons.satellite,Icons.save,Icons.save_alt,Icons.scanner,Icons.scatter_plot,Icons.schedule,Icons.school,Icons.score,Icons.screen_lock_landscape,Icons.screen_lock_portrait,Icons.screen_lock_rotation,Icons.screen_rotation,Icons.screen_share,Icons.sd_card,Icons.sd_storage,Icons.search,Icons.security,Icons.select_all,Icons.send,Icons.sentiment_dissatisfied,Icons.sentiment_neutral,Icons.sentiment_satisfied,Icons.sentiment_very_dissatisfied,Icons.sentiment_very_satisfied,Icons.settings,Icons.settings_applications,Icons.settings_backup_restore,Icons.settings_bluetooth,Icons.settings_brightness,Icons.settings_cell,Icons.settings_ethernet,Icons.settings_input_antenna,Icons.settings_input_component,Icons.settings_input_composite,Icons.settings_input_hdmi,Icons.settings_input_svideo,Icons.settings_overscan,Icons.settings_phone,Icons.settings_power,Icons.settings_remote,Icons.settings_system_daydream,Icons.settings_voice,Icons.share,Icons.shop,Icons.shop_two,Icons.shopping_basket,Icons.shopping_cart,Icons.short_text,Icons.show_chart,Icons.shuffle,Icons.shutter_speed,Icons.signal_cellular_4_bar,Icons.signal_cellular_connected_no_internet_4_bar,Icons.signal_cellular_no_sim,Icons.signal_cellular_null,Icons.signal_cellular_off,Icons.signal_wifi_4_bar,Icons.signal_wifi_4_bar_lock,Icons.signal_wifi_off,Icons.sim_card,Icons.sim_card_alert,Icons.skip_next,Icons.skip_previous,Icons.slideshow,Icons.slow_motion_video,Icons.smartphone,Icons.smoke_free,Icons.smoking_rooms,Icons.sms,Icons.sms_failed,Icons.snooze,Icons.sort,Icons.sort_by_alpha,Icons.spa,Icons.space_bar,Icons.speaker,Icons.speaker_group,Icons.speaker_notes,Icons.speaker_notes_off,Icons.speaker_phone,Icons.spellcheck,Icons.star,Icons.star_border,Icons.star_half,Icons.stars,Icons.stay_current_landscape,Icons.stay_current_portrait,Icons.stay_primary_landscape,Icons.stay_primary_portrait,Icons.stop,Icons.stop_screen_share,Icons.storage,Icons.store,Icons.store_mall_directory,Icons.straighten,Icons.streetview,Icons.strikethrough_s,Icons.style,Icons.subdirectory_arrow_left,Icons.subdirectory_arrow_right,Icons.subject,Icons.subscriptions,Icons.subtitles,Icons.subway,Icons.supervised_user_circle,Icons.supervisor_account,Icons.surround_sound,Icons.swap_calls,Icons.swap_horiz,Icons.swap_horizontal_circle,Icons.swap_vert,Icons.swap_vertical_circle,Icons.switch_camera,Icons.switch_video,Icons.sync,Icons.sync_disabled,Icons.sync_problem,Icons.system_update,Icons.system_update_alt,Icons.tab,Icons.tab_unselected,Icons.table_chart,Icons.tablet,Icons.tablet_android,Icons.tablet_mac,Icons.tag_faces,Icons.tap_and_play,Icons.terrain,Icons.text_fields,Icons.text_format,Icons.text_rotate_up,Icons.text_rotate_vertical,Icons.text_rotation_angledown,Icons.text_rotation_angleup,Icons.text_rotation_down,Icons.text_rotation_none,Icons.textsms,Icons.texture,Icons.theaters,Icons.threed_rotation,Icons.threesixty,Icons.thumb_down,Icons.thumb_up,Icons.thumbs_up_down,Icons.time_to_leave,Icons.timelapse,Icons.timeline,Icons.timer,Icons.timer_3,Icons.timer_10,Icons.timer_off,Icons.title,Icons.toc,Icons.today,Icons.toll,Icons.tonality,Icons.touch_app,Icons.toys,Icons.track_changes,Icons.traffic,Icons.train,Icons.tram,Icons.transfer_within_a_station,Icons.transform,Icons.transit_enterexit,Icons.translate,Icons.trending_down,Icons.trending_flat,Icons.trending_up,Icons.trip_origin,Icons.tune,Icons.turned_in,Icons.turned_in_not,Icons.tv,Icons.unarchive,Icons.undo,Icons.unfold_less,Icons.unfold_more,Icons.update,Icons.usb,Icons.verified_user,Icons.vertical_align_bottom,Icons.vertical_align_center,Icons.vertical_align_top,Icons.vibration,Icons.video_call,Icons.video_label,Icons.video_library,Icons.videocam,Icons.videocam_off,Icons.videogame_asset,Icons.view_agenda,Icons.view_array,Icons.view_carousel,Icons.view_column,Icons.view_comfy,Icons.view_compact,Icons.view_day,Icons.view_headline,Icons.view_list,Icons.view_module,Icons.view_quilt,Icons.view_stream,Icons.view_week,Icons.vignette,Icons.visibility,Icons.visibility_off,Icons.voice_chat,Icons.voicemail,Icons.volume_down,Icons.volume_mute,Icons.volume_off,Icons.volume_up,Icons.vpn_key,Icons.vpn_lock,Icons.wallpaper,Icons.warning,Icons.watch,Icons.watch_later,Icons.wb_auto,Icons.wb_cloudy,Icons.wb_incandescent,Icons.wb_iridescent,Icons.wb_sunny,Icons.wc,Icons.web,Icons.web_asset,Icons.weekend,Icons.whatshot,Icons.widgets,Icons.wifi,Icons.wifi_lock,Icons.wifi_tethering,Icons.work,Icons.wrap_text,Icons.youtube_searched_for,Icons.zoom_in,Icons.zoom_out,Icons.zoom_out_map]; + static List names = [ + Icons.ac_unit, + Icons.access_alarm, + Icons.access_alarms, + Icons.access_time, + Icons.accessibility, + Icons.accessibility_new, + Icons.accessible, + Icons.accessible_forward, + Icons.account_balance, + Icons.account_balance_wallet, + Icons.account_box, + Icons.account_circle, + Icons.adb, + Icons.add, + Icons.add_a_photo, + Icons.add_alarm, + Icons.add_alert, + Icons.add_box, + Icons.add_call, + Icons.add_circle, + Icons.add_circle_outline, + Icons.add_comment, + Icons.add_location, + Icons.add_photo_alternate, + Icons.add_shopping_cart, + Icons.add_to_home_screen, + Icons.add_to_photos, + Icons.add_to_queue, + Icons.adjust, + Icons.airline_seat_flat, + Icons.airline_seat_flat_angled, + Icons.airline_seat_individual_suite, + Icons.airline_seat_legroom_extra, + Icons.airline_seat_legroom_normal, + Icons.airline_seat_legroom_reduced, + Icons.airline_seat_recline_extra, + Icons.airline_seat_recline_normal, + Icons.airplanemode_active, + Icons.airplanemode_inactive, + Icons.airplay, + Icons.airport_shuttle, + Icons.alarm, + Icons.alarm_add, + Icons.alarm_off, + Icons.alarm_on, + Icons.album, + Icons.all_inclusive, + Icons.all_out, + Icons.alternate_email, + Icons.android, + Icons.announcement, + Icons.apps, + Icons.archive, + Icons.arrow_back, + Icons.arrow_back_ios, + Icons.arrow_downward, + Icons.arrow_drop_down, + Icons.arrow_drop_down_circle, + Icons.arrow_drop_up, + Icons.arrow_forward, + Icons.arrow_forward_ios, + Icons.arrow_left, + Icons.arrow_right, + Icons.arrow_upward, + Icons.art_track, + Icons.aspect_ratio, + Icons.assessment, + Icons.assignment, + Icons.assignment_ind, + Icons.assignment_late, + Icons.assignment_return, + Icons.assignment_returned, + Icons.assignment_turned_in, + Icons.assistant, + Icons.assistant_photo, + Icons.atm, + Icons.attach_file, + Icons.attach_money, + Icons.attachment, + Icons.audiotrack, + Icons.autorenew, + Icons.av_timer, + Icons.backspace, + Icons.backup, + Icons.battery_alert, + Icons.battery_charging_full, + Icons.battery_full, + Icons.battery_std, + Icons.battery_unknown, + Icons.beach_access, + Icons.beenhere, + Icons.block, + Icons.bluetooth, + Icons.bluetooth_audio, + Icons.bluetooth_connected, + Icons.bluetooth_disabled, + Icons.bluetooth_searching, + Icons.blur_circular, + Icons.blur_linear, + Icons.blur_off, + Icons.blur_on, + Icons.book, + Icons.bookmark, + Icons.bookmark_border, + Icons.border_all, + Icons.border_bottom, + Icons.border_clear, + Icons.border_color, + Icons.border_horizontal, + Icons.border_inner, + Icons.border_left, + Icons.border_outer, + Icons.border_right, + Icons.border_style, + Icons.border_top, + Icons.border_vertical, + Icons.branding_watermark, + Icons.brightness_1, + Icons.brightness_2, + Icons.brightness_3, + Icons.brightness_4, + Icons.brightness_5, + Icons.brightness_6, + Icons.brightness_7, + Icons.brightness_auto, + Icons.brightness_high, + Icons.brightness_low, + Icons.brightness_medium, + Icons.broken_image, + Icons.brush, + Icons.bubble_chart, + Icons.bug_report, + Icons.build, + Icons.burst_mode, + Icons.business, + Icons.business_center, + Icons.cached, + Icons.cake, + Icons.calendar_today, + Icons.calendar_view_day, + Icons.call, + Icons.call_end, + Icons.call_made, + Icons.call_merge, + Icons.call_missed, + Icons.call_missed_outgoing, + Icons.call_received, + Icons.call_split, + Icons.call_to_action, + Icons.camera, + Icons.camera_alt, + Icons.camera_enhance, + Icons.camera_front, + Icons.camera_rear, + Icons.camera_roll, + Icons.cancel, + Icons.card_giftcard, + Icons.card_membership, + Icons.card_travel, + Icons.casino, + Icons.cast, + Icons.cast_connected, + Icons.category, + Icons.center_focus_strong, + Icons.center_focus_weak, + Icons.change_history, + Icons.chat, + Icons.chat_bubble, + Icons.chat_bubble_outline, + Icons.check, + Icons.check_box, + Icons.check_box_outline_blank, + Icons.check_circle, + Icons.check_circle_outline, + Icons.chevron_left, + Icons.chevron_right, + Icons.child_care, + Icons.child_friendly, + Icons.chrome_reader_mode, + Icons.class_, + Icons.clear, + Icons.clear_all, + Icons.close, + Icons.closed_caption, + Icons.cloud, + Icons.cloud_circle, + Icons.cloud_done, + Icons.cloud_download, + Icons.cloud_off, + Icons.cloud_queue, + Icons.cloud_upload, + Icons.code, + Icons.collections, + Icons.collections_bookmark, + Icons.color_lens, + Icons.colorize, + Icons.comment, + Icons.compare, + Icons.compare_arrows, + Icons.computer, + Icons.confirmation_number, + Icons.contact_mail, + Icons.contact_phone, + Icons.contacts, + Icons.content_copy, + Icons.content_cut, + Icons.content_paste, + Icons.control_point, + Icons.control_point_duplicate, + Icons.copyright, + Icons.create, + Icons.create_new_folder, + Icons.credit_card, + Icons.crop, + Icons.crop_3_2, + Icons.crop_5_4, + Icons.crop_7_5, + Icons.crop_16_9, + Icons.crop_din, + Icons.crop_free, + Icons.crop_landscape, + Icons.crop_original, + Icons.crop_portrait, + Icons.crop_rotate, + Icons.crop_square, + Icons.dashboard, + Icons.data_usage, + Icons.date_range, + Icons.dehaze, + Icons.delete, + Icons.delete_forever, + Icons.delete_outline, + Icons.delete_sweep, + Icons.departure_board, + Icons.description, + Icons.desktop_mac, + Icons.desktop_windows, + Icons.details, + Icons.developer_board, + Icons.developer_mode, + Icons.device_hub, + Icons.device_unknown, + Icons.devices, + Icons.devices_other, + Icons.dialer_sip, + Icons.dialpad, + Icons.directions, + Icons.directions_bike, + Icons.directions_boat, + Icons.directions_bus, + Icons.directions_car, + Icons.directions_railway, + Icons.directions_run, + Icons.directions_subway, + Icons.directions_transit, + Icons.directions_walk, + Icons.disc_full, + Icons.dns, + Icons.do_not_disturb, + Icons.do_not_disturb_alt, + Icons.do_not_disturb_off, + Icons.do_not_disturb_on, + Icons.dock, + Icons.domain, + Icons.done, + Icons.done_all, + Icons.done_outline, + Icons.donut_large, + Icons.donut_small, + Icons.drafts, + Icons.drag_handle, + Icons.drive_eta, + Icons.dvr, + Icons.edit, + Icons.edit_attributes, + Icons.edit_location, + Icons.eject, + Icons.email, + Icons.enhanced_encryption, + Icons.equalizer, + Icons.error, + Icons.error_outline, + Icons.euro_symbol, + Icons.ev_station, + Icons.event, + Icons.event_available, + Icons.event_busy, + Icons.event_note, + Icons.event_seat, + Icons.exit_to_app, + Icons.expand_less, + Icons.expand_more, + Icons.explicit, + Icons.explore, + Icons.exposure, + Icons.exposure_neg_1, + Icons.exposure_neg_2, + Icons.exposure_plus_1, + Icons.exposure_plus_2, + Icons.exposure_zero, + Icons.extension, + Icons.face, + Icons.fast_forward, + Icons.fast_rewind, + Icons.fastfood, + Icons.favorite, + Icons.favorite_border, + Icons.featured_play_list, + Icons.featured_video, + Icons.feedback, + Icons.fiber_dvr, + Icons.fiber_manual_record, + Icons.fiber_new, + Icons.fiber_pin, + Icons.fiber_smart_record, + Icons.file_download, + Icons.file_upload, + Icons.filter, + Icons.filter_1, + Icons.filter_2, + Icons.filter_3, + Icons.filter_4, + Icons.filter_5, + Icons.filter_6, + Icons.filter_7, + Icons.filter_8, + Icons.filter_9, + Icons.filter_9_plus, + Icons.filter_b_and_w, + Icons.filter_center_focus, + Icons.filter_drama, + Icons.filter_frames, + Icons.filter_hdr, + Icons.filter_list, + Icons.filter_none, + Icons.filter_tilt_shift, + Icons.filter_vintage, + Icons.find_in_page, + Icons.find_replace, + Icons.fingerprint, + Icons.first_page, + Icons.fitness_center, + Icons.flag, + Icons.flare, + Icons.flash_auto, + Icons.flash_off, + Icons.flash_on, + Icons.flight, + Icons.flight_land, + Icons.flight_takeoff, + Icons.flip, + Icons.flip_to_back, + Icons.flip_to_front, + Icons.folder, + Icons.folder_open, + Icons.folder_shared, + Icons.folder_special, + Icons.font_download, + Icons.format_align_center, + Icons.format_align_justify, + Icons.format_align_left, + Icons.format_align_right, + Icons.format_bold, + Icons.format_clear, + Icons.format_color_fill, + Icons.format_color_reset, + Icons.format_color_text, + Icons.format_indent_decrease, + Icons.format_indent_increase, + Icons.format_italic, + Icons.format_line_spacing, + Icons.format_list_bulleted, + Icons.format_list_numbered, + Icons.format_list_numbered_rtl, + Icons.format_paint, + Icons.format_quote, + Icons.format_shapes, + Icons.format_size, + Icons.format_strikethrough, + Icons.format_textdirection_l_to_r, + Icons.format_textdirection_r_to_l, + Icons.format_underlined, + Icons.forum, + Icons.forward, + Icons.forward_5, + Icons.forward_10, + Icons.forward_30, + Icons.four_k, + Icons.free_breakfast, + Icons.fullscreen, + Icons.fullscreen_exit, + Icons.functions, + Icons.g_translate, + Icons.gamepad, + Icons.games, + Icons.gavel, + Icons.gesture, + Icons.get_app, + Icons.gif, + Icons.golf_course, + Icons.gps_fixed, + Icons.gps_not_fixed, + Icons.gps_off, + Icons.grade, + Icons.gradient, + Icons.grain, + Icons.graphic_eq, + Icons.grid_off, + Icons.grid_on, + Icons.group, + Icons.group_add, + Icons.group_work, + Icons.hd, + Icons.hdr_off, + Icons.hdr_on, + Icons.hdr_strong, + Icons.hdr_weak, + Icons.headset, + Icons.headset_mic, + Icons.headset_off, + Icons.healing, + Icons.hearing, + Icons.help, + Icons.help_outline, + Icons.high_quality, + Icons.highlight, + Icons.highlight_off, + Icons.history, + Icons.home, + Icons.hot_tub, + Icons.hotel, + Icons.hourglass_empty, + Icons.hourglass_full, + Icons.http, + Icons.https, + Icons.image, + Icons.image_aspect_ratio, + Icons.import_contacts, + Icons.import_export, + Icons.important_devices, + Icons.inbox, + Icons.indeterminate_check_box, + Icons.info, + Icons.info_outline, + Icons.input, + Icons.insert_chart, + Icons.insert_comment, + Icons.insert_drive_file, + Icons.insert_emoticon, + Icons.insert_invitation, + Icons.insert_link, + Icons.insert_photo, + Icons.invert_colors, + Icons.invert_colors_off, + Icons.iso, + Icons.keyboard, + Icons.keyboard_arrow_down, + Icons.keyboard_arrow_left, + Icons.keyboard_arrow_right, + Icons.keyboard_arrow_up, + Icons.keyboard_backspace, + Icons.keyboard_capslock, + Icons.keyboard_hide, + Icons.keyboard_return, + Icons.keyboard_tab, + Icons.keyboard_voice, + Icons.kitchen, + Icons.label, + Icons.label_important, + Icons.label_outline, + Icons.landscape, + Icons.language, + Icons.laptop, + Icons.laptop_chromebook, + Icons.laptop_mac, + Icons.laptop_windows, + Icons.last_page, + Icons.launch, + Icons.layers, + Icons.layers_clear, + Icons.leak_add, + Icons.leak_remove, + Icons.lens, + Icons.library_add, + Icons.library_books, + Icons.library_music, + Icons.lightbulb_outline, + Icons.line_style, + Icons.line_weight, + Icons.linear_scale, + Icons.link, + Icons.link_off, + Icons.linked_camera, + Icons.list, + Icons.live_help, + Icons.live_tv, + Icons.local_activity, + Icons.local_airport, + Icons.local_atm, + Icons.local_bar, + Icons.local_cafe, + Icons.local_car_wash, + Icons.local_convenience_store, + Icons.local_dining, + Icons.local_drink, + Icons.local_florist, + Icons.local_gas_station, + Icons.local_grocery_store, + Icons.local_hospital, + Icons.local_hotel, + Icons.local_laundry_service, + Icons.local_library, + Icons.local_mall, + Icons.local_movies, + Icons.local_offer, + Icons.local_parking, + Icons.local_pharmacy, + Icons.local_phone, + Icons.local_pizza, + Icons.local_play, + Icons.local_post_office, + Icons.local_printshop, + Icons.local_see, + Icons.local_shipping, + Icons.local_taxi, + Icons.location_city, + Icons.location_disabled, + Icons.location_off, + Icons.location_on, + Icons.location_searching, + Icons.lock, + Icons.lock_open, + Icons.lock_outline, + Icons.looks, + Icons.looks_3, + Icons.looks_4, + Icons.looks_5, + Icons.looks_6, + Icons.looks_one, + Icons.looks_two, + Icons.loop, + Icons.loupe, + Icons.low_priority, + Icons.loyalty, + Icons.mail, + Icons.mail_outline, + Icons.map, + Icons.markunread, + Icons.markunread_mailbox, + Icons.maximize, + Icons.memory, + Icons.menu, + Icons.merge_type, + Icons.message, + Icons.mic, + Icons.mic_none, + Icons.mic_off, + Icons.minimize, + Icons.missed_video_call, + Icons.mms, + Icons.mobile_screen_share, + Icons.mode_comment, + Icons.mode_edit, + Icons.monetization_on, + Icons.money_off, + Icons.monochrome_photos, + Icons.mood, + Icons.mood_bad, + Icons.more, + Icons.more_horiz, + Icons.more_vert, + Icons.motorcycle, + Icons.mouse, + Icons.move_to_inbox, + Icons.movie, + Icons.movie_creation, + Icons.movie_filter, + Icons.multiline_chart, + Icons.music_note, + Icons.music_video, + Icons.my_location, + Icons.nature, + Icons.nature_people, + Icons.navigate_before, + Icons.navigate_next, + Icons.navigation, + Icons.near_me, + Icons.network_cell, + Icons.network_check, + Icons.network_locked, + Icons.network_wifi, + Icons.new_releases, + Icons.next_week, + Icons.nfc, + Icons.no_encryption, + Icons.no_sim, + Icons.not_interested, + Icons.not_listed_location, + Icons.note, + Icons.note_add, + Icons.notification_important, + Icons.notifications, + Icons.notifications_active, + Icons.notifications_none, + Icons.notifications_off, + Icons.notifications_paused, + Icons.offline_bolt, + Icons.offline_pin, + Icons.ondemand_video, + Icons.opacity, + Icons.open_in_browser, + Icons.open_in_new, + Icons.open_with, + Icons.outlined_flag, + Icons.pages, + Icons.pageview, + Icons.palette, + Icons.pan_tool, + Icons.panorama, + Icons.panorama_fish_eye, + Icons.panorama_horizontal, + Icons.panorama_vertical, + Icons.panorama_wide_angle, + Icons.party_mode, + Icons.pause, + Icons.pause_circle_filled, + Icons.pause_circle_outline, + Icons.payment, + Icons.people, + Icons.people_outline, + Icons.perm_camera_mic, + Icons.perm_contact_calendar, + Icons.perm_data_setting, + Icons.perm_device_information, + Icons.perm_identity, + Icons.perm_media, + Icons.perm_phone_msg, + Icons.perm_scan_wifi, + Icons.person, + Icons.person_add, + Icons.person_outline, + Icons.person_pin, + Icons.person_pin_circle, + Icons.personal_video, + Icons.pets, + Icons.phone, + Icons.phone_android, + Icons.phone_bluetooth_speaker, + Icons.phone_forwarded, + Icons.phone_in_talk, + Icons.phone_iphone, + Icons.phone_locked, + Icons.phone_missed, + Icons.phone_paused, + Icons.phonelink, + Icons.phonelink_erase, + Icons.phonelink_lock, + Icons.phonelink_off, + Icons.phonelink_ring, + Icons.phonelink_setup, + Icons.photo, + Icons.photo_album, + Icons.photo_camera, + Icons.photo_filter, + Icons.photo_library, + Icons.photo_size_select_actual, + Icons.photo_size_select_large, + Icons.photo_size_select_small, + Icons.picture_as_pdf, + Icons.picture_in_picture, + Icons.picture_in_picture_alt, + Icons.pie_chart, + Icons.pie_chart_outlined, + Icons.pin_drop, + Icons.place, + Icons.play_arrow, + Icons.play_circle_filled, + Icons.play_circle_outline, + Icons.play_for_work, + Icons.playlist_add, + Icons.playlist_add_check, + Icons.playlist_play, + Icons.plus_one, + Icons.poll, + Icons.polymer, + Icons.pool, + Icons.portable_wifi_off, + Icons.portrait, + Icons.power, + Icons.power_input, + Icons.power_settings_new, + Icons.pregnant_woman, + Icons.present_to_all, + Icons.print, + Icons.priority_high, + Icons.public, + Icons.publish, + Icons.query_builder, + Icons.question_answer, + Icons.queue, + Icons.queue_music, + Icons.queue_play_next, + Icons.radio, + Icons.radio_button_checked, + Icons.radio_button_unchecked, + Icons.rate_review, + Icons.receipt, + Icons.recent_actors, + Icons.record_voice_over, + Icons.redeem, + Icons.redo, + Icons.refresh, + Icons.remove, + Icons.remove_circle, + Icons.remove_circle_outline, + Icons.remove_from_queue, + Icons.remove_red_eye, + Icons.remove_shopping_cart, + Icons.reorder, + Icons.repeat, + Icons.repeat_one, + Icons.replay, + Icons.replay_5, + Icons.replay_10, + Icons.replay_30, + Icons.reply, + Icons.reply_all, + Icons.report, + Icons.report_off, + Icons.report_problem, + Icons.restaurant, + Icons.restaurant_menu, + Icons.restore, + Icons.restore_from_trash, + Icons.restore_page, + Icons.ring_volume, + Icons.room, + Icons.room_service, + Icons.rotate_90_degrees_ccw, + Icons.rotate_left, + Icons.rotate_right, + Icons.rounded_corner, + Icons.router, + Icons.rowing, + Icons.rss_feed, + Icons.rv_hookup, + Icons.satellite, + Icons.save, + Icons.save_alt, + Icons.scanner, + Icons.scatter_plot, + Icons.schedule, + Icons.school, + Icons.score, + Icons.screen_lock_landscape, + Icons.screen_lock_portrait, + Icons.screen_lock_rotation, + Icons.screen_rotation, + Icons.screen_share, + Icons.sd_card, + Icons.sd_storage, + Icons.search, + Icons.security, + Icons.select_all, + Icons.send, + Icons.sentiment_dissatisfied, + Icons.sentiment_neutral, + Icons.sentiment_satisfied, + Icons.sentiment_very_dissatisfied, + Icons.sentiment_very_satisfied, + Icons.settings, + Icons.settings_applications, + Icons.settings_backup_restore, + Icons.settings_bluetooth, + Icons.settings_brightness, + Icons.settings_cell, + Icons.settings_ethernet, + Icons.settings_input_antenna, + Icons.settings_input_component, + Icons.settings_input_composite, + Icons.settings_input_hdmi, + Icons.settings_input_svideo, + Icons.settings_overscan, + Icons.settings_phone, + Icons.settings_power, + Icons.settings_remote, + Icons.settings_system_daydream, + Icons.settings_voice, + Icons.share, + Icons.shop, + Icons.shop_two, + Icons.shopping_basket, + Icons.shopping_cart, + Icons.short_text, + Icons.show_chart, + Icons.shuffle, + Icons.shutter_speed, + Icons.signal_cellular_4_bar, + Icons.signal_cellular_connected_no_internet_4_bar, + Icons.signal_cellular_no_sim, + Icons.signal_cellular_null, + Icons.signal_cellular_off, + Icons.signal_wifi_4_bar, + Icons.signal_wifi_4_bar_lock, + Icons.signal_wifi_off, + Icons.sim_card, + Icons.sim_card_alert, + Icons.skip_next, + Icons.skip_previous, + Icons.slideshow, + Icons.slow_motion_video, + Icons.smartphone, + Icons.smoke_free, + Icons.smoking_rooms, + Icons.sms, + Icons.sms_failed, + Icons.snooze, + Icons.sort, + Icons.sort_by_alpha, + Icons.spa, + Icons.space_bar, + Icons.speaker, + Icons.speaker_group, + Icons.speaker_notes, + Icons.speaker_notes_off, + Icons.speaker_phone, + Icons.spellcheck, + Icons.star, + Icons.star_border, + Icons.star_half, + Icons.stars, + Icons.stay_current_landscape, + Icons.stay_current_portrait, + Icons.stay_primary_landscape, + Icons.stay_primary_portrait, + Icons.stop, + Icons.stop_screen_share, + Icons.storage, + Icons.store, + Icons.store_mall_directory, + Icons.straighten, + Icons.streetview, + Icons.strikethrough_s, + Icons.style, + Icons.subdirectory_arrow_left, + Icons.subdirectory_arrow_right, + Icons.subject, + Icons.subscriptions, + Icons.subtitles, + Icons.subway, + Icons.supervised_user_circle, + Icons.supervisor_account, + Icons.surround_sound, + Icons.swap_calls, + Icons.swap_horiz, + Icons.swap_horizontal_circle, + Icons.swap_vert, + Icons.swap_vertical_circle, + Icons.switch_camera, + Icons.switch_video, + Icons.sync, + Icons.sync_disabled, + Icons.sync_problem, + Icons.system_update, + Icons.system_update_alt, + Icons.tab, + Icons.tab_unselected, + Icons.table_chart, + Icons.tablet, + Icons.tablet_android, + Icons.tablet_mac, + Icons.tag_faces, + Icons.tap_and_play, + Icons.terrain, + Icons.text_fields, + Icons.text_format, + Icons.text_rotate_up, + Icons.text_rotate_vertical, + Icons.text_rotation_angledown, + Icons.text_rotation_angleup, + Icons.text_rotation_down, + Icons.text_rotation_none, + Icons.textsms, + Icons.texture, + Icons.theaters, + Icons.threed_rotation, + Icons.threesixty, + Icons.thumb_down, + Icons.thumb_up, + Icons.thumbs_up_down, + Icons.time_to_leave, + Icons.timelapse, + Icons.timeline, + Icons.timer, + Icons.timer_3, + Icons.timer_10, + Icons.timer_off, + Icons.title, + Icons.toc, + Icons.today, + Icons.toll, + Icons.tonality, + Icons.touch_app, + Icons.toys, + Icons.track_changes, + Icons.traffic, + Icons.train, + Icons.tram, + Icons.transfer_within_a_station, + Icons.transform, + Icons.transit_enterexit, + Icons.translate, + Icons.trending_down, + Icons.trending_flat, + Icons.trending_up, + Icons.trip_origin, + Icons.tune, + Icons.turned_in, + Icons.turned_in_not, + Icons.tv, + Icons.unarchive, + Icons.undo, + Icons.unfold_less, + Icons.unfold_more, + Icons.update, + Icons.usb, + Icons.verified_user, + Icons.vertical_align_bottom, + Icons.vertical_align_center, + Icons.vertical_align_top, + Icons.vibration, + Icons.video_call, + Icons.video_label, + Icons.video_library, + Icons.videocam, + Icons.videocam_off, + Icons.videogame_asset, + Icons.view_agenda, + Icons.view_array, + Icons.view_carousel, + Icons.view_column, + Icons.view_comfy, + Icons.view_compact, + Icons.view_day, + Icons.view_headline, + Icons.view_list, + Icons.view_module, + Icons.view_quilt, + Icons.view_stream, + Icons.view_week, + Icons.vignette, + Icons.visibility, + Icons.visibility_off, + Icons.voice_chat, + Icons.voicemail, + Icons.volume_down, + Icons.volume_mute, + Icons.volume_off, + Icons.volume_up, + Icons.vpn_key, + Icons.vpn_lock, + Icons.wallpaper, + Icons.warning, + Icons.watch, + Icons.watch_later, + Icons.wb_auto, + Icons.wb_cloudy, + Icons.wb_incandescent, + Icons.wb_iridescent, + Icons.wb_sunny, + Icons.wc, + Icons.web, + Icons.web_asset, + Icons.weekend, + Icons.whatshot, + Icons.widgets, + Icons.wifi, + Icons.wifi_lock, + Icons.wifi_tethering, + Icons.work, + Icons.wrap_text, + Icons.youtube_searched_for, + Icons.zoom_in, + Icons.zoom_out, + Icons.zoom_out_map + ]; } class CupertinoIIconNames { - static List names = [CupertinoIcons.add,CupertinoIcons.add_circled,CupertinoIcons.add_circled_solid,CupertinoIcons.back,CupertinoIcons.battery_25_percent,CupertinoIcons.battery_75_percent,CupertinoIcons.battery_charging,CupertinoIcons.battery_empty,CupertinoIcons.battery_full,CupertinoIcons.bluetooth,CupertinoIcons.book,CupertinoIcons.book_solid,CupertinoIcons.bookmark,CupertinoIcons.bookmark_solid,CupertinoIcons.check_mark,CupertinoIcons.check_mark_circled,CupertinoIcons.check_mark_circled_solid,CupertinoIcons.clear,CupertinoIcons.clear_circled,CupertinoIcons.clear_circled_solid,CupertinoIcons.clear_thick,CupertinoIcons.clear_thick_circled,CupertinoIcons.clock,CupertinoIcons.clock_solid,CupertinoIcons.collections,CupertinoIcons.collections_solid,CupertinoIcons.conversation_bubble,CupertinoIcons.create,CupertinoIcons.create_solid,CupertinoIcons.delete,CupertinoIcons.delete_simple,CupertinoIcons.delete_solid,CupertinoIcons.down_arrow,CupertinoIcons.ellipsis,CupertinoIcons.eye,CupertinoIcons.eye_solid,CupertinoIcons.flag,CupertinoIcons.folder,CupertinoIcons.folder_open,CupertinoIcons.folder_solid,CupertinoIcons.forward,CupertinoIcons.fullscreen,CupertinoIcons.fullscreen_exit,CupertinoIcons.gear,CupertinoIcons.gear_big,CupertinoIcons.gear_solid,CupertinoIcons.group,CupertinoIcons.group_solid,CupertinoIcons.home,CupertinoIcons.info,CupertinoIcons.left_chevron,CupertinoIcons.location,CupertinoIcons.location_solid,CupertinoIcons.loop,CupertinoIcons.loop_thick,CupertinoIcons.mail,CupertinoIcons.mail_solid,CupertinoIcons.mic,CupertinoIcons.mic_off,CupertinoIcons.mic_solid,CupertinoIcons.minus_circled,CupertinoIcons.music_note,CupertinoIcons.padlock,CupertinoIcons.padlock_solid,CupertinoIcons.pause,CupertinoIcons.pause_solid,CupertinoIcons.pen,CupertinoIcons.pencil,CupertinoIcons.person,CupertinoIcons.person_add,CupertinoIcons.person_add_solid,CupertinoIcons.person_solid,CupertinoIcons.phone,CupertinoIcons.phone_solid,CupertinoIcons.photo_camera,CupertinoIcons.photo_camera_solid,CupertinoIcons.play_arrow,CupertinoIcons.play_arrow_solid,CupertinoIcons.plus_circled,CupertinoIcons.profile_circled,CupertinoIcons.refresh,CupertinoIcons.refresh_bold,CupertinoIcons.refresh_circled,CupertinoIcons.refresh_circled_solid,CupertinoIcons.refresh_thick,CupertinoIcons.refresh_thin,CupertinoIcons.reply,CupertinoIcons.reply_all,CupertinoIcons.reply_thick_solid,CupertinoIcons.restart,CupertinoIcons.right_chevron,CupertinoIcons.search,CupertinoIcons.settings,CupertinoIcons.settings_solid,CupertinoIcons.share,CupertinoIcons.share_solid,CupertinoIcons.share_up,CupertinoIcons.shopping_cart,CupertinoIcons.shuffle_thick,CupertinoIcons.switch_camera,CupertinoIcons.switch_camera_solid,CupertinoIcons.tag,CupertinoIcons.tag_solid,CupertinoIcons.tags,CupertinoIcons.tags_solid,CupertinoIcons.time,CupertinoIcons.time_solid,CupertinoIcons.up_arrow,CupertinoIcons.video_camera,CupertinoIcons.video_camera_solid,CupertinoIcons.volume_down,CupertinoIcons.volume_mute,CupertinoIcons.volume_off,CupertinoIcons.volume_up]; -} \ No newline at end of file + static List names = [ + CupertinoIcons.add, + CupertinoIcons.add_circled, + CupertinoIcons.add_circled_solid, + CupertinoIcons.back, + CupertinoIcons.battery_25_percent, + CupertinoIcons.battery_75_percent, + CupertinoIcons.battery_charging, + CupertinoIcons.battery_empty, + CupertinoIcons.battery_full, + CupertinoIcons.bluetooth, + CupertinoIcons.book, + CupertinoIcons.book_solid, + CupertinoIcons.bookmark, + CupertinoIcons.bookmark_solid, + CupertinoIcons.check_mark, + CupertinoIcons.check_mark_circled, + CupertinoIcons.check_mark_circled_solid, + CupertinoIcons.clear, + CupertinoIcons.clear_circled, + CupertinoIcons.clear_circled_solid, + CupertinoIcons.clear_thick, + CupertinoIcons.clear_thick_circled, + CupertinoIcons.clock, + CupertinoIcons.clock_solid, + CupertinoIcons.collections, + CupertinoIcons.collections_solid, + CupertinoIcons.conversation_bubble, + CupertinoIcons.create, + CupertinoIcons.create_solid, + CupertinoIcons.delete, + CupertinoIcons.delete_simple, + CupertinoIcons.delete_solid, + CupertinoIcons.down_arrow, + CupertinoIcons.ellipsis, + CupertinoIcons.eye, + CupertinoIcons.eye_solid, + CupertinoIcons.flag, + CupertinoIcons.folder, + CupertinoIcons.folder_open, + CupertinoIcons.folder_solid, + CupertinoIcons.forward, + CupertinoIcons.fullscreen, + CupertinoIcons.fullscreen_exit, + CupertinoIcons.gear, + CupertinoIcons.gear_big, + CupertinoIcons.gear_solid, + CupertinoIcons.group, + CupertinoIcons.group_solid, + CupertinoIcons.home, + CupertinoIcons.info, + CupertinoIcons.left_chevron, + CupertinoIcons.location, + CupertinoIcons.location_solid, + CupertinoIcons.loop, + CupertinoIcons.loop_thick, + CupertinoIcons.mail, + CupertinoIcons.mail_solid, + CupertinoIcons.mic, + CupertinoIcons.mic_off, + CupertinoIcons.mic_solid, + CupertinoIcons.minus_circled, + CupertinoIcons.music_note, + CupertinoIcons.padlock, + CupertinoIcons.padlock_solid, + CupertinoIcons.pause, + CupertinoIcons.pause_solid, + CupertinoIcons.pen, + CupertinoIcons.pencil, + CupertinoIcons.person, + CupertinoIcons.person_add, + CupertinoIcons.person_add_solid, + CupertinoIcons.person_solid, + CupertinoIcons.phone, + CupertinoIcons.phone_solid, + CupertinoIcons.photo_camera, + CupertinoIcons.photo_camera_solid, + CupertinoIcons.play_arrow, + CupertinoIcons.play_arrow_solid, + CupertinoIcons.plus_circled, + CupertinoIcons.profile_circled, + CupertinoIcons.refresh, + CupertinoIcons.refresh_bold, + CupertinoIcons.refresh_circled, + CupertinoIcons.refresh_circled_solid, + CupertinoIcons.refresh_thick, + CupertinoIcons.refresh_thin, + CupertinoIcons.reply, + CupertinoIcons.reply_all, + CupertinoIcons.reply_thick_solid, + CupertinoIcons.restart, + CupertinoIcons.right_chevron, + CupertinoIcons.search, + CupertinoIcons.settings, + CupertinoIcons.settings_solid, + CupertinoIcons.share, + CupertinoIcons.share_solid, + CupertinoIcons.share_up, + CupertinoIcons.shopping_cart, + CupertinoIcons.shuffle_thick, + CupertinoIcons.switch_camera, + CupertinoIcons.switch_camera_solid, + CupertinoIcons.tag, + CupertinoIcons.tag_solid, + CupertinoIcons.tags, + CupertinoIcons.tags_solid, + CupertinoIcons.time, + CupertinoIcons.time_solid, + CupertinoIcons.up_arrow, + CupertinoIcons.video_camera, + CupertinoIcons.video_camera_solid, + CupertinoIcons.volume_down, + CupertinoIcons.volume_mute, + CupertinoIcons.volume_off, + CupertinoIcons.volume_up + ]; +} diff --git a/lib/resources/shared_preferences_keys.dart b/lib/resources/shared_preferences_keys.dart index ad7398ae..940485ea 100644 --- a/lib/resources/shared_preferences_keys.dart +++ b/lib/resources/shared_preferences_keys.dart @@ -1,4 +1,3 @@ - // Created with Android Studio. // User: 三帆 // Date: 31/01/2019 @@ -7,7 +6,6 @@ // target: xxx // - //enum DateType { // Int, // Double, @@ -27,12 +25,12 @@ class SharedPreferencesKeys { /// boolean /// 用于欢迎页面. 只有第一次访问才会显示. 或者手动将这个值设为false static String showWelcome = 'loginWelcone'; - /// json + + /// json /// 用于存放搜索页的搜索数据. /// [{ /// name: 'name' - /// + /// /// }] static String searchHistory = 'searchHistory'; } - diff --git a/lib/resources/widget_name_to_icon.dart b/lib/resources/widget_name_to_icon.dart index 82f2593f..5519b822 100644 --- a/lib/resources/widget_name_to_icon.dart +++ b/lib/resources/widget_name_to_icon.dart @@ -1,165 +1,166 @@ import 'package:flutter/material.dart'; + class WidgetName2Icon { - static Map icons = { + static Map icons = { "Developer": Icons.developer_mode, - "Standard": Icons.pages , - "Element":Icons.explicit, - "Components":Icons.extension, - "Theme":Icons.filter_b_and_w, - "Form":Icons.table_chart, - "Frame":Icons.aspect_ratio, - "Media":Icons.subscriptions, - "Input":Icons.input, - "TextField":Icons.text_fields, - "Checkbox":Icons.check_box, - "CheckboxListTile":Icons.playlist_add_check, - "Button":Icons.aspect_ratio, - "FlatButton":Icons.outlined_flag, - "RaisedButton":Icons.picture_in_picture_alt, - "IconButton":Icons.import_contacts, - "PopupMenuButton":Icons.power_input, - "FloatingActionButton":Icons.flash_off, - "RawMaterialButton":Icons.rowing, - "DropdownButton":Icons.drag_handle, - "OutlineButton":Icons.done_outline, - "Text":Icons.text_format, - "RichText":Icons.text_rotation_angleup, - "Radio":Icons.radio_button_checked, - "RadioListTile":Icons.list, - "Slider":Icons.slideshow, - "SliderTheme":Icons.theaters, - "SliderComponentShape":Icons.format_shapes, - "SliderThemeData":Icons.data_usage, - "Switch":Icons.switch_camera, - "SwitchListTile":Icons.switch_video, - "AnimatedSwitcher":Icons.airplanemode_active, - "Align":Icons.format_align_left, - "Stack":Icons.storage, - "IndexedStack":Icons.star, - "Layout":Icons.layers, - "Row":Icons.recent_actors, - "Column":Icons.cloud_off, - "Container":Icons.edit_location, - "Center":Icons.gesture, - "Box":Icons.hdr_strong, - "ConstrainedBox":Icons.account_box, - "OverflowBox":Icons.email, - "DecoratedBox":Icons.settings_overscan, - "FittedBox":Icons.data_usage, - "LimitedBox":Icons.format_align_justify, - "RenderBox":Icons.error, - "RotateBox":Icons.navigate_next, - "SizedOverflowBox":Icons.undo, - "TextBox":Icons.wallpaper, - "UnconstrainedBox":Icons.account_box, - "Axis":Icons.access_alarm, - "MainAxis":Icons.add_circle, - "CrossAxis":Icons.dehaze, - "FlipAxis":Icons.zoom_out, - "Expanded":Icons.all_out, - "Spacing":Icons.crop_free, - "Padding":Icons.crop, - "SliverPadding":Icons.euro_symbol, - "AnimatedPadding":Icons.zoom_out_map, - "Table":Icons.table_chart, - "Image":Icons.image, - "AssetImage":Icons.image_aspect_ratio, - "DecorationImage":Icons.picture_in_picture, - "DecorationImagePainter":Icons.image, - "ExactAssetImage":Icons.assessment, - "FadeInImage":Icons.flip, - "FileImage":Icons.filter, - "NetworkImage":Icons.network_wifi, - "RawImage":Icons.text_rotation_down, - "PaintImage":Icons.format_paint, - "PrecacheImage":Icons.perm_camera_mic, - "MemoryImage":Icons.memory, - "Icon":Icons.event_available, - "ImageIcon":Icons.image, - "IconTheme":Icons.table_chart, - "IconData":Icons.date_range, - "IconThemeData":Icons.insert_comment, - "Canvas":Icons.edit, - "PainterPath":Icons.gesture, - "CircleProgressBarPainter":Icons.av_timer, - "PainterSketch":Icons.touch_app, - "Material":Icons.android, - "MaterialApp":Icons.android, - "MaterialButton":Icons.speaker, - "MaterialGap":Icons.view_week, - "MaterialSlice":Icons.format_list_numbered_rtl , - "MaterialColor":Icons.color_lens, - "Cupertino":Icons.phone_iphone, - "Scroll":Icons.swap_vertical_circle, - "Tab":Icons.tab, - "Menu":Icons.menu, - "PopupMenuDivider":Icons.remove, - "PopupMenuEntry":Icons.menu, - "CheckedPopupMenuItem":Icons.playlist_add_check, - "DropdownMenuItem":Icons.playlist_play, - "Grid":Icons.grid_on, - "Scaffold":Icons.local_convenience_store, - "Dialog":Icons.add_alert, - "Bar":Icons.border_horizontal, - "Card":Icons.credit_card, - "Panel":Icons.video_label, - "Navigation":Icons.navigation, - "List":Icons.list, - "ScrollView":Icons.move_to_inbox, - "Scrollable":Icons.swap_vertical_circle, - "ScrollbarPainter":Icons.format_paint, - "ScrollMetrics":Icons.camera, - "ScrollPhysics":Icons.control_point_duplicate, - "BoxScrollView":Icons.inbox, - "Chip":Icons.sim_card, - "ChipTheme":Icons.sd_card, - "CustomScrollView":Icons.autorenew, - "NestedScrollView":Icons.panorama_fish_eye, - "ChipThemeData":Icons.sim_card_alert, - "ChoiceChip":Icons.insert_drive_file, - "FilterChip":Icons.note_add, - "InputChip":Icons.restore_page, - "RawChip":Icons.save, - "LinearProgressIndicator":Icons.trending_flat , - "CircularProgressIndicator":Icons.rotate_left , - "ExpansionPanel":Icons.view_stream, - "ExpansionPanelList":Icons.view_headline, - "BottomNavigationBar":Icons.call_to_action, - "ListView":Icons.view_list , - "ListBody":Icons.list , - "AnimatedList":Icons.format_line_spacing , - "SliverAppBar":Icons.content_paste, - "AppBar":Icons.card_membership, - "BottomAppBar":Icons.call_to_action, - "BottomNavigationBarItem":Icons.crop_original, - "FlexibleSpaceBar":Icons.aspect_ratio, - "ButtonBar":Icons.branding_watermark, - "SnackBar":Icons.sms_failed, - "Progress":Icons.sync, - "Pick":Icons.event_note, - "DayPicker":Icons.calendar_today, - "MonthPicker":Icons.date_range, - "YearPicker":Icons.event_busy, - "ShowdatePicker":Icons.event, - "MaterialPageRoute":Icons.album, - "MaterialAccentColor":Icons.brush, - "SnackBarAction":Icons.assessment, - "TabBar":Icons.burst_mode, - "AlertDialog":Icons.sms_failed, - "AboutDialog":Icons.sms, - "SimpleDialog":Icons.message, - "ScaffoldState":Icons.local_bar, - "GridTile":Icons.apps, - "MergeableMaterialItem":Icons.view_list, - "CupertinoApp":Icons.face, - "CupertinoButton":Icons.crop_7_5, - "CupertinoColors":Icons.color_lens, - "CupertinoIcons":Icons.insert_emoticon, - "CupertinoNavigationBar":Icons.payment, - "CupertinoPageRoute":Icons.router, - "CupertinoPageScaffold":Icons.pages, - "CupertinoPicker":Icons.add_alarm, - "CupertinoPopupSurface":Icons.center_focus_weak, + "Standard": Icons.pages, + "Element": Icons.explicit, + "Components": Icons.extension, + "Theme": Icons.filter_b_and_w, + "Form": Icons.table_chart, + "Frame": Icons.aspect_ratio, + "Media": Icons.subscriptions, + "Input": Icons.input, + "TextField": Icons.text_fields, + "Checkbox": Icons.check_box, + "CheckboxListTile": Icons.playlist_add_check, + "Button": Icons.aspect_ratio, + "FlatButton": Icons.outlined_flag, + "RaisedButton": Icons.picture_in_picture_alt, + "IconButton": Icons.import_contacts, + "PopupMenuButton": Icons.power_input, + "FloatingActionButton": Icons.flash_off, + "RawMaterialButton": Icons.rowing, + "DropdownButton": Icons.drag_handle, + "OutlineButton": Icons.done_outline, + "Text": Icons.text_format, + "RichText": Icons.text_rotation_angleup, + "Radio": Icons.radio_button_checked, + "RadioListTile": Icons.list, + "Slider": Icons.slideshow, + "SliderTheme": Icons.theaters, + "SliderComponentShape": Icons.format_shapes, + "SliderThemeData": Icons.data_usage, + "Switch": Icons.switch_camera, + "SwitchListTile": Icons.switch_video, + "AnimatedSwitcher": Icons.airplanemode_active, + "Align": Icons.format_align_left, + "Stack": Icons.storage, + "IndexedStack": Icons.star, + "Layout": Icons.layers, + "Row": Icons.recent_actors, + "Column": Icons.cloud_off, + "Container": Icons.edit_location, + "Center": Icons.gesture, + "Box": Icons.hdr_strong, + "ConstrainedBox": Icons.account_box, + "OverflowBox": Icons.email, + "DecoratedBox": Icons.settings_overscan, + "FittedBox": Icons.data_usage, + "LimitedBox": Icons.format_align_justify, + "RenderBox": Icons.error, + "RotateBox": Icons.navigate_next, + "SizedOverflowBox": Icons.undo, + "TextBox": Icons.wallpaper, + "UnconstrainedBox": Icons.account_box, + "Axis": Icons.access_alarm, + "MainAxis": Icons.add_circle, + "CrossAxis": Icons.dehaze, + "FlipAxis": Icons.zoom_out, + "Expanded": Icons.all_out, + "Spacing": Icons.crop_free, + "Padding": Icons.crop, + "SliverPadding": Icons.euro_symbol, + "AnimatedPadding": Icons.zoom_out_map, + "Table": Icons.table_chart, + "Image": Icons.image, + "AssetImage": Icons.image_aspect_ratio, + "DecorationImage": Icons.picture_in_picture, + "DecorationImagePainter": Icons.image, + "ExactAssetImage": Icons.assessment, + "FadeInImage": Icons.flip, + "FileImage": Icons.filter, + "NetworkImage": Icons.network_wifi, + "RawImage": Icons.text_rotation_down, + "PaintImage": Icons.format_paint, + "PrecacheImage": Icons.perm_camera_mic, + "MemoryImage": Icons.memory, + "Icon": Icons.event_available, + "ImageIcon": Icons.image, + "IconTheme": Icons.table_chart, + "IconData": Icons.date_range, + "IconThemeData": Icons.insert_comment, + "Canvas": Icons.edit, + "PainterPath": Icons.gesture, + "CircleProgressBarPainter": Icons.av_timer, + "PainterSketch": Icons.touch_app, + "Material": Icons.android, + "MaterialApp": Icons.android, + "MaterialButton": Icons.speaker, + "MaterialGap": Icons.view_week, + "MaterialSlice": Icons.format_list_numbered_rtl, + "MaterialColor": Icons.color_lens, + "Cupertino": Icons.phone_iphone, + "Scroll": Icons.swap_vertical_circle, + "Tab": Icons.tab, + "Menu": Icons.menu, + "PopupMenuDivider": Icons.remove, + "PopupMenuEntry": Icons.menu, + "CheckedPopupMenuItem": Icons.playlist_add_check, + "DropdownMenuItem": Icons.playlist_play, + "Grid": Icons.grid_on, + "Scaffold": Icons.local_convenience_store, + "Dialog": Icons.add_alert, + "Bar": Icons.border_horizontal, + "Card": Icons.credit_card, + "Panel": Icons.video_label, + "Navigation": Icons.navigation, + "List": Icons.list, + "ScrollView": Icons.move_to_inbox, + "Scrollable": Icons.swap_vertical_circle, + "ScrollbarPainter": Icons.format_paint, + "ScrollMetrics": Icons.camera, + "ScrollPhysics": Icons.control_point_duplicate, + "BoxScrollView": Icons.inbox, + "Chip": Icons.sim_card, + "ChipTheme": Icons.sd_card, + "CustomScrollView": Icons.autorenew, + "NestedScrollView": Icons.panorama_fish_eye, + "ChipThemeData": Icons.sim_card_alert, + "ChoiceChip": Icons.insert_drive_file, + "FilterChip": Icons.note_add, + "InputChip": Icons.restore_page, + "RawChip": Icons.save, + "LinearProgressIndicator": Icons.trending_flat, + "CircularProgressIndicator": Icons.rotate_left, + "ExpansionPanel": Icons.view_stream, + "ExpansionPanelList": Icons.view_headline, + "BottomNavigationBar": Icons.call_to_action, + "ListView": Icons.view_list, + "ListBody": Icons.list, + "AnimatedList": Icons.format_line_spacing, + "SliverAppBar": Icons.content_paste, + "AppBar": Icons.card_membership, + "BottomAppBar": Icons.call_to_action, + "BottomNavigationBarItem": Icons.crop_original, + "FlexibleSpaceBar": Icons.aspect_ratio, + "ButtonBar": Icons.branding_watermark, + "SnackBar": Icons.sms_failed, + "Progress": Icons.sync, + "Pick": Icons.event_note, + "DayPicker": Icons.calendar_today, + "MonthPicker": Icons.date_range, + "YearPicker": Icons.event_busy, + "ShowdatePicker": Icons.event, + "MaterialPageRoute": Icons.album, + "MaterialAccentColor": Icons.brush, + "SnackBarAction": Icons.assessment, + "TabBar": Icons.burst_mode, + "AlertDialog": Icons.sms_failed, + "AboutDialog": Icons.sms, + "SimpleDialog": Icons.message, + "ScaffoldState": Icons.local_bar, + "GridTile": Icons.apps, + "MergeableMaterialItem": Icons.view_list, + "CupertinoApp": Icons.face, + "CupertinoButton": Icons.crop_7_5, + "CupertinoColors": Icons.color_lens, + "CupertinoIcons": Icons.insert_emoticon, + "CupertinoNavigationBar": Icons.payment, + "CupertinoPageRoute": Icons.router, + "CupertinoPageScaffold": Icons.pages, + "CupertinoPicker": Icons.add_alarm, + "CupertinoPopupSurface": Icons.center_focus_weak, "CupertinoScrollbar": Icons.fullscreen, "CupertinoSlider": Icons.switch_camera, "CupertinoSegmentedControl": Icons.business_center, diff --git a/lib/routers/application.dart b/lib/routers/application.dart index 0724ad89..08144b61 100644 --- a/lib/routers/application.dart +++ b/lib/routers/application.dart @@ -3,10 +3,12 @@ import 'package:fluro/fluro.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; import '../model/widget.dart'; + enum ENV { PRODUCTION, DEV, } + class Application { /// 通过Application设计环境变量 static ENV env = ENV.DEV; @@ -18,20 +20,20 @@ class Application { static bool pageIsOpen = false; static Map github = { - 'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/', + 'widgetsURL': + 'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/', //'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/', //'master':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/master/lib/widgets/' }; /// 所有获取配置的唯一入口 Map get config { - if (Application.env == ENV.PRODUCTION) { - return {}; - } - if (Application.env == ENV.DEV) { - return {}; - } + if (Application.env == ENV.PRODUCTION) { return {}; + } + if (Application.env == ENV.DEV) { + return {}; + } + return {}; } - } diff --git a/lib/routers/router_handler.dart b/lib/routers/router_handler.dart index 2e718d40..41a06ae9 100644 --- a/lib/routers/router_handler.dart +++ b/lib/routers/router_handler.dart @@ -21,18 +21,16 @@ var homeHandler = new Handler( ); var collectionFullHandler = new Handler( - handlerFunc: (BuildContext context,Map> params){ - bool hasLogined = params['hasLogin']?.first == 'true'; - return CollectionFullPage(hasLogined: hasLogined); - } -); + handlerFunc: (BuildContext context, Map> params) { + bool hasLogined = params['hasLogin']?.first == 'true'; + return CollectionFullPage(hasLogined: hasLogined); +}); var collectionHandler = new Handler( - handlerFunc: (BuildContext context,Map> params){ - bool hasLogined = params['hasLogin']?.first == 'true'; - return CollectionPage(hasLogined: hasLogined); - } -); + handlerFunc: (BuildContext context, Map> params) { + bool hasLogined = params['hasLogin']?.first == 'true'; + return CollectionPage(hasLogined: hasLogined); +}); var categoryHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { @@ -44,29 +42,28 @@ var categoryHandler = new Handler( var widgetNotFoundHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return new WidgetNotFound(); - }); + return new WidgetNotFound(); +}); var loginPageHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return LoginPage(); - }); + return LoginPage(); +}); var fullScreenCodeDialog = new Handler( handlerFunc: (BuildContext context, Map> params) { - String path = params['filePath']?.first; - return new FullScreenCodeDialog( - filePath: path, - ); - }); - + String path = params['filePath']?.first; + return new FullScreenCodeDialog( + filePath: path, + ); +}); var githubCodeDialog = new Handler( handlerFunc: (BuildContext context, Map> params) { - String path = params['remotePath']?.first; - return new FullScreenCodeDialog( - remoteFilePath: path, - ); - }); + String path = params['remotePath']?.first; + return new FullScreenCodeDialog( + remoteFilePath: path, + ); +}); var webViewPageHand = new Handler( handlerFunc: (BuildContext context, Map> params) { @@ -75,16 +72,13 @@ var webViewPageHand = new Handler( return new WebViewPage(url, title); }); - var standardPageHandler = new Handler( - handlerFunc: (BuildContext context, Map> params) { - String id = params['id']?.first; - return StandardView(id: id); - } -); - + handlerFunc: (BuildContext context, Map> params) { + String id = params['id']?.first; + return StandardView(id: id); +}); var issuesMessageHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return IssuesMessagePage(); - }); + return IssuesMessagePage(); +}); diff --git a/lib/routers/routers.dart b/lib/routers/routers.dart index 32d6b9c2..72169e46 100644 --- a/lib/routers/routers.dart +++ b/lib/routers/routers.dart @@ -1,9 +1,9 @@ - import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter_go/utils/analytics.dart' show analytics; import '../widgets/index.dart'; import './router_handler.dart'; + /// import '../standard_pages/index.dart'; class Routes { static String root = "/"; @@ -13,7 +13,7 @@ class Routes { static String githubCodeView = '/github-code-view'; static String webViewPage = '/web-view-page'; static String loginPage = '/loginpage'; - static String issuesMessage='/issuesMessage'; + static String issuesMessage = '/issuesMessage'; static String collectionPage = '/collection-page'; static String collectionFullPage = '/collection-full-page'; static String standardPage = '/standard-page/:id'; @@ -25,24 +25,24 @@ class Routes { // } // ); router.define(home, handler: homeHandler); - router.define(collectionPage,handler:collectionHandler); - router.define(collectionFullPage,handler:collectionFullHandler); + router.define(collectionPage, handler: collectionHandler); + router.define(collectionFullPage, handler: collectionFullHandler); router.define('/category/:ids', handler: categoryHandler); router.define('/category/error/404', handler: widgetNotFoundHandler); router.define(loginPage, handler: loginPageHandler); - router.define(codeView,handler:fullScreenCodeDialog); - router.define(githubCodeView,handler:githubCodeDialog); - router.define(webViewPage,handler:webViewPageHand); + router.define(codeView, handler: fullScreenCodeDialog); + router.define(githubCodeView, handler: githubCodeDialog); + router.define(webViewPage, handler: webViewPageHand); router.define(issuesMessage, handler: issuesMessageHandler); - router.define(standardPage,handler:standardPageHandler); + router.define(standardPage, handler: standardPageHandler); widgetDemosList.forEach((demo) { - Handler handler = new Handler( - handlerFunc: (BuildContext context, Map> params) { - print('组件路由params=$params widgetsItem=${demo.routerName}'); - analytics.logEvent( - name: 'component', parameters: {'name': demo.routerName }); - return demo.buildRouter(context); - }); + Handler handler = new Handler(handlerFunc: + (BuildContext context, Map> params) { + print('组件路由params=$params widgetsItem=${demo.routerName}'); + analytics + .logEvent(name: 'component', parameters: {'name': demo.routerName}); + return demo.buildRouter(context); + }); String path = demo.routerName; router.define('${path.toLowerCase()}', handler: handler); }); diff --git a/lib/standard_pages/.pages.json b/lib/standard_pages/.pages.json index 9b3a3ca9..fa8e84db 100644 --- a/lib/standard_pages/.pages.json +++ b/lib/standard_pages/.pages.json @@ -1 +1 @@ -[{"name":"local","screenShot":"","author":"hnaxu","title":"本地","email":"hanxu@qq.com","desc":"desc","id":"5d7178d0_42ae_4241_9c8a_5c9e1f92b096"},{"name":"test","screenShot":"","author":"abc","title":"ya","email":"adsf.com","desc":"desc","id":"84f38e00_42ae_4241_9c8a_5c9e1f92b096"},{"name":"standard","screenShot":"","author":"sanfan","title":"介绍页","email":"hanxu317@qq.com","desc":"desc","id":"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"standard_for_slider","screenShot":"","author":"sanfan","title":"slider组件","email":"hanxu@qq.com","desc":"slider, new Slider","id":"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096"}] \ No newline at end of file +[{"name":"PullToRefresh","screenShot":"","author":"chenfeihu","title":"PullToRefresh","email":"763551832@qq.com","desc":"Refresh conponent","id":"cd9b8b80_52ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"hnaxu","title":"本地","email":"hanxu@qq.com","desc":"desc","id":"5d7178d0_42ae_4241_9c8a_5c9e1f92b096"},{"name":"test","screenShot":"","author":"abc","title":"ya","email":"adsf.com","desc":"desc","id":"84f38e00_42ae_4241_9c8a_5c9e1f92b096"},{"name":"standard","screenShot":"","author":"sanfan","title":"介绍页","email":"hanxu317@qq.com","desc":"desc","id":"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"standard_for_slider","screenShot":"","author":"sanfan","title":"slider组件","email":"hanxu@qq.com","desc":"slider, new Slider","id":"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096"},{"name":"RangeSlider","screenShot":"","author":"hanxu","title":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget","id":"cbffbf7c_52ae_4241_9c8a_5c9e1f92b096"}] \ No newline at end of file diff --git a/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/.page.json b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/.page.json new file mode 100644 index 00000000..b007469b --- /dev/null +++ b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/.page.json @@ -0,0 +1,10 @@ +{ + "name": "PullToRefresh", + "screenShot": "", + "author":"chenfeihu", + "title":"PullToRefresh", + "email": "763551832@qq.com", + "desc": "Refresh conponent", + "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096" +} + \ No newline at end of file diff --git a/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart new file mode 100644 index 00000000..19aadf0b --- /dev/null +++ b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -0,0 +1,86 @@ +String getMd() { + return """ +# PullToRefresh + +> 下拉刷新 上拉加载 + +PullToRefresh 是一个刷新列表组件,借助于pull_to_refresh库实现,感觉这是目前最好的一款三方刷新库,它的可定制性比较好,刷新样式多样化,已经满足大部分的开发需求。 + +### **基本用法** + +* 添加依赖 pull_to_refresh: ^1.5.6 +* ListView包裹一层SmartRefresher + + + +### **SmartRefresher常用属性说明** + +* **enablePullDown** 允许下拉刷新 +* **enablePullUp** 允许上拉加载 +* **header** 下拉刷新头部样式 +* **footer** 上拉加载底部样式 +* **onRefresh** 下拉刷新的回调 +* **onLoading** 上拉加载的回调 +* **controller** 刷新控件的控制器,用来处理回调状态等 + + +### **国际化显示** + + ``` + 需要添加语言本地化SDK,不然刷新库头部与底部显示加载提示内容为英文 + + 添加依赖 flutter_localizations: + sdk: flutter + + main.dart中MateriaApp里面添加以下内容 + + localizationsDelegates: [ + // 这行是关键 + RefreshLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalMaterialLocalizations.delegate + ], + supportedLocales: [ + const Locale('en'), + const Locale('zh'), + ], + localeResolutionCallback: + (Locale locale, Iterable supportedLocales) { + //print("change language"); + return locale; + }, + + ``` + + +### **全局配置** + 全局配置RefreshConfiguration,配置子树下的所有SmartRefresher表现,一般存放于MaterialApp的根部 + + ``` + RefreshConfiguration( + headerBuilder: () => WaterDropHeader(), // 配置默认头部指示器,假如你每个页面的头部指示器都一样的话,你需要设置这个 + footerBuilder: () => ClassicFooter(), // 配置默认底部指示器 + headerTriggerDistance: 80.0, // 头部触发刷新的越界距离 + springDescription:SpringDescription(stiffness: 170, damping: 16, mass: 1.9), // 自定义回弹动画,三个属性值意义请查询flutter api + maxOverScrollExtent :100, //头部最大可以拖动的范围,如果发生冲出视图范围区域,请设置这个属性 + maxUnderScrollExtent:0, // 底部最大可以拖动的范围 + enableScrollWhenRefreshCompleted: true, //这个属性不兼容PageView和TabBarView,如果你特别需要TabBarView左右滑动,你需要把它设置为true + enableLoadingWhenFailed : true, //在加载失败的状态下,用户仍然可以通过手势上拉来触发加载更多 + hideFooterWhenNotFull: false, // Viewport不满一屏时,禁用上拉加载更多功能 + enableBallisticLoad: true, // 可以通过惯性滑动触发加载更多 + child: MaterialApp( + ........ + ) + ); + + ``` + + +### 实例展示 + +[demo:5553db80_52ae_4241_9c8a_5c9e1f92b096] + + + +"""; +} diff --git a/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.md b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.md new file mode 100644 index 00000000..1dca085b --- /dev/null +++ b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.md @@ -0,0 +1,82 @@ +# PullToRefresh + +> 下拉刷新 上拉加载 + +PullToRefresh 是一个刷新列表组件,借助于pull_to_refresh库实现,感觉这是目前最好的一款三方刷新库,它的可定制性比较好,刷新样式多样化,已经满足大部分的开发需求。 + +### **基本用法** + +* 添加依赖 pull_to_refresh: ^1.5.6 +* ListView包裹一层SmartRefresher + + + +### **SmartRefresher常用属性说明** + +* **enablePullDown** 允许下拉刷新 +* **enablePullUp** 允许上拉加载 +* **header** 下拉刷新头部样式 +* **footer** 上拉加载底部样式 +* **onRefresh** 下拉刷新的回调 +* **onLoading** 上拉加载的回调 +* **controller** 刷新控件的控制器,用来处理回调状态等 + + +### **国际化显示** + + ``` + 需要添加语言本地化SDK,不然刷新库头部与底部显示加载提示内容为英文 + + 添加依赖 flutter_localizations: + sdk: flutter + + main.dart中MateriaApp里面添加以下内容 + + localizationsDelegates: [ + // 这行是关键 + RefreshLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalMaterialLocalizations.delegate + ], + supportedLocales: [ + const Locale('en'), + const Locale('zh'), + ], + localeResolutionCallback: + (Locale locale, Iterable supportedLocales) { + //print("change language"); + return locale; + }, + + ``` + + +### **全局配置** + 全局配置RefreshConfiguration,配置子树下的所有SmartRefresher表现,一般存放于MaterialApp的根部 + + ``` + RefreshConfiguration( + headerBuilder: () => WaterDropHeader(), // 配置默认头部指示器,假如你每个页面的头部指示器都一样的话,你需要设置这个 + footerBuilder: () => ClassicFooter(), // 配置默认底部指示器 + headerTriggerDistance: 80.0, // 头部触发刷新的越界距离 + springDescription:SpringDescription(stiffness: 170, damping: 16, mass: 1.9), // 自定义回弹动画,三个属性值意义请查询flutter api + maxOverScrollExtent :100, //头部最大可以拖动的范围,如果发生冲出视图范围区域,请设置这个属性 + maxUnderScrollExtent:0, // 底部最大可以拖动的范围 + enableScrollWhenRefreshCompleted: true, //这个属性不兼容PageView和TabBarView,如果你特别需要TabBarView左右滑动,你需要把它设置为true + enableLoadingWhenFailed : true, //在加载失败的状态下,用户仍然可以通过手势上拉来触发加载更多 + hideFooterWhenNotFull: false, // Viewport不满一屏时,禁用上拉加载更多功能 + enableBallisticLoad: true, // 可以通过惯性滑动触发加载更多 + child: MaterialApp( + ........ + ) + ); + + ``` + + +### 实例展示 + +[demo:5553db80_52ae_4241_9c8a_5c9e1f92b096] + + + \ No newline at end of file diff --git a/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/.page.json b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/.page.json new file mode 100644 index 00000000..553fa67b --- /dev/null +++ b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/.page.json @@ -0,0 +1,10 @@ +{ + "name": "RangeSlider", + "screenShot": "", + "author":"hanxu", + "title":"RangeSlider", + "email": "hanxu317@qq.com", + "desc": "RangeSlider widget", + "id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096" +} + \ No newline at end of file diff --git a/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart new file mode 100644 index 00000000..955ef81f --- /dev/null +++ b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -0,0 +1,33 @@ +String getMd() { + return """ + # RangeSlider + +> 用来选择范围性的数据 + +slider 用来选择连续性的或者非连续性的数据. 默认是在一段最大值最小值间做任意值的选择. 如果你想选择间隔性的值, 例如0.0到50.0间,选择10, 15,...50.0这样的值, 给divisions设定一个非空的整数5,, 去分割区间范围. + + +### **基本用法** + +关于slider有以下的术语: + +* **thumb** 滑块 用户可以水平拖拽移动的区域 + +* **track** 滑轨 thumb 可以滑动的线条区域 + +* **value indicator** 值指示器 当用户拖拽thumb的时候. 显示用户当前所选的属性值 + +* **active** 选中区 + +* **inactive** 非选中区 + +如果**onChanged**属性为空或者**min** .. **max**给出的范围 为空(例如如果min等于max),则将禁用滑块。 + +滑块小部件本身不保持任何状态State。相反,当滑块状态发生变化时,窗口小部件会调用 **onChanged** 回调。大多数使用滑块的小部件将侦听 **onChanged** 回调并使用新值重建滑块以更新滑块的视觉外观。要知道值何时开始更改,或何时更改,请设置可选回调**onChangeStart**或**onChangeEnd**。 + +默认情况下,滑块将尽可能宽,垂直居中。当给定无限制约束时,它将尝试使轨道宽144像素(每边有边距)并垂直收缩。 + +### 实例展示 + +[demo:e5f958bc_52ae_4241_9c8a_5c9e1f92b096]"""; +} diff --git a/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.md b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.md new file mode 100644 index 00000000..d6049358 --- /dev/null +++ b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.md @@ -0,0 +1,30 @@ +# RangeSlider + +> 用来选择范围性的数据 + +slider 用来选择连续性的或者非连续性的数据. 默认是在一段最大值最小值间做任意值的选择. 如果你想选择间隔性的值, 例如0.0到50.0间,选择10, 15,...50.0这样的值, 给divisions设定一个非空的整数5,, 去分割区间范围. + + +### **基本用法** + +关于slider有以下的术语: + +* **thumb** 滑块 用户可以水平拖拽移动的区域 + +* **track** 滑轨 thumb 可以滑动的线条区域 + +* **value indicator** 值指示器 当用户拖拽thumb的时候. 显示用户当前所选的属性值 + +* **active** 选中区 + +* **inactive** 非选中区 + +如果**onChanged**属性为空或者**min** .. **max**给出的范围 为空(例如如果min等于max),则将禁用滑块。 + +滑块小部件本身不保持任何状态State。相反,当滑块状态发生变化时,窗口小部件会调用 **onChanged** 回调。大多数使用滑块的小部件将侦听 **onChanged** 回调并使用新值重建滑块以更新滑块的视觉外观。要知道值何时开始更改,或何时更改,请设置可选回调**onChangeStart**或**onChangeEnd**。 + +默认情况下,滑块将尽可能宽,垂直居中。当给定无限制约束时,它将尝试使轨道宽144像素(每边有边距)并垂直收缩。 + +### 实例展示 + +[demo:e5f958bc_52ae_4241_9c8a_5c9e1f92b096] \ No newline at end of file diff --git a/lib/standard_pages/index.dart b/lib/standard_pages/index.dart index 6af27c34..12cba175 100644 --- a/lib/standard_pages/index.dart +++ b/lib/standard_pages/index.dart @@ -1,35 +1,77 @@ +import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096; +import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096; +import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096; +import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096; +import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096; +import 'RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096; -import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096; -import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096; -import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096; -import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096; class StandardPages { Map standardPages; Map getPages() { return { - "0": "0" , - "5d7178d0_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd() -, - "84f38e00_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd() -, - "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd() -, - "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096.getMd() + "0": "0", + "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096": + StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096 + .getMd(), + "5d7178d0_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd(), + "84f38e00_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd(), + "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096": + StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd(), + "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096 + .getMd(), + "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096": + StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096.getMd() }; } + List> getLocalList() { return [ {}, - { "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", "name": "local", "email": "hanxu@qq.com", "author": "hnaxu"} -, - { "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", "name": "test", "email": "adsf.com", "author": "abc"} -, - { "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", "name": "standard", "email": "hanxu317@qq.com", "author": "sanfan"} -, - { "id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096", "name": "standard_for_slider", "email": "hanxu@qq.com", "author": "sanfan"} + { + "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096", + "name": "PullToRefresh", + "email": "763551832@qq.com", + "author": "chenfeihu" + }, + { + "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", + "name": "local", + "email": "hanxu@qq.com", + "author": "hnaxu" + }, + { + "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", + "name": "test", + "email": "adsf.com", + "author": "abc" + }, + { + "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", + "name": "standard", + "email": "hanxu317@qq.com", + "author": "sanfan" + }, + { + "id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096", + "name": "standard_for_slider", + "email": "hanxu@qq.com", + "author": "sanfan" + }, + { + "id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096", + "name": "RangeSlider", + "email": "hanxu317@qq.com", + "author": "hanxu" + } ]; } - } - - \ No newline at end of file diff --git a/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart index 6e506d10..8ff3798f 100644 --- a/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -48,5 +48,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - } diff --git a/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart index bd222ee8..46d46bd3 100644 --- a/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -55,7 +55,4 @@ goCLi createDemo 调用效果: [demo:1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]"""; - - } - \ No newline at end of file diff --git a/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart index be0e2607..58a2066f 100644 --- a/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart @@ -50,7 +50,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - - } - \ No newline at end of file diff --git a/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart index 6e506d10..8ff3798f 100644 --- a/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -48,5 +48,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - } diff --git a/lib/utils/data_utils.dart b/lib/utils/data_utils.dart index 921f95ff..f609d73e 100644 --- a/lib/utils/data_utils.dart +++ b/lib/utils/data_utils.dart @@ -5,6 +5,7 @@ import 'package:flutter_go/model/collection.dart'; import 'package:flutter_go/model/version.dart'; import 'package:flutter_go/model/widget.dart'; import 'package:package_info/package_info.dart'; + /// import 'package:flutter_go/model/responseData.dart'; import './net_utils.dart'; @@ -190,7 +191,9 @@ class DataUtils { "name": json['name'], "cnName": json['name'], "routerName": routerName, - "catId": json['parentId'].runtimeType == String ? int.parse(json['parentId']) : json['parentId'] + "catId": json['parentId'].runtimeType == String + ? int.parse(json['parentId']) + : json['parentId'] }; list.add(WidgetPoint.fromJSON(tempMap)); } diff --git a/lib/utils/example_code_parser.dart b/lib/utils/example_code_parser.dart index 7b09b532..eab2a0c9 100644 --- a/lib/utils/example_code_parser.dart +++ b/lib/utils/example_code_parser.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:36 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 16:53:11 @@ -11,7 +11,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/routers/application.dart'; - Map _exampleCode; String _code; @@ -23,12 +22,14 @@ void _launchURL(String url) async { } } -Future getExampleCode(context,String filePath, AssetBundle bundle) async { - if (_exampleCode == null) await _parseExampleCode(context,filePath, bundle); +Future getExampleCode( + context, String filePath, AssetBundle bundle) async { + if (_exampleCode == null) await _parseExampleCode(context, filePath, bundle); return _code; } -Future _parseExampleCode(context,String filePath, AssetBundle bundle) async { +Future _parseExampleCode( + context, String filePath, AssetBundle bundle) async { String code; try { code = await bundle.loadString('lib/widgets/$filePath'); diff --git a/lib/utils/high_light_code.dart b/lib/utils/high_light_code.dart index 1ac0fdcd..5e1a7f3b 100644 --- a/lib/utils/high_light_code.dart +++ b/lib/utils/high_light_code.dart @@ -9,16 +9,15 @@ import 'package:string_scanner/string_scanner.dart'; /// DartSyntaxHighlighter(style).format(source) class SyntaxHighlighterStyle { - SyntaxHighlighterStyle({ - this.baseStyle, - this.numberStyle, - this.commentStyle, - this.keywordStyle, - this.stringStyle, - this.punctuationStyle, - this.classStyle, - this.constantStyle - }); + SyntaxHighlighterStyle( + {this.baseStyle, + this.numberStyle, + this.commentStyle, + this.keywordStyle, + this.stringStyle, + this.punctuationStyle, + this.classStyle, + this.constantStyle}); static SyntaxHighlighterStyle lightThemeStyle() { return SyntaxHighlighterStyle( @@ -29,8 +28,7 @@ class SyntaxHighlighterStyle { stringStyle: const TextStyle(color: Color(0xFF43A047)), punctuationStyle: const TextStyle(color: Color(0xFF000000)), classStyle: const TextStyle(color: Color(0xFF512DA8)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + constantStyle: const TextStyle(color: Color(0xFF795548))); } static SyntaxHighlighterStyle darkThemeStyle() { @@ -42,8 +40,7 @@ class SyntaxHighlighterStyle { stringStyle: const TextStyle(color: Color(0xFF009688)), punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), classStyle: const TextStyle(color: Color(0xFF009688)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + constantStyle: const TextStyle(color: Color(0xFF795548))); } final TextStyle baseStyle; @@ -56,7 +53,8 @@ class SyntaxHighlighterStyle { final TextStyle constantStyle; } -abstract class Highlighter { // ignore: one_member_abstracts +abstract class Highlighter { + // ignore: one_member_abstracts TextSpan format(String src); } @@ -69,17 +67,66 @@ class DartSyntaxHighlighter extends Highlighter { SyntaxHighlighterStyle _style; static const List _keywords = [ - 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', - 'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else', - 'enum', 'export', 'external', 'extends', 'factory', 'false', 'final', - 'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library', - 'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static', - 'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var', - 'void', 'while', 'with', 'yield' + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'external', + 'extends', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'get', + 'if', + 'implements', + 'import', + 'in', + 'is', + 'library', + 'new', + 'null', + 'operator', + 'part', + 'rethrow', + 'return', + 'set', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield' ]; static const List _builtInTypes = [ - 'int', 'double', 'num', 'bool' + 'int', + 'double', + 'num', + 'bool' ]; String _src; @@ -99,15 +146,18 @@ class DartSyntaxHighlighter extends Highlighter { for (_HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); + formattedText.add(TextSpan( + style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) - formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, _src.length))); return TextSpan(style: _style.baseStyle, children: formattedText); } else { @@ -125,11 +175,8 @@ class DartSyntaxHighlighter extends Highlighter { // Block comments if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(_HighlightSpan( - _HighlightType.comment, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.comment, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -146,115 +193,81 @@ class DartSyntaxHighlighter extends Highlighter { endComment = _src.length; } - _spans.add(_HighlightSpan( - _HighlightType.comment, - startComment, - endComment - )); + _spans.add( + _HighlightSpan(_HighlightType.comment, startComment, endComment)); - if (eof) - break; + if (eof) break; continue; } // Raw r"String" if (_scanner.scan(RegExp(r'r".*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Raw r'String' if (_scanner.scan(RegExp(r"r'.*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline """String""" if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline '''String''' if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // "String" if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // 'String' if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Double if (_scanner.scan(RegExp(r'\d+\.\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Integer if (_scanner.scan(RegExp(r'\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end) - ); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Punctuation if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _spans.add(_HighlightSpan( - _HighlightType.punctuation, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.punctuation, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Meta data if (_scanner.scan(RegExp(r'@\w+'))) { - _spans.add(_HighlightSpan( - _HighlightType.keyword, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.keyword, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -263,8 +276,7 @@ class DartSyntaxHighlighter extends Highlighter { _HighlightType type; String word = _scanner.lastMatch[0]; - if (word.startsWith('_')) - word = word.substring(1); + if (word.startsWith('_')) word = word.substring(1); if (_keywords.contains(word)) type = _HighlightType.keyword; @@ -272,15 +284,14 @@ class DartSyntaxHighlighter extends Highlighter { type = _HighlightType.keyword; else if (_firstLetterIsUpperCase(word)) type = _HighlightType.klass; - else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1))) + else if (word.length >= 2 && + word.startsWith('k') && + _firstLetterIsUpperCase(word.substring(1))) type = _HighlightType.constant; if (type != null) { _spans.add(_HighlightSpan( - type, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + type, _scanner.lastMatch.start, _scanner.lastMatch.end)); } } @@ -298,12 +309,10 @@ class DartSyntaxHighlighter extends Highlighter { void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { - if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { - _spans[i] = _HighlightSpan( - _spans[i].type, - _spans[i].start, - _spans[i + 1].end - ); + if (_spans[i].type == _spans[i + 1].type && + _spans[i].end == _spans[i + 1].start) { + _spans[i] = + _HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end); _spans.removeAt(i + 1); } } diff --git a/lib/utils/provider.dart b/lib/utils/provider.dart index 89003886..ac1b43a9 100644 --- a/lib/utils/provider.dart +++ b/lib/utils/provider.dart @@ -32,9 +32,10 @@ class Provider { if (db == null) { return Future.value([]); } - List tables = await db.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"'); + List tables = await db + .rawQuery('SELECT name FROM sqlite_master WHERE type = "table"'); List targetList = []; - tables.forEach((item) { + tables.forEach((item) { targetList.add(item['name']); }); return targetList; @@ -46,13 +47,12 @@ class Provider { List tables = await getTables(); - for(int i = 0; i < expectTables.length; i++) { + for (int i = 0; i < expectTables.length; i++) { if (!tables.contains(expectTables[i])) { return false; } } - return true; - + return true; } //初始化数据库 @@ -89,5 +89,4 @@ class Provider { print("Opening existing database"); } } - } diff --git a/lib/utils/shared_preferences.dart b/lib/utils/shared_preferences.dart index 81f7dc70..9a71a954 100644 --- a/lib/utils/shared_preferences.dart +++ b/lib/utils/shared_preferences.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:shared_preferences/shared_preferences.dart'; @@ -14,18 +13,18 @@ class SpUtil { static SharedPreferences _spf; - SpUtil._(); Future _init() async { _spf = await SharedPreferences.getInstance(); } - static Future getInstance() async { + static Future getInstance() async { if (_instance == null) { _instance = new SpUtil._(); + } + if (_spf == null) { await _instance._init(); - } return _instance; } @@ -36,6 +35,7 @@ class SpUtil { } return false; } + // 判断是否存在数据 bool hasKey(String key) { Set keys = getKeys(); @@ -106,8 +106,6 @@ class SpUtil { return _spf.get(key); } - - Future remove(String key) { if (_beforeCheck()) return null; return _spf.remove(key); @@ -117,4 +115,4 @@ class SpUtil { if (_beforeCheck()) return null; return _spf.clear(); } -} \ No newline at end of file +} diff --git a/lib/utils/sql.dart b/lib/utils/sql.dart index d932415b..3ab98660 100644 --- a/lib/utils/sql.dart +++ b/lib/utils/sql.dart @@ -1,14 +1,12 @@ - - import 'package:sqflite/sqflite.dart'; import './provider.dart'; -class BaseModel{ +class BaseModel { Database db; final String table = ''; var query; - BaseModel(this.db){ + BaseModel(this.db) { query = db.query; } } @@ -20,18 +18,21 @@ class Sql extends BaseModel { super(Provider.db); // sdf - Future get() async{ + Future get() async { return await this.query(tableName); } - String getTableName () { + + String getTableName() { return tableName; } - Future delete(String value,String key) async{ - return await this.db.delete(tableName,where:'$key = ?',whereArgs:[value]); + Future delete(String value, String key) async { + return await this + .db + .delete(tableName, where: '$key = ?', whereArgs: [value]); } - Future deleteAll() async{ + Future deleteAll() async { return await this.db.delete(tableName); } @@ -44,7 +45,7 @@ class Sql extends BaseModel { int index = 0; conditions.forEach((key, value) { if (value == null) { - return ; + return; } if (value.runtimeType == String) { stringConditions = '$stringConditions $key = "$value"'; @@ -53,7 +54,7 @@ class Sql extends BaseModel { stringConditions = '$stringConditions $key = $value'; } - if (index >= 0 && index < conditions.length -1) { + if (index >= 0 && index < conditions.length - 1) { stringConditions = '$stringConditions and'; } index++; @@ -61,18 +62,21 @@ class Sql extends BaseModel { // print("this is string condition for sql > $stringConditions"); return await this.query(tableName, where: stringConditions); } + Future> insert(Map json) async { var id = await this.db.insert(tableName, json); json['id'] = id; return json; } + /// /// 搜索 /// @param Object condition /// @mods [And, Or] default is Or /// search({'name': "hanxu', 'id': 1}; /// - Future search({Map conditions, String mods = 'Or'}) async { + Future search( + {Map conditions, String mods = 'Or'}) async { if (conditions == null || conditions.isEmpty) { return this.get(); } @@ -80,7 +84,7 @@ class Sql extends BaseModel { int index = 0; conditions.forEach((key, value) { if (value == null) { - return ; + return; } if (value.runtimeType == String) { @@ -90,7 +94,7 @@ class Sql extends BaseModel { stringConditions = '$stringConditions $key = "%$value%"'; } - if (index >= 0 && index < conditions.length -1) { + if (index >= 0 && index < conditions.length - 1) { stringConditions = '$stringConditions $mods'; } index++; @@ -98,4 +102,4 @@ class Sql extends BaseModel { return await this.query(tableName, where: stringConditions); } -} \ No newline at end of file +} diff --git a/lib/utils/style.dart b/lib/utils/style.dart index 31d9bb8d..a991c3c5 100644 --- a/lib/utils/style.dart +++ b/lib/utils/style.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; //颜色配置 -class AppColor{ +class AppColor { static const int white = 0xFFFFFFFF; static const int mainTextColor = 0xFF121917; static const int subTextColor = 0xff959595; } //文本设置 -class AppText{ +class AppText { static const middleSize = 16.0; static const middleText = TextStyle( @@ -21,9 +21,9 @@ class AppText{ fontSize: middleSize, ); } + class WidgetDemoColor { static const int fontColor = 0xFF607173; static const int iconColor = 0xFF607173; static const int borderColor = 0xFFEFEFEF; - } diff --git a/lib/utils/syntax_highlighter.dart b/lib/utils/syntax_highlighter.dart index 1b36f07c..3b0971f1 100644 --- a/lib/utils/syntax_highlighter.dart +++ b/lib/utils/syntax_highlighter.dart @@ -1,47 +1,44 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:39 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2019-01-14 11:42:39 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:39 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 11:42:39 import 'package:flutter/material.dart'; import 'package:string_scanner/string_scanner.dart'; class SyntaxHighlighterStyle { - SyntaxHighlighterStyle({ - this.baseStyle, - this.numberStyle, - this.commentStyle, - this.keywordStyle, - this.stringStyle, - this.punctuationStyle, - this.classStyle, - this.constantStyle - }); + SyntaxHighlighterStyle( + {this.baseStyle, + this.numberStyle, + this.commentStyle, + this.keywordStyle, + this.stringStyle, + this.punctuationStyle, + this.classStyle, + this.constantStyle}); static SyntaxHighlighterStyle lightThemeStyle() { return SyntaxHighlighterStyle( - baseStyle: const TextStyle(color: Color(0xFF000000)), - numberStyle: const TextStyle(color: Color(0xFF1565C0)), - commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), - keywordStyle: const TextStyle(color: Color(0xFF9C27B0)), - stringStyle: const TextStyle(color: Color(0xFF43A047)), - punctuationStyle: const TextStyle(color: Color(0xFF000000)), - classStyle: const TextStyle(color: Color(0xFF512DA8)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + baseStyle: const TextStyle(color: Color(0xFF000000)), + numberStyle: const TextStyle(color: Color(0xFF1565C0)), + commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), + keywordStyle: const TextStyle(color: Color(0xFF9C27B0)), + stringStyle: const TextStyle(color: Color(0xFF43A047)), + punctuationStyle: const TextStyle(color: Color(0xFF000000)), + classStyle: const TextStyle(color: Color(0xFF512DA8)), + constantStyle: const TextStyle(color: Color(0xFF795548))); } static SyntaxHighlighterStyle darkThemeStyle() { return SyntaxHighlighterStyle( - baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), - numberStyle: const TextStyle(color: Color(0xFF1565C0)), - commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), - keywordStyle: const TextStyle(color: Color(0xFF80CBC4)), - stringStyle: const TextStyle(color: Color(0xFF009688)), - punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), - classStyle: const TextStyle(color: Color(0xFF009688)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), + numberStyle: const TextStyle(color: Color(0xFF1565C0)), + commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), + keywordStyle: const TextStyle(color: Color(0xFF80CBC4)), + stringStyle: const TextStyle(color: Color(0xFF009688)), + punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), + classStyle: const TextStyle(color: Color(0xFF009688)), + constantStyle: const TextStyle(color: Color(0xFF795548))); } final TextStyle baseStyle; @@ -54,7 +51,8 @@ class SyntaxHighlighterStyle { final TextStyle constantStyle; } -abstract class SyntaxHighlighter { // ignore: one_member_abstracts +abstract class SyntaxHighlighter { + // ignore: one_member_abstracts TextSpan format(String src); } @@ -67,17 +65,66 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { SyntaxHighlighterStyle _style; static const List _keywords = [ - 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', - 'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else', - 'enum', 'export', 'external', 'extends', 'factory', 'false', 'final', - 'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library', - 'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static', - 'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var', - 'void', 'while', 'with', 'yield' + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'external', + 'extends', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'get', + 'if', + 'implements', + 'import', + 'in', + 'is', + 'library', + 'new', + 'null', + 'operator', + 'part', + 'rethrow', + 'return', + 'set', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield' ]; static const List _builtInTypes = [ - 'int', 'double', 'num', 'bool' + 'int', + 'double', + 'num', + 'bool' ]; String _src; @@ -97,15 +144,18 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { for (_HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); + formattedText.add(TextSpan( + style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) - formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, _src.length))); return TextSpan(style: _style.baseStyle, children: formattedText); } else { @@ -123,11 +173,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { // Block comments if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(_HighlightSpan( - _HighlightType.comment, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.comment, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -144,115 +191,81 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { endComment = _src.length; } - _spans.add(_HighlightSpan( - _HighlightType.comment, - startComment, - endComment - )); + _spans.add( + _HighlightSpan(_HighlightType.comment, startComment, endComment)); - if (eof) - break; + if (eof) break; continue; } // Raw r"String" if (_scanner.scan(RegExp(r'r".*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Raw r'String' if (_scanner.scan(RegExp(r"r'.*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline """String""" if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline '''String''' if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // "String" if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // 'String' if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Double if (_scanner.scan(RegExp(r'\d+\.\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Integer if (_scanner.scan(RegExp(r'\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end) - ); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Punctuation if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _spans.add(_HighlightSpan( - _HighlightType.punctuation, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.punctuation, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Meta data if (_scanner.scan(RegExp(r'@\w+'))) { - _spans.add(_HighlightSpan( - _HighlightType.keyword, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.keyword, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -261,8 +274,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { _HighlightType type; String word = _scanner.lastMatch[0]; - if (word.startsWith('_')) - word = word.substring(1); + if (word.startsWith('_')) word = word.substring(1); if (_keywords.contains(word)) type = _HighlightType.keyword; @@ -270,15 +282,14 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { type = _HighlightType.keyword; else if (_firstLetterIsUpperCase(word)) type = _HighlightType.klass; - else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1))) + else if (word.length >= 2 && + word.startsWith('k') && + _firstLetterIsUpperCase(word.substring(1))) type = _HighlightType.constant; if (type != null) { _spans.add(_HighlightSpan( - type, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + type, _scanner.lastMatch.start, _scanner.lastMatch.end)); } } @@ -296,12 +307,10 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { - if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { - _spans[i] = _HighlightSpan( - _spans[i].type, - _spans[i].start, - _spans[i + 1].end - ); + if (_spans[i].type == _spans[i + 1].type && + _spans[i].end == _spans[i + 1].start) { + _spans[i] = + _HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end); _spans.removeAt(i + 1); } } diff --git a/lib/views/collection_page/collection_full_page.dart b/lib/views/collection_page/collection_full_page.dart index ada616eb..29be26e3 100644 --- a/lib/views/collection_page/collection_full_page.dart +++ b/lib/views/collection_page/collection_full_page.dart @@ -58,7 +58,6 @@ class _CollectionFullPageState extends State { } Widget _renderList(context, index) { - if (index == 0) { return Container( height: 40.0, @@ -115,9 +114,8 @@ class _CollectionFullPageState extends State { trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0), onTap: () { - Application.router.navigateTo( - context, targetRouter.toLowerCase(), - transition: TransitionType.inFromRight); + Application.router.navigateTo(context, targetRouter.toLowerCase(), + transition: TransitionType.native); }, ), ); diff --git a/lib/views/collection_page/collection_page.dart b/lib/views/collection_page/collection_page.dart index 75d6e309..9dd69de3 100644 --- a/lib/views/collection_page/collection_page.dart +++ b/lib/views/collection_page/collection_page.dart @@ -1,3 +1,5 @@ +import 'package:fluro/fluro.dart'; + /// @Author: 一凨 /// @Date: 2019-01-08 17:12:58 /// @Last Modified by: 一凨 @@ -11,6 +13,7 @@ import 'package:flutter_go/routers/application.dart'; import 'package:flutter_go/routers/routers.dart'; import 'package:flutter_go/event/event_bus.dart'; import 'package:flutter_go/event/event_model.dart'; + /// import 'package:flutter_go/utils/data_utils.dart'; class CollectionPage extends StatefulWidget { @@ -26,6 +29,7 @@ class _CollectionPageState extends State { final eventBus = new EventBus(); ApplicationEvent.event = eventBus; } + /// CollectionControlModel _collectionControl = new CollectionControlModel(); List _collectionList = []; ScrollController _scrollController = new ScrollController(); @@ -116,11 +120,17 @@ class _CollectionPageState extends State { onTap: () { if (_collectionList[index - 1].router.contains('http')) { // 注意这里title已经转义过了 - Application.router.navigateTo(context, - '${Routes.webViewPage}?title=${_collectionList[index - 1].name}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${_collectionList[index - 1].name}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}', + transition: TransitionType.nativeModal, + ); } else { - Application.router - .navigateTo(context, "${_collectionList[index - 1].router}"); + Application.router.navigateTo( + context, + "${_collectionList[index - 1].router}", + transition: TransitionType.nativeModal, + ); } }, ), diff --git a/lib/views/first_page/drawer_page.dart b/lib/views/first_page/drawer_page.dart index f0fc1be0..d456598c 100644 --- a/lib/views/first_page/drawer_page.dart +++ b/lib/views/first_page/drawer_page.dart @@ -172,9 +172,11 @@ class _DrawerPageState extends State { style: textStyle, ), onTap: () { - Application.router.navigateTo(context, - '${Routes.collectionFullPage}?hasLogin=${hasLogin.toString()}', - transition: TransitionType.fadeIn); + Application.router.navigateTo( + context, + '${Routes.collectionFullPage}?hasLogin=${hasLogin.toString()}', + transition: TransitionType.nativeModal, + ); }, ), // new Divider(), @@ -205,11 +207,18 @@ class _DrawerPageState extends State { onTap: () { if (hasLogin) { //issue 未登陆状态 返回登陆页面 - Application.router.navigateTo(context, '${Routes.issuesMessage}'); + Application.router.navigateTo( + context, + '${Routes.issuesMessage}', + transition: TransitionType.nativeModal, + ); } else { //No description provided. - Application.router.navigateTo(context, '${Routes.loginPage}'); - + Application.router.navigateTo( + context, + '${Routes.loginPage}', + transition: TransitionType.nativeModal, + ); } }, ), diff --git a/lib/views/first_page/first_page.dart b/lib/views/first_page/first_page.dart index 38840ba1..e1d01544 100644 --- a/lib/views/first_page/first_page.dart +++ b/lib/views/first_page/first_page.dart @@ -17,7 +17,8 @@ class FirstPage extends StatefulWidget { FirstPageState createState() => new FirstPageState(); } -class FirstPageState extends State with AutomaticKeepAliveClientMixin{ +class FirstPageState extends State + with AutomaticKeepAliveClientMixin { Future _prefs = SharedPreferences.getInstance(); Future _unKnow; GlobalKey key; @@ -25,7 +26,6 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin @override bool get wantKeepAlive => true; - @override void initState() { super.initState(); @@ -39,8 +39,10 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 _unKnow.then((bool value) { - new Future.delayed(const Duration(seconds: 1),(){ - if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { + new Future.delayed(const Duration(seconds: 1), () { + if (!value && + key.currentState is DisclaimerMsgState && + key.currentState.showAlertDialog is Function) { key.currentState.showAlertDialog(context); } }); @@ -48,26 +50,24 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin } } - Future getIndexListData([Map params]) async { /// const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; - const juejin_flutter = 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; + const juejin_flutter = + 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; var pageIndex = (params is Map) ? params['pageIndex'] : 0; - final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'}; + final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'}; var responseList = []; - var pageTotal = 0; + var pageTotal = 0; - try{ + try { var response = await NetUtils.get(juejin_flutter, _param); responseList = response['d']['entrylist']; pageTotal = response['d']['total']; if (!(pageTotal is int) || pageTotal <= 0) { pageTotal = 0; } - }catch(e){ - - } + } catch (e) {} pageIndex += 1; List resultList = new List(); for (int i = 0; i < responseList.length; i++) { @@ -78,44 +78,50 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin // No specified type, handles all } } - Map result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex}; + Map result = { + "list": resultList, + 'total': pageTotal, + 'pageIndex': pageIndex + }; return result; } /// 每个item的样式 - Widget makeCard(index,item){ + Widget makeCard(index, item) { var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); + return new ListViewItem( + itemUrl: codeUrl, + itemTitle: myTitle, + data: myUsername, + ); } - headerView(){ - return - Column( - children: [ - Stack( + headerView() { + return Column( + children: [ + Stack( //alignment: const FractionalOffset(0.9, 0.1),//方法一 - children: [ - Pagination(), - Positioned(//方法二 - top: 10.0, - left: 0.0, - child: DisclaimerMsg(key:key,pWidget:this) - ), - ]), - SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), - SizedBox(height: 10), - ], - ); - + children: [ + Pagination(), + Positioned( + //方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key: key, pWidget: this)), + ]), + SizedBox( + height: 1, child: Container(color: Theme.of(context).primaryColor)), + SizedBox(height: 10), + ], + ); } @override Widget build(BuildContext context) { super.build(context); - return new Column( - children: [ + return new Column(children: [ // new Stack( // //alignment: const FractionalOffset(0.9, 0.1),//方法一 // children: [ @@ -127,14 +133,9 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin // ), // ]), // SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)), - new Expanded( - //child: new List(), - child: listComp.ListRefresh(getIndexListData,makeCard,headerView) - ) - ] - - ); + new Expanded( + //child: new List(), + child: listComp.ListRefresh(getIndexListData, makeCard, headerView)) + ]); } } - - diff --git a/lib/views/first_page/first_page_item.dart b/lib/views/first_page/first_page_item.dart index bef10315..bdd5da10 100644 --- a/lib/views/first_page/first_page_item.dart +++ b/lib/views/first_page/first_page_item.dart @@ -20,18 +20,18 @@ class FirstPageItem { FirstPageItem( {this.hot, - this.tag, - this.username, - this.collectionCount, - this.createdTime, - this.commentCount, - this.title, - this.detailUrl, - this.isCollection}); + this.tag, + this.username, + this.collectionCount, + this.createdTime, + this.commentCount, + this.title, + this.detailUrl, + this.isCollection}); factory FirstPageItem.fromJson(Map json) { String _tag = ''; - if(json['tags'].length>0){ + if (json['tags'].length > 0) { _tag = '${json['tags'][0]['title']}/'; } return FirstPageItem( @@ -43,7 +43,7 @@ class FirstPageItem { createdTime: Util.getTimeDuration(json['createdAt']), title: json['title'], detailUrl: json['originalUrl'], - isCollection: json['type'] , + isCollection: json['type'], ); } -} \ No newline at end of file +} diff --git a/lib/views/first_page/main_page.dart b/lib/views/first_page/main_page.dart index c48fbe0d..d2f7850b 100644 --- a/lib/views/first_page/main_page.dart +++ b/lib/views/first_page/main_page.dart @@ -1,7 +1,9 @@ +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_go/views/first_page/drawer_page.dart'; import './first_page.dart'; + /// import './sub_page.dart'; import './main_app_bar.dart'; import './search_page.dart'; @@ -16,13 +18,14 @@ class _Page { final String labelId; final int labelIndex; - _Page(this.labelId,this.labelIndex); + _Page(this.labelId, this.labelIndex); } final List<_Page> _allPages = <_Page>[ _Page('热门资讯', 1), _Page('FG-官网', 2), _Page('FG-web版', 3), + ///_Page('项目4'), ]; @@ -36,11 +39,13 @@ class MainPage extends StatelessWidget { _tabController = DefaultTabController( length: _allPages.length, child: Scaffold( - appBar: MyAppBar( + appBar: MyAppBar( leading: Container( - child: ClipOval( + child: ClipOval( child: Image.network( - userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic, + userInfo.id == 0 + ? 'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658' + : userInfo.avatarPic, scale: 15.0, ), )), @@ -48,16 +53,14 @@ class MainPage extends StatelessWidget { title: TabLayout(), actions: [ IconButton( - icon: Icon(Icons.search), + icon: Icon(Icons.search), onPressed: () { pushPage(context, SearchPage(), pageName: "SearchPage"); }) ], ), drawer: Drawer( - child: DrawerPage( - userInfo: userInfo - ), + child: DrawerPage(userInfo: userInfo), ), body: TabBarViewLayout(), )); @@ -74,26 +77,32 @@ class TabLayout extends StatelessWidget { @override Widget build(BuildContext context) { _tabBar = TabBar( - isScrollable: true, - //labelPadding: EdgeInsets.all(12.0), - labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0), - indicatorSize: TabBarIndicatorSize.label, - tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(), - onTap: (index) { - if (index == 1) { - DefaultTabController.of(context).animateTo(0); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}'); - } else if (index == 2) { - + isScrollable: true, + //labelPadding: EdgeInsets.all(12.0), + labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0), + indicatorSize: TabBarIndicatorSize.label, + tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(), + onTap: (index) { + if (index == 1) { + DefaultTabController.of(context).animateTo(0); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}', + transition: TransitionType.nativeModal, + ); + } else if (index == 2) { // new Future.delayed(const Duration(seconds: 1),(){ // showAlertDialog(Application.globalContext); // }); - DefaultTabController.of(context).animateTo(0); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}'); - } - } - ); + DefaultTabController.of(context).animateTo(0); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}', + transition: TransitionType.nativeModal, + ); + } + }); return _tabBar; } } @@ -116,7 +125,7 @@ class TabBarViewLayout extends StatelessWidget { print("TabBarViewLayout build......."); return TabBarView( children: _allPages.map((_Page page) { - return buildTabView(context, page); - }).toList()); + return buildTabView(context, page); + }).toList()); } } diff --git a/lib/views/first_page/search_page.dart b/lib/views/first_page/search_page.dart index 042bae8a..f1ee1cba 100644 --- a/lib/views/first_page/search_page.dart +++ b/lib/views/first_page/search_page.dart @@ -1,3 +1,4 @@ +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter/cupertino.dart'; @@ -8,7 +9,7 @@ import 'package:flutter_go/blocs/industry_event.dart'; import 'package:flutter_go/routers/application.dart'; import 'package:flutter_go/routers/routers.dart'; -final _industryPage = Industry.IndustryPage(itemTitle: (state){ +final _industryPage = Industry.IndustryPage(itemTitle: (state) { return ListView.builder( itemBuilder: (BuildContext context, int index) { return ListTile( @@ -27,7 +28,11 @@ final _industryPage = Industry.IndustryPage(itemTitle: (state){ print(state.res[index].source); final itemTitle = state.res[index].title; final itemUrl = state.res[index].source; - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}', + transition: TransitionType.nativeModal, + ); }, ); }, @@ -44,9 +49,8 @@ class SearchPage extends StatelessWidget { /// print('suggestion::${Industry.suggestion}'); return Scaffold( appBar: PreferredSize( - preferredSize: Size(double.infinity, 52), // is the height - child: AppBar(title: searchBarPage) - ), + preferredSize: Size(double.infinity, 52), // is the height + child: AppBar(title: searchBarPage)), //body: ProgressView(), body: _industryPage, floatingActionButton: FloatingActionButton( @@ -54,7 +58,9 @@ class SearchPage extends StatelessWidget { onPressed: () { //print('searchBarPage=====>${controller.text}'); //print('searchBarPage=====>${that.getResultsDebounced}'); - if(that is _SearchBarPageState && that.getResultsDebounced is Function && controller.text is String ) { + if (that is _SearchBarPageState && + that.getResultsDebounced is Function && + controller.text is String) { that.getResultsDebounced(controller.text); } }, @@ -67,11 +73,11 @@ class SearchPage extends StatelessWidget { class ProgressView extends StatelessWidget { @override Widget build(BuildContext context) { - return Center( - child: SizedBox( + return Center( + child: SizedBox( width: 24.0, height: 24.0, - child: CircularProgressIndicator( + child: CircularProgressIndicator( strokeWidth: 2.0, ), ), @@ -79,15 +85,15 @@ class ProgressView extends StatelessWidget { } } -class SearchBarPage extends StatefulWidget{ +class SearchBarPage extends StatefulWidget { @override - State createState() => _SearchBarPageState(); + State createState() => _SearchBarPageState(); } - final TextEditingController controller = TextEditingController(); var that; var loading; + class _SearchBarPageState extends State { @override void initState() { @@ -99,9 +105,10 @@ class _SearchBarPageState extends State { Timer _resultsTimer; String oldKey; + /// 防抖函数 Future getResultsDebounced(String text) async { - if(oldKey == text){ + if (oldKey == text) { print('请求内容重复'); return; } @@ -114,15 +121,14 @@ class _SearchBarPageState extends State { } _resultsTimer = new Timer(new Duration(milliseconds: 400), () async { loading = true; - if(mounted){ + if (mounted) { suggestion.dispatch(SuggestionFetch(query: text)); } oldKey = text; }); } - - void onSearchTextChanged(String text){ + void onSearchTextChanged(String text) { print('onSearchTextChanged:$text'); //suggestion.dispatch(SuggestionFetch(query: text)); getResultsDebounced(text); @@ -136,56 +142,58 @@ class _SearchBarPageState extends State { super.dispose(); } - Widget build(BuildContext context) { return Container( - color: Theme.of(context).primaryColor, - //color: Colors.amber, - child: Padding( - //padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top,), - padding: EdgeInsets.all(0.0), - child: Container( - //height: 162.0, - child: Padding( - padding: const EdgeInsets.all(6.0), - child: Card( - child: Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(width: 5.0,), - Icon(Icons.search, color: Colors.grey,size: 18.0,), - Expanded( - child: Container( - alignment: Alignment.center, - child: TextField( - controller: controller, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(top: 0.0), - hintText: '全网搜索 Flutter 相关知识库', - hintStyle:TextStyle(fontSize: 12.0), - border: InputBorder.none - ), - onChanged: onSearchTextChanged, - ), - ), - ), - IconButton( - icon: Icon(Icons.cancel), - color: Colors.grey, - iconSize: 18.0, - onPressed: () { - controller.clear(); - // onSearchTextChanged(''); - }, - ), - ], + color: Theme.of(context).primaryColor, + //color: Colors.amber, + child: Padding( + //padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top,), + padding: EdgeInsets.all(0.0), + child: Container( + //height: 162.0, + child: Padding( + padding: const EdgeInsets.all(6.0), + child: Card( + child: Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 5.0, + ), + Icon( + Icons.search, + color: Colors.grey, + size: 18.0, + ), + Expanded( + child: Container( + alignment: Alignment.center, + child: TextField( + controller: controller, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(top: 0.0), + hintText: '全网搜索 Flutter 相关知识库', + hintStyle: TextStyle(fontSize: 12.0), + border: InputBorder.none), + onChanged: onSearchTextChanged, + ), ), - ) - ) - ), - ), + ), + IconButton( + icon: Icon(Icons.cancel), + color: Colors.grey, + iconSize: 18.0, + onPressed: () { + controller.clear(); + // onSearchTextChanged(''); + }, + ), + ], + ), + ))), ), - ); + ), + ); } -} \ No newline at end of file +} diff --git a/lib/views/first_page/sub_page.dart b/lib/views/first_page/sub_page.dart index 22325f97..45b7de72 100644 --- a/lib/views/first_page/sub_page.dart +++ b/lib/views/first_page/sub_page.dart @@ -17,7 +17,7 @@ class SubPage extends StatefulWidget { SubPageState createState() => SubPageState(); } -class SubPageState extends State with AutomaticKeepAliveClientMixin{ +class SubPageState extends State with AutomaticKeepAliveClientMixin { Future _prefs = SharedPreferences.getInstance(); Future _unKnow; GlobalKey key; @@ -25,47 +25,46 @@ class SubPageState extends State with AutomaticKeepAliveClientMixin{ @override bool get wantKeepAlive => true; - - @override + @override void initState() { super.initState(); if (key == null) { - key = GlobalKey(); - // key = const Key('__RIKEY1__'); + key = GlobalKey(); + // key = const Key('__RIKEY1__'); //获取sharePre - _unKnow = _prefs.then((SharedPreferences prefs) { - return (prefs.getBool('disclaimer::Boolean') ?? false); - }); + _unKnow = _prefs.then((SharedPreferences prefs) { + return (prefs.getBool('disclaimer::Boolean') ?? false); + }); /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 _unKnow.then((bool value) { - new Future.delayed(const Duration(seconds: 1),(){ - if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { - key.currentState.showAlertDialog(context); - } - }); + new Future.delayed(const Duration(seconds: 1), () { + if (!value && + key.currentState is DisclaimerMsgState && + key.currentState.showAlertDialog is Function) { + key.currentState.showAlertDialog(context); + } + }); }); } } - Future getIndexListData([Map params]) async { - const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; + const juejin_flutter = + 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; var pageIndex = (params is Map) ? params['pageIndex'] : 0; - final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'}; + final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'}; var responseList = []; - var pageTotal = 0; + var pageTotal = 0; - try{ + try { var response = await NetUtils.get(juejin_flutter, _param); responseList = response['d']['entrylist']; pageTotal = response['d']['total']; if (!(pageTotal is int) || pageTotal <= 0) { pageTotal = 0; } - }catch(e){ - - } + } catch (e) {} pageIndex += 1; List resultList = new List(); for (int i = 0; i < responseList.length; i++) { @@ -76,50 +75,50 @@ class SubPageState extends State with AutomaticKeepAliveClientMixin{ // No specified type, handles all } } - Map result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex}; + Map result = { + "list": resultList, + 'total': pageTotal, + 'pageIndex': pageIndex + }; return result; } - Widget makeCard(index,item){ - + Widget makeCard(index, item) { var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); + return new ListViewItem( + itemUrl: codeUrl, + itemTitle: myTitle, + data: myUsername, + ); } - headerView(){ - return - Column( - children: [ + headerView() { + return Column( + children: [ Stack( - //alignment: const FractionalOffset(0.9, 0.1),//方法一 - children: [ - Pagination(), - Positioned(//方法二 - top: 10.0, - left: 0.0, - child: DisclaimerMsg(key:key,pWidget:this) - ), - ]), - SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), + //alignment: const FractionalOffset(0.9, 0.1),//方法一 + children: [ + Pagination(), + Positioned( + //方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key: key, pWidget: this)), + ]), + SizedBox( + height: 1, child: Container(color: Theme.of(context).primaryColor)), SizedBox(height: 10), - ], - ); - + ], + ); } @override Widget build(BuildContext context) { super.build(context); - return new Column( - children: [ - new Expanded( - child: listComp.ListRefresh(getIndexListData,makeCard) - ) - ] - ); + return new Column(children: [ + new Expanded(child: listComp.ListRefresh(getIndexListData, makeCard)) + ]); } } - - diff --git a/lib/views/fourth_page/page_dragger.dart b/lib/views/fourth_page/page_dragger.dart index e36b8282..1e1c1e61 100644 --- a/lib/views/fourth_page/page_dragger.dart +++ b/lib/views/fourth_page/page_dragger.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'dart:ui'; @@ -7,13 +6,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/views/fourth_page/pager_indicator.dart'; class PageDragger extends StatefulWidget { - final canDragLeftToRight; final canDragRightToLeft; final StreamController slideUpdateStream; - PageDragger({ this.canDragLeftToRight, this.canDragRightToLeft, @@ -25,14 +22,13 @@ class PageDragger extends StatefulWidget { } class _PageDraggerState extends State { - static const FULL_TRANSTITION_PX = 300.0; Offset dragStart; SlideDirection slideDirection; double slidePercent = 0.0; - onDragStart(DragStartDetails details){ + onDragStart(DragStartDetails details) { dragStart = details.globalPosition; } @@ -49,28 +45,22 @@ class _PageDraggerState extends State { slideDirection = SlideDirection.none; } - if (slideDirection != SlideDirection.none){ - slidePercent = (dx / FULL_TRANSTITION_PX).abs().clamp(0.0, 1.0); + if (slideDirection != SlideDirection.none) { + slidePercent = (dx / FULL_TRANSTITION_PX).abs().clamp(0.0, 1.0); } else { slidePercent = 0.0; } widget.slideUpdateStream.add( - new SlideUpdate( - UpdateType.dragging, - slideDirection, - slidePercent - )); + new SlideUpdate(UpdateType.dragging, slideDirection, slidePercent)); } } - onDragEnd(DragEndDetails details){ - widget.slideUpdateStream.add( - new SlideUpdate( + onDragEnd(DragEndDetails details) { + widget.slideUpdateStream.add(new SlideUpdate( UpdateType.doneDragging, SlideDirection.none, 0.0, - ) - ); + )); dragStart = null; } @@ -78,15 +68,14 @@ class _PageDraggerState extends State { @override Widget build(BuildContext context) { return GestureDetector( - onHorizontalDragStart: onDragStart , - onHorizontalDragUpdate: onDragUpdate , - onHorizontalDragEnd: onDragEnd , + onHorizontalDragStart: onDragStart, + onHorizontalDragUpdate: onDragUpdate, + onHorizontalDragEnd: onDragEnd, ); } } -class AnimatedPageDragger{ - +class AnimatedPageDragger { static const PERCENT_PER_MILLISECOND = 0.005; final slideDirection; @@ -95,85 +84,67 @@ class AnimatedPageDragger{ AnimationController completionAnimationController; AnimatedPageDragger({ - this.slideDirection, - this.transitionGoal, - slidePercent, - StreamController slideUpdateStream, - TickerProvider vsync, + this.slideDirection, + this.transitionGoal, + slidePercent, + StreamController slideUpdateStream, + TickerProvider vsync, }) { final startSlidePercent = slidePercent; var endSlidePercent; var duration; - if ( transitionGoal == TransitionGoal.open){ + if (transitionGoal == TransitionGoal.open) { endSlidePercent = 1.0; final slideRemaining = 1.0 - slidePercent; duration = new Duration( - milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round() - ); - + milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round()); } else { endSlidePercent = 0.0; duration = new Duration( - milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round() - ); + milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round()); } - completionAnimationController = new AnimationController( - duration: duration, - vsync: vsync - ) - ..addListener((){ - slidePercent = lerpDouble( - startSlidePercent, - endSlidePercent, - completionAnimationController.value - ); - - slideUpdateStream.add( - new SlideUpdate( - UpdateType.animating, - slideDirection, - slidePercent, - ) - ); - - }) - - ..addStatusListener((AnimationStatus status){ - - if(status == AnimationStatus.completed){ - slideUpdateStream.add( - new SlideUpdate( - UpdateType.doneAnimating, - slideDirection, - endSlidePercent, - ) - ); - } - - }); - + completionAnimationController = + new AnimationController(duration: duration, vsync: vsync) + ..addListener(() { + slidePercent = lerpDouble(startSlidePercent, endSlidePercent, + completionAnimationController.value); + + slideUpdateStream.add(new SlideUpdate( + UpdateType.animating, + slideDirection, + slidePercent, + )); + }) + ..addStatusListener((AnimationStatus status) { + if (status == AnimationStatus.completed) { + slideUpdateStream.add(new SlideUpdate( + UpdateType.doneAnimating, + slideDirection, + endSlidePercent, + )); + } + }); } - run(){ + run() { completionAnimationController.forward(from: 0.0); } - dispose(){ + dispose() { completionAnimationController.dispose(); } - } -enum TransitionGoal{ +enum TransitionGoal { open, close, } -enum UpdateType{ +enum UpdateType { dragging, doneDragging, animating, @@ -185,9 +156,5 @@ class SlideUpdate { final direction; final slidePercent; - SlideUpdate( - this.updateType, - this.direction, - this.slidePercent - ); + SlideUpdate(this.updateType, this.direction, this.slidePercent); } diff --git a/lib/views/fourth_page/page_reveal.dart b/lib/views/fourth_page/page_reveal.dart index 4cd5a48a..ded05eeb 100644 --- a/lib/views/fourth_page/page_reveal.dart +++ b/lib/views/fourth_page/page_reveal.dart @@ -3,14 +3,10 @@ import 'dart:math'; import 'package:flutter/material.dart'; class PageReveal extends StatelessWidget { - final double revealPercent; final Widget child; - PageReveal({ - this.revealPercent, - this.child - }); + PageReveal({this.revealPercent, this.child}); @override Widget build(BuildContext context) { @@ -21,18 +17,13 @@ class PageReveal extends StatelessWidget { } } -class CircleRevealClipper extends CustomClipper{ - +class CircleRevealClipper extends CustomClipper { final double revealPercent; - - CircleRevealClipper( - this.revealPercent - ); + CircleRevealClipper(this.revealPercent); @override Rect getClip(Size size) { - final epicenter = new Offset(size.width / 2, size.height * 0.9); double theta = atan(epicenter.dy / epicenter.dx); @@ -41,12 +32,12 @@ class CircleRevealClipper extends CustomClipper{ final radius = distanceToCorner * revealPercent; final diameter = 2 * radius; - return new Rect.fromLTWH(epicenter.dx - radius, epicenter.dy - radius, diameter, diameter); + return new Rect.fromLTWH( + epicenter.dx - radius, epicenter.dy - radius, diameter, diameter); } @override bool shouldReclip(CustomClipper oldClipper) { return true; } - -} \ No newline at end of file +} diff --git a/lib/views/fourth_page/pager_indicator.dart b/lib/views/fourth_page/pager_indicator.dart index c3aa7438..b077cc49 100644 --- a/lib/views/fourth_page/pager_indicator.dart +++ b/lib/views/fourth_page/pager_indicator.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/views/fourth_page/pages.dart'; class PagerIndicator extends StatelessWidget { - final PagerIndicatorViewModel viewModel; PagerIndicator({ @@ -14,47 +13,49 @@ class PagerIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - List bubbles = []; - for(var i = 0; i < viewModel.pages.length; ++i ){ + for (var i = 0; i < viewModel.pages.length; ++i) { final page = viewModel.pages[i]; var percentActive; - if(i == viewModel.activeIndex){ + if (i == viewModel.activeIndex) { percentActive = 1.0 - viewModel.slidePercent; - } else if (i == viewModel.activeIndex - 1 && viewModel.slideDirection == SlideDirection.leftToRight){ + } else if (i == viewModel.activeIndex - 1 && + viewModel.slideDirection == SlideDirection.leftToRight) { percentActive = viewModel.slidePercent; - } else if (i == viewModel.activeIndex + 1 && viewModel.slideDirection == SlideDirection.rightToLeft){ + } else if (i == viewModel.activeIndex + 1 && + viewModel.slideDirection == SlideDirection.rightToLeft) { percentActive = viewModel.slidePercent; - }else { + } else { percentActive = 0.0; } - bool isHollow = i > viewModel.activeIndex || (i == viewModel.activeIndex && viewModel.slideDirection == SlideDirection.leftToRight); - - + bool isHollow = i > viewModel.activeIndex || + (i == viewModel.activeIndex && + viewModel.slideDirection == SlideDirection.leftToRight); bubbles.add( - new PageBubble( + new PageBubble( viewModel: new PageBubbleViewModel( - page.iconAssetPath, - page.color, - isHollow, - percentActive, + page.iconAssetPath, + page.color, + isHollow, + percentActive, ), ), ); } - final bubbleWidth = 55.0 ; - final baseTranslation = ((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2) ; + final bubbleWidth = 55.0; + final baseTranslation = + ((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2); var translation = baseTranslation - (viewModel.activeIndex * bubbleWidth); - if (viewModel.slideDirection == SlideDirection.leftToRight){ - translation = bubbleWidth * viewModel.slidePercent + translation; - }else if (viewModel.slideDirection == SlideDirection.rightToLeft){ - translation = bubbleWidth * viewModel.slidePercent - translation; + if (viewModel.slideDirection == SlideDirection.leftToRight) { + translation = bubbleWidth * viewModel.slidePercent + translation; + } else if (viewModel.slideDirection == SlideDirection.rightToLeft) { + translation = bubbleWidth * viewModel.slidePercent - translation; } return new Column( @@ -72,37 +73,26 @@ class PagerIndicator extends StatelessWidget { } } -enum SlideDirection{ +enum SlideDirection { leftToRight, rightToLeft, none, } - -class PagerIndicatorViewModel{ +class PagerIndicatorViewModel { final List pages; final int activeIndex; final SlideDirection slideDirection; final double slidePercent; PagerIndicatorViewModel( - this.pages, - this.activeIndex, - this.slideDirection, - this.slidePercent - ); - - + this.pages, this.activeIndex, this.slideDirection, this.slidePercent); } class PageBubble extends StatelessWidget { - final PageBubbleViewModel viewModel; - - PageBubble({ - this.viewModel - }); + PageBubble({this.viewModel}); @override Widget build(BuildContext context) { @@ -111,16 +101,18 @@ class PageBubble extends StatelessWidget { height: 65.0, child: new Center( child: new Container( - width: lerpDouble(20.0,45.0,viewModel.activePercent), - height: lerpDouble(20.0,45.0,viewModel.activePercent), + width: lerpDouble(20.0, 45.0, viewModel.activePercent), + height: lerpDouble(20.0, 45.0, viewModel.activePercent), decoration: new BoxDecoration( shape: BoxShape.circle, color: viewModel.isHollow - ? const Color(0x88FFFFFF).withAlpha(0x88 * viewModel.activePercent.round()) + ? const Color(0x88FFFFFF) + .withAlpha(0x88 * viewModel.activePercent.round()) : const Color(0x88FFFFFF), border: new Border.all( color: viewModel.isHollow - ? const Color(0x88FFFFFF).withAlpha((0x88 * (1.0 - viewModel.activePercent)).round()) + ? const Color(0x88FFFFFF).withAlpha( + (0x88 * (1.0 - viewModel.activePercent)).round()) : Colors.transparent, width: 3.0, ), @@ -138,20 +130,16 @@ class PageBubble extends StatelessWidget { } } - class PageBubbleViewModel { final String iconAssetPath; final Color color; final bool isHollow; final double activePercent; - PageBubbleViewModel ( - this.iconAssetPath, - this.color, - this.isHollow, - this.activePercent, - ); - - + PageBubbleViewModel( + this.iconAssetPath, + this.color, + this.isHollow, + this.activePercent, + ); } - diff --git a/lib/views/fourth_page/pages.dart b/lib/views/fourth_page/pages.dart index 5d088e07..2e44ee19 100644 --- a/lib/views/fourth_page/pages.dart +++ b/lib/views/fourth_page/pages.dart @@ -1,3 +1,4 @@ +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import '../../routers/application.dart'; @@ -51,14 +52,18 @@ class Page extends StatelessWidget { ..putBool(SharedPreferencesKeys.showWelcome, false); _goHomePage(context); } else if (type == 'goGithub') { - Application.router.navigateTo(context, - '${Routes.webViewPage}?title=${Uri.encodeComponent(txt)} Doc&&url=${Uri.encodeComponent("https://github.com/alibaba/flutter-go")}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(txt)} Doc&&url=${Uri.encodeComponent("https://github.com/alibaba/flutter-go")}', + transition: TransitionType.nativeModal, + ); } }, elevation: 10.0, color: Colors.black26, // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))), //如果不手动设置icon和text颜色,则默认使用foregroundColor颜色 icon: Icon(iconName, color: Colors.white, size: 14.0), label: Text( @@ -71,11 +76,13 @@ class Page extends StatelessWidget { @override Widget build(BuildContext context) { + final paddingTop = MediaQuery.of(context).padding.top; return Stack( //alignment: const Alignment(1.2, 0.6), children: [ Container( width: double.infinity, + /// height:MediaQuery.of(context).size.height-200.0, color: viewModel.color, padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), @@ -86,15 +93,17 @@ class Page extends StatelessWidget { layout(context), ], ), - ) - ), + )), Positioned( right: -5.0, - top: 2.0, - child: creatButton(context, 'GitHub', Icons.arrow_forward, 'goGithub') - ), - ] - ); + top: paddingTop + 2.0, + child: creatButton( + context, + 'GitHub', + Icons.arrow_forward, + 'goGithub', + )), + ]); } Column layout(BuildContext context) { diff --git a/lib/views/home.dart b/lib/views/home.dart index 435fc81d..e9babf7e 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -6,19 +6,24 @@ /// target: app首页 import 'package:flutter/material.dart'; + /// import 'package:flutter/rendering.dart'; import 'package:flutter_go/utils/data_utils.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; + /// import 'package:flutter_go/views/first_page/first_page.dart'; import 'package:flutter_go/views/first_page/main_page.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter_go/views/user_page/user_page.dart'; import 'package:flutter_go/views/widget_page/widget_page.dart'; import 'package:flutter_go/views/welcome_page/fourth_page.dart'; + /// import 'package:flutter_go/views/collection_page/collection_page.dart'; import 'package:flutter_go/routers/application.dart'; + /// import 'package:flutter_go/utils/provider.dart'; import 'package:flutter_go/model/widget.dart'; + /// import 'package:flutter_go/widgets/index.dart'; import 'package:flutter_go/components/search_input.dart'; import 'package:flutter_go/model/search_history.dart'; @@ -60,10 +65,11 @@ class _MyHomePageState extends State print('widget.userInfo ${widget.userInfo}'); initSearchHistory(); - if(Application.pageIsOpen == true){// 是否展开业界动态 + if (Application.pageIsOpen == true) { + // 是否展开业界动态 tabData.insert(0, {'text': '业界动态', 'icon': Icon(Icons.language)}); _list - //..add(FirstPage()) + //..add(FirstPage()) ..add(MainPage(userInfo: widget.userInfo)); } appBarTitle = tabData[0]['text']; @@ -76,10 +82,10 @@ class _MyHomePageState extends State ), )); } - _list - ..add(WidgetPage()) - ..add(FourthPage()) - ..add(UserPage(userInfo: widget.userInfo)); + _list + ..add(WidgetPage()) + ..add(FourthPage()) + ..add(UserPage(userInfo: widget.userInfo)); } @override @@ -96,12 +102,12 @@ class _MyHomePageState extends State void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) { String targetName = widgetPoint.name; - searchHistoryList.add( - SearchHistory(name: targetName, targetRouter: widgetPoint.routerName)); - print("searchHistoryList1 ${searchHistoryList.toString()}"); String targetRouter = widgetPoint.routerName; + searchHistoryList + .add(SearchHistory(name: targetName, targetRouter: targetRouter)); + print("searchHistoryList1 ${searchHistoryList.toString()}"); Application.router.navigateTo(context, targetRouter.toLowerCase(), - transition: TransitionType.inFromRight); + transition: TransitionType.native); } Widget buildSearchInput(BuildContext context) { @@ -129,7 +135,7 @@ class _MyHomePageState extends State renderAppBar(BuildContext context, Widget widget, int index) { if (index == 1 && Application.pageIsOpen == true) { return AppBar(title: buildSearchInput(context)); - }else if(index == 0 && Application.pageIsOpen == false){ + } else if (index == 0 && Application.pageIsOpen == false) { return AppBar(title: buildSearchInput(context)); } } diff --git a/lib/views/issuse_message_page/issuse_message_page.dart b/lib/views/issuse_message_page/issuse_message_page.dart index 0bfef825..a4c94814 100644 --- a/lib/views/issuse_message_page/issuse_message_page.dart +++ b/lib/views/issuse_message_page/issuse_message_page.dart @@ -6,8 +6,6 @@ import 'package:flutter_go/utils/data_utils.dart'; import 'package:notus/convert.dart'; import 'package:fluttertoast/fluttertoast.dart'; - - class IssuesMessagePage extends StatefulWidget { @override _IssuesMessagePageState createState() => _IssuesMessagePageState(); @@ -48,15 +46,17 @@ class _IssuesMessagePageState extends State { if (_title.trim().isEmpty) { _show('标题不能为空'); } else { - String mk = (_delta==null)?'No description provided.':notusMarkdown.encode(_delta); - DataUtils.feedback({'title': _title, "body": mk},context).then((result) { + String mk = (_delta == null) + ? 'No description provided.' + : notusMarkdown.encode(_delta); + DataUtils.feedback({'title': _title, "body": mk}, context).then((result) { _show('提交成功'); Navigator.maybePop(context); }); } } - _show(String msgs){ + _show(String msgs) { Fluttertoast.showToast( msg: msgs, toastLength: Toast.LENGTH_SHORT, @@ -68,20 +68,19 @@ class _IssuesMessagePageState extends State { } Widget buildLoading() { - return Opacity( - opacity: .5, - child: Container( - width: MediaQuery.of(context).size.width * 0.85, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(8.0)), - color: Colors.black, - ), - child: SpinKitPouringHourglass(color: Colors.white), + return Opacity( + opacity: .5, + child: Container( + width: MediaQuery.of(context).size.width * 0.85, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(8.0)), + color: Colors.black, ), - ); + child: SpinKitPouringHourglass(color: Colors.white), + ), + ); } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/views/login_page/login_page.dart b/lib/views/login_page/login_page.dart index bc8ae79f..94957db9 100644 --- a/lib/views/login_page/login_page.dart +++ b/lib/views/login_page/login_page.dart @@ -1,3 +1,4 @@ +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:event_bus/event_bus.dart'; @@ -137,7 +138,7 @@ class _LoginPageState extends State { if (value.isEmpty) { return "登录名不可为空!"; } - return ' '; + return null; }, onSaved: (value) { setState(() { @@ -180,7 +181,7 @@ class _LoginPageState extends State { if (value == null || value.isEmpty) { return "密码不可为空!"; } - return ''; + return null; }, onSaved: (value) { setState(() { @@ -256,15 +257,15 @@ class _LoginPageState extends State { MaterialPageRoute(builder: (context) => AppPage(userResult)), (route) => route == null); } - }else if(userResult.runtimeType == String){ + } else if (userResult.runtimeType == String) { Fluttertoast.showToast( - msg: userResult, - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.CENTER, - timeInSecForIos: 1, - backgroundColor: Theme.of(context).primaryColor, - textColor: Colors.white, - fontSize: 16.0); + msg: userResult, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIos: 1, + backgroundColor: Theme.of(context).primaryColor, + textColor: Colors.white, + fontSize: 16.0); } }).catchError((errorMsg) { setState(() { @@ -376,8 +377,11 @@ class _LoginPageState extends State { decoration: TextDecoration.underline), ), onPressed: () { - Application.router.navigateTo(context, - '${Routes.webViewPage}?title=Github&url=${Uri.encodeComponent("https://github.com/login/oauth/authorize?client_id=cfe4795e76382ae8a5bd&scope=user,public_repo")}'); + Application.router.navigateTo( + context, + '${Routes.webViewPage}?title=Github&url=${Uri.encodeComponent("https://github.com/login/oauth/authorize?client_id=cfe4795e76382ae8a5bd&scope=user,public_repo")}', + transition: TransitionType.nativeModal, + ); }, ), FlatButton( @@ -388,11 +392,12 @@ class _LoginPageState extends State { decoration: TextDecoration.underline), ), onPressed: () { - Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute( - builder: (context) => - AppPage(UserInformation(id: 0))), - (route) => route == null); + Application.router.navigateTo( + context, + Routes.home, + clearStack: true, + transition: TransitionType.nativeModal, + ); }, ) ], diff --git a/lib/views/standard_demo_page/index.dart b/lib/views/standard_demo_page/index.dart index 20264f9d..73fe42e0 100644 --- a/lib/views/standard_demo_page/index.dart +++ b/lib/views/standard_demo_page/index.dart @@ -7,6 +7,7 @@ // tartget: xxx // +import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import '../../components/widget_demo.dart'; import 'dart:convert'; @@ -19,12 +20,12 @@ import 'package:flutter_go/routers/routers.dart'; import 'package:flutter_go/utils/net_utils.dart'; import 'package:flutter_go/components/loading.dart'; -const githubHost = 'https://raw.githubusercontent.com/alibaba/flutter-go/master'; +const githubHost = + 'https://raw.githubusercontent.com/alibaba/flutter-go/master'; const githubUrl = '$githubHost/lib/standard_pages/'; const PagesUrl = '$githubHost/lib/standard_pages/.pages.json'; const DemosUrl = '$githubHost/lib/page_demo_package/.demo.json'; - // ONLINE || LOCAL ENV env = Application.env; @@ -54,9 +55,11 @@ class _StandardView extends State { // } /// 本地调用的获取文章属性的基本信息 Future localGetPagesAttrsInfo() async { - String jsonString = await DefaultAssetBundle.of(context).loadString('lib/standard_pages/.pages.json'); + String jsonString = await DefaultAssetBundle.of(context) + .loadString('lib/standard_pages/.pages.json'); List jsonList = json.decode(jsonString); - Map pageDetail = jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null); + Map pageDetail = + jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null); if (pageDetail != null) { setState(() { @@ -69,12 +72,12 @@ class _StandardView extends State { /// 从本地获取基本文章信息 String localGetPagesMarkdown() { - String pageId = widget.id; Map pagesList = standardPage.getPages(); // print('pagesList[pageId]>>> ${pagesList[pageId]}'); return pagesList[pageId]; } + Future getContentOnline() async { this.setState(() { isLoading = true; @@ -82,8 +85,6 @@ class _StandardView extends State { List response = jsonDecode(await NetUtils.get(PagesUrl)); - - Map targetPage = response.firstWhere((page) => page['id'] == widget.id); if (targetPage == null) { setState(() { @@ -97,13 +98,18 @@ class _StandardView extends State { email = targetPage['email']; }); - String pageName = targetPage['name'] + "_" +targetPage['author']+ "_" +targetPage['id']; + String pageName = targetPage['name'] + + "_" + + targetPage['author'] + + "_" + + targetPage['id']; String pageContent = await NetUtils.get(githubUrl + pageName + "/index.md"); setState(() { isLoading = false; }); return Future(() => pageContent); } + /// 获取当面界面的相关信息. 需要区分环境 /// 本地环境下, 从本地获取 standard_pages的目录中互殴 /// 线上环境. 从github的api中获取 @@ -124,6 +130,7 @@ class _StandardView extends State { } return Future(() => conent); } + void seeSourceCode(id) async { List response; try { @@ -132,16 +139,21 @@ class _StandardView extends State { return alertDialog(msg: '请检查网络链接', title: '提示'); } - Map demoDetail = response.firstWhere((item) => item['id'] == id, orElse: null); + Map demoDetail = + response.firstWhere((item) => item['id'] == id, orElse: null); if (demoDetail == null) { return null; } - String remoteSouceCode = '$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart'; - Application.router.navigateTo(context, - '${Routes.githubCodeView}?remotePath=${Uri.encodeComponent(remoteSouceCode)}'); - + String remoteSouceCode = + '$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart'; + Application.router.navigateTo( + context, + '${Routes.githubCodeView}?remotePath=${Uri.encodeComponent(remoteSouceCode)}', + transition: TransitionType.nativeModal, + ); } + Widget buildFootInfo() { if (!isLoading) { return Container( @@ -159,8 +171,6 @@ class _StandardView extends State { } Widget buildMarkdown() { - - if (markdownDesc == null) { return null; } else { @@ -172,7 +182,7 @@ class _StandardView extends State { return MarkdownBody( data: markdownDesc, - syntaxHighlighter:new mdCopy.HighLight(), + syntaxHighlighter: new mdCopy.HighLight(), demoBuilder: (Map attrs) { List demo = demoObjects[attrs['id']]; if (demo == null) { @@ -193,28 +203,29 @@ class _StandardView extends State { onTap: () { seeSourceCode(attrs['id']); }, - child: Text("查看源码", style: TextStyle(color: Theme.of(context).primaryColor)), + child: Text("查看源码", + style: TextStyle(color: Theme.of(context).primaryColor)), ) ], - ) ; + ); } }); } + alertDialog({String msg, String title}) { showDialog( context: context, barrierDismissible: true, builder: (BuildContext context) { return new AlertDialog( - title: new Text(title), - content: new SingleChildScrollView( - child: new ListBody( - children: [ - new Text(msg), - ], - ), - ) - ); + title: new Text(title), + content: new SingleChildScrollView( + child: new ListBody( + children: [ + new Text(msg), + ], + ), + )); }, ); } diff --git a/lib/views/web_page/web_view_page.dart b/lib/views/web_page/web_view_page.dart index 8f39c7f6..fbadf772 100644 --- a/lib/views/web_page/web_view_page.dart +++ b/lib/views/web_page/web_view_page.dart @@ -76,6 +76,7 @@ class _WebViewPageState extends State { withZoom: false, withLocalStorage: true, withJavascript: true, + hidden: true, ), ); } diff --git a/lib/views/welcome_page/index.dart b/lib/views/welcome_page/index.dart index 36576bcb..6360373d 100644 --- a/lib/views/welcome_page/index.dart +++ b/lib/views/welcome_page/index.dart @@ -20,12 +20,8 @@ class WelcomePage extends StatefulWidget { } class _WelcomePageState extends State { - @override Widget build(BuildContext context) { - return new Container( - color: Colors.white, - child: FourthPage() - ); + return new Container(color: Colors.white, child: FourthPage()); } } diff --git a/lib/views/widget_page/widget_page.dart b/lib/views/widget_page/widget_page.dart index 5df042cb..6bc118ee 100644 --- a/lib/views/widget_page/widget_page.dart +++ b/lib/views/widget_page/widget_page.dart @@ -1,5 +1,5 @@ -/// Author: 一凨 -/// Date: 2019-01-11 14:39:48 +/// Author: 一凨 +/// Date: 2019-01-11 14:39:48 /// Last Modified by: 一凨 /// Last Modified time: 2019-01-11 14:40:09 @@ -9,36 +9,27 @@ import 'package:flutter_go/components/cate_card.dart'; import 'package:flutter_go/routers/application.dart'; - class WidgetPage extends StatefulWidget { - - - - @override SecondPageState createState() => new SecondPageState(); } -class SecondPageState extends State with AutomaticKeepAliveClientMixin{ - +class SecondPageState extends State + with AutomaticKeepAliveClientMixin { SecondPageState() : super(); TextEditingController controller; String active = 'test'; String data = '无'; - - @override - bool get wantKeepAlive => true; + bool get wantKeepAlive => true; @override - void initState() { + void initState() { super.initState(); } - - Widget buildGrid() { // 存放最后的widget List tiles = []; @@ -58,5 +49,4 @@ class SecondPageState extends State with AutomaticKeepAliveClientMix child: this.buildGrid(), ); } - } diff --git a/lib/widgets/404.dart b/lib/widgets/404.dart index 52149ac3..49a0e9c2 100644 --- a/lib/widgets/404.dart +++ b/lib/widgets/404.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; class WidgetNotFound extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("widget not found"), - ), - body: Container( - child: Text("widget not found") - ) - ); - } + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("widget not found"), + ), + body: Container(child: Text("widget not found"))); + } } diff --git a/lib/widgets/components/Bar/AppBar/demo.dart b/lib/widgets/components/Bar/AppBar/demo.dart index a2eb5bd0..8c580a9d 100644 --- a/lib/widgets/components/Bar/AppBar/demo.dart +++ b/lib/widgets/components/Bar/AppBar/demo.dart @@ -18,15 +18,17 @@ class AppBarLessDefaultComplex extends StatefulWidget { } // AppBar 默认的实例,有状态 -class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixin { +class _AppBarLessDefaultComplex extends State + with SingleTickerProviderStateMixin { ScrollController _scrollViewController; TabController _tabController; @override void initState() { super.initState(); - _scrollViewController = ScrollController(); - _tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应 + _scrollViewController = ScrollController(); + _tabController = + TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应 } @override @@ -41,48 +43,49 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, - child: AppBar( // 大量配置属性参考 SliverAppBar 示例 - title: Text('title'), - leading: Icon(Icons.home), + child: AppBar( + // 大量配置属性参考 SliverAppBar 示例 + title: Text('title'), + leading: Icon(Icons.home), backgroundColor: Colors.amber[500], centerTitle: true, actions: [ - IconButton( - icon: Icon(Icons.add_alarm), + IconButton( + icon: Icon(Icons.add_alarm), tooltip: 'Add Alarm', onPressed: () { // do nothing }), - PopupMenuButton( + PopupMenuButton( itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: "price", child: Text('Sort by price')), - PopupMenuItem( - value: "time", child: Text('Sort by time')), - ], + PopupMenuItem( + value: "price", child: Text('Sort by price')), + PopupMenuItem( + value: "time", child: Text('Sort by time')), + ], onSelected: (String action) { switch (action) { case "price": - // do nothing + // do nothing break; case "time": - // do nothing + // do nothing break; } }) ], - bottom: TabBar( + bottom: TabBar( isScrollable: true, controller: _tabController, tabs: [ - Tab(text: "Tabs 1"), - Tab(text: "Tabs 2"), - Tab(text: "Tabs 3"), - Tab(text: "Tabs 4"), - Tab(text: "Tabs 5"), - Tab(text: "Tabs 6"), + Tab(text: "Tabs 1"), + Tab(text: "Tabs 2"), + Tab(text: "Tabs 3"), + Tab(text: "Tabs 4"), + Tab(text: "Tabs 5"), + Tab(text: "Tabs 6"), ], ), ), @@ -90,40 +93,37 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi } } - // AppBar 默认的实例,无状态 class AppBarLessDefaultSimple extends StatelessWidget { final widget; final parent; - const AppBarLessDefaultSimple([this.widget, this.parent]) - : super(); + const AppBarLessDefaultSimple([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { - return SizedBox( - height: 200, - child:AppBar( - title: Text('My Fancy Dress'), - actions: [ - IconButton( - icon: Icon(Icons.playlist_play), - tooltip: 'Air it', - onPressed: ()=>{}, - ), - IconButton( - icon: Icon(Icons.playlist_add), - tooltip: 'Restitch it', - onPressed: ()=>{}, - ), - IconButton( - icon: Icon(Icons.playlist_add_check), - tooltip: 'Repair it', - onPressed: ()=>{}, - ), - ], - ) - ); + return SizedBox( + height: 200, + child: AppBar( + title: Text('My Fancy Dress'), + actions: [ + IconButton( + icon: Icon(Icons.playlist_play), + tooltip: 'Air it', + onPressed: () => {}, + ), + IconButton( + icon: Icon(Icons.playlist_add), + tooltip: 'Restitch it', + onPressed: () => {}, + ), + IconButton( + icon: Icon(Icons.playlist_add_check), + tooltip: 'Repair it', + onPressed: () => {}, + ), + ], + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/AppBar/index.dart b/lib/widgets/components/Bar/AppBar/index.dart index dac6d0b6..abc6199e 100644 --- a/lib/widgets/components/Bar/AppBar/index.dart +++ b/lib/widgets/components/Bar/AppBar/index.dart @@ -10,23 +10,19 @@ import 'package:flutter/material.dart'; import './demo.dart' as AppBarDemo; import 'package:flutter_go/components/widget_demo.dart'; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > AppBar “应用栏” - 应用栏由工具栏组成,或者是工具栏和其他 widget 组合形成,例如 TabBar和FlexibleSpaceBar; - 应用栏通常用于 Scaffold.appBar 属性,该属性将应用栏放置在屏幕顶部的固定高度小部件中; - 对于可滚动的应用栏,请参阅SliverAppBar,它将AppBar嵌入 sliver 中以便在CustomScrollView中使用; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > AppBar - AppBar 在底部上方显示工具栏 widget,前导 leading ,标题 title 和操作 actions; """; -const String _Text2 = -"""### **进阶用法** +const String _Text2 = """### **进阶用法** > AppBar - 一个完整的 AppBar 的例子, 增加 PopupMenuButton,TabBar 的示例子; - 所述底部通常用于一个的 TabBar; diff --git a/lib/widgets/components/Bar/BottomAppBar/demo.dart b/lib/widgets/components/Bar/BottomAppBar/demo.dart index 5473e0da..48ace2c8 100644 --- a/lib/widgets/components/Bar/BottomAppBar/demo.dart +++ b/lib/widgets/components/Bar/BottomAppBar/demo.dart @@ -12,31 +12,39 @@ class AppBarLessDefaultSimple extends StatelessWidget { final widget; final parent; - const AppBarLessDefaultSimple([this.widget, this.parent]) - : super(); + const AppBarLessDefaultSimple([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { - return SizedBox( - height: 100, - child: Scaffold( - //appBar: AppBar(title: const Text('Bottom App Bar')), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - floatingActionButton: FloatingActionButton( - child: const Icon(Icons.add), onPressed: () {},), + return SizedBox( + height: 100, + child: Scaffold( + //appBar: AppBar(title: const Text('Bottom App Bar')), + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.add), + onPressed: () {}, + ), bottomNavigationBar: BottomAppBar( shape: CircularNotchedRectangle(), - notchMargin: 10.0,// FloatingActionButton和BottomAppBar 之间的差距 - color:Colors.pink, + notchMargin: 10.0, // FloatingActionButton和BottomAppBar 之间的差距 + color: Colors.pink, child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - IconButton(icon: Icon(Icons.menu), onPressed: () {},), - IconButton(icon: Icon(Icons.search), onPressed: () {},), + IconButton( + icon: Icon(Icons.menu), + onPressed: () {}, + ), + IconButton( + icon: Icon(Icons.search), + onPressed: () {}, + ), ], ), ), - ) - ); -}} \ No newline at end of file + )); + } +} diff --git a/lib/widgets/components/Bar/BottomAppBar/index.dart b/lib/widgets/components/Bar/BottomAppBar/index.dart index 132e2ef1..962695d2 100644 --- a/lib/widgets/components/Bar/BottomAppBar/index.dart +++ b/lib/widgets/components/Bar/BottomAppBar/index.dart @@ -11,19 +11,15 @@ import 'package:flutter/material.dart'; import './demo.dart' as BottomAppBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > BottomAppBar “底部应用栏” - 一个通常与 Scaffold.bottomNavigationBar 一起使用的容器,可以在顶部有一个凹口,为重叠的FloatingActionButton腾出空间; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 通常与 Scaffold 和 FloatingActionButton 一起使用; """; - class Demo extends StatefulWidget { static const String routeName = '/components//Bar/BottomAppBar'; @@ -38,7 +34,8 @@ class _DemoState extends State { title: 'BottomAppBar', codeUrl: 'components/Bar/BottomAppBar/demo.dart', contentList: allDomes(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/BottomAppBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/BottomAppBar-class.html', ); } } @@ -56,6 +53,3 @@ List allDomes(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - - - diff --git a/lib/widgets/components/Bar/ButtonBar/demo.dart b/lib/widgets/components/Bar/ButtonBar/demo.dart index fb78c633..e4a0d11f 100644 --- a/lib/widgets/components/Bar/ButtonBar/demo.dart +++ b/lib/widgets/components/Bar/ButtonBar/demo.dart @@ -20,8 +20,8 @@ class _ButtonBarFullDefault extends State { @override Widget build(BuildContext context) { return ButtonBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -30,37 +30,61 @@ class ButtonBarLessDefault extends StatelessWidget { final widget; final parent; - const ButtonBarLessDefault([this.widget, this.parent]) - : super(); + const ButtonBarLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(vertical: 0.0), + margin: EdgeInsets.symmetric(vertical: 0.0), height: 100.0, - child: Scrollbar(child:ListView( - scrollDirection: Axis.horizontal, // 水平listView - children: [ + child: Scrollbar( + child: ListView(scrollDirection: Axis.horizontal, // 水平listView + children: [ ButtonBar( - alignment: MainAxisAlignment.spaceAround, //布局方向,默认MainAxisAlignment.end + alignment: MainAxisAlignment + .spaceAround, //布局方向,默认MainAxisAlignment.end mainAxisSize: MainAxisSize.max, //主轴大小,默认MainAxisSize.max - children: [ // Button集合 - RaisedButton(child: Text('ButtonBar1'),color: Colors.red,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar2'),color: Colors.red,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar3'),color: Colors.red,onPressed: ()=>{},), + children: [ + // Button集合 + RaisedButton( + child: Text('ButtonBar1'), + color: Colors.red, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar2'), + color: Colors.red, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar3'), + color: Colors.red, + onPressed: () => {}, + ), ], ), ButtonBar( alignment: MainAxisAlignment.end, //布局方向,默认MainAxisAlignment.end mainAxisSize: MainAxisSize.min, //主轴大小,默认MainAxisSize.max - children: [ // Button集合 - RaisedButton(child: Text('ButtonBar1'),color: Colors.yellow,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar2'),color: Colors.yellow,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar3'),color: Colors.yellow,onPressed: ()=>{},), + children: [ + // Button集合 + RaisedButton( + child: Text('ButtonBar1'), + color: Colors.yellow, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar2'), + color: Colors.yellow, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar3'), + color: Colors.yellow, + onPressed: () => {}, + ), ], ) - ] - ) - )); + ]))); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/ButtonBar/index.dart b/lib/widgets/components/Bar/ButtonBar/index.dart index 5078804c..fb55c737 100644 --- a/lib/widgets/components/Bar/ButtonBar/index.dart +++ b/lib/widgets/components/Bar/ButtonBar/index.dart @@ -11,22 +11,18 @@ import 'package:flutter/material.dart'; import './demo.dart' as ButtonBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ButtonBar “末端对齐的按钮容器” - 横排的Button布局 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 根据当前 ButtonTheme 中的填充水平放置 button - 子 button 在布置行与 MainAxisAlignment.end; - 当 Directionality为TextDirection.ltr 时,按钮栏的子项右对齐,最后一个子项成为最右边的子项; - 当 Directionality TextDirection.rtl 时,子项被左对齐,最后一个子项成为最左边的子项; """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/ButtonBar'; @@ -58,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) { ButtonBarDemo.ButtonBarLessDefault() ]; } - diff --git a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart index 078a25b3..bee24fa3 100644 --- a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart +++ b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart @@ -4,28 +4,24 @@ /// Time: 下午10:38 /// email: zhu.yan@alibaba-inc.com /// target: FlexibleSpaceBar 的示例 - + import 'package:flutter_go/components/widget_demo.dart'; import 'package:flutter/material.dart'; import './demo.dart' as FlexibleSpaceBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > FlexibleSpaceBar “扩展和折叠的应用栏” - AppBar 的一部分,可以扩展和折叠; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 最常用于 SliverAppBar.flexibleSpace 字段 - 灵活的空格键随着应用滚动而扩展和收缩,以便 AppBar 从应用程序的顶部到达应用程序滚动内容的顶部; - 要调整 AppBar 大小,必须将其包装在 FlexibleSpaceBar.createSettings 返回的 widget 中 ,以将大小调整信息传递给 FlexibleSpaceBar; """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/FlexibleSpaceBar'; @@ -40,7 +36,8 @@ class _DemoState extends State { title: 'FlexibleSpaceBar', codeUrl: 'components/Bar/FlexibleSpaceBar/demo.dart', contentList: allDomes(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html', ); } } @@ -58,4 +55,3 @@ List allDomes(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - diff --git a/lib/widgets/components/Bar/SliverAppBar/demo.dart b/lib/widgets/components/Bar/SliverAppBar/demo.dart index dec30849..1689e769 100644 --- a/lib/widgets/components/Bar/SliverAppBar/demo.dart +++ b/lib/widgets/components/Bar/SliverAppBar/demo.dart @@ -20,8 +20,8 @@ class _SliverAppBarFullDefault extends State { @override Widget build(BuildContext context) { return SliverAppBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -36,9 +36,9 @@ class SliverAppBarLessDefault extends StatelessWidget { @override Widget build(BuildContext context) { for (int i = 0; i < 20; i++) { - listData.add( ListItem("我是测试标题$i", Icons.cake)); + listData.add(ListItem("我是测试标题$i", Icons.cake)); } - return SizedBox( + return SizedBox( height: 500.0, child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -56,15 +56,16 @@ class SliverAppBarLessDefault extends StatelessWidget { //iconTheme, // 图标主题,App bar 上图标的颜色、透明度、和尺寸信息。默认值为 ThemeData.primaryIconTheme //textTheme, //文字主题, App bar 上的文字样式。默认值为 ThemeData.primaryTextTheme //centerTitle, //标题是否居中, 标题是否居中显示,默认值根据不同的操作系统,显示方式不一样 - primary: true, //是否预留高度 - forceElevated:false, - automaticallyImplyLeading:true, + primary: true, //是否预留高度 + forceElevated: false, + automaticallyImplyLeading: true, titleSpacing: NavigationToolbar.kMiddleSpacing, - snap:false, //与floating结合使用 - expandedHeight: 200.0,//展开高度 - floating: false,//是否随着滑动隐藏标题 - pinned: true,//是否固定在顶部 - flexibleSpace: FlexibleSpaceBar( //可以展开区域,通常是一个FlexibleSpaceBar + snap: false, //与floating结合使用 + expandedHeight: 200.0, //展开高度 + floating: false, //是否随着滑动隐藏标题 + pinned: true, //是否固定在顶部 + flexibleSpace: FlexibleSpaceBar( + //可以展开区域,通常是一个FlexibleSpaceBar centerTitle: true, title: Text("我是一个帅气的标题", style: TextStyle( @@ -78,30 +79,30 @@ class SliverAppBarLessDefault extends StatelessWidget { fit: BoxFit.fill, )), ), - // SliverPersistentHeader( - // delegate: _SliverAppBarDelegate( - // TabBar( - // controller: TabController(length: 2, vsync: this), - // labelColor: Colors.black87, - // unselectedLabelColor: Colors.grey, - // tabs: [ - // Tab(icon: Icon(Icons.security), text: "security"), - // Tab(icon: Icon(Icons.cake), text: "cake"), - // ], - // ), - // )) + // SliverPersistentHeader( + // delegate: _SliverAppBarDelegate( + // TabBar( + // controller: TabController(length: 2, vsync: this), + // labelColor: Colors.black87, + // unselectedLabelColor: Colors.grey, + // tabs: [ + // Tab(icon: Icon(Icons.security), text: "security"), + // Tab(icon: Icon(Icons.cake), text: "cake"), + // ], + // ), + // )) ]; - }, - body: Center( - child: ListView.builder( - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return ListItemWidget(listData[index]); }, - itemCount: listData.length, - ), - ), - )); + body: Center( + child: ListView.builder( + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return ListItemWidget(listData[index]); + }, + itemCount: listData.length, + ), + ), + )); } } @@ -119,13 +120,12 @@ class ListItemWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return InkWell( - child: ListTile( - leading: Icon(listItem.iconData), - title: Text(listItem.title), + return InkWell( + child: ListTile( + leading: Icon(listItem.iconData), + title: Text(listItem.title), ), onTap: () {}, ); } } - diff --git a/lib/widgets/components/Bar/SliverAppBar/index.dart b/lib/widgets/components/Bar/SliverAppBar/index.dart index 9ca28d7f..9a70c5f8 100644 --- a/lib/widgets/components/Bar/SliverAppBar/index.dart +++ b/lib/widgets/components/Bar/SliverAppBar/index.dart @@ -11,15 +11,12 @@ import 'package:flutter/material.dart'; import './demo.dart' as SliverAppBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > SliverAppBar “应用栏” - 它类似于Android中的toolbar; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 虽然基本相同,构造方法也是非常的简单,但是却不能直接使用它,由官方文档可以看到通常结合 ScrollView 来使用它; - AppBar 和 SliverAppBar 都是继承StatefulWidget 类,都代表 Toobar; - 二者的区别在于 AppBar 位置的固定的应用最上面的;而 SliverAppBar 是可以跟随内容滚动的; @@ -57,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) { SliverAppBarDemo.SliverAppBarLessDefault() ]; } - diff --git a/lib/widgets/components/Bar/SnackBar/demo.dart b/lib/widgets/components/Bar/SnackBar/demo.dart index 0f463371..90f9c73a 100644 --- a/lib/widgets/components/Bar/SnackBar/demo.dart +++ b/lib/widgets/components/Bar/SnackBar/demo.dart @@ -12,48 +12,47 @@ class SnackBarLessDefault extends StatelessWidget { final widget; final parent; - const SnackBarLessDefault([this.widget, this.parent]) - : super(); + const SnackBarLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { // 当BuildContext在Scaffold之前时,调用Scaffold.of(context)会报错。这时可以通过Builder Widget来解决 - return Center( - child: Column( - children: [ - GestureDetector( - onTap: () { - final snackBar = SnackBar( - content: Text('这是一个SnackBar, 右侧有SnackBarAction'), - backgroundColor:Colors.red, - action: SnackBarAction( // 提示信息上添加一个撤消的按钮 - textColor:Colors.black, - label: '撤消', - onPressed: () { - // Some code to undo the change! - }, - ), - duration:Duration(minutes: 1),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('显示SnackBar'), - ), - GestureDetector( - onTap: () { - final snackBar = SnackBar( - content: Text('右侧无SnackBarAction'), - backgroundColor:Colors.red, - duration:Duration(minutes: 1),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('显示无SnackBarAction的SnackBar'), - ), - ], - ) - ); + return Center( + child: Column( + children: [ + GestureDetector( + onTap: () { + final snackBar = SnackBar( + content: Text('这是一个SnackBar, 右侧有SnackBarAction'), + backgroundColor: Colors.red, + action: SnackBarAction( + // 提示信息上添加一个撤消的按钮 + textColor: Colors.black, + label: '撤消', + onPressed: () { + // Some code to undo the change! + }, + ), + duration: Duration(minutes: 1), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('显示SnackBar'), + ), + GestureDetector( + onTap: () { + final snackBar = SnackBar( + content: Text('右侧无SnackBarAction'), + backgroundColor: Colors.red, + duration: Duration(minutes: 1), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('显示无SnackBarAction的SnackBar'), + ), + ], + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/SnackBar/index.dart b/lib/widgets/components/Bar/SnackBar/index.dart index e476237b..f4d91ef0 100644 --- a/lib/widgets/components/Bar/SnackBar/index.dart +++ b/lib/widgets/components/Bar/SnackBar/index.dart @@ -9,21 +9,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as SnackBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > SnackBar “屏幕底部消息” - 带有可选操作的轻量级消息,短暂显示在屏幕底部 - SnackBar是用户操作后,显示提示信息的一个控件,类似Toast,会自动隐藏; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > Scaffold.of(context).showSnackBar(),传递描述消息的 SnackBar 实例; - 要控制SnackBar保持可见的时间,请指定持续时间。 """; - class Demo extends StatefulWidget { static const String routeName = '/components//Bar/SnackBar'; @@ -55,4 +51,4 @@ List allDomes(BuildContext context, _DemoState that) { SnackBarDemo.SnackBarLessDefault(), SizedBox(height: 20.0), // 间距 ]; -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/SnackBarAction/demo.dart b/lib/widgets/components/Bar/SnackBarAction/demo.dart index 9db5b0a6..fe432316 100644 --- a/lib/widgets/components/Bar/SnackBarAction/demo.dart +++ b/lib/widgets/components/Bar/SnackBarAction/demo.dart @@ -13,44 +13,42 @@ class SnackBarActionDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { - return Center( - child: Column( - children: [ - new RaisedButton( - onPressed: () { - final snackBar = new SnackBar( - content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'), - backgroundColor:Color(0xffc91b3a), - action: SnackBarAction( // 提示信息上添加一个撤消的按钮 - textColor:Colors.white, - label: '撤消', - onPressed: () { - // Some code to undo the change! - }, - ), - duration:Duration(seconds: 3),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - - child: Text('点我显示有action的SnackBar'), - ), - new RaisedButton( - onPressed: () async { - final snackBar = new SnackBar( - content: new Text('右侧无SnackBarAction, 3秒后消失'), - backgroundColor:Color(0xffc91b3a), - duration:Duration(seconds: 3),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('点我显示无SnackBarAction的SnackBar'), - ), - ], - ) - ); + return Center( + child: Column( + children: [ + new RaisedButton( + onPressed: () { + final snackBar = new SnackBar( + content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'), + backgroundColor: Color(0xffc91b3a), + action: SnackBarAction( + // 提示信息上添加一个撤消的按钮 + textColor: Colors.white, + label: '撤消', + onPressed: () { + // Some code to undo the change! + }, + ), + duration: Duration(seconds: 3), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('点我显示有action的SnackBar'), + ), + new RaisedButton( + onPressed: () async { + final snackBar = new SnackBar( + content: new Text('右侧无SnackBarAction, 3秒后消失'), + backgroundColor: Color(0xffc91b3a), + duration: Duration(seconds: 3), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('点我显示无SnackBarAction的SnackBar'), + ), + ], + )); } - } diff --git a/lib/widgets/components/Bar/SnackBarAction/index.dart b/lib/widgets/components/Bar/SnackBarAction/index.dart index 7920ea7c..158b27e1 100644 --- a/lib/widgets/components/Bar/SnackBarAction/index.dart +++ b/lib/widgets/components/Bar/SnackBarAction/index.dart @@ -22,7 +22,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/SnackBarAction'; @@ -40,7 +39,8 @@ class _DemoState extends State { _Text0, SnackBarDemo.SnackBarActionDemo(), ], - docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', ); } } diff --git a/lib/widgets/components/Bar/TabBar/demo.dart b/lib/widgets/components/Bar/TabBar/demo.dart index 6b706862..3e41c004 100644 --- a/lib/widgets/components/Bar/TabBar/demo.dart +++ b/lib/widgets/components/Bar/TabBar/demo.dart @@ -22,8 +22,9 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin { @override void initState() { super.initState(); - _scrollViewController = ScrollController(); - _tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应 + _scrollViewController = ScrollController(); + _tabController = + TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应 } @override @@ -38,36 +39,35 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( - height: 500, - child: Scaffold( - appBar: AppBar( // 大量配置属性参考 SliverAppBar 示例 - title: Text('TabBar'), - leading: Icon(Icons.home), - backgroundColor: Colors.amber[1000], - bottom: TabBar( - isScrollable: true, - controller: _tabController, - tabs: [ - Tab(text: "Tabs 1"), - Tab(text: "Tabs 2"), - Tab(text: "Tabs 3"), - Tab(text: "Tabs 4"), - Tab(text: "Tabs 5"), - Tab(text: "Tabs 6"), - ], + return SizedBox( + height: 500, + child: Scaffold( + appBar: AppBar( + // 大量配置属性参考 SliverAppBar 示例 + title: Text('TabBar'), + leading: Icon(Icons.home), + backgroundColor: Colors.amber[1000], + bottom: TabBar( + isScrollable: true, + controller: _tabController, + tabs: [ + Tab(text: "Tabs 1"), + Tab(text: "Tabs 2"), + Tab(text: "Tabs 3"), + Tab(text: "Tabs 4"), + Tab(text: "Tabs 5"), + Tab(text: "Tabs 6"), + ], + ), ), - ), - body: TabBarView(controller: _tabController, children: [ - Text('TabsView 1'), - Text('TabsView 2'), - Text('TabsView 3'), - Text('TabsView 4'), - Text('TabsView 5'), - Text('TabsView 6'), - ]), - ) - - ); + body: TabBarView(controller: _tabController, children: [ + Text('TabsView 1'), + Text('TabsView 2'), + Text('TabsView 3'), + Text('TabsView 4'), + Text('TabsView 5'), + Text('TabsView 6'), + ]), + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/TabBar/index.dart b/lib/widgets/components/Bar/TabBar/index.dart index f4c16731..c17e6edb 100644 --- a/lib/widgets/components/Bar/TabBar/index.dart +++ b/lib/widgets/components/Bar/TabBar/index.dart @@ -43,7 +43,6 @@ const String _Text0 = """ - controller TabController对象 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/TabBar'; @@ -57,11 +56,9 @@ class _DemoState extends State { return WidgetDemo( title: 'TabBar', codeUrl: 'components/Bar/TabBar/demo.dart', - contentList: [ - _Text0, - TabBarDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', + contentList: [_Text0, TabBarDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', ); } } diff --git a/lib/widgets/components/Bar/index.dart b/lib/widgets/components/Bar/index.dart index b93f7f68..f428d19c 100644 --- a/lib/widgets/components/Bar/index.dart +++ b/lib/widgets/components/Bar/index.dart @@ -17,8 +17,6 @@ import 'SnackBar/index.dart' as SnackBar; import 'SnackBarAction/index.dart' as SnackBarAction; import 'TabBar/index.dart' as TabBar; - - List widgetPoints = [ WidgetPoint( name: 'AppBar', diff --git a/lib/widgets/components/Card/Card/demo.dart b/lib/widgets/components/Card/Card/demo.dart index 3a1d4269..6a26af21 100644 --- a/lib/widgets/components/Card/Card/demo.dart +++ b/lib/widgets/components/Card/Card/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - /// Checkbox 默认Card的实例 class CardFullDefault extends StatefulWidget { const CardFullDefault() : super(); @@ -16,14 +15,13 @@ class CardFullDefault extends StatefulWidget { State createState() => _CardFullDefault(); } - /// Card 默认的实例,有状态 class _CardFullDefault extends State { @override Widget build(BuildContext context) { return Card( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -32,41 +30,48 @@ class CardLessDefault extends StatelessWidget { final widget; final parent; - const CardLessDefault([this.widget, this.parent]) - : super(); + const CardLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return Card( - clipBehavior:Clip.antiAlias,// 根据设置裁剪内容 - color:Colors.green, // 卡片背景颜色 - elevation:20.0, // 卡片的z坐标,控制卡片下面的阴影大小 - margin:EdgeInsets.all(20.0), + clipBehavior: Clip.antiAlias, // 根据设置裁剪内容 + color: Colors.green, // 卡片背景颜色 + elevation: 20.0, // 卡片的z坐标,控制卡片下面的阴影大小 + margin: EdgeInsets.all(20.0), // margin: EdgeInsetsDirectional.only(bottom: 30.0, top: 30.0, start: 30.0),// 边距 - semanticContainer:true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget + semanticContainer: + true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget // shape: Border.all( // color: Colors.indigo, width: 1.0, style: BorderStyle.solid), // 卡片材质的形状,以及边框 - shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), // 圆角 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0)), // 圆角 //borderRadius: BorderRadius.all(Radius.circular(8.0)), - child: Column( //card里面的子控件 + child: Column( + //card里面的子控件 mainAxisSize: MainAxisSize.min, children: [ const ListTile( leading: Icon(Icons.access_time), - title: Text('The Enchanted Nightingale',style: TextStyle(color: Colors.white, fontSize: 40.0)), - subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.',style: TextStyle(color: Colors.yellow, fontSize: 16.0)), - contentPadding: EdgeInsets.all(20.0),// item 内容内边距 + title: Text('The Enchanted Nightingale', + style: TextStyle(color: Colors.white, fontSize: 40.0)), + subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.', + style: TextStyle(color: Colors.yellow, fontSize: 16.0)), + contentPadding: EdgeInsets.all(20.0), // item 内容内边距 ), - ButtonTheme.bar( // make buttons use the appropriate styles for cards + ButtonTheme.bar( + // make buttons use the appropriate styles for cards child: ButtonBar( children: [ FlatButton( - child: const Text('BUY TICKETS',style: TextStyle(color: Colors.black, fontSize: 14.0)), - onPressed: () { }, + child: const Text('BUY TICKETS', + style: TextStyle(color: Colors.black, fontSize: 14.0)), + onPressed: () {}, ), FlatButton( - child: const Text('LISTEN',style: TextStyle(color: Colors.black, fontSize: 14.0)), - onPressed: () { }, + child: const Text('LISTEN', + style: TextStyle(color: Colors.black, fontSize: 14.0)), + onPressed: () {}, ), ], ), @@ -75,4 +80,4 @@ class CardLessDefault extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Card/Card/index.dart b/lib/widgets/components/Card/Card/index.dart index be83fe19..c29092cf 100644 --- a/lib/widgets/components/Card/Card/index.dart +++ b/lib/widgets/components/Card/Card/index.dart @@ -10,19 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as CardDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > Card “卡片” - 卡片用于表示一些相关信息,例如相册,地理位置,用餐,联系方式等 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 此示例显示了创建卡片窗口组件,其中显示了相册信息和两个操作 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Card/Card'; @@ -42,7 +38,6 @@ class _DemoState extends State { } } - /// 所有的 Card widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget @@ -55,4 +50,3 @@ List allDomes(BuildContext context, _DemoState that) { CardDemo.CardLessDefault() ]; } - diff --git a/lib/widgets/components/Chip/Chip/demo.dart b/lib/widgets/components/Chip/Chip/demo.dart index 3ba411cb..b76e5e53 100644 --- a/lib/widgets/components/Chip/Chip/demo.dart +++ b/lib/widgets/components/Chip/Chip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 11:40:57 +/// @Date: 2018-12-18 11:40:57 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 16:50:43 diff --git a/lib/widgets/components/Chip/Chip/index.dart b/lib/widgets/components/Chip/Chip/index.dart index 709e5fac..6e0f9109 100644 --- a/lib/widgets/components/Chip/Chip/index.dart +++ b/lib/widgets/components/Chip/Chip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 11:40:57 +/// @Date: 2018-12-18 11:40:57 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 15:13:23 @@ -31,11 +31,10 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipDemo(), + ChipDemo(), ], codeUrl: 'components/Chip/Chip/demo.dart', - docUrl: - 'https://docs.flutter.io/flutter/material/Chip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/Chip-class.html', title: 'Chip'); } } diff --git a/lib/widgets/components/Chip/ChipTheme/demo.dart b/lib/widgets/components/Chip/ChipTheme/demo.dart index a764a58d..8a0650a7 100644 --- a/lib/widgets/components/Chip/ChipTheme/demo.dart +++ b/lib/widgets/components/Chip/ChipTheme/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:10 +/// @Date: 2018-12-18 15:14:10 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:15:25 @@ -15,9 +15,11 @@ class _ChipThemeDemoState extends State { @override Widget build(BuildContext context) { return ChipTheme( - data: ChipTheme.of(context).copyWith(backgroundColor:Colors.red.shade800 ), + data: + ChipTheme.of(context).copyWith(backgroundColor: Colors.red.shade800), child: ChoiceChip( - padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0), + padding: + EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0), label: Text('down'), labelStyle: TextStyle(color: Colors.white), onSelected: (bool value) { @@ -31,29 +33,28 @@ class _ChipThemeDemoState extends State { } } - // Widget build(BuildContext context) { - - // return Container( - // child: ChipTheme( - // data: ChipThemeData( - // backgroundColor: Colors.red.shade500, - // //描述颜色对比度(暗,亮,设置固定值) - // brightness : Brightness.dark, - // deleteIconColor: Colors.red.shade200, - // //背景颜色,表示它被禁用 - // disabledColor: Colors.grey.shade50, - // labelPadding: EdgeInsets.all(10.0), - // labelStyle: TextStyle(fontSize: 15.0,fontStyle: FontStyle.italic), - // padding: EdgeInsets.all(2.0), - // //用于另一种chip widget 标签样式 - // secondaryLabelStyle: TextStyle(fontSize: 20.0,fontStyle: FontStyle.normal), - // selectedColor: Colors.yellow, - // //表示已经选中度颜色 - // secondarySelectedColor: Colors.black - // // shape: - // ), - // ), - // ); +// Widget build(BuildContext context) { - - // } +// return Container( +// child: ChipTheme( +// data: ChipThemeData( +// backgroundColor: Colors.red.shade500, +// //描述颜色对比度(暗,亮,设置固定值) +// brightness : Brightness.dark, +// deleteIconColor: Colors.red.shade200, +// //背景颜色,表示它被禁用 +// disabledColor: Colors.grey.shade50, +// labelPadding: EdgeInsets.all(10.0), +// labelStyle: TextStyle(fontSize: 15.0,fontStyle: FontStyle.italic), +// padding: EdgeInsets.all(2.0), +// //用于另一种chip widget 标签样式 +// secondaryLabelStyle: TextStyle(fontSize: 20.0,fontStyle: FontStyle.normal), +// selectedColor: Colors.yellow, +// //表示已经选中度颜色 +// secondarySelectedColor: Colors.black +// // shape: +// ), +// ), +// ); + +// } diff --git a/lib/widgets/components/Chip/ChipTheme/index.dart b/lib/widgets/components/Chip/ChipTheme/index.dart index cc0814f7..7fca797d 100644 --- a/lib/widgets/components/Chip/ChipTheme/index.dart +++ b/lib/widgets/components/Chip/ChipTheme/index.dart @@ -1,7 +1,7 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:03 +/// @Date: 2018-12-18 15:14:03 /// @Last Modified by: xiaojia.dxj -/// @Last Modified time: 2018-12-18 15:14:03 +/// @Last Modified time: 2018-12-18 15:14:03 import 'package:flutter/material.dart'; @@ -32,11 +32,10 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipThemeDemo(), + ChipThemeDemo(), ], codeUrl: 'components/Chip/ChipTheme/demo.dart', - docUrl: - 'https://docs.flutter.io/flutter/material/ChipTheme-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/ChipTheme-class.html', title: 'ChipTheme'); } } diff --git a/lib/widgets/components/Chip/ChipThemeData/demo.dart b/lib/widgets/components/Chip/ChipThemeData/demo.dart index 9cb2021d..b7a2c4a2 100644 --- a/lib/widgets/components/Chip/ChipThemeData/demo.dart +++ b/lib/widgets/components/Chip/ChipThemeData/demo.dart @@ -1,8 +1,8 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:10 +/// @Date: 2018-12-18 15:14:10 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:39:41 - + import 'package:flutter/material.dart'; class ChipThemeDemo extends StatefulWidget { @@ -16,11 +16,13 @@ class _ChipThemeDemoState extends State { Widget build(BuildContext context) { return ChipTheme( data: ChipThemeData.fromDefaults( - // brightness: Brightness.dark, - labelStyle: TextStyle(fontSize: 15.0), - primaryColor: Colors.red,secondaryColor: Colors.red.shade800), + // brightness: Brightness.dark, + labelStyle: TextStyle(fontSize: 15.0), + primaryColor: Colors.red, + secondaryColor: Colors.red.shade800), child: ChoiceChip( - padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0), + padding: + EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0), label: Text('down'), onSelected: (bool value) { setState(() { @@ -32,6 +34,3 @@ class _ChipThemeDemoState extends State { ); } } - - - diff --git a/lib/widgets/components/Chip/ChipThemeData/index.dart b/lib/widgets/components/Chip/ChipThemeData/index.dart index 86c9690c..3fac0f2b 100644 --- a/lib/widgets/components/Chip/ChipThemeData/index.dart +++ b/lib/widgets/components/Chip/ChipThemeData/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:03 +/// @Date: 2018-12-18 15:14:03 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 17:38:56 @@ -32,7 +32,7 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipThemeDemo(), + ChipThemeDemo(), ], codeUrl: 'components/Chip/ChipThemeData/demo.dart', docUrl: diff --git a/lib/widgets/components/Chip/ChoiceChip/demo.dart b/lib/widgets/components/Chip/ChoiceChip/demo.dart index 3aabd30f..24da893a 100644 --- a/lib/widgets/components/Chip/ChoiceChip/demo.dart +++ b/lib/widgets/components/Chip/ChoiceChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-19 15:13:24 +/// @Date: 2018-12-19 15:13:24 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-20 19:32:10 @@ -10,41 +10,38 @@ class ChoiceChipDemo extends StatefulWidget { } class _ChoiceChipDemoState extends State { - String _selected = ''; - - List _sub=[ - 'java','web','android' -]; + String _selected = ''; - Iterable get actorWidgets sync*{ - for(String choiceSub in _sub){ - yield Padding( - padding:EdgeInsets.all(15.0) , - child: ChoiceChip( - // avatar: Icon(Icons.access_alarm,size: 20.0,color: Colors.white,), - //未选定的时候背景 - backgroundColor:Colors.red, - //被禁用得时候背景 - disabledColor: Colors.blue, - label: Text(choiceSub), - labelStyle: TextStyle(fontWeight: FontWeight.w200,fontSize: 15.0), - labelPadding: EdgeInsets.only(left: 20.0,right: 20.0), + List _sub = ['java', 'web', 'android']; - materialTapTargetSize: MaterialTapTargetSize.padded, - onSelected: (bool value) { - setState(() { - _selected = value ? choiceSub : 'Colors.red'; - }); - }, - selected: _selected == choiceSub,) - ); - + Iterable get actorWidgets sync* { + for (String choiceSub in _sub) { + yield Padding( + padding: EdgeInsets.all(15.0), + child: ChoiceChip( + // avatar: Icon(Icons.access_alarm,size: 20.0,color: Colors.white,), + //未选定的时候背景 + backgroundColor: Colors.red, + //被禁用得时候背景 + disabledColor: Colors.blue, + label: Text(choiceSub), + labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 15.0), + labelPadding: EdgeInsets.only(left: 20.0, right: 20.0), + + materialTapTargetSize: MaterialTapTargetSize.padded, + onSelected: (bool value) { + setState(() { + _selected = value ? choiceSub : 'Colors.red'; + }); + }, + selected: _selected == choiceSub, + )); } } - @override + @override Widget build(BuildContext context) { - return Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Wrap( @@ -52,9 +49,5 @@ class _ChoiceChipDemoState extends State { ), ], ); - } } - - - diff --git a/lib/widgets/components/Chip/ChoiceChip/index.dart b/lib/widgets/components/Chip/ChoiceChip/index.dart index fcc53af4..72ee7881 100644 --- a/lib/widgets/components/Chip/ChoiceChip/index.dart +++ b/lib/widgets/components/Chip/ChoiceChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-19 15:13:29 +/// @Date: 2018-12-19 15:13:29 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:22:57 @@ -30,10 +30,11 @@ class _DemoState extends State { contentList: [ content0, content1, - ChoiceChipDemo(), + ChoiceChipDemo(), ], codeUrl: 'components/Chip/ChoiceChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/ChoiceChip-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/ChoiceChip-class.html', title: 'ChoiceChip'); } } diff --git a/lib/widgets/components/Chip/FilterChip/demo.dart b/lib/widgets/components/Chip/FilterChip/demo.dart index ccac842a..9d07305c 100644 --- a/lib/widgets/components/Chip/FilterChip/demo.dart +++ b/lib/widgets/components/Chip/FilterChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 10:19:46 +/// @Date: 2018-12-20 10:19:46 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-20 14:09:31 @@ -9,46 +9,44 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class ActorFilerEntry{ +class ActorFilerEntry { final String name; final String initials; - const ActorFilerEntry(this.name,this.initials); + const ActorFilerEntry(this.name, this.initials); } - class _FilterChipDemoState extends State { - final List _list=[ + final List _list = [ const ActorFilerEntry('android', 'ad'), const ActorFilerEntry('java', 'ja'), const ActorFilerEntry('php', 'ph'), const ActorFilerEntry('web', 'wb'), ]; - List _filters=[]; - Iterable get actorWidgets sync*{ - for(ActorFilerEntry actor in _list){ + List _filters = []; + Iterable get actorWidgets sync* { + for (ActorFilerEntry actor in _list) { yield Padding( padding: const EdgeInsets.all(4.0), child: FilterChip( // avatar: CircleAvatar(child: Text(actor.initials),), label: Text(actor.name), selected: _filters.contains(actor.name), - onSelected: (bool value){ + onSelected: (bool value) { setState(() { - if(value){ - _filters.add(actor.name); - }else{ - _filters.retainWhere((String name){ - return name==actor.name; - }); - } - }); + if (value) { + _filters.add(actor.name); + } else { + _filters.retainWhere((String name) { + return name == actor.name; + }); + } + }); }, ), ); } } - @override Widget build(BuildContext context) { @@ -63,6 +61,3 @@ class _FilterChipDemoState extends State { ); } } - - - diff --git a/lib/widgets/components/Chip/FilterChip/index.dart b/lib/widgets/components/Chip/FilterChip/index.dart index eb069e7f..367e71cc 100644 --- a/lib/widgets/components/Chip/FilterChip/index.dart +++ b/lib/widgets/components/Chip/FilterChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 10:19:55 +/// @Date: 2018-12-20 10:19:55 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:25:22 diff --git a/lib/widgets/components/Chip/InputChip/demo.dart b/lib/widgets/components/Chip/InputChip/demo.dart index 04739e70..3bbe3adf 100644 --- a/lib/widgets/components/Chip/InputChip/demo.dart +++ b/lib/widgets/components/Chip/InputChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 13:32:22 +/// @Date: 2018-12-20 13:32:22 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:31:12 @@ -9,66 +9,56 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class InputEntry{ +class InputEntry { final String name; final String initials; - const InputEntry(this.name,this.initials); - + const InputEntry(this.name, this.initials); } - -class _FilterChipDemoState extends State { -final List _lists=[ +class _FilterChipDemoState extends State { + final List _lists = [ const InputEntry('android', 'A'), const InputEntry('java', 'J'), const InputEntry('php', 'P'), const InputEntry('web', 'W'), -]; + ]; -List _inputLists=[]; -Iterable get inputWidget sync*{ - for(InputEntry value in _lists){ - _inputLists.add(value); - yield Padding( - padding: const EdgeInsets.all(4.0), - child: InputChip( - avatar: CircleAvatar( - backgroundColor: Colors.redAccent.shade400, - child: Text(value.initials), + List _inputLists = []; + Iterable get inputWidget sync* { + for (InputEntry value in _lists) { + _inputLists.add(value); + yield Padding( + padding: const EdgeInsets.all(4.0), + child: InputChip( + avatar: CircleAvatar( + backgroundColor: Colors.redAccent.shade400, + child: Text(value.initials), + ), + label: Text(value.name), + onDeleted: () { + setState(() { + _lists.remove(value); + }); + }, ), - label: Text(value.name), - onDeleted: (){ - setState(() { - _lists.remove(value); - }); - - }, - - ), - ); + ); + } } -} @override Widget build(BuildContext context) { return Column( children: [ - Wrap( + Wrap( children: inputWidget.toList(), ), - // InputChip( - // label: Text('刷新'), - // onSelected: (bool value){ - - // }, - // ) - ], - - + // InputChip( + // label: Text('刷新'), + // onSelected: (bool value){ + // }, + // ) + ], ); } } - - - diff --git a/lib/widgets/components/Chip/InputChip/index.dart b/lib/widgets/components/Chip/InputChip/index.dart index f7d0a84b..4919ad95 100644 --- a/lib/widgets/components/Chip/InputChip/index.dart +++ b/lib/widgets/components/Chip/InputChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 13:32:15 +/// @Date: 2018-12-20 13:32:15 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:42:05 @@ -36,7 +36,7 @@ class _DemoState extends State { FilterChipDemo(), ], codeUrl: 'components/Chip/FilterChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/InputChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/InputChip-class.html', title: 'InputChip'); } } diff --git a/lib/widgets/components/Chip/RawChip/demo.dart b/lib/widgets/components/Chip/RawChip/demo.dart index f6d37f3b..40437c2b 100644 --- a/lib/widgets/components/Chip/RawChip/demo.dart +++ b/lib/widgets/components/Chip/RawChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:36 +/// @Date: 2018-12-20 20:30:36 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:23:21 @@ -9,56 +9,49 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class InputEntry{ +class InputEntry { final String name; final String initials; - const InputEntry(this.name,this.initials); + const InputEntry(this.name, this.initials); } - -class _FilterChipDemoState extends State { -final List _lists=[ +class _FilterChipDemoState extends State { + final List _lists = [ const InputEntry('android', 'A'), const InputEntry('java', 'J'), const InputEntry('php', 'P'), const InputEntry('web', 'W'), -]; - -Iterable get _rawChipWidget sync*{ - for(InputEntry value in _lists){ - yield Padding( - padding: const EdgeInsets.all(4.0), - child: RawChip( - avatar: CircleAvatar( - backgroundColor: Colors.redAccent.shade400, - child: Text(value.initials), + ]; + + Iterable get _rawChipWidget sync* { + for (InputEntry value in _lists) { + yield Padding( + padding: const EdgeInsets.all(4.0), + child: RawChip( + avatar: CircleAvatar( + backgroundColor: Colors.redAccent.shade400, + child: Text(value.initials), + ), + label: Text(value.name), + onDeleted: () { + // _inputs.add(value.name); + setState(() { + _lists.remove(value); + }); + }, ), - label: Text(value.name), - onDeleted: (){ - // _inputs.add(value.name); - setState(() { - _lists.remove(value); - - }); - }, - - ), - ); + ); + } } -} @override Widget build(BuildContext context) { return Column( children: [ - Wrap( + Wrap( children: _rawChipWidget.toList(), ), - ], ); } } - - - diff --git a/lib/widgets/components/Chip/RawChip/index.dart b/lib/widgets/components/Chip/RawChip/index.dart index c57c49ca..d38bea13 100644 --- a/lib/widgets/components/Chip/RawChip/index.dart +++ b/lib/widgets/components/Chip/RawChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:35:51 @@ -40,7 +40,7 @@ class _DemoState extends State { FilterChipDemo(), ], codeUrl: 'components/Chip/RawChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Dialog/AboutDialog/demo.dart b/lib/widgets/components/Dialog/AboutDialog/demo.dart index 5f980907..cd53dae2 100644 --- a/lib/widgets/components/Dialog/AboutDialog/demo.dart +++ b/lib/widgets/components/Dialog/AboutDialog/demo.dart @@ -12,26 +12,23 @@ class AboutDialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, - builder: (_) => AboutDialog( - applicationName: '名称', - applicationIcon: Icon(Icons.ac_unit), - applicationVersion: 'V1.0', - children: [ - Text('我是一个关于的dialog') - ] - )); + builder: (_) => AboutDialog( + applicationName: '名称', + applicationIcon: Icon(Icons.ac_unit), + applicationVersion: 'V1.0', + children: [Text('我是一个关于的dialog')])); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( 'show aboutDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -42,6 +39,6 @@ class _Demo extends State { splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } } diff --git a/lib/widgets/components/Dialog/AboutDialog/index.dart b/lib/widgets/components/Dialog/AboutDialog/index.dart index 718b582b..77d0cc82 100644 --- a/lib/widgets/components/Dialog/AboutDialog/index.dart +++ b/lib/widgets/components/Dialog/AboutDialog/index.dart @@ -23,7 +23,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/AboutDialog'; @@ -37,10 +36,7 @@ class _DemoState extends State { return WidgetDemo( title: 'AboutDialog', codeUrl: 'components/Dialog/AboutDialog/demo.dart', - contentList: [ - _Text0, - AboutDialogDemo() - ], + contentList: [_Text0, AboutDialogDemo()], docUrl: 'https://docs.flutter.io/flutter/material/AboutDialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/AlertDialog/demo.dart b/lib/widgets/components/Dialog/AlertDialog/demo.dart index 616aa135..f765c549 100644 --- a/lib/widgets/components/Dialog/AlertDialog/demo.dart +++ b/lib/widgets/components/Dialog/AlertDialog/demo.dart @@ -7,8 +7,7 @@ import 'package:flutter/material.dart'; -class AlertDialogDemo extends StatelessWidget{ - +class AlertDialogDemo extends StatelessWidget { void showAlertDialog(BuildContext context) { showDialog( context: context, @@ -98,7 +97,6 @@ class AlertDialogDemo extends StatelessWidget{ Text('too long~~~'), Text('too long~~~'), Text('too long~~~'), - ], ), ), @@ -114,13 +112,14 @@ class AlertDialogDemo extends StatelessWidget{ }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( '点我显示 AlertDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -131,7 +130,6 @@ class AlertDialogDemo extends StatelessWidget{ splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } } - diff --git a/lib/widgets/components/Dialog/AlertDialog/index.dart b/lib/widgets/components/Dialog/AlertDialog/index.dart index a067842c..f4d00295 100644 --- a/lib/widgets/components/Dialog/AlertDialog/index.dart +++ b/lib/widgets/components/Dialog/AlertDialog/index.dart @@ -22,7 +22,6 @@ const String _Text0 = """ - 当需要给用户提供多个选项的供选择时,请使用SimpleDialog """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/AlertDialog'; @@ -36,10 +35,7 @@ class _DemoState extends State { return WidgetDemo( title: 'AlertDialog', codeUrl: 'components/Dialog/AlertDialog/demo.dart', - contentList: [ - _Text0, - AlertDialogDemo() - ], + contentList: [_Text0, AlertDialogDemo()], docUrl: 'https://docs.flutter.io/flutter/material/AlertDialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/Dialog/demo.dart b/lib/widgets/components/Dialog/Dialog/demo.dart index 31d1385c..328f35d4 100644 --- a/lib/widgets/components/Dialog/Dialog/demo.dart +++ b/lib/widgets/components/Dialog/Dialog/demo.dart @@ -12,39 +12,38 @@ class DialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return Dialog( - child: Container( - height: 100, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text('我是一个dialog'), - RaisedButton( - child: Text('取消'), - onPressed: () { - Navigator.of(context).pop(); - }, - ) - ], - ), - ) - ); + child: Container( + height: 100, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text('我是一个dialog'), + RaisedButton( + child: Text('取消'), + onPressed: () { + Navigator.of(context).pop(); + }, + ) + ], + ), + )); }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( '点我显示 Dialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -59,7 +58,6 @@ class _Demo extends State { } } - class DialogMoreDemo extends StatefulWidget { _DialogMoreDemo createState() => _DialogMoreDemo(); } @@ -68,11 +66,10 @@ class _DialogMoreDemo extends State { int value = 0; void showCommonDialog(BuildContext context) { showDialog( - context: context, - barrierDismissible: false, // user must tap button! - builder: (context) { - return StatefulBuilder( - builder: (context, state) { + context: context, + barrierDismissible: false, // user must tap button! + builder: (context) { + return StatefulBuilder(builder: (context, state) { return Dialog( child: Container( height: 150, @@ -86,47 +83,43 @@ class _DialogMoreDemo extends State { value += 1; }); }, - child: Text("我是一个Dialog, 点我更新value: $value"), + child: Text("我是一个Dialog, 点我更新value: $value"), ), RaisedButton( onPressed: () { - Navigator.of(context).pop(); + Navigator.of(context).pop(); }, - child: Text("取消"), + child: Text("取消"), ) ], ), ), - ); - } - ); - } - ); + }); + }); } + Widget build(BuildContext context) { - return Column( + return Column( children: [ - RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), - //padding - child: Text( - '点我显示Dialog', - style: TextStyle( - fontSize: 18.0, //textsize - color: Colors.white, // textcolor - ), - ), - color: Theme.of(context).accentColor, - elevation: 4.0, - //shadow - splashColor: Colors.blueGrey, - onPressed: () { - showCommonDialog(context); - } - ) + RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + //padding + child: Text( + '点我显示Dialog', + style: TextStyle( + fontSize: 18.0, //textsize + color: Colors.white, // textcolor + ), + ), + color: Theme.of(context).accentColor, + elevation: 4.0, + //shadow + splashColor: Colors.blueGrey, + onPressed: () { + showCommonDialog(context); + }) ], ); } } - diff --git a/lib/widgets/components/Dialog/Dialog/index.dart b/lib/widgets/components/Dialog/Dialog/index.dart index 8df84a94..4bd90c0f 100644 --- a/lib/widgets/components/Dialog/Dialog/index.dart +++ b/lib/widgets/components/Dialog/Dialog/index.dart @@ -30,7 +30,6 @@ const String _Text1 = """ 注意事项: 当前弹出的dialog并非是一个单纯的组件, 而是一个新路由界面, 如果我想通过操作dialog中的内容, 直接使用setState触发的是原界面中的状态 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/Dialog'; @@ -44,12 +43,7 @@ class _DemoState extends State { return WidgetDemo( title: 'Dialog', codeUrl: 'components/Dialog/Dialog/demo.dart', - contentList: [ - _Text0, - DialogDemo(), - _Text1, - DialogMoreDemo() - ], + contentList: [_Text0, DialogDemo(), _Text1, DialogMoreDemo()], docUrl: 'https://docs.flutter.io/flutter/material/Dialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/SimpleDialog/demo.dart b/lib/widgets/components/Dialog/SimpleDialog/demo.dart index 58f41ad1..5bfcd91f 100644 --- a/lib/widgets/components/Dialog/SimpleDialog/demo.dart +++ b/lib/widgets/components/Dialog/SimpleDialog/demo.dart @@ -12,22 +12,21 @@ class SimpleDialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { - return SimpleDialog( - title: Text('选择'), + return SimpleDialog( + title: Text('选择'), children: [ - SimpleDialogOption( - child: Text('选项 1'), + SimpleDialogOption( + child: Text('选项 1'), onPressed: () { Navigator.of(context).pop(); }, ), - SimpleDialogOption( - child: Text('选项 2'), + SimpleDialogOption( + child: Text('选项 2'), onPressed: () { Navigator.of(context).pop(); }, @@ -37,13 +36,14 @@ class _Demo extends State { }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( 'show SimpleDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -54,7 +54,6 @@ class _Demo extends State { splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } - } diff --git a/lib/widgets/components/Dialog/SimpleDialog/index.dart b/lib/widgets/components/Dialog/SimpleDialog/index.dart index 44a94023..9014fd57 100644 --- a/lib/widgets/components/Dialog/SimpleDialog/index.dart +++ b/lib/widgets/components/Dialog/SimpleDialog/index.dart @@ -25,7 +25,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/SimpleDialog'; @@ -39,11 +38,9 @@ class _DemoState extends State { return WidgetDemo( title: 'SimpleDialog', codeUrl: 'components/Dialog/SimpleDialog/demo.dart', - contentList: [ - _Text0, - SimpleDialogDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SimpleDialog-class.html', + contentList: [_Text0, SimpleDialogDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SimpleDialog-class.html', ); } } diff --git a/lib/widgets/components/Grid/GridPaper/demo.dart b/lib/widgets/components/Grid/GridPaper/demo.dart index 129f9324..57e91191 100644 --- a/lib/widgets/components/Grid/GridPaper/demo.dart +++ b/lib/widgets/components/Grid/GridPaper/demo.dart @@ -12,48 +12,86 @@ class GridPaperDemo extends StatefulWidget { } class _Demo extends State { - - Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - GridPaper( - color: Colors.red, - child: Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + GridPaper( + color: Colors.red, + child: Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridPaper/index.dart b/lib/widgets/components/Grid/GridPaper/index.dart index abc6eabc..8ec33d4d 100644 --- a/lib/widgets/components/Grid/GridPaper/index.dart +++ b/lib/widgets/components/Grid/GridPaper/index.dart @@ -16,8 +16,6 @@ const String _Text0 = """ """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridPaper'; diff --git a/lib/widgets/components/Grid/GridTile/demo.dart b/lib/widgets/components/Grid/GridTile/demo.dart index 06e3fcec..4a16c0fc 100644 --- a/lib/widgets/components/Grid/GridTile/demo.dart +++ b/lib/widgets/components/Grid/GridTile/demo.dart @@ -14,40 +14,87 @@ class GridTileDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: Text("GridTile header", style: TextStyle(color: Colors.white)), - child: Container( - padding: EdgeInsets.fromLTRB(0, 30, 0, 0), - child: Text("GridTile child", style: TextStyle(color: Colors.white)), + children: [ + GridTile( + header: Text("GridTile header", + style: TextStyle(color: Colors.white)), + child: Container( + padding: EdgeInsets.fromLTRB(0, 30, 0, 0), + child: Text("GridTile child", + style: TextStyle(color: Colors.white)), + ), + footer: Text("GridTile footer", + style: TextStyle(color: Colors.white)), ), - footer: Text("GridTile footer", style: TextStyle(color: Colors.white)), - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridTile/index.dart b/lib/widgets/components/Grid/GridTile/index.dart index 1f4f809f..d605c9f5 100644 --- a/lib/widgets/components/Grid/GridTile/index.dart +++ b/lib/widgets/components/Grid/GridTile/index.dart @@ -22,8 +22,6 @@ const String _Text0 = """ 如下实例中, 第一个是item便是GridTile组件构成. 包含header, body, footer; """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridTile'; diff --git a/lib/widgets/components/Grid/GridTileBar/demo.dart b/lib/widgets/components/Grid/GridTileBar/demo.dart index 22628299..a67c30fe 100644 --- a/lib/widgets/components/Grid/GridTileBar/demo.dart +++ b/lib/widgets/components/Grid/GridTileBar/demo.dart @@ -14,42 +14,85 @@ class GridTileDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridTileBar/index.dart b/lib/widgets/components/Grid/GridTileBar/index.dart index 3579656b..b6e223f4 100644 --- a/lib/widgets/components/Grid/GridTileBar/index.dart +++ b/lib/widgets/components/Grid/GridTileBar/index.dart @@ -26,8 +26,6 @@ const String _Text0 = """ - trailing GridTileBar右侧的widgett, 通常我们用来做交互操作类的组件 """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridTileBar'; diff --git a/lib/widgets/components/Grid/GridView/demo.dart b/lib/widgets/components/Grid/GridView/demo.dart index 6246c433..b39e6746 100644 --- a/lib/widgets/components/Grid/GridView/demo.dart +++ b/lib/widgets/components/Grid/GridView/demo.dart @@ -12,50 +12,91 @@ class GridTileDemo extends StatefulWidget { } class _Demo extends State { - Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } - class GridViewDemo extends StatelessWidget { @override Widget build(BuildContext context) { @@ -64,24 +105,46 @@ class GridViewDemo extends StatelessWidget { color: Color(0xffc91b3a), child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - ///列数 - crossAxisCount: 3, - ///列间距 - mainAxisSpacing: 10.0, - ///横轴距离 - crossAxisSpacing: 4.0, - ///缩放比例 - childAspectRatio: 1.3,), - padding: const EdgeInsets.only(left: 10,right: 10,top: 10), + ///列数 + crossAxisCount: 3, + + ///列间距 + mainAxisSpacing: 10.0, + + ///横轴距离 + crossAxisSpacing: 4.0, + + ///缩放比例 + childAspectRatio: 1.3, + ), + padding: const EdgeInsets.only(left: 10, right: 10, top: 10), children: [ - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ],), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + ), ); } - -} \ No newline at end of file +} diff --git a/lib/widgets/components/Grid/GridView/index.dart b/lib/widgets/components/Grid/GridView/index.dart index d00925e9..9e6e6813 100644 --- a/lib/widgets/components/Grid/GridView/index.dart +++ b/lib/widgets/components/Grid/GridView/index.dart @@ -49,15 +49,13 @@ const String _Text0 = """ - GridView.extent """; -const Text1=""" +const Text1 = """ ### > SliverGridDelegateWithFixedCrossAxisCount gridDelegate: SliverGridDelegateWithFixedCrossAxisCount,实现网格 """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridView'; diff --git a/lib/widgets/components/Grid/SliverGrid/demo.dart b/lib/widgets/components/Grid/SliverGrid/demo.dart index f8bfb19a..8701849d 100644 --- a/lib/widgets/components/Grid/SliverGrid/demo.dart +++ b/lib/widgets/components/Grid/SliverGrid/demo.dart @@ -12,23 +12,22 @@ class SliverGridDemo extends StatefulWidget { } class _Demo extends State { - Widget showCustomScrollView() { - return CustomScrollView( + return CustomScrollView( slivers: [ - SliverGrid( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + SliverGrid( + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200.0, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, childAspectRatio: 4.0, ), - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return Container( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( alignment: Alignment.center, color: Colors.cyan[100 * (index % 5)], - child: Text('grid item $index'), + child: Text('grid item $index'), ); }, childCount: 20, @@ -52,9 +51,6 @@ class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: showCustomScrollView() - ); + height: 400, color: Color(0xffc91b3a), child: showCustomScrollView()); } } diff --git a/lib/widgets/components/Grid/SliverGrid/index.dart b/lib/widgets/components/Grid/SliverGrid/index.dart index c3a50dcf..e4c4a80f 100644 --- a/lib/widgets/components/Grid/SliverGrid/index.dart +++ b/lib/widgets/components/Grid/SliverGrid/index.dart @@ -26,8 +26,6 @@ const String _Text0 = """ """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/SliverGrid'; diff --git a/lib/widgets/components/List/AnimatedList/demo.dart b/lib/widgets/components/List/AnimatedList/demo.dart index a4c328f3..d7aab282 100644 --- a/lib/widgets/components/List/AnimatedList/demo.dart +++ b/lib/widgets/components/List/AnimatedList/demo.dart @@ -10,10 +10,9 @@ class AnimatedListFullDefault extends StatefulWidget { _AnimatedListFullDefault createState() => _AnimatedListFullDefault(); } - /// AnimatedList 默认的实例,有状态 class _AnimatedListFullDefault extends State { - final GlobalKey _listKey = GlobalKey(); + final GlobalKey _listKey = GlobalKey(); ListModel _list; int _selectedItem; int _nextItem; // The next item inserted when the user presses the '+' button. @@ -24,7 +23,7 @@ class _AnimatedListFullDefault extends State { if (widget.parent is State) { widget.parent.animatedList = this; // 修改父级的对象引用 } - _list = ListModel( + _list = ListModel( listKey: _listKey, initialItems: [0, 1, 2], removedItemBuilder: _buildRemovedItem, @@ -33,7 +32,8 @@ class _AnimatedListFullDefault extends State { } void insert() { - final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem); + final int index = + _selectedItem == null ? _list.length : _list.indexOf(_selectedItem); _list.insert(index, _nextItem++); } @@ -41,7 +41,7 @@ class _AnimatedListFullDefault extends State { void remove() { if (_selectedItem != null) { _list.removeAt(_list.indexOf(_selectedItem)); - if(mounted) { + if (mounted) { setState(() { _selectedItem = null; }); @@ -49,8 +49,9 @@ class _AnimatedListFullDefault extends State { } } - Widget _buildItem(BuildContext context, int index, Animation animation) { - return CardItem( + Widget _buildItem( + BuildContext context, int index, Animation animation) { + return CardItem( animation: animation, item: _list[index], selected: _selectedItem == _list[index], @@ -62,8 +63,9 @@ class _AnimatedListFullDefault extends State { ); } - Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { - return CardItem( + Widget _buildRemovedItem( + int item, BuildContext context, Animation animation) { + return CardItem( animation: animation, item: item, selected: false, @@ -75,24 +77,25 @@ class _AnimatedListFullDefault extends State { Widget build(BuildContext context) { return SizedBox( height: 500.0, - child:AnimatedList( + child: AnimatedList( //shrinkWrap: true, key: _listKey, initialItemCount: _list.length, itemBuilder: _buildItem, )); } + void methodA() {} } class CardItem extends StatelessWidget { - const CardItem({ - Key key, - @required this.animation, - this.onTap, - @required this.item, - this.selected: false - }) : assert(animation != null), + const CardItem( + {Key key, + @required this.animation, + this.onTap, + @required this.item, + this.selected: false}) + : assert(animation != null), assert(item != null && item >= 0), assert(selected != null), super(key: key); @@ -107,20 +110,20 @@ class CardItem extends StatelessWidget { TextStyle textStyle = Theme.of(context).textTheme.display1; if (selected) textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); - return Padding( + return Padding( padding: const EdgeInsets.all(2.0), - child: SizeTransition( + child: SizeTransition( axis: Axis.vertical, sizeFactor: animation, - child: GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: onTap, - child: SizedBox( + child: SizedBox( height: 128.0, - child: Card( + child: Card( color: Colors.primaries[item % Colors.primaries.length], - child: Center( - child: Text('Item $item', style: textStyle), + child: Center( + child: Text('Item $item', style: textStyle), ), ), ), @@ -128,4 +131,4 @@ class CardItem extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/AnimatedList/index.dart b/lib/widgets/components/List/AnimatedList/index.dart index 23992c1e..10548fda 100644 --- a/lib/widgets/components/List/AnimatedList/index.dart +++ b/lib/widgets/components/List/AnimatedList/index.dart @@ -13,21 +13,17 @@ import './demo.dart'; //var _AnimatedListFullDefault = AnimatedListDemo.AnimatedListFullDefault; GlobalKey globalKey = GlobalKey(); -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > AnimatedList “动画滚动容器” - 一个滚动容器,可在插入或移除项目时为其设置动画 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > AnimatedList - AnimatedListState 可用于动态插入或删除项目。 - 下面示例展示效果:点击+号增加 card, 点击 card 保持激活状态,再点击-号,减少 card。 """; - class Demo extends StatefulWidget { static const String routeName = '/components/List/AnimatedList'; @@ -48,7 +44,6 @@ class _DemoState extends State { } } - /// 所有的 AnimatedList widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget @@ -73,33 +68,28 @@ List allDemoBoxs(BuildContext context, _DemoState that) { ]; } - // 演示辅助按钮 Widget assistButtonLeft(that) { return FloatingActionButton( - // 文本内容 - backgroundColor:Colors.red, + // 文本内容 + backgroundColor: Colors.red, child: const Icon(Icons.add_circle_outline), heroTag: null, // 不加这个参数会黑屏... onPressed: () { //demo.insert(); //print('${globalKey.currentState}'); that.animatedList.insert(); - } - ); + }); } - // 演示辅助按钮 Widget assistButtonRight(that) { return FloatingActionButton( - // 文本内容 - backgroundColor:Colors.green, + // 文本内容 + backgroundColor: Colors.green, child: const Icon(Icons.remove_circle_outline), heroTag: null, // 不加这个参数会黑屏... onPressed: () { that.animatedList.remove(); - } - ); + }); } - diff --git a/lib/widgets/components/List/AnimatedList/model.dart b/lib/widgets/components/List/AnimatedList/model.dart index 3b0b3d59..b7ad33c8 100644 --- a/lib/widgets/components/List/AnimatedList/model.dart +++ b/lib/widgets/components/List/AnimatedList/model.dart @@ -12,9 +12,9 @@ class ListModel { @required this.listKey, @required this.removedItemBuilder, Iterable initialItems, - }) : assert(listKey != null), + }) : assert(listKey != null), assert(removedItemBuilder != null), - _items = List.from(initialItems ?? []); + _items = List.from(initialItems ?? []); final GlobalKey listKey; final dynamic removedItemBuilder; @@ -30,7 +30,8 @@ class ListModel { E removeAt(int index) { final E removedItem = _items.removeAt(index); if (removedItem != null) { - _animatedList.removeItem(index, (BuildContext context, Animation animation) { + _animatedList.removeItem(index, + (BuildContext context, Animation animation) { return removedItemBuilder(removedItem, context, animation); }); } @@ -40,4 +41,4 @@ class ListModel { int get length => _items.length; E operator [](int index) => _items[index]; int indexOf(E item) => _items.indexOf(item); -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListBody/demo.dart b/lib/widgets/components/List/ListBody/demo.dart index 038c69b2..7313a693 100644 --- a/lib/widgets/components/List/ListBody/demo.dart +++ b/lib/widgets/components/List/ListBody/demo.dart @@ -15,14 +15,13 @@ class ListBodyFullDefault extends StatefulWidget { State createState() => _ListBodyFullDefault(); } - /// ListBody 默认的实例,有状态 class _ListBodyFullDefault extends State { @override Widget build(BuildContext context) { return ListBody( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -31,36 +30,40 @@ class ListBodyLessDefault extends StatelessWidget { final widget; final parent; - const ListBodyLessDefault([this.widget, this.parent]) - : super(); + const ListBodyLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return ListBody( - mainAxis: Axis.vertical, // 排列的主轴方向 - reverse: false, // 是否反向 - children: [ - Container(color: Colors.red, - width: 50.0, - height: 150.0, - child: Text('标题1', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.yellow, - width: 50.0, - height: 50.0, - child: Text('标题2', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.green, - width: 50.0, - height: 50.0, - child: Text('标题3', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.blue, - width: 50.0, - height: 50.0, - child: Text('标题4', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.black, - width: 50.0, - height: 50.0, - child: Text('标题5', style: TextStyle(color: Color(0xffffffff)))) - ], - ); + mainAxis: Axis.vertical, // 排列的主轴方向 + reverse: false, // 是否反向 + children: [ + Container( + color: Colors.red, + width: 50.0, + height: 150.0, + child: Text('标题1', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.yellow, + width: 50.0, + height: 50.0, + child: Text('标题2', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.green, + width: 50.0, + height: 50.0, + child: Text('标题3', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.blue, + width: 50.0, + height: 50.0, + child: Text('标题4', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.black, + width: 50.0, + height: 50.0, + child: Text('标题5', style: TextStyle(color: Color(0xffffffff)))) + ], + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListBody/index.dart b/lib/widgets/components/List/ListBody/index.dart index 5b5bdb56..2adeffa5 100644 --- a/lib/widgets/components/List/ListBody/index.dart +++ b/lib/widgets/components/List/ListBody/index.dart @@ -11,16 +11,13 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as ListBodyDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ListBody “列表组件” - 作用是按给定的轴方向,按照顺序排列子节点。 - 是一个不常直接使用的控件,一般都会配合ListView或者Column等控件使用。 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 布局行为 - 在主轴上,子节点按照顺序进行布局,在交叉轴上,子节点尺寸会被拉伸,以适应交叉轴的区域。 - 在主轴上,给予子节点的空间必须是不受限制的(unlimited),使得子节点可以全部被容纳,ListBody不会去裁剪或者缩放其子节点。 @@ -46,7 +43,6 @@ class _DemoState extends State { } } - /// 所有的 ListBody widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/List/ListView/demo.dart b/lib/widgets/components/List/ListView/demo.dart index 4e31f69f..3373265a 100644 --- a/lib/widgets/components/List/ListView/demo.dart +++ b/lib/widgets/components/List/ListView/demo.dart @@ -15,29 +15,29 @@ class ListViewFullDefault extends StatefulWidget { State createState() => _ListViewFullDefault(); } - /// ListView 默认的实例,有状态 class _ListViewFullDefault extends State { @override Widget build(BuildContext context) { - return ListView( - ); + return ListView(); } } - /// ListView 默认的实例,无状态 class ListViewLessDefault extends StatelessWidget { final widget; final parent; final index; - const ListViewLessDefault([this.index, this.widget, this.parent,]) - : super(); + const ListViewLessDefault([ + this.index, + this.widget, + this.parent, + ]) : super(); @override Widget build(BuildContext context) { - switch(index){ + switch (index) { case 0: return ListView( shrinkWrap: true, @@ -45,18 +45,18 @@ class ListViewLessDefault extends StatelessWidget { children: [ Text('I\'m dedicating every day to you'), ListTile( - leading: Icon(Icons.map), - title: Text('Maps'), + leading: Icon(Icons.map), + title: Text('Maps'), ), Text('Domestic life was never quite my style'), ListTile( - leading: Icon(Icons.photo_album), - title: Text('Album'), + leading: Icon(Icons.photo_album), + title: Text('Album'), ), Text('When you smile, you knock me out, I fall apart'), ListTile( - leading: Icon(Icons.phone), - title: Text('Phone'), + leading: Icon(Icons.phone), + title: Text('Phone'), ), Text('And I thought I was so smart'), ], @@ -65,23 +65,27 @@ class ListViewLessDefault extends StatelessWidget { case 1: return SizedBox( height: 300.0, - child: ListView.builder( + child: ListView.builder( scrollDirection: Axis.vertical, itemCount: 10, // item 的个数 itemExtent: 50.0, // 如果为非null,则强制子项在滚动方向上具有给定范围 itemBuilder: (BuildContext context, int index) { return ListTile( - title: Text("title $index"), // item 标题 - leading: Icon(Icons.keyboard), // item 前置图标 - subtitle: Text("subtitle $index"), // item 副标题 - trailing: Icon(Icons.keyboard_arrow_right),// item 后置图标 - isThreeLine:false, // item 是否三行显示 - dense:true, // item 直观感受是整体大小 - contentPadding: EdgeInsets.all(10.0),// item 内容内边距 - enabled:true, - onTap:(){print('点击:$index');},// item onTap 点击事件 - onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 - selected:false, // item 是否选中状态 + title: Text("title $index"), // item 标题 + leading: Icon(Icons.keyboard), // item 前置图标 + subtitle: Text("subtitle $index"), // item 副标题 + trailing: Icon(Icons.keyboard_arrow_right), // item 后置图标 + isThreeLine: false, // item 是否三行显示 + dense: true, // item 直观感受是整体大小 + contentPadding: EdgeInsets.all(10.0), // item 内容内边距 + enabled: true, + onTap: () { + print('点击:$index'); + }, // item onTap 点击事件 + onLongPress: () { + print('长按:$index'); + }, // item onLongPress 长按事件 + selected: false, // item 是否选中状态 ); }, ), @@ -90,34 +94,40 @@ class ListViewLessDefault extends StatelessWidget { case 2: return SizedBox( height: 300.0, - child: ListView.separated( + child: ListView.separated( scrollDirection: Axis.vertical, itemCount: 100, // item 的个数 - separatorBuilder: (BuildContext context, int index) => Divider(height:1.0,color: Colors.blue), // 添加分割线 + separatorBuilder: (BuildContext context, int index) => + Divider(height: 1.0, color: Colors.blue), // 添加分割线 itemBuilder: (BuildContext context, int index) { return ListTile( - title: Text("title $index"), // item 标题 + title: Text("title $index"), // item 标题 leading: Icon(Icons.keyboard), // item 前置图标 subtitle: Text("subtitle $index"), // item 副标题 - trailing: Icon(Icons.keyboard_arrow_right),// item 后置图标 - isThreeLine:false, // item 是否三行显示 - dense:true, // item 直观感受是整体大小 - contentPadding: EdgeInsets.all(10.0),// item 内容内边距 - enabled:true, - onTap:(){print('点击:$index');},// item onTap 点击事件 - onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 - selected:false, // item 是否选中状态 + trailing: Icon(Icons.keyboard_arrow_right), // item 后置图标 + isThreeLine: false, // item 是否三行显示 + dense: true, // item 直观感受是整体大小 + contentPadding: EdgeInsets.all(10.0), // item 内容内边距 + enabled: true, + onTap: () { + print('点击:$index'); + }, // item onTap 点击事件 + onLongPress: () { + print('长按:$index'); + }, // item onLongPress 长按事件 + selected: false, // item 是否选中状态 ); }, ), ); - break; + break; case 3: return SizedBox( height: 300.0, - child: ListView.custom( + child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: + SliverChildBuilderDelegate((BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -133,4 +143,4 @@ class ListViewLessDefault extends StatelessWidget { break; } } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListView/index.dart b/lib/widgets/components/List/ListView/index.dart index a953337d..b5366737 100644 --- a/lib/widgets/components/List/ListView/index.dart +++ b/lib/widgets/components/List/ListView/index.dart @@ -11,16 +11,13 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as ListViewDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ListView “滚动列表” - 一个非常常用的控件,涉及到数据列表展示的,一般情况下都会选用该控件。 - 跟GridView相似,基本上是一个slivers里面只包含一个SliverList的CustomScrollView。 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 布局行为 - ListView在主轴方向可以滚动,在交叉轴方向,则是填满ListView。 @@ -28,28 +25,24 @@ const String _Text1 = - ### 在Flutter中有几种构建ListView的方式,分别是: **默认List,ListView.builder, ListView.separated,ListView.custom**。 """; -const String _Text2 = -""" +const String _Text2 = """ > ListView() - 默认 List 方式,是把数据 Iterable 添加到列表中,之后直接添加到 ListView 即可。 - Tips: 如果需要设置分割线,需要对列表 item 添加处理,ListTile.divideTiles。 - 仅适用于内容较少的情形,因为它是一次性渲染所有的 items ,当 items 的数目较多时,很容易出现卡顿现象的,导致滑动不流畅。 """; -const String _Text3 = -""" +const String _Text3 = """ > ListView.builder() - 设置单个item的属性,懒加载的,假如有 1000 个列表,初始渲染时并不会所有都渲染,而只会特定数量的 item ,这对于性能和用户体验来说,是很好的提升。 """; -const String _Text4 = -""" +const String _Text4 = """ > 官方示例 ListView.separated() - 带分割线的item,separated 相比较于 builder,又多了一个参数 separatorBuilder ,用于控制列表各个元素的间隔如何渲染。 """; -const String _Text5 = -""" +const String _Text5 = """ > 官方示例 ListView.custom() - 必须的参数就是 childrenDelegate , 然后传入一个 实现了 SliverChildDelegate 的组件,如 SliverChildListDelegate 和 SliverChildBuilderDelegate。 """; @@ -94,5 +87,3 @@ List allDomeBox(BuildContext context, _DemoState that) { ListViewDemo.ListViewLessDefault(3), ]; } - - diff --git a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart index 6cd604d7..2eb12e4c 100644 --- a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart +++ b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart @@ -1,8 +1,8 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:51 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:51 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:37:04 - + import 'package:flutter/material.dart'; class CheckedPopupMenuItemDemo extends StatefulWidget { @@ -24,18 +24,17 @@ class _CheckedPopupMenuItemDemoState extends State { _checkedValues = [_checkedValue3]; } - bool isChecked(String value) => _checkedValues.contains(value); - void showCheckedMenuSelections(String value){ - if(_checkedValues.contains(value)){ + void showCheckedMenuSelections(String value) { + if (_checkedValues.contains(value)) { _checkedValues.remove(value); - }else{ + } else { _checkedValues.add(value); } - - Scaffold.of(context).showSnackBar( SnackBar( - content: Text('Checked $_checkedValues'))); + + Scaffold.of(context) + .showSnackBar(SnackBar(content: Text('Checked $_checkedValues'))); } @override @@ -43,33 +42,35 @@ class _CheckedPopupMenuItemDemoState extends State { return Container( color: Theme.of(context).primaryColor, child: ListTile( - title: const Text('CheckedPopupMenuItem Demo',style: TextStyle(color: Colors.white),), + title: const Text( + 'CheckedPopupMenuItem Demo', + style: TextStyle(color: Colors.white), + ), trailing: PopupMenuButton( padding: EdgeInsets.zero, onSelected: showCheckedMenuSelections, - icon: Icon(Icons.menu,color: Colors.white,), - itemBuilder: (BuildContext context)=>>[ + icon: Icon( + Icons.menu, + color: Colors.white, + ), + itemBuilder: (BuildContext context) => >[ + CheckedPopupMenuItem( + value: _checkedValue1, + checked: isChecked(_checkedValue1), + child: Text(_checkedValue1)), + CheckedPopupMenuItem( + value: _checkedValue2, + enabled: false, + checked: isChecked(_checkedValue2), + child: Text(_checkedValue2)), + CheckedPopupMenuItem( + value: _checkedValue3, + checked: isChecked(_checkedValue3), + child: Text(_checkedValue3)), CheckedPopupMenuItem( - value: _checkedValue1, - checked: isChecked(_checkedValue1), - child: Text(_checkedValue1) - ), - CheckedPopupMenuItem( - value: _checkedValue2, - enabled: false, - checked: isChecked(_checkedValue2), - child: Text(_checkedValue2) - ), - CheckedPopupMenuItem( - value: _checkedValue3, - checked: isChecked(_checkedValue3), - child: Text(_checkedValue3) - ), - CheckedPopupMenuItem( - value: _checkedValue4, - checked: isChecked(_checkedValue4), - child: Text(_checkedValue4) - ) + value: _checkedValue4, + checked: isChecked(_checkedValue4), + child: Text(_checkedValue4)) ], ), ), diff --git a/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart b/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart index 9d6fb700..ada4e29c 100644 --- a/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart +++ b/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:45 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:45 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 21:26:54 @@ -23,7 +23,7 @@ const String content1 = ''' '''; class Demo extends StatefulWidget { - static const String routeName = '/components/Menu/CheckedPopupMenuItem'; + static const String routeName = '/components/Menu/CheckedPopupMenuItem'; _DemoState createState() => _DemoState(); } @@ -32,7 +32,8 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( codeUrl: 'components/Menu/CheckedPopupMenuItem/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/CheckedPopupMenuItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/CheckedPopupMenuItem-class.html', title: 'CheckedPopupMenuItem', contentList: [ content0, @@ -41,4 +42,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/DropdownMenuItem/demo.dart b/lib/widgets/components/Menu/DropdownMenuItem/demo.dart index effe3dd8..9f591ad0 100644 --- a/lib/widgets/components/Menu/DropdownMenuItem/demo.dart +++ b/lib/widgets/components/Menu/DropdownMenuItem/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:05:32 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:05:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:05:52 @@ -10,12 +10,10 @@ class DropdownMenuItemDemo extends StatefulWidget { } class _DropdownMenuItemDemoState extends State { - String dropdown1Value = 'Three'; String dropdown2Value; String dropdown3Value = 'Four'; - @override Widget build(BuildContext context) { return Padding( @@ -32,7 +30,8 @@ class _DropdownMenuItemDemoState extends State { dropdown1Value = newValue; }); }, - items: ['One', 'Two', 'Three', 'Four'].map>((String value) { + items: ['One', 'Two', 'Three', 'Four'] + .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), @@ -53,7 +52,8 @@ class _DropdownMenuItemDemoState extends State { dropdown2Value = newValue; }); }, - items: ['One', 'Two', 'Three', 'Four'].map>((String value) { + items: ['One', 'Two', 'Three', 'Four'] + .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), @@ -74,20 +74,33 @@ class _DropdownMenuItemDemoState extends State { }); }, items: [ - 'One', 'Two', 'Three', 'Four', 'Can', 'I', 'Have', 'A', 'Little', - 'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' - ] - .map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }) - .toList(), - ), + 'One', + 'Two', + 'Three', + 'Four', + 'Can', + 'I', + 'Have', + 'A', + 'Little', + 'Bit', + 'More', + 'Five', + 'Six', + 'Seven', + 'Eight', + 'Nine', + 'Ten' + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), ), ], ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/DropdownMenuItem/index.dart b/lib/widgets/components/Menu/DropdownMenuItem/index.dart index c378f5b6..dbfe6bdb 100644 --- a/lib/widgets/components/Menu/DropdownMenuItem/index.dart +++ b/lib/widgets/components/Menu/DropdownMenuItem/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 11:20:07 +/// @Author: 一凨 +/// @Date: 2018-12-27 11:20:07 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:51:44 @@ -38,8 +38,9 @@ class _DemoState extends State { DropdownMenuItemDemo(), ], title: 'DropdownMenuItem', - docUrl: 'https://docs.flutter.io/flutter/material/DropdownMenuItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/DropdownMenuItem-class.html', codeUrl: 'components/Menu/DropdownMenuItem/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuButton/demo.dart b/lib/widgets/components/Menu/PopupMenuButton/demo.dart index b290c760..14bd1941 100644 --- a/lib/widgets/components/Menu/PopupMenuButton/demo.dart +++ b/lib/widgets/components/Menu/PopupMenuButton/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 15:17:10 +/// @Author: 一凨 +/// @Date: 2018-12-27 15:17:10 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:39:35 @@ -18,20 +18,16 @@ class _PopupMenuButtonDemoState extends State { void showMenuSelection(String value) { if ([_simpleValue1, _simpleValue2, _simpleValue3].contains(value)) _simpleValue = value; - Scaffold.of(context).showSnackBar( SnackBar( - content: Text('You selected: $value'))); + Scaffold.of(context) + .showSnackBar(SnackBar(content: Text('You selected: $value'))); } - - @override void initState() { super.initState(); _simpleValue = _simpleValue2; } - - @override Widget build(BuildContext context) { return Container( @@ -43,15 +39,15 @@ class _PopupMenuButtonDemoState extends State { padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: _simpleValue1, - child: const Text('Context menu item one')), - const PopupMenuItem( - enabled: false, child: Text('A disabled menu item')), - PopupMenuItem( - value: _simpleValue3, - child: const Text('Context menu item three')), - ], + PopupMenuItem( + value: _simpleValue1, + child: const Text('Context menu item one')), + const PopupMenuItem( + enabled: false, child: Text('A disabled menu item')), + PopupMenuItem( + value: _simpleValue3, + child: const Text('Context menu item three')), + ], ), ), ListTile( @@ -60,27 +56,25 @@ class _PopupMenuButtonDemoState extends State { padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: 'Preview', - child: ListTile( - leading: Icon(Icons.visibility), - title: Text('Preview'))), - const PopupMenuItem( - value: 'Share', - child: ListTile( - leading: Icon(Icons.person_add), - title: Text('Share'))), - const PopupMenuItem( - value: 'Get Link', - child: ListTile( - leading: Icon(Icons.link), - title: Text('Get link'))), - const PopupMenuDivider(), - const PopupMenuItem( - value: 'Remove', - child: ListTile( - leading: Icon(Icons.delete), title: Text('Remove'))) - ], + const PopupMenuItem( + value: 'Preview', + child: ListTile( + leading: Icon(Icons.visibility), + title: Text('Preview'))), + const PopupMenuItem( + value: 'Share', + child: ListTile( + leading: Icon(Icons.person_add), title: Text('Share'))), + const PopupMenuItem( + value: 'Get Link', + child: ListTile( + leading: Icon(Icons.link), title: Text('Get link'))), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'Remove', + child: ListTile( + leading: Icon(Icons.delete), title: Text('Remove'))) + ], ), ), PopupMenuButton( @@ -91,52 +85,43 @@ class _PopupMenuButtonDemoState extends State { title: const Text('An item with a simple menu'), subtitle: Text(_simpleValue)), itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: _simpleValue1, child: Text(_simpleValue1)), - PopupMenuItem( - value: _simpleValue2, child: Text(_simpleValue2)), - PopupMenuItem( - value: _simpleValue3, child: Text(_simpleValue3)) - ], + PopupMenuItem( + value: _simpleValue1, child: Text(_simpleValue1)), + PopupMenuItem( + value: _simpleValue2, child: Text(_simpleValue2)), + PopupMenuItem( + value: _simpleValue3, child: Text(_simpleValue3)) + ], ), ListTile( - title: const Text('An item with a sectioned menu'), - trailing: PopupMenuButton( - padding: EdgeInsets.zero, - onSelected: showMenuSelection, - itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: 'Preview', - child: ListTile( - leading: Icon(Icons.visibility), - title: Text('Preview') - ) - ), - const PopupMenuItem( - value: 'Share', - child: ListTile( - leading: Icon(Icons.person_add), - title: Text('Share') - ) - ), - const PopupMenuItem( - value: 'Get Link', - child: ListTile( - leading: Icon(Icons.link), - title: Text('Get link') - ) - ), - const PopupMenuDivider(), - const PopupMenuItem( - value: 'Remove', - child: ListTile( - leading: Icon(Icons.delete), - title: Text('Remove') - ) - ) - ] - ) - ), + title: const Text('An item with a sectioned menu'), + trailing: PopupMenuButton( + padding: EdgeInsets.zero, + onSelected: showMenuSelection, + itemBuilder: (BuildContext context) => + >[ + const PopupMenuItem( + value: 'Preview', + child: ListTile( + leading: Icon(Icons.visibility), + title: Text('Preview'))), + const PopupMenuItem( + value: 'Share', + child: ListTile( + leading: Icon(Icons.person_add), + title: Text('Share'))), + const PopupMenuItem( + value: 'Get Link', + child: ListTile( + leading: Icon(Icons.link), + title: Text('Get link'))), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'Remove', + child: ListTile( + leading: Icon(Icons.delete), + title: Text('Remove'))) + ])), ], ), ); diff --git a/lib/widgets/components/Menu/PopupMenuButton/index.dart b/lib/widgets/components/Menu/PopupMenuButton/index.dart index cd81f7d5..80dfac55 100644 --- a/lib/widgets/components/Menu/PopupMenuButton/index.dart +++ b/lib/widgets/components/Menu/PopupMenuButton/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:43:50 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:43:50 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:44:31 @@ -40,8 +40,9 @@ class _DemoState extends State { PopupMenuButtonDemo(), ], codeUrl: 'components/Menu/PopupMenuButton/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', title: 'PopupMenuButton', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuDivider/demo.dart b/lib/widgets/components/Menu/PopupMenuDivider/demo.dart index 3b578b53..32d68ecf 100644 --- a/lib/widgets/components/Menu/PopupMenuDivider/demo.dart +++ b/lib/widgets/components/Menu/PopupMenuDivider/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 15:45:26 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 15:45:26 +/// @Author: 一凨 +/// @Date: 2018-12-27 15:45:26 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 15:45:26 import 'package:flutter/material.dart'; @@ -12,7 +12,7 @@ class PopupMenuDividerDemo extends StatefulWidget { class _PopupMenuDividerDemoState extends State { void showInSnackBar(String value) { Scaffold.of(context) - .showSnackBar( SnackBar(content: Text('You selected: $value'))); + .showSnackBar(SnackBar(content: Text('You selected: $value'))); } @override diff --git a/lib/widgets/components/Menu/PopupMenuDivider/index.dart b/lib/widgets/components/Menu/PopupMenuDivider/index.dart index f6c2fd68..7d0ee26b 100644 --- a/lib/widgets/components/Menu/PopupMenuDivider/index.dart +++ b/lib/widgets/components/Menu/PopupMenuDivider/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:51:58 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:51:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:55:22 diff --git a/lib/widgets/components/Menu/PopupMenuEntry/index.dart b/lib/widgets/components/Menu/PopupMenuEntry/index.dart index 54b15669..2dca2cbe 100644 --- a/lib/widgets/components/Menu/PopupMenuEntry/index.dart +++ b/lib/widgets/components/Menu/PopupMenuEntry/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:51:58 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:51:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:06:20 @@ -28,14 +28,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuEntry-class.html', + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuEntry-class.html', codeUrl: 'components/Menu/PopupMenuDivider/demo.dart', title: 'PopupMenuEntry', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuItem/index.dart b/lib/widgets/components/Menu/PopupMenuItem/index.dart index dbb05dc9..87cb58d4 100644 --- a/lib/widgets/components/Menu/PopupMenuItem/index.dart +++ b/lib/widgets/components/Menu/PopupMenuItem/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-29 15:04:51 +/// @Date: 2018-12-29 15:04:51 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-29 15:07:16 @@ -28,14 +28,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", codeUrl: 'components/Menu/PopupMenuDivider/demo.dart', title: 'PopupMenuItem', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuItemState/index.dart b/lib/widgets/components/Menu/PopupMenuItemState/index.dart index 327724b4..214b33b9 100644 --- a/lib/widgets/components/Menu/PopupMenuItemState/index.dart +++ b/lib/widgets/components/Menu/PopupMenuItemState/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-29 15:04:51 +/// @Date: 2018-12-29 15:04:51 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-29 16:22:06 @@ -29,14 +29,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", codeUrl: 'components/Menu/PopupMenuEntry/demo.dart', title: 'PopupMenuItem', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/index.dart b/lib/widgets/components/Menu/index.dart index ce1de856..c6e70232 100644 --- a/lib/widgets/components/Menu/index.dart +++ b/lib/widgets/components/Menu/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:42 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:53:04 @@ -14,41 +14,40 @@ import './PopupMenuEntry/index.dart' as PopupMenuEntry; import './PopupMenuItemState/index.dart' as PopupMenuItemState; import './PopupMenuItem/index.dart' as PopupMenuItem; - List widgetPoints = [ WidgetPoint( - name:'CheckedPopupMenuItem', + name: 'CheckedPopupMenuItem', routerName: CheckedPopupMenuItem.Demo.routeName, buildRouter: (BuildContext context) => CheckedPopupMenuItem.Demo(), ), WidgetPoint( - name:'DropdownMenuItem', + name: 'DropdownMenuItem', routerName: DropdownMenuItem.Demo.routeName, buildRouter: (BuildContext context) => DropdownMenuItem.Demo(), ), WidgetPoint( - name:'PopupMenuButton', + name: 'PopupMenuButton', routerName: PopupMenuButton.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuButton.Demo(), ), WidgetPoint( - name:'PopupMenuDivider', + name: 'PopupMenuDivider', routerName: PopupMenuDivider.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuDivider.Demo(), ), WidgetPoint( - name:'PopupMenuEntry', + name: 'PopupMenuEntry', routerName: PopupMenuEntry.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuEntry.Demo(), ), WidgetPoint( - name:'PopupMenuItemState', + name: 'PopupMenuItemState', routerName: PopupMenuItemState.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuItemState.Demo(), ), WidgetPoint( - name:'PopupMenuItem', + name: 'PopupMenuItem', routerName: PopupMenuItem.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuItem.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart index 6771263b..63dabced 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - // BottomNavigationBar 默认的实例 class BottomNavigationBarFullDefault extends StatefulWidget { const BottomNavigationBarFullDefault() : super(); @@ -15,13 +14,12 @@ class BottomNavigationBarFullDefault extends StatefulWidget { State createState() => _BottomNavigationBarFullDefault(); } - // BottomNavigationBar 默认的实例,有状态 class _BottomNavigationBarFullDefault extends State { - int _currentIndex = 1; + int _currentIndex = 1; void _onItemTapped(int index) { - if(mounted) { + if (mounted) { setState(() { _currentIndex = index; }); @@ -31,27 +29,25 @@ class _BottomNavigationBarFullDefault extends State { @override Widget build(BuildContext context) { return BottomNavigationBar( - type: BottomNavigationBarType.fixed, // BottomNavigationBarType 中定义的类型,有 fixed 和 shifting 两种类型 + type: BottomNavigationBarType + .fixed, // BottomNavigationBarType 中定义的类型,有 fixed 和 shifting 两种类型 iconSize: 24.0, // BottomNavigationBarItem 中 icon 的大小 currentIndex: _currentIndex, // 当前所高亮的按钮index onTap: _onItemTapped, // 点击里面的按钮的回调函数,参数为当前点击的按钮 index - fixedColor: Colors.deepPurple, // 如果 type 类型为 fixed,则通过 fixedColor 设置选中 item 的颜色 - items: [ - BottomNavigationBarItem( - title: Text("Home"), icon: Icon(Icons.home)), - BottomNavigationBarItem( - title: Text("List"), icon: Icon(Icons.list)), + fixedColor: + Colors.deepPurple, // 如果 type 类型为 fixed,则通过 fixedColor 设置选中 item 的颜色 + selectedFontSize: 12.0, + unselectedFontSize: 12.0, + items: [ + BottomNavigationBarItem(title: Text("Home"), icon: Icon(Icons.home)), + BottomNavigationBarItem(title: Text("List"), icon: Icon(Icons.list)), BottomNavigationBarItem( - title: Text("Message"), icon: Icon(Icons.message)), + title: Text("Message"), icon: Icon(Icons.message)), + BottomNavigationBarItem(title: Text("add"), icon: Icon(Icons.add)), + BottomNavigationBarItem(title: Text("menu"), icon: Icon(Icons.menu)), BottomNavigationBarItem( - title: Text("add"), icon: Icon(Icons.add)), - BottomNavigationBarItem( - title: Text("menu"), icon: Icon(Icons.menu)), - BottomNavigationBarItem( - title: Text("other"), icon: Icon(Icons.devices_other)), - + title: Text("other"), icon: Icon(Icons.devices_other)), ], ); } } - diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart index 019ea65b..c21fe875 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart @@ -7,24 +7,22 @@ import 'package:flutter/material.dart'; -import 'package:flutter_go/components/widget_demo.dart'; +import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as BottomNavigationBarDemo; -const String _text0 = -"""### **简介** +const String _text0 = """### **简介** > BottomNavigationBar “底部导航栏” - 显示在应用程序底部的导航栏,由文本标签,图标或两者形式的多个项目组成; - 它提供了应用程序顶级视图之间的快速导航; """; - -const String _text1 = -"""### **基本用法** +const String _text1 = """### **基本用法** > BottomNavigationBar 底部导航栏通常与Scaffold结合使用 - 它作为 Scaffold.bottomNavigationBar 参数; - BottomNavigationBar 3-5个之间个底部按钮数量是合理的,理论上 icon 大小合适,可以支持更多; - 默认0-3个底部按钮数量时,BottomNavigationBar采用fixed的模式摆放底部按钮,当有4个时默认使用 BottomNavigationBarType.shifting 模式摆放底部按钮; +- 大多数人可能不需要选中文字被放大,可以通过 设置 selectedFontSize 与 unselectedFontSize 同等大小覆盖默认效果; - 下面的底部导航即是效果; """; @@ -39,16 +37,16 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'BottomNavigationBar', - codeUrl: 'components/Navigation/BottomNavigationBar/demo.dart', - contentList: allDemoBoxs(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html', - bottomNaviBar:BottomNavigationBarDemo.BottomNavigationBarFullDefault() - ); + title: 'BottomNavigationBar', + codeUrl: 'components/Navigation/BottomNavigationBar/demo.dart', + contentList: allDemoBoxs(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html', + bottomNaviBar: + BottomNavigationBarDemo.BottomNavigationBarFullDefault()); } } - // 所有的 BottomNavigationBar widget // context: 运行上下文 // that: 指向有状态的 StatefulWidget @@ -66,5 +64,3 @@ List allDemoBoxs(BuildContext context, _DemoState that) { SizedBox(width: 20.0), // 间距 ]; } - - diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart index 1cebb426..ebee54c8 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart @@ -17,25 +17,27 @@ class BottomNavigationBarItemLessDefault extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( + return SizedBox( height: 100, child: Scaffold( - bottomNavigationBar: BottomNavigationBar(items: [ - BottomNavigationBarItem( - icon: Icon(Icons.laptop_chromebook), - title: Text("主页"), - backgroundColor: Colors.red - ), - BottomNavigationBarItem( - icon: Icon(Icons.list), title: Text("分类"),backgroundColor: Colors.grey), - BottomNavigationBarItem( - icon: Icon(Icons.local_grocery_store), title: Text("购物车")), - BottomNavigationBarItem(icon: Icon(Icons.person), title: Text("我的")) - ], + bottomNavigationBar: BottomNavigationBar( + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.laptop_chromebook), + title: Text("主页"), + backgroundColor: Colors.red), + BottomNavigationBarItem( + icon: Icon(Icons.list), + title: Text("分类"), + backgroundColor: Colors.grey), + BottomNavigationBarItem( + icon: Icon(Icons.local_grocery_store), title: Text("购物车")), + BottomNavigationBarItem( + icon: Icon(Icons.person), title: Text("我的")) + ], //onTap: onTap, //currentIndex: page ), - ) - ); + )); } } diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart index 3ff65af9..5ebc9587 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart @@ -11,19 +11,18 @@ import 'package:flutter/material.dart'; import './demo.dart' as BottomNavigationBarItemDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > BottomNavigationBarItem “底部导航应用栏” - material 的 BottomNavigationBar 或带有图标和标题的 iOS主题 CupertinoTabBar 中的交互式按钮; """; -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 这个类很少单独使用。通常嵌入在上面的一个底部 bottom navigation widgets 中; """; class Demo extends StatefulWidget { - static const String routeName = '/components/Navigation/BottomNavigationBarItem'; + static const String routeName = + '/components/Navigation/BottomNavigationBarItem'; @override _DemoState createState() => _DemoState(); @@ -36,12 +35,12 @@ class _DemoState extends State { title: 'BottomNavigationBarItem', codeUrl: 'components/Navigation/BottomNavigationBarItem/demo.dart', contentList: allDomeBox(context, this), - docUrl: 'https://docs.flutter.io/flutter/widgets/BottomNavigationBarItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/BottomNavigationBarItem-class.html', ); } } - // 所有的 BottomNavigationBarItem widget // context: 运行上下文 // that: 指向有状态的 StatefulWidget @@ -55,6 +54,3 @@ List allDomeBox(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - - - diff --git a/lib/widgets/components/Panel/ExpansionPanel/demo.dart b/lib/widgets/components/Panel/ExpansionPanel/demo.dart index 716abd43..65a73fd4 100644 --- a/lib/widgets/components/Panel/ExpansionPanel/demo.dart +++ b/lib/widgets/components/Panel/ExpansionPanel/demo.dart @@ -4,24 +4,14 @@ import 'package:flutter/material.dart'; - @visibleForTesting -enum Location { - Barbados, - Bahamas, - Bermuda -} +enum Location { Barbados, Bahamas, Bermuda } typedef DemoItemBodyBuilder = Widget Function(DemoItem item); typedef ValueToString = String Function(T value); class DualHeaderWithHint extends StatelessWidget { - const DualHeaderWithHint({ - this.name, - this.value, - this.hint, - this.showHint - }); + const DualHeaderWithHint({this.name, this.value, this.hint, this.showHint}); final String name; final String value; @@ -35,7 +25,8 @@ class DualHeaderWithHint extends StatelessWidget { firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, - crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, + crossFadeState: + isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: const Duration(milliseconds: 200), ); } @@ -45,45 +36,37 @@ class DualHeaderWithHint extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: Alignment.centerLeft, - child: Text( - name, - style: textTheme.body1.copyWith(fontSize: 15.0), - ), + return Row(children: [ + Expanded( + flex: 2, + child: Container( + margin: const EdgeInsets.only(left: 24.0), + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + name, + style: textTheme.body1.copyWith(fontSize: 15.0), ), ), ), - Expanded( + ), + Expanded( flex: 3, child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: _crossFade( - Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), - Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), - showHint - ) - ) - ) - ] - ); + margin: const EdgeInsets.only(left: 24.0), + child: _crossFade( + Text(value, + style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + showHint))) + ]); } } class CollapsibleBody extends StatelessWidget { - const CollapsibleBody({ - this.margin = EdgeInsets.zero, - this.child, - this.onSave, - this.onCancel - }); + const CollapsibleBody( + {this.margin = EdgeInsets.zero, this.child, this.onSave, this.onCancel}); final EdgeInsets margin; final Widget child; @@ -95,62 +78,42 @@ class CollapsibleBody extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 24.0, - right: 24.0, - bottom: 24.0 - ) - margin, + return Column(children: [ + Container( + margin: const EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0) - + margin, child: Center( - child: DefaultTextStyle( - style: textTheme.caption.copyWith(fontSize: 15.0), - child: child - ) - ) - ), - const Divider(height: 1.0), - Container( + child: DefaultTextStyle( + style: textTheme.caption.copyWith(fontSize: 15.0), + child: child))), + const Divider(height: 1.0), + Container( padding: const EdgeInsets.symmetric(vertical: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( + child: + Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Container( margin: const EdgeInsets.only(right: 8.0), child: FlatButton( - onPressed: onCancel, - child: const Text('CANCEL', style: TextStyle( - color: Colors.black54, - fontSize: 15.0, - fontWeight: FontWeight.w500 - )) - ) - ), - Container( + onPressed: onCancel, + child: const Text('CANCEL', + style: TextStyle( + color: Colors.black54, + fontSize: 15.0, + fontWeight: FontWeight.w500)))), + Container( margin: const EdgeInsets.only(right: 8.0), child: FlatButton( - onPressed: onSave, - textTheme: ButtonTextTheme.accent, - child: const Text('SAVE') - ) - ) - ] - ) - ) - ] - ); + onPressed: onSave, + textTheme: ButtonTextTheme.accent, + child: const Text('SAVE'))) + ])) + ]); } } class DemoItem { - DemoItem({ - this.name, - this.value, - this.hint, - this.builder, - this.valueToString - }) : textController = TextEditingController(text: valueToString(value)); + DemoItem({this.name, this.value, this.hint, this.builder, this.valueToString}) + : textController = TextEditingController(text: valueToString(value)); final String name; final String hint; @@ -163,11 +126,10 @@ class DemoItem { ExpansionPanelHeaderBuilder get headerBuilder { return (BuildContext context, bool isExpanded) { return DualHeaderWithHint( - name: name, - value: valueToString(value), - hint: hint, - showHint: isExpanded - ); + name: name, + value: valueToString(value), + hint: hint, + showHint: isExpanded); }; } @@ -189,87 +151,88 @@ class _ExpansionPanelsDemoState extends State { super.initState(); _demoItems = >[ - DemoItem( - name: 'Location', - value: Location.Bahamas, - hint: 'Select location', - valueToString: (Location location) => location.toString().split('.')[1], - builder: (DemoItem item) { - void close() { - setState(() { - item.isExpanded = false; - }); - } - return Form( - child: Builder( - builder: (BuildContext context) { - return CollapsibleBody( - onSave: () { Form.of(context).save(); close(); }, - onCancel: () { Form.of(context).reset(); close(); }, - child: FormField( + name: 'Location', + value: Location.Bahamas, + hint: 'Select location', + valueToString: (Location location) => + location.toString().split('.')[1], + builder: (DemoItem item) { + void close() { + setState(() { + item.isExpanded = false; + }); + } + + return Form(child: Builder(builder: (BuildContext context) { + return CollapsibleBody( + onSave: () { + Form.of(context).save(); + close(); + }, + onCancel: () { + Form.of(context).reset(); + close(); + }, + child: FormField( initialValue: item.value, - onSaved: (Location result) { item.value = result; }, + onSaved: (Location result) { + item.value = result; + }, builder: (FormFieldState field) { return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - RadioListTile( - value: Location.Bahamas, - title: const Text('Bahamas'), - groupValue: field.value, - onChanged: field.didChange, - ), - RadioListTile( - value: Location.Barbados, - title: const Text('Barbados'), - groupValue: field.value, - onChanged: field.didChange, - ), - RadioListTile( - value: Location.Bermuda, - title: const Text('Bermuda'), - groupValue: field.value, - onChanged: field.didChange, - ), - ] - ); - } - ), - ); - } - ) - ); - } - ), + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RadioListTile( + value: Location.Bahamas, + title: const Text('Bahamas'), + groupValue: field.value, + onChanged: field.didChange, + ), + RadioListTile( + value: Location.Barbados, + title: const Text('Barbados'), + groupValue: field.value, + onChanged: field.didChange, + ), + RadioListTile( + value: Location.Bermuda, + title: const Text('Bermuda'), + groupValue: field.value, + onChanged: field.didChange, + ), + ]); + }), + ); + })); + }), ]; } @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: SafeArea( - top: false, - bottom: false, - child: Container( - margin: const EdgeInsets.all(24.0), - child: ExpansionPanelList( + return SingleChildScrollView( + child: SafeArea( + top: false, + bottom: false, + child: Container( + margin: const EdgeInsets.all(24.0), + child: ExpansionPanelList( expansionCallback: (int index, bool isExpanded) { setState(() { _demoItems[index].isExpanded = !isExpanded; }); }, - children: _demoItems.map((DemoItem item) { + children: + _demoItems.map((DemoItem item) { return ExpansionPanel( - isExpanded: true, - headerBuilder: item.headerBuilder, - body: item.build() - ); - }).toList() - ), - ), + isExpanded: true, + headerBuilder: item.headerBuilder, + body: item.build()); + }).toList()), ), - ); + ), + ); } } diff --git a/lib/widgets/components/Panel/ExpansionPanel/index.dart b/lib/widgets/components/Panel/ExpansionPanel/index.dart index b39aa257..4ef19fd1 100644 --- a/lib/widgets/components/Panel/ExpansionPanel/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanel/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-21 11:35:39 +/// @Date: 2018-12-21 11:35:39 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:36:23 @@ -34,7 +34,7 @@ class _DemoState extends State { ExpansionPanelsDemo(), ], codeUrl: 'widgets/components/Panel/ExpansionPanel/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'ExpansionPanel'); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart index 8d8259e5..48acd398 100644 --- a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart +++ b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart @@ -5,11 +5,7 @@ import 'package:flutter/material.dart'; @visibleForTesting -enum Location { - Barbados, - Bahamas, - Bermuda -} +enum Location { Barbados, Bahamas, Bermuda } typedef DemoItemBodyBuilder = Widget Function(DemoItem item); typedef ValueToString = String Function(T value); @@ -18,12 +14,7 @@ typedef ValueToString = String Function(T value); // https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart class DualHeaderWithHint extends StatelessWidget { - const DualHeaderWithHint({ - this.name, - this.value, - this.hint, - this.showHint - }); + const DualHeaderWithHint({this.name, this.value, this.hint, this.showHint}); final String name; final String value; @@ -37,7 +28,8 @@ class DualHeaderWithHint extends StatelessWidget { firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, - crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, + crossFadeState: + isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: const Duration(milliseconds: 200), ); } @@ -47,47 +39,37 @@ class DualHeaderWithHint extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: Alignment.centerLeft, - child: Text( - name, - style: textTheme.body1.copyWith(fontSize: 15.0), - ), + return Row(children: [ + Expanded( + flex: 2, + child: Container( + margin: const EdgeInsets.only(left: 24.0), + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + name, + style: textTheme.body1.copyWith(fontSize: 15.0), ), ), ), - Expanded( + ), + Expanded( flex: 3, child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: _crossFade( - Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), - Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), - showHint - ) - ) - ) - ] - ); + margin: const EdgeInsets.only(left: 24.0), + child: _crossFade( + Text(value, + style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + showHint))) + ]); } } - class DemoItem { - DemoItem({ - this.name, - this.value, - this.hint, - this.builder, - this.valueToString - }) : textController = TextEditingController(text: valueToString(value)); + DemoItem({this.name, this.value, this.hint, this.builder, this.valueToString}) + : textController = TextEditingController(text: valueToString(value)); final String name; final String hint; @@ -100,11 +82,10 @@ class DemoItem { ExpansionPanelHeaderBuilder get headerBuilder { return (BuildContext context, bool isExpanded) { return DualHeaderWithHint( - name: name, - value: valueToString(value), - hint: hint, - showHint: isExpanded - ); + name: name, + value: valueToString(value), + hint: hint, + showHint: isExpanded); }; } @@ -126,21 +107,21 @@ class _ExpansionPanelsDemoState extends State { super.initState(); _demoItems = >[ - DemoItem( - name: 'Location', - value: Location.Bahamas, - hint: 'Select location', - valueToString: (Location location) => location.toString().split('.')[1], - builder: (DemoItem item) { - return Form( - child: Builder( - builder: (BuildContext context) { - return FormField( - initialValue: item.value, - onSaved: (Location result) { item.value = result; }, - builder: (FormFieldState field) { - return Column( + name: 'Location', + value: Location.Bahamas, + hint: 'Select location', + valueToString: (Location location) => + location.toString().split('.')[1], + builder: (DemoItem item) { + return Form(child: Builder(builder: (BuildContext context) { + return FormField( + initialValue: item.value, + onSaved: (Location result) { + item.value = result; + }, + builder: (FormFieldState field) { + return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -162,42 +143,36 @@ class _ExpansionPanelsDemoState extends State { groupValue: field.value, onChanged: field.didChange, ), - ] - ); - } - ); - } - ) - ); - } - ), + ]); + }); + })); + }), ]; } @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: SafeArea( - top: false, - bottom: false, - child: Container( - margin: const EdgeInsets.all(24.0), - child: ExpansionPanelList( + return SingleChildScrollView( + child: SafeArea( + top: false, + bottom: false, + child: Container( + margin: const EdgeInsets.all(24.0), + child: ExpansionPanelList( expansionCallback: (int index, bool isExpanded) { setState(() { _demoItems[index].isExpanded = !isExpanded; }); }, - children: _demoItems.map((DemoItem item) { + children: + _demoItems.map((DemoItem item) { return ExpansionPanel( - isExpanded: true, - headerBuilder: item.headerBuilder, - body: item.build() - ); - }).toList() - ), - ), + isExpanded: true, + headerBuilder: item.headerBuilder, + body: item.build()); + }).toList()), ), - ); + ), + ); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelList/index.dart b/lib/widgets/components/Panel/ExpansionPanelList/index.dart index f9c3657c..6b3bb3c3 100644 --- a/lib/widgets/components/Panel/ExpansionPanelList/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanelList/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2019-01-08 16:15:20 @@ -39,7 +39,7 @@ class _DemoState extends State { ExpansionPanelsDemo(), ], codeUrl: 'components/Panel/ExpansionPanelList/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart b/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart index df757027..f858c679 100644 --- a/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:35:48 @@ -39,7 +39,7 @@ class _DemoState extends State { // FilterChipDemo(), ], codeUrl: 'components/Chip/RawChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Panel/index.dart b/lib/widgets/components/Panel/index.dart index dc8f3fae..aa1783a6 100644 --- a/lib/widgets/components/Panel/index.dart +++ b/lib/widgets/components/Panel/index.dart @@ -21,5 +21,4 @@ List widgetPoints = [ routerName: ExpansionPanelList.Demo.routeName, buildRouter: (BuildContext context) => ExpansionPanelList.Demo(), ), - ]; diff --git a/lib/widgets/components/Pick/CityPIcker/demo.dart b/lib/widgets/components/Pick/CityPIcker/demo.dart index 4e39b2d2..1ff95d91 100644 --- a/lib/widgets/components/Pick/CityPIcker/demo.dart +++ b/lib/widgets/components/Pick/CityPIcker/demo.dart @@ -15,7 +15,7 @@ class CityPickerDemo extends StatefulWidget { class _Demo extends State { String _result; show(context) async { - Result temp = await CityPickers.showCityPicker( + Result temp = await CityPickers.showCityPicker( context: context, // locationCode: '640221', height: 400, @@ -28,15 +28,15 @@ class _Demo extends State { Widget build(BuildContext context) { return Center( child: Column( - children: [ - Text("result: ${_result.toString()}"), - RaisedButton( - onPressed: () {this.show(context); - }, - child: Text("select"), - ), - ], - ) - ); + children: [ + Text("result: ${_result.toString()}"), + RaisedButton( + onPressed: () { + this.show(context); + }, + child: Text("select"), + ), + ], + )); } } diff --git a/lib/widgets/components/Pick/CityPIcker/index.dart b/lib/widgets/components/Pick/CityPIcker/index.dart index 066b3aae..01a625e0 100644 --- a/lib/widgets/components/Pick/CityPIcker/index.dart +++ b/lib/widgets/components/Pick/CityPIcker/index.dart @@ -21,23 +21,19 @@ const String content1 = ''' - height 弹出层高度 - context 上下文对象 '''; + class Demo extends StatefulWidget { static const String routeName = '/components/Pick/CityPicker'; _Demo createState() => _Demo(); } class _Demo extends State { - Widget build(BuildContext context) { return WidgetDemo( title: 'CityPicker', codeUrl: '', docUrl: '', - contentList: [ - content0, - content1, - CityPickerDemo() - ], + contentList: [content0, content1, CityPickerDemo()], ); } } diff --git a/lib/widgets/components/Pick/DayPicker/demo.dart b/lib/widgets/components/Pick/DayPicker/demo.dart index 2ba81f04..447bd0a7 100644 --- a/lib/widgets/components/Pick/DayPicker/demo.dart +++ b/lib/widgets/components/Pick/DayPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:12:32 @@ -13,8 +13,8 @@ class DayPickerDemo extends StatefulWidget { } class _DayPickerState extends State { - DateTime _date = DateTime.now(); - TimeOfDay _time = TimeOfDay.now(); + DateTime _date = DateTime.now(); + TimeOfDay _time = TimeOfDay.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -28,7 +28,7 @@ class _DayPickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } Future _selectTime(BuildContext context) async { @@ -39,23 +39,23 @@ class _DayPickerState extends State { setState(() { _time = picked; }); - if (picked == null) _time = TimeOfDay.now(); + if (picked == null) _time = TimeOfDay.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, ), - Text('时间选择'), - RaisedButton( - child: Text('date selected:${_time.toString()}'), + Text('时间选择'), + RaisedButton( + child: Text('date selected:${_time.toString()}'), onPressed: () { _selectTime(context); }, diff --git a/lib/widgets/components/Pick/DayPicker/index.dart b/lib/widgets/components/Pick/DayPicker/index.dart index 72cdc9ed..be47a1f7 100644 --- a/lib/widgets/components/Pick/DayPicker/index.dart +++ b/lib/widgets/components/Pick/DayPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 15:50:02 diff --git a/lib/widgets/components/Pick/MonthPicker/demo.dart b/lib/widgets/components/Pick/MonthPicker/demo.dart index bf4584c5..061a1bf7 100644 --- a/lib/widgets/components/Pick/MonthPicker/demo.dart +++ b/lib/widgets/components/Pick/MonthPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:26:21 @@ -13,7 +13,7 @@ class MothPickerDemo extends StatefulWidget { } class _MothPickerState extends State { - DateTime _date = DateTime.now(); + DateTime _date = DateTime.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -27,16 +27,16 @@ class _MothPickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, diff --git a/lib/widgets/components/Pick/MonthPicker/index.dart b/lib/widgets/components/Pick/MonthPicker/index.dart index 4f4f864d..c34ee1ed 100644 --- a/lib/widgets/components/Pick/MonthPicker/index.dart +++ b/lib/widgets/components/Pick/MonthPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 17:06:34 diff --git a/lib/widgets/components/Pick/ShowdatePicker/demo.dart b/lib/widgets/components/Pick/ShowdatePicker/demo.dart index c5c2c147..2a8d2c06 100644 --- a/lib/widgets/components/Pick/ShowdatePicker/demo.dart +++ b/lib/widgets/components/Pick/ShowdatePicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:12:32 @@ -13,8 +13,8 @@ class ShowDatePickerDemo extends StatefulWidget { } class _ShowDatePickerState extends State { - DateTime _date = DateTime.now(); - TimeOfDay _time = TimeOfDay.now(); + DateTime _date = DateTime.now(); + TimeOfDay _time = TimeOfDay.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -28,7 +28,7 @@ class _ShowDatePickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } Future _selectTime(BuildContext context) async { @@ -39,23 +39,23 @@ class _ShowDatePickerState extends State { setState(() { _time = picked; }); - if (picked == null) _time = TimeOfDay.now(); + if (picked == null) _time = TimeOfDay.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, ), - Text('时间选择'), - RaisedButton( - child: Text('date selected:${_time.toString()}'), + Text('时间选择'), + RaisedButton( + child: Text('date selected:${_time.toString()}'), onPressed: () { _selectTime(context); }, diff --git a/lib/widgets/components/Pick/ShowdatePicker/index.dart b/lib/widgets/components/Pick/ShowdatePicker/index.dart index fd2fe108..96aa59ff 100644 --- a/lib/widgets/components/Pick/ShowdatePicker/index.dart +++ b/lib/widgets/components/Pick/ShowdatePicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Pick/YearPicker/demo.dart b/lib/widgets/components/Pick/YearPicker/demo.dart index b6a74d2c..26eb7833 100644 --- a/lib/widgets/components/Pick/YearPicker/demo.dart +++ b/lib/widgets/components/Pick/YearPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-11 15:17:26 @@ -13,7 +13,7 @@ class YearPickerDemo extends StatefulWidget { } class _YearPickerDemoState extends State { - DateTime _date = DateTime.now(); + DateTime _date = DateTime.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -27,16 +27,16 @@ class _YearPickerDemoState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, diff --git a/lib/widgets/components/Pick/YearPicker/index.dart b/lib/widgets/components/Pick/YearPicker/index.dart index 9177677a..c2dbffe7 100644 --- a/lib/widgets/components/Pick/YearPicker/index.dart +++ b/lib/widgets/components/Pick/YearPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Pick/index.dart b/lib/widgets/components/Pick/index.dart index 3e61a2ed..560d4b62 100644 --- a/lib/widgets/components/Pick/index.dart +++ b/lib/widgets/components/Pick/index.dart @@ -33,5 +33,4 @@ List widgetPoints = [ routerName: CityPicker.Demo.routeName, buildRouter: (BuildContext context) => CityPicker.Demo(), ), - ]; diff --git a/lib/widgets/components/Progress/CircularProgressIndicator/index.dart b/lib/widgets/components/Progress/CircularProgressIndicator/index.dart index c7579ad9..4ba1fe69 100644 --- a/lib/widgets/components/Progress/CircularProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/CircularProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Progress/LinearProgressIndicator/index.dart b/lib/widgets/components/Progress/LinearProgressIndicator/index.dart index dffc8dfb..a9641f2e 100644 --- a/lib/widgets/components/Progress/LinearProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/LinearProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart b/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart index e69de29b..8b137891 100644 --- a/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart +++ b/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart @@ -0,0 +1 @@ + diff --git a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart index 92cce808..09c3342e 100644 --- a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 @@ -22,7 +22,8 @@ const String content1 = ''' '''; class Demo extends StatefulWidget { - static const String routeName = '/components/Progress/RefreshProgressIndicator'; + static const String routeName = + '/components/Progress/RefreshProgressIndicator'; _DemoState createState() => _DemoState(); } @@ -36,7 +37,8 @@ class _DemoState extends State { // LinearProgressIndicatorDemo(), ], codeUrl: 'components/Progress/RefreshProgressIndicator/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RefreshProgressIndicator-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RefreshProgressIndicator-class.html', title: 'RefreshProgressIndicator'); } } diff --git a/lib/widgets/components/Scaffold/Scaffold/demo.dart b/lib/widgets/components/Scaffold/Scaffold/demo.dart index cd65e73e..1d80ecce 100644 --- a/lib/widgets/components/Scaffold/Scaffold/demo.dart +++ b/lib/widgets/components/Scaffold/Scaffold/demo.dart @@ -33,9 +33,9 @@ class _ScaffoldDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, - child: Scaffold( + child: Scaffold( appBar: AppBar( title: Text('Sample Code'), ), @@ -46,8 +46,8 @@ class _ScaffoldDemo extends State with SingleTickerProviderStateMixin { FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( onPressed: () => setState(() { - count += 1; - }), + count += 1; + }), tooltip: 'Increment Counter', child: Icon(Icons.add), ), diff --git a/lib/widgets/components/Scaffold/Scaffold/index.dart b/lib/widgets/components/Scaffold/Scaffold/index.dart index f90e562c..e83dc7a8 100644 --- a/lib/widgets/components/Scaffold/Scaffold/index.dart +++ b/lib/widgets/components/Scaffold/Scaffold/index.dart @@ -40,7 +40,6 @@ Scaffold 有下面几个主要属性: """; - class Demo extends StatefulWidget { static const String routeName = '/components/Scaffold/Scaffold'; @@ -56,7 +55,7 @@ class _DemoState extends State { codeUrl: 'components/Scaffold/Scaffold/demo.dart', contentList: [ _Text0, - ScaffoldDemo(), + ScaffoldDemo(), ], docUrl: 'https://docs.flutter.io/flutter/material/Scaffold-class.html', ); diff --git a/lib/widgets/components/Scaffold/ScaffoldState/demo.dart b/lib/widgets/components/Scaffold/ScaffoldState/demo.dart index 79f6aea0..ff581187 100644 --- a/lib/widgets/components/Scaffold/ScaffoldState/demo.dart +++ b/lib/widgets/components/Scaffold/ScaffoldState/demo.dart @@ -16,7 +16,6 @@ class ScaffoldStateDemo extends StatefulWidget { // AppBar 默认的实例,有状态 class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { - int count = 0; final GlobalKey _scaffoldKey = GlobalKey(); @override @@ -24,14 +23,14 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, child: Scaffold( - key:_scaffoldKey, + key: _scaffoldKey, appBar: AppBar( title: Text('ScaffoldState Demo'), ), - body: Center( + body: Center( child: Column( children: [ RaisedButton( @@ -39,8 +38,7 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { onPressed: () { _scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState.showSnackBar(const SnackBar( - content: Text("我是通过ScaffoldState的方式呼出的SnackBar.") - )); + content: Text("我是通过ScaffoldState的方式呼出的SnackBar."))); }, ) ], @@ -72,9 +70,6 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { ], ), ), - - ) - - ); + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scaffold/ScaffoldState/index.dart b/lib/widgets/components/Scaffold/ScaffoldState/index.dart index 00dc10b0..3a5fae1d 100644 --- a/lib/widgets/components/Scaffold/ScaffoldState/index.dart +++ b/lib/widgets/components/Scaffold/ScaffoldState/index.dart @@ -24,7 +24,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Scaffold/ScaffoldState'; @@ -38,11 +37,9 @@ class _DemoState extends State { return WidgetDemo( title: 'ScaffoldState', codeUrl: 'components/Scaffold/ScaffoldState/demo.dart', - contentList: [ - _Text0, - ScaffoldStateDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/ScaffoldState-class.html', + contentList: [_Text0, ScaffoldStateDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/ScaffoldState-class.html', ); } } diff --git a/lib/widgets/components/Scroll/BoxScrollView/demo.dart b/lib/widgets/components/Scroll/BoxScrollView/demo.dart index 9562295e..8719e16f 100644 --- a/lib/widgets/components/Scroll/BoxScrollView/demo.dart +++ b/lib/widgets/components/Scroll/BoxScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-17 13:16:29 +/// @Author: 一凨 +/// @Date: 2018-12-17 13:16:29 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-17 13:43:01 diff --git a/lib/widgets/components/Scroll/BoxScrollView/index.dart b/lib/widgets/components/Scroll/BoxScrollView/index.dart index a696fba1..1f0d203d 100644 --- a/lib/widgets/components/Scroll/BoxScrollView/index.dart +++ b/lib/widgets/components/Scroll/BoxScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-17 13:16:46 +/// @Author: 一凨 +/// @Date: 2018-12-17 13:16:46 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-17 13:34:46 @@ -31,11 +31,7 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - BoxScrollViewDemo() - ], + contentList: [content0, content1, BoxScrollViewDemo()], codeUrl: 'components/Scroll/BoxScrollView/demo.dart', docUrl: 'https://docs.flutter.io/flutter/widgets/BoxScrollView-class.html', diff --git a/lib/widgets/components/Scroll/CustomScrollView/demo.dart b/lib/widgets/components/Scroll/CustomScrollView/demo.dart index b06e2dbb..aba849a2 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/demo.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 13:40:58 +/// @Author: 一凨 +/// @Date: 2018-12-20 13:40:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:06:31 @@ -58,9 +58,10 @@ class CustomScrollViewDemo extends StatelessWidget { backgroundColor: Theme.of(context).primaryColor, expandedHeight: 200.0, flexibleSpace: FlexibleSpaceBar( - background: Image.asset('assets/images/food01.jpeg', fit: BoxFit.cover), + background: + Image.asset('assets/images/food01.jpeg', fit: BoxFit.cover), ), - pinned: true,//固定导航 + pinned: true, //固定导航 ), SliverFixedExtentList( delegate: SliverChildListDelegate(products.map((product) { diff --git a/lib/widgets/components/Scroll/CustomScrollView/index.dart b/lib/widgets/components/Scroll/CustomScrollView/index.dart index cb466740..cc754166 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/index.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 13:21:36 +/// @Author: 一凨 +/// @Date: 2018-12-20 13:21:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:08:29 @@ -29,7 +29,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - @override Widget build(BuildContext context) { return WidgetDemo( @@ -39,8 +38,9 @@ class _DemoState extends State { CustomScrollViewDemo(), ], codeUrl: 'components/Scroll/CustomScrollView/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/widgets/CustomScrollView-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/CustomScrollView-class.html', title: 'CustomScrollView', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/CustomScrollView/product_list.dart b/lib/widgets/components/Scroll/CustomScrollView/product_list.dart index 0c802382..f26e2d02 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/product_list.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/product_list.dart @@ -1,5 +1,3 @@ - - class ProductItem { final String name; final String tag; diff --git a/lib/widgets/components/Scroll/NestedScrollView/demo.dart b/lib/widgets/components/Scroll/NestedScrollView/demo.dart index cdb38f89..91780ee1 100644 --- a/lib/widgets/components/Scroll/NestedScrollView/demo.dart +++ b/lib/widgets/components/Scroll/NestedScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 14:19:26 +/// @Author: 一凨 +/// @Date: 2018-12-20 14:19:26 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:50:36 @@ -46,9 +46,9 @@ class _NestedScrollViewDemoState extends State flexibleSpace: Container( child: Image.asset( 'assets/images/timg.jpeg', - width: double.infinity, - repeat: ImageRepeat.repeat, - height: double.infinity, + width: double.infinity, + repeat: ImageRepeat.repeat, + height: double.infinity, ), ), bottom: TabBar( @@ -118,16 +118,16 @@ class PageTwo extends StatelessWidget { return ListView.builder( itemExtent: 250.0, itemBuilder: (context, index) => Container( - padding: EdgeInsets.all(10.0), - child: Material( - elevation: 4.0, - borderRadius: BorderRadius.circular(5.0), - color: index % 2 == 0 ? Colors.cyan : Colors.deepOrange, - child: Center( - child: Text(index.toString()), - ), - ), + padding: EdgeInsets.all(10.0), + child: Material( + elevation: 4.0, + borderRadius: BorderRadius.circular(5.0), + color: index % 2 == 0 ? Colors.cyan : Colors.deepOrange, + child: Center( + child: Text(index.toString()), ), + ), + ), ); } } diff --git a/lib/widgets/components/Scroll/NestedScrollView/index.dart b/lib/widgets/components/Scroll/NestedScrollView/index.dart index 6ea21f59..96185cec 100644 --- a/lib/widgets/components/Scroll/NestedScrollView/index.dart +++ b/lib/widgets/components/Scroll/NestedScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 14:18:36 +/// @Author: 一凨 +/// @Date: 2018-12-20 14:18:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:19:15 diff --git a/lib/widgets/components/Scroll/ScrollMetrics/demo.dart b/lib/widgets/components/Scroll/ScrollMetrics/demo.dart index 5a6a9fc4..d7e21896 100644 --- a/lib/widgets/components/Scroll/ScrollMetrics/demo.dart +++ b/lib/widgets/components/Scroll/ScrollMetrics/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 19:43:41 +/// @Author: 一凨 +/// @Date: 2018-12-15 19:43:41 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:37:03 diff --git a/lib/widgets/components/Scroll/ScrollMetrics/index.dart b/lib/widgets/components/Scroll/ScrollMetrics/index.dart index b0a50565..835e14dc 100644 --- a/lib/widgets/components/Scroll/ScrollMetrics/index.dart +++ b/lib/widgets/components/Scroll/ScrollMetrics/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 19:44:12 +/// @Author: 一凨 +/// @Date: 2018-12-15 19:44:12 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 20:33:47 @@ -36,7 +36,8 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'ScrollMetrics', - docUrl: 'https://docs.flutter.io/flutter/widgets/ScrollMetrics-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/ScrollMetrics-class.html', codeUrl: 'components/Scroll/ScrollMetrics/demo.dart', contentList: [ content0, @@ -45,4 +46,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/ScrollPhysics/demo.dart b/lib/widgets/components/Scroll/ScrollPhysics/demo.dart index 3b31a90e..e511e580 100644 --- a/lib/widgets/components/Scroll/ScrollPhysics/demo.dart +++ b/lib/widgets/components/Scroll/ScrollPhysics/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 20:39:14 +/// @Author: 一凨 +/// @Date: 2018-12-15 20:39:14 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:27:39 @@ -10,7 +10,7 @@ class ScrollPhysicsDemo extends StatefulWidget { } class _ScrollPhysicsDemoState extends State { - final PageController _pageController = PageController(); + final PageController _pageController = PageController(); double _currentPage = 0.0; @override @@ -20,27 +20,27 @@ class _ScrollPhysicsDemoState extends State { width: MediaQuery.of(context).size.width, child: LayoutBuilder( builder: (context, constraints) => NotificationListener( - onNotification: (ScrollNotification note) { - setState(() { - _currentPage = _pageController.page; - }); - return false; - }, - child: PageView.custom( - physics: const PageScrollPhysics( - parent: const BouncingScrollPhysics()), - controller: _pageController, - childrenDelegate: SliverChildBuilderDelegate( - (context, index) => _SimplePage( - '$index', - parallaxOffset: - constraints.maxWidth / 2.0 * (index - _currentPage), - // 小字 Text 在页面滑动时要比整体移动速度快一倍,所以小字的 translate X 为 \tt{pageWidth / 2 * progress} 。 - ), - childCount: 10, - ), + onNotification: (ScrollNotification note) { + setState(() { + _currentPage = _pageController.page; + }); + return false; + }, + child: PageView.custom( + physics: + const PageScrollPhysics(parent: const BouncingScrollPhysics()), + controller: _pageController, + childrenDelegate: SliverChildBuilderDelegate( + (context, index) => _SimplePage( + '$index', + parallaxOffset: + constraints.maxWidth / 2.0 * (index - _currentPage), + // 小字 Text 在页面滑动时要比整体移动速度快一倍,所以小字的 translate X 为 \tt{pageWidth / 2 * progress} 。 ), + childCount: 10, ), + ), + ), ), ); } @@ -54,22 +54,25 @@ class _SimplePage extends StatelessWidget { final double parallaxOffset; @override - Widget build(BuildContext context) => Center( + Widget build(BuildContext context) => Center( child: Container( color: Theme.of(context).primaryColor, - child: Center( - child: Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text( + Text( data, - style: const TextStyle(fontSize: 60.0,color: Colors.white), + style: const TextStyle(fontSize: 60.0, color: Colors.white), ), - SizedBox(height: 40.0), - Transform( + SizedBox(height: 40.0), + Transform( transform: - Matrix4.translationValues(parallaxOffset, 0.0, 0.0), - child: const Text('左右滑动,这是第二行滚动速度更快的小字',style: const TextStyle(fontSize: 16.0,color: Colors.white),), + Matrix4.translationValues(parallaxOffset, 0.0, 0.0), + child: const Text( + '左右滑动,这是第二行滚动速度更快的小字', + style: const TextStyle(fontSize: 16.0, color: Colors.white), + ), ), ], ), diff --git a/lib/widgets/components/Scroll/ScrollPhysics/index.dart b/lib/widgets/components/Scroll/ScrollPhysics/index.dart index 1fd5afd6..258cb230 100644 --- a/lib/widgets/components/Scroll/ScrollPhysics/index.dart +++ b/lib/widgets/components/Scroll/ScrollPhysics/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 20:39:18 +/// @Author: 一凨 +/// @Date: 2018-12-15 20:39:18 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:26:11 @@ -8,14 +8,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart'; -const String content0 = ''' +const String content0 = ''' ### **简介** > 确定滚动组件的物理属性 - 例如,确定当用户达到最大滚动范围或者停止滚动时,Scrollable的一些滚动行为 - 当启动物理 [Simulation](https://docs.flutter.io/flutter/physics/Simulation-class.html) 时,当前滚动位置和速度将作为初始条件。 - 使用simulation中的模拟移动来确定widget的滚动位置 '''; -const String content1 = ''' +const String content1 = ''' ### **基本用法** > 该widget不能赋值给参数类型为Widget的组件 - 下方Demo,我们设置PageView的physics属性,滑动感受下下方小字自定义的滚动 @@ -36,7 +36,8 @@ class _DemoState extends State { ScrollPhysicsDemo(), ], codeUrl: 'components/Scroll/ScrollPhysics/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/widgets/ScrollPhysics-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/ScrollPhysics-class.html', title: 'ScrollPhysics', ); } diff --git a/lib/widgets/components/Scroll/ScrollView/demo.dart b/lib/widgets/components/Scroll/ScrollView/demo.dart index f305971a..fe4699b2 100644 --- a/lib/widgets/components/Scroll/ScrollView/demo.dart +++ b/lib/widgets/components/Scroll/ScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:15:27 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:15:27 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-10 21:16:05 @@ -9,7 +9,7 @@ class ScrollViewDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height: 400.0,//注意这里的高度必须得指定 + height: 400.0, //注意这里的高度必须得指定 child: PageView( children: [ Container( diff --git a/lib/widgets/components/Scroll/ScrollView/index.dart b/lib/widgets/components/Scroll/ScrollView/index.dart index 465e6a4a..03c309b2 100644 --- a/lib/widgets/components/Scroll/ScrollView/index.dart +++ b/lib/widgets/components/Scroll/ScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 20:30:53 +/// @Author: 一凨 +/// @Date: 2018-12-10 20:30:53 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-14 20:36:57 @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart'; - const String contentText0 = ''' ### **简介** > 一个可以使内容滚动的Widget diff --git a/lib/widgets/components/Scroll/Scrollable/demo.dart b/lib/widgets/components/Scroll/Scrollable/demo.dart index 1ab53c44..fb04f416 100644 --- a/lib/widgets/components/Scroll/Scrollable/demo.dart +++ b/lib/widgets/components/Scroll/Scrollable/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:32:07 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:32:07 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 16:26:20 diff --git a/lib/widgets/components/Scroll/Scrollable/index.dart b/lib/widgets/components/Scroll/Scrollable/index.dart index 82c07fe0..fe364669 100644 --- a/lib/widgets/components/Scroll/Scrollable/index.dart +++ b/lib/widgets/components/Scroll/Scrollable/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:31:24 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:31:24 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 17:05:20 @@ -40,4 +40,4 @@ class _DemoState extends State { title: 'Scrollable', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart b/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart index 7698eef5..320e595e 100644 --- a/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart +++ b/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 16:25:39 +/// @Author: 一凨 +/// @Date: 2018-12-15 16:25:39 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 19:36:43 @@ -14,7 +14,6 @@ const Duration _kScrollbarFadeDuration = Duration(milliseconds: 300); const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600); class PaintDemo extends StatelessWidget { - @override Widget build(BuildContext context) { return Container( diff --git a/lib/widgets/components/Scroll/ScrollbarPainter/index.dart b/lib/widgets/components/Scroll/ScrollbarPainter/index.dart index faf72744..cd9638aa 100644 --- a/lib/widgets/components/Scroll/ScrollbarPainter/index.dart +++ b/lib/widgets/components/Scroll/ScrollbarPainter/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 16:25:36 +/// @Author: 一凨 +/// @Date: 2018-12-15 16:25:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 19:38:18 diff --git a/lib/widgets/components/Scroll/index.dart b/lib/widgets/components/Scroll/index.dart index 0bdf7d15..5be113d5 100644 --- a/lib/widgets/components/Scroll/index.dart +++ b/lib/widgets/components/Scroll/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:51 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-22 20:37:51 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:51 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-22 20:37:51 import 'package:flutter/material.dart'; @@ -56,4 +56,4 @@ List widgetPoints = [ routerName: NestedScrollView.Demo.routeName, buildRouter: (BuildContext context) => NestedScrollView.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/Tab/Tab/demo.dart b/lib/widgets/components/Tab/Tab/demo.dart index d5d5774e..371cc5db 100644 --- a/lib/widgets/components/Tab/Tab/demo.dart +++ b/lib/widgets/components/Tab/Tab/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:38:01 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:38:01 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:51:47 @@ -16,12 +16,13 @@ class TabDemo extends StatelessWidget { } class MyTabbedPage extends StatefulWidget { - const MyTabbedPage({ Key key }) : super(key: key); + const MyTabbedPage({Key key}) : super(key: key); @override _MyTabbedPageState createState() => _MyTabbedPageState(); } -class _MyTabbedPageState extends State with SingleTickerProviderStateMixin { +class _MyTabbedPageState extends State + with SingleTickerProviderStateMixin { final List myTabs = [ Tab(text: 'LEFT'), Tab(text: 'RIGHT'), @@ -35,11 +36,11 @@ class _MyTabbedPageState extends State with SingleTickerProviderSt _tabController = TabController(vsync: this, length: myTabs.length); } - @override - void dispose() { - _tabController.dispose(); - super.dispose(); - } + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -58,4 +59,4 @@ class _MyTabbedPageState extends State with SingleTickerProviderSt ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Tab/Tab/index.dart b/lib/widgets/components/Tab/Tab/index.dart index 02a80d98..c402b25f 100644 --- a/lib/widgets/components/Tab/Tab/index.dart +++ b/lib/widgets/components/Tab/Tab/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:58 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:49:56 @@ -40,4 +40,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Tab/index.dart b/lib/widgets/components/Tab/index.dart index 866d9c8d..acea0f75 100644 --- a/lib/widgets/components/Tab/index.dart +++ b/lib/widgets/components/Tab/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:45 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:45 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:43:15 @@ -10,8 +10,8 @@ import './Tab/index.dart' as Tab; List widgetPoints = [ WidgetPoint( - name:'Tab', + name: 'Tab', routerName: Tab.Demo.routeName, buildRouter: (BuildContext context) => Tab.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/index.dart b/lib/widgets/components/index.dart index 2077b0da..6225c978 100644 --- a/lib/widgets/components/index.dart +++ b/lib/widgets/components/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 20:34:18 +/// @Author: 一凨 +/// @Date: 2018-12-10 20:34:18 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 21:25:40 @@ -18,7 +18,6 @@ import 'Dialog/index.dart' as Dialog; import 'Scaffold/index.dart' as Scaffold; import 'Grid/index.dart' as GridTile; - List getWidgets() { List result = []; result.addAll(Scroll.widgetPoints); @@ -36,4 +35,4 @@ List getWidgets() { result.addAll(Scaffold.widgetPoints); result.addAll(GridTile.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart index 42450c81..7d7d9bfe 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart @@ -13,16 +13,16 @@ var selectItValue; var selectItemValue; class DropdownButtonDefault extends StatelessWidget { - List generateItemList() { - final List items = List(); - final DropdownMenuItem item1 = DropdownMenuItem( - value: '张三', child: Text('张三')); - final DropdownMenuItem item2 = DropdownMenuItem( - value: '李四', child: Text('李四')); - final DropdownMenuItem item3 = DropdownMenuItem( - value: '王二', child: Text('王二')); - final DropdownMenuItem item4 = DropdownMenuItem( - value: '麻子', child: Text('麻子')); + List generateItemList() { + final List items = List(); + final DropdownMenuItem item1 = + DropdownMenuItem(value: '张三', child: Text('张三')); + final DropdownMenuItem item2 = + DropdownMenuItem(value: '李四', child: Text('李四')); + final DropdownMenuItem item3 = + DropdownMenuItem(value: '王二', child: Text('王二')); + final DropdownMenuItem item4 = + DropdownMenuItem(value: '麻子', child: Text('麻子')); items.add(item1); items.add(item2); items.add(item3); @@ -33,68 +33,68 @@ class DropdownButtonDefault extends StatelessWidget { @override Widget build(BuildContext context) { return DropdownButton( - hint: Text('下拉菜单选择一个人名'), - //设置这个value之后,选中对应位置的item, - //再次呼出下拉菜单,会自动定位item位置在当前按钮显示的位置处 - value: selectItValue, - items: generateItemList(), - onChanged: (T){ + hint: Text('下拉菜单选择一个人名'), + //设置这个value之后,选中对应位置的item, + //再次呼出下拉菜单,会自动定位item位置在当前按钮显示的位置处 + value: selectItValue, + items: generateItemList(), + onChanged: (T) { // setState(() { // selectItemValue=T; // }); - }, + }, ); } } -List getListData(){ - List items= List(); - DropdownMenuItem dropdownMenuItem1= DropdownMenuItem( +List getListData() { + List items = List(); + DropdownMenuItem dropdownMenuItem1 = DropdownMenuItem( child: Text('1'), value: '1', ); items.add(dropdownMenuItem1); - DropdownMenuItem dropdownMenuItem2= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem2 = DropdownMenuItem( child: Text('2'), value: '2', ); items.add(dropdownMenuItem2); - DropdownMenuItem dropdownMenuItem3= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem3 = DropdownMenuItem( child: Text('3'), value: '3', ); items.add(dropdownMenuItem3); - DropdownMenuItem dropdownMenuItem4= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem4 = DropdownMenuItem( child: Text('4'), value: '4', ); items.add(dropdownMenuItem4); - DropdownMenuItem dropdownMenuItem5= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem5 = DropdownMenuItem( child: Text('5'), value: '5', ); items.add(dropdownMenuItem5); - DropdownMenuItem dropdownMenuItem6= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem6 = DropdownMenuItem( child: Text('6'), value: '6', ); items.add(dropdownMenuItem6); - DropdownMenuItem dropdownMenuItem7= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem7 = DropdownMenuItem( child: Text('7'), value: '7', ); items.add(dropdownMenuItem7); - DropdownMenuItem dropdownMenuItem8= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem8 = DropdownMenuItem( child: Text('8'), value: '8', ); items.add(dropdownMenuItem8); - DropdownMenuItem dropdownMenuItem9= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem9 = DropdownMenuItem( child: Text('9'), value: '9', ); items.add(dropdownMenuItem9); - DropdownMenuItem dropdownMenuItem10= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem10 = DropdownMenuItem( child: Text('10'), value: '10', ); @@ -106,34 +106,33 @@ List getListData(){ class DropdownButtonCustom extends StatelessWidget { final widget; final parent; - const DropdownButtonCustom([this.widget,this.parent]) - : super(); + const DropdownButtonCustom([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return DropdownButton( - items: getListData(), - //当没有默认值的时候可以设置的提示 - hint:Text('下拉选择你想要的数据'), - //下拉菜单选择完之后显示给用户的值 - value: selectItemValue, - //下拉菜单item点击之后的回调 - onChanged: (T){ - if (parent.mounted) { - parent.setState(() { - selectItemValue = T; - }); - } - }, - //设置阴影的高度 - elevation: 24, - style: TextStyle(//设置文本框里面文字的样式 - color: Colors.red - ), - // isDense: true,//减少按钮的高度。默认情况下,此按钮的高度与其菜单项的高度相同。如果isDense为true,则按钮的高度减少约一半。 这个当按钮嵌入添加的容器中时,非常有用 - // 将下拉列表的内部内容设置为水平填充其父级 - isExpanded:true, - iconSize: 50.0,//设置三角标icon的大小 + items: getListData(), + //当没有默认值的时候可以设置的提示 + hint: Text('下拉选择你想要的数据'), + //下拉菜单选择完之后显示给用户的值 + value: selectItemValue, + //下拉菜单item点击之后的回调 + onChanged: (T) { + if (parent.mounted) { + parent.setState(() { + selectItemValue = T; + }); + } + }, + //设置阴影的高度 + elevation: 24, + style: TextStyle( + //设置文本框里面文字的样式 + color: Colors.red), + // isDense: true,//减少按钮的高度。默认情况下,此按钮的高度与其菜单项的高度相同。如果isDense为true,则按钮的高度减少约一半。 这个当按钮嵌入添加的容器中时,非常有用 + // 将下拉列表的内部内容设置为水平填充其父级 + isExpanded: true, + iconSize: 50.0, //设置三角标icon的大小 ); } } diff --git a/lib/widgets/elements/Form/Button/DropdownButton/index.dart b/lib/widgets/elements/Form/Button/DropdownButton/index.dart index f6d1ae8a..345d880b 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/index.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/index.dart @@ -11,19 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart' as dropdownButton; -const String _dropdownText0 = -"""### **简介** +const String _dropdownText0 = """### **简介** > Dropdown button “用于从项目列表中进行选择的按钮” - 参数类型 T 是下拉菜单表示的值的类型。给定菜单中的所有条目必须表示具有一致类型的值。通常,使用枚举。每个DropdownMenuItem在项目必须专门与同类型的说法; """; -const String _dropdownText1 = -"""### **基本用法** +const String _dropdownText1 = """### **基本用法** > 此示例显示一个包含四个项目的菜单 """; -const String _dropdownText2 = -"""### **进阶用法** +const String _dropdownText2 = """### **进阶用法** > 此示例尝试调整所有属性,展示出效果 """; @@ -36,25 +33,27 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ + void setButtonShapeType() { //String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - this.setState((){ + this.setState(() { //buttonShapeType = _buttonShapeType; }); } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'DropdownButton', codeUrl: 'elements/Form/Button/DropdownButton/demo.dart', - contentList: allDropdownButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/DropdownButton-class.html', + contentList: allDropdownButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/DropdownButton-class.html', ); } } // 所有的 DropdownButton 按钮 -List allDropdownButtons(BuildContext context,_DemoState that){ +List allDropdownButtons(BuildContext context, _DemoState that) { return [ _dropdownText0, _dropdownText1, @@ -71,4 +70,3 @@ List allDropdownButtons(BuildContext context,_DemoState that){ SizedBox(height: 20.0) ]; } - diff --git a/lib/widgets/elements/Form/Button/FlatButton/demo.dart b/lib/widgets/elements/Form/Button/FlatButton/demo.dart index 94cbcb50..88a4088a 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/demo.dart @@ -14,20 +14,19 @@ import 'package:flutter/material.dart'; class FlatButtonDefault extends StatelessWidget { final bool isDisabled; - const FlatButtonDefault([ this.isDisabled = true]) + const FlatButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @override Widget build(BuildContext context) { return FlatButton( - // 文本内容 + // 文本内容 child: const Text('默认按钮', semanticsLabel: 'FLAT BUTTON 1'), onPressed: isDisabled ? () {} : null); } } - // FlatButton.icon 默认按钮的实例 // Create a text button from a pair of widgets that serve as the button's icon and label // isDisabled:是否是禁用 @@ -36,7 +35,7 @@ class FlatButtonIconDefault extends StatelessWidget { final IconData icon; const FlatButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -49,18 +48,17 @@ class FlatButtonIconDefault extends StatelessWidget { @override Widget build(BuildContext context) { return FlatButton.icon( - // 文本内容 + // 文本内容 icon: Icon(icon, size: 25.0, color: _randomColor()), label: Text('默认按钮', semanticsLabel: 'FLAT BUTTON 2'), onPressed: isDisabled ? () { - //_showMessage('点击了 FLAT BUTTON ', context); - } + //_showMessage('点击了 FLAT BUTTON ', context); + } : null); } } - // FlatButton 自定义的实例 class FlatButtonCustom extends StatelessWidget { @@ -69,18 +67,18 @@ class FlatButtonCustom extends StatelessWidget { final ShapeBorder shape; final VoidCallback onPressed; - const FlatButtonCustom([ - this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed - ]) :super(); + const FlatButtonCustom( + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) + : super(); @override Widget build(BuildContext context) { final _onPressed = onPressed; return FlatButton( - // 文本内容 + // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 按钮颜色 color: color, @@ -101,14 +99,16 @@ class FlatButtonCustom extends StatelessWidget { splashColor: Colors.deepPurple, // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only( - bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), - shape: (shape is ShapeBorder) ? shape : Border.all( - // 设置边框样式 - color: Colors.grey, - width: 2.0, - style: BorderStyle.solid, - ), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + shape: (shape is ShapeBorder) + ? shape + : Border.all( + // 设置边框样式 + color: Colors.grey, + width: 2.0, + style: BorderStyle.solid, + ), // FlatButton 的点击事件 onPressed: () { // Perform some action @@ -120,7 +120,6 @@ class FlatButtonCustom extends StatelessWidget { // 参数 bool,按下后true,恢复false onHighlightChanged: (isClick) { print(isClick); - } - ); + }); } } diff --git a/lib/widgets/elements/Form/Button/FlatButton/index.dart b/lib/widgets/elements/Form/Button/FlatButton/index.dart index d7e5ba73..026b20f9 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/index.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/index.dart @@ -11,26 +11,21 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as flatButton; -const String _flatText0 = -"""### **简介** +const String _flatText0 = """### **简介** > FlatButton 是显示在(零高程)material widget 上的文本标签 - 通过填充颜色对触摸作出反应在工具栏上; - FlatButtons 故意不具有可见边框,因此必须依赖于它们相对于其他内容的位置以用于上下文; - 在对话框和卡片中,它们应该组合在一个底角中。避免使用平面按钮,它们会与其他内容混合,例如在列表中间;"""; -const String _flatText1 = -"""### **基本用法** +const String _flatText1 = """### **基本用法** > 参数的默认的 button 和禁用 button - 如果 onPressed 回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;。"""; - -const String _flatText2 = -"""### **进阶用法1** +const String _flatText2 = """### **进阶用法1** > FlatButton.icon ,button 图标和标签的 widget 创建文本按钮;"""; -const String _flatText3 = -"""### **进阶用法2** +const String _flatText3 = """### **进阶用法2** > 更改参数的自定义,比如:边框,点击效果,内容文字颜色等; - 要使应用程序的一部分具有交互式,使用 ink splashes,请考虑使用InkWell; - Flat button 的最小尺寸为88.0×36.0,可以用 ButtonTheme 覆盖。该clipBehavior参数不能为空;"""; @@ -54,75 +49,76 @@ class _DemoState extends State { } } - // 所有的 FlatButton 按钮 -List allFlatButtons(BuildContext context){ +// 所有的 FlatButton 按钮 +List allFlatButtons(BuildContext context) { return [ - _flatText0, - _flatText1, - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - mainAxisSize: MainAxisSize.max, - children: [ - flatButton.FlatButtonDefault(), - SizedBox(width: 20.0), // 间距 - flatButton.FlatButtonDefault(false), - ], - ), - _flatText2, - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - //mainAxisSize: MainAxisSize.min, - children: [ - flatButton.FlatButtonIconDefault(), - flatButton.FlatButtonIconDefault(false), - ], - ), - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - //mainAxisSize: MainAxisSize.min, - children: [ - flatButton.FlatButtonIconDefault(true, Icons.android), - flatButton.FlatButtonIconDefault(true, Icons.announcement), - ], - ), - _flatText3, - //flatButton.FlatButtonCustom(context,'主要按钮',Colors.blue), - flatButton.FlatButtonCustom('主要按钮',Colors.blue), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('成功按钮',Colors.green), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('信息按钮',Colors.grey), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('警告按钮',Colors.orange), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('危险按钮',Colors.pink), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('点击我试试!', Colors.red, - Border.all(color: Colors.brown, width: 5.0, style: BorderStyle.solid), - () => _showMessage('点击了 FLAT BUTTON ', context)), - SizedBox(height: 20.0) - ]; + _flatText0, + _flatText1, + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + mainAxisSize: MainAxisSize.max, + children: [ + flatButton.FlatButtonDefault(), + SizedBox(width: 20.0), // 间距 + flatButton.FlatButtonDefault(false), + ], + ), + _flatText2, + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + //mainAxisSize: MainAxisSize.min, + children: [ + flatButton.FlatButtonIconDefault(), + flatButton.FlatButtonIconDefault(false), + ], + ), + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + //mainAxisSize: MainAxisSize.min, + children: [ + flatButton.FlatButtonIconDefault(true, Icons.android), + flatButton.FlatButtonIconDefault(true, Icons.announcement), + ], + ), + _flatText3, + //flatButton.FlatButtonCustom(context,'主要按钮',Colors.blue), + flatButton.FlatButtonCustom('主要按钮', Colors.blue), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('成功按钮', Colors.green), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('信息按钮', Colors.grey), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('警告按钮', Colors.orange), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('危险按钮', Colors.pink), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom( + '点击我试试!', + Colors.red, + Border.all(color: Colors.brown, width: 5.0, style: BorderStyle.solid), + () => _showMessage('点击了 FLAT BUTTON ', context)), + SizedBox(height: 20.0) + ]; } - // alert 弹框 - // context:容器的父级 +// alert 弹框 +// context:容器的父级 void _showMessage(String name, BuildContext context) { showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text('提示'), - content: Text(name), - actions: [ - FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: Text('取消')) - ]); - } - ); + // alert 的父级 + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('提示'), + content: Text(name), + actions: [ + FlatButton( + // alert 的取消按钮 + onPressed: () { + // 取消的事件 + Navigator.of(context).pop(true); + }, + child: Text('取消')) + ]); + }); } diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart index 95303b83..045f0811 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; class FloatingActionButtonDefault extends StatelessWidget { final bool isDisabled; - const FloatingActionButtonDefault([ this.isDisabled = true]) + const FloatingActionButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -20,7 +20,7 @@ class FloatingActionButtonDefault extends StatelessWidget { Widget build(BuildContext context) { return FloatingActionButton( // 文本内容 - backgroundColor:Colors.red, + backgroundColor: Colors.red, child: const Icon(Icons.add), heroTag: null, // 不加这个参数会黑屏... onPressed: isDisabled ? () {} : null); @@ -35,45 +35,44 @@ class FloatingActionButtonCustom extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.orange, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override Widget build(BuildContext context) { - final _onPressed = (onPressed is Function) ? onPressed : ()=>{}; - return FloatingActionButton( - // 子视图,一般为Icon,不推荐使用文字 - child: const Icon(Icons.refresh), - // FAB的文字解释,FAB被长按时显示,也是无障碍功能 - tooltip: txt, - // 前景色 - foregroundColor: Colors.white, - // 背景色 - backgroundColor: color, - // hero效果使用的tag,系统默认会给所有FAB使用同一个tag,方便做动画效果,简单理解为两个界面内拥有同样tag的元素在界面切换过程中,会有动画效果,是界面切换不再那么生硬。 - heroTag: null, - // 未点击时阴影值,默认6.0 - elevation: 7.0, - // 点击时阴影值,默认12.0 - highlightElevation: 14.0, - // 点击事件回调 - onPressed: () { - Scaffold.of(context).showSnackBar( SnackBar( - content: Text("FAB is Clicked"), - )); - _onPressed(); - }, - // 是否为“mini”类型,默认为false,FAB 分为三种类型:regular, mini, and extended - mini: false, - // 定义FAB的shape,设置shape时,默认的elevation将会失效,默认为CircleBorder - //shape: CircleBorder(), - shape: shape, - // 是否为”extended”类型 - isExtended: true - ); + final _onPressed = (onPressed is Function) ? onPressed : () => {}; + return FloatingActionButton( + // 子视图,一般为Icon,不推荐使用文字 + child: const Icon(Icons.refresh), + // FAB的文字解释,FAB被长按时显示,也是无障碍功能 + tooltip: txt, + // 前景色 + foregroundColor: Colors.white, + // 背景色 + backgroundColor: color, + // hero效果使用的tag,系统默认会给所有FAB使用同一个tag,方便做动画效果,简单理解为两个界面内拥有同样tag的元素在界面切换过程中,会有动画效果,是界面切换不再那么生硬。 + heroTag: null, + // 未点击时阴影值,默认6.0 + elevation: 7.0, + // 点击时阴影值,默认12.0 + highlightElevation: 14.0, + // 点击事件回调 + onPressed: () { + Scaffold.of(context).showSnackBar(SnackBar( + content: Text("FAB is Clicked"), + )); + _onPressed(); + }, + // 是否为“mini”类型,默认为false,FAB 分为三种类型:regular, mini, and extended + mini: false, + // 定义FAB的shape,设置shape时,默认的elevation将会失效,默认为CircleBorder + //shape: CircleBorder(), + shape: shape, + // 是否为”extended”类型 + isExtended: true); } } @@ -85,10 +84,10 @@ class FloatingActionButtonCustom2 extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom2( - [ this.txt = '自定义按钮', - this.color = Colors.orange, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override @@ -102,8 +101,8 @@ class FloatingActionButtonCustom2 extends StatelessWidget { foregroundColor: Colors.white, backgroundColor: Colors.amber, //如果不手动设置icon和text颜色,则默认使用foregroundColor颜色 - icon: Icon(Icons.flag,color: Colors.red), - label: Text('FloatingActionButton.extended', maxLines: 1), + icon: Icon(Icons.flag, color: Colors.red), + label: Text('FloatingActionButton.extended', maxLines: 1), ); } } diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart index 71e5b8ea..8d3948c9 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart @@ -13,28 +13,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as floatingActionButton; - -const String _floatingActionText0 = -"""### **简介** +const String _floatingActionText0 = """### **简介** > FloatingAction Button “浮动动作按钮” - FloatingActionButton 按钮是一个圆形图标按钮,悬停在内容上以提升应用程序中的主要操作。浮动操作按钮最常用于Scaffold.floatingActionButton字段中; - 每个屏幕最多使用一个浮动操作按钮。浮动操作按钮应用于积极操作,例如“创建”,“共享”或“导航”; - 一般用来处理界面中最常用,最基础的用户动作。它一般出现在屏幕内容的前面,通常是一个圆形,中间有一个图标。 FAB有三种类型:regular, mini, extended。不要强行使用FAB,只有当使用场景符合FAB功能的时候使用才最为恰当; """; -const String _floatingActionText1 = -"""### **基本用法** +const String _floatingActionText1 = """### **基本用法** > 默认参数的 button 和禁用 button - 如果 onPressed 回调为null,则该 button 将被禁用,并且不会对触摸作出反应,不会变成灰色; """; -const String _floatingActionText2 = -"""### **进阶用法1** +const String _floatingActionText2 = """### **进阶用法1** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 """; -const String _floatingActionText3 = -"""### **进阶用法2** +const String _floatingActionText3 = """### **进阶用法2** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 """; @@ -47,28 +42,31 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'FloatingActionButton', // desc: _floatingActionTitle, codeUrl: 'elements/Form/Button/FloatingActionButton/demo.dart', - contentList: allFloatingActionButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/FloatingActionButton-class.html', + contentList: allFloatingActionButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/FloatingActionButton-class.html', ); } } - // 所有的 FloatingActionButton 按钮 -List allFloatingActionButtons(BuildContext context,_DemoState that){ +// 所有的 FloatingActionButton 按钮 +List allFloatingActionButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _floatingActionText0, @@ -96,12 +94,12 @@ List allFloatingActionButtons(BuildContext context,_DemoState that){ } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -112,7 +110,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -137,4 +136,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/IconButton/demo.dart b/lib/widgets/elements/Form/Button/IconButton/demo.dart index 69915c84..26010fda 100644 --- a/lib/widgets/elements/Form/Button/IconButton/demo.dart +++ b/lib/widgets/elements/Form/Button/IconButton/demo.dart @@ -10,16 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/resources/icon_names.dart'; - -final int len = IconNames.names.length; - +final int len = IconNames.names.length; // IconButton 默认按钮的实例 // isDisabled:是否是禁用,isDisabled 默认为true class IconButtonDefault extends StatelessWidget { final bool isDisabled; - const IconButtonDefault([ this.isDisabled = true]) + const IconButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -41,13 +39,13 @@ class IconButtonCustom extends StatelessWidget { final VoidCallback onPressed; const IconButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); - getIcons(){ + getIcons() { return Icons; } @@ -58,22 +56,23 @@ class IconButtonCustom extends StatelessWidget { final _onPressed = onPressed; return IconButton( // 定义图标在IconButton中的定位方式,AlignmentGeometry 如果父Widget尺寸大于child Widget尺寸,这个属性设置会起作用,有很多种对齐方式。 - alignment:AlignmentDirectional.center, + alignment: AlignmentDirectional.center, // 按钮颜色 color: _randomColor(), // 如果图标被禁用,则用于按钮内图标的颜色。默认为当前主题的ThemeData.disabledColor - disabledColor:_randomColor(), + disabledColor: _randomColor(), // 高亮时的背景色 highlightColor: Colors.yellow, // 按钮内图标的大小 - icon:Icon(type), + icon: Icon(type), // 图标尺寸 - iconSize:(Random.secure().nextInt(20)+20).toDouble(), // 随机大小 + iconSize: (Random.secure().nextInt(20) + 20).toDouble(), // 随机大小 // 按钮内部,墨汁飞溅的颜色,点击按钮时的渐变背景色,当你不设置高亮背景时才会看的更清楚 splashColor: _randomColor(), - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), // 描述按下按钮时将发生的操作的文本 - tooltip:'这是${ type.codePoint }信息', + tooltip: '这是${type.codePoint}信息', // IconButton 的点击事件 onPressed: () { // Perform some action diff --git a/lib/widgets/elements/Form/Button/IconButton/index.dart b/lib/widgets/elements/Form/Button/IconButton/index.dart index e15147df..836f3185 100644 --- a/lib/widgets/elements/Form/Button/IconButton/index.dart +++ b/lib/widgets/elements/Form/Button/IconButton/index.dart @@ -1,11 +1,10 @@ - - /// Created with FlutterGo. - /// User: 一晟 - /// Date: 2018/11/14 - /// Time: 下午4:31 - /// email: zhu.yan@alibaba-inc.com - /// target: IconButton 的示例 - /// 对应文档地址:https://docs.flutter.io/flutter/material/IconButton-class.html +/// Created with FlutterGo. +/// User: 一晟 +/// Date: 2018/11/14 +/// Time: 下午4:31 +/// email: zhu.yan@alibaba-inc.com +/// target: IconButton 的示例 +/// 对应文档地址:https://docs.flutter.io/flutter/material/IconButton-class.html import 'dart:math'; @@ -14,20 +13,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as iconButton; -const String _iconText0 = -"""### **简介** +const String _iconText0 = """### **简介** > Icon button “图标按钮” - IconButton widget上的图片,通过填充颜色(墨水)来对触摸作出反应; """; -const String _iconText1 = -"""### **基本用法** +const String _iconText1 = """### **基本用法** > 参数的默认的按钮和禁用按钮 - 图标按钮通常在AppBar.actions字段中使用,但它们也可以在许多其他地方使用; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; -const String _iconText2 = -"""### **进阶用法** +const String _iconText2 = """### **进阶用法** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等; - 如果可能,图标按钮的命中区域的大小至少为48.0像素,与实际的iconSize无关,以满足 Material Design规范中的触摸目标大小要求。的对准控制图标本身如何定位命中区域内; - ** 长按可弹出 tip 文字 ** @@ -42,27 +38,29 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'IconButton', codeUrl: 'elements/Form/Button/IconButton/demo.dart', - contentList: allIconButtons(context,this), + contentList: allIconButtons(context, this), docUrl: 'https://docs.flutter.io/flutter/material/IconButton-class.html', ); } } // 所有的 IconButton 按钮 -List allIconButtons(BuildContext context,_DemoState that){ +List allIconButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _iconText0, @@ -89,7 +87,7 @@ List allIconButtons(BuildContext context,_DemoState that){ iconButton.IconButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), RaisedButton( - // 文本内容 + // 文本内容 child: const Text('点击切换,图标按钮', semanticsLabel: 'FLAT BUTTON 1'), onPressed: () => that.setButtonShapeType()), SizedBox(height: 20.0) @@ -97,12 +95,12 @@ List allIconButtons(BuildContext context,_DemoState that){ } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -113,7 +111,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -138,4 +137,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart index 5f169f1c..8a603bdc 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart @@ -14,7 +14,7 @@ import 'package:flutter/material.dart'; class OutlineButtonDefault extends StatelessWidget { final bool isDisabled; - const OutlineButtonDefault([ this.isDisabled = true]) + const OutlineButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -35,7 +35,7 @@ class OutlineButtonIconDefault extends StatelessWidget { final IconData icon; const OutlineButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); @override @@ -60,10 +60,10 @@ class OutlineButtonCustom extends StatelessWidget { final VoidCallback onPressed; const OutlineButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override @@ -73,12 +73,14 @@ class OutlineButtonCustom extends StatelessWidget { // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 边框的颜色,颜色也可以走主题色 Theme.of(context).primaryColor - borderSide: BorderSide(color: _randomColor(),width:Random.secure().nextInt(10).toDouble()), + borderSide: BorderSide( + color: _randomColor(), + width: Random.secure().nextInt(10).toDouble()), // 按钮颜色 color: _randomColor(), // 按钮失效时边框颜色 disabledBorderColor: Colors.red, - highlightedBorderColor:Colors.black54, + highlightedBorderColor: Colors.black54, // 高亮时的背景色 highlightColor: Colors.yellow, // 失效时的背景色 @@ -94,7 +96,8 @@ class OutlineButtonCustom extends StatelessWidget { splashColor: _randomColor(), // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), //高亮时候的阴影 highlightElevation: 10.0, shape: shape, // 在Outline 里只能设置圆角,边框用borderSide diff --git a/lib/widgets/elements/Form/Button/OutlineButton/index.dart b/lib/widgets/elements/Form/Button/OutlineButton/index.dart index eb31d1e6..a215e1ec 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/index.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/index.dart @@ -13,26 +13,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as outlineButton; -const String _outlineText0 = -"""### **简介** +const String _outlineText0 = """### **简介** > Outline button “边框按钮” - RaisedButton和FlatButton之间的交叉:一个有边框的按钮,当按下按钮时,其高度增加,背景变得不透明; - 高程最初为0.0,其背景颜色 为透明。按下按钮时,其背景变为不透明,然后其高程增加到highlightElevation; """; -const String _outlineText1 = -"""### **基本用法** +const String _outlineText1 = """### **基本用法** > 参数的默认的 button 和禁用 button - 如果onPressed回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; - -const String _outlineText2 = -"""### **进阶用法1** +const String _outlineText2 = """### **进阶用法1** > OutlineButton.icon 的用法,按钮图标和标签的widget创建文本按钮"""; -const String _outlineText3 = -"""### **进阶用法2** +const String _outlineText3 = """### **进阶用法2** > 更改参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等; - Outline buttons 按钮有一个边框,其形状由形状定义 ,其外观由borderSide,disabledBorderColor 和 highlightedBorderColor 定义; - 如果您想要 ink-splash 效果,但又不想使用 button ,请考虑直接使用 InkWell; @@ -50,27 +45,30 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'OutlineButton', codeUrl: 'elements/Form/Button/OutlineButton/demo.dart', - contentList: allOutlineButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/OutlineButton-class.html', + contentList: allOutlineButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/OutlineButton-class.html', ); } } - // 所有的 OutlineButton 按钮 -List allOutlineButtons(BuildContext context,_DemoState that){ +// 所有的 OutlineButton 按钮 +List allOutlineButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _outlineText0, @@ -113,20 +111,19 @@ List allOutlineButtons(BuildContext context,_DemoState that){ SizedBox(height: 10.0), outlineButton.OutlineButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), - outlineButton.OutlineButtonCustom( - '点击切换,随机改变按钮的圆角,边框样式', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + outlineButton.OutlineButtonCustom('点击切换,随机改变按钮的圆角,边框样式', Colors.blue, + buttonShape, () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -137,7 +134,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -162,4 +160,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart index 839f51c6..cf11ace0 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart @@ -15,8 +15,7 @@ class PopupMenuButtonDefault extends StatelessWidget { final bool isDisabled; final String type; - const PopupMenuButtonDefault( - [ this.type = 'default1', this.isDisabled = true]) + const PopupMenuButtonDefault([this.type = 'default1', this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -43,23 +42,23 @@ class PopupMenuButtonDefault extends StatelessWidget { // setState(() { _selection = result; }); }, itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: WhyFarther.harder, - child: Text('Working a lot harder'), - ), - const PopupMenuItem( - value: WhyFarther.smarter, - child: Text('Being a lot smarter'), - ), - const PopupMenuItem( - value: WhyFarther.selfStarter, - child: Text('Being a self-starter'), - ), - const PopupMenuItem( - value: WhyFarther.tradingCharter, - child: Text('Placed in charge of trading charter'), - ), - ], + const PopupMenuItem( + value: WhyFarther.harder, + child: Text('Working a lot harder'), + ), + const PopupMenuItem( + value: WhyFarther.smarter, + child: Text('Being a lot smarter'), + ), + const PopupMenuItem( + value: WhyFarther.selfStarter, + child: Text('Being a self-starter'), + ), + const PopupMenuItem( + value: WhyFarther.tradingCharter, + child: Text('Placed in charge of trading charter'), + ), + ], ); } @@ -68,8 +67,8 @@ class PopupMenuButtonDefault extends StatelessWidget { child: Text('点我试试'), onSelected: (String value) {}, itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")) + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")) ]); } @@ -79,61 +78,58 @@ class PopupMenuButtonDefault extends StatelessWidget { icon: Icon(Icons.menu), onSelected: (String value) {}, itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")) + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")) ]); } } - class PopupMenuButtonCustom extends StatelessWidget { final widget; final parent; - const PopupMenuButtonCustom([this.widget,this.parent]) - : super(); + const PopupMenuButtonCustom([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { final String selectStr = widget.options['defaultSelect']; return PopupMenuButton( //如果提供,则用于此按钮的widget。 child: RaisedButton.icon( - disabledColor:Colors.red, - icon: Icon(Icons.message, size: 25.0,color:Colors.yellow), - label: Text( - '自定义按钮', style: TextStyle(color: Colors.white), + disabledColor: Colors.red, + icon: Icon(Icons.message, size: 25.0, color: Colors.yellow), + label: Text('自定义按钮', + style: TextStyle(color: Colors.white), semanticsLabel: 'FLAT BUTTON'), - onPressed:(){} // 激活状态按钮 - ), + onPressed: () {} // 激活状态按钮 + ), // 打开时放置菜单的z坐标。这可以控制菜单下方阴影的大小。 - elevation:10.0, + elevation: 10.0, // 如果提供,则用于此按钮的图标。 //icon // 菜单项的值(如果有),在菜单打开时应突出显示。 //initialValue:options['defaultSelect'], - initialValue:selectStr, + initialValue: selectStr, // 按下按钮时调用以创建要在菜单中显示的项目。 itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")), - PopupMenuItem(value: "选项三的内容", child: Text("选项三")), - PopupMenuItem(value: "选项四的内容", child: Text("选项四")) - ], + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")), + PopupMenuItem(value: "选项三的内容", child: Text("选项三")), + PopupMenuItem(value: "选项四的内容", child: Text("选项四")) + ], // 应用于弹出菜单按钮的偏移量(x,y)。 - offset:Offset(0.0,50.0), + offset: Offset(0.0, 50.0), // 当用户在不选择项目的情况下关闭弹出菜单时调用。 - onCanceled:()=> - print('onCanceled'), + onCanceled: () => print('onCanceled'), // 当用户从此按钮创建的弹出菜单中选择一个值时调用。 - onSelected:(String value){ + onSelected: (String value) { print('onSelected:${parent.setState}'); - parent.setState((){ - widget.options['defaultSelect']= value; + parent.setState(() { + widget.options['defaultSelect'] = value; }); }, // 默认情况下匹配IconButton的8 dps填充。在某些情况下,特别是在此按钮作为列表项的尾随元素出现的情况下,能够将填充设置为零是有用的。 - padding: EdgeInsets.only(bottom: 20.0, top: 20.0, left: 0.0, right: 0.0), + padding: + EdgeInsets.only(bottom: 20.0, top: 20.0, left: 0.0, right: 0.0), //描述按下按钮时将发生的操作的文本。 - tooltip:'这是信息' - ); + tooltip: '这是信息'); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart index a40e704d..e622da70 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart @@ -33,8 +33,8 @@ const String _titleText2 = """ class Demo extends StatefulWidget { static const String routeName = '/element/Form/Button/PopupMenuButton'; - final Map options = {'defaultSelect': '选项二的内容'}; - final _DemoState self = _DemoState(); + final Map options = {'defaultSelect': '选项二的内容'}; + final _DemoState self = _DemoState(); @override _DemoState createState() => self; @@ -42,19 +42,22 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - this.setState((){ + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + this.setState(() { buttonShapeType = _buttonShapeType; }); } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'PopupMenuButton', codeUrl: 'elements/Form/Button/RaisedButton/demo.dart', - contentList: allPopupMenuButton(widget,this), - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', + contentList: allPopupMenuButton(widget, this), + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', ); } } @@ -79,4 +82,4 @@ List allPopupMenuButton(Demo widget, State parent) { popupMenuButton.PopupMenuButtonCustom(widget, parent), SizedBox(height: 40.0) ]; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart index b386be84..c38b30fb 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; class RaisedButtonDefault extends StatelessWidget { final bool isDisabled; - const RaisedButtonDefault([ this.isDisabled = true]) + const RaisedButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -34,7 +34,7 @@ class RaisedButtonIconDefault extends StatelessWidget { final IconData icon; const RaisedButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -58,7 +58,6 @@ class RaisedButtonIconDefault extends StatelessWidget { } } - // RaisedButton 自定义的实例 class RaisedButtonCustom extends StatelessWidget { final String txt; @@ -67,10 +66,10 @@ class RaisedButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RaisedButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override @@ -99,10 +98,10 @@ class RaisedButtonCustom extends StatelessWidget { // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, padding: - EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), shape: (shape is ShapeBorder) ? shape - : Border.all( + : Border.all( // 设置边框样式 color: Colors.grey, width: 2.0, diff --git a/lib/widgets/elements/Form/Button/RaisedButton/index.dart b/lib/widgets/elements/Form/Button/RaisedButton/index.dart index 87caba25..de352853 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/index.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/index.dart @@ -13,28 +13,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as raisedButton; - -const String _raisedText0 = -"""### **简介** +const String _raisedText0 = """### **简介** > Raised button “凸起按钮” - Raised button 基于 a Material widget 窗口widget,按下 button 时,Material.elevation 会增加; - 使用 Raised button 可将尺寸添加到大多数平面布局中; - 例如在复杂的内容列表中,或在宽阔的空间中。避免在已经提出的内容(例如对话框或卡片)上使用 Raised button; """; -const String _raisedText1 = -"""### **基本用法** +const String _raisedText1 = """### **基本用法** > 参数的默认的 button 和禁用 button; - 如果onPressed回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; - -const String _raisedText2 = -"""### **进阶用法1** +const String _raisedText2 = """### **进阶用法1** > RaisedButton.icon 的用方法,按钮图标和标签的widget创建文本按钮;"""; -const String _raisedText3 = -"""### **进阶用法2** +const String _raisedText3 = """### **进阶用法2** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 - 如果您想要 ink-splash 的墨水效果,但又不想使用按钮,请考虑直接使用InkWell; - Raised buttons 的最小尺寸为88.0×36.0,可以用 ButtonTheme 覆盖; @@ -50,27 +44,30 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'RaisedButton', codeUrl: 'elements/Form/Button/RaisedButton/demo.dart', contentList: allRaisedButtons(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/RaisedButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RaisedButton-class.html', ); } } - // 所有的 RaisedButton 按钮 -List allRaisedButtons(BuildContext context,_DemoState that){ +// 所有的 RaisedButton 按钮 +List allRaisedButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _raisedText0, @@ -114,18 +111,18 @@ List allRaisedButtons(BuildContext context,_DemoState that){ raisedButton.RaisedButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), raisedButton.RaisedButtonCustom('点击切换,按钮的圆角', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -136,7 +133,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -161,4 +159,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart index a763504c..cb89d945 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart @@ -15,7 +15,7 @@ import 'package:flutter/material.dart'; class RawMaterialButtonDefault extends StatelessWidget { final bool isDisabled; - const RawMaterialButtonDefault([ this.isDisabled = true]) + const RawMaterialButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -36,21 +36,21 @@ class RawMaterialButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RawMaterialButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override Widget build(BuildContext context) { final _onPressed = onPressed; - final _fontSize = (Random.secure().nextInt(10)+15).toDouble(); + final _fontSize = (Random.secure().nextInt(10) + 15).toDouble(); return RawMaterialButton( // 使用Material.textStyle为按钮的子项定义默认文本样式。 - textStyle:TextStyle(color: _randomColor(),fontSize: _fontSize), + textStyle: TextStyle(color: _randomColor(), fontSize: _fontSize), // 定义形状和高程的动画更改的持续时间 - animationDuration:Duration(seconds: 1), + animationDuration: Duration(seconds: 1), // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 高亮时的背景色 @@ -59,7 +59,8 @@ class RawMaterialButtonCustom extends StatelessWidget { splashColor: _randomColor(), // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), //高亮时候的阴影 highlightElevation: 10.0, // 按钮材质的形状 diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart index b17bf1fa..b422ef91 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart @@ -13,20 +13,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as rawMaterialButton; -const String _rawMaterialText0 = -"""### **简介** +const String _rawMaterialText0 = """### **简介** > RawMaterial button “RawMaterial 按钮” - 基于 Semantics,Material 和InkWell 小部件创建按钮; - 此类不使用当前 Theme 或 ButtonTheme 来计算未指定参数的默认值。它旨在用于自定义 Material button,可选择包含主题或特定于应用程序源的默认值; """; -const String _rawMaterialText1 = -"""### **基本用法** +const String _rawMaterialText1 = """### **基本用法** > 参数的默认的 button 和禁用 button """; -const String _rawMaterialText2 = -"""### **进阶用法** +const String _rawMaterialText2 = """### **进阶用法** > 更改项参数的自定义 """; @@ -39,28 +36,29 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ + void setButtonShapeType() { //String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if( mounted ) { + if (mounted) { this.setState(() { //buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'RawMaterialButton', codeUrl: 'elements/Form/Button/RawMaterialButton/demo.dart', - contentList: allRawMaterialButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/RawMaterialButton-class.html', + contentList: allRawMaterialButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/RawMaterialButton-class.html', ); } } - // 所有的 RawMaterialButton 按钮 -List allRawMaterialButtons(BuildContext context,_DemoState that){ +List allRawMaterialButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _rawMaterialText0, @@ -88,20 +86,19 @@ List allRawMaterialButtons(BuildContext context,_DemoState that){ SizedBox(height: 10.0), rawMaterialButton.RawMaterialButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), - rawMaterialButton.RawMaterialButtonCustom( - '点击切换,观察字体变化', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + rawMaterialButton.RawMaterialButtonCustom('点击切换,观察字体变化', Colors.blue, + buttonShape, () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -112,7 +109,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -137,4 +135,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/index.dart b/lib/widgets/elements/Form/Button/index.dart index b5cda7e7..24d2b29f 100644 --- a/lib/widgets/elements/Form/Button/index.dart +++ b/lib/widgets/elements/Form/Button/index.dart @@ -10,7 +10,6 @@ import 'FloatingActionButton/index.dart' as FloatingActionButton; import 'RawMaterialButton/index.dart' as RawMaterialButton; import 'DropdownButton/index.dart' as DropdownButton; - List widgetPoints = [ WidgetPoint( name: 'FlatButton', @@ -52,4 +51,4 @@ List widgetPoints = [ routerName: DropdownButton.Demo.routeName, buildRouter: (BuildContext context) => DropdownButton.Demo(), ) -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart index 7cd4037f..2ed71c8e 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart @@ -11,30 +11,30 @@ import 'package:flutter/material.dart'; /// Checkbox 默认的实例 /// index 当前checkbox 的索引值 -class CheckboxDefault extends StatefulWidget{ +class CheckboxDefault extends StatefulWidget { final int index; final parent; const CheckboxDefault([this.parent, this.index = -1]) : super(); @override - State createState() =>_CheckboxDefault(); + State createState() => _CheckboxDefault(); } + class _CheckboxDefault extends State { - bool isChecked=false; + bool isChecked = false; Color color = _randomColor(); // 注意和下面的 StatelessWidget 里的 _randomColor 区别 @override Widget build(BuildContext context) { return Checkbox( activeColor: color, - tristate:false, + tristate: false, value: isChecked, onChanged: (bool bol) { - if(mounted) { + if (mounted) { setState(() { isChecked = bol; }); } - } - ); + }); } } @@ -45,24 +45,22 @@ class CheckboxSelect extends StatelessWidget { final widget; final parent; - const CheckboxSelect([this.widget,this.parent, this.index = -1]) - : super(); + const CheckboxSelect([this.widget, this.parent, this.index = -1]) : super(); @override Widget build(BuildContext context) { Color color = _randomColor(); return Checkbox( activeColor: color, - tristate:false, + tristate: false, value: parent.selectValue == this.index, onChanged: (bool bol) { - if(parent.mounted) { + if (parent.mounted) { parent.setState(() { parent.selectValue = bol ? this.index : -1; }); } - } - ); + }); } } diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart index 2a65383f..dd3a2efb 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart @@ -11,22 +11,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as checkbox; -const String _checkboxText0 = -"""### **简介** +const String _checkboxText0 = """### **简介** > checkbox “复选框” - 复选框本身不保持任何状态; - 当复选框的状态发生变化时,窗口小部件会调用onChanged回调; - 大多数使用复选框的小部件将侦听onChanged回调,并使用新值重建复选框以更新复选框的可视外观;"""; - -const String _checkboxText1 = -"""### **基本用法** +const String _checkboxText1 = """### **基本用法** > 下面示例展示多个颜色(随机)样式的 `checkbox` - 一个多选的 `checkbox`; """; -const String _checkboxText2 = -"""### **进阶用法** +const String _checkboxText2 = """### **进阶用法** > 下面示例展示多个颜色(随机)样式的 `checkbox` - 一个单选 `checkbox` 操作; """; @@ -45,14 +41,14 @@ class _DemoState extends State { return WidgetDemo( title: 'Checkbox', codeUrl: 'elements/Form/CheckBox/Checkbox/demo.dart', - contentList: allCheckboxs(context,this), + contentList: allCheckboxs(context, this), docUrl: 'https://docs.flutter.io/flutter/material/Checkbox-class.html', ); } } - // 所有的 Checkbox 按钮 -List allCheckboxs(BuildContext context,_DemoState that){ +// 所有的 Checkbox 按钮 +List allCheckboxs(BuildContext context, _DemoState that) { return [ _checkboxText0, _checkboxText1, @@ -82,5 +78,3 @@ List allCheckboxs(BuildContext context,_DemoState that){ SizedBox(width: 20.0), // 间距 ]; } - - diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart index a302b59c..84a8c950 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart @@ -23,78 +23,80 @@ class _CheckboxListTileStateDefault extends State { for (var i = 0; i < isChecks.length; i++) { isChecks[i] = value; } - if(mounted) { + if (mounted) { setState(() => _value = value); } } - bool isCheck=false; - List isChecks=[false,false,false,false]; + + bool isCheck = false; + List isChecks = [false, false, false, false]; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Center( + Center( child: CheckboxListTile( value: _value, - selected:true,// 默认文字是否高亮 + selected: true, // 默认文字是否高亮 onChanged: _valueChanged, - dense: false,// 文字是否对齐 图标高度 - isThreeLine: false,// 文字是否三行显示 - title: Text('全部'), // 主标题 - controlAffinity: ListTileControlAffinity.trailing, // 将控件放在何处相对于文本,leading 按钮显示在文字后面,platform,trailing 按钮显示在文字前面 - subtitle: Text('勾选下列全部结果'), // 标题下方显示的副标题 - secondary: Icon(Icons.archive), // 从复选框显示在磁贴另一侧的小组件 + dense: false, // 文字是否对齐 图标高度 + isThreeLine: false, // 文字是否三行显示 + title: Text('全部'), // 主标题 + controlAffinity: ListTileControlAffinity + .trailing, // 将控件放在何处相对于文本,leading 按钮显示在文字后面,platform,trailing 按钮显示在文字前面 + subtitle: Text('勾选下列全部结果'), // 标题下方显示的副标题 + secondary: Icon(Icons.archive), // 从复选框显示在磁贴另一侧的小组件 activeColor: Colors.red, // 选中此复选框时要使用的颜色 ), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[0], - title: Text('选项1'), + title: Text('选项1'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ - if(mounted) { + onChanged: (bool) { + if (mounted) { setState(() { isChecks[0] = bool; }); } }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[1], - title: Text('选项2'), + title: Text('选项2'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[1]=bool; + isChecks[1] = bool; }); }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[2], - title: Text('选项3'), + title: Text('选项3'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[2]=bool; + isChecks[2] = bool; }); }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[3], - title: Text('选项4'), + title: Text('选项4'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[3]=bool; + isChecks[3] = bool; }); }), ) @@ -107,8 +109,7 @@ class _CheckboxListTileStateDefault extends State { class CheckboxListTileDefault extends StatelessWidget { final widget; final parant; - const CheckboxListTileDefault ([this.widget,this.parant]) - : super(); + const CheckboxListTileDefault([this.widget, this.parant]) : super(); @override Widget build(BuildContext context) { @@ -116,10 +117,10 @@ class CheckboxListTileDefault extends StatelessWidget { title: Text('一个简单的例子'), activeColor: Colors.red, value: widget.valBool['val'], - onChanged: (bool value) { - parant.setState(()=> widget.valBool['val'] = value); - }, - secondary: const Icon(Icons.hourglass_empty), + onChanged: (bool value) { + parant.setState(() => widget.valBool['val'] = value); + }, + secondary: const Icon(Icons.hourglass_empty), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart index 47605144..6da94e38 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart @@ -10,16 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as CheckboxListTileDemo; -const String _CheckboxListTileText0 = -"""### **简介** +const String _CheckboxListTileText0 = """### **简介** > CheckboxListTile “下拉复选框” - 带有复选框的 ListTile,带有标签的 ListTile; - 整个列表图块是交互式的:点击图块中的任意位置可切换复选框; """; - -const String _CheckboxListTileText1 = -"""### **基本用法** +const String _CheckboxListTileText1 = """### **基本用法** > CheckboxListTile 的属性特征 - 与 Checkbox 类似的命名属性,比如:onChanged 和 activeColor; - 和 ListTile 类似的命名属性,比如:title, subtitle, isThreeLine,dense; @@ -27,14 +24,13 @@ const String _CheckboxListTileText1 = - onChanged 回调函数为 null,显示禁用; """; -const String _CheckboxListTileText2 = -"""### **进阶用法** +const String _CheckboxListTileText2 = """### **进阶用法** > CheckboxListTile 单选和全选的示例 """; class Demo extends StatefulWidget { static const String routeName = '/element/Form/Checkbox/CheckboxListTile'; - final Map valBool = {'val':true}; + final Map valBool = {'val': true}; @override _DemoState createState() => _DemoState(); } @@ -46,14 +42,15 @@ class _DemoState extends State { title: 'CheckboxListTile', codeUrl: 'elements/Form/CheckBox/CheckboxListTile/demo.dart', contentList: allCheckboxs(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/CheckboxListTile-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/CheckboxListTile-class.html', ); } } - // 所有的 CheckboxListTile widget - // context: 运行上下文 - // that: 指向有状态的 StatefulWidget +// 所有的 CheckboxListTile widget +// context: 运行上下文 +// that: 指向有状态的 StatefulWidget List allCheckboxs(BuildContext context, _DemoState that) { return [ _CheckboxListTileText0, @@ -65,4 +62,3 @@ List allCheckboxs(BuildContext context, _DemoState that) { SizedBox(height: 20.0), ]; } - diff --git a/lib/widgets/elements/Form/CheckBox/index.dart b/lib/widgets/elements/Form/CheckBox/index.dart index 6c26b47d..8e9eea85 100644 --- a/lib/widgets/elements/Form/CheckBox/index.dart +++ b/lib/widgets/elements/Form/CheckBox/index.dart @@ -4,7 +4,6 @@ import '../../../../model/widget.dart'; import 'Checkbox/index.dart' as Checkbox; import 'CheckboxListTile/index.dart' as CheckboxListTile; - List widgetPoints = [ WidgetPoint( name: 'Checkbox', @@ -16,4 +15,4 @@ List widgetPoints = [ routerName: CheckboxListTile.Demo.routeName, buildRouter: (BuildContext context) => CheckboxListTile.Demo(), ) -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/Input/TextField/index.dart b/lib/widgets/elements/Form/Input/TextField/index.dart index fe5fe77b..bbb2900c 100644 --- a/lib/widgets/elements/Form/Input/TextField/index.dart +++ b/lib/widgets/elements/Form/Input/TextField/index.dart @@ -34,7 +34,7 @@ const String _textFieldText2 = """### **进阶用法** """; class Demo extends StatefulWidget { - static const String routeName = 'elements/Form/Input/TextField'; + static const String routeName = 'element/Form/Input/TextField'; @override _DemoState createState() => _DemoState(); diff --git a/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart b/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart index f028bfe0..147a3435 100644 --- a/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart +++ b/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; class DefaultTextField extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return Container( padding: const EdgeInsets.all(30.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, //文本是起始端对齐 @@ -27,7 +27,7 @@ class CustomTextField extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return Container( padding: const EdgeInsets.all(30.0), child: TextField( keyboardType: TextInputType.number, diff --git a/lib/widgets/elements/Form/Radio/Radio/demo.dart b/lib/widgets/elements/Form/Radio/Radio/demo.dart index 2e5df8df..69e4a8ef 100644 --- a/lib/widgets/elements/Form/Radio/Radio/demo.dart +++ b/lib/widgets/elements/Form/Radio/Radio/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:37 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:37 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -18,38 +18,34 @@ class _Demo extends State { groupValue = val; }); } + Widget build(BuildContext context) { - return ( - Container( - alignment: Alignment.centerLeft, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Radio( - value: 1, - groupValue: groupValue,//当value和groupValue一致的时候则选中 - onChanged: (T){ - onChange(T); - } - ), - Radio( - value: 2, - groupValue: groupValue, - onChanged: (T){ - onChange(T); - } - ), - Radio( - value: 3, - groupValue: groupValue, - onChanged: (T){ - onChange(T); - } - ) - ], - ), - ) - ); + return (Container( + alignment: Alignment.centerLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Radio( + value: 1, + groupValue: groupValue, //当value和groupValue一致的时候则选中 + onChanged: (T) { + onChange(T); + }), + Radio( + value: 2, + groupValue: groupValue, + onChanged: (T) { + onChange(T); + }), + Radio( + value: 3, + groupValue: groupValue, + onChanged: (T) { + onChange(T); + }) + ], + ), + )); } } diff --git a/lib/widgets/elements/Form/Radio/Radio/index.dart b/lib/widgets/elements/Form/Radio/Radio/index.dart index ba347f19..8f79c2bf 100644 --- a/lib/widgets/elements/Form/Radio/Radio/index.dart +++ b/lib/widgets/elements/Form/Radio/Radio/index.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:17 - /// email: sanfan.hx@alibaba-inc.com - /// target: Radio相关 +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:17 +/// email: sanfan.hx@alibaba-inc.com +/// target: Radio相关 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -24,6 +24,7 @@ Radio widget 代表表单中的单选按钮, 当groupValue = value时代表组 - onChanged → ValueChanged - 改变时触发。 - value → T - 单选的值。 """; + class Demo extends StatefulWidget { static const String routeName = '/element/Form/Radio/Radio'; _DemoState createState() => _DemoState(); diff --git a/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart b/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart index 7bd16122..57fe51e6 100644 --- a/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart +++ b/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 14:32 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 14:32 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class DemoA extends StatefulWidget { _Demo createState() => _Demo(); } @@ -20,25 +19,23 @@ class _Demo extends State { value = v; }); } - Widget build(BuildContext context) { - return Column( + Widget build(BuildContext context) { + return Column( children: [ RadioListTile( - title: const Text('A'), - value: "A", - groupValue: this.value, - isThreeLine: false, - subtitle: const Text("subtitleA"), - onChanged:onChange - ), + title: const Text('A'), + value: "A", + groupValue: this.value, + isThreeLine: false, + subtitle: const Text("subtitleA"), + onChanged: onChange), RadioListTile( - title: const Text('B'), - value: "B", + title: const Text('B'), + value: "B", subtitle: const Text("subtitleB"), - groupValue: this.value, - onChanged: onChange - ), + groupValue: this.value, + onChanged: onChange), ], ); } diff --git a/lib/widgets/elements/Form/Radio/RadioListTile/index.dart b/lib/widgets/elements/Form/Radio/RadioListTile/index.dart index 603451c7..0f7ed52c 100644 --- a/lib/widgets/elements/Form/Radio/RadioListTile/index.dart +++ b/lib/widgets/elements/Form/Radio/RadioListTile/index.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:17 - /// email: sanfan.hx@alibaba-inc.com - /// target: Radio相关 +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:17 +/// email: sanfan.hx@alibaba-inc.com +/// target: Radio相关 import 'package:flutter/material.dart'; @@ -21,6 +21,7 @@ const content1 = """ ### **基本用法** Radio是单选框,和checkbox一样本身不包含状态,当groupValue = value时代表选中状态 """; + class Demo extends StatefulWidget { static const String routeName = '/element/Form/RadioListTile/index'; _DemoState createState() => _DemoState(); @@ -30,13 +31,10 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content1, - new DemoA() - - ], + contentList: [content1, new DemoA()], title: 'RadioListTile', - docUrl: 'https://docs.flutter.io/flutter/material/RadioListTile-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RadioListTile-class.html', codeUrl: 'elements/Form/Radio/RadioListTile/demo.dart', ); } diff --git a/lib/widgets/elements/Form/Radio/index.dart b/lib/widgets/elements/Form/Radio/index.dart index f987d9ed..fb88bd7f 100644 --- a/lib/widgets/elements/Form/Radio/index.dart +++ b/lib/widgets/elements/Form/Radio/index.dart @@ -4,7 +4,6 @@ import '../../../../model/widget.dart'; import 'Radio/index.dart' as Radio; import 'RadioListTile/index.dart' as RadioTile; - List widgetPoints = [ WidgetPoint( name: 'Radio', @@ -16,5 +15,4 @@ List widgetPoints = [ routerName: RadioTile.Demo.routeName, buildRouter: (BuildContext context) => RadioTile.Demo(), ), - -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/Slider/Slider/demo.dart b/lib/widgets/elements/Form/Slider/Slider/demo.dart index 9e596828..9bc326ab 100644 --- a/lib/widgets/elements/Form/Slider/Slider/demo.dart +++ b/lib/widgets/elements/Form/Slider/Slider/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - class SliderDemo extends StatefulWidget { _Demo createState() => _Demo(); } diff --git a/lib/widgets/elements/Form/Slider/Slider/index.dart b/lib/widgets/elements/Form/Slider/Slider/index.dart index 515ae27e..32cc4e04 100644 --- a/lib/widgets/elements/Form/Slider/Slider/index.dart +++ b/lib/widgets/elements/Form/Slider/Slider/index.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -40,7 +40,6 @@ slider 用来选择连续性的或者非连续性的数据. 默认是在一段 '''; - const contentB = ''' ### **高级用法** > 自定义Slider 样式 @@ -80,12 +79,7 @@ class _Demo extends State { return WidgetDemo( title: 'Slider', codeUrl: 'elements/Form/Slider/Slider/demo.dart', - contentList: [ - contentA, - SliderDemo(), - contentB, - SliderThemeDemo() - ], + contentList: [contentA, SliderDemo(), contentB, SliderThemeDemo()], docUrl: 'https://docs.flutter.io/flutter/material/Slider-class.html', ); } diff --git a/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart b/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart index babb65c5..0a1dd402 100644 --- a/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart +++ b/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 27/12/2018 - /// Time: 14:40 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 27/12/2018 +/// Time: 14:40 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class SliderThemeDemo extends StatefulWidget { _SliderThemeDemo createState() => _SliderThemeDemo(); } @@ -16,43 +15,44 @@ class _SliderThemeDemo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return Container( - child: SliderTheme( + return Container( + child: SliderTheme( data: SliderTheme.of(context).copyWith( // activeTickMarkColor:Colors.yellowAccent, - activeTrackColor: Colors.yellowAccent,//实际进度的颜色 + activeTrackColor: Colors.yellowAccent, //实际进度的颜色 // inactiveTickMarkColor:Colors.black - thumbColor: Colors.black,//滑块中心的颜色 - inactiveTrackColor:Colors.red,//默 认进度条的颜色 - valueIndicatorColor: Colors.blue,//提示进度的气派的背景色 - valueIndicatorTextStyle: TextStyle(//提示气泡里面文字的样式 + thumbColor: Colors.black, //滑块中心的颜色 + inactiveTrackColor: Colors.red, //默 认进度条的颜色 + valueIndicatorColor: Colors.blue, //提示进度的气派的背景色 + valueIndicatorTextStyle: TextStyle( + //提示气泡里面文字的样式 color: Colors.white, ), - inactiveTickMarkColor:Colors.blue,//divisions对进度线分割后 断续线中间间隔的颜色 - overlayColor: Colors.pink,//滑块边缘颜色 + inactiveTickMarkColor: Colors.blue, //divisions对进度线分割后 断续线中间间隔的颜色 + overlayColor: Colors.pink, //滑块边缘颜色 ), - child: Container( + child: Container( width: 340.0, margin: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0), - child: Row( + child: Row( children: [ - Text('0.0'), - Expanded( + Text('0.0'), + Expanded( flex: 1, - child: Slider( + child: Slider( value: value, label: '$value', divisions: 10, - onChanged: (double){ + onChanged: (double) { setState(() { - value=double.floorToDouble();//转化成double + value = double.floorToDouble(); //转化成double }); }, min: 0.0, max: 100.0, ), ), - Text('100.0'), + Text('100.0'), ], ), ), diff --git a/lib/widgets/elements/Form/Slider/SliderTheme/index.dart b/lib/widgets/elements/Form/Slider/SliderTheme/index.dart index 8b8e8b2a..61dc6a65 100644 --- a/lib/widgets/elements/Form/Slider/SliderTheme/index.dart +++ b/lib/widgets/elements/Form/Slider/SliderTheme/index.dart @@ -1,14 +1,14 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 17:43 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 17:43 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -52,7 +52,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Slider/SliderTheme'; _Demo createState() => _Demo(); @@ -66,7 +65,7 @@ class _Demo extends State { codeUrl: 'elements/Form/Slider/SliderTheme/demo.dart', contentList: [ contentA, - SliderThemeDemo(), + SliderThemeDemo(), ], docUrl: 'https://docs.flutter.io/flutter/material/SliderTheme-class.html', ); diff --git a/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart b/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart index babb65c5..0a1dd402 100644 --- a/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart +++ b/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 27/12/2018 - /// Time: 14:40 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 27/12/2018 +/// Time: 14:40 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class SliderThemeDemo extends StatefulWidget { _SliderThemeDemo createState() => _SliderThemeDemo(); } @@ -16,43 +15,44 @@ class _SliderThemeDemo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return Container( - child: SliderTheme( + return Container( + child: SliderTheme( data: SliderTheme.of(context).copyWith( // activeTickMarkColor:Colors.yellowAccent, - activeTrackColor: Colors.yellowAccent,//实际进度的颜色 + activeTrackColor: Colors.yellowAccent, //实际进度的颜色 // inactiveTickMarkColor:Colors.black - thumbColor: Colors.black,//滑块中心的颜色 - inactiveTrackColor:Colors.red,//默 认进度条的颜色 - valueIndicatorColor: Colors.blue,//提示进度的气派的背景色 - valueIndicatorTextStyle: TextStyle(//提示气泡里面文字的样式 + thumbColor: Colors.black, //滑块中心的颜色 + inactiveTrackColor: Colors.red, //默 认进度条的颜色 + valueIndicatorColor: Colors.blue, //提示进度的气派的背景色 + valueIndicatorTextStyle: TextStyle( + //提示气泡里面文字的样式 color: Colors.white, ), - inactiveTickMarkColor:Colors.blue,//divisions对进度线分割后 断续线中间间隔的颜色 - overlayColor: Colors.pink,//滑块边缘颜色 + inactiveTickMarkColor: Colors.blue, //divisions对进度线分割后 断续线中间间隔的颜色 + overlayColor: Colors.pink, //滑块边缘颜色 ), - child: Container( + child: Container( width: 340.0, margin: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0), - child: Row( + child: Row( children: [ - Text('0.0'), - Expanded( + Text('0.0'), + Expanded( flex: 1, - child: Slider( + child: Slider( value: value, label: '$value', divisions: 10, - onChanged: (double){ + onChanged: (double) { setState(() { - value=double.floorToDouble();//转化成double + value = double.floorToDouble(); //转化成double }); }, min: 0.0, max: 100.0, ), ), - Text('100.0'), + Text('100.0'), ], ), ), diff --git a/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart b/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart index b28e578a..8dd56b78 100644 --- a/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart +++ b/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart @@ -1,15 +1,15 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 17:43 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 17:43 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -25,7 +25,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Slider/SliderThemeData'; _Demo createState() => _Demo(); @@ -38,11 +37,9 @@ class _Demo extends State { return WidgetDemo( title: 'SliderThemeData', codeUrl: 'elements/Form/Slider/SliderThemeData/demo.dart', - contentList: [ - contentA, - SliderThemeDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SliderThemeData-class.html', + contentList: [contentA, SliderThemeDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SliderThemeData-class.html', ); } } diff --git a/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart b/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart index 1ec3e50a..ab982c9a 100644 --- a/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart +++ b/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 19:58 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 19:58 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -47,4 +47,4 @@ class _ClickCounterState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/Switch/demo.dart b/lib/widgets/elements/Form/Switch/Switch/demo.dart index a575b718..a6c9cbe8 100644 --- a/lib/widgets/elements/Form/Switch/Switch/demo.dart +++ b/lib/widgets/elements/Form/Switch/Switch/demo.dart @@ -15,7 +15,7 @@ class _Demo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch( + return Switch( value: this.check, onChanged: (bool val) { this.setState(() { @@ -34,9 +34,9 @@ class _SwitchHighDemo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch.adaptive( + return Switch.adaptive( value: this.check, - activeColor: Colors.blue, // 激活时原点颜色 + activeColor: Colors.blue, // 激活时原点颜色 onChanged: (bool val) { this.setState(() { this.check = !this.check; @@ -46,7 +46,6 @@ class _SwitchHighDemo extends State { } } - class SwitchTypesDemo extends StatefulWidget { _SwitchTypesDemo createState() => _SwitchTypesDemo(); } @@ -55,16 +54,16 @@ class _SwitchTypesDemo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch( + return Switch( value: this.check, - activeTrackColor:Colors.green, + activeTrackColor: Colors.green, inactiveThumbColor: Colors.black, - inactiveThumbImage: NetworkImage('https://flutter.io/images/homepage/header-illustration.png'), - activeThumbImage: NetworkImage( - "https://flutter.io/images/homepage/screenshot-2.png" - ), + inactiveThumbImage: NetworkImage( + 'https://flutter.io/images/homepage/header-illustration.png'), + activeThumbImage: + NetworkImage("https://flutter.io/images/homepage/screenshot-2.png"), inactiveTrackColor: Colors.yellow, - activeColor: Colors.blue, // 激活时原点颜色 + activeColor: Colors.blue, // 激活时原点颜色 onChanged: (bool val) { this.setState(() { this.check = !this.check; @@ -72,4 +71,4 @@ class _SwitchTypesDemo extends State { }, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/Switch/index.dart b/lib/widgets/elements/Form/Switch/Switch/index.dart index c7ce8dff..18c6c0c2 100644 --- a/lib/widgets/elements/Form/Switch/Switch/index.dart +++ b/lib/widgets/elements/Form/Switch/Switch/index.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -20,7 +20,6 @@ const contentA = ''' '''; - const contentB = ''' ios 风格的实例 @@ -45,7 +44,6 @@ const contentC = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Switch/Switch'; _Demo createState() => _Demo(); diff --git a/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart b/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart index 57b21ea1..05c8d8ee 100644 --- a/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart +++ b/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 15:48 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 15:48 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -15,11 +15,15 @@ class _Demo extends State { bool _lights = false; @override Widget build(BuildContext context) { - return SwitchListTile( + return SwitchListTile( title: const Text('Lights'), value: _lights, - onChanged: (bool value) { setState(() { _lights = value; }); }, + onChanged: (bool value) { + setState(() { + _lights = value; + }); + }, secondary: const Icon(Icons.lightbulb_outline), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart b/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart index bc4adbcb..09c1eab1 100644 --- a/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart +++ b/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart @@ -1,13 +1,13 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 15:48 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 15:48 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -21,7 +21,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Switch/SwitchListTile'; _Demo createState() => _Demo(); @@ -33,10 +32,7 @@ class _Demo extends State { return WidgetDemo( title: 'SwitchListTile', codeUrl: 'elements/Form/Switch/SwitchListTile/demo.dart', - contentList: [ - contentA, - SwitchListTileDemo() - ], + contentList: [contentA, SwitchListTileDemo()], docUrl: '', ); } diff --git a/lib/widgets/elements/Form/Switch/index.dart b/lib/widgets/elements/Form/Switch/index.dart index c6f26d73..bd28c6d3 100644 --- a/lib/widgets/elements/Form/Switch/index.dart +++ b/lib/widgets/elements/Form/Switch/index.dart @@ -5,7 +5,6 @@ import "Switch/index.dart" as Switch; import "SwitchListTile/index.dart" as SwitchListTile; import "AnimatedSwitcher/index.dart" as AnimatedSwitcher; - List widgetPoints = [ WidgetPoint( name: 'Switch', diff --git a/lib/widgets/elements/Form/Text/RichText/demo.dart b/lib/widgets/elements/Form/Text/RichText/demo.dart index 8d8705ae..f2547f93 100644 --- a/lib/widgets/elements/Form/Text/RichText/demo.dart +++ b/lib/widgets/elements/Form/Text/RichText/demo.dart @@ -17,12 +17,16 @@ class _Demo extends State { return Container( color: Color(0xff000000), width: 750.0, - child: RichText( + child: RichText( text: TextSpan( text: 'Hello ', children: [ - TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Color(0xfffffc42))), - TextSpan(text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)), + TextSpan( + text: 'bold', + style: TextStyle( + fontWeight: FontWeight.bold, color: Color(0xfffffc42))), + TextSpan( + text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)), ], ), ), diff --git a/lib/widgets/elements/Form/Text/RichText/index.dart b/lib/widgets/elements/Form/Text/RichText/index.dart index 0e2e8451..d6e31a60 100644 --- a/lib/widgets/elements/Form/Text/RichText/index.dart +++ b/lib/widgets/elements/Form/Text/RichText/index.dart @@ -18,7 +18,6 @@ const String intro = """ """; - class Demo extends StatefulWidget { static const String routeName = '/element/Form/Text/RichText'; _Demo createState() => _Demo(); @@ -28,12 +27,12 @@ class _Demo extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'Rich Text', - docUrl: 'https://docs.flutter.io/flutter/widgets/RichText-class.html', - codeUrl: 'elements/Form/Text/RichText/demo.dart', - contentList: [ - intro, - RichTextDemo(), - ]); + title: 'Rich Text', + docUrl: 'https://docs.flutter.io/flutter/widgets/RichText-class.html', + codeUrl: 'elements/Form/Text/RichText/demo.dart', + contentList: [ + intro, + RichTextDemo(), + ]); } } diff --git a/lib/widgets/elements/Form/Text/Text/demo.dart b/lib/widgets/elements/Form/Text/Text/demo.dart index 505b5d09..48b27c34 100644 --- a/lib/widgets/elements/Form/Text/Text/demo.dart +++ b/lib/widgets/elements/Form/Text/Text/demo.dart @@ -17,6 +17,6 @@ class _Demo extends State { Duration timer = new Duration(minutes: 50); @override Widget build(BuildContext context) { - return Text("i'm a text"); + return Text("i'm a text"); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Text/Text/index.dart b/lib/widgets/elements/Form/Text/Text/index.dart index 4c6586a7..6fac05a1 100644 --- a/lib/widgets/elements/Form/Text/Text/index.dart +++ b/lib/widgets/elements/Form/Text/Text/index.dart @@ -32,19 +32,16 @@ class Demo extends StatefulWidget { } class _Demo extends State { - onButtonTap() { - - } + onButtonTap() {} @override Widget build(BuildContext context) { return WidgetDemo( - title: "Text", - docUrl: 'flutter/widgets/Text-class.html', - codeUrl: 'elements/Form/Text/Text/demo.dart', - contentList: [ - intro, - TextDemo(), - ] - ); + title: "Text", + docUrl: 'flutter/widgets/Text-class.html', + codeUrl: 'elements/Form/Text/Text/demo.dart', + contentList: [ + intro, + TextDemo(), + ]); } } diff --git a/lib/widgets/elements/Form/Text/index.dart b/lib/widgets/elements/Form/Text/index.dart index f5b7eb50..40555e2f 100644 --- a/lib/widgets/elements/Form/Text/index.dart +++ b/lib/widgets/elements/Form/Text/index.dart @@ -4,16 +4,15 @@ import '../../../../model/widget.dart'; import 'RichText/index.dart' as RichText; import 'Text/index.dart' as Text; - List widgetPoints = [ - WidgetPoint( - name: 'RichText', - routerName: RichText.Demo.routeName, - buildRouter: (BuildContext context) => RichText.Demo(), - ), + WidgetPoint( + name: 'RichText', + routerName: RichText.Demo.routeName, + buildRouter: (BuildContext context) => RichText.Demo(), + ), WidgetPoint( name: 'Text', routerName: Text.Demo.routeName, buildRouter: (BuildContext context) => Text.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/index.dart b/lib/widgets/elements/Form/index.dart index 7a140fa3..8016383b 100644 --- a/lib/widgets/elements/Form/index.dart +++ b/lib/widgets/elements/Form/index.dart @@ -16,4 +16,4 @@ List getWidgets() { result.addAll(Slider.widgetPoints); result.addAll(Switch.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/Align/Align/demo.dart b/lib/widgets/elements/Frame/Align/Align/demo.dart index 98f48584..57a41ecb 100644 --- a/lib/widgets/elements/Frame/Align/Align/demo.dart +++ b/lib/widgets/elements/Frame/Align/Align/demo.dart @@ -1,9 +1,9 @@ /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Align描述 +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Align描述 import 'package:flutter/widgets.dart'; @@ -11,17 +11,17 @@ class AlignAlignment extends StatelessWidget { final Alignment status; final String dec; - const AlignAlignment( this.status, this.dec) : super(); + const AlignAlignment(this.status, this.dec) : super(); @override Widget build(BuildContext context) { - return Container( + return Container( color: Color(0xffd81b60), width: 90.0, height: 50.0, - child: Align( + child: Align( alignment: status, - child: Text( + child: Text( dec, style: TextStyle(fontSize: 12.0, color: Color(0xffffffff)), ), @@ -36,16 +36,15 @@ class AlignFactor extends StatelessWidget { final double hFactor; final String dec; - const AlignFactor( this.status, this.wFactor, - this.hFactor, this.dec) + const AlignFactor(this.status, this.wFactor, this.hFactor, this.dec) : super(); @override Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + return Container( + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), color: Color(0xffd81b60), - child: Align( + child: Align( alignment: status, widthFactor: wFactor, heightFactor: hFactor, diff --git a/lib/widgets/elements/Frame/Align/Align/index.dart b/lib/widgets/elements/Frame/Align/Align/index.dart index 610ede29..125426f6 100644 --- a/lib/widgets/elements/Frame/Align/Align/index.dart +++ b/lib/widgets/elements/Frame/Align/Align/index.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -36,15 +35,15 @@ class _DemoState extends State { title: 'Align', codeUrl: "elements/Frame/Align/Align/demo.dart", docUrl: 'https://docs.flutter.io/flutter/widgets/Align-class.html', - contentList: [_flatText0, _alignCreate(),_flatText1,_alignCreates()], + contentList: [_flatText0, _alignCreate(), _flatText1, _alignCreates()], ); } Column _alignCreate() { - return Column( + return Column( children: [ SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.center, 'center'), @@ -52,7 +51,7 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.centerRight, 'centerRight'), @@ -61,7 +60,7 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.topLeft, 'topLeft'), @@ -70,31 +69,29 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - - ], ); } } -Column _alignCreates(){ +Column _alignCreates() { return Column( children: [ Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), - color: Color(0xffe91e63), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Align", - style: TextStyle(color: Color(0xffffffff)), - ), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + color: Color(0xffe91e63), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Align", + style: TextStyle(color: Color(0xffffffff)), ), ), - AlignFactor(Alignment.topLeft, 2.0, 2.0, 'topleft'), - AlignFactor(Alignment.topRight, null, null, 'topleft'), - AlignFactor(Alignment.center, null, null, 'center'), - AlignFactor(Alignment.bottomLeft, null, null, 'bottomLeft') + ), + AlignFactor(Alignment.topLeft, 2.0, 2.0, 'topleft'), + AlignFactor(Alignment.topRight, null, null, 'topleft'), + AlignFactor(Alignment.center, null, null, 'center'), + AlignFactor(Alignment.bottomLeft, null, null, 'bottomLeft') ], ); } diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart index 03ceeb89..5c4f8bf5 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:ConstrainedBox描述 +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:ConstrainedBox描述 import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -12,8 +12,8 @@ class ConstrainedBoxCreate extends StatelessWidget { final double currWidth; final String describe; - const ConstrainedBoxCreate({Key key,this.currWidth,this.describe}): - super(key: key); + const ConstrainedBoxCreate({Key key, this.currWidth, this.describe}) + : super(key: key); @override Widget build(BuildContext context) { @@ -27,12 +27,12 @@ class ConstrainedBoxCreate extends StatelessWidget { maxWidth: 300.0, maxHeight: 50.0, ), - child: Container( + child: Container( margin: const EdgeInsets.only(left: 20.0, right: 20.0), //child 宽高超过制定限制范围失效,效果宽/高=100/20区域 width: currWidth, height: 250.0, - child: Text( + child: Text( describe, style: TextStyle(color: Colors.white), ), diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart index cd1d06fe..62054885 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart @@ -1,7 +1,7 @@ /// Author: xiaojia.dxj -/// Date: 2019-01-08 15:56:53 +/// Date: 2019-01-08 15:56:53 /// Last Modified by: xiaojia.dxj -/// Last Modified time: 2019-01-08 15:56:53 +/// Last Modified time: 2019-01-08 15:56:53 /// email: xiaojia.dxj@alibaba-inc.com import 'package:flutter/material.dart'; @@ -61,7 +61,6 @@ class _DemoState extends State { height: 10.0, ), ConstrainedBoxCreate(currWidth: 100, describe: "currWidth=minWidth"), - ], docUrl: 'https://docs.flutter.io/flutter/widgets/ConstrainedBox-class.html', diff --git a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart index 86da89f3..94cd956c 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart @@ -20,8 +20,9 @@ class DecoratedBoxCreate extends StatelessWidget { color: const Color(0xff7c94b6), //设置图片内容 image: DecorationImage( - ///fix:BoxFit.contain: 保持图片的比例,最大程度填充容器 BoxFit.fill:容器被图片完全填充,不在意图片比例,只填充整个容器 - ///fix:BoxFit.fitWidth:图片以宽被完全填充 BoxFit.fix:fixHigth:图片以高度完全填充 + + ///fix:BoxFit.contain: 保持图片的比例,最大程度填充容器 BoxFit.fill:容器被图片完全填充,不在意图片比例,只填充整个容器 + ///fix:BoxFit.fitWidth:图片以宽被完全填充 BoxFit.fix:fixHigth:图片以高度完全填充 fit: BoxFit.cover, //图片填充整个容器,按比例放大,多余部分被裁切 image: ExactAssetImage('assets/images/food01.jpeg')), //外宽边框,可以不设置 diff --git a/lib/widgets/elements/Frame/Box/FittedBox/demo.dart b/lib/widgets/elements/Frame/Box/FittedBox/demo.dart index 084f8fe9..959ec799 100644 --- a/lib/widgets/elements/Frame/Box/FittedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/FittedBox/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/12/2 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/12/2 - /// LastUpdateBy: xj.deng - /// Describle:FittedBox +/// Author: xiaojia.dxj +/// Date: 2018/12/2 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/12/2 +/// LastUpdateBy: xj.deng +/// Describle:FittedBox import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -16,7 +16,7 @@ class FittedBoxDefault extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( + return Column( children: [ Container( //外部有位置约束,内部大小设定失效,保持和外部约束一致 diff --git a/lib/widgets/elements/Frame/Box/FittedBox/index.dart b/lib/widgets/elements/Frame/Box/FittedBox/index.dart index 74d1e25f..8bb98014 100644 --- a/lib/widgets/elements/Frame/Box/FittedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/FittedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2019-01-08 - /// LastUpdateBy: xj.deng +/// Author: xiaojia.dxj +/// Date: 2019-01-08 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2019-01-08 +/// LastUpdateBy: xj.deng import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart index 30dc8321..0890c223 100644 --- a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:35 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:35 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:35 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:35 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart index d9a26a75..4121311f 100644 --- a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart +++ b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:31 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:31 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/RotatedBox/index.dart b/lib/widgets/elements/Frame/Box/RotatedBox/index.dart index c87107d4..a35c0075 100644 --- a/lib/widgets/elements/Frame/Box/RotatedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/RotatedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:13 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:13 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:13 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:13 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/SizeBox/index.dart b/lib/widgets/elements/Frame/Box/SizeBox/index.dart index 6ae1f9db..abcb4ebb 100644 --- a/lib/widgets/elements/Frame/Box/SizeBox/index.dart +++ b/lib/widgets/elements/Frame/Box/SizeBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:55:46 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:55:46 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:55:46 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:55:46 import 'package:flutter/material.dart'; @@ -30,15 +29,15 @@ class _DemoState extends State { } Column _sizeBoxCreate() { - return Column( + return Column( children: [ - Text("SizedBox", + Text("SizedBox", textAlign: TextAlign.right, style: TextStyle( fontSize: 28.0, fontWeight: FontWeight.bold, )), - Row( + Row( children: [ sizeBox.SizeBoxDefault(), SizedBox( diff --git a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart index f69a3c0d..1d96402d 100644 --- a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart @@ -20,7 +20,7 @@ class SizeOverflowBoxDefault extends StatelessWidget { color: Color(0xfff06292), width: 50.0, height: 50.0, - child: Text( + child: Text( text, style: TextStyle(color: Colors.white), ), diff --git a/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart b/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart index 2333db8c..744619bd 100644 --- a/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart +++ b/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart @@ -1,10 +1,9 @@ +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:55:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:55:31 - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:55:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:55:31 - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -55,7 +54,7 @@ class _DemoState extends State { } Column _sizedOverflowBoxCreate() { - return Column( + return Column( children: [ SizeBoxDefault( curWidth: 200.0, @@ -63,13 +62,13 @@ class _DemoState extends State { ), SizedBox(height: 20.0), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), alignment: Alignment.topCenter, width: 200.0, @@ -79,7 +78,7 @@ class _DemoState extends State { ), ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, @@ -90,7 +89,7 @@ class _DemoState extends State { ), ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart index 0a62c64f..223c260d 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart @@ -6,7 +6,7 @@ class UnconstrainedBoxDemo extends StatelessWidget { return UnconstrainedBox( constrainedAxis: Axis.vertical, textDirection: TextDirection.rtl, - child: Row( + child: Row( children: [ Container( width: 100.0, diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart index b37fd267..841af7af 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart @@ -1,10 +1,9 @@ +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; diff --git a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart index 24075553..982cd0c4 100644 --- a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart +++ b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart @@ -1,69 +1,86 @@ -/// @Author: 一凨 -/// @Date: 2018-11-28 20:09:40 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:09:40 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-11-28 20:10:32 import 'package:flutter/material.dart'; class ExpandedDemo extends StatelessWidget { - final TextStyle txtColor = TextStyle(color: Colors.white); @override Widget build(BuildContext context) { return Column( children: [ Text('Expanded'), - Row(children: [ - RaisedButton( + Row(children: [ + RaisedButton( onPressed: () { print('点击红色按钮事件'); }, color: const Color(0xffcc0000), - child: Text('红色按钮',style: txtColor,), + child: Text( + '红色按钮', + style: txtColor, + ), ), - Expanded( - flex: 1,//flex用来设置当前可用空间的占优比 - child: RaisedButton( + Expanded( + flex: 1, //flex用来设置当前可用空间的占优比 + child: RaisedButton( onPressed: () { print('点击黄色按钮事件'); }, color: const Color(0xfff1c232), - child: Text('黄色按钮',style: txtColor,), + child: Text( + '黄色按钮', + style: txtColor, + ), ), ), - RaisedButton( + RaisedButton( onPressed: () { print('点击粉色按钮事件'); }, color: const Color(0xffea9999), - child: Text('粉色按钮',style: txtColor,), + child: Text( + '粉色按钮', + style: txtColor, + ), ), ]), Text('Flexible'), - Row(children: [ - RaisedButton( + Row(children: [ + RaisedButton( onPressed: () { print('点击红色按钮事件'); }, color: const Color(0xffcc0000), - child: Text('红色按钮',style: txtColor,), + child: Text( + '红色按钮', + style: txtColor, + ), ), - Flexible( + Flexible( flex: 1, - child: RaisedButton( + child: RaisedButton( onPressed: () { print('点击黄色按钮事件'); }, color: const Color(0xfff1c232), - child: Text('黄色按钮',style: txtColor,), + child: Text( + '黄色按钮', + style: txtColor, + ), ), ), - RaisedButton( + RaisedButton( onPressed: () { print('点击粉色按钮事件'); }, color: const Color(0xffea9999), - child: Text('粉色按钮',style: txtColor,), + child: Text( + '粉色按钮', + style: txtColor, + ), ), ]), ], diff --git a/lib/widgets/elements/Frame/Layout/Center/index.dart b/lib/widgets/elements/Frame/Layout/Center/index.dart index 42c2bc9c..d3b40169 100644 --- a/lib/widgets/elements/Frame/Layout/Center/index.dart +++ b/lib/widgets/elements/Frame/Layout/Center/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Column/demo.dart b/lib/widgets/elements/Frame/Layout/Column/demo.dart index e1c5a28e..7935ca30 100644 --- a/lib/widgets/elements/Frame/Layout/Column/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Column/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/widgets.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Column/index.dart b/lib/widgets/elements/Frame/Layout/Column/index.dart index 34d73786..50ba0ade 100644 --- a/lib/widgets/elements/Frame/Layout/Column/index.dart +++ b/lib/widgets/elements/Frame/Layout/Column/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Container/demo.dart b/lib/widgets/elements/Frame/Layout/Container/demo.dart index c09965c8..fd4e00b3 100644 --- a/lib/widgets/elements/Frame/Layout/Container/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Container/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Container/index.dart b/lib/widgets/elements/Frame/Layout/Container/index.dart index 86848cb7..4e97ebdc 100644 --- a/lib/widgets/elements/Frame/Layout/Container/index.dart +++ b/lib/widgets/elements/Frame/Layout/Container/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Row/demo.dart b/lib/widgets/elements/Frame/Layout/Row/demo.dart index 7e26823b..89942f34 100644 --- a/lib/widgets/elements/Frame/Layout/Row/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Row/demo.dart @@ -1,13 +1,14 @@ - import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; + /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Row +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Row import 'package:flutter/widgets.dart'; - + class RowMainAxisAlignment extends StatelessWidget { //> mainAxisAlignment属性 // - MainAxisAlignment.spaceEvenly/spaceAround/spaceBetween, @@ -34,7 +35,7 @@ class RowMainAxisAlignment extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( + return Row( mainAxisAlignment: status, children: [ Container( @@ -62,29 +63,29 @@ class RowLayoutCreate extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( + return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfffce4ec), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff8bbd0), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff48fb1), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff06292), width: 60.0, height: 50.0, @@ -94,33 +95,40 @@ class RowLayoutCreate extends StatelessWidget { } } -class RowExpanded extends StatelessWidget{ +class RowExpanded extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( children: [ ////填充数据 - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfffce4ec), - child:new Text('flutter',style: TextStyle(color: Colors.white),) - ),), - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfff8bbd0), - child:new Text('Expanded',style: TextStyle(color: Colors.white),) - ),), - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfff48fb1), - child:new Text('flutter',style: TextStyle(color: Colors.white),) - ),), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfffce4ec), + child: new Text( + 'flutter', + style: TextStyle(color: Colors.white), + )), + ), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfff8bbd0), + child: new Text( + 'Expanded', + style: TextStyle(color: Colors.white), + )), + ), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfff48fb1), + child: new Text( + 'flutter', + style: TextStyle(color: Colors.white), + )), + ), ], ); } - } diff --git a/lib/widgets/elements/Frame/Layout/Row/index.dart b/lib/widgets/elements/Frame/Layout/Row/index.dart index 4ebb6f8f..33d9bef2 100644 --- a/lib/widgets/elements/Frame/Layout/Row/index.dart +++ b/lib/widgets/elements/Frame/Layout/Row/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Row +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Row import 'package:flutter/material.dart'; @@ -57,10 +57,12 @@ class _DemoState extends State { } Column _rowCreate() { - return Column( + return Column( children: [ RowLayoutCreate(), - SizedBox(height: 10.0,), + SizedBox( + height: 10.0, + ), RowExpanded(), Row( children: [ diff --git a/lib/widgets/elements/Frame/Layout/index.dart b/lib/widgets/elements/Frame/Layout/index.dart index b936fa00..387978dd 100644 --- a/lib/widgets/elements/Frame/Layout/index.dart +++ b/lib/widgets/elements/Frame/Layout/index.dart @@ -22,7 +22,7 @@ List widgetPoints = [ routerName: Container.Demo.routeName, buildRouter: (BuildContext context) => Container.Demo(), ), - WidgetPoint( + WidgetPoint( name: 'Center', routerName: Center.Demo.routeName, buildRouter: (BuildContext context) => Center.Demo(), diff --git a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart index 93bea0eb..b26e8b7d 100644 --- a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:42:40 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:42:40 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:42:40 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:42:40 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart index 623bca26..f9058900 100644 --- a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:44:13 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 17:02:20 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:44:13 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 17:02:20 import 'package:flutter/material.dart'; @@ -37,7 +37,8 @@ class _DemoState extends State { ], docUrl: 'https://docs.flutter.io/flutter/widgets/AnimatedPadding-class.html', - codeUrl: 'elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart', + codeUrl: + 'elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart', ); } } diff --git a/lib/widgets/elements/Frame/Spacing/Padding/index.dart b/lib/widgets/elements/Frame/Spacing/Padding/index.dart index 82233cd7..0b0d6d10 100644 --- a/lib/widgets/elements/Frame/Spacing/Padding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/Padding/index.dart @@ -1,26 +1,27 @@ - /// Author: 一凨 - /// Date: 2018-11-28 20:25:24 - /// Last Modified by: 一凨 - /// Last Modified time: 2019-01-14 17:01:55 +/// Author: 一凨 +/// Date: 2018-11-28 20:25:24 +/// Last Modified by: 一凨 +/// Last Modified time: 2019-01-14 17:01:55 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './padding_demo.dart'; -const contentDesc0=''' +const contentDesc0 = ''' ### **简介** > widget 内边距 - 类似于前端中的 div+css:padding 效果 - Container + padding = Padding '''; -const contentDesc1 = ''' +const contentDesc1 = ''' ### **基本用法** > Padding widget 的padding必须设置,不能为null - 通过给定的padding值来隔开子组件 - 通过EdgeInsets 类来计算 padding的大小 '''; + class Demo extends StatefulWidget { static const String routeName = '/element/Frame/spacing/Padding'; _DemoState createState() => _DemoState(); @@ -31,14 +32,9 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'Padding', - contentList: [ - contentDesc0, - contentDesc1, - PaddingDemo() - ], + contentList: [contentDesc0, contentDesc1, PaddingDemo()], docUrl: 'https://docs.flutter.io/flutter/widgets/Padding-class.html', - codeUrl: - 'elements/Frame/Spacing/Padding/padding_demo.dart', + codeUrl: 'elements/Frame/Spacing/Padding/padding_demo.dart', ); } } diff --git a/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart b/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart index 6721d366..d5236c51 100644 --- a/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:20:04 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 16:30:16 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:20:04 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 16:30:16 import 'package:flutter/material.dart'; @@ -11,7 +11,7 @@ class PaddingDemo extends StatelessWidget { return Container( color: Colors.blueAccent, child: Padding( - padding: const EdgeInsets.all(18.0),//通过 EdgeInsets 来设置 padding的值 + padding: const EdgeInsets.all(18.0), //通过 EdgeInsets 来设置 padding的值 child: Container( height: 100.0, width: 100.0, diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart index e836f35c..1136383d 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:26:16 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 17:06:36 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:26:16 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 17:06:36 import 'package:flutter/material.dart'; @@ -43,6 +43,4 @@ class _DemoState extends State { 'https://docs.flutter.io/flutter/widgets/SliverPadding-class.html', ); } - - } diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart index 0c802382..f26e2d02 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart @@ -1,5 +1,3 @@ - - class ProductItem { final String name; final String tag; diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart index db0fe909..449ea6ae 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart @@ -1,70 +1,66 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:36:17 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:36:17 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:36:17 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:36:17 import 'package:flutter/material.dart'; import 'package:flutter_go/widgets/components/Scroll/CustomScrollView/product_list.dart'; class SliverPaddingDemo extends StatelessWidget { - - - Widget _buildItem(BuildContext context,ProductItem product){ - return Container( + Widget _buildItem(BuildContext context, ProductItem product) { + return Container( height: 100.0, margin: const EdgeInsets.only(bottom: 5.0), padding: const EdgeInsets.only(left: 10.0), color: Colors.blueGrey, - child: Stack( - alignment: AlignmentDirectional.centerStart, - children: [ - Positioned( - right: 40.0, - child: Card( - child: Center( - child: Text( - product.name, - style: Theme.of(context).textTheme.title, - textAlign: TextAlign.center, - ), + child: Stack( + alignment: AlignmentDirectional.centerStart, + children: [ + Positioned( + right: 40.0, + child: Card( + child: Center( + child: Text( + product.name, + style: Theme.of(context).textTheme.title, + textAlign: TextAlign.center, ), - )), - ClipRRect( - child: SizedBox( - width: 70.0, - height: 70.0, - child: Image.asset( - product.asset, - fit: BoxFit.cover, ), + )), + ClipRRect( + child: SizedBox( + width: 70.0, + height: 70.0, + child: Image.asset( + product.asset, + fit: BoxFit.cover, ), - borderRadius: BorderRadius.all(Radius.circular(8.0)), ), - ], - ), + borderRadius: BorderRadius.all(Radius.circular(8.0)), + ), + ], + ), ); } @override Widget build(BuildContext context) { - return CustomScrollView( - shrinkWrap: true, - slivers: [ - SliverPadding( - padding: const EdgeInsets.fromLTRB(50.0,10.0,20.0,0.0), - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { + return CustomScrollView( + shrinkWrap: true, + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(50.0, 10.0, 20.0, 0.0), + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { return _buildItem(context, products[index]); }, childCount: products.length, ), - ), - ) - ], - ); + ), + ) + ], + ); } - - -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart index bfc83c8c..76227266 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:indexedStack +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:indexedStack import 'package:flutter/material.dart'; @@ -28,7 +28,7 @@ class StackDefault extends StatelessWidget { // fit: BoxFit.cover, // ), CircleAvatar( - backgroundColor: Color(0xfff48fb1), + backgroundColor: Color(0xfff48fb1), radius: 40.0, ), Container( @@ -59,27 +59,27 @@ class StackIndex extends StatelessWidget { return IndexedStack( index: currIndex, children: [ - Icon( + Icon( Icons.update, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.access_alarm, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.add_alarm, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.access_time, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.alarm_off, size: 40.0, color: Color(0xffe91e63), diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart index da85006c..77b8233b 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -56,20 +56,20 @@ class _DemoState extends State { } Column _indexedStackCreate() { - return Column( + return Column( children: [ SizedBox( height: 10.0, ), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackDefault(0), ), Container( - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackDefault(1), ) ], @@ -77,7 +77,7 @@ class _DemoState extends State { SizedBox( height: 10.0, ), - Row( + Row( mainAxisAlignment: MainAxisAlignment.center, children: [ StackIndex(0), @@ -97,7 +97,7 @@ class _DemoState extends State { onPressed: () { _indexAdd(); }, - icon: Icon(Icons.adb), + icon: Icon(Icons.adb), label: Text("点击这里")), StackIndex(currIndex) ], diff --git a/lib/widgets/elements/Frame/Stack/Stack/demo.dart b/lib/widgets/elements/Frame/Stack/Stack/demo.dart index b1a72425..1dd5441f 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/demo.dart @@ -1,10 +1,10 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:stack描述 - +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:stack描述 + import 'package:flutter/material.dart'; class StackDefault extends StatelessWidget { @@ -14,19 +14,19 @@ class StackDefault extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Stack( + Stack( //fit :定义如何设置non-positioned节点尺寸 fit: StackFit.loose, overflow: Overflow.clip, textDirection: TextDirection.ltr, alignment: Alignment.center, children: [ - Container( - color: Color(0xfff48fb1), + Container( + color: Color(0xfff48fb1), width: 100.0, height: 50.0, ), - Text("stack demo", + Text("stack demo", textDirection: TextDirection.ltr, style: TextStyle( fontSize: 20.0, @@ -47,22 +47,22 @@ class StackDefault2 extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Stack( + Stack( //fit :定义如何设置non-positioned节点尺寸 fit: StackFit.loose, overflow: Overflow.clip, textDirection: TextDirection.ltr, alignment: Alignment.center, children: [ - Text("stack demo", + Text("stack demo", textDirection: TextDirection.ltr, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, letterSpacing: 5.0, color: Colors.white)), - Container( - color: Color(0xfff48fb1), + Container( + color: Color(0xfff48fb1), width: 100.0, height: 50.0, ), @@ -78,32 +78,32 @@ class StackPositioned extends StatelessWidget { @override Widget build(BuildContext context) { - return Stack( + return Stack( alignment: Alignment.center, children: [ - Positioned( - child: Icon( + Positioned( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[300], )), - Positioned( + Positioned( left: 40.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], )), - Positioned( + Positioned( left: 60.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], )), - Positioned( + Positioned( left: 80.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], @@ -118,12 +118,12 @@ class StackLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return Stack( + return Stack( overflow: Overflow.visible, alignment: const Alignment(0.2, 0.6), children: [ CircleAvatar( - backgroundColor: Color(0xfff48fb1), + backgroundColor: Color(0xfff48fb1), radius: 140.0, ), Container( diff --git a/lib/widgets/elements/Frame/Stack/Stack/index.dart b/lib/widgets/elements/Frame/Stack/Stack/index.dart index 6787abd6..90dc530a 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/index.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/index.dart @@ -46,18 +46,18 @@ class _DemoState extends State { _stackText0, _stackCreate(), _stackText1, - Container( + Container( width: 300.0, height: 100.0, - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), - color: Color(0xffe91e63), + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + color: Color(0xffe91e63), child: StackPositioned(), ), _stackText2, - Container( + Container( width: 200.0, height: 200.0, - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackLayout(), ), ], @@ -65,18 +65,18 @@ class _DemoState extends State { } Column _stackCreate() { - return Column( + return Column( children: [ Column( children: [ - Container( - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + Container( + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), width: 300.0, height: 100.0, color: Color(0xffe91e63), child: StackDefault(), ), - Container( + Container( width: 300.0, height: 100.0, color: Color(0xffe91e63), diff --git a/lib/widgets/elements/Frame/Table/Table/index.dart b/lib/widgets/elements/Frame/Table/Table/index.dart index 7706c69d..aa5b0426 100644 --- a/lib/widgets/elements/Frame/Table/Table/index.dart +++ b/lib/widgets/elements/Frame/Table/Table/index.dart @@ -15,6 +15,7 @@ const contentDesc1 = ''' - 表格中行的大小是根据列行数和宽度计算的来,控制列宽可以使用 columnWidth 属性 - 注意,Table中每一行的列数需要一致,否则报错 '''; + class Demo extends StatefulWidget { static const String routeName = '/element/Frame/Table/Table'; _DemoState createState() => _DemoState(); @@ -25,8 +26,7 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'Table', - codeUrl: - 'elements/Frame/Table/Table/table_demo.dart', + codeUrl: 'elements/Frame/Table/Table/table_demo.dart', contentList: [ contentDesc0, contentDesc1, diff --git a/lib/widgets/elements/Frame/Table/Table/table_demo.dart b/lib/widgets/elements/Frame/Table/Table/table_demo.dart index 9d81d71e..beb89d0d 100644 --- a/lib/widgets/elements/Frame/Table/Table/table_demo.dart +++ b/lib/widgets/elements/Frame/Table/Table/table_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:52:35 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:59:50 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:52:35 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:59:50 import 'package:flutter/material.dart'; @@ -9,8 +9,8 @@ class TableDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin:const EdgeInsets.only(top: 10.0), - child:Table( + margin: const EdgeInsets.only(top: 10.0), + child: Table( columnWidths: const { 0: FixedColumnWidth(50.0), 1: FixedColumnWidth(100.0), @@ -48,4 +48,4 @@ class TableDemo extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/index.dart b/lib/widgets/elements/Frame/index.dart index 25348967..02c378be 100644 --- a/lib/widgets/elements/Frame/index.dart +++ b/lib/widgets/elements/Frame/index.dart @@ -6,7 +6,6 @@ import 'Layout/index.dart' as Layout; import 'Stack/index.dart' as Stack; import 'Box/index.dart' as Box; - List getWidgets() { List result = []; result.addAll(Spacing.widgetPoints); diff --git a/lib/widgets/elements/Media/Canvas/Canvas/demo.dart b/lib/widgets/elements/Media/Canvas/Canvas/demo.dart index eee36df0..355a2297 100644 --- a/lib/widgets/elements/Media/Canvas/Canvas/demo.dart +++ b/lib/widgets/elements/Media/Canvas/Canvas/demo.dart @@ -18,9 +18,8 @@ CustomPaint graph; var image; class CustomViewPage extends StatefulWidget { - final String type; - CustomViewPage({this.type='drawLine'}) : super(); + CustomViewPage({this.type = 'drawLine'}) : super(); @override State createState() => CustomViewPageState(); @@ -28,7 +27,6 @@ class CustomViewPage extends StatefulWidget { class CustomViewPageState extends State with SingleTickerProviderStateMixin { - static Future getImage(String asset) async { ByteData data = await rootBundle.load(asset); Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); @@ -50,9 +48,7 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { - graph = CustomPaint( - painter: DrawPainter(type:widget.type) - ); + graph = CustomPaint(painter: DrawPainter(type: widget.type)); return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.6, @@ -60,10 +56,9 @@ class CustomViewPageState extends State //padding: EdgeInsets.all(10.0), child: graph //child:Center(child: graph) - ); + ); } - @override void reassemble() { super.reassemble(); @@ -80,7 +75,7 @@ class DrawPainter extends CustomPainter { Paint painter; final type; - DrawPainter ({this.type}){ + DrawPainter({this.type}) { // Paint painter = Paint() // ..color = Colors.blueAccent //画笔颜色 // ..strokeCap = StrokeCap.round //画笔笔触类型 @@ -100,69 +95,93 @@ class DrawPainter extends CustomPainter { ..filterQuality = FilterQuality.high ..style = PaintingStyle.stroke; } + ///Flutter中负责View绘制的地方,使用传递来的canvas和size即可完成对目标View的绘制 @override void paint(Canvas canvas, Size size) { - switch(type) { + switch (type) { case 'drawPoints': - const List points1 = [Offset(20.0, 0.0), Offset(100.0, 50.0), Offset(150.0, 0.0),Offset(300.0, 0.0)]; - const List points2 = [Offset(20.0, 100.0), Offset(100.0, 100.0), Offset(150.0, 100.0), Offset(300.0, 100.0)]; - const List points3 = [Offset(20.0, 150.0), Offset(100.0, 150.0), Offset(150.0, 180.0), Offset(300.0, 150.0)]; + const List points1 = [ + Offset(20.0, 0.0), + Offset(100.0, 50.0), + Offset(150.0, 0.0), + Offset(300.0, 0.0) + ]; + const List points2 = [ + Offset(20.0, 100.0), + Offset(100.0, 100.0), + Offset(150.0, 100.0), + Offset(300.0, 100.0) + ]; + const List points3 = [ + Offset(20.0, 150.0), + Offset(100.0, 150.0), + Offset(150.0, 180.0), + Offset(300.0, 150.0) + ]; //绘制点 canvas.drawPoints( + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.points, points1, - painter..color = Colors.redAccent // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.redAccent // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); canvas.drawPoints( - ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) + + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.lines, points2, - painter..color = Colors.orange // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.orange // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); canvas.drawPoints( - ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) + + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.polygon, points3, - painter..color = Colors.blue // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.blue // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); break; case 'drawLine': //绘制直线 - canvas.drawLine(Offset(20.0, 0.0), Offset(size.width*0.8, 200), painter ..color = Colors.redAccent); + canvas.drawLine(Offset(20.0, 0.0), Offset(size.width * 0.8, 200), + painter..color = Colors.redAccent); break; case 'rawCircle': //绘制圆 参数(圆心,半径,画笔) canvas.drawCircle( - Offset(size.width/2, 100.0), - 100.0, - painter - ..color = Colors.greenAccent - ..style = PaintingStyle.stroke //绘画风格改为stroke - ); + Offset(size.width / 2, 100.0), + 100.0, + painter + ..color = Colors.greenAccent + ..style = PaintingStyle.stroke //绘画风格改为stroke + ); break; case 'drawOval': // 绘制椭圆 // 使用左上和右下角坐标来确定矩形的大小和位置,椭圆是在这个矩形之中内切的形状 - Rect rect1 = Rect.fromPoints(Offset(0.0, 0.0), Offset(size.width, 200.0)); - canvas.drawOval(rect1, painter ..color = Colors.indigo); + Rect rect1 = + Rect.fromPoints(Offset(0.0, 0.0), Offset(size.width, 200.0)); + canvas.drawOval(rect1, painter..color = Colors.indigo); break; case 'drawArc': // 绘制圆弧 // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 const PI = 3.1415926; Rect rect1 = Rect.fromCircle(center: Offset(20, 50.0), radius: 100.0); - canvas.drawArc(rect1, 0.0, PI / 2, false, painter ..color = Colors.pink); + canvas.drawArc(rect1, 0.0, PI / 2, false, painter..color = Colors.pink); - Rect rect2 = Rect.fromCircle(center: Offset(size.width*0.6, 50.0), radius: 100.0); - canvas.drawArc(rect2, 0.0, PI / 2, true, painter ..color = Colors.deepPurple); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width * 0.6, 50.0), radius: 100.0); + canvas.drawArc( + rect2, 0.0, PI / 2, true, painter..color = Colors.deepPurple); break; case 'drawRRect': + /// fromPoints(Offset a, Offset b) /// 使用左上和右下角坐标来确定矩形的大小和位置 /// fromCircle({ Offset center, double radius }) @@ -173,7 +192,8 @@ class DrawPainter extends CustomPainter { /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 // 用Rect构建一个边长50,中心点坐标为50,100的矩形 Rect rect1 = Rect.fromCircle(center: Offset(80.0, 100.0), radius: 50.0); - Rect rect2 = Rect.fromCircle(center: Offset(250.0, 100.0), radius: 50.0); + Rect rect2 = + Rect.fromCircle(center: Offset(250.0, 100.0), radius: 50.0); // 根据上面的矩形,构建一个圆角矩形 RRect rrect1 = RRect.fromRectAndRadius(rect1, Radius.circular(0.0)); canvas.drawRRect(rrect1, painter); @@ -182,12 +202,14 @@ class DrawPainter extends CustomPainter { break; case 'drawDRRect': //绘制两个矩形 - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 60.0); - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 40.0); + Rect rect1 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 60.0); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 40.0); //分别绘制外部圆角矩形和内部的圆角矩形 RRect outer = RRect.fromRectAndRadius(rect1, Radius.circular(30.0)); RRect inner = RRect.fromRectAndRadius(rect2, Radius.circular(5.0)); - canvas.drawDRRect(outer, inner, painter ..color = Colors.lime); + canvas.drawDRRect(outer, inner, painter..color = Colors.lime); break; case 'drawImage': // canvas.drawImage(image, Offset(0.0, 0.0), painter); @@ -197,40 +219,48 @@ class DrawPainter extends CustomPainter { break; case 'drawStar': var rect = Offset.zero & size; + /// 背景颜色 canvas.drawRect(rect, Paint()..color = Color(0xFF000000)); + /// 绘制星形 - canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50.0, 50.0)), painter..color = Colors.red); + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50.0, 50.0)), + painter..color = Colors.red); + /// 绘制多边形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(0, 100); - canvas.scale(1.2,1.2); - canvas.drawPath(MathTools().nStarPath(4, 30, 30, Offset(40.0, 50.0)), painter); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.scale(1.2, 1.2); + canvas.drawPath( + MathTools().nStarPath(4, 30, 30, Offset(40.0, 50.0)), painter); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制旋转星形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(150, 50); canvas.rotate(50 * pi / 180); - canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(0,0)), painter..color = Colors.green); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(0, 0)), + painter..color = Colors.green); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制变形星形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(80, 100); - canvas.skew(0.5,0.2); - canvas.drawPath(MathTools().regularStarPath(6, 30,Offset(50,50)), painter..color = Colors.lime); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.skew(0.5, 0.2); + canvas.drawPath(MathTools().regularStarPath(6, 30, Offset(50, 50)), + painter..color = Colors.lime); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制matrix星形 canvas.translate(250, 0); Float64List matrix = Float64List.fromList(const [ // careful, this is in _column_-major order - 0.7, -0.7, 0.0, 0.0, - 0.7, 0.7, 0.0, 0.0, - 0.7, 0.0, 1.0, 0.0, - -70.697, 98.057, 0.0, 1.0, + 0.7, -0.7, 0.0, 0.0, + 0.7, 0.7, 0.0, 0.0, + 0.7, 0.0, 1.0, 0.0, + -70.697, 98.057, 0.0, 1.0, ]); canvas.transform(matrix); - canvas.drawPath(MathTools().regularStarPath(5, 30,Offset(50,50)), painter..color = Colors.blue); + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50, 50)), + painter..color = Colors.blue); break; } @@ -248,7 +278,7 @@ class MathTools { static MathTools _mathTools; static bool _flag; - factory MathTools(){ + factory MathTools() { if (_flag == null) { _flag = true; } @@ -259,6 +289,7 @@ class MathTools { return _mathTools; } MathTools._internal(); + /// ///画正n角星的路径: /// @@ -308,14 +339,15 @@ class MathTools { path.moveTo(cos(_rad(degA)) * R + xy.dx, (-sin(_rad(degA)) * R + xy.dy)); for (int i = 0; i < num; i++) { - path.lineTo( - cos(_rad(degA + perDeg * i)) * R + xy.dx, -sin(_rad(degA + perDeg * i)) * R + xy.dy); - path.lineTo( - cos(_rad(degB + perDeg * i)) * r + xy.dx, -sin(_rad(degB + perDeg * i)) * r + xy.dy); + path.lineTo(cos(_rad(degA + perDeg * i)) * R + xy.dx, + -sin(_rad(degA + perDeg * i)) * R + xy.dy); + path.lineTo(cos(_rad(degB + perDeg * i)) * r + xy.dx, + -sin(_rad(degB + perDeg * i)) * r + xy.dy); } path.close(); return path; } + double _rad(double deg) { return deg * pi / 180; } diff --git a/lib/widgets/elements/Media/Canvas/Canvas/index.dart b/lib/widgets/elements/Media/Canvas/Canvas/index.dart index 3e6cda7e..2e64c5f8 100644 --- a/lib/widgets/elements/Media/Canvas/Canvas/index.dart +++ b/lib/widgets/elements/Media/Canvas/Canvas/index.dart @@ -72,23 +72,23 @@ class _DemoState extends State { Text, Text1, Text2, - demoBoxs.CustomViewPage(type:'drawPoints'), + demoBoxs.CustomViewPage(type: 'drawPoints'), Text3, - demoBoxs.CustomViewPage(type:'drawLine'), + demoBoxs.CustomViewPage(type: 'drawLine'), Text4, - demoBoxs.CustomViewPage(type:'rawCircle'), + demoBoxs.CustomViewPage(type: 'rawCircle'), Text5, - demoBoxs.CustomViewPage(type:'drawOval'), + demoBoxs.CustomViewPage(type: 'drawOval'), Text6, - demoBoxs.CustomViewPage(type:'drawArc'), + demoBoxs.CustomViewPage(type: 'drawArc'), Text7, - demoBoxs.CustomViewPage(type:'drawRRect'), + demoBoxs.CustomViewPage(type: 'drawRRect'), Text8, - demoBoxs.CustomViewPage(type:'drawDRRect'), + demoBoxs.CustomViewPage(type: 'drawDRRect'), Text9, - demoBoxs.CustomViewPage(type:'drawImage'), + demoBoxs.CustomViewPage(type: 'drawImage'), Text10, - demoBoxs.CustomViewPage(type:'drawStar'), + demoBoxs.CustomViewPage(type: 'drawStar'), ], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Canvas-class.html', ); diff --git a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart index 432e4f16..5d49fee7 100644 --- a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart +++ b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart @@ -30,7 +30,7 @@ class CustomViewPageState extends State _doubleAnimation = Tween(begin: 0.0, end: 360.0).animate(_controller); _controller.addListener(() { - if(mounted){ + if (mounted) { this.setState(() {}); } }); @@ -40,15 +40,14 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { return Container( - width: 100.0, - height: 100.0, - margin: EdgeInsets.all(8.0), - child: CustomPaint( - child: Center( - child: Text((_doubleAnimation.value / 3.6).round().toString())), - painter: CircleProgressBarPainter(_doubleAnimation.value) - ), - ); + width: 100.0, + height: 100.0, + margin: EdgeInsets.all(8.0), + child: CustomPaint( + child: Center( + child: Text((_doubleAnimation.value / 3.6).round().toString())), + painter: CircleProgressBarPainter(_doubleAnimation.value)), + ); } void onAnimationStart() { @@ -90,7 +89,8 @@ class CircleProgressBarPainter extends CustomPainter { } @override void paint(Canvas canvas, Size size) { - canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 2,_paintBackground); + canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 2, + _paintBackground); Rect rect = Rect.fromCircle( center: Offset(size.width / 2, size.height / 2), radius: size.width / 2, @@ -102,4 +102,4 @@ class CircleProgressBarPainter extends CustomPainter { bool shouldRepaint(CustomPainter oldDelegate) { return false; } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart index 346a4fdd..b3fb0991 100644 --- a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart +++ b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart @@ -12,9 +12,9 @@ const Text1 = ''' - canvas + Animation 实现一个 loading 效果; '''; - class Demo extends StatefulWidget { - static const String routeName = '/element/Media/Canvas/CircleProgressBarPainter'; + static const String routeName = + '/element/Media/Canvas/CircleProgressBarPainter'; _DemoState createState() => _DemoState(); } @@ -25,13 +25,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CircleProgressBarPainter', codeUrl: 'elements/Media/Canvas/CircleProgressBarPainter/demo.dart', - contentList: [ - Text, - Text1, - demoBoxs.CustomViewPage() - ], + contentList: [Text, Text1, demoBoxs.CustomViewPage()], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Canvas-class.html', ); } } - diff --git a/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart b/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart index 3c02dd73..74180709 100644 --- a/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart +++ b/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart @@ -12,9 +12,8 @@ import 'package:flutter/material.dart'; CustomPaint graph; class CustomViewPage extends StatefulWidget { - final String type; - CustomViewPage({this.type='simpleline'}) : super(); + CustomViewPage({this.type = 'simpleline'}) : super(); @override State createState() => CustomViewPageState(); @@ -22,7 +21,6 @@ class CustomViewPage extends StatefulWidget { class CustomViewPageState extends State with SingleTickerProviderStateMixin { - @override void initState() { super.initState(); @@ -30,9 +28,7 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { - graph = CustomPaint( - painter: DrawPainter(type:widget.type) - ); + graph = CustomPaint(painter: DrawPainter(type: widget.type)); return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.6, @@ -40,10 +36,9 @@ class CustomViewPageState extends State //padding: EdgeInsets.all(10.0), child: graph //child:Center(child: graph) - ); + ); } - @override void reassemble() { super.reassemble(); @@ -60,7 +55,7 @@ class DrawPainter extends CustomPainter { Paint painter; final type; - DrawPainter ({this.type}){ + DrawPainter({this.type}) { // Paint painter = Paint() // ..color = Colors.blueAccent //画笔颜色 // ..strokeCap = StrokeCap.round //画笔笔触类型 @@ -79,6 +74,7 @@ class DrawPainter extends CustomPainter { ..strokeWidth = 5.0 ..style = PaintingStyle.stroke; } + ///Flutter中负责View绘制的地方,使用传递来的canvas和size即可完成对目标View的绘制 @override @@ -90,10 +86,14 @@ class DrawPainter extends CustomPainter { canvas.drawPath(path, painter); } - void drawThisPath(Canvas canvas, Size size, Path path,) { - switch(type) { + void drawThisPath( + Canvas canvas, + Size size, + Path path, + ) { + switch (type) { case 'simpleline': - //新建了一个path,然后将路径起始点移动到坐标(100,100)的位置 + //新建了一个path,然后将路径起始点移动到坐标(100,100)的位置 Path path = new Path()..moveTo(0.0, 0.0); path.lineTo(200.0, 200.0); canvas.drawPath(path, painter); @@ -112,8 +112,9 @@ class DrawPainter extends CustomPainter { path.arcTo(rect1, 0.0, 3.14, false); canvas.drawPath(path, painter); - Rect rect2 = Rect.fromCircle(center: Offset(200.0, 100.0), radius: 60.0); - path.arcTo(rect2, 0.0, 3.14*2, true); + Rect rect2 = + Rect.fromCircle(center: Offset(200.0, 100.0), radius: 60.0); + path.arcTo(rect2, 0.0, 3.14 * 2, true); canvas.drawPath(path, painter); break; case 'Besizerline3': @@ -123,9 +124,9 @@ class DrawPainter extends CustomPainter { path.cubicTo((width * 6) / 7, height / 9, (width * 13) / 13, (height * 2) / 5, width / 2, (height * 7) / 12); canvas.drawPath(path, painter - // ..style = PaintingStyle.fill - // ..color = Colors.red - ); + // ..style = PaintingStyle.fill + // ..color = Colors.red + ); Path path2 = new Path(); path2.moveTo(width / 2, height / 4); @@ -134,25 +135,29 @@ class DrawPainter extends CustomPainter { canvas.drawPath(path2, painter); break; case 'drawArc': - // 绘制圆弧 - // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 + // 绘制圆弧 + // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 const PI = 3.1415926; - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 0.0), radius: 100.0); - canvas.drawArc(rect1, 0.0, PI / 2, false, painter ..color = Colors.pink); - - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 150.0), radius: 100.0); - canvas.drawArc(rect2, 0.0, PI / 2, true, painter ..color = Colors.deepPurple); + Rect rect1 = + Rect.fromCircle(center: Offset(size.width / 2, 0.0), radius: 100.0); + canvas.drawArc(rect1, 0.0, PI / 2, false, painter..color = Colors.pink); + + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 150.0), radius: 100.0); + canvas.drawArc( + rect2, 0.0, PI / 2, true, painter..color = Colors.deepPurple); break; case 'drawRRect': - /// fromPoints(Offset a, Offset b) - /// 使用左上和右下角坐标来确定矩形的大小和位置 - /// fromCircle({ Offset center, double radius }) - /// 使用圆的圆心点坐标和半径和确定外切矩形的大小和位置 - /// fromLTRB(double left, double top, double right, double bottom) - /// 使用矩形左边的X坐标、矩形顶部的Y坐标、矩形右边的X坐标、矩形底部的Y坐标来确定矩形的大小和位置 - /// fromLTWH(double left, double top, double width, double height) - /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 - // 用Rect构建一个边长50,中心点坐标为50,100的矩形 + + /// fromPoints(Offset a, Offset b) + /// 使用左上和右下角坐标来确定矩形的大小和位置 + /// fromCircle({ Offset center, double radius }) + /// 使用圆的圆心点坐标和半径和确定外切矩形的大小和位置 + /// fromLTRB(double left, double top, double right, double bottom) + /// 使用矩形左边的X坐标、矩形顶部的Y坐标、矩形右边的X坐标、矩形底部的Y坐标来确定矩形的大小和位置 + /// fromLTWH(double left, double top, double width, double height) + /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 + // 用Rect构建一个边长50,中心点坐标为50,100的矩形 Rect rect1 = Rect.fromCircle(center: Offset(50.0, 50.0), radius: 50.0); Rect rect2 = Rect.fromCircle(center: Offset(200.0, 50.0), radius: 50.0); // 根据上面的矩形,构建一个圆角矩形 @@ -162,13 +167,15 @@ class DrawPainter extends CustomPainter { canvas.drawRRect(rrect2, painter); break; case 'drawDRRect': - //绘制两个矩形 - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 60.0); - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 40.0); + //绘制两个矩形 + Rect rect1 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 60.0); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 40.0); //分别绘制外部圆角矩形和内部的圆角矩形 RRect outer = RRect.fromRectAndRadius(rect1, Radius.circular(30.0)); RRect inner = RRect.fromRectAndRadius(rect2, Radius.circular(5.0)); - canvas.drawDRRect(outer, inner, painter ..color = Colors.lime); + canvas.drawDRRect(outer, inner, painter..color = Colors.lime); break; } } diff --git a/lib/widgets/elements/Media/Canvas/PainterPath/index.dart b/lib/widgets/elements/Media/Canvas/PainterPath/index.dart index ab64fadb..78545088 100644 --- a/lib/widgets/elements/Media/Canvas/PainterPath/index.dart +++ b/lib/widgets/elements/Media/Canvas/PainterPath/index.dart @@ -34,7 +34,6 @@ const Text5 = ''' > 三阶贝塞尔曲线 '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Canvas/PainterPath'; @@ -51,13 +50,13 @@ class _DemoState extends State { Text, Text1, Text2, - demoBoxs.CustomViewPage(type:'simpleline'), + demoBoxs.CustomViewPage(type: 'simpleline'), Text3, - demoBoxs.CustomViewPage(type:'polyline'), + demoBoxs.CustomViewPage(type: 'polyline'), Text4, - demoBoxs.CustomViewPage(type:'Besizerline2'), + demoBoxs.CustomViewPage(type: 'Besizerline2'), Text5, - demoBoxs.CustomViewPage(type:'Besizerline3'), + demoBoxs.CustomViewPage(type: 'Besizerline3'), ], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Paint-class.html', ); diff --git a/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart b/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart index af67fae6..66455c82 100644 --- a/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart +++ b/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart @@ -18,14 +18,13 @@ class PainterSketchDome extends StatefulWidget { } class _PainterSketchDomeState extends State { - List lines = []; List nowPoints = []; Color nowColor = Colors.redAccent; - void moveGestureDetector(DragUpdateDetails detail){ + void moveGestureDetector(DragUpdateDetails detail) { RenderBox box = context.findRenderObject(); - final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置 + final Offset xy = box.globalToLocal(detail.globalPosition); // 重要需要转换以下坐标位置 Offset p = Offset(xy.dx, xy.dy - 60); //Offset p = Offset(detail.globalPosition.dx, detail.globalPosition.dy - 60); if (mounted) { @@ -42,7 +41,7 @@ class _PainterSketchDomeState extends State { nowPoints.clear(); } RenderBox box = context.findRenderObject(); - final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置 + final Offset xy = box.globalToLocal(detail.globalPosition); // 重要需要转换以下坐标位置 Offset p = Offset(xy.dx, xy.dy - 60); //Offset p = Offset(detail.globalPosition.dx, detail.globalPosition.dy - 60); if (mounted) { @@ -52,7 +51,7 @@ class _PainterSketchDomeState extends State { } } - void changeColor (Color c){ + void changeColor(Color c) { if (nowPoints.length != 0) { LinePoints l = LinePoints(new List.from(nowPoints), nowColor); lines.add(l); @@ -75,9 +74,10 @@ class _PainterSketchDomeState extends State { Colors.deepPurpleAccent, Colors.lightBlueAccent, Colors.lightGreenAccent, - Colors.cyanAccent,]; + Colors.cyanAccent, + ]; - void _tapClear(){ + void _tapClear() { if (mounted) { setState(() { lines.clear(); @@ -91,62 +91,59 @@ class _PainterSketchDomeState extends State { List pallet = []; for (int i = 0; i < colors.length; i++) { Color c = colors[i]; - pallet.add(ColorPallet(color: c,changeColor: changeColor,isSelect: c==nowColor,)); + pallet.add(ColorPallet( + color: c, + changeColor: changeColor, + isSelect: c == nowColor, + )); } return SizedBox( - width: MediaQuery.of(context).size.width * 0.9, - height: MediaQuery.of(context).size.height * 0.6, - child:new Scaffold( - primary: false, - body: new Container( - decoration: BoxDecoration( - color: Colors.white - ), - child:new Flex( - direction: Axis.vertical, - children: [ - Container( - decoration:BoxDecoration( - color: Colors.black12 - ), - child: ListView( - scrollDirection: Axis.horizontal, - children: pallet - , - ), - height: 60.0, + width: MediaQuery.of(context).size.width * 0.9, + height: MediaQuery.of(context).size.height * 0.6, + child: new Scaffold( + primary: false, + body: new Container( + decoration: BoxDecoration(color: Colors.white), + child: new Flex( + direction: Axis.vertical, + children: [ + Container( + decoration: BoxDecoration(color: Colors.black12), + child: ListView( + scrollDirection: Axis.horizontal, + children: pallet, ), - Expanded( - child: AspectRatio( - aspectRatio: 1.0, - child: GestureDetector( - child: CustomPaint( - painter: PaintCanvas(lines,nowPoints,nowColor), - ), - onHorizontalDragUpdate: moveGestureDetector, - onVerticalDragUpdate: moveGestureDetector, - onHorizontalDragStart: newGestureDetector, - onVerticalDragStart: newGestureDetector, + height: 60.0, + ), + Expanded( + child: AspectRatio( + aspectRatio: 1.0, + child: GestureDetector( + child: CustomPaint( + painter: PaintCanvas(lines, nowPoints, nowColor), ), + onHorizontalDragUpdate: moveGestureDetector, + onVerticalDragUpdate: moveGestureDetector, + onHorizontalDragStart: newGestureDetector, + onVerticalDragStart: newGestureDetector, ), - ) - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _tapClear, - backgroundColor: Colors.redAccent, - foregroundColor: Colors.white, - child: Icon(Icons.delete), + ), + ) + ], ), - ) - ); + ), + floatingActionButton: FloatingActionButton( + onPressed: _tapClear, + backgroundColor: Colors.redAccent, + foregroundColor: Colors.white, + child: Icon(Icons.delete), + ), + )); } } -class PaintCanvas extends CustomPainter{ - +class PaintCanvas extends CustomPainter { final List lines; final List nowPoints; final Color nowColor; @@ -162,14 +159,14 @@ class PaintCanvas extends CustomPainter{ canvas.save(); for (int i = 0; i < lines.length; i++) { LinePoints l = lines[i]; - for (int j = 1; j < l.points.length; j++){ + for (int j = 1; j < l.points.length; j++) { Offset p1 = l.points[j - 1]; Offset p2 = l.points[j]; p.color = l.lineColor; canvas.drawLine(p1, p2, p); } } - for (int i = 1; i < nowPoints.length; i++){ + for (int i = 1; i < nowPoints.length; i++) { Offset p1 = nowPoints[i - 1]; Offset p2 = nowPoints[i]; p.color = nowColor; @@ -178,13 +175,14 @@ class PaintCanvas extends CustomPainter{ canvas.restore(); } + @override bool shouldRepaint(CustomPainter oldDelegate) { return true; } } -class LinePoints{ +class LinePoints { final List points; final Color lineColor; LinePoints(this.points, this.lineColor); @@ -193,10 +191,11 @@ class LinePoints{ class ColorPallet extends StatelessWidget { final Color color; final Function changeColor; - const ColorPallet({Key key, this.color, this.changeColor, this.isSelect}) : super(key: key); + const ColorPallet({Key key, this.color, this.changeColor, this.isSelect}) + : super(key: key); final bool isSelect; - void onPressed(){ + void onPressed() { changeColor(color); } @@ -204,16 +203,16 @@ class ColorPallet extends StatelessWidget { Widget build(BuildContext context) { return new RawMaterialButton( onPressed: onPressed, - constraints: BoxConstraints(minWidth: 60.0,minHeight: 50.0), + constraints: BoxConstraints(minWidth: 60.0, minHeight: 50.0), child: new Container( - margin: EdgeInsets.only(top: 5.0,bottom: 5.0), + margin: EdgeInsets.only(top: 5.0, bottom: 5.0), width: 50.0, height: 50.0, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.all(Radius.circular(25.0)), - border: Border.all(color: Colors.white,width: isSelect?3.0:0.0) - ), - )) ; + border: + Border.all(color: Colors.white, width: isSelect ? 3.0 : 0.0)), + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart b/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart index 1288eb9f..15bfbe0f 100644 --- a/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart +++ b/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart @@ -13,7 +13,6 @@ const Text1 = ''' - canvas + paint + GestureDetector 实现一个 简易的画板; '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Canvas/PainterSketch'; @@ -26,13 +25,8 @@ class _DemoState extends State { return WidgetDemo( title: 'PainterSketch', codeUrl: 'elements/Media/Canvas/PainterSketch/demo.dart', - contentList: [ - Text, - Text1, - demoBoxs.PainterSketchDome() - ], + contentList: [Text, Text1, demoBoxs.PainterSketchDome()], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Paint-class.html', ); } } - diff --git a/lib/widgets/elements/Media/Canvas/index.dart b/lib/widgets/elements/Media/Canvas/index.dart index d3c73227..78d48188 100644 --- a/lib/widgets/elements/Media/Canvas/index.dart +++ b/lib/widgets/elements/Media/Canvas/index.dart @@ -6,7 +6,6 @@ import 'Canvas/index.dart' as Canvas; import 'PainterPath/index.dart' as PainterPath; import 'CircleProgressBarPainter/index.dart' as CircleProgressBarPainter; - List widgetPoints = [ WidgetPoint( name: 'PainterSketch', diff --git a/lib/widgets/elements/Media/Icon/Icon/demo.dart b/lib/widgets/elements/Media/Icon/Icon/demo.dart index 3fca415b..5bc716c2 100644 --- a/lib/widgets/elements/Media/Icon/Icon/demo.dart +++ b/lib/widgets/elements/Media/Icon/Icon/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 15:10:34 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 11:09:17 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 15:10:34 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 11:09:17 import 'package:flutter/material.dart'; class IconDemo extends StatelessWidget { @@ -13,7 +13,7 @@ class IconDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: Icon( + child: Icon( Icons.favorite, color: this.curColor, size: 30.0, diff --git a/lib/widgets/elements/Media/Icon/IconData/demo.dart b/lib/widgets/elements/Media/Icon/IconData/demo.dart index a9706e45..db66937d 100644 --- a/lib/widgets/elements/Media/Icon/IconData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconData/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 10:15:34 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 11:38:50 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 10:15:34 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 11:38:50 import 'package:flutter/material.dart'; class IconDataDemo extends StatelessWidget { @@ -13,10 +13,9 @@ class IconDataDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: Icon( + child: Icon( //参考 icon constans - IconData(0xe567, - fontFamily: 'MaterialIcons', matchTextDirection: true), + IconData(0xe567, fontFamily: 'MaterialIcons', matchTextDirection: true), color: this.curColor, size: 30.0, ), diff --git a/lib/widgets/elements/Media/Icon/IconData/index.dart b/lib/widgets/elements/Media/Icon/IconData/index.dart index 9017a35f..56512990 100644 --- a/lib/widgets/elements/Media/Icon/IconData/index.dart +++ b/lib/widgets/elements/Media/Icon/IconData/index.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; - const Text = ''' ### **简介** > 字体表示符合表示的图标说明 diff --git a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart index c27da87f..0ea9ea05 100644 --- a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 16:07:59 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-15 16:49:17 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 16:07:59 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-15 16:49:17 import 'package:flutter/material.dart'; class IconThemeDemo extends StatelessWidget { @@ -14,8 +14,8 @@ class IconThemeDemo extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 3.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 3.0), child: Container( padding: EdgeInsets.all(20.0), child: Icon(Icons.equalizer), @@ -36,8 +36,8 @@ class IconThemeDemo2 extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 3.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 3.0), child: Row( children: [ Icon( diff --git a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart index 67d852d6..c21a55e8 100644 --- a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-17 09:46:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 15:53:42 +/// Author: xiaojia.dxj +/// Date: 2018-12-17 09:46:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 15:53:42 import 'package:flutter/material.dart'; @@ -15,13 +15,13 @@ class IconThemeDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: IconTheme( + child: IconTheme( //opacity: 设置透明 - data: IconThemeData( + data: IconThemeData( color: curColor, opacity: curOpacity, ), - child: Icon(Icons.favorite), + child: Icon(Icons.favorite), ), ); } @@ -37,8 +37,8 @@ class IconThemeDemo2 extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 1.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 1.0), child: Row( children: [ Icon(Icons.favorite_border), diff --git a/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart b/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart index 0345c3b6..8c971f8e 100644 --- a/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart +++ b/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart @@ -1,9 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 15:19:41 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 10:07:19 - +/// Author: xiaojia.dxj +/// Date: 2018-12-15 15:19:41 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 10:07:19 import 'package:flutter/material.dart'; @@ -11,8 +10,8 @@ class ImageIconDemo extends StatelessWidget { @override Widget build(BuildContext context) { //注意:当你用一个图片的时候,这个图片会被整个覆盖,只保留图片的形状,填充你设置的颜色 - return ImageIcon( - AssetImage('assets/images/btn_icon_dingyuehao_normal.png'), + return ImageIcon( + AssetImage('assets/images/btn_icon_dingyuehao_normal.png'), color: Colors.red, size: 50.0, ); diff --git a/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart b/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart index 940b4cd7..83e412ec 100644 --- a/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart +++ b/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart @@ -4,18 +4,18 @@ class AssetImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Column( - children: [ - CircleAvatar( - backgroundImage: AssetImage('assets/images/food01.jpeg'), + children: [ + CircleAvatar( + backgroundImage: AssetImage('assets/images/food01.jpeg'), + ), + Container( + child: Image( + image: AssetImage('assets/images/food02.jpeg'), + height: 300.0, + width: 300.0, ), - Container( - child: Image( - image: AssetImage('assets/images/food02.jpeg'), - height: 300.0, - width: 300.0, - ), - ) - ], - ); + ) + ], + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/AssetImage/index.dart b/lib/widgets/elements/Media/Image/AssetImage/index.dart index b33a0db6..d5705677 100644 --- a/lib/widgets/elements/Media/Image/AssetImage/index.dart +++ b/lib/widgets/elements/Media/Image/AssetImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/DecorationImage/index.dart b/lib/widgets/elements/Media/Image/DecorationImage/index.dart index d2f638e5..32f15514 100644 --- a/lib/widgets/elements/Media/Image/DecorationImage/index.dart +++ b/lib/widgets/elements/Media/Image/DecorationImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:12:39 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:12:39 import 'package:flutter/material.dart'; @@ -14,7 +14,7 @@ const contentText0 = ''' > 修饰Box的图片 '''; -const contentText1= ''' +const contentText1 = ''' ### **基本用法** > demo演示作为背景图片的样例 diff --git a/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart b/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart index c1b4ae0f..b0fe6042 100644 --- a/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart +++ b/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart @@ -3,15 +3,12 @@ import 'package:flutter/material.dart'; class DecorationImagePainterDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } } // class ImagePainter extends CustomPainter{ - // Future getImage(String path) async { // ByteData data = await rootBundle.load(path); // ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); @@ -35,4 +32,4 @@ class DecorationImagePainterDemo extends StatelessWidget { // // TODO: implement shouldRepaint // return false; // } -// } \ No newline at end of file +// } diff --git a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart index 4550381a..e743ddc8 100644 --- a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart +++ b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; @@ -20,11 +20,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [], - docUrl: 'https://docs.flutter.io/flutter/painting/DecorationImagePainter-class.html', - codeUrl: 'elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart', - title:'DecorationImagePainter' - ); + contentList: [], + docUrl: + 'https://docs.flutter.io/flutter/painting/DecorationImagePainter-class.html', + codeUrl: + 'elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart', + title: 'DecorationImagePainter'); } } - diff --git a/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart b/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart index 9b7a5c36..fdc6a09a 100644 --- a/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart +++ b/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 13:29:34 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 14:12:21 +/// @Author: 一凨 +/// @Date: 2018-12-08 13:29:34 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 14:12:21 import 'package:flutter/material.dart'; @@ -36,9 +36,11 @@ class _DemoState extends State { contentText1, ExactAssetImageDemo(), ], - title:'ExactAssetImage', - codeUrl: 'elements/Media/Image/ExactAssetImage/exact_asset_image_demo.dart', - docUrl: 'https://docs.flutter.io/flutter/painting/ExactAssetImage-class.html', + title: 'ExactAssetImage', + codeUrl: + 'elements/Media/Image/ExactAssetImage/exact_asset_image_demo.dart', + docUrl: + 'https://docs.flutter.io/flutter/painting/ExactAssetImage-class.html', ); } } diff --git a/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart b/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart index e0eccc6e..cf55c8ff 100644 --- a/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart +++ b/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:08:41 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 16:22:50 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:08:41 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 16:22:50 import 'package:flutter/material.dart'; @@ -10,8 +10,8 @@ class FadeInImageDemo extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - ClipOval( - child: FadeInImage.assetNetwork( + ClipOval( + child: FadeInImage.assetNetwork( placeholder: "assets/images/normal_user_icon.png", //预览图 fit: BoxFit.fitWidth, image: @@ -23,10 +23,10 @@ class FadeInImageDemo extends StatelessWidget { SizedBox( height: 20.0, ), - CircleAvatar( - backgroundImage: NetworkImage( + CircleAvatar( + backgroundImage: NetworkImage( "https://img.alicdn.com/tfs/TB148sWfMHqK1RjSZFgXXa7JXXa-536-482.png"), - child: Text("一凨"), //可以在图片上添加文字等等 + child: Text("一凨"), //可以在图片上添加文字等等 ), ], ); diff --git a/lib/widgets/elements/Media/Image/FadeInImage/index.dart b/lib/widgets/elements/Media/Image/FadeInImage/index.dart index ffcf1d16..4ae7fdbd 100644 --- a/lib/widgets/elements/Media/Image/FadeInImage/index.dart +++ b/lib/widgets/elements/Media/Image/FadeInImage/index.dart @@ -1,14 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 14:26:00 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 16:10:55 +/// @Author: 一凨 +/// @Date: 2018-12-08 14:26:00 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 16:10:55 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './fade_in_image_demo.dart'; - const contentText0 = ''' ### **简介** > placeHodler image到目标图片的一种过渡widget @@ -25,7 +24,6 @@ const contentText1 = ''' '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Image/FadeInImage'; _DemoState createState() => _DemoState(); @@ -37,7 +35,7 @@ class _DemoState extends State { return WidgetDemo( codeUrl: 'elements/Media/Image/FadeInImage/fade_in_image_demo.dart', docUrl: 'https://docs.flutter.io/flutter/widgets/FadeInImage-class.html', - title:'FadeInImage', + title: 'FadeInImage', contentList: [ contentText0, contentText1, diff --git a/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart b/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart index f0638e39..684dd47b 100644 --- a/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart +++ b/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:20:17 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:18:39 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:20:17 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:18:39 import 'dart:async'; import 'dart:io'; @@ -11,7 +11,7 @@ import 'package:image_picker/image_picker.dart'; class FileImageDemo extends StatefulWidget { @override - _FileImageDemoState createState() => _FileImageDemoState(); + _FileImageDemoState createState() => _FileImageDemoState(); } class _FileImageDemoState extends State { @@ -29,16 +29,22 @@ class _FileImageDemoState extends State { Widget build(BuildContext context) { return Column( children: [ - Center( + Center( child: _image == null - ? Text('您还未选择任何图片.') - : Image.file(_image,scale: 0.5,fit: BoxFit.cover,), + ? Text('您还未选择任何图片.') + : Image.file( + _image, + scale: 0.5, + fit: BoxFit.cover, + ), ), FlatButton( - onPressed: getImage, - child: Text('点击选择图片',style: TextStyle(color: Colors.white),), - color: Colors.lightBlue - ) + onPressed: getImage, + child: Text( + '点击选择图片', + style: TextStyle(color: Colors.white), + ), + color: Colors.lightBlue) ], ); } diff --git a/lib/widgets/elements/Media/Image/FileImage/index.dart b/lib/widgets/elements/Media/Image/FileImage/index.dart index ff20b410..18d8fe8a 100644 --- a/lib/widgets/elements/Media/Image/FileImage/index.dart +++ b/lib/widgets/elements/Media/Image/FileImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:20:33 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 19:24:33 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:20:33 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 19:24:33 import 'package:flutter/material.dart'; @@ -32,7 +32,7 @@ class _DemoState extends State { return WidgetDemo( codeUrl: 'elements/Media/Image/FileImage/file_image_demo.dart', docUrl: 'https://docs.flutter.io/flutter/painting/FileImage-class.html', - title:'FileImage', + title: 'FileImage', contentList: [ contentText0, contentText1, diff --git a/lib/widgets/elements/Media/Image/Image/demo.dart b/lib/widgets/elements/Media/Image/Image/demo.dart index 64a053b7..fb2afb8d 100644 --- a/lib/widgets/elements/Media/Image/Image/demo.dart +++ b/lib/widgets/elements/Media/Image/Image/demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2019-01-07 15:33:49 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-07 15:45:29 +/// @Author: 一凨 +/// @Date: 2019-01-07 15:33:49 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-07 15:45:29 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/Image/index.dart b/lib/widgets/elements/Media/Image/Image/index.dart index c0f13f70..1281949f 100644 --- a/lib/widgets/elements/Media/Image/Image/index.dart +++ b/lib/widgets/elements/Media/Image/Image/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2019-01-07 15:33:42 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-07 15:42:54 +/// @Author: 一凨 +/// @Date: 2019-01-07 15:33:42 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-07 15:42:54 import 'package:flutter/material.dart'; @@ -34,14 +34,14 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'Image', - codeUrl: 'elements/Media/Image/Image/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/dart-ui/Image-class.html', - contentList: [ - content0, - content1, - ImageDemo(), - ], + title: 'Image', + codeUrl: 'elements/Media/Image/Image/demo.dart', + docUrl: 'https://docs.flutter.io/flutter/dart-ui/Image-class.html', + contentList: [ + content0, + content1, + ImageDemo(), + ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/MemoryImage/index.dart b/lib/widgets/elements/Media/Image/MemoryImage/index.dart index b89aefbd..b70f2107 100644 --- a/lib/widgets/elements/Media/Image/MemoryImage/index.dart +++ b/lib/widgets/elements/Media/Image/MemoryImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:48:28 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:48:28 import 'package:flutter/material.dart'; @@ -27,7 +27,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - @override Widget build(BuildContext context) { return WidgetDemo( @@ -39,8 +38,7 @@ class _DemoState extends State { title: 'MemoryImage', // desc: 'MemoryImage 使用介绍', docUrl: 'https://docs.flutter.io/flutter/painting/MemoryImage-class.html', - codeUrl: - 'elements/Media/Image/MemoryImage/index.dart', + codeUrl: 'elements/Media/Image/MemoryImage/index.dart', ); } } diff --git a/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart b/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart index 6abe4acc..9b12c559 100644 --- a/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart +++ b/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart @@ -1,14 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:49:19 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:46:37 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:49:19 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:46:37 import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; - class MemoryImageDemo extends StatefulWidget { _MemoryImageDemoState createState() => _MemoryImageDemoState(); } @@ -29,17 +28,17 @@ class _MemoryImageDemoState extends State { @override Widget build(BuildContext context) { - final decoration = BoxDecoration( + final decoration = BoxDecoration( image: bytes == null ? null - : DecorationImage( - image: MemoryImage(bytes,scale: 1.0), + : DecorationImage( + image: MemoryImage(bytes, scale: 1.0), ), ); return Container( - width: 300.0, - height: 300.0, - decoration: decoration, + width: 300.0, + height: 300.0, + decoration: decoration, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/NetworkImage/index.dart b/lib/widgets/elements/Media/Image/NetworkImage/index.dart index b3e4e72e..6d885096 100644 --- a/lib/widgets/elements/Media/Image/NetworkImage/index.dart +++ b/lib/widgets/elements/Media/Image/NetworkImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:32:57 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:32:57 import 'package:flutter/material.dart'; @@ -35,7 +35,8 @@ class _DemoState extends State { NetworkImageDemo(), ], codeUrl: 'elements/Media/Image/NetworkImage/network_image_demo.dart', - docUrl: 'https://docs.flutter.io/flutter/painting/NetworkImage-class.html', + docUrl: + 'https://docs.flutter.io/flutter/painting/NetworkImage-class.html', title: 'NetworkImage', ); } diff --git a/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart b/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart index 42f001c7..85b5d945 100644 --- a/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart +++ b/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:20:37 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:35:36 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:20:37 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:35:36 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/RawImage/index.dart b/lib/widgets/elements/Media/Image/RawImage/index.dart index a96e002a..e4a07c78 100644 --- a/lib/widgets/elements/Media/Image/RawImage/index.dart +++ b/lib/widgets/elements/Media/Image/RawImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:11:44 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:11:44 import 'package:flutter/material.dart'; @@ -21,7 +21,7 @@ const contentText1 = ''' '''; -const contentText2= ''' +const contentText2 = ''' ### **高级用法** > 关于更多详细介绍,请看paintImage的属性说明 '''; diff --git a/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart b/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart index 3aa1caba..b3dd2dce 100644 --- a/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart +++ b/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:47:25 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:09:32 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:47:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:09:32 import 'dart:async'; import 'dart:typed_data'; diff --git a/lib/widgets/elements/Media/Image/index.dart b/lib/widgets/elements/Media/Image/index.dart index 3ff15ba3..9e36aa98 100644 --- a/lib/widgets/elements/Media/Image/index.dart +++ b/lib/widgets/elements/Media/Image/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:19 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:19 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:37:07 @@ -19,7 +19,6 @@ import './precacheImage/index.dart' as precacheImage; import './RawImage/index.dart' as RawImage; import './Image/index.dart' as Image; - List widgetPoints = [ WidgetPoint( name: 'AssetImage', @@ -81,4 +80,4 @@ List widgetPoints = [ routerName: Image.Demo.routeName, buildRouter: (BuildContext context) => Image.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Media/Image/paintImage/index.dart b/lib/widgets/elements/Media/Image/paintImage/index.dart index 38721433..99f62fb3 100644 --- a/lib/widgets/elements/Media/Image/paintImage/index.dart +++ b/lib/widgets/elements/Media/Image/paintImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:19:01 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:19:01 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart b/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart index 24347bcc..d09cf682 100644 --- a/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart +++ b/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart @@ -1,15 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:46:57 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:46:57 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:46:57 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:46:57 import 'package:flutter/material.dart'; class PaintImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/precacheImage/index.dart b/lib/widgets/elements/Media/Image/precacheImage/index.dart index 8e586ff9..5b7aeebe 100644 --- a/lib/widgets/elements/Media/Image/precacheImage/index.dart +++ b/lib/widgets/elements/Media/Image/precacheImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; @@ -14,7 +14,7 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return Container( - child: null, + child: null, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart b/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart index 4464e624..23de6bd7 100644 --- a/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart +++ b/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart @@ -1,15 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:47:57 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:48:20 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:47:57 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:48:20 import 'package:flutter/material.dart'; class PrecacheImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/index.dart b/lib/widgets/elements/Media/index.dart index 488d1f67..a7c68ec4 100644 --- a/lib/widgets/elements/Media/index.dart +++ b/lib/widgets/elements/Media/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:27 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-11-16 15:09:27 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:27 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:27 import 'Image/index.dart' as Image; import 'Icon/index.dart' as Icon; @@ -13,4 +13,4 @@ List getWidgets() { result.addAll(Icon.widgetPoints); result.addAll(Canvas.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/index.dart b/lib/widgets/elements/index.dart index d3362d59..a4f3e71f 100644 --- a/lib/widgets/elements/index.dart +++ b/lib/widgets/elements/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:31 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-11-16 15:09:31 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:31 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:31 import 'Form/index.dart' as Form; import 'Frame/index.dart' as Frame; @@ -13,4 +13,4 @@ List getWidgets() { result.addAll(Frame.getWidgets()); result.addAll(Media.getWidgets()); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart b/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart index ddd7888a..70d266a8 100644 --- a/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart @@ -33,8 +33,8 @@ class _CupertinoAppFullDefault extends State { (___, Animation animation, ____, Widget child) { return FadeTransition( opacity: animation, - child: ScaleTransition( - scale: Tween(begin: 0.5, end: 1.0).animate(animation), + child: ScaleTransition( + scale: Tween(begin: 0.5, end: 1.0).animate(animation), child: child, ), ); @@ -144,7 +144,8 @@ class _CupertinoAppFullDefault extends State { backgroundColor: CupertinoColors.destructiveRed, middle: Text('这里是标题', style: TextStyle(color: Colors.white)), ), - child: Center(child: Text('这里是内容', style: TextStyle(color: Colors.black))), + child: Center( + child: Text('这里是内容', style: TextStyle(color: Colors.black))), backgroundColor: CupertinoColors.inactiveGray, ); }); diff --git a/lib/widgets/themes/Cupertino/CupertinoApp/index.dart b/lib/widgets/themes/Cupertino/CupertinoApp/index.dart index e1efb44d..1ae50897 100644 --- a/lib/widgets/themes/Cupertino/CupertinoApp/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoApp/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:52:45 @@ -40,14 +40,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoAppFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoAppFullDefault()], title: 'CupertinoApp', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoApp-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoApp-class.html', codeUrl: 'themes/Cupertino/CupertinoApp/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart b/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart index 806704df..47dc60a7 100644 --- a/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart @@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - // Checkbox 默认按钮的实例 // index 当前checkbox 的索引值 class CupertinoButtonFullDefault extends StatefulWidget { @@ -18,10 +17,8 @@ class CupertinoButtonFullDefault extends StatefulWidget { State createState() => _CupertinoButtonFullDefault(); } - // CupertinoButton 默认的实例,有状态 class _CupertinoButtonFullDefault extends State { - @override Widget build(BuildContext context) { return CupertinoButton( @@ -29,9 +26,9 @@ class _CupertinoButtonFullDefault extends State { onPressed: () { print('on Pressed!'); }, - pressedOpacity:0.5,// 按下后的按钮不透明度 - color:CupertinoColors.inactiveGray, + pressedOpacity: 0.5, // 按下后的按钮不透明度 + color: CupertinoColors.inactiveGray, child: new Text('CupertinoButton'), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoButton/index.dart b/lib/widgets/themes/Cupertino/CupertinoButton/index.dart index 03b691f3..2dd1c485 100644 --- a/lib/widgets/themes/Cupertino/CupertinoButton/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoButton/index.dart @@ -31,14 +31,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoButtonFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoButtonFullDefault()], title: 'CupertinoButton', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html', codeUrl: 'themes/Cupertino/CupertinoButton/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart b/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart index 926fbcc1..40ad5a9e 100644 --- a/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart @@ -19,27 +19,27 @@ class CupertinoColorsFullDefault extends StatefulWidget { // CupertinoColors 默认的实例,有状态 class _CupertinoColorsFullDefault extends State { - - Widget setColorsView(cupertinoColors,String colorName){ + Widget setColorsView(cupertinoColors, String colorName) { return Container( - width: MediaQuery.of(context).size.width-100, + width: MediaQuery.of(context).size.width - 100, padding: const EdgeInsets.all(10.0), - child:Text(colorName,style:TextStyle(color:Colors.white)), - decoration:BoxDecoration(color: cupertinoColors) - ); + child: Text(colorName, style: TextStyle(color: Colors.white)), + decoration: BoxDecoration(color: cupertinoColors)); } + @override Widget build(BuildContext context) { return Column( children: [ - setColorsView(CupertinoColors.activeBlue,'activeBlue'), - setColorsView(CupertinoColors.activeGreen,'activeGreen'), - setColorsView(CupertinoColors.black,'black'), - setColorsView(CupertinoColors.destructiveRed,'destructiveRed'), - setColorsView(CupertinoColors.inactiveGray,'inactiveGray'), - setColorsView(CupertinoColors.lightBackgroundGray,'lightBackgroundGray'), - setColorsView(CupertinoColors.white,'white') + setColorsView(CupertinoColors.activeBlue, 'activeBlue'), + setColorsView(CupertinoColors.activeGreen, 'activeGreen'), + setColorsView(CupertinoColors.black, 'black'), + setColorsView(CupertinoColors.destructiveRed, 'destructiveRed'), + setColorsView(CupertinoColors.inactiveGray, 'inactiveGray'), + setColorsView( + CupertinoColors.lightBackgroundGray, 'lightBackgroundGray'), + setColorsView(CupertinoColors.white, 'white') ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoColors/index.dart b/lib/widgets/themes/Cupertino/CupertinoColors/index.dart index 4953ba79..2a32adf3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoColors/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoColors/index.dart @@ -29,14 +29,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoColorsFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoColorsFullDefault()], title: 'CupertinoColors', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoColors-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoColors-class.html', codeUrl: 'themes/Cupertino/CupertinoColors/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart b/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart index 10c01ad6..55449e56 100644 --- a/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart @@ -20,11 +20,10 @@ class CupertinoIconsFullDefault extends StatefulWidget { // CupertinoIcons 默认的实例,有状态 class _CupertinoIconsFullDefault extends State { - final colorsList = []; final List widgetList = []; - Widget rowView(IconData itA,IconData itB){ + Widget rowView(IconData itA, IconData itB) { //print('itA=====>${itA.fontPackage}'); return Row( //mainAxisSize:MainAxisSize.max, @@ -32,28 +31,30 @@ class _CupertinoIconsFullDefault extends State { //mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( - flex:1, - child: CupertinoButton( - padding: EdgeInsets.only(left: 0), - onPressed: () { }, - child:FlatButton.icon( - label: Text('默认按钮', semanticsLabel: 'Add'), - icon:Icon(itA, - semanticLabel: 'Add', - ), - onPressed: () { }, - ))), + flex: 1, + child: CupertinoButton( + padding: EdgeInsets.only(left: 0), + onPressed: () {}, + child: FlatButton.icon( + label: Text('默认按钮', semanticsLabel: 'Add'), + icon: Icon( + itA, + semanticLabel: 'Add', + ), + onPressed: () {}, + ))), Expanded( - flex:1, + flex: 1, child: CupertinoButton( padding: EdgeInsets.zero, - onPressed: () { }, - child:FlatButton.icon( + onPressed: () {}, + child: FlatButton.icon( label: Text('默认按钮', semanticsLabel: 'Add'), - icon:Icon(itB, + icon: Icon( + itB, semanticLabel: 'Add', ), - onPressed: () { }, + onPressed: () {}, ))), ], ); @@ -64,22 +65,21 @@ class _CupertinoIconsFullDefault extends State { super.initState(); final names = icon_names.CupertinoIIconNames.names; - for(var i=0;i { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoIconsFullDefault() - ], - title: 'CupertinoIcons', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoIcons-class.html', - codeUrl: 'themes/Cupertino/CupertinoIcons/demo.dart' - ); + contentList: [content0, content1, demoBox.CupertinoIconsFullDefault()], + title: 'CupertinoIcons', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoIcons-class.html', + codeUrl: 'themes/Cupertino/CupertinoIcons/demo.dart'); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart index aa62be92..8873c634 100644 --- a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart @@ -18,115 +18,118 @@ class CupertinoNavigationBarFullDefault extends StatefulWidget { // CupertinoNavigationBar 默认的实例,有状态 class _CupertinoNavigationBarFullDefault extends State { - Widget build2(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - //height: 500.0, - child:CupertinoApp( - home: CupertinoTabScaffold( - tabBar: CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('Tab 1'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('Tab 2'), - ), - ], - ), - tabBuilder: (BuildContext context, int index) { - // For 1-indexed readability. - ++index; - return CupertinoTabView( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tab $index'), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + //height: 500.0, + child: CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('Tab 1'), ), - child: Center( - child: CupertinoButton( - child: const Text('Next'), - onPressed: () { - Navigator.of(context).push( - CupertinoPageRoute( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 2 of tab $index'), - ), - child: Center( - child: CupertinoButton( - child: const Text('Back'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ); - }, - ), - ); - }, - ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('Tab 2'), ), + ], + ), + tabBuilder: (BuildContext context, int index) { + // For 1-indexed readability. + ++index; + return CupertinoTabView( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Next'), + onPressed: () { + Navigator.of(context).push( + CupertinoPageRoute( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 2 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Back'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ); + }, + ), + ); + }, + ), + ), + ); + }, ); }, - ); - }, - ), - ) - ); + ), + )); } @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/1.5, - child: navigationBar(context) - ); + height: MediaQuery.of(context).size.height / 1.5, + child: navigationBar(context)); } Widget navigationBar(BuildContext context) { - return CupertinoPageScaffold( // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold + return CupertinoPageScaffold( + // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold navigationBar: CupertinoNavigationBar( - leading: Icon(CupertinoIcons.back),// 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 - middle: Text('Title'),// 放置在导航栏的中间。通常是标题或分段控件 - trailing: Icon(CupertinoIcons.share),// 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 - actionsForegroundColor:CupertinoColors.white,// 用于 导航栏中前导和尾随小部件的文本和图标的默认颜色。 - backgroundColor:CupertinoColors.activeGreen,// 导航栏的背景颜色。如果它包含透明度,标签栏将自动对其背后的内容产生模糊效果 - border:Border( // 边框样式 - bottom: BorderSide(color: CupertinoColors.inactiveGray, width: 1.0), - ), - //heroTag :null, - previousPageTitle:'???',// 自动隐含前导按钮时手动指定上一个路线的标题 - transitionBetweenRoutes:true // 是否在导航栏之间转换 - ), + leading: + Icon(CupertinoIcons.back), // 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 + middle: Text('Title'), // 放置在导航栏的中间。通常是标题或分段控件 + trailing: + Icon(CupertinoIcons.share), // 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 + actionsForegroundColor: + CupertinoColors.white, // 用于 导航栏中前导和尾随小部件的文本和图标的默认颜色。 + backgroundColor: CupertinoColors + .activeGreen, // 导航栏的背景颜色。如果它包含透明度,标签栏将自动对其背后的内容产生模糊效果 + border: Border( + // 边框样式 + bottom: BorderSide(color: CupertinoColors.inactiveGray, width: 1.0), + ), + //heroTag :null, + previousPageTitle: '???', // 自动隐含前导按钮时手动指定上一个路线的标题 + transitionBetweenRoutes: true // 是否在导航栏之间转换 + ), child: Center( - child: Text('这里是内容', style: TextStyle(color: Colors.black)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + child: Text('这里是内容', + style: TextStyle( + color: Colors + .black))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) ); } - Widget tabBar(BuildContext context){ - return CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.home), - title: Text('Home'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.conversation_bubble), - title: Text('Support'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.profile_circled), - title: Text('Profile'), - ), - ] - ); + Widget tabBar(BuildContext context) { + return CupertinoTabBar(items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.home), + title: Text('Home'), + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.conversation_bubble), + title: Text('Support'), + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.profile_circled), + title: Text('Profile'), + ), + ]); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart index 8dfa5198..786c4b90 100644 --- a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart @@ -44,11 +44,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoNavigationBarFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoNavigationBar', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoNavigationBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoNavigationBar-class.html', codeUrl: 'themes/Cupertino/CupertinoNavigationBar/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart index e09a6d56..2519cb3d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart @@ -18,73 +18,69 @@ class CupertinoPageRouteFullDefault extends StatefulWidget { // CupertinoPageRoute 默认的实例,有状态 class _CupertinoPageRouteFullDefault extends State { - - Widget pageRoute(BuildContext context,int index){ + Widget pageRoute(BuildContext context, int index) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 2 of tab $index'), - ), - child: Center( - child: CupertinoButton( - child: const Text('Back'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ); + navigationBar: CupertinoNavigationBar( + middle: Text('Page 2 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Back'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ); } @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - //height: 500.0, - child:CupertinoApp( - home: CupertinoTabScaffold( - tabBar: CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('无滑动的切换1'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('无滑动的切换2'), - ), - ], - ), - tabBuilder: (BuildContext context, int index) { - // For 1-indexed readability. - ++index; - return CupertinoTabView( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tab $index'), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + //height: 500.0, + child: CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('无滑动的切换1'), ), - child: Center( - child: CupertinoButton( - child: const Text('点击我,看滑动动画'), - onPressed: () { - Navigator.of(context).push( - CupertinoPageRoute( - maintainState:false, // 是否前一个路由将保留在内存中 - builder: (BuildContext context) { // 生成器 - return pageRoute(context,index); - } - ) - ); - }, - ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('无滑动的切换2'), ), + ], + ), + tabBuilder: (BuildContext context, int index) { + // For 1-indexed readability. + ++index; + return CupertinoTabView( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('点击我,看滑动动画'), + onPressed: () { + Navigator.of(context).push(CupertinoPageRoute( + maintainState: false, // 是否前一个路由将保留在内存中 + builder: (BuildContext context) { + // 生成器 + return pageRoute(context, index); + })); + }, + ), + ), + ); + }, ); }, - ); - }, - ), - ) - ); + ), + )); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart b/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart index ba91f779..20821b18 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart @@ -37,11 +37,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPageRouteFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPageRoute', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPageRoute-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPageRoute-class.html', codeUrl: 'themes/Cupertino/CupertinoPageRoute/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart index bc92622c..43cf7d5a 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart @@ -21,23 +21,27 @@ class _CupertinoPageScaffoldFullDefault extends State { @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/1.5, - child: navigationBar(context) - ); + height: MediaQuery.of(context).size.height / 1.5, + child: navigationBar(context)); } Widget navigationBar(BuildContext context) { - return CupertinoPageScaffold( // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold - backgroundColor:CupertinoColors.inactiveGray,// 整个脚手架下面的 widget 的颜色 + return CupertinoPageScaffold( + // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold + backgroundColor: CupertinoColors.inactiveGray, // 整个脚手架下面的 widget 的颜色 navigationBar: CupertinoNavigationBar( - leading: Icon(CupertinoIcons.back),// 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 - middle: Text('这里是标题'),// 放置在导航栏的中间。通常是标题或分段控件 - trailing: Icon(CupertinoIcons.share),// 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 - ), - child: Center( - child: Text('这里是内容', style: TextStyle(color: Colors.black)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) - resizeToAvoidBottomInset:false // child 是否应该调整自己的大小以避免窗口的底部插入 - ); + leading: + Icon(CupertinoIcons.back), // 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 + middle: Text('这里是标题'), // 放置在导航栏的中间。通常是标题或分段控件 + trailing: + Icon(CupertinoIcons.share), // 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 + ), + child: Center( + child: Text('这里是内容', + style: TextStyle( + color: Colors + .black))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + resizeToAvoidBottomInset: false // child 是否应该调整自己的大小以避免窗口的底部插入 + ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart index 98a41a64..5df53852 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart @@ -34,11 +34,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPageScaffoldFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPageScaffold', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPageScaffold-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPageScaffold-class.html', codeUrl: 'themes/Cupertino/CupertinoPageScaffold/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart index 26c6df4b..dbc4e099 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart @@ -8,15 +8,33 @@ import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; - const double _kPickerSheetHeight = 216.0; const double _kPickerItemHeight = 32.0; const List coolColorNames = [ - 'Sarcoline', 'Coquelicot', 'Smaragdine', 'Mikado', 'Glaucous', 'Wenge', - 'Fulvous', 'Xanadu', 'Falu', 'Eburnean', 'Amaranth', 'Australien', - 'Banan', 'Falu', 'Gingerline', 'Incarnadine', 'Labrador', 'Nattier', - 'Pervenche', 'Sinoper', 'Verditer', 'Watchet', 'Zaffre', + 'Sarcoline', + 'Coquelicot', + 'Smaragdine', + 'Mikado', + 'Glaucous', + 'Wenge', + 'Fulvous', + 'Xanadu', + 'Falu', + 'Eburnean', + 'Amaranth', + 'Australien', + 'Banan', + 'Falu', + 'Gingerline', + 'Incarnadine', + 'Labrador', + 'Nattier', + 'Pervenche', + 'Sinoper', + 'Verditer', + 'Watchet', + 'Zaffre', ]; class CupertinoPickerDemo extends StatefulWidget { @@ -43,7 +61,7 @@ class _CupertinoPickerDemoState extends State { Widget _buildMenu(List children) { return Container( decoration: BoxDecoration( - color:CupertinoColors.inactiveGray, + color: CupertinoColors.inactiveGray, border: const Border( top: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), @@ -88,7 +106,7 @@ class _CupertinoPickerDemoState extends State { Widget _buildColorPicker(BuildContext context) { final FixedExtentScrollController scrollController = - FixedExtentScrollController(initialItem: _selectedColorIndex); + FixedExtentScrollController(initialItem: _selectedColorIndex); return GestureDetector( onTap: () async { @@ -97,23 +115,26 @@ class _CupertinoPickerDemoState extends State { builder: (BuildContext context) { return _buildBottomPicker( CupertinoPicker( - magnification:1.0, // 整体放大率 - //offAxisFraction:10.0,// 球面效果的透视系数,消失点位置 - scrollController: scrollController,// 用于读取和控制当前项的FixedxtentScrollController - itemExtent: _kPickerItemHeight,// 所以子节点 统一高度 - backgroundColor: CupertinoColors.white,// 所有子节点下面的背景颜色 - useMagnifier:true,// 是否使用放大效果 - onSelectedItemChanged: (int index) { // 当正中间选项改变时的回调 - if (mounted) { - setState(() => _selectedColorIndex = index); - } - }, - children: List.generate(coolColorNames.length, (int index) { - return Center(child: - Text(coolColorNames[index]), - ); - }), - ), + magnification: 1.0, // 整体放大率 + //offAxisFraction:10.0,// 球面效果的透视系数,消失点位置 + scrollController: + scrollController, // 用于读取和控制当前项的FixedxtentScrollController + itemExtent: _kPickerItemHeight, // 所以子节点 统一高度 + backgroundColor: CupertinoColors.white, // 所有子节点下面的背景颜色 + useMagnifier: true, // 是否使用放大效果 + onSelectedItemChanged: (int index) { + // 当正中间选项改变时的回调 + if (mounted) { + setState(() => _selectedColorIndex = index); + } + }, + children: + List.generate(coolColorNames.length, (int index) { + return Center( + child: Text(coolColorNames[index]), + ); + }), + ), ); }, ); @@ -123,9 +144,7 @@ class _CupertinoPickerDemoState extends State { const Text('Favorite Color'), Text( coolColorNames[_selectedColorIndex], - style: const TextStyle( - color: CupertinoColors.inactiveGray - ), + style: const TextStyle(color: CupertinoColors.inactiveGray), ), ], ), @@ -156,8 +175,8 @@ class _CupertinoPickerDemoState extends State { const Text('Countdown Timer'), Text( '${timer.inHours}:' - '${(timer.inMinutes % 60).toString().padLeft(2,'0')}:' - '${(timer.inSeconds % 60).toString().padLeft(2,'0')}', + '${(timer.inMinutes % 60).toString().padLeft(2, '0')}:' + '${(timer.inSeconds % 60).toString().padLeft(2, '0')}', style: const TextStyle(color: CupertinoColors.inactiveGray), ), ], @@ -185,15 +204,13 @@ class _CupertinoPickerDemoState extends State { }, ); }, - child: _buildMenu( - [ - const Text('Date'), - Text( - DateFormat.yMMMMd().format(date), - style: const TextStyle(color: CupertinoColors.inactiveGray), - ), - ] - ), + child: _buildMenu([ + const Text('Date'), + Text( + DateFormat.yMMMMd().format(date), + style: const TextStyle(color: CupertinoColors.inactiveGray), + ), + ]), ); } @@ -264,32 +281,28 @@ class _CupertinoPickerDemoState extends State { @override Widget build(BuildContext context) { return SizedBox( - height:MediaQuery.of(context).size.height, - child:CupertinoPageScaffold( + height: MediaQuery.of(context).size.height, + child: CupertinoPageScaffold( // navigationBar: CupertinoNavigationBar( // middle: const Text('Picker'), // previousPageTitle: 'Cupertino' // ), child: DefaultTextStyle( - style: TextStyle(), - child: DecoratedBox( - decoration: BoxDecoration( - color: CupertinoColors.inactiveGray - ), - child: ListView( - children: [ - const Padding(padding: EdgeInsets.only(top: 32.0)), - _buildColorPicker(context), - _buildCountdownTimerPicker(context), - _buildDatePicker(context), - _buildTimePicker(context), - _buildDateAndTimePicker(context), - ], + style: TextStyle(), + child: DecoratedBox( + decoration: BoxDecoration(color: CupertinoColors.inactiveGray), + child: ListView( + children: [ + const Padding(padding: EdgeInsets.only(top: 32.0)), + _buildColorPicker(context), + _buildCountdownTimerPicker(context), + _buildDatePicker(context), + _buildTimePicker(context), + _buildDateAndTimePicker(context), + ], + ), ), ), - ), - ) - ); - + )); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart b/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart index 40de0df9..6dbf3a0c 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart @@ -35,11 +35,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPickerDemo(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPicker', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html', codeUrl: 'themes/Cupertino/CupertinoPicker/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart index a878fec5..7175d3d7 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart @@ -21,19 +21,20 @@ class _CupertinoPopupSurfaceFullDefault extends State { @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/5, - child: cupertinoPopupSurfaceBar(context) - ); + height: MediaQuery.of(context).size.height / 5, + child: cupertinoPopupSurfaceBar(context)); } Widget cupertinoPopupSurfaceBar(BuildContext context) { return CupertinoPopupSurface( - isSurfacePainted:false, + isSurfacePainted: false, child: Container( color: CupertinoColors.inactiveGray, alignment: Alignment.center, - child: Text('这里是内容', style: TextStyle(color: Colors.white)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + child: Text('这里是内容', + style: TextStyle( + color: Colors + .white))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart index 87392b90..75ad5a97 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart @@ -4,7 +4,7 @@ /// Time: 下午10:57 /// email: zhu.yan@alibaba-inc.com /// target: CupertinoPopupSurface 的示例 - + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as demoBox; @@ -33,11 +33,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPopupSurfaceFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPopupSurface', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPopupSurface-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPopupSurface-class.html', codeUrl: 'themes/Cupertino/CupertinoPopupSurface/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart index 35abb32e..9e4dffc5 100644 --- a/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart @@ -22,7 +22,8 @@ class _Demo extends State { height: 300, child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -30,9 +31,7 @@ class _Demo extends State { child: Text('list item $index'), ); }, childCount: 10), - ) - ) - ), + ))), Center( child: Text("CupertinoScrollbar效果"), ) @@ -41,7 +40,6 @@ class _Demo extends State { } } - class NoCupertinoScrollbarDemo extends StatefulWidget { _NoCupertinoScrollbarDemo createState() => _NoCupertinoScrollbarDemo(); } @@ -55,7 +53,8 @@ class _NoCupertinoScrollbarDemo extends State { height: 300, child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: + SliverChildBuilderDelegate((BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -63,8 +62,7 @@ class _NoCupertinoScrollbarDemo extends State { child: Text('list item $index'), ); }, childCount: 10), - ) - ), + )), Center( child: Text("无CupertinoScrollbar效果"), ) diff --git a/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart b/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart index 93f14914..979e4cbe 100644 --- a/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart @@ -30,7 +30,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoScrollbar', codeUrl: 'themes/Cupertino/CupertinoScrollbar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/MaterialAccentColor-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/MaterialAccentColor-class.html', contentList: [ Text0, Text1, diff --git a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart index 20aeac97..768a45c1 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -10,10 +9,10 @@ class _Demo extends State { String value = 'a'; @override Widget build(BuildContext context) { - return CupertinoSegmentedControl( + return CupertinoSegmentedControl( onValueChanged: (v) { this.setState(() { - value = v; + value = v; }); }, pressedColor: Color(0xff7c1c25), @@ -22,15 +21,10 @@ class _Demo extends State { groupValue: value, children: { 'a': Container( - alignment: Alignment.center, - width: 130.0, - child: Text('a') - ), + alignment: Alignment.center, width: 130.0, child: Text('a')), 'c': Text('C'), 'b': Text('B'), }, ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart index 5063c7d2..f731c0e3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart @@ -20,7 +20,6 @@ const Text0 = ''' 样式支持用户自定义. '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoSegmentedControl'; @@ -35,7 +34,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSegmentedControl', codeUrl: '/hemes/Cupertino/CupertinoSegmentedControl/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html', contentList: [ Text0, CupertinoSegmentedControlDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart index 1ddded71..fe36bc93 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart @@ -16,19 +16,17 @@ class _Demo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return CupertinoSlider( - value: value,//实际进度的位置 + return CupertinoSlider( + value: value, //实际进度的位置 min: 0.0, max: 100.0, divisions: 100, - activeColor: Colors.blue,//进度中活动部分的颜色 - onChanged: (double){ + activeColor: Colors.blue, //进度中活动部分的颜色 + onChanged: (double) { setState(() { value = double.roundToDouble(); }); }, ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart b/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart index 8d993208..af0b7a10 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart @@ -15,8 +15,7 @@ CupertinoSlider 是ios风格的Slide组件,用来选择连续性的或者非连 '''; class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoSlider'; + static const String routeName = '/element/themes/Cupertino/CupertinoSlider'; @override State createState() => _DemoState(); @@ -28,7 +27,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSlider/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html', contentList: [ Text0, CupertinoSliderDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart index 5e272294..922334da 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart @@ -18,44 +18,46 @@ class _Demo extends State { Widget build(BuildContext context) { return CupertinoPageScaffold( child: DecoratedBox( - decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), - child: Container( - height: 600.0, - child: CustomScrollView( - slivers: [ - CupertinoSliverNavigationBar( - largeTitle: const Text('demo', maxLines: 1,), - previousPageTitle: 'Cupertino', - trailing: Icon(Icons.perm_camera_mic) - ), - CupertinoSliverRefreshControl( + decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), + child: Container( + height: 600.0, + child: CustomScrollView( + slivers: [ + CupertinoSliverNavigationBar( + largeTitle: const Text( + 'demo', + maxLines: 1, + ), + previousPageTitle: 'Cupertino', + trailing: Icon(Icons.perm_camera_mic)), + CupertinoSliverRefreshControl( // onRefresh: () { // // }, - ), - SliverSafeArea( - top: false, // Top safe area is consumed by the navigation bar. - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return _ListItem(name: 'name$index',place: 'place$index', date: 'date', called: true); - }, - childCount: 20, + ), + SliverSafeArea( + top: + false, // Top safe area is consumed by the navigation bar. + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return _ListItem( + name: 'name$index', + place: 'place$index', + date: 'date', + called: true); + }, + childCount: 20, + ), ), ), - ), - ], - ), - ) - ), + ], + ), + )), ); } - } - - - class _ListItem extends StatelessWidget { const _ListItem({ this.name, @@ -82,13 +84,13 @@ class _ListItem extends StatelessWidget { margin: EdgeInsets.only(top: 10), child: called ? const Align( - alignment: Alignment.topCenter, - child: Icon( - CupertinoIcons.phone_solid, - color: CupertinoColors.inactiveGray, - size: 28.0, - ), - ) + alignment: Alignment.topCenter, + child: Icon( + CupertinoIcons.phone_solid, + color: CupertinoColors.inactiveGray, + size: 28.0, + ), + ) : null, ), Expanded( @@ -98,7 +100,8 @@ class _ListItem extends StatelessWidget { bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), ), ), - padding: const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0), + padding: + const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0), child: Row( children: [ Expanded( @@ -138,10 +141,8 @@ class _ListItem extends StatelessWidget { ), const Padding( padding: EdgeInsets.only(left: 9.0), - child: Icon( - CupertinoIcons.info, - color: CupertinoColors.activeBlue - ), + child: Icon(CupertinoIcons.info, + color: CupertinoColors.activeBlue), ), ], ), diff --git a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart index 3cd0ffc8..1c012d6b 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart @@ -12,7 +12,6 @@ const Text0 = ''' > 该组件使用时. 必须做为含有slivers属性的滚动列表的子组件中,例如CustomScrollView '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoSliverNavigationBar'; @@ -27,7 +26,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSliverNavigationBar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSliverNavigationBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSliverNavigationBar-class.html', contentList: [ Text0, CupertinoSliverNavigationBarDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart index d677dd0a..a2b6c7aa 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart @@ -22,12 +22,18 @@ class _Demo extends State { trailing: CupertinoSwitch( activeColor: Colors.yellow, value: _lights, - onChanged: (bool value) { setState(() { _lights = value; }); }, + onChanged: (bool value) { + setState(() { + _lights = value; + }); + }, ), - onTap: () { setState(() { _lights = !_lights; }); }, + onTap: () { + setState(() { + _lights = !_lights; + }); + }, ), ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart b/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart index 94b9ac68..e8bd1447 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** > ios风格下的Switch组件, 用法与Switch组件相同 @@ -12,10 +13,8 @@ const Text0 = ''' > 基本用法与Switch基本相同. 不同点在于, 该组件仅支持自定义activeColor, 也就是支持自定义当按钮处于true状态下,按钮的背景色. '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoSwitch'; + static const String routeName = '/element/themes/Cupertino/CupertinoSwitch'; @override State createState() => _DemoState(); @@ -27,11 +26,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSwitch/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html', - contentList: [ - Text0, - CupertinoSwitchDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html', + contentList: [Text0, CupertinoSwitchDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart index c6794121..eaeedd0f 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart @@ -20,13 +20,15 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return Container( height: 500, child: Scaffold( appBar: AppBar(title: const Text('CupertinoTabBarDemo')), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, body: Center( child: Text('CupertinoTabBarDemo in bottom'), ), @@ -42,11 +44,9 @@ class _Demo extends State { icon: Icon(Icons.add), ), BottomNavigationBarItem( - title: Text("2"), - icon: Icon(Icons.delete) - )], - ) - ), + title: Text("2"), icon: Icon(Icons.delete)) + ], + )), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart index c2cd0106..4c99c8e3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** > ios风格下底部导航组件. @@ -20,10 +21,8 @@ const Text0 = ''' 本人试了很多次. 也没有发现这个Blur Effect是怎么触发的, 如果有人了解, 欢迎提PR. '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoTabBar'; + static const String routeName = '/element/themes/Cupertino/CupertinoTabBar'; @override State createState() => _DemoState(); @@ -35,11 +34,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabBar', codeUrl: 'themes/Cupertino/CupertinoTabBar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabBar-class.html', - contentList: [ - Text0, - CupertinoTabBarDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabBar-class.html', + contentList: [Text0, CupertinoTabBarDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart index fde03721..b1770173 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart @@ -20,13 +20,14 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return SizedBox( height: 500, child: CupertinoTabScaffold( tabBar: CupertinoTabBar( - items: [ + items: [ BottomNavigationBarItem( title: Text("1"), icon: Icon(Icons.add), @@ -58,7 +59,9 @@ class _Demo extends State { child: Center( child: CupertinoButton( child: const Text('Back'), - onPressed: () { Navigator.of(context).pop(); }, + onPressed: () { + Navigator.of(context).pop(); + }, ), ), ); @@ -75,4 +78,4 @@ class _Demo extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart index fe736adc..f9dcbc77 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** @@ -26,7 +27,6 @@ const Text0 = ''' '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoTabScaffold'; @@ -41,11 +41,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabScaffold', codeUrl: 'themes/Cupertino/CupertinoTabScaffold/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html', - contentList: [ - Text0, - CupertinoTabScaffoldDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html', + contentList: [Text0, CupertinoTabScaffoldDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart index a0b61b08..e73153e0 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart @@ -20,13 +20,14 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return SizedBox( height: 500, child: CupertinoTabScaffold( tabBar: CupertinoTabBar( - items: [ + items: [ BottomNavigationBarItem( title: Text("A"), icon: Icon(Icons.add), @@ -42,9 +43,9 @@ class _Demo extends State { routes: { '/': (context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tabView $index'), - ), + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tabView $index'), + ), child: Center( child: Text('CupertinoTabView /'), ), @@ -63,9 +64,9 @@ class _Demo extends State { }, builder: (BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tabView $index'), - ), + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tabView $index'), + ), child: Column( children: [ SizedBox(height: 100), @@ -78,16 +79,16 @@ class _Demo extends State { CupertinoButton( child: Text('Next page is home home page'), onPressed: () { - Navigator.of(context, rootNavigator: true).pushNamed('/home'); + Navigator.of(context, rootNavigator: true) + .pushNamed('/home'); }, ) ], - ) - ); + )); }, ); }, ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart index ad72bb6f..e10c7d9d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart @@ -30,10 +30,8 @@ Navigator.of(context, rootNavigator: true) '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoTabView'; + static const String routeName = '/element/themes/Cupertino/CupertinoTabView'; @override State createState() => _DemoState(); @@ -45,11 +43,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabView', codeUrl: 'themes/Cupertino/CupertinoTabView/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabView-class.html', - contentList: [ - Text0, - CupertinoTabScaffoldDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabView-class.html', + contentList: [Text0, CupertinoTabScaffoldDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart index fdd8d3f1..748aae0d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart @@ -8,8 +8,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - - class CupertinoTimerPickerDemo extends StatefulWidget { _Demo createState() => _Demo(); } @@ -39,6 +37,7 @@ class _Demo extends State { ), ); } + @override Widget build(BuildContext context) { return GestureDetector( diff --git a/lib/widgets/themes/Cupertino/index.dart b/lib/widgets/themes/Cupertino/index.dart index 2f8b8cbc..e9cd56aa 100644 --- a/lib/widgets/themes/Cupertino/index.dart +++ b/lib/widgets/themes/Cupertino/index.dart @@ -13,7 +13,8 @@ import './CupertinoPopupSurface/index.dart' as CupertinoPopupSurface; import './CupertinoScrollbar/index.dart' as CupertinoScrollbar; import './CupertinoSlider/index.dart' as CupertinoSlider; import './CupertinoSegmentedControl/index.dart' as CupertinoSegmentedControl; -import './CupertinoSliverNavigationBar/index.dart' as CupertinoSliverNavigationBar; +import './CupertinoSliverNavigationBar/index.dart' + as CupertinoSliverNavigationBar; import './CupertinoSwitch/index.dart' as CupertinoSwitch; import './CupertinoTabBar/index.dart' as CupertinoTabBar; import './CupertinoTabScaffold/index.dart' as CupertinoTabScaffold; @@ -117,4 +118,3 @@ List widgetPoints = [ buildRouter: (BuildContext context) => CupertinoTimerPicker.Demo(), ), ]; - diff --git a/lib/widgets/themes/Material/MaterialApp/demo.dart b/lib/widgets/themes/Material/MaterialApp/demo.dart index b06a5f78..61333cb0 100644 --- a/lib/widgets/themes/Material/MaterialApp/demo.dart +++ b/lib/widgets/themes/Material/MaterialApp/demo.dart @@ -1,8 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 - +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 // !!! 代码示例,并非Demo // import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialApp/index.dart b/lib/widgets/themes/Material/MaterialApp/index.dart index 0285bc1d..a3a2af72 100644 --- a/lib/widgets/themes/Material/MaterialApp/index.dart +++ b/lib/widgets/themes/Material/MaterialApp/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:52:45 diff --git a/lib/widgets/themes/Material/MaterialButton/demo.dart b/lib/widgets/themes/Material/MaterialButton/demo.dart index baa68e36..3cbfb5f7 100644 --- a/lib/widgets/themes/Material/MaterialButton/demo.dart +++ b/lib/widgets/themes/Material/MaterialButton/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialButton/index.dart b/lib/widgets/themes/Material/MaterialButton/index.dart index 3fb955b3..d0f86620 100644 --- a/lib/widgets/themes/Material/MaterialButton/index.dart +++ b/lib/widgets/themes/Material/MaterialButton/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:35:39 diff --git a/lib/widgets/themes/Material/MaterialColor/demo.dart b/lib/widgets/themes/Material/MaterialColor/demo.dart index ff466379..b9664f2e 100644 --- a/lib/widgets/themes/Material/MaterialColor/demo.dart +++ b/lib/widgets/themes/Material/MaterialColor/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialColor/index.dart b/lib/widgets/themes/Material/MaterialColor/index.dart index 79117f93..a6f056d8 100644 --- a/lib/widgets/themes/Material/MaterialColor/index.dart +++ b/lib/widgets/themes/Material/MaterialColor/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:35:39 diff --git a/lib/widgets/themes/Material/MaterialPageRoute/demo.dart b/lib/widgets/themes/Material/MaterialPageRoute/demo.dart index 726dd428..ba120f31 100644 --- a/lib/widgets/themes/Material/MaterialPageRoute/demo.dart +++ b/lib/widgets/themes/Material/MaterialPageRoute/demo.dart @@ -14,18 +14,18 @@ class FirstPage extends StatefulWidget { } class _FirstPageState extends State { - var _usernameController = TextEditingController(); - var _emailController = TextEditingController(); + var _usernameController = TextEditingController(); + var _emailController = TextEditingController(); @override Widget build(BuildContext context) { return Column( children: [ Padding( - child: Text( + child: Text( "账号登录", textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), padding: EdgeInsets.only(bottom: 10.0), ), @@ -37,11 +37,11 @@ class _FirstPageState extends State { decoration: InputDecoration(labelText: "email"), controller: _emailController, ), - RaisedButton( + RaisedButton( child: Text("点击跳转"), onPressed: () { - var route = MaterialPageRoute( - builder: (BuildContext context) => SecondPage( + var route = MaterialPageRoute( + builder: (BuildContext context) => SecondPage( value: User( account: _usernameController.text, email: _emailController.text)), @@ -65,21 +65,21 @@ class SecondPage extends StatefulWidget { class _SecondPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( + return Scaffold( + appBar: AppBar( title: Text("MaterialPageRoute2"), ), - body: Container( - child: Center( + body: Container( + child: Center( child: Column( children: [ Container( padding: EdgeInsets.only(top: 30.0), - child: Text("登陆成功!!!", + child: Text("登陆成功!!!", style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold))), Padding( - child: Text( + child: Text( 'account:${widget.value.account}', textAlign: TextAlign.center, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), @@ -87,7 +87,7 @@ class _SecondPageState extends State { padding: EdgeInsets.only(bottom: 20.0, top: 40.0), ), Padding( - child: Text( + child: Text( 'email:${widget.value.email}', textAlign: TextAlign.center, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), diff --git a/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart b/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart index e5d0b3aa..185485e4 100644 --- a/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart +++ b/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 11:33:21 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:24:14 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 11:33:21 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:24:14 import 'package:flutter/material.dart'; @@ -28,17 +27,17 @@ class _MergeableMaterialItemState extends State { items.add( //class MaterialSlice extends MergeableMaterialItem - MaterialSlice( - key: ValueKey(currIndexNum), - child: Column(children: [ + MaterialSlice( + key: ValueKey(currIndexNum), + child: Column(children: [ // header, - AnimatedCrossFade( - firstChild: Container( + AnimatedCrossFade( + firstChild: Container( height: 20.0, width: 20.0, color: Colors.green, ), - secondChild: Container( + secondChild: Container( height: 20.0, width: 20.0, color: Colors.red, @@ -57,8 +56,8 @@ class _MergeableMaterialItemState extends State { return Column( children: [ - MergeableMaterial(hasDividers: true, children: items), - RaisedButton( + MergeableMaterial(hasDividers: true, children: items), + RaisedButton( child: Text("点击添加"), onPressed: () { _isChildExpanded(); diff --git a/lib/widgets/themes/Material/MergeableMaterialItem/index.dart b/lib/widgets/themes/Material/MergeableMaterialItem/index.dart index fafc2240..5e4a8a6e 100644 --- a/lib/widgets/themes/Material/MergeableMaterialItem/index.dart +++ b/lib/widgets/themes/Material/MergeableMaterialItem/index.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-07 16:36:43 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 14:12:32 +/// Author: xiaojia.dxj +/// Date: 2019-01-07 16:36:43 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 14:12:32 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/index.dart b/lib/widgets/themes/Material/index.dart index 2ef1f607..b405e045 100644 --- a/lib/widgets/themes/Material/index.dart +++ b/lib/widgets/themes/Material/index.dart @@ -8,7 +8,6 @@ import 'MaterialButton/index.dart' as MaterialButton; import 'MaterialColor/index.dart' as MaterialColor; import 'MergeableMaterialItem/index.dart' as MergeableMaterialItem; - List widgetPoints = [ WidgetPoint( name: 'MaterialPageRoute', @@ -30,8 +29,7 @@ List widgetPoints = [ routerName: MaterialButton.Demo.routeName, buildRouter: (BuildContext context) => MaterialButton.Demo(), ), - -WidgetPoint( + WidgetPoint( name: 'MaterialAccentColor', routerName: MaterialAccentColor.Demo.routeName, buildRouter: (BuildContext context) => MaterialAccentColor.Demo(), @@ -41,5 +39,4 @@ WidgetPoint( routerName: MergeableMaterialItem.Demo.routeName, buildRouter: (BuildContext context) => MergeableMaterialItem.Demo(), ), - ]; diff --git a/lib/widgets/themes/index.dart b/lib/widgets/themes/index.dart index b263753b..350b683c 100644 --- a/lib/widgets/themes/index.dart +++ b/lib/widgets/themes/index.dart @@ -1,7 +1,7 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-24 16:31:09 +/// @Date: 2018-12-24 16:31:09 /// @Last Modified by: xiaojia.dxj -/// @Last Modified time: 2018-12-24 16:31:09 +/// @Last Modified time: 2018-12-24 16:31:09 import './Material/index.dart' as Material; import './Cupertino/index.dart' as Cupertino; @@ -11,4 +11,4 @@ List getWidgets() { result.addAll(Material.widgetPoints); result.addAll(Cupertino.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/mupp_build_env_init.sh b/mupp_build_env_init.sh new file mode 100644 index 00000000..5057c3ee --- /dev/null +++ b/mupp_build_env_init.sh @@ -0,0 +1,17 @@ +#! /bin/bash +print 'entitlement config' +cd ios +ruby entitlement_config.rb +cd .. +#屏蔽Build Shell +sed -i "" "s/\/bin\/sh \\\\\"\\\$FLUTTER_ROOT/#\/bin\/sh \\\\\"\\\$FLUTTER_ROOT/" ./ios/Runner.xcodeproj/project.pbxproj +#拷贝已生成好的Dart代码中间产物 +mtl_dir="ios/Flutter_MTL/Flutter" +flutter_dir="ios/Flutter" +[ -d ${flutter_dir} ] || mkdir ${flutter_dir} +rm -rf ${flutter_dir}/* +cp -r ${mtl_dir}/ ${flutter_dir}/ +sizeStr=`wc -c ${flutter_dir}/Flutter.framework/Flutter` +lipoStr=`lipo -info ${flutter_dir}/Flutter.framework/Flutter` +echo "[KWLM]Flutter.framework size:${sizeStr}${lipoStr}" +cat ./ios/Runner.xcodeproj/project.pbxproj diff --git a/pubspec.yaml b/pubspec.yaml index 6401c44a..862e0453 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,8 +51,8 @@ dependencies: open_file: ^2.0.1+2 package_info: ^0.4.0+3 flutter_jpush: ^0.0.4 - zefyr: - path: ./zefyr + zefyr: ^0.8.0 + pull_to_refresh: ^1.5.6 dev_dependencies: diff --git a/zefyr/.gitignore b/zefyr/.gitignore deleted file mode 100644 index 9f87252c..00000000 --- a/zefyr/.gitignore +++ /dev/null @@ -1,72 +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/ -.dart_tool/ -.flutter-plugins -.packages -.pub-cache/ -.pub/ -build/ - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/zefyr/CHANGELOG.md b/zefyr/CHANGELOG.md deleted file mode 100644 index ac071598..00000000 --- a/zefyr/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## [0.0.1] - TODO: Add release date. - -* TODO: Describe initial release. diff --git a/zefyr/LICENSE b/zefyr/LICENSE deleted file mode 100644 index ba75c69f..00000000 --- a/zefyr/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/zefyr/README.md b/zefyr/README.md deleted file mode 100644 index cc0c4567..00000000 --- a/zefyr/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# zefyr - -A new Flutter package project. - -## Getting Started - -This project is a starting point for a Dart -[package](https://flutter.dev/developing-packages/), -a library module containing code that can be shared easily across -multiple Flutter or Dart projects. - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/zefyr/lib/src/fast_diff.dart b/zefyr/lib/src/fast_diff.dart deleted file mode 100644 index ade850b6..00000000 --- a/zefyr/lib/src/fast_diff.dart +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:math' as math; - -/// Performs a fast diff operation on two input strings based on provided -/// [cursorPosition]. -DiffResult fastDiff(String oldText, String newText, int cursorPosition) { - var delta = newText.length - oldText.length; - var limit = math.max(0, cursorPosition - delta); - var end = oldText.length; - while (end > limit && oldText[end - 1] == newText[end + delta - 1]) { - end -= 1; - } - var start = 0; - var startLimit = cursorPosition - math.max(0, delta); - while (start < startLimit && oldText[start] == newText[start]) { - start += 1; - } - final String deleted = (start < end) ? oldText.substring(start, end) : ''; - final inserted = newText.substring(start, end + delta); - return new DiffResult(start, deleted, inserted); -} - -/// A diff between two strings of text. -class DiffResult { - /// Start index in old text at which changes begin. - final int start; - - /// Deleted text in old text. - final String deleted; - - /// Inserted text. - final String inserted; - - DiffResult(this.start, this.deleted, this.inserted); - - @override - String toString() => 'DiffResult[$start, "$deleted", "$inserted"]'; -} diff --git a/zefyr/lib/src/widgets/buttons.dart b/zefyr/lib/src/widgets/buttons.dart deleted file mode 100644 index 675f4ea3..00000000 --- a/zefyr/lib/src/widgets/buttons.dart +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:notus/notus.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import 'scope.dart'; -import 'theme.dart'; -import 'toolbar.dart'; - -/// A button used in [ZefyrToolbar]. -/// -/// Create an instance of this widget with [ZefyrButton.icon] or -/// [ZefyrButton.text] constructors. -/// -/// Toolbar buttons are normally created by a [ZefyrToolbarDelegate]. -class ZefyrButton extends StatelessWidget { - /// Creates a toolbar button with an icon. - ZefyrButton.icon({ - @required this.action, - @required IconData icon, - double iconSize, - this.onPressed, - }) : assert(action != null), - assert(icon != null), - _icon = icon, - _iconSize = iconSize, - _text = null, - _textStyle = null, - super(); - - /// Creates a toolbar button containing text. - /// - /// Note that [ZefyrButton] has fixed width and does not expand to accommodate - /// long texts. - ZefyrButton.text({ - @required this.action, - @required String text, - TextStyle style, - this.onPressed, - }) : assert(action != null), - assert(text != null), - _icon = null, - _iconSize = null, - _text = text, - _textStyle = style, - super(); - - /// Toolbar action associated with this button. - final ZefyrToolbarAction action; - final IconData _icon; - final double _iconSize; - final String _text; - final TextStyle _textStyle; - - /// Callback to trigger when this button is tapped. - final VoidCallback onPressed; - - bool get isAttributeAction { - return kZefyrToolbarAttributeActions.keys.contains(action); - } - - @override - Widget build(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - final editor = toolbar.editor; - final toolbarTheme = ZefyrTheme.of(context).toolbarTheme; - final pressedHandler = _getPressedHandler(editor, toolbar); - final iconColor = (pressedHandler == null) - ? toolbarTheme.disabledIconColor - : toolbarTheme.iconColor; - if (_icon != null) { - return RawZefyrButton.icon( - action: action, - icon: _icon, - size: _iconSize, - iconColor: iconColor, - color: _getColor(editor, toolbarTheme), - onPressed: _getPressedHandler(editor, toolbar), - ); - } else { - assert(_text != null); - var style = _textStyle ?? new TextStyle(); - style = style.copyWith(color: iconColor); - return RawZefyrButton( - action: action, - child: new Text(_text, style: style), - color: _getColor(editor, toolbarTheme), - onPressed: _getPressedHandler(editor, toolbar), - ); - } - } - - Color _getColor(ZefyrScope editor, ZefyrToolbarTheme theme) { - if (isAttributeAction) { - final attribute = kZefyrToolbarAttributeActions[action]; - final isToggled = (attribute is NotusAttribute) - ? editor.selectionStyle.containsSame(attribute) - : editor.selectionStyle.contains(attribute); - return isToggled ? theme.toggleColor : null; - } - return null; - } - - VoidCallback _getPressedHandler( - ZefyrScope editor, ZefyrToolbarState toolbar) { - if (onPressed != null) { - return onPressed; - } else if (isAttributeAction) { - final attribute = kZefyrToolbarAttributeActions[action]; - if (attribute is NotusAttribute) { - return () => _toggleAttribute(attribute, editor); - } - } else if (action == ZefyrToolbarAction.close) { - return () => toolbar.closeOverlay(); - } else if (action == ZefyrToolbarAction.hideKeyboard) { - return () => editor.hideKeyboard(); - } - - return null; - } - - void _toggleAttribute(NotusAttribute attribute, ZefyrScope editor) { - final isToggled = editor.selectionStyle.containsSame(attribute); - if (isToggled) { - editor.formatSelection(attribute.unset); - } else { - editor.formatSelection(attribute); - } - } -} - -/// Raw button widget used by [ZefyrToolbar]. -/// -/// See also: -/// -/// * [ZefyrButton], which wraps this widget and implements most of the -/// action-specific logic. -class RawZefyrButton extends StatelessWidget { - const RawZefyrButton({ - Key key, - @required this.action, - @required this.child, - @required this.color, - @required this.onPressed, - }) : super(key: key); - - /// Creates a [RawZefyrButton] containing an icon. - RawZefyrButton.icon({ - @required this.action, - @required IconData icon, - double size, - Color iconColor, - @required this.color, - @required this.onPressed, - }) : child = new Icon(icon, size: size, color: iconColor), - super(); - - /// Toolbar action associated with this button. - final ZefyrToolbarAction action; - - /// Child widget to show inside this button. Usually an icon. - final Widget child; - - /// Background color of this button. - final Color color; - - /// Callback to trigger when this button is pressed. - final VoidCallback onPressed; - - /// Returns `true` if this button is currently toggled on. - bool get isToggled => color != null; - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final width = theme.buttonTheme.constraints.minHeight + 4.0; - final constraints = theme.buttonTheme.constraints.copyWith( - minWidth: width, maxHeight: theme.buttonTheme.constraints.minHeight); - final radius = BorderRadius.all(Radius.circular(3.0)); - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 1.0, vertical: 6.0), - child: RawMaterialButton( - shape: RoundedRectangleBorder(borderRadius: radius), - elevation: 0.0, - fillColor: color, - constraints: constraints, - onPressed: onPressed, - child: child, - ), - ); - } -} - -/// Controls heading styles. -/// -/// When pressed, this button displays overlay toolbar with three -/// buttons for each heading level. -class HeadingButton extends StatefulWidget { - const HeadingButton({Key key}) : super(key: key); - - @override - _HeadingButtonState createState() => _HeadingButtonState(); -} - -class _HeadingButtonState extends State { - @override - Widget build(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - return toolbar.buildButton( - context, - ZefyrToolbarAction.heading, - onPressed: showOverlay, - ); - } - - void showOverlay() { - final toolbar = ZefyrToolbar.of(context); - toolbar.showOverlay(buildOverlay); - } - - Widget buildOverlay(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - final buttons = Row( - children: [ - SizedBox(width: 8.0), - toolbar.buildButton(context, ZefyrToolbarAction.headingLevel1), - toolbar.buildButton(context, ZefyrToolbarAction.headingLevel2), - toolbar.buildButton(context, ZefyrToolbarAction.headingLevel3), - ], - ); - return ZefyrToolbarScaffold(body: buttons); - } -} - -/// Controls image attribute. -/// -/// When pressed, this button displays overlay toolbar with three -/// buttons for each heading level. -class ImageButton extends StatefulWidget { - const ImageButton({Key key}) : super(key: key); - - @override - _ImageButtonState createState() => _ImageButtonState(); -} - -class _ImageButtonState extends State { - @override - Widget build(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - return toolbar.buildButton( - context, - ZefyrToolbarAction.image, - onPressed: showOverlay, - ); - } - - void showOverlay() { - final toolbar = ZefyrToolbar.of(context); - toolbar.showOverlay(buildOverlay); - } - - Widget buildOverlay(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - final buttons = Row( - children: [ - SizedBox(width: 8.0), - toolbar.buildButton(context, ZefyrToolbarAction.cameraImage, - onPressed: _pickFromCamera), - toolbar.buildButton(context, ZefyrToolbarAction.galleryImage, - onPressed: _pickFromGallery), - ], - ); - return ZefyrToolbarScaffold(body: buttons); - } - - void _pickFromCamera() async { - final editor = ZefyrToolbar.of(context).editor; - final image = await editor.imageDelegate.pickImage(ImageSource.camera); - if (image != null) - editor.formatSelection(NotusAttribute.embed.image(image)); - } - - void _pickFromGallery() async { - final editor = ZefyrToolbar.of(context).editor; - final image = await editor.imageDelegate.pickImage(ImageSource.gallery); - if (image != null) - editor.formatSelection(NotusAttribute.embed.image(image)); - } -} - -class LinkButton extends StatefulWidget { - const LinkButton({Key key}) : super(key: key); - - @override - _LinkButtonState createState() => _LinkButtonState(); -} - -class _LinkButtonState extends State { - final TextEditingController _inputController = TextEditingController(); - Key _inputKey; - bool _formatError = false; - ZefyrScope _editor; - - bool get isEditing => _inputKey != null; - - @override - Widget build(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - final editor = toolbar.editor; - final enabled = - hasLink(editor.selectionStyle) || !editor.selection.isCollapsed; - - return toolbar.buildButton( - context, - ZefyrToolbarAction.link, - onPressed: enabled ? showOverlay : null, - ); - } - - bool hasLink(NotusStyle style) => style.contains(NotusAttribute.link); - - String getLink([String defaultValue]) { - final editor = ZefyrToolbar.of(context).editor; - final attrs = editor.selectionStyle; - if (hasLink(attrs)) { - return attrs.value(NotusAttribute.link); - } - return defaultValue; - } - - void showOverlay() { - final toolbar = ZefyrToolbar.of(context); - toolbar.showOverlay(buildOverlay).whenComplete(cancelEdit); - } - - void closeOverlay() { - final toolbar = ZefyrToolbar.of(context); - toolbar.closeOverlay(); - } - - void edit() { - final toolbar = ZefyrToolbar.of(context); - setState(() { - _inputKey = new UniqueKey(); - _inputController.text = getLink('https://'); - _inputController.addListener(_handleInputChange); - toolbar.markNeedsRebuild(); - }); - } - - void doneEdit() { - final toolbar = ZefyrToolbar.of(context); - setState(() { - var error = false; - if (_inputController.text.isNotEmpty) { - try { - var uri = Uri.parse(_inputController.text); - if ((uri.isScheme('https') || uri.isScheme('http')) && - uri.host.isNotEmpty) { - toolbar.editor.formatSelection( - NotusAttribute.link.fromString(_inputController.text)); - } else { - error = true; - } - } on FormatException { - error = true; - } - } - if (error) { - _formatError = error; - toolbar.markNeedsRebuild(); - } else { - _inputKey = null; - _inputController.text = ''; - _inputController.removeListener(_handleInputChange); - toolbar.markNeedsRebuild(); - toolbar.editor.focus(); - } - }); - } - - void cancelEdit() { - if (mounted) { - final editor = ZefyrToolbar.of(context).editor; - setState(() { - _inputKey = null; - _inputController.text = ''; - _inputController.removeListener(_handleInputChange); - editor.focus(); - }); - } - } - - void unlink() { - final editor = ZefyrToolbar.of(context).editor; - editor.formatSelection(NotusAttribute.link.unset); - closeOverlay(); - } - - void copyToClipboard() { - var link = getLink(); - assert(link != null); - Clipboard.setData(new ClipboardData(text: link)); - } - - void openInBrowser() async { - final editor = ZefyrToolbar.of(context).editor; - var link = getLink(); - assert(link != null); - if (await canLaunch(link)) { - editor.hideKeyboard(); - await launch(link, forceWebView: true); - } - } - - void _handleInputChange() { - final toolbar = ZefyrToolbar.of(context); - setState(() { - _formatError = false; - toolbar.markNeedsRebuild(); - }); - } - - Widget buildOverlay(BuildContext context) { - final toolbar = ZefyrToolbar.of(context); - final style = toolbar.editor.selectionStyle; - - String value = 'Tap to edit link'; - if (style.contains(NotusAttribute.link)) { - value = style.value(NotusAttribute.link); - } - final clipboardEnabled = value != 'Tap to edit link'; - final body = !isEditing - ? _LinkView(value: value, onTap: edit) - : _LinkInput( - key: _inputKey, - controller: _inputController, - formatError: _formatError, - ); - final items = [Expanded(child: body)]; - if (!isEditing) { - final unlinkHandler = hasLink(style) ? unlink : null; - final copyHandler = clipboardEnabled ? copyToClipboard : null; - final openHandler = hasLink(style) ? openInBrowser : null; - final buttons = [ - toolbar.buildButton(context, ZefyrToolbarAction.unlink, - onPressed: unlinkHandler), - toolbar.buildButton(context, ZefyrToolbarAction.clipboardCopy, - onPressed: copyHandler), - toolbar.buildButton( - context, - ZefyrToolbarAction.openInBrowser, - onPressed: openHandler, - ), - ]; - items.addAll(buttons); - } - final trailingPressed = isEditing ? doneEdit : closeOverlay; - final trailingAction = - isEditing ? ZefyrToolbarAction.confirm : ZefyrToolbarAction.close; - - return ZefyrToolbarScaffold( - body: Row(children: items), - trailing: toolbar.buildButton( - context, - trailingAction, - onPressed: trailingPressed, - ), - ); - } -} - -class _LinkInput extends StatefulWidget { - final TextEditingController controller; - final bool formatError; - - const _LinkInput( - {Key key, @required this.controller, this.formatError: false}) - : super(key: key); - - @override - _LinkInputState createState() { - return new _LinkInputState(); - } -} - -class _LinkInputState extends State<_LinkInput> { - final FocusNode _focusNode = FocusNode(); - - ZefyrScope _editor; - bool _didAutoFocus = false; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (!_didAutoFocus) { - FocusScope.of(context).requestFocus(_focusNode); - _didAutoFocus = true; - } - - final toolbar = ZefyrToolbar.of(context); - - if (_editor != toolbar.editor) { - _editor?.toolbarFocusNode = null; - _editor = toolbar.editor; - _editor.toolbarFocusNode = _focusNode; - } - } - - @override - void dispose() { - _editor?.toolbarFocusNode = null; - _focusNode.dispose(); - _editor = null; - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final toolbarTheme = ZefyrTheme.of(context).toolbarTheme; - final color = - widget.formatError ? Colors.redAccent : toolbarTheme.iconColor; - final style = theme.textTheme.subhead.copyWith(color: color); - return TextField( - style: style, - keyboardType: TextInputType.url, - focusNode: _focusNode, - controller: widget.controller, - autofocus: true, - decoration: new InputDecoration( - hintText: 'https://', - filled: true, - fillColor: toolbarTheme.color, - border: InputBorder.none, - contentPadding: const EdgeInsets.all(10.0), - ), - ); - } -} - -class _LinkView extends StatelessWidget { - const _LinkView({Key key, @required this.value, this.onTap}) - : super(key: key); - final String value; - final VoidCallback onTap; - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final toolbarTheme = ZefyrTheme.of(context).toolbarTheme; - Widget widget = new ClipRect( - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - alignment: AlignmentDirectional.centerStart, - constraints: BoxConstraints(minHeight: ZefyrToolbar.kToolbarHeight), - padding: const EdgeInsets.all(10.0), - child: Text( - value, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: theme.textTheme.subhead - .copyWith(color: toolbarTheme.disabledIconColor), - ), - ) - ], - ), - ); - if (onTap != null) { - widget = GestureDetector( - child: widget, - onTap: onTap, - ); - } - return widget; - } -} diff --git a/zefyr/lib/src/widgets/caret.dart b/zefyr/lib/src/widgets/caret.dart deleted file mode 100644 index 895cd3b4..00000000 --- a/zefyr/lib/src/widgets/caret.dart +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:ui'; - -import 'package:flutter/material.dart'; - -/// Helper class responsible for cursor layout and painting. -class CursorPainter { - static const double _kCaretHeightOffset = 2.0; // pixels - static const double _kCaretWidth = 1.0; // pixels - - static Rect buildPrototype(double lineHeight) { - return new Rect.fromLTWH( - 0.0, 0.0, _kCaretWidth, lineHeight - _kCaretHeightOffset); - } - - CursorPainter(Color color) - : assert(color != null), - _color = color; - - Rect _prototype; - - Rect get prototype => _prototype; - - Color _color; - Color get color => _color; - set color(Color value) { - assert(value != null); - _color = value; - } - - void layout(double lineHeight) { - _prototype = buildPrototype(lineHeight); - } - - void paint(Canvas canvas, Offset offset) { - final Paint paint = new Paint()..color = _color; - final Rect caretRect = _prototype.shift(offset); - canvas.drawRect(caretRect, paint); - } -} diff --git a/zefyr/lib/src/widgets/code.dart b/zefyr/lib/src/widgets/code.dart deleted file mode 100644 index 1c5c6050..00000000 --- a/zefyr/lib/src/widgets/code.dart +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'common.dart'; -import 'theme.dart'; - -/// Represents a code snippet in Zefyr editor. -class ZefyrCode extends StatelessWidget { - const ZefyrCode({Key key, @required this.node}) : super(key: key); - - /// Document node represented by this widget. - final BlockNode node; - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context); - - List items = []; - for (var line in node.children) { - items.add(_buildLine(line, theme.blockTheme.code.textStyle)); - } - - return new Padding( - padding: theme.blockTheme.code.padding, - child: new Container( - // TODO: make decorations configurable - decoration: BoxDecoration( - color: Colors.blueGrey.shade50, - borderRadius: BorderRadius.circular(3.0), - ), - padding: const EdgeInsets.all(16.0), - child: new Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: items, - ), - ), - ); - } - - Widget _buildLine(Node node, TextStyle style) { - LineNode line = node; - return new RawZefyrLine(node: line, style: style); - } -} diff --git a/zefyr/lib/src/widgets/common.dart b/zefyr/lib/src/widgets/common.dart deleted file mode 100644 index aabc8b8f..00000000 --- a/zefyr/lib/src/widgets/common.dart +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; - -import 'editable_box.dart'; -import 'horizontal_rule.dart'; -import 'image.dart'; -import 'rich_text.dart'; -import 'scope.dart'; -import 'theme.dart'; - -/// Raw widget representing a single line of rich text document in Zefyr editor. -/// -/// See [ZefyrParagraph] and [ZefyrHeading] which wrap this widget and -/// integrate it with current [ZefyrTheme]. -class RawZefyrLine extends StatefulWidget { - const RawZefyrLine({ - Key key, - @required this.node, - this.style, - this.padding, - }) : super(key: key); - - /// Line in the document represented by this widget. - final LineNode node; - - /// Style to apply to this line. Required for lines with text contents, - /// ignored for lines containing embeds. - final TextStyle style; - - /// Padding to add around this paragraph. - final EdgeInsets padding; - - @override - _RawZefyrLineState createState() => new _RawZefyrLineState(); -} - -class _RawZefyrLineState extends State { - final LayerLink _link = new LayerLink(); - - @override - Widget build(BuildContext context) { - final scope = ZefyrScope.of(context); - if (scope.isEditable) { - ensureVisible(context, scope); - } - final theme = ZefyrTheme.of(context); - - Widget content; - if (widget.node.hasEmbed) { - content = buildEmbed(context, scope); - } else { - assert(widget.style != null); - content = ZefyrRichText( - node: widget.node, - text: buildText(context), - ); - } - - if (scope.isEditable) { - content = EditableBox( - child: content, - node: widget.node, - layerLink: _link, - renderContext: scope.renderContext, - showCursor: scope.showCursor, - selection: scope.selection, - selectionColor: theme.selectionColor, - cursorColor: theme.cursorColor, - ); - content = CompositedTransformTarget(link: _link, child: content); - } - - if (widget.padding != null) { - return Padding(padding: widget.padding, child: content); - } - return content; - } - - void ensureVisible(BuildContext context, ZefyrScope scope) { - if (scope.selection.isCollapsed && - widget.node.containsOffset(scope.selection.extentOffset)) { - WidgetsBinding.instance.addPostFrameCallback((_) { - bringIntoView(context); - }); - } - } - - void bringIntoView(BuildContext context) { - ScrollableState scrollable = Scrollable.of(context); - final object = context.findRenderObject(); - assert(object.attached); - final RenderAbstractViewport viewport = RenderAbstractViewport.of(object); - assert(viewport != null); - - final double offset = scrollable.position.pixels; - double target = viewport.getOffsetToReveal(object, 0.0).offset; - if (target - offset < 0.0) { - scrollable.position.jumpTo(target); - return; - } - target = viewport.getOffsetToReveal(object, 1.0).offset; - if (target - offset > 0.0) { - scrollable.position.jumpTo(target); - } - } - - TextSpan buildText(BuildContext context) { - final theme = ZefyrTheme.of(context); - final List children = widget.node.children - .map((node) => _segmentToTextSpan(node, theme)) - .toList(growable: false); - return new TextSpan(style: widget.style, children: children); - } - - TextSpan _segmentToTextSpan(Node node, ZefyrThemeData theme) { - final TextNode segment = node; - final attrs = segment.style; - - return new TextSpan( - text: segment.value, - style: _getTextStyle(attrs, theme), - ); - } - - TextStyle _getTextStyle(NotusStyle style, ZefyrThemeData theme) { - TextStyle result = new TextStyle(); - if (style.containsSame(NotusAttribute.bold)) { - result = result.merge(theme.boldStyle); - } - if (style.containsSame(NotusAttribute.italic)) { - result = result.merge(theme.italicStyle); - } - if (style.contains(NotusAttribute.link)) { - result = result.merge(theme.linkStyle); - } - return result; - } - - Widget buildEmbed(BuildContext context, ZefyrScope scope) { - EmbedNode node = widget.node.children.single; - EmbedAttribute embed = node.style.get(NotusAttribute.embed); - - if (embed.type == EmbedType.horizontalRule) { - return ZefyrHorizontalRule(node: node); - } else if (embed.type == EmbedType.image) { - return ZefyrImage(node: node, delegate: scope.imageDelegate); - } else { - throw new UnimplementedError('Unimplemented embed type ${embed.type}'); - } - } -} diff --git a/zefyr/lib/src/widgets/controller.dart b/zefyr/lib/src/widgets/controller.dart deleted file mode 100644 index 325769d3..00000000 --- a/zefyr/lib/src/widgets/controller.dart +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:math' as math; - -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; -import 'package:quill_delta/quill_delta.dart'; -import 'package:zefyr/util.dart'; - -const TextSelection _kZeroSelection = const TextSelection.collapsed( - offset: 0, - affinity: TextAffinity.upstream, -); - -/// Owner of focus. -enum FocusOwner { - /// Current owner is the editor. - editor, - - /// Current owner is the toolbar. - toolbar, - - /// No focus owner. - none, -} - -/// Controls instance of [ZefyrEditor]. -class ZefyrController extends ChangeNotifier { - ZefyrController(NotusDocument document) - : assert(document != null), - _document = document; - - /// Zefyr document managed by this controller. - NotusDocument get document => _document; - NotusDocument _document; - - /// Currently selected text within the [document]. - TextSelection get selection => _selection; - TextSelection _selection = _kZeroSelection; - - ChangeSource _lastChangeSource; - - /// Source of the last text or selection change. - ChangeSource get lastChangeSource => _lastChangeSource; - - /// Updates selection with specified [value]. - /// - /// [value] and [source] cannot be `null`. - void updateSelection(TextSelection value, - {ChangeSource source: ChangeSource.remote}) { - _updateSelectionSilent(value, source: source); - notifyListeners(); - } - - // Updates selection without triggering notifications to listeners. - void _updateSelectionSilent(TextSelection value, - {ChangeSource source: ChangeSource.remote}) { - assert(value != null && source != null); - _selection = value; - _lastChangeSource = source; - _ensureSelectionBeforeLastBreak(); - } - - @override - void dispose() { - _document.close(); - super.dispose(); - } - - /// Composes [change] into document managed by this controller. - /// - /// This method does not apply any adjustments or heuristic rules to - /// provided [change] and it is caller's responsibility to ensure this change - /// can be composed without errors. - /// - /// If composing this change fails then this method throws [ComposeError]. - void compose(Delta change, - {TextSelection selection, ChangeSource source: ChangeSource.remote}) { - if (change.isNotEmpty) { - _document.compose(change, source); - } - if (selection != null) { - _updateSelectionSilent(selection, source: source); - } else { - // Transform selection against the composed change and give priority to - // current position (force: false). - final base = - change.transformPosition(_selection.baseOffset, force: false); - final extent = - change.transformPosition(_selection.extentOffset, force: false); - selection = _selection.copyWith(baseOffset: base, extentOffset: extent); - if (_selection != selection) { - _updateSelectionSilent(selection, source: source); - } - } - _lastChangeSource = source; - notifyListeners(); - } - - void replaceText(int index, int length, String text, - {TextSelection selection}) { - Delta delta; - - if (length > 0 || text.isNotEmpty) { - delta = document.replace(index, length, text); - } - - if (selection != null) { - if (delta == null) { - _updateSelectionSilent(selection, source: ChangeSource.local); - } else { - // need to transform selection position in case actual delta - // is different from user's version (in deletes and inserts). - Delta user = new Delta() - ..retain(index) - ..insert(text) - ..delete(length); - int positionDelta = getPositionDelta(user, delta); - _updateSelectionSilent( - selection.copyWith( - baseOffset: selection.baseOffset + positionDelta, - extentOffset: selection.extentOffset + positionDelta, - ), - source: ChangeSource.local, - ); - } - } - _lastChangeSource = ChangeSource.local; - notifyListeners(); - } - - void formatText(int index, int length, NotusAttribute attribute) { - final change = document.format(index, length, attribute); - _lastChangeSource = ChangeSource.local; - // Transform selection against the composed change and give priority to - // the change. This is needed in cases when format operation actually - // inserts data into the document (e.g. embeds). - final base = change.transformPosition(_selection.baseOffset); - final extent = - change.transformPosition(_selection.extentOffset); - final adjustedSelection = - _selection.copyWith(baseOffset: base, extentOffset: extent); - if (_selection != adjustedSelection) { - _updateSelectionSilent(adjustedSelection, source: _lastChangeSource); - } - notifyListeners(); - } - - /// Formats current selection with [attribute]. - void formatSelection(NotusAttribute attribute) { - int index = _selection.start; - int length = _selection.end - index; - formatText(index, length, attribute); - } - - NotusStyle getSelectionStyle() { - int start = _selection.start; - int length = _selection.end - start; - return _document.collectStyle(start, length); - } - - TextEditingValue get plainTextEditingValue { - return new TextEditingValue( - text: document.toPlainText(), - selection: selection, - composing: new TextRange.collapsed(0), - ); - } - - void _ensureSelectionBeforeLastBreak() { - final end = _document.length - 1; - final base = math.min(_selection.baseOffset, end); - final extent = math.min(_selection.extentOffset, end); - _selection = _selection.copyWith(baseOffset: base, extentOffset: extent); - } -} diff --git a/zefyr/lib/src/widgets/cursor_timer.dart b/zefyr/lib/src/widgets/cursor_timer.dart deleted file mode 100644 index 947dc5ab..00000000 --- a/zefyr/lib/src/widgets/cursor_timer.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -/// Helper class that keeps state relevant to the editing cursor. -class CursorTimer { - static const _kCursorBlinkHalfPeriod = const Duration(milliseconds: 500); - - Timer _timer; - final ValueNotifier _showCursor = new ValueNotifier(false); - - ValueNotifier get value => _showCursor; - - void _cursorTick(Timer timer) { - _showCursor.value = !_showCursor.value; - } - - /// Starts cursor timer. - void start() { - _showCursor.value = true; - _timer = new Timer.periodic(_kCursorBlinkHalfPeriod, _cursorTick); - } - - /// Stops cursor timer. - void stop() { - _timer?.cancel(); - _timer = null; - _showCursor.value = false; - } - - /// Starts or stops cursor timer based on current state of [focusNode] - /// and [selection]. - void startOrStop(FocusNode focusNode, TextSelection selection) { - final hasFocus = focusNode.hasFocus; - final selectionCollapsed = selection.isCollapsed; - if (_timer == null && hasFocus && selectionCollapsed) { - start(); - } else if (_timer != null && (!hasFocus || !selectionCollapsed)) { - stop(); - } - } -} diff --git a/zefyr/lib/src/widgets/editable_box.dart b/zefyr/lib/src/widgets/editable_box.dart deleted file mode 100644 index 71c52f48..00000000 --- a/zefyr/lib/src/widgets/editable_box.dart +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:math' as math; -import 'dart:ui' as ui; - -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; - -import 'caret.dart'; -import 'render_context.dart'; - -class EditableBox extends SingleChildRenderObjectWidget { - EditableBox({ - @required Widget child, - @required this.node, - @required this.layerLink, - @required this.renderContext, - @required this.showCursor, - @required this.selection, - @required this.selectionColor, - @required this.cursorColor, - }) : super(child: child); - - final ContainerNode node; - final LayerLink layerLink; - final ZefyrRenderContext renderContext; - final ValueNotifier showCursor; - final TextSelection selection; - final Color selectionColor; - final Color cursorColor; - - @override - RenderEditableProxyBox createRenderObject(BuildContext context) { - return new RenderEditableProxyBox( - node: node, - layerLink: layerLink, - renderContext: renderContext, - showCursor: showCursor, - selection: selection, - selectionColor: selectionColor, - cursorColor: cursorColor, - ); - } - - @override - void updateRenderObject( - BuildContext context, RenderEditableProxyBox renderObject) { - renderObject - ..node = node - ..layerLink = layerLink - ..renderContext = renderContext - ..showCursor = showCursor - ..selection = selection - ..selectionColor = selectionColor - ..cursorColor = cursorColor; - } -} - -class RenderEditableProxyBox extends RenderBox - with - RenderObjectWithChildMixin, - RenderProxyBoxMixin - implements RenderEditableBox { - RenderEditableProxyBox({ - RenderEditableBox child, - @required ContainerNode node, - @required LayerLink layerLink, - @required ZefyrRenderContext renderContext, - @required ValueNotifier showCursor, - @required TextSelection selection, - @required Color selectionColor, - @required Color cursorColor, - }) : _node = node, - _layerLink = layerLink, - _renderContext = renderContext, - _showCursor = showCursor, - _selection = selection, - _selectionColor = selectionColor, - super() { - this.child = child; - _cursorPainter = CursorPainter(cursorColor); - } - - CursorPainter _cursorPainter; - - set cursorColor(Color value) { - if (_cursorPainter.color != value) { - _cursorPainter.color = value; - markNeedsPaint(); - } - } - - bool _isDirty = true; - - ContainerNode get node => _node; - ContainerNode _node; - void set node(ContainerNode value) { - _node = value; - } - - LayerLink get layerLink => _layerLink; - LayerLink _layerLink; - void set layerLink(LayerLink value) { - if (_layerLink == value) return; - _layerLink = value; - } - - ZefyrRenderContext _renderContext; - void set renderContext(ZefyrRenderContext value) { - if (_renderContext == value) return; - if (attached) _renderContext.removeBox(this); - _renderContext = value; - if (attached) _renderContext.addBox(this); - } - - ValueNotifier _showCursor; - set showCursor(ValueNotifier value) { - assert(value != null); - if (_showCursor == value) return; - if (attached) _showCursor.removeListener(markNeedsCursorPaint); - _showCursor = value; - if (attached) _showCursor.addListener(markNeedsCursorPaint); - markNeedsPaint(); - } - - /// Current document selection. - TextSelection get selection => _selection; - TextSelection _selection; - set selection(TextSelection value) { - if (_selection == value) return; - // TODO: check if selection affects this block (also check previous value) - _selection = value; - markNeedsPaint(); - } - - /// Color of selection. - Color get selectionColor => _selectionColor; - Color _selectionColor; - set selectionColor(Color value) { - if (_selectionColor == value) return; - _selectionColor = value; - markNeedsPaint(); - } - - /// Returns `true` if current selection is collapsed, located within - /// this paragraph and is visible according to tick timer. - bool get isCaretVisible { - return _showCursor.value && containsCaret; - } - - /// Returns `true` if current selection is collapsed and located - /// within this paragraph. - bool get containsCaret { - if (!_selection.isCollapsed) return false; - - final int start = node.documentOffset; - final int end = start + node.length; - final int caretOffset = _selection.extentOffset; - return caretOffset >= start && caretOffset < end; - } - - /// Returns `true` if selection is not collapsed and intersects with this - /// paragraph. - bool get isSelectionVisible { - if (_selection.isCollapsed) return false; - return intersectsWithSelection(_selection); - } - - void markNeedsCursorPaint() { - if (containsCaret) { - markNeedsPaint(); - } - } - - // - // Overridden members of RenderBox - // - - @override - void attach(PipelineOwner owner) { - super.attach(owner); - _showCursor.addListener(markNeedsCursorPaint); - _renderContext.addBox(this); - _renderContext.markDirty(this, _isDirty); - } - - @override - void detach() { - _showCursor.removeListener(markNeedsCursorPaint); - _renderContext.removeBox(this); - super.detach(); - } - - @override - @mustCallSuper - void performLayout() { - super.performLayout(); - _cursorPainter.layout(preferredLineHeight); - // Indicate to render context that this object can be used by other - // layers (selection overlay, for instance). - _isDirty = false; - _renderContext.markDirty(this, false); - } - - @override - void markNeedsLayout() { - // Temporarily remove this object from the render context. - _isDirty = true; - _renderContext.markDirty(this, true); - super.markNeedsLayout(); - } - - @override - void paint(PaintingContext context, Offset offset) { - if (selectionOrder == SelectionOrder.background && isSelectionVisible) { - paintSelection(context, offset, selection, selectionColor); - } - super.paint(context, offset); - if (selectionOrder == SelectionOrder.foreground && isSelectionVisible) { - paintSelection(context, offset, selection, selectionColor); - } - if (isCaretVisible) { - _paintCursor(context, offset); - } - } - - void _paintCursor(PaintingContext context, Offset offset) { - Offset caretOffset = - getOffsetForCaret(_selection.extent, _cursorPainter.prototype); - _cursorPainter.paint(context.canvas, caretOffset + offset); - } - - @override - bool hitTestSelf(Offset position) => true; - - @override - bool hitTest(HitTestResult result, {Offset position}) { - if (size.contains(position)) { - result.add(new BoxHitTestEntry(this, position)); - return true; - } - return false; - } - - // - // Proxy methods - // - - @override - double get preferredLineHeight => child.preferredLineHeight; - - @override - SelectionOrder get selectionOrder => child.selectionOrder; - - @override - void paintSelection(PaintingContext context, Offset offset, - TextSelection selection, Color selectionColor) => - child.paintSelection(context, offset, selection, selectionColor); - - @override - Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) => - child.getOffsetForCaret(position, caretPrototype); - - @override - TextSelection getLocalSelection(TextSelection documentSelection) => - child.getLocalSelection(documentSelection); - - bool intersectsWithSelection(TextSelection selection) => - child.intersectsWithSelection(selection); - - @override - List getEndpointsForSelection(TextSelection selection) => - child.getEndpointsForSelection(selection); - - @override - ui.TextPosition getPositionForOffset(ui.Offset offset) => - child.getPositionForOffset(offset); - - @override - TextRange getWordBoundary(ui.TextPosition position) => - child.getWordBoundary(position); -} - -enum SelectionOrder { - /// Background selection is painted before primary content of editable box. - background, - - /// Foreground selection is painted after primary content of editable box. - foreground, -} - -abstract class RenderEditableBox extends RenderBox { - Node get node; - double get preferredLineHeight; - - TextPosition getPositionForOffset(Offset offset); - List getEndpointsForSelection(TextSelection selection); - - /// Returns the text range of the word at the given offset. Characters not - /// part of a word, such as spaces, symbols, and punctuation, have word breaks - /// on both sides. In such cases, this method will return a text range that - /// contains the given text position. - /// - /// Word boundaries are defined more precisely in Unicode Standard Annex #29 - /// . - /// - /// Valid only after [layout]. - TextRange getWordBoundary(TextPosition position); - - /// Paint order of selection in this editable box. - SelectionOrder get selectionOrder; - - void paintSelection(PaintingContext context, Offset offset, - TextSelection selection, Color selectionColor); - - Offset getOffsetForCaret(TextPosition position, Rect caretPrototype); - - /// Returns part of [documentSelection] local to this box. May return - /// `null`. - /// - /// [documentSelection] must not be collapsed. - TextSelection getLocalSelection(TextSelection documentSelection) { - if (!intersectsWithSelection(documentSelection)) return null; - - int nodeBase = node.documentOffset; - int nodeExtent = nodeBase + node.length; - int base = math.max(0, documentSelection.baseOffset - nodeBase); - int extent = - math.min(documentSelection.extentOffset, nodeExtent) - nodeBase; - return documentSelection.copyWith(baseOffset: base, extentOffset: extent); - } - - /// Returns `true` if this box intersects with document [selection]. - bool intersectsWithSelection(TextSelection selection) { - final int base = node.documentOffset; - final int extent = base + node.length; - return base <= selection.extentOffset && selection.baseOffset <= extent; - } -} diff --git a/zefyr/lib/src/widgets/editable_text.dart b/zefyr/lib/src/widgets/editable_text.dart deleted file mode 100644 index 37fdcf41..00000000 --- a/zefyr/lib/src/widgets/editable_text.dart +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/cupertino.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; - -import 'code.dart'; -import 'common.dart'; -import 'controller.dart'; -import 'cursor_timer.dart'; -import 'editor.dart'; -import 'image.dart'; -import 'input.dart'; -import 'list.dart'; -import 'paragraph.dart'; -import 'quote.dart'; -import 'render_context.dart'; -import 'scope.dart'; -import 'selection.dart'; -import 'theme.dart'; - -/// Core widget responsible for editing Zefyr documents. -/// -/// Depends on presence of [ZefyrTheme] and [ZefyrScope] somewhere up the -/// widget tree. -/// -/// Consider using [ZefyrEditor] which wraps this widget and adds a toolbar to -/// edit style attributes. -class ZefyrEditableText extends StatefulWidget { - const ZefyrEditableText({ - Key key, - @required this.controller, - @required this.focusNode, - @required this.imageDelegate, - this.autofocus: true, - this.enabled: true, - this.padding: const EdgeInsets.symmetric(horizontal: 16.0), - this.physics, - }) : super(key: key); - - final ZefyrController controller; - final FocusNode focusNode; - final ZefyrImageDelegate imageDelegate; - final bool autofocus; - final bool enabled; - final ScrollPhysics physics; - - /// Padding around editable area. - final EdgeInsets padding; - - - - @override - _ZefyrEditableTextState createState() => new _ZefyrEditableTextState(); -} - -class _ZefyrEditableTextState extends State - with AutomaticKeepAliveClientMixin { - // - // New public members - // - - /// Focus node of this widget. - FocusNode get focusNode => widget.focusNode; - - /// Document controlled by this widget. - NotusDocument get document => widget.controller.document; - - /// Current text selection. - TextSelection get selection => widget.controller.selection; - - /// Express interest in interacting with the keyboard. - /// - /// If this control is already attached to the keyboard, this function will - /// request that the keyboard become visible. Otherwise, this function will - /// ask the focus system that it become focused. If successful in acquiring - /// focus, the control will then attach to the keyboard and request that the - /// keyboard become visible. - void requestKeyboard() { - if (focusNode.hasFocus) - _input.openConnection(widget.controller.plainTextEditingValue); - else - FocusScope.of(context).requestFocus(focusNode); - } - - void focusOrUnfocusIfNeeded() { - if (!_didAutoFocus && widget.autofocus && widget.enabled) { - FocusScope.of(context).autofocus(focusNode); - _didAutoFocus = true; - } - if (!widget.enabled && focusNode.hasFocus) { - _didAutoFocus = false; - focusNode.unfocus(); - } - } - - // - // Overridden members of State - // - - - - @override - Widget build(BuildContext context) { -// var reparentIfNeeded = FocusScope.of(context).reparentIfNeeded(focusNode); - - _nodeAttachment.reparent(); - super.build(context); // See AutomaticKeepAliveState. - - Widget body = ListBody(children: _buildChildren(context)); - if (widget.padding != null) { - body = new Padding(padding: widget.padding, child: body); - } - final scrollable = SingleChildScrollView( - physics: widget.physics, - controller: _scrollController, - child: body, - ); - - final overlay = Overlay.of(context, debugRequiredFor: widget); - final layers = [scrollable]; - if (widget.enabled) { - layers.add(ZefyrSelectionOverlay( - controller: widget.controller, - controls: cupertinoTextSelectionControls, - overlay: overlay, - )); - } - - return Stack(fit: StackFit.expand, children: layers); - } - - FocusAttachment _nodeAttachment; - @override - void initState() { - super.initState(); -// FocusScopeNode _node = focusNode; - _nodeAttachment = focusNode.attach(context); - _input = new InputConnectionController(_handleRemoteValueChange); - _updateSubscriptions(); - } - - @override - void didUpdateWidget(ZefyrEditableText oldWidget) { - super.didUpdateWidget(oldWidget); - _updateSubscriptions(oldWidget); - focusOrUnfocusIfNeeded(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - final scope = ZefyrScope.of(context); - if (_renderContext != scope.renderContext) { - _renderContext?.removeListener(_handleRenderContextChange); - _renderContext = scope.renderContext; - _renderContext.addListener(_handleRenderContextChange); - } - if (_cursorTimer != scope.cursorTimer) { - _cursorTimer?.stop(); - _cursorTimer = scope.cursorTimer; - _cursorTimer.startOrStop(focusNode, selection); - } - focusOrUnfocusIfNeeded(); - } - - @override - void dispose() { - _cancelSubscriptions(); - super.dispose(); - } - - // - // Overridden members of AutomaticKeepAliveClientMixin - // - - @override - bool get wantKeepAlive => focusNode.hasFocus; - - // - // Private members - // - - final ScrollController _scrollController = ScrollController(); - ZefyrRenderContext _renderContext; - CursorTimer _cursorTimer; - InputConnectionController _input; - bool _didAutoFocus = false; - - List _buildChildren(BuildContext context) { - final result = []; - for (var node in document.root.children) { - result.add(_defaultChildBuilder(context, node)); - } - return result; - } - - Widget _defaultChildBuilder(BuildContext context, Node node) { - if (node is LineNode) { - if (node.hasEmbed) { - return new RawZefyrLine(node: node); - } else if (node.style.contains(NotusAttribute.heading)) { - return new ZefyrHeading(node: node); - } - return new ZefyrParagraph(node: node); - } - - final BlockNode block = node; - final blockStyle = block.style.get(NotusAttribute.block); - if (blockStyle == NotusAttribute.block.code) { - return new ZefyrCode(node: block); - } else if (blockStyle == NotusAttribute.block.bulletList) { - return new ZefyrList(node: block); - } else if (blockStyle == NotusAttribute.block.numberList) { - return new ZefyrList(node: block); - } else if (blockStyle == NotusAttribute.block.quote) { - return new ZefyrQuote(node: block); - } - - throw new UnimplementedError('Block format $blockStyle.'); - } - - void _updateSubscriptions([ZefyrEditableText oldWidget]) { - if (oldWidget == null) { - widget.controller.addListener(_handleLocalValueChange); - focusNode.addListener(_handleFocusChange); - return; - } - - if (widget.controller != oldWidget.controller) { - oldWidget.controller.removeListener(_handleLocalValueChange); - widget.controller.addListener(_handleLocalValueChange); - _input.updateRemoteValue(widget.controller.plainTextEditingValue); - } - if (widget.focusNode != oldWidget.focusNode) { - oldWidget.focusNode.removeListener(_handleFocusChange); - widget.focusNode.addListener(_handleFocusChange); - updateKeepAlive(); - } - } - - void _cancelSubscriptions() { - _renderContext.removeListener(_handleRenderContextChange); - widget.controller.removeListener(_handleLocalValueChange); - focusNode.removeListener(_handleFocusChange); - _input.closeConnection(); - _cursorTimer.stop(); - } - - // Triggered for both text and selection changes. - void _handleLocalValueChange() { - if (widget.enabled && - widget.controller.lastChangeSource == ChangeSource.local) { - // Only request keyboard for user actions. - requestKeyboard(); - } - _input.updateRemoteValue(widget.controller.plainTextEditingValue); - _cursorTimer.startOrStop(focusNode, selection); - setState(() { - // nothing to update internally. - }); - } - - void _handleFocusChange() { - _input.openOrCloseConnection( - focusNode, widget.controller.plainTextEditingValue); - _cursorTimer.startOrStop(focusNode, selection); - updateKeepAlive(); - } - - void _handleRemoteValueChange( - int start, String deleted, String inserted, TextSelection selection) { - widget.controller - .replaceText(start, deleted.length, inserted, selection: selection); - } - - void _handleRenderContextChange() { - setState(() { - // nothing to update internally. - }); - } -} diff --git a/zefyr/lib/src/widgets/editor.dart b/zefyr/lib/src/widgets/editor.dart deleted file mode 100644 index 4a37337e..00000000 --- a/zefyr/lib/src/widgets/editor.dart +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/widgets.dart'; - -import 'controller.dart'; -import 'editable_text.dart'; -import 'image.dart'; -import 'scaffold.dart'; -import 'scope.dart'; -import 'theme.dart'; -import 'toolbar.dart'; - -/// Widget for editing Zefyr documents. -class ZefyrEditor extends StatefulWidget { - const ZefyrEditor({ - Key key, - @required this.controller, - @required this.focusNode, - this.autofocus: true, - this.enabled: true, - this.padding: const EdgeInsets.symmetric(horizontal: 16.0), - this.toolbarDelegate, - this.imageDelegate, - this.physics, - }) : super(key: key); - - final ZefyrController controller; - final FocusNode focusNode; - final bool autofocus; - final bool enabled; - final ZefyrToolbarDelegate toolbarDelegate; - final ZefyrImageDelegate imageDelegate; - final ScrollPhysics physics; - - /// Padding around editable area. - final EdgeInsets padding; - - @override - _ZefyrEditorState createState() => new _ZefyrEditorState(); -} - -class _ZefyrEditorState extends State { - ZefyrImageDelegate _imageDelegate; - ZefyrScope _scope; - ZefyrThemeData _themeData; - GlobalKey _toolbarKey; - ZefyrScaffoldState _scaffold; - - bool get hasToolbar => _toolbarKey != null; - - void showToolbar() { - assert(_toolbarKey == null); - _toolbarKey = GlobalKey(); - _scaffold.showToolbar(buildToolbar); - } - - void hideToolbar() { - if (_toolbarKey == null) return; - _scaffold.hideToolbar(); - _toolbarKey = null; - } - - Widget buildToolbar(BuildContext context) { - return ZefyrTheme( - data: _themeData, - child: ZefyrToolbar( - key: _toolbarKey, - editor: _scope, - delegate: widget.toolbarDelegate, - ), - ); - } - - void _handleChange() { - if (_scope.focusOwner == FocusOwner.none) { - hideToolbar(); - } else if (!hasToolbar) { - showToolbar(); - } else { - // TODO: is there a nicer way to do this? - WidgetsBinding.instance.addPostFrameCallback((_) { - _toolbarKey?.currentState?.markNeedsRebuild(); - }); - } - } - - @override - void initState() { - super.initState(); - _imageDelegate = widget.imageDelegate ?? new ZefyrDefaultImageDelegate(); - } - - @override - void didUpdateWidget(ZefyrEditor oldWidget) { - super.didUpdateWidget(oldWidget); - _scope.controller = widget.controller; - _scope.focusNode = widget.focusNode; - if (widget.imageDelegate != oldWidget.imageDelegate) { - _imageDelegate = widget.imageDelegate ?? new ZefyrDefaultImageDelegate(); - _scope.imageDelegate = _imageDelegate; - } - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - final parentTheme = ZefyrTheme.of(context, nullOk: true); - final fallbackTheme = ZefyrThemeData.fallback(context); - _themeData = (parentTheme != null) - ? fallbackTheme.merge(parentTheme) - : fallbackTheme; - - if (_scope == null) { - _scope = ZefyrScope.editable( - imageDelegate: _imageDelegate, - controller: widget.controller, - focusNode: widget.focusNode, - focusScope: FocusScope.of(context), - ); - _scope.addListener(_handleChange); - } else { - final focusScope = FocusScope.of(context); - _scope.focusScope = focusScope; - } - - final scaffold = ZefyrScaffold.of(context); - if (_scaffold != scaffold) { - bool didHaveToolbar = hasToolbar; - hideToolbar(); - _scaffold = scaffold; - if (didHaveToolbar) showToolbar(); - } - } - - @override - void dispose() { - hideToolbar(); - _scope.removeListener(_handleChange); - _scope.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - Widget editable = new ZefyrEditableText( - controller: _scope.controller, - focusNode: _scope.focusNode, - imageDelegate: _scope.imageDelegate, - autofocus: widget.autofocus, - enabled: widget.enabled, - padding: widget.padding, - physics: widget.physics, - ); - - return ZefyrTheme( - data: _themeData, - child: ZefyrScopeAccess( - scope: _scope, - child: editable, - ), - ); - } -} diff --git a/zefyr/lib/src/widgets/field.dart b/zefyr/lib/src/widgets/field.dart deleted file mode 100644 index d23f3ca7..00000000 --- a/zefyr/lib/src/widgets/field.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'controller.dart'; -import 'editor.dart'; -import 'image.dart'; -import 'toolbar.dart'; - -/// Zefyr editor with material design decorations. -class ZefyrField extends StatefulWidget { - /// Decoration to paint around this editor. - final InputDecoration decoration; - - /// Height of this editor field. - final double height; - final ZefyrController controller; - final FocusNode focusNode; - final bool autofocus; - final bool enabled; - final ZefyrToolbarDelegate toolbarDelegate; - final ZefyrImageDelegate imageDelegate; - final ScrollPhysics physics; - - const ZefyrField({ - Key key, - this.decoration, - this.height, - this.controller, - this.focusNode, - this.autofocus: false, - this.enabled, - this.toolbarDelegate, - this.imageDelegate, - this.physics, - }) : super(key: key); - - @override - _ZefyrFieldState createState() => _ZefyrFieldState(); -} - -class _ZefyrFieldState extends State { - @override - Widget build(BuildContext context) { - Widget child = ZefyrEditor( - padding: EdgeInsets.symmetric(vertical: 6.0), - controller: widget.controller, - focusNode: widget.focusNode, - autofocus: widget.autofocus, - enabled: widget.enabled ?? true, - toolbarDelegate: widget.toolbarDelegate, - imageDelegate: widget.imageDelegate, - physics: widget.physics, - ); - - if (widget.height != null) { - child = ConstrainedBox( - constraints: BoxConstraints.tightFor(height: widget.height), - child: child, - ); - } - - return AnimatedBuilder( - animation: - Listenable.merge([widget.focusNode, widget.controller]), - builder: (BuildContext context, Widget child) { - return InputDecorator( - decoration: _getEffectiveDecoration(), - isFocused: widget.focusNode.hasFocus, - isEmpty: widget.controller.document.length == 1, - child: child, - ); - }, - child: child, - ); - } - - InputDecoration _getEffectiveDecoration() { - final InputDecoration effectiveDecoration = - (widget.decoration ?? const InputDecoration()) - .applyDefaults(Theme.of(context).inputDecorationTheme) - .copyWith( - enabled: widget.enabled ?? true, - ); - - return effectiveDecoration; - } -} diff --git a/zefyr/lib/src/widgets/horizontal_rule.dart b/zefyr/lib/src/widgets/horizontal_rule.dart deleted file mode 100644 index d9011f0e..00000000 --- a/zefyr/lib/src/widgets/horizontal_rule.dart +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:ui' as ui; - -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; - -import 'editable_box.dart'; - -class ZefyrHorizontalRule extends LeafRenderObjectWidget { - ZefyrHorizontalRule({@required this.node}) : assert(node != null); - - final EmbedNode node; - - @override - RenderHorizontalRule createRenderObject(BuildContext context) { - return new RenderHorizontalRule(node: node); - } - - @override - void updateRenderObject( - BuildContext context, RenderHorizontalRule renderObject) { - renderObject..node = node; - } -} - -class RenderHorizontalRule extends RenderEditableBox { - static const _kPaddingBottom = 24.0; - static const _kThickness = 3.0; - static const _kHeight = _kThickness + _kPaddingBottom; - - RenderHorizontalRule({ - @required EmbedNode node, - }) : _node = node; - - @override - EmbedNode get node => _node; - EmbedNode _node; - set node(EmbedNode value) { - if (_node == value) return; - _node = value; - markNeedsPaint(); - } - - @override - double get preferredLineHeight => size.height; - - @override - SelectionOrder get selectionOrder => SelectionOrder.background; - - @override - List getEndpointsForSelection(TextSelection selection) { - TextSelection local = getLocalSelection(selection); - if (local.isCollapsed) { - final dx = local.extentOffset == 0 ? 0.0 : size.width; - return [ - new ui.TextBox.fromLTRBD(dx, 0.0, dx, size.height, TextDirection.ltr), - ]; - } - - return [ - new ui.TextBox.fromLTRBD(0.0, 0.0, 0.0, size.height, TextDirection.ltr), - new ui.TextBox.fromLTRBD( - size.width, 0.0, size.width, size.height, TextDirection.ltr), - ]; - } - - @override - void performLayout() { - assert(constraints.hasBoundedWidth); - size = new Size(constraints.maxWidth, _kHeight); - } - - @override - void paint(PaintingContext context, Offset offset) { - final rect = new Rect.fromLTWH(0.0, 0.0, size.width, _kThickness); - final paint = new ui.Paint()..color = Colors.grey.shade200; - context.canvas.drawRect(rect.shift(offset), paint); - } - - @override - TextPosition getPositionForOffset(Offset offset) { - int position = _node.documentOffset; - - if (offset.dx > size.width / 2) { - position++; - } - return new TextPosition(offset: position); - } - - @override - TextRange getWordBoundary(TextPosition position) { - final start = _node.documentOffset; - return new TextRange(start: start, end: start + 1); - } - - @override - void paintSelection(PaintingContext context, Offset offset, - TextSelection selection, Color selectionColor) { - final localSelection = getLocalSelection(selection); - assert(localSelection != null); - if (!localSelection.isCollapsed) { - final Paint paint = new Paint()..color = selectionColor; - final rect = new Rect.fromLTWH(0.0, 0.0, size.width, _kHeight); - context.canvas.drawRect(rect.shift(offset), paint); - } - } - - @override - Offset getOffsetForCaret(ui.TextPosition position, ui.Rect caretPrototype) { - final pos = position.offset - node.documentOffset; - Offset caretOffset = Offset.zero; - if (pos == 1) { - caretOffset = caretOffset + new Offset(size.width - 1.0, 0.0); - } - return caretOffset; - } -} diff --git a/zefyr/lib/src/widgets/image.dart b/zefyr/lib/src/widgets/image.dart deleted file mode 100644 index be096d06..00000000 --- a/zefyr/lib/src/widgets/image.dart +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:async'; -import 'dart:io'; -import 'dart:math' as math; -import 'dart:ui' as ui; - -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; -import 'package:image_picker/image_picker.dart'; - -import 'editable_box.dart'; - -abstract class ZefyrImageDelegate { - /// Builds image widget for specified [imageSource] and [context]. - Widget buildImage(BuildContext context, String imageSource); - - /// Picks an image from specified [source]. - /// - /// Returns unique string key for the selected image. Returned key is stored - /// in the document. - Future pickImage(S source); -} - -class ZefyrDefaultImageDelegate implements ZefyrImageDelegate { - @override - Widget buildImage(BuildContext context, String imageSource) { - final file = new File.fromUri(Uri.parse(imageSource)); - final image = new FileImage(file); - return new Image(image: image); - } - - @override - Future pickImage(ImageSource source) async { - final file = await ImagePicker.pickImage(source: source); - if (file == null) return null; - return file.uri.toString(); - } -} - -class ZefyrImage extends StatefulWidget { - const ZefyrImage({Key key, @required this.node, @required this.delegate}) - : super(key: key); - - final EmbedNode node; - final ZefyrImageDelegate delegate; - - @override - _ZefyrImageState createState() => _ZefyrImageState(); -} - -class _ZefyrImageState extends State { - String get imageSource { - EmbedAttribute attribute = widget.node.style.get(NotusAttribute.embed); - return attribute.value['source'] as String; - } - - @override - Widget build(BuildContext context) { - final image = widget.delegate.buildImage(context, imageSource); - return _EditableImage( - child: image, - node: widget.node, - ); - } -} - -class _EditableImage extends SingleChildRenderObjectWidget { - _EditableImage({@required Widget child, @required this.node}) - : assert(node != null), - super(child: child); - - final EmbedNode node; - - @override - RenderEditableImage createRenderObject(BuildContext context) { - return new RenderEditableImage(node: node); - } - - @override - void updateRenderObject( - BuildContext context, RenderEditableImage renderObject) { - renderObject..node = node; - } -} - -class RenderEditableImage extends RenderBox - with RenderObjectWithChildMixin, RenderProxyBoxMixin - implements RenderEditableBox { - static const kPaddingBottom = 24.0; - - RenderEditableImage({ - RenderImage child, - @required EmbedNode node, - }) : _node = node { - this.child = child; - } - - @override - EmbedNode get node => _node; - EmbedNode _node; - void set node(EmbedNode value) { - _node = value; - } - - // TODO: Customize caret height offset instead of adjusting here by 2px. - @override - double get preferredLineHeight => size.height - kPaddingBottom + 2.0; - - @override - SelectionOrder get selectionOrder => SelectionOrder.foreground; - - @override - TextSelection getLocalSelection(TextSelection documentSelection) { - if (!intersectsWithSelection(documentSelection)) return null; - - int nodeBase = node.documentOffset; - int nodeExtent = nodeBase + node.length; - int base = math.max(0, documentSelection.baseOffset - nodeBase); - int extent = - math.min(documentSelection.extentOffset, nodeExtent) - nodeBase; - return documentSelection.copyWith(baseOffset: base, extentOffset: extent); - } - - @override - List getEndpointsForSelection(TextSelection selection) { - TextSelection local = getLocalSelection(selection); - if (local.isCollapsed) { - final dx = local.extentOffset == 0 ? _childOffset.dx : size.width; - return [ - new ui.TextBox.fromLTRBD( - dx, 0.0, dx, size.height - kPaddingBottom, TextDirection.ltr), - ]; - } - - final rect = _childRect; - return [ - new ui.TextBox.fromLTRBD( - rect.left, rect.top, rect.left, rect.bottom, TextDirection.ltr), - new ui.TextBox.fromLTRBD( - rect.right, rect.top, rect.right, rect.bottom, TextDirection.ltr), - ]; - } - - @override - TextPosition getPositionForOffset(Offset offset) { - int position = _node.documentOffset; - - if (offset.dx > size.width / 2) { - position++; - } - return new TextPosition(offset: position); - } - - @override - TextRange getWordBoundary(TextPosition position) { - final start = _node.documentOffset; - return new TextRange(start: start, end: start + 1); - } - - @override - bool intersectsWithSelection(TextSelection selection) { - final int base = node.documentOffset; - final int extent = base + node.length; - return base <= selection.extentOffset && selection.baseOffset <= extent; - } - - @override - Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) { - final pos = position.offset - node.documentOffset; - Offset caretOffset = _childOffset - new Offset(kHorizontalPadding, 0.0); - if (pos == 1) { - caretOffset = caretOffset + - new Offset(_lastChildSize.width + kHorizontalPadding, 0.0); - } - return caretOffset; - } - - @override - void paintSelection(PaintingContext context, Offset offset, - TextSelection selection, Color selectionColor) { - final localSelection = getLocalSelection(selection); - assert(localSelection != null); - if (!localSelection.isCollapsed) { - final Paint paint = new Paint() - ..color = selectionColor - ..style = PaintingStyle.stroke - ..strokeWidth = 3.0; - final rect = new Rect.fromLTWH( - 0.0, 0.0, _lastChildSize.width, _lastChildSize.height); - context.canvas.drawRect(rect.shift(offset + _childOffset), paint); - } - } - - void paint(PaintingContext context, Offset offset) { - super.paint(context, offset + _childOffset); - } - - static const double kHorizontalPadding = 1.0; - - Size _lastChildSize; - - Offset get _childOffset { - final dx = (size.width - _lastChildSize.width) / 2 + kHorizontalPadding; - final dy = (size.height - _lastChildSize.height - kPaddingBottom) / 2; - return new Offset(dx, dy); - } - - Rect get _childRect { - return new Rect.fromLTWH(_childOffset.dx, _childOffset.dy, - _lastChildSize.width, _lastChildSize.height); - } - - @override - void performLayout() { - assert(constraints.hasBoundedWidth); - if (child != null) { - // Make constraints use 16:9 aspect ratio. - final width = constraints.maxWidth - kHorizontalPadding * 2; - final childConstraints = constraints.copyWith( - minWidth: 0.0, - maxWidth: width, - minHeight: 0.0, - maxHeight: (width * 9 / 16).floorToDouble(), - ); - child.layout(childConstraints, parentUsesSize: true); - _lastChildSize = child.size; - size = new Size( - constraints.maxWidth, _lastChildSize.height + kPaddingBottom); - } else { - performResize(); - } - } -} diff --git a/zefyr/lib/src/widgets/input.dart b/zefyr/lib/src/widgets/input.dart deleted file mode 100644 index d006d976..00000000 --- a/zefyr/lib/src/widgets/input.dart +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/services.dart'; -import 'package:flutter/src/foundation/diagnostics.dart'; -import 'package:flutter/widgets.dart'; -import 'package:zefyr/util.dart'; - -typedef RemoteValueChanged = Function( - int start, String deleted, String inserted, TextSelection selection); - -class InputConnectionController implements TextInputClient { - InputConnectionController(this.onValueChanged) - : assert(onValueChanged != null); - - // - // New public members - // - - final RemoteValueChanged onValueChanged; - - /// Returns `true` if there is open input connection. - bool get hasConnection => - _textInputConnection != null && _textInputConnection.attached; - - /// Opens or closes input connection based on the current state of - /// [focusNode] and [value]. - void openOrCloseConnection(FocusNode focusNode, TextEditingValue value) { - if (focusNode.hasFocus && focusNode.consumeKeyboardToken()) { - openConnection(value); - } else if (!focusNode.hasFocus) { - closeConnection(); - } - } - - void openConnection(TextEditingValue value) { - if (!hasConnection) { - _lastKnownRemoteTextEditingValue = value; - _textInputConnection = TextInput.attach( - this, - new TextInputConfiguration( - inputType: TextInputType.multiline, - obscureText: false, - autocorrect: true, - inputAction: TextInputAction.newline, - textCapitalization: TextCapitalization.sentences, - ), - )..setEditingState(value); - _sentRemoteValues.add(value); - } - _textInputConnection.show(); - } - - /// Closes input connection if it's currently open. Otherwise does nothing. - void closeConnection() { - if (hasConnection) { - _textInputConnection.close(); - _textInputConnection = null; - _lastKnownRemoteTextEditingValue = null; - _sentRemoteValues.clear(); - } - } - - /// Updates remote value based on current state of [document] and - /// [selection]. - /// - /// This method may not actually send an update to native side if it thinks - /// remote value is up to date or identical. - void updateRemoteValue(TextEditingValue value) { - if (!hasConnection) return; - - // Since we don't keep track of composing range in value provided by - // ZefyrController we need to add it here manually before comparing - // with the last known remote value. - // It is important to prevent excessive remote updates as it can cause - // race conditions. - final actualValue = value.copyWith( - composing: _lastKnownRemoteTextEditingValue.composing, - ); - - if (actualValue == _lastKnownRemoteTextEditingValue) return; - - bool shouldRemember = value.text != _lastKnownRemoteTextEditingValue.text; - _lastKnownRemoteTextEditingValue = actualValue; - _textInputConnection.setEditingState(actualValue); - if (shouldRemember) { - // Only keep track if text changed (selection changes are not relevant) - _sentRemoteValues.add(actualValue); - } - } - - // - // Overridden members - // - - @override - void performAction(TextInputAction action) { - // no-op - } - - @override - void updateEditingValue(TextEditingValue value) { - if (_sentRemoteValues.contains(value)) { - /// There is a race condition in Flutter text input plugin where sending - /// updates to native side too often results in broken behavior. - /// TextInputConnection.setEditingValue is an async call to native side. - /// For each such call native side _always_ sends update which triggers - /// this method (updateEditingValue) with the same value we've sent it. - /// If multiple calls to setEditingValue happen too fast and we only - /// track the last sent value then there is no way for us to filter out - /// automatic callbacks from native side. - /// Therefore we have to keep track of all values we send to the native - /// side and when we see this same value appear here we skip it. - /// This is fragile but it's probably the only available option. - _sentRemoteValues.remove(value); - return; - } - - if (_lastKnownRemoteTextEditingValue == value) { - // There is no difference between this value and the last known value. - return; - } - - // Check if only composing range changed. - if (_lastKnownRemoteTextEditingValue.text == value.text && - _lastKnownRemoteTextEditingValue.selection == value.selection) { - // This update only modifies composing range. Since we don't keep track - // of composing range in Zefyr we just need to update last known value - // here. - // Note: this check fixes an issue on Android when it sends - // composing updates separately from regular changes for text and - // selection. - _lastKnownRemoteTextEditingValue = value; - return; - } - - // Note Flutter (unintentionally?) silences errors occurred during - // text input update, so we have to report it ourselves. - // For more details see https://github.com/flutter/flutter/issues/19191 - // TODO: remove try-catch when/if Flutter stops silencing these errors. - try { - final effectiveLastKnownValue = _lastKnownRemoteTextEditingValue; - _lastKnownRemoteTextEditingValue = value; - final oldText = effectiveLastKnownValue.text; - final text = value.text; - final cursorPosition = value.selection.extentOffset; - final diff = fastDiff(oldText, text, cursorPosition); - onValueChanged(diff.start, diff.deleted, diff.inserted, value.selection); - } catch (e, trace) { - FlutterError.reportError(new FlutterErrorDetails( - exception: e, - stack: trace, - library: 'Zefyr', -// context: 'while updating editing value', - context: new TextNode() - )); - rethrow; - } - } - - - // - // Private members - // - - final List _sentRemoteValues = []; - TextInputConnection _textInputConnection; - TextEditingValue _lastKnownRemoteTextEditingValue; - - @override - void updateFloatingCursor(RawFloatingCursorPoint point) { - // TODO: implement updateFloatingCursor - } -} - -class TextNode extends DiagnosticsNode{ - @override - List getChildren() { - // TODO: implement getChildren - return null; - } - - @override - List getProperties() { - // TODO: implement getProperties - return null; - } - - @override - String toDescription({TextTreeConfiguration parentConfiguration}) { - // TODO: implement toDescription - return null; - } - - @override - Object get value => 'while updating editing value'; - -} diff --git a/zefyr/lib/src/widgets/list.dart b/zefyr/lib/src/widgets/list.dart deleted file mode 100644 index a3479e58..00000000 --- a/zefyr/lib/src/widgets/list.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'common.dart'; -import 'paragraph.dart'; -import 'theme.dart'; - -/// Represents number lists and bullet lists in a Zefyr editor. -class ZefyrList extends StatelessWidget { - const ZefyrList({Key key, @required this.node}) : super(key: key); - - final BlockNode node; - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context); - List items = []; - int index = 1; - for (var line in node.children) { - items.add(_buildItem(line, index)); - index++; - } - - final isNumberList = - node.style.get(NotusAttribute.block) == NotusAttribute.block.numberList; - EdgeInsets padding = isNumberList - ? theme.blockTheme.numberList.padding - : theme.blockTheme.bulletList.padding; - padding = padding.copyWith(left: theme.indentSize); - - return new Padding( - padding: padding, - child: new Column(children: items), - ); - } - - Widget _buildItem(Node node, int index) { - LineNode line = node; - return new ZefyrListItem(index: index, node: line); - } -} - -/// An item in a [ZefyrList]. -class ZefyrListItem extends StatelessWidget { - ZefyrListItem({Key key, this.index, this.node}) : super(key: key); - - final int index; - final LineNode node; - - @override - Widget build(BuildContext context) { - final BlockNode block = node.parent; - final style = block.style.get(NotusAttribute.block); - final theme = ZefyrTheme.of(context); - final bulletText = - (style == NotusAttribute.block.bulletList) ? '•' : '$index.'; - - TextStyle textStyle; - Widget content; - EdgeInsets padding; - - if (node.style.contains(NotusAttribute.heading)) { - final headingTheme = ZefyrHeading.themeOf(node, context); - textStyle = headingTheme.textStyle; - padding = headingTheme.padding; - content = new ZefyrHeading(node: node); - } else { - textStyle = theme.paragraphTheme.textStyle; - content = new RawZefyrLine(node: node, style: textStyle); - } - - Widget bullet = - SizedBox(width: 24.0, child: Text(bulletText, style: textStyle)); - if (padding != null) { - bullet = Padding(padding: padding, child: bullet); - } - - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [bullet, Expanded(child: content)], - ); - } -} diff --git a/zefyr/lib/src/widgets/paragraph.dart b/zefyr/lib/src/widgets/paragraph.dart deleted file mode 100644 index 222b5bae..00000000 --- a/zefyr/lib/src/widgets/paragraph.dart +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'common.dart'; -import 'theme.dart'; - -/// Represents regular paragraph line in a Zefyr editor. -class ZefyrParagraph extends StatelessWidget { - ZefyrParagraph({Key key, @required this.node, this.blockStyle}) - : super(key: key); - - final LineNode node; - final TextStyle blockStyle; - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context); - TextStyle style = theme.paragraphTheme.textStyle; - if (blockStyle != null) { - style = style.merge(blockStyle); - } - return new RawZefyrLine( - node: node, - style: style, - padding: theme.paragraphTheme.padding, - ); - } -} - -/// Represents heading-styled line in [ZefyrEditor]. -class ZefyrHeading extends StatelessWidget { - ZefyrHeading({Key key, @required this.node, this.blockStyle}) - : assert(node.style.contains(NotusAttribute.heading)), - super(key: key); - - final LineNode node; - final TextStyle blockStyle; - - @override - Widget build(BuildContext context) { - final theme = themeOf(node, context); - TextStyle style = theme.textStyle; - if (blockStyle != null) { - style = style.merge(blockStyle); - } - return new RawZefyrLine( - node: node, - style: style, - padding: theme.padding, - ); - } - - static StyleTheme themeOf(LineNode node, BuildContext context) { - final theme = ZefyrTheme.of(context); - final style = node.style.get(NotusAttribute.heading); - if (style == NotusAttribute.heading.level1) { - return theme.headingTheme.level1; - } else if (style == NotusAttribute.heading.level2) { - return theme.headingTheme.level2; - } else if (style == NotusAttribute.heading.level3) { - return theme.headingTheme.level3; - } - throw new UnimplementedError('Unsupported heading style $style'); - } -} diff --git a/zefyr/lib/src/widgets/quote.dart b/zefyr/lib/src/widgets/quote.dart deleted file mode 100644 index a9eacd13..00000000 --- a/zefyr/lib/src/widgets/quote.dart +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'paragraph.dart'; -import 'theme.dart'; - -/// Represents a quote block in a Zefyr editor. -class ZefyrQuote extends StatelessWidget { - const ZefyrQuote({Key key, @required this.node}) : super(key: key); - - final BlockNode node; - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context); - final style = theme.blockTheme.quote.textStyle; - List items = []; - for (var line in node.children) { - items.add(_buildLine(line, style, theme.indentSize)); - } - - return Padding( - padding: theme.blockTheme.quote.padding, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: items, - ), - ); - } - - Widget _buildLine(Node node, TextStyle blockStyle, double indentSize) { - LineNode line = node; - - Widget content; - if (line.style.contains(NotusAttribute.heading)) { - content = new ZefyrHeading(node: line, blockStyle: blockStyle); - } else { - content = new ZefyrParagraph(node: line, blockStyle: blockStyle); - } - - final row = Row(children: [Expanded(child: content)]); - return Container( - decoration: BoxDecoration( - border: Border( - left: BorderSide(width: 4.0, color: Colors.grey.shade300), - ), - ), - padding: EdgeInsets.only(left: indentSize), - child: row, - ); - } -} diff --git a/zefyr/lib/src/widgets/render_context.dart b/zefyr/lib/src/widgets/render_context.dart deleted file mode 100644 index 1e88aa53..00000000 --- a/zefyr/lib/src/widgets/render_context.dart +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'package:flutter/foundation.dart'; -import 'package:flutter/widgets.dart'; - -import 'editable_box.dart'; - -/// Registry of all [RenderEditableProxyBox]es inside a [ZefyrEditableText]. -/// -/// Provides access to all currently active [RenderEditableProxyBox] -/// instances of a [ZefyrEditableText]. -/// -/// Use [boxForTextOffset] or [boxForGlobalPoint] to retrieve a -/// specific box. -/// -/// The [addBox], [removeBox] and [markDirty] are intended to be -/// only used by [RenderEditableProxyBox] objects to register with a rendering -/// context. -/// -/// ### Life cycle details -/// -/// When a box object is attached to rendering pipeline it registers -/// itself with a render scope by calling [addBox]. At this point the context -/// treats this object as "dirty" and query methods like [boxForTextOffset] -/// still exclude this object from returned results. -/// -/// When this box considers itself initialized it calls [markDirty] with -/// `isDirty` set to `false` which activates it. At this point query methods -/// include this object in results. -/// -/// When a box is rebuilt it may deactivate itself by calling [markDirty] -/// again. -/// -/// When a box is detached from rendering pipeline it unregisters -/// itself by calling [removeBox]. -class ZefyrRenderContext extends ChangeNotifier { - final Set _dirtyBoxes = new Set(); - final Set _activeBoxes = new Set(); - - Set get dirty => _dirtyBoxes; - Set get active => _activeBoxes; - - bool _disposed = false; - - /// Adds [box] to this context. The box is considered "dirty" at - /// this point and is not included in query results of `boxFor*` - /// methods. - void addBox(RenderEditableProxyBox box) { - assert(!_disposed); - _dirtyBoxes.add(box); - } - - /// Removes [box] from this render context. - void removeBox(RenderEditableProxyBox box) { - assert(!_disposed); - _dirtyBoxes.remove(box); - _activeBoxes.remove(box); - notifyListeners(); - } - - void markDirty(RenderEditableProxyBox box, bool isDirty) { - assert(!_disposed); - - var collection = isDirty ? _dirtyBoxes : _activeBoxes; - if (collection.contains(box)) return; - - if (isDirty) { - _activeBoxes.remove(box); - _dirtyBoxes.add(box); - } else { - _dirtyBoxes.remove(box); - _activeBoxes.add(box); - } - notifyListeners(); - } - - /// Returns box containing character at specified document [offset]. - RenderEditableProxyBox boxForTextOffset(int offset) { - assert(!_disposed); - return _activeBoxes.firstWhere( - (p) => p.node.containsOffset(offset), - orElse: _null, - ); - } - - /// Returns box located at specified global [point] on the screen or - /// `null`. - RenderEditableProxyBox boxForGlobalPoint(Offset point) { - assert(!_disposed); - return _activeBoxes.firstWhere((p) { - final localPoint = p.globalToLocal(point); - return p.size.contains(localPoint); - }, orElse: _null); - } - - /// Returns closest render box to the specified global [point]. - /// - /// If [point] is inside of one of active render boxes that box is returned. - /// If no box found this method checks if [point] is to the left or to the right - /// side of a box, e.g. if vertical offset of this point is inside of one of - /// the active boxes. If it is then that box is returned. If not then this - /// method picks a box with shortest vertical distance to this [point]. - RenderEditableProxyBox closestBoxForGlobalPoint(Offset point) { - assert(!_disposed); - if (_activeBoxes.isEmpty) return null; - RenderEditableProxyBox box = boxForGlobalPoint(point); - if (box != null) return box; - - box = _activeBoxes.firstWhere((p) { - final localPoint = p.globalToLocal(point); - return (localPoint.dy >= 0 && localPoint.dy < p.size.height); - }, orElse: _null); - if (box != null) return box; - - box = _activeBoxes.map((p) { - final localPoint = p.globalToLocal(point); - final distance = localPoint.dy - p.size.height; - return new MapEntry(distance.abs(), p); - }).reduce((a, b) { - return (a.key <= b.key) ? a : b; - }).value; - - return box; - } - - static Null _null() => null; - - @override - void dispose() { - _disposed = true; - _activeBoxes.clear(); - _dirtyBoxes.clear(); - super.dispose(); - } - - @override - void notifyListeners() { - /// Ensures listeners are not notified during rendering phase where they - /// cannot react by updating their state or rebuilding. - WidgetsBinding.instance.addPostFrameCallback((_) { - if (_disposed) return; - super.notifyListeners(); - }); - } -} diff --git a/zefyr/lib/src/widgets/rich_text.dart b/zefyr/lib/src/widgets/rich_text.dart deleted file mode 100644 index f2eff9c9..00000000 --- a/zefyr/lib/src/widgets/rich_text.dart +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:math' as math; -import 'dart:ui' as ui; - -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:notus/notus.dart'; - -import 'caret.dart'; -import 'editable_box.dart'; - -/// Represents single paragraph of Zefyr rich-text. -class ZefyrRichText extends LeafRenderObjectWidget { - ZefyrRichText({ - @required this.node, - @required this.text, - }) : assert(node != null && text != null); - - final LineNode node; - final TextSpan text; - - @override - RenderObject createRenderObject(BuildContext context) { - return new RenderZefyrParagraph( - text, - node: node, - textDirection: Directionality.of(context), - ); - } - - @override - void updateRenderObject( - BuildContext context, RenderZefyrParagraph renderObject) { - renderObject - ..text = text - ..node = node; - } -} - -class RenderZefyrParagraph extends RenderParagraph - implements RenderEditableBox { - RenderZefyrParagraph( - TextSpan text, { - @required LineNode node, - TextAlign textAlign: TextAlign.start, - @required TextDirection textDirection, - bool softWrap: true, - TextOverflow overflow: TextOverflow.clip, - double textScaleFactor: 1.0, - int maxLines, - }) : _node = node, - _prototypePainter = new TextPainter( - text: new TextSpan(text: '.', style: text.style), - textAlign: textAlign, - textDirection: textDirection, - textScaleFactor: textScaleFactor, - ), - super( - text, - textAlign: textAlign, - textDirection: textDirection, - softWrap: softWrap, - overflow: overflow, - textScaleFactor: textScaleFactor, - maxLines: maxLines, - ); - - LineNode get node => _node; - LineNode _node; - void set node(LineNode value) { - _node = value; - } - - @override - double get preferredLineHeight => _prototypePainter.height; - - @override - SelectionOrder get selectionOrder => SelectionOrder.background; - - @override - TextSelection getLocalSelection(TextSelection documentSelection) { - if (!intersectsWithSelection(documentSelection)) return null; - - int nodeBase = node.documentOffset; - int nodeExtent = nodeBase + node.length; - int base = math.max(0, documentSelection.baseOffset - nodeBase); - int extent = - math.min(documentSelection.extentOffset, nodeExtent) - nodeBase; - return documentSelection.copyWith(baseOffset: base, extentOffset: extent); - } - - @override - TextPosition getPositionForOffset(Offset offset) { - final position = super.getPositionForOffset(offset); - return new TextPosition( - offset: _node.documentOffset + position.offset, - affinity: position.affinity, - ); - } - - @override - TextRange getWordBoundary(TextPosition position) { - final localPosition = new TextPosition( - offset: position.offset - _node.documentOffset, - affinity: position.affinity, - ); - final localRange = super.getWordBoundary(localPosition); - return new TextRange( - start: _node.documentOffset + localRange.start, - end: _node.documentOffset + localRange.end, - ); - } - - @override - Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) { - final localPosition = new TextPosition( - offset: position.offset - _node.documentOffset, - affinity: position.affinity, - ); - return super.getOffsetForCaret(localPosition, caretPrototype); - } - - // This method works around some issues in getBoxesForSelection and handles - // edge-case with our TextSpan objects not having last line-break character. - @override - List getEndpointsForSelection(TextSelection selection) { - TextSelection local = getLocalSelection(selection); - if (local.isCollapsed) { - final caret = CursorPainter.buildPrototype(preferredLineHeight); - final offset = getOffsetForCaret(local.extent, caret); - return [ - new ui.TextBox.fromLTRBD( - offset.dx, - offset.dy, - offset.dx, - offset.dy + caret.height, - TextDirection.ltr, - ) - ]; - } - - int isBaseShifted = 0; - bool isExtentShifted = false; - if (local.baseOffset == node.length - 1 && local.baseOffset > 0) { - // Since we exclude last line-break from rendered TextSpan we have to - // handle end-of-line selection explicitly. - local = local.copyWith(baseOffset: local.baseOffset - 1); - isBaseShifted = -1; - } else if (local.baseOffset == 0 && local.isCollapsed) { - // This takes care of beginning of line position. - local = local.copyWith(baseOffset: local.baseOffset + 1); - isBaseShifted = 1; - } - if (text.codeUnitAt(local.extentOffset - 1) == 0xA) { - // This takes care of the rest end-of-line scenarios, where there are - // actually line-breaks in the TextSpan (e.g. in code blocks). - local = local.copyWith(extentOffset: local.extentOffset + 1); - isExtentShifted = true; - } - final result = getBoxesForSelection(local).toList(); - if (isBaseShifted != 0) { - final box = result.first; - final dx = isBaseShifted == -1 ? box.right : box.left; - result.removeAt(0); - result.insert(0, - new ui.TextBox.fromLTRBD(dx, box.top, dx, box.bottom, box.direction)); - } - if (isExtentShifted) { - final box = result.last; - result.removeLast; - result.add(new ui.TextBox.fromLTRBD( - box.left, box.top, box.left, box.bottom, box.direction)); - } - return result; - } - - @override - void set text(InlineSpan value) { - _prototypePainter.text = new TextSpan(text: '.', style: value.style); - _selectionRects = null; - super.text = value; - } - - @override - void performLayout() { - super.performLayout(); - _prototypePainter.layout( - minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); - } - - @override - void paint(PaintingContext context, Offset offset) { - super.paint(context, offset); - } - - final TextPainter _prototypePainter; - List _selectionRects; - - /// Returns `true` if this paragraph intersects with document [selection]. - @override - bool intersectsWithSelection(TextSelection selection) { - final int base = node.documentOffset; - final int extent = base + node.length; - return base <= selection.extentOffset && selection.baseOffset <= extent; - } - - TextSelection _lastPaintedSelection; - @override - void paintSelection(PaintingContext context, Offset offset, - TextSelection selection, Color selectionColor) { - if (_lastPaintedSelection != selection) { - _selectionRects = null; - } - _selectionRects ??= getBoxesForSelection(getLocalSelection(selection)); - final Paint paint = new Paint()..color = selectionColor; - for (ui.TextBox box in _selectionRects) { - context.canvas.drawRect(box.toRect().shift(offset), paint); - } - _lastPaintedSelection = selection; - } -} diff --git a/zefyr/lib/src/widgets/scaffold.dart b/zefyr/lib/src/widgets/scaffold.dart deleted file mode 100644 index f711070e..00000000 --- a/zefyr/lib/src/widgets/scaffold.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; - -class ZefyrScaffold extends StatefulWidget { - final Widget child; - - const ZefyrScaffold({Key key, this.child}) : super(key: key); - - static ZefyrScaffoldState of(BuildContext context) { - final _ZefyrScaffoldAccess widget = - context.inheritFromWidgetOfExactType(_ZefyrScaffoldAccess); - return widget.scaffold; - } - - @override - ZefyrScaffoldState createState() => ZefyrScaffoldState(); -} - -class ZefyrScaffoldState extends State { - WidgetBuilder _toolbarBuilder; - - void showToolbar(WidgetBuilder builder) { - setState(() { - _toolbarBuilder = builder; - }); - } - - void hideToolbar() { - if (_toolbarBuilder != null) { - setState(() { - _toolbarBuilder = null; - }); - } - } - - @override - Widget build(BuildContext context) { - final toolbar = - (_toolbarBuilder == null) ? Container() : _toolbarBuilder(context); - return _ZefyrScaffoldAccess( - scaffold: this, - child: Column( - children: [ - Expanded(child: widget.child), - toolbar, - ], - ), - ); - } -} - -class _ZefyrScaffoldAccess extends InheritedWidget { - final ZefyrScaffoldState scaffold; - - _ZefyrScaffoldAccess({Widget child, this.scaffold}) : super(child: child); - - @override - bool updateShouldNotify(_ZefyrScaffoldAccess oldWidget) { - return oldWidget.scaffold != scaffold; - } -} diff --git a/zefyr/lib/src/widgets/scope.dart b/zefyr/lib/src/widgets/scope.dart deleted file mode 100644 index 2853a8a2..00000000 --- a/zefyr/lib/src/widgets/scope.dart +++ /dev/null @@ -1,232 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'controller.dart'; -import 'cursor_timer.dart'; -import 'editor.dart'; -import 'image.dart'; -import 'render_context.dart'; -import 'view.dart'; - -/// Provides access to shared state of [ZefyrEditor] or [ZefyrView]. -/// -/// A scope object can be created by an editable widget like [ZefyrEditor] in -/// which case it provides access to editing state, including focus nodes, -/// selection and such. Editable scope can be created using -/// [ZefyrScope.editable] constructor. -/// -/// If a scope object is created by a view-only widget like [ZefyrView] then -/// it only provides access to [imageDelegate]. -/// -/// Can be retrieved using [ZefyrScope.of]. -class ZefyrScope extends ChangeNotifier { - /// Creates a view-only scope. - /// - /// Normally used in [ZefyrView]. - ZefyrScope.view({@required ZefyrImageDelegate imageDelegate}) - : assert(imageDelegate != null), - isEditable = false, - _imageDelegate = imageDelegate; - - /// Creates editable scope. - /// - /// Normally used in [ZefyrEditor]. - ZefyrScope.editable({ - @required ZefyrController controller, - @required ZefyrImageDelegate imageDelegate, - @required FocusNode focusNode, - @required FocusScopeNode focusScope, - }) : assert(controller != null), - assert(imageDelegate != null), - assert(focusNode != null), - assert(focusScope != null), - isEditable = true, - _controller = controller, - _imageDelegate = imageDelegate, - _focusNode = focusNode, - _focusScope = focusScope, - _cursorTimer = CursorTimer(), - _renderContext = ZefyrRenderContext() { - _selectionStyle = _controller.getSelectionStyle(); - _selection = _controller.selection; - _controller.addListener(_handleControllerChange); - _focusNode.addListener(_handleFocusChange); - } - - static ZefyrScope of(BuildContext context) { - final ZefyrScopeAccess widget = - context.inheritFromWidgetOfExactType(ZefyrScopeAccess); - return widget.scope; - } - - ZefyrImageDelegate _imageDelegate; - ZefyrImageDelegate get imageDelegate => _imageDelegate; - set imageDelegate(ZefyrImageDelegate value) { - assert(value != null); - if (_imageDelegate != value) { - _imageDelegate = value; - notifyListeners(); - } - } - - ZefyrController _controller; - ZefyrController get controller => _controller; - set controller(ZefyrController value) { - assert(isEditable && value != null); - if (_controller != value) { - _controller.removeListener(_handleControllerChange); - _controller = value; - _selectionStyle = _controller.getSelectionStyle(); - _selection = _controller.selection; - _controller.addListener(_handleControllerChange); - notifyListeners(); - } - } - - FocusNode _focusNode; - FocusNode get focusNode => _focusNode; - set focusNode(FocusNode value) { - assert(isEditable && value != null); - if (_focusNode != value) { - _focusNode.removeListener(_handleFocusChange); - _focusNode = value; - _focusNode.addListener(_handleFocusChange); - notifyListeners(); - } - } - - FocusScopeNode _focusScope; - FocusScopeNode get focusScope => _focusScope; - set focusScope(FocusScopeNode value) { - assert(isEditable && value != null); - if (_focusScope != value) { - _focusScope = value; - } - } - - CursorTimer _cursorTimer; - CursorTimer get cursorTimer => _cursorTimer; - ValueNotifier get showCursor => cursorTimer.value; - - ZefyrRenderContext _renderContext; - ZefyrRenderContext get renderContext => _renderContext; - - NotusStyle get selectionStyle => _selectionStyle; - NotusStyle _selectionStyle; - TextSelection get selection => _selection; - TextSelection _selection; - - bool _disposed = false; - FocusNode _toolbarFocusNode; - - /// Whether this scope is backed by editable Zefyr widgets or read-only view. - /// - /// Returns `true` if this scope provides Zefyr interface that allows editing - /// (e.g. created by [ZefyrEditor]). Returns `false` if this scope provides - /// read-only view (e.g. created by [ZefyrView]). - /// - /// Editable scope provides access to corresponding [controller], [focusNode], - /// [focusScope], [showCursor], [renderContext] and other shared objects. For - /// non-editable scopes these are set to `null`. You can still access - /// objects which are not dependent on editing flow, e.g. [imageDelegate]. - final bool isEditable; - - set toolbarFocusNode(FocusNode node) { - assert(isEditable); - assert(!_disposed || node == null); - if (_toolbarFocusNode != node) { - _toolbarFocusNode?.removeListener(_handleFocusChange); - _toolbarFocusNode = node; - _toolbarFocusNode?.addListener(_handleFocusChange); - // We do not notify listeners here because it will happen when - // focus state changes, see [_handleFocusChange]. - } - } - - FocusOwner get focusOwner { - assert(isEditable); - assert(!_disposed); - if (_focusNode.hasFocus) { - return FocusOwner.editor; - } else if (_toolbarFocusNode?.hasFocus == true) { - return FocusOwner.toolbar; - } else { - return FocusOwner.none; - } - } - - void updateSelection(TextSelection value, - {ChangeSource source: ChangeSource.remote}) { - assert(isEditable); - assert(!_disposed); - _controller.updateSelection(value, source: source); - } - - void formatSelection(NotusAttribute value) { - assert(isEditable); - assert(!_disposed); - _controller.formatSelection(value); - } - - void focus() { - assert(isEditable); - assert(!_disposed); - _focusScope.requestFocus(_focusNode); - } - - void hideKeyboard() { - assert(isEditable); - assert(!_disposed); - _focusNode.unfocus(); - } - - @override - void dispose() { - assert(!_disposed); - _controller?.removeListener(_handleControllerChange); - _focusNode?.removeListener(_handleFocusChange); - _disposed = true; - super.dispose(); - } - - void _handleControllerChange() { - assert(!_disposed); - final attrs = _controller.getSelectionStyle(); - final selection = _controller.selection; - if (_selectionStyle != attrs || _selection != selection) { - _selectionStyle = attrs; - _selection = selection; - notifyListeners(); - } - } - - void _handleFocusChange() { - assert(!_disposed); - if (focusOwner == FocusOwner.none && !_selection.isCollapsed) { - // Collapse selection if there is nothing focused. - _controller.updateSelection(_selection.copyWith( - baseOffset: _selection.extentOffset, - extentOffset: _selection.extentOffset, - )); - } - notifyListeners(); - } - - @override - String toString() { - return '$ZefyrScope#${shortHash(this)}'; - } -} - -class ZefyrScopeAccess extends InheritedWidget { - final ZefyrScope scope; - - ZefyrScopeAccess({Key key, @required this.scope, @required Widget child}) - : super(key: key, child: child); - - @override - bool updateShouldNotify(ZefyrScopeAccess oldWidget) { - return scope != oldWidget.scope; - } -} diff --git a/zefyr/lib/src/widgets/selection.dart b/zefyr/lib/src/widgets/selection.dart deleted file mode 100644 index febbd661..00000000 --- a/zefyr/lib/src/widgets/selection.dart +++ /dev/null @@ -1,512 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:ui' as ui; - -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:notus/notus.dart'; -import 'package:zefyr/util.dart'; - -import 'controller.dart'; -import 'editable_box.dart'; -import 'scope.dart'; - -RenderEditableBox _getEditableBox(HitTestResult result) { - for (var entry in result.path) { - if (entry.target is RenderEditableBox) { - return entry.target as RenderEditableBox; - } - } - return null; -} - -/// Selection overlay controls selection handles and other gestures. -class ZefyrSelectionOverlay extends StatefulWidget { - const ZefyrSelectionOverlay({ - Key key, - @required this.controller, - @required this.controls, - @required this.overlay, - }) : super(key: key); - - final ZefyrController controller; - final TextSelectionControls controls; - final OverlayState overlay; - - @override - _ZefyrSelectionOverlayState createState() => - new _ZefyrSelectionOverlayState(); -} - -class _ZefyrSelectionOverlayState extends State - implements TextSelectionDelegate { - @override - TextEditingValue get textEditingValue => - widget.controller.plainTextEditingValue; - - set textEditingValue(TextEditingValue value) { - final cursorPosition = value.selection.extentOffset; - final oldText = widget.controller.document.toPlainText(); - final newText = value.text; - final diff = fastDiff(oldText, newText, cursorPosition); - widget.controller.replaceText( - diff.start, diff.deleted.length, diff.inserted, - selection: value.selection); - } - - @override - void bringIntoView(ui.TextPosition position) { - // TODO: implement bringIntoView - } - - bool get isToolbarVisible => _toolbar != null; - bool get isToolbarHidden => _toolbar == null; - - @override - void hideToolbar() { - _didCaretTap = false; // reset double tap. - _toolbar?.remove(); - _toolbar = null; - _toolbarController.stop(); - } - - void showToolbar() { - final scope = ZefyrScope.of(context); - assert(scope != null); - final toolbarOpacity = _toolbarController.view; - _toolbar = new OverlayEntry( - builder: (context) => new FadeTransition( - opacity: toolbarOpacity, - child: new _SelectionToolbar( - scope: scope, - controls: widget.controls, - delegate: this, - ), - ), - ); - widget.overlay.insert(_toolbar); - _toolbarController.forward(from: 0.0); - } - - // - // Overridden members of State - // - - @override - void initState() { - super.initState(); - _toolbarController = new AnimationController( - duration: _kFadeDuration, vsync: widget.overlay); - } - - static const Duration _kFadeDuration = const Duration(milliseconds: 150); - - @override - void didUpdateWidget(ZefyrSelectionOverlay oldWidget) { - super.didUpdateWidget(oldWidget); - if (oldWidget.overlay != widget.overlay) { - hideToolbar(); - _toolbarController.dispose(); - _toolbarController = new AnimationController( - duration: _kFadeDuration, vsync: widget.overlay); - } - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - final editor = ZefyrScope.of(context); - if (_editor != editor) { - _editor?.removeListener(_handleChange); - _editor = editor; - _editor.addListener(_handleChange); - _selection = _editor.selection; - _focusOwner = _editor.focusOwner; - } - } - - @override - void dispose() { - _editor.removeListener(_handleChange); - hideToolbar(); - _toolbarController.dispose(); - _toolbarController = null; - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final overlay = new GestureDetector( - behavior: HitTestBehavior.translucent, - onTapDown: _handleTapDown, - onTap: _handleTap, - onTapCancel: _handleTapCancel, - onLongPress: _handleLongPress, - child: new Stack( - fit: StackFit.expand, - children: [ - new SelectionHandleDriver( - position: _SelectionHandlePosition.base, - controls: widget.controls, - ), - new SelectionHandleDriver( - position: _SelectionHandlePosition.extent, - controls: widget.controls, - ), - ], - ), - ); - return new Container(child: overlay); - } - - // - // Private members - // - - /// Global position of last TapDown event. - Offset _lastTapDownPosition; - - /// Global position of last TapDown which is potentially a long press. - Offset _longPressPosition; - - OverlayEntry _toolbar; - AnimationController _toolbarController; - - ZefyrScope _editor; - TextSelection _selection; - FocusOwner _focusOwner; - - bool _didCaretTap = false; - - void _handleChange() { - if (_selection != _editor.selection || _focusOwner != _editor.focusOwner) { - _updateToolbar(); - } - } - - void _updateToolbar() { - if (!mounted) { - return; - } - - final selection = _editor.selection; - final focusOwner = _editor.focusOwner; - setState(() { - if (focusOwner != FocusOwner.editor) { - hideToolbar(); - } else { - if (_selection != selection) { - if (selection.isCollapsed && isToolbarVisible) hideToolbar(); - _toolbar?.markNeedsBuild(); - if (!selection.isCollapsed && isToolbarHidden) showToolbar(); - } else { - if (!selection.isCollapsed && isToolbarHidden) { - showToolbar(); - } else if (isToolbarVisible) { - _toolbar?.markNeedsBuild(); - } - } - } - _selection = selection; - _focusOwner = focusOwner; - }); - } - - void _handleTapDown(TapDownDetails details) { - _lastTapDownPosition = details.globalPosition; - } - - void _handleTapCancel() { - // longPress arrives after tapCancel, so remember the tap position. - _longPressPosition = _lastTapDownPosition; - _lastTapDownPosition = null; - } - - void _handleTap() { - assert(_lastTapDownPosition != null); - final globalPoint = _lastTapDownPosition; - _lastTapDownPosition = null; - HitTestResult result = new HitTestResult(); - WidgetsBinding.instance.hitTest(result, globalPoint); - - RenderEditableProxyBox box = _getEditableBox(result); - if (box == null) { - box = _editor.renderContext.closestBoxForGlobalPoint(globalPoint); - } - if (box == null) return null; - - final localPoint = box.globalToLocal(globalPoint); - final position = box.getPositionForOffset(localPoint); - final selection = new TextSelection.collapsed( - offset: position.offset, - affinity: position.affinity, - ); - if (_didCaretTap && _selection == selection) { - _didCaretTap = false; - if (isToolbarVisible) { - hideToolbar(); - } else { - showToolbar(); - } - } else { - _didCaretTap = true; - } - widget.controller.updateSelection(selection, source: ChangeSource.local); - } - - void _handleLongPress() { - final Offset globalPoint = _longPressPosition; - _longPressPosition = null; - HitTestResult result = new HitTestResult(); - WidgetsBinding.instance.hitTest(result, globalPoint); - final box = _getEditableBox(result); - if (box == null) { - return; - } - final localPoint = box.globalToLocal(globalPoint); - final position = box.getPositionForOffset(localPoint); - final word = box.getWordBoundary(position); - final selection = new TextSelection( - baseOffset: word.start, - extentOffset: word.end, - ); - widget.controller.updateSelection(selection, source: ChangeSource.local); - } - - @override - bool get copyEnabled => true; - - @override - bool get cutEnabled => true; - - @override - bool get pasteEnabled => true; - - @override - bool get selectAllEnabled => true; -} - -enum _SelectionHandlePosition { base, extent } - -class SelectionHandleDriver extends StatefulWidget { - const SelectionHandleDriver({ - Key key, - @required this.position, - @required this.controls, - }) : super(key: key); - - final _SelectionHandlePosition position; - final TextSelectionControls controls; - - @override - _SelectionHandleDriverState createState() => - new _SelectionHandleDriverState(); -} - -class _SelectionHandleDriverState extends State { - ZefyrScope _scope; - - /// Current document selection. - TextSelection get selection => _selection; - TextSelection _selection; - - /// Returns `true` if this handle is located at the baseOffset of selection. - bool get isBaseHandle => widget.position == _SelectionHandlePosition.base; - - /// Character offset of this handle in the document. - /// - /// For base handle this equals to [TextSelection.baseOffset] and for - /// extent handle - [TextSelection.extentOffset]. - int get documentOffset => - isBaseHandle ? selection.baseOffset : selection.extentOffset; - - /// Position in pixels of this selection handle within its paragraph [block]. - Offset getPosition(RenderEditableBox block) { - if (block == null) return null; - - final localSelection = block.getLocalSelection(selection); - assert(localSelection != null); - - final boxes = block.getEndpointsForSelection(selection); - assert(boxes.isNotEmpty, 'Got empty boxes for selection ${selection}'); - - final box = isBaseHandle ? boxes.first : boxes.last; - final dx = isBaseHandle ? box.start : box.end; - return new Offset(dx, box.bottom); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - final scope = ZefyrScope.of(context); - if (_scope != scope) { - _scope?.removeListener(_handleScopeChange); - _scope = scope; - _scope.addListener(_handleScopeChange); - } - _selection = _scope.selection; - } - - @override - void dispose() { - _scope?.removeListener(_handleScopeChange); - super.dispose(); - } - - // - // Overridden members - // - - @override - Widget build(BuildContext context) { - if (selection == null || - selection.isCollapsed || - widget.controls == null || - _scope.focusOwner != FocusOwner.editor) { - return new Container(); - } - final block = _scope.renderContext.boxForTextOffset(documentOffset); - final position = getPosition(block); - Widget handle; - if (position == null) { - handle = new Container(); - } else { - final handleType = isBaseHandle - ? TextSelectionHandleType.left - : TextSelectionHandleType.right; - handle = new Positioned( - left: position.dx, - top: position.dy, - child: widget.controls.buildHandle( - context, - handleType, - block.preferredLineHeight, - ), - ); - handle = new CompositedTransformFollower( - link: block.layerLink, - showWhenUnlinked: false, - child: new Stack( - overflow: Overflow.visible, - children: [handle], - ), - ); - } - // Always return this gesture detector even if handle is an empty container - // This way we prevent drag gesture from being canceled in case current - // position is somewhere outside of any visible paragraph block. - return new GestureDetector( - onPanStart: _handleDragStart, - onPanUpdate: _handleDragUpdate, - child: handle, - ); - } - - // - // Private members - // - - Offset _dragPosition; - - void _handleScopeChange() { - if (_selection != _scope.selection) { - setState(() { - _selection = _scope.selection; - }); - } - } - - void _handleDragStart(DragStartDetails details) { - _dragPosition = details.globalPosition; - } - - void _handleDragUpdate(DragUpdateDetails details) { - _dragPosition += details.delta; - final globalPoint = _dragPosition; - final paragraph = _scope.renderContext.boxForGlobalPoint(globalPoint); - if (paragraph == null) { - return; - } - - final localPoint = paragraph.globalToLocal(globalPoint); - final position = paragraph.getPositionForOffset(localPoint); - final newSelection = selection.copyWith( - baseOffset: isBaseHandle ? position.offset : selection.baseOffset, - extentOffset: isBaseHandle ? selection.extentOffset : position.offset, - ); - if (newSelection.baseOffset >= newSelection.extentOffset) { - // Don't allow reversed or collapsed selection. - return; - } - - if (newSelection != _selection) { - _scope.updateSelection(newSelection, source: ChangeSource.local); - } - } -} - -class _SelectionToolbar extends StatefulWidget { - const _SelectionToolbar({ - Key key, - @required this.scope, - @required this.controls, - @required this.delegate, - }) : super(key: key); - - final ZefyrScope scope; - final TextSelectionControls controls; - final TextSelectionDelegate delegate; - - @override - _SelectionToolbarState createState() => new _SelectionToolbarState(); -} - -class _SelectionToolbarState extends State<_SelectionToolbar> { - ZefyrScope get editable => widget.scope; - TextSelection get selection => widget.delegate.textEditingValue.selection; - - @override - Widget build(BuildContext context) { - return _buildToolbar(context); - } - - Widget _buildToolbar(BuildContext context) { - final base = selection.baseOffset; - // TODO: Editable is not refreshed and may contain stale renderContext instance. - final block = editable.renderContext.boxForTextOffset(base); - if (block == null) { - return Container(); - } - final boxes = block.getEndpointsForSelection(selection); - // Find the horizontal midpoint, just above the selected text. - final Offset midpoint = new Offset( - (boxes.length == 1) - ? (boxes[0].start + boxes[0].end) / 2.0 - : (boxes[0].start + boxes[1].start) / 2.0, - boxes[0].bottom - block.preferredLineHeight, - ); - - final Rect editingRegion = new Rect.fromPoints( - block.localToGlobal(Offset.zero), - block.localToGlobal(block.size.bottomRight(Offset.zero)), - ); -// final toolbar = widget.controls -// .buildToolbar(context, editingRegion, midpoint, widget.delegate); - final Offset endpoint = new Offset( - (boxes.length == 1) - ? (boxes[0].start + boxes[0].end) - : (boxes[0].start + boxes[1].start), - boxes[0].bottom - block.preferredLineHeight, - ); - final TextSelectionPoint textEndpoint = new TextSelectionPoint(endpoint, TextDirection.ltr); - final toolbar = widget.controls - .buildToolbar(context, editingRegion,0.0, midpoint, [textEndpoint], widget.delegate); - return new CompositedTransformFollower( - link: block.layerLink, - showWhenUnlinked: false, - offset: -editingRegion.topLeft, - child: toolbar, - ); - } -} diff --git a/zefyr/lib/src/widgets/theme.dart b/zefyr/lib/src/widgets/theme.dart deleted file mode 100644 index 0f7c1160..00000000 --- a/zefyr/lib/src/widgets/theme.dart +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:meta/meta.dart'; - -/// Applies a Zefyr editor theme to descendant widgets. -/// -/// Describes colors and typographic styles for an editor. -/// -/// Descendant widgets obtain the current theme's [ZefyrThemeData] object using -/// [ZefyrTheme.of]. -/// -/// See also: -/// -/// * [ZefyrThemeData], which describes actual configuration of a theme. -class ZefyrTheme extends InheritedWidget { - final ZefyrThemeData data; - - /// Applies the given theme [data] to [child]. - /// - /// The [data] and [child] arguments must not be null. - ZefyrTheme({ - Key key, - @required this.data, - @required Widget child, - }) : assert(data != null), - assert(child != null), - super(key: key, child: child); - - @override - bool updateShouldNotify(ZefyrTheme oldWidget) { - return data != oldWidget.data; - } - - /// The data from the closest [ZefyrTheme] instance that encloses the given - /// context. - /// - /// Returns `null` if there is no [ZefyrTheme] in the given build context - /// and [nullOk] is set to `true`. If [nullOk] is set to `false` (default) - /// then this method asserts. - static ZefyrThemeData of(BuildContext context, {bool nullOk: false}) { - final ZefyrTheme widget = context.inheritFromWidgetOfExactType(ZefyrTheme); - if (widget == null && nullOk) return null; - assert(widget != null, - '$ZefyrTheme.of() called with a context that does not contain a ZefyrEditor.'); - return widget.data; - } -} - -/// Holds colors and typography styles for [ZefyrEditor]. -class ZefyrThemeData { - final TextStyle boldStyle; - final TextStyle italicStyle; - final TextStyle linkStyle; - final StyleTheme paragraphTheme; - final HeadingTheme headingTheme; - final BlockTheme blockTheme; - final Color selectionColor; - final Color cursorColor; - - /// Size of indentation for blocks. - final double indentSize; - final ZefyrToolbarTheme toolbarTheme; - - factory ZefyrThemeData.fallback(BuildContext context) { - final defaultStyle = DefaultTextStyle.of(context); - final paragraphStyle = defaultStyle.style.copyWith( - fontSize: 16.0, - height: 1.25, - fontWeight: FontWeight.normal, - color: Colors.grey.shade800, - ); - final padding = const EdgeInsets.only(bottom: 16.0); - final boldStyle = new TextStyle(fontWeight: FontWeight.bold); - final italicStyle = new TextStyle(fontStyle: FontStyle.italic); - final linkStyle = - TextStyle(color: Colors.blue, decoration: TextDecoration.underline); - - return new ZefyrThemeData( - boldStyle: boldStyle, - italicStyle: italicStyle, - linkStyle: linkStyle, - paragraphTheme: - new StyleTheme(textStyle: paragraphStyle, padding: padding), - headingTheme: new HeadingTheme.fallback(), - blockTheme: new BlockTheme.fallback(), - selectionColor: Colors.lightBlueAccent.shade100, - cursorColor: Colors.black, - indentSize: 16.0, - toolbarTheme: new ZefyrToolbarTheme.fallback(context), - ); - } - - const ZefyrThemeData({ - this.boldStyle, - this.italicStyle, - this.linkStyle, - this.paragraphTheme, - this.headingTheme, - this.blockTheme, - this.selectionColor, - this.cursorColor, - this.indentSize, - this.toolbarTheme, - }); - - ZefyrThemeData copyWith({ - TextStyle textStyle, - TextStyle boldStyle, - TextStyle italicStyle, - TextStyle linkStyle, - StyleTheme paragraphTheme, - HeadingTheme headingTheme, - BlockTheme blockTheme, - Color selectionColor, - Color cursorColor, - double indentSize, - ZefyrToolbarTheme toolbarTheme, - }) { - return new ZefyrThemeData( - boldStyle: boldStyle ?? this.boldStyle, - italicStyle: italicStyle ?? this.italicStyle, - linkStyle: linkStyle ?? this.linkStyle, - paragraphTheme: paragraphTheme ?? this.paragraphTheme, - headingTheme: headingTheme ?? this.headingTheme, - blockTheme: blockTheme ?? this.blockTheme, - selectionColor: selectionColor ?? this.selectionColor, - cursorColor: cursorColor ?? this.cursorColor, - indentSize: indentSize ?? this.indentSize, - toolbarTheme: toolbarTheme ?? this.toolbarTheme, - ); - } - - ZefyrThemeData merge(ZefyrThemeData other) { - return copyWith( - boldStyle: other.boldStyle, - italicStyle: other.italicStyle, - linkStyle: other.linkStyle, - paragraphTheme: other.paragraphTheme, - headingTheme: other.headingTheme, - blockTheme: other.blockTheme, - selectionColor: other.selectionColor, - cursorColor: other.cursorColor, - indentSize: other.indentSize, - toolbarTheme: other.toolbarTheme, - ); - } -} - -/// Theme for heading-styled lines of text. -class HeadingTheme { - /// Style theme for level 1 headings. - final StyleTheme level1; - - /// Style theme for level 2 headings. - final StyleTheme level2; - - /// Style theme for level 3 headings. - final StyleTheme level3; - - HeadingTheme({ - @required this.level1, - @required this.level2, - @required this.level3, - }); - - /// Creates fallback theme for headings. - factory HeadingTheme.fallback() { - return HeadingTheme( - level1: StyleTheme( - textStyle: TextStyle( - fontSize: 30.0, - color: Colors.grey.shade800, - height: 1.25, - fontWeight: FontWeight.w600, - ), - padding: EdgeInsets.only(top: 16.0, bottom: 16.0), - ), - level2: StyleTheme( - textStyle: TextStyle( - fontSize: 24.0, - color: Colors.grey.shade800, - height: 1.25, - fontWeight: FontWeight.w600, - ), - padding: EdgeInsets.only(bottom: 8.0, top: 8.0), - ), - level3: StyleTheme( - textStyle: TextStyle( - fontSize: 20.0, - color: Colors.grey.shade800, - height: 1.25, - fontWeight: FontWeight.w600, - ), - padding: EdgeInsets.only(bottom: 8.0, top: 8.0), - ), - ); - } -} - -/// Theme for a block of lines in a document. -class BlockTheme { - /// Style theme for bullet lists. - final StyleTheme bulletList; - - /// Style theme for number lists. - final StyleTheme numberList; - - /// Style theme for code snippets. - final StyleTheme code; - - /// Style theme for quotes. - final StyleTheme quote; - - BlockTheme({ - @required this.bulletList, - @required this.numberList, - @required this.quote, - @required this.code, - }); - - /// Creates fallback theme for blocks. - factory BlockTheme.fallback() { - final padding = const EdgeInsets.only(bottom: 8.0); - return new BlockTheme( - bulletList: new StyleTheme(padding: padding), - numberList: new StyleTheme(padding: padding), - quote: new StyleTheme( - textStyle: new TextStyle(color: Colors.grey.shade700), - padding: padding, - ), - code: new StyleTheme( - textStyle: new TextStyle( - color: Colors.blueGrey.shade800, - fontFamily: Platform.isIOS ? 'Menlo' : 'Roboto Mono', - fontSize: 14.0, - height: 1.25, - ), - padding: padding, - ), - ); - } -} - -/// Theme for a specific attribute style. -/// -/// Used in [HeadingTheme] and [BlockTheme], as well as in -/// [ZefyrThemeData.paragraphTheme]. -class StyleTheme { - /// Text style of this theme. - final TextStyle textStyle; - - /// Padding to apply around lines of text. - final EdgeInsets padding; - - /// Creates a new [StyleTheme]. - StyleTheme({ - this.textStyle, - this.padding, - }); -} - -/// Defines styles and colors for [ZefyrToolbar]. -class ZefyrToolbarTheme { - /// The background color of toolbar. - final Color color; - - /// Color of buttons in toggled state. - final Color toggleColor; - - /// Color of button icons. - final Color iconColor; - - /// Color of button icons in disabled state. - final Color disabledIconColor; - - /// Creates fallback theme for editor toolbars. - factory ZefyrToolbarTheme.fallback(BuildContext context) { - final theme = Theme.of(context); - return ZefyrToolbarTheme._( - color: theme.primaryColorLight, - toggleColor: theme.primaryColor, - iconColor: theme.primaryIconTheme.color, - disabledIconColor: theme.primaryColor, - ); - } - - ZefyrToolbarTheme._({ - @required this.color, - @required this.toggleColor, - @required this.iconColor, - @required this.disabledIconColor, - }); - - ZefyrToolbarTheme copyWith({ - Color color, - Color toggleColor, - Color iconColor, - Color disabledIconColor, - }) { - return ZefyrToolbarTheme._( - color: color ?? this.color, - toggleColor: toggleColor ?? this.toggleColor, - iconColor: iconColor ?? this.iconColor, - disabledIconColor: disabledIconColor ?? this.disabledIconColor, - ); - } -} diff --git a/zefyr/lib/src/widgets/toolbar.dart b/zefyr/lib/src/widgets/toolbar.dart deleted file mode 100644 index d9364cbf..00000000 --- a/zefyr/lib/src/widgets/toolbar.dart +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -import 'dart:async'; -import 'dart:ui' as ui; - -import 'package:flutter/material.dart'; -import 'package:notus/notus.dart'; - -import 'buttons.dart'; -import 'scope.dart'; -import 'theme.dart'; - -/// List of all button actions supported by [ZefyrToolbar] buttons. -enum ZefyrToolbarAction { - bold, - italic, - link, - unlink, - clipboardCopy, - openInBrowser, - heading, - headingLevel1, - headingLevel2, - headingLevel3, - bulletList, - numberList, - code, - quote, - horizontalRule, - image, - cameraImage, - galleryImage, - hideKeyboard, - close, - confirm, -} - -final kZefyrToolbarAttributeActions = { - ZefyrToolbarAction.bold: NotusAttribute.bold, - ZefyrToolbarAction.italic: NotusAttribute.italic, - ZefyrToolbarAction.link: NotusAttribute.link, - ZefyrToolbarAction.heading: NotusAttribute.heading, - ZefyrToolbarAction.headingLevel1: NotusAttribute.heading.level1, - ZefyrToolbarAction.headingLevel2: NotusAttribute.heading.level2, - ZefyrToolbarAction.headingLevel3: NotusAttribute.heading.level3, - ZefyrToolbarAction.bulletList: NotusAttribute.block.bulletList, - ZefyrToolbarAction.numberList: NotusAttribute.block.numberList, - ZefyrToolbarAction.code: NotusAttribute.block.code, - ZefyrToolbarAction.quote: NotusAttribute.block.quote, - ZefyrToolbarAction.horizontalRule: NotusAttribute.embed.horizontalRule, -}; - -/// Allows customizing appearance of [ZefyrToolbar]. -abstract class ZefyrToolbarDelegate { - /// Builds toolbar button for specified [action]. - /// - /// Returned widget is usually an instance of [ZefyrButton]. - Widget buildButton(BuildContext context, ZefyrToolbarAction action, - {VoidCallback onPressed}); -} - -/// Scaffold for [ZefyrToolbar]. -class ZefyrToolbarScaffold extends StatelessWidget { - const ZefyrToolbarScaffold({ - Key key, - @required this.body, - this.trailing, - this.autoImplyTrailing: true, - }) : super(key: key); - - final Widget body; - final Widget trailing; - final bool autoImplyTrailing; - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context).toolbarTheme; - final toolbar = ZefyrToolbar.of(context); - final constraints = - BoxConstraints.tightFor(height: ZefyrToolbar.kToolbarHeight); - final children = [ - Expanded(child: body), - ]; - - if (trailing != null) { - children.add(trailing); - } else if (autoImplyTrailing) { - children.add(toolbar.buildButton(context, ZefyrToolbarAction.close)); - } - return new Container( - constraints: constraints, - child: Material(color: theme.color, child: Row(children: children)), - ); - } -} - -/// Toolbar for [ZefyrEditor]. -class ZefyrToolbar extends StatefulWidget implements PreferredSizeWidget { - static const kToolbarHeight = 50.0; - - const ZefyrToolbar({ - Key key, - @required this.editor, - this.autoHide: true, - this.delegate, - }) : super(key: key); - - final ZefyrToolbarDelegate delegate; - final ZefyrScope editor; - - /// Whether to automatically hide this toolbar when editor loses focus. - final bool autoHide; - - static ZefyrToolbarState of(BuildContext context) { - final _ZefyrToolbarScope scope = - context.inheritFromWidgetOfExactType(_ZefyrToolbarScope); - return scope?.toolbar; - } - - @override - ZefyrToolbarState createState() => ZefyrToolbarState(); - - @override - ui.Size get preferredSize => new Size.fromHeight(ZefyrToolbar.kToolbarHeight); -} - -class _ZefyrToolbarScope extends InheritedWidget { - _ZefyrToolbarScope({Key key, @required Widget child, @required this.toolbar}) - : super(key: key, child: child); - - final ZefyrToolbarState toolbar; - - @override - bool updateShouldNotify(_ZefyrToolbarScope oldWidget) { - return toolbar != oldWidget.toolbar; - } -} - -class ZefyrToolbarState extends State - with SingleTickerProviderStateMixin { - final Key _toolbarKey = UniqueKey(); - final Key _overlayKey = UniqueKey(); - - ZefyrToolbarDelegate _delegate; - AnimationController _overlayAnimation; - WidgetBuilder _overlayBuilder; - Completer _overlayCompleter; - - TextSelection _selection; - - void markNeedsRebuild() { - setState(() { - if (_selection != editor.selection) { - _selection = editor.selection; - closeOverlay(); - } - }); - } - - Widget buildButton(BuildContext context, ZefyrToolbarAction action, - {VoidCallback onPressed}) { - return _delegate.buildButton(context, action, onPressed: onPressed); - } - - Future showOverlay(WidgetBuilder builder) async { - assert(_overlayBuilder == null); - final completer = new Completer(); - setState(() { - _overlayBuilder = builder; - _overlayCompleter = completer; - _overlayAnimation.forward(); - }); - return completer.future; - } - - void closeOverlay() { - if (!hasOverlay) return; - _overlayAnimation.reverse().whenComplete(() { - setState(() { - _overlayBuilder = null; - _overlayCompleter?.complete(); - _overlayCompleter = null; - }); - }); - } - - bool get hasOverlay => _overlayBuilder != null; - - ZefyrScope get editor => widget.editor; - - @override - void initState() { - super.initState(); - _delegate = widget.delegate ?? new _DefaultZefyrToolbarDelegate(); - _overlayAnimation = new AnimationController( - vsync: this, duration: Duration(milliseconds: 100)); - _selection = editor.selection; - } - - @override - void didUpdateWidget(ZefyrToolbar oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.delegate != oldWidget.delegate) { - _delegate = widget.delegate ?? new _DefaultZefyrToolbarDelegate(); - } - } - - @override - void dispose() { - _overlayAnimation.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final layers = []; - - // Must set unique key for the toolbar to prevent it from reconstructing - // new state each time we toggle overlay. - final toolbar = ZefyrToolbarScaffold( - key: _toolbarKey, - body: ZefyrButtonList(buttons: _buildButtons(context)), - trailing: buildButton(context, ZefyrToolbarAction.hideKeyboard), - ); - - layers.add(toolbar); - - if (hasOverlay) { - Widget widget = new Builder(builder: _overlayBuilder); - assert(widget != null); - final overlay = FadeTransition( - key: _overlayKey, - opacity: _overlayAnimation, - child: widget, - ); - layers.add(overlay); - } - - final constraints = - BoxConstraints.tightFor(height: ZefyrToolbar.kToolbarHeight); - return _ZefyrToolbarScope( - toolbar: this, - child: Container( - constraints: constraints, - child: Stack(children: layers), - ), - ); - } - - List _buildButtons(BuildContext context) { - final buttons = [ - buildButton(context, ZefyrToolbarAction.bold), - buildButton(context, ZefyrToolbarAction.italic), - LinkButton(), - HeadingButton(), - buildButton(context, ZefyrToolbarAction.bulletList), - buildButton(context, ZefyrToolbarAction.numberList), - buildButton(context, ZefyrToolbarAction.quote), - buildButton(context, ZefyrToolbarAction.code), - buildButton(context, ZefyrToolbarAction.horizontalRule), - ImageButton(), - ]; - return buttons; - } -} - -/// Scrollable list of toolbar buttons. -class ZefyrButtonList extends StatefulWidget { - const ZefyrButtonList({Key key, @required this.buttons}) : super(key: key); - final List buttons; - - @override - _ZefyrButtonListState createState() => _ZefyrButtonListState(); -} - -class _ZefyrButtonListState extends State { - final ScrollController _controller = new ScrollController(); - bool _showLeftArrow = false; - bool _showRightArrow = false; - - @override - void initState() { - super.initState(); - _controller.addListener(_handleScroll); - // Workaround to allow scroll controller attach to our ListView so that - // we can detect if overflow arrows need to be shown on init. - // TODO: find a better way to detect overflow - Timer.run(_handleScroll); - } - - @override - Widget build(BuildContext context) { - final theme = ZefyrTheme.of(context).toolbarTheme; - final color = theme.iconColor; - final list = ListView( - scrollDirection: Axis.horizontal, - controller: _controller, - children: widget.buttons, - physics: ClampingScrollPhysics(), - ); - - final leftArrow = _showLeftArrow - ? Icon(Icons.arrow_left, size: 18.0, color: color) - : null; - final rightArrow = _showRightArrow - ? Icon(Icons.arrow_right, size: 18.0, color: color) - : null; - return Row( - children: [ - SizedBox( - width: 12.0, - height: ZefyrToolbar.kToolbarHeight, - child: Container(child: leftArrow, color: theme.color), - ), - Expanded(child: ClipRect(child: list)), - SizedBox( - width: 12.0, - height: ZefyrToolbar.kToolbarHeight, - child: Container(child: rightArrow, color: theme.color), - ), - ], - ); - } - - void _handleScroll() { - setState(() { - _showLeftArrow = - _controller.position.minScrollExtent != _controller.position.pixels; - _showRightArrow = - _controller.position.maxScrollExtent != _controller.position.pixels; - }); - } -} - -class _DefaultZefyrToolbarDelegate implements ZefyrToolbarDelegate { - static const kDefaultButtonIcons = { - ZefyrToolbarAction.bold: Icons.format_bold, - ZefyrToolbarAction.italic: Icons.format_italic, - ZefyrToolbarAction.link: Icons.link, - ZefyrToolbarAction.unlink: Icons.link_off, - ZefyrToolbarAction.clipboardCopy: Icons.content_copy, - ZefyrToolbarAction.openInBrowser: Icons.open_in_new, - ZefyrToolbarAction.heading: Icons.format_size, - ZefyrToolbarAction.bulletList: Icons.format_list_bulleted, - ZefyrToolbarAction.numberList: Icons.format_list_numbered, - ZefyrToolbarAction.code: Icons.code, - ZefyrToolbarAction.quote: Icons.format_quote, - ZefyrToolbarAction.horizontalRule: Icons.remove, - ZefyrToolbarAction.image: Icons.photo, - ZefyrToolbarAction.cameraImage: Icons.photo_camera, - ZefyrToolbarAction.galleryImage: Icons.photo_library, - ZefyrToolbarAction.hideKeyboard: Icons.keyboard_hide, - ZefyrToolbarAction.close: Icons.close, - ZefyrToolbarAction.confirm: Icons.check, - }; - - static const kSpecialIconSizes = { - ZefyrToolbarAction.unlink: 20.0, - ZefyrToolbarAction.clipboardCopy: 20.0, - ZefyrToolbarAction.openInBrowser: 20.0, - ZefyrToolbarAction.close: 20.0, - ZefyrToolbarAction.confirm: 20.0, - }; - - static const kDefaultButtonTexts = { - ZefyrToolbarAction.headingLevel1: 'H1', - ZefyrToolbarAction.headingLevel2: 'H2', - ZefyrToolbarAction.headingLevel3: 'H3', - }; - - @override - Widget buildButton(BuildContext context, ZefyrToolbarAction action, - {VoidCallback onPressed}) { - final theme = Theme.of(context); - if (kDefaultButtonIcons.containsKey(action)) { - final icon = kDefaultButtonIcons[action]; - final size = kSpecialIconSizes[action]; - return ZefyrButton.icon( - action: action, - icon: icon, - iconSize: size, - onPressed: onPressed, - ); - } else { - final text = kDefaultButtonTexts[action]; - assert(text != null); - final style = theme.textTheme.caption - .copyWith(fontWeight: FontWeight.bold, fontSize: 14.0); - return ZefyrButton.text( - action: action, - text: text, - style: style, - onPressed: onPressed, - ); - } - } -} diff --git a/zefyr/lib/src/widgets/view.dart b/zefyr/lib/src/widgets/view.dart deleted file mode 100644 index d7b7b13e..00000000 --- a/zefyr/lib/src/widgets/view.dart +++ /dev/null @@ -1,107 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:meta/meta.dart'; -import 'package:notus/notus.dart'; - -import 'code.dart'; -import 'common.dart'; -import 'image.dart'; -import 'list.dart'; -import 'paragraph.dart'; -import 'quote.dart'; -import 'scope.dart'; -import 'theme.dart'; - -/// Non-scrollable read-only view of Notus rich text documents. -@experimental -class ZefyrView extends StatefulWidget { - final NotusDocument document; - final ZefyrImageDelegate imageDelegate; - - const ZefyrView({Key key, @required this.document, this.imageDelegate}) - : super(key: key); - - @override - ZefyrViewState createState() => ZefyrViewState(); -} - -class ZefyrViewState extends State { - ZefyrScope _scope; - ZefyrThemeData _themeData; - - ZefyrImageDelegate get imageDelegate => widget.imageDelegate; - - @override - void initState() { - super.initState(); - _scope = ZefyrScope.view(imageDelegate: widget.imageDelegate); - } - - @override - void didUpdateWidget(ZefyrView oldWidget) { - super.didUpdateWidget(oldWidget); - _scope.imageDelegate = widget.imageDelegate; - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - final parentTheme = ZefyrTheme.of(context, nullOk: true); - final fallbackTheme = ZefyrThemeData.fallback(context); - _themeData = (parentTheme != null) - ? fallbackTheme.merge(parentTheme) - : fallbackTheme; - } - - @override - void dispose() { - _scope.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return ZefyrTheme( - data: _themeData, - child: ZefyrScopeAccess( - scope: _scope, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: _buildChildren(context), - ), - ), - ); - } - - List _buildChildren(BuildContext context) { - final result = []; - for (var node in widget.document.root.children) { - result.add(_defaultChildBuilder(context, node)); - } - return result; - } - - Widget _defaultChildBuilder(BuildContext context, Node node) { - if (node is LineNode) { - if (node.hasEmbed) { - return new RawZefyrLine(node: node); - } else if (node.style.contains(NotusAttribute.heading)) { - return new ZefyrHeading(node: node); - } - return new ZefyrParagraph(node: node); - } - - final BlockNode block = node; - final blockStyle = block.style.get(NotusAttribute.block); - if (blockStyle == NotusAttribute.block.code) { - return new ZefyrCode(node: block); - } else if (blockStyle == NotusAttribute.block.bulletList) { - return new ZefyrList(node: block); - } else if (blockStyle == NotusAttribute.block.numberList) { - return new ZefyrList(node: block); - } else if (blockStyle == NotusAttribute.block.quote) { - return new ZefyrQuote(node: block); - } - - throw new UnimplementedError('Block format $blockStyle.'); - } -} diff --git a/zefyr/lib/util.dart b/zefyr/lib/util.dart deleted file mode 100644 index 7ef640e8..00000000 --- a/zefyr/lib/util.dart +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// Utility functions for Zefyr. -library zefyr.util; - -import 'dart:math' as math; - -import 'package:quill_delta/quill_delta.dart'; - -export 'src/fast_diff.dart'; - -int getPositionDelta(Delta user, Delta actual) { - final userIter = new DeltaIterator(user); - final actualIter = new DeltaIterator(actual); - int diff = 0; - while (userIter.hasNext || actualIter.hasNext) { - num length = math.min(userIter.peekLength(), actualIter.peekLength()); - final userOp = userIter.next(length); - final actualOp = actualIter.next(length); - assert(userOp.length == actualOp.length); - if (userOp.key == actualOp.key) continue; - if (userOp.isInsert && actualOp.isRetain) { - diff -= userOp.length; - } else if (userOp.isDelete && actualOp.isRetain) { - diff += userOp.length; - } else if (userOp.isRetain && actualOp.isInsert) { - if (actualOp.data.startsWith('\n') ) { - // At this point user input reached its end (retain). If a heuristic - // rule inserts a new line we should keep cursor on it's original position. - continue; - } - diff += actualOp.length; - } else { - // TODO: this likely needs to cover more edge cases. - } - } - return diff; -} diff --git a/zefyr/lib/zefyr.dart b/zefyr/lib/zefyr.dart deleted file mode 100644 index 846ba5f5..00000000 --- a/zefyr/lib/zefyr.dart +++ /dev/null @@ -1,22 +0,0 @@ -library zefyr; - -export 'package:notus/notus.dart'; - -export 'src/widgets/buttons.dart' hide HeadingButton, LinkButton; -export 'src/widgets/code.dart'; -export 'src/widgets/common.dart'; -export 'src/widgets/controller.dart'; -export 'src/widgets/editable_text.dart'; -export 'src/widgets/editor.dart'; -export 'src/widgets/field.dart'; -export 'src/widgets/horizontal_rule.dart'; -export 'src/widgets/image.dart'; -export 'src/widgets/list.dart'; -export 'src/widgets/paragraph.dart'; -export 'src/widgets/quote.dart'; -export 'src/widgets/scaffold.dart'; -export 'src/widgets/scope.dart' hide ZefyrScopeAccess; -export 'src/widgets/selection.dart' hide SelectionHandleDriver; -export 'src/widgets/theme.dart'; -export 'src/widgets/toolbar.dart'; -export 'src/widgets/view.dart'; \ No newline at end of file diff --git a/zefyr/pubspec.yaml b/zefyr/pubspec.yaml deleted file mode 100644 index 24625589..00000000 --- a/zefyr/pubspec.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: zefyr -description: A new Flutter package project. -version: 0.0.1 -author: Anatoly Pulyaevskiy -homepage: - -environment: - sdk: ">=2.1.0 <3.0.0" - -dependencies: - flutter: - sdk: flutter - collection: ^1.14.6 - url_launcher: ^5.0.0 - image_picker: ^0.5.0 - quill_delta: ^1.0.0-dev.1.0 - notus: ^0.1.0 - meta: ^1.1.0 - -dev_dependencies: - flutter_test: - sdk: flutter - -# 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: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # To add custom fonts to your package, 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 in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/zefyr/test/zefyr_test.dart b/zefyr/test/zefyr_test.dart deleted file mode 100644 index f9502254..00000000 --- a/zefyr/test/zefyr_test.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:zefyr/zefyr.dart'; - -void main() { -// test('adds one to input values', () { -// final calculator = Calculator(); -// expect(calculator.addOne(2), 3); -// expect(calculator.addOne(-7), -6); -// expect(calculator.addOne(0), 1); -// expect(() => calculator.addOne(null), throwsNoSuchMethodError); -// }); -}