From d2a37e0fd9153e138f10efefd78bd36f4415bccd Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Mon, 27 Dec 2021 15:07:49 +0800 Subject: [PATCH 01/31] =?UTF-8?q?Theme:=20=E4=BC=98=E5=8C=96=E5=8D=95?= =?UTF-8?q?=E4=BE=8B=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=88=9D=E6=AD=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20BrnAllThemeConfig=20=E5=B1=9E=E6=80=A7=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=B8=8D=E4=B8=BA=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/theme/base/brn_base_config.dart | 3 +- .../theme/base/brn_default_config_utils.dart | 7 +- lib/src/theme/brn_theme_configurator.dart | 19 +- lib/src/theme/configs/brn_all_config.dart | 217 ++++++++++++------ .../brn_enhance_number_card_config.dart | 2 +- 5 files changed, 169 insertions(+), 79 deletions(-) diff --git a/lib/src/theme/base/brn_base_config.dart b/lib/src/theme/base/brn_base_config.dart index c339629d..ebbcf3a7 100644 --- a/lib/src/theme/base/brn_base_config.dart +++ b/lib/src/theme/base/brn_base_config.dart @@ -49,6 +49,5 @@ abstract class BrnBaseConfig { _currentLevelCommonConfig ?? BrnThemeConfigurator.instance .getConfig(configId: configId) - .commonConfig ?? - BrnDefaultConfigUtils.defaultCommonConfig; + .commonConfig; } diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index 92e6f5b0..bb5207a4 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -42,12 +42,15 @@ class BrnDefaultConfigUtils { buttonConfig: defaultButtonConfig, actionSheetConfig: defaultActionSheetConfig, pickerConfig: defaultPickerConfig, - enhanceNumberCardConfig: defaultNumberInfoConfig, + enhanceNumberCardConfig: defaultEnhanceNumberInfoConfig, tabBarConfig: defaultTabBarConfig, selectionConfig: defaultSelectionConfig, galleryDetailConfig: defaultGalleryDetailConfig, ); + + + /// 全局默认配置 static BrnCommonConfig defaultCommonConfig = BrnCommonConfig( /// 主题色相关 @@ -559,7 +562,7 @@ class BrnDefaultConfigUtils { ); /// 数字增强信息配置 - static BrnEnhanceNumberCardConfig defaultNumberInfoConfig = + static BrnEnhanceNumberCardConfig defaultEnhanceNumberInfoConfig = BrnEnhanceNumberCardConfig( runningSpace: 16, itemRunningSpace: 8, diff --git a/lib/src/theme/brn_theme_configurator.dart b/lib/src/theme/brn_theme_configurator.dart index 999b03a3..392030cb 100644 --- a/lib/src/theme/brn_theme_configurator.dart +++ b/lib/src/theme/brn_theme_configurator.dart @@ -5,9 +5,19 @@ const String BRUNO_CONFIG_ID = 'BRUNO_CONFIG_ID'; const String GLOBAL_CONFIG_ID = 'GLOBAL_CONFIG_ID'; class BrnThemeConfigurator { - BrnThemeConfigurator._(); - static late final BrnThemeConfigurator instance = BrnThemeConfigurator._(); + BrnThemeConfigurator._(){ + _checkAndInitBrunoConfig(); + } + + static BrnThemeConfigurator? _instance; + + static get instance { + if (null == _instance) { + _instance = BrnThemeConfigurator._(); + } + return _instance!; + } Map globalConfig = {}; @@ -16,12 +26,10 @@ class BrnThemeConfigurator { BrnAllThemeConfig? allThemeConfig, { String configId = GLOBAL_CONFIG_ID, }) { - // 先赋值默认配置 - _checkAndInitBrunoConfig(); // 打平内部字段 if (allThemeConfig != null) { // 赋值传入配置 - instance.globalConfig[configId] = allThemeConfig + globalConfig[configId] = allThemeConfig ..initThemeConfig(configId); } } @@ -31,7 +39,6 @@ class BrnThemeConfigurator { /// 2、若获取的为 null,则使用默认的全局配置。 /// 3、若没有配置 GLOBAL_CONFIG_ID ,则使用 BRUNO 的配置。 BrnAllThemeConfig getConfig({String configId = GLOBAL_CONFIG_ID}) { - _checkAndInitBrunoConfig(); BrnAllThemeConfig? allThemeConfig = globalConfig[configId] ?? globalConfig[GLOBAL_CONFIG_ID] ?? diff --git a/lib/src/theme/configs/brn_all_config.dart b/lib/src/theme/configs/brn_all_config.dart index 5d5712ff..d0ca3e93 100644 --- a/lib/src/theme/configs/brn_all_config.dart +++ b/lib/src/theme/configs/brn_all_config.dart @@ -1,3 +1,4 @@ +import 'package:bruno/bruno.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_abnormal_state_config.dart'; import 'package:bruno/src/theme/configs/brn_action_sheet_config.dart'; @@ -24,119 +25,199 @@ import 'package:bruno/src/theme/configs/brn_tag_config.dart'; /// 当没有配置组件的特定属性时使用上一级特定配置 class BrnAllThemeConfig { BrnAllThemeConfig({ - required this.commonConfig, - this.appBarConfig, - this.buttonConfig, - this.dialogConfig, - this.formItemConfig, - this.cardTitleConfig, - this.abnormalStateConfig, - this.tagConfig, - this.pairInfoTableConfig, - this.pairRichInfoGridConfig, - this.actionSheetConfig, - this.pickerConfig, - this.enhanceNumberCardConfig, - this.tabBarConfig, - this.selectionConfig, - this.galleryDetailConfig, + commonConfig, + appBarConfig, + buttonConfig, + dialogConfig, + formItemConfig, + cardTitleConfig, + abnormalStateConfig, + tagConfig, + pairInfoTableConfig, + pairRichInfoGridConfig, + actionSheetConfig, + pickerConfig, + enhanceNumberCardConfig, + tabBarConfig, + selectionConfig, + galleryDetailConfig, String configId = GLOBAL_CONFIG_ID, - }); - - BrnCommonConfig? commonConfig; - BrnAppBarConfig? appBarConfig; - BrnButtonConfig? buttonConfig; - BrnDialogConfig? dialogConfig; - BrnCardTitleConfig? cardTitleConfig; - BrnAbnormalStateConfig? abnormalStateConfig; - BrnTagConfig? tagConfig; - BrnPairInfoTableConfig? pairInfoTableConfig; - BrnPairRichInfoGridConfig? pairRichInfoGridConfig; - BrnActionSheetConfig? actionSheetConfig; - BrnPickerConfig? pickerConfig; - BrnEnhanceNumberCardConfig? enhanceNumberCardConfig; - BrnTabBarConfig? tabBarConfig; - BrnFormItemConfig? formItemConfig; - BrnSelectionConfig? selectionConfig; - BrnGalleryDetailConfig? galleryDetailConfig; + }) : _commonConfig = commonConfig, + _appBarConfig = appBarConfig, + _buttonConfig = buttonConfig, + _dialogConfig = dialogConfig, + _formItemConfig = formItemConfig, + _cardTitleConfig = cardTitleConfig, + _abnormalStateConfig = abnormalStateConfig, + _tagConfig = tagConfig, + _pairInfoTableConfig = pairInfoTableConfig, + _pairRichInfoGridConfig = pairRichInfoGridConfig, + _actionSheetConfig = actionSheetConfig, + _pickerConfig = pickerConfig, + _enhanceNumberCardConfig = enhanceNumberCardConfig, + _tabBarConfig = tabBarConfig, + _selectionConfig = selectionConfig, + _galleryDetailConfig = galleryDetailConfig; + + BrnCommonConfig? _commonConfig; + + BrnCommonConfig get commonConfig => + _commonConfig ?? BrnDefaultConfigUtils.defaultCommonConfig; + + BrnAppBarConfig? _appBarConfig; + + BrnAppBarConfig get appBarConfig => + _appBarConfig ?? BrnDefaultConfigUtils.defaultAppBarConfig; + + BrnButtonConfig? _buttonConfig; + + BrnButtonConfig get buttonConfig => + _buttonConfig ?? BrnDefaultConfigUtils.defaultButtonConfig; + + BrnDialogConfig? _dialogConfig; + + BrnDialogConfig get dialogConfig => + _dialogConfig ?? BrnDefaultConfigUtils.defaultDialogConfig; + + BrnCardTitleConfig? _cardTitleConfig; + + BrnCardTitleConfig get cardTitleConfig => + _cardTitleConfig ?? BrnDefaultConfigUtils.defaultCardTitleConfig; + + BrnAbnormalStateConfig? _abnormalStateConfig; + + BrnAbnormalStateConfig get abnormalStateConfig => + _abnormalStateConfig ?? BrnDefaultConfigUtils.defaultAbnormalStateConfig; + + BrnTagConfig? _tagConfig; + + BrnTagConfig get tagConfig => + _tagConfig ?? BrnDefaultConfigUtils.defaultTagConfig; + + BrnPairInfoTableConfig? _pairInfoTableConfig; + + BrnPairInfoTableConfig get pairInfoTableConfig => + _pairInfoTableConfig ?? BrnDefaultConfigUtils.defaultPairInfoTableConfig; + + BrnPairRichInfoGridConfig? _pairRichInfoGridConfig; + + BrnPairRichInfoGridConfig get pairRichInfoGridConfig => + _pairRichInfoGridConfig ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig; + + BrnActionSheetConfig? _actionSheetConfig; + + BrnActionSheetConfig get actionSheetConfig => + _actionSheetConfig ?? BrnDefaultConfigUtils.defaultActionSheetConfig; + + BrnPickerConfig? _pickerConfig; + + BrnPickerConfig get pickerConfig => + _pickerConfig ?? BrnDefaultConfigUtils.defaultPickerConfig; + + BrnEnhanceNumberCardConfig? _enhanceNumberCardConfig; + + BrnEnhanceNumberCardConfig get enhanceNumberCardConfig => + _enhanceNumberCardConfig ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig; + + BrnTabBarConfig? _tabBarConfig; + + BrnTabBarConfig get tabBarConfig => + _tabBarConfig ?? BrnDefaultConfigUtils.defaultTabBarConfig; + + BrnFormItemConfig? _formItemConfig; + + BrnFormItemConfig get formItemConfig => + _formItemConfig ?? BrnDefaultConfigUtils.defaultFormItemConfig; + + BrnSelectionConfig? _selectionConfig; + + BrnSelectionConfig get selectionConfig => + _selectionConfig ?? BrnDefaultConfigUtils.defaultSelectionConfig; + + BrnGalleryDetailConfig? _galleryDetailConfig; + + BrnGalleryDetailConfig get galleryDetailConfig => + _galleryDetailConfig ?? BrnDefaultConfigUtils.defaultGalleryDetailConfig; void initThemeConfig(String configId) { - this.commonConfig ??= BrnCommonConfig(); - this.appBarConfig ??= BrnAppBarConfig(); - this.buttonConfig ??= BrnButtonConfig(); - this.dialogConfig ??= BrnDialogConfig(); - this.formItemConfig ??= BrnFormItemConfig(); - this.cardTitleConfig ??= BrnCardTitleConfig(); - this.abnormalStateConfig ??= BrnAbnormalStateConfig(); - this.tagConfig ??= BrnTagConfig(); - this.appBarConfig ??= BrnAppBarConfig(); - this.pairInfoTableConfig ??= BrnPairInfoTableConfig(); - this.pairRichInfoGridConfig ??= BrnPairRichInfoGridConfig(); - this.actionSheetConfig ??= BrnActionSheetConfig(); - this.pickerConfig ??= BrnPickerConfig(); - this.enhanceNumberCardConfig ??= BrnEnhanceNumberCardConfig(); - this.tabBarConfig ??= BrnTabBarConfig(); - this.selectionConfig ??= BrnSelectionConfig(); - this.galleryDetailConfig ??= BrnGalleryDetailConfig(); - - commonConfig?.initThemeConfig(configId); - appBarConfig?.initThemeConfig( + this._commonConfig ??= BrnCommonConfig(); + this._appBarConfig ??= BrnAppBarConfig(); + this._buttonConfig ??= BrnButtonConfig(); + this._dialogConfig ??= BrnDialogConfig(); + this._formItemConfig ??= BrnFormItemConfig(); + this._cardTitleConfig ??= BrnCardTitleConfig(); + this._abnormalStateConfig ??= BrnAbnormalStateConfig(); + this._tagConfig ??= BrnTagConfig(); + this._appBarConfig ??= BrnAppBarConfig(); + this._pairInfoTableConfig ??= BrnPairInfoTableConfig(); + this._pairRichInfoGridConfig ??= BrnPairRichInfoGridConfig(); + this._actionSheetConfig ??= BrnActionSheetConfig(); + this._pickerConfig ??= BrnPickerConfig(); + this._enhanceNumberCardConfig ??= BrnEnhanceNumberCardConfig(); + this._tabBarConfig ??= BrnTabBarConfig(); + this._selectionConfig ??= BrnSelectionConfig(); + this._galleryDetailConfig ??= BrnGalleryDetailConfig(); + + commonConfig.initThemeConfig(configId); + appBarConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - buttonConfig?.initThemeConfig( + buttonConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - dialogConfig?.initThemeConfig( + dialogConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - formItemConfig?.initThemeConfig( + formItemConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - cardTitleConfig?.initThemeConfig( + cardTitleConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - abnormalStateConfig?.initThemeConfig( + abnormalStateConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - tagConfig?.initThemeConfig( + tagConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pairInfoTableConfig?.initThemeConfig( + pairInfoTableConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pairRichInfoGridConfig?.initThemeConfig( + pairRichInfoGridConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - selectionConfig?.initThemeConfig( + selectionConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - actionSheetConfig?.initThemeConfig( + actionSheetConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - pickerConfig?.initThemeConfig( + pickerConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - enhanceNumberCardConfig?.initThemeConfig( + enhanceNumberCardConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - tabBarConfig?.initThemeConfig( + tabBarConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); - galleryDetailConfig?.initThemeConfig( + galleryDetailConfig.initThemeConfig( configId, currentLevelCommonConfig: commonConfig, ); diff --git a/lib/src/theme/configs/brn_enhance_number_card_config.dart b/lib/src/theme/configs/brn_enhance_number_card_config.dart index 8e710f8b..d0243fd4 100644 --- a/lib/src/theme/configs/brn_enhance_number_card_config.dart +++ b/lib/src/theme/configs/brn_enhance_number_card_config.dart @@ -6,7 +6,7 @@ import 'package:bruno/src/theme/configs/brn_common_config.dart'; /// 强化数字展示组件配置 class BrnEnhanceNumberCardConfig extends BrnBaseConfig { /// 遵循外部主题配置 - /// 默认为 [BrnDefaultConfigUtils.defaultNumberInfoConfig] + /// 默认为 [BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig] BrnEnhanceNumberCardConfig({ this.runningSpace, this.itemRunningSpace, From 75a2be37de2eb59568b4c982a33aa629ed675c58 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 28 Dec 2021 00:42:45 +0800 Subject: [PATCH 02/31] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96theme,?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E9=9D=9Enull=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/ios/Podfile | 86 +-- example/ios/Runner.xcodeproj/project.pbxproj | 16 - .../contents.xcworkspacedata | 2 +- example/lib/main.dart | 3 + .../items_example/title_select_example.dart | 2 +- .../scroll_actor_tab_example.dart | 1 + lib/src/components/navbar/brn_appbar.dart | 4 +- .../components/sugsearch/brn_search_text.dart | 2 +- .../theme/base/brn_default_config_utils.dart | 180 ++--- .../configs/brn_abnormal_state_config.dart | 137 ++-- .../configs/brn_action_sheet_config.dart | 191 +++-- lib/src/theme/configs/brn_all_config.dart | 32 +- lib/src/theme/configs/brn_appbar_config.dart | 256 ++++--- lib/src/theme/configs/brn_button_config.dart | 95 ++- .../theme/configs/brn_card_title_config.dart | 147 ++-- lib/src/theme/configs/brn_common_config.dart | 682 ++++++++++++------ lib/src/theme/configs/brn_dialog_config.dart | 404 +++++++---- .../brn_enhance_number_card_config.dart | 86 ++- lib/src/theme/configs/brn_form_config.dart | 297 +++++--- .../configs/brn_gallery_detail_config.dart | 336 +++++---- .../theme/configs/brn_pair_info_config.dart | 192 +++-- lib/src/theme/configs/brn_picker_config.dart | 182 +++-- .../theme/configs/brn_selection_config.dart | 455 +++++++----- lib/src/theme/configs/brn_tabbar_config.dart | 221 ++++-- lib/src/theme/configs/brn_tag_config.dart | 125 ++-- 25 files changed, 2539 insertions(+), 1595 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index b30a428b..08502eec 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,90 +1,10 @@ -# Uncomment this line to define a global platform for your project +# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; - end - generated_key_values = {} - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) do |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - generated_key_values[podname] = podpath - else - puts "Invalid plugin specification: #{line}" - end - end - generated_key_values -end - target 'Runner' do + # Comment the next line if you don't want to use dynamic frameworks use_frameworks! - use_modular_headers! - - # Flutter Pod - - copied_flutter_dir = File.join(__dir__, 'Flutter') - copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') - copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') - unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) - # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. - # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. - # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. - - generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') - unless File.exist?(generated_xcode_build_settings_path) - raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) - cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; - - unless File.exist?(copied_framework_path) - FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) - end - unless File.exist?(copied_podspec_path) - FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) - end - end - - # Keep pod path relative so it can be checked into Podfile.lock. - pod 'Flutter', :path => 'Flutter' - - # Plugin Pods - - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf .symlinks') - system('mkdir -p .symlinks/plugins') - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.each do |name, path| - symlink = File.join('.symlinks', 'plugins', name) - File.symlink(path, symlink) - pod name, :path => File.join(symlink, 'ios') - end -end -# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. -install! 'cocoapods', :disable_input_output_paths => true + # Pods for Runner -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end - end end diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index bacab8cf..e891e69b 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -146,7 +146,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - DC926F330116FD87C8E402BA /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -256,21 +255,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - DC926F330116FD87C8E402BA /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16..919434a6 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/lib/main.dart b/example/lib/main.dart index 202b0652..ec337f68 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,8 +1,11 @@ +import 'package:bruno/bruno.dart'; import 'package:example/sample/home/home.dart'; import 'package:flutter/material.dart'; void main() { + BrnInitializer.register(allThemeConfig: BrnAllThemeConfig(appBarConfig: BrnAppBarConfig(backgroundColor:Colors.orange))); runApp(MyApp()); + } class MyApp extends StatelessWidget { diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index 698237bf..9fe73327 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -47,7 +47,7 @@ class TitleSelectInputState extends State { title: _list[0], hint: "请输入", controller: controller, - inputFormatters: [FilteringTextInputFormatter(RegExp('[0-9"]'))], + inputFormatters: [FilteringTextInputFormatter.digitsOnly], selectedIndex: -1, selectList: _list, onTip: () { diff --git a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart index 9060636a..0182569e 100644 --- a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart +++ b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart @@ -8,6 +8,7 @@ class ScrollActorTabExample extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: BrnAppBar( + themeData: BrnAppBarConfig(backgroundColor: Colors.green), title: '锚点', ), body: BrnAnchorTab( diff --git a/lib/src/components/navbar/brn_appbar.dart b/lib/src/components/navbar/brn_appbar.dart index be1d1efc..23e426c6 100644 --- a/lib/src/components/navbar/brn_appbar.dart +++ b/lib/src/components/navbar/brn_appbar.dart @@ -276,12 +276,12 @@ class BrnAppBar extends PreferredSize { .merge(_defaultConfig); Widget flexibleSpace; - if (_defaultConfig.flexibleSpace != null) { + if (this.flexibleSpace != null) { flexibleSpace = Container( height: _defaultConfig.appBarHeight + MediaQueryData.fromWindow(window)?.padding?.top ?? 0, - child: _defaultConfig.flexibleSpace, + child: this.flexibleSpace, ); } diff --git a/lib/src/components/sugsearch/brn_search_text.dart b/lib/src/components/sugsearch/brn_search_text.dart index 98656f3c..421cb5a2 100644 --- a/lib/src/components/sugsearch/brn_search_text.dart +++ b/lib/src/components/sugsearch/brn_search_text.dart @@ -271,7 +271,7 @@ class _SearchTextState extends State { child: GestureDetector( onTap: () { if (widget.onTextClear != null) { - bool isIntercept = widget.onTextClear!() ?? false; + bool isIntercept = widget.onTextClear!(); if (isIntercept) return; } textEditingController!.clear(); diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index bb5207a4..66861fb3 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -122,29 +122,29 @@ class BrnDefaultConfigUtils { /// 文本字号 /// /// 特殊数据展示,DIN Condensed数字字体,用于强吸引 - fontSizeDIN: 28, + fontSizeDIN: 28.0, /// 标题字体 /// 名称/页面大标题 - fontSizeHeadLg: 22, + fontSizeHeadLg: 22.0, /// 标题字体 /// 内容模块标题/一级标题 - fontSizeHead: 18, + fontSizeHead: 18.0, /// 子标题字体 /// 标题/录入文字/大按钮文字/二级标题 - fontSizeSubHead: 16, + fontSizeSubHead: 16.0, /// 基础字体 /// 内容副文本/普通说明文字 - fontSizeBase: 14, + fontSizeBase: 14.0, /// 辅助字体-普通 - fontSizeCaption: 12, + fontSizeCaption: 12.0, ///辅助字体-小 - fontSizeCaptionSm: 11, + fontSizeCaptionSm: 11.0, /// 圆角尺寸 radiusXs: 2.0, @@ -154,31 +154,31 @@ class BrnDefaultConfigUtils { /// 边框尺寸 borderWidthSm: 0.5, - borderWidthMd: 1, - borderWidthLg: 2, + borderWidthMd: 1.0, + borderWidthLg: 2.0, /// 水平间距 - hSpacingXs: 8, - hSpacingSm: 12, - hSpacingMd: 16, - hSpacingLg: 20, - hSpacingXl: 24, - hSpacingXxl: 42, + hSpacingXs: 8.0, + hSpacingSm: 12.0, + hSpacingMd: 16.0, + hSpacingLg: 20.0, + hSpacingXl: 24.0, + hSpacingXxl: 42.0, /// 垂直间距 - vSpacingXs: 4, - vSpacingSm: 8, - vSpacingMd: 12, - vSpacingLg: 14, - vSpacingXl: 16, - vSpacingXxl: 28, + vSpacingXs: 4.0, + vSpacingSm: 8.0, + vSpacingMd: 12.0, + vSpacingLg: 14.0, + vSpacingXl: 16.0, + vSpacingXxl: 28.0, /// 图标大小 - iconSizeXxs: 8, - iconSizeXs: 12, - iconSizeSm: 14, - iconSizeMd: 16, - iconSizeLg: 32, + iconSizeXxs: 8.0, + iconSizeXs: 12.0, + iconSizeSm: 14.0, + iconSizeMd: 16.0, + iconSizeLg: 32.0, ); ///******** 以下是子配置项 ********/// @@ -210,7 +210,7 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, ), optionsMiddlePadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingMd ?? 0, + left: defaultCommonConfig.hSpacingMd, ), optionTextStyle: BrnTextStyle( height: 1.3, @@ -223,20 +223,20 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, ), formPadding: EdgeInsets.only( - left: 0, - top: defaultCommonConfig.vSpacingLg ?? 0, - right: defaultCommonConfig.hSpacingLg ?? 0, - bottom: defaultCommonConfig.vSpacingLg ?? 0, + left: 0.0, + top: defaultCommonConfig.vSpacingLg , + right: defaultCommonConfig.hSpacingLg , + bottom: defaultCommonConfig.vSpacingLg, ), titlePaddingSm: EdgeInsets.only(left: 10), - titlePaddingLg: EdgeInsets.only(left: defaultCommonConfig.hSpacingLg ?? 0), + titlePaddingLg: EdgeInsets.only(left: defaultCommonConfig.hSpacingLg), subTitlePadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingLg ?? 0, - top: defaultCommonConfig.vSpacingXs ?? 0, + left: defaultCommonConfig.hSpacingLg, + top: defaultCommonConfig.vSpacingXs, ), errorPadding: EdgeInsets.only( - left: defaultCommonConfig.hSpacingLg ?? 0, - top: defaultCommonConfig.vSpacingXs ?? 0, + left: defaultCommonConfig.hSpacingLg, + top: defaultCommonConfig.vSpacingXs, ), disableTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextDisabled, @@ -250,18 +250,18 @@ class BrnDefaultConfigUtils { /// Dialog默认配置 static BrnDialogConfig defaultDialogConfig = BrnDialogConfig( - dialogWidth: 300, + dialogWidth: 300.0, radius: defaultCommonConfig.radiusLg, - iconPadding: EdgeInsets.only(top: defaultCommonConfig.vSpacingXxl ?? 0), + iconPadding: EdgeInsets.only(top: defaultCommonConfig.vSpacingXxl), titlePaddingSm: EdgeInsets.only( - top: 12, - left: defaultCommonConfig.hSpacingXxl ?? 0, - right: defaultCommonConfig.hSpacingXxl ?? 0, + top: 12.0, + left: defaultCommonConfig.hSpacingXxl, + right: defaultCommonConfig.hSpacingXxl, ), titlePaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXxl ?? 0, - right: defaultCommonConfig.hSpacingXxl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXxl, + right: defaultCommonConfig.hSpacingXxl, ), titleTextStyle: BrnTextStyle( fontWeight: FontWeight.w600, @@ -270,14 +270,14 @@ class BrnDefaultConfigUtils { ), titleTextAlign: TextAlign.center, contentPaddingSm: EdgeInsets.only( - top: 8, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 8.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), contentPaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), contentTextStyle: BrnTextStyle( fontSize: defaultCommonConfig.fontSizeBase, @@ -286,14 +286,14 @@ class BrnDefaultConfigUtils { ), contentTextAlign: TextAlign.center, warningPaddingSm: EdgeInsets.only( - top: 6, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 6.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), warningPaddingLg: EdgeInsets.only( - top: 28, - left: defaultCommonConfig.hSpacingXl ?? 0, - right: defaultCommonConfig.hSpacingXl ?? 0, + top: 28.0, + left: defaultCommonConfig.hSpacingXl, + right: defaultCommonConfig.hSpacingXl, ), warningTextAlign: TextAlign.center, warningTextStyle: BrnTextStyle( @@ -301,7 +301,7 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.brandError, decoration: TextDecoration.none, ), - dividerPadding: EdgeInsets.only(top: 28), + dividerPadding: EdgeInsets.only(top: 28.0), mainActionTextStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontWeight: FontWeight.w600, @@ -323,7 +323,7 @@ class BrnDefaultConfigUtils { titleWithHeightTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeHead, - height: 25 / 18, + height: 25.0 / 18.0, fontWeight: FontWeight.w600, ), titleTextStyle: BrnTextStyle( @@ -344,8 +344,8 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeBase, ), cardTitlePadding: EdgeInsets.only( - top: defaultCommonConfig.vSpacingXl ?? 0, - bottom: defaultCommonConfig.vSpacingMd ?? 0, + top: defaultCommonConfig.vSpacingXl, + bottom: defaultCommonConfig.vSpacingMd, ), alignment: PlaceholderAlignment.middle, cardBackgroundColor: defaultCommonConfig.fillBase, @@ -376,8 +376,8 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.colorTextBaseInverse, fontSize: defaultCommonConfig.fontSizeSubHead, ), - singleMinWidth: 160, - doubleMinWidth: 120, + singleMinWidth: 160.0, + doubleMinWidth: 120.0, ); /// 标签配置 @@ -394,11 +394,12 @@ class BrnDefaultConfigUtils { tagBackgroundColor: defaultCommonConfig.fillBody, selectedTagBackgroundColor: defaultCommonConfig.brandPrimary, tagRadius: defaultCommonConfig.radiusXs, - tagHeight: 34, - tagWidth: 75, - tagMinWidth: 75, + tagHeight: 34.0, + tagWidth: 75.0, + tagMinWidth: 75.0, ); + /// 导航栏配置 static BrnAppBarConfig defaultAppBarConfig = BrnAppBarConfig( backgroundColor: Colors.white, @@ -421,7 +422,7 @@ class BrnDefaultConfigUtils { fontWeight: FontWeight.w600, ), titleMaxLength: BrnAppBarTheme.maxLength, - leftAndRightPadding: 20, + leftAndRightPadding: 20.0, itemSpacing: BrnAppBarTheme.iconMargin, titlePadding: EdgeInsets.zero, iconSize: BrnAppBarTheme.iconSize, @@ -452,9 +453,9 @@ class BrnDefaultConfigUtils { /// 内容信息(一列)配置 static BrnPairRichInfoGridConfig defaultPairRichInfoGridConfig = BrnPairRichInfoGridConfig( - rowSpacing: 4, - itemSpacing: 2, - itemHeight: 20, + rowSpacing: 4.0, + itemSpacing: 2.0, + itemHeight: 20.0, keyTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextSecondary, fontSize: defaultCommonConfig.fontSizeBase, @@ -475,12 +476,12 @@ class BrnDefaultConfigUtils { /// 按钮配置 static BrnButtonConfig defaultButtonConfig = BrnButtonConfig( - bigButtonRadius: 6, - bigButtonHeight: 48, - bigButtonFontSize: 16, - smallButtonRadius: 4, - smallButtonHeight: 32, - smallButtonFontSize: 14, + bigButtonRadius: 6.0, + bigButtonHeight: 48.0, + bigButtonFontSize: 16.0, + smallButtonRadius: 4.0, + smallButtonHeight: 32.0, + smallButtonFontSize: 14.0, configId: BRUNO_CONFIG_ID, ); @@ -525,8 +526,8 @@ class BrnDefaultConfigUtils { fontSize: defaultCommonConfig.fontSizeSubHead, fontWeight: FontWeight.w600, ), - titlePadding: EdgeInsets.symmetric(horizontal: 60, vertical: 16), - contentPadding: EdgeInsets.symmetric(horizontal: 60, vertical: 12), + titlePadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 16.0), + contentPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 12.0), ); static BrnPickerConfig defaultPickerConfig = BrnPickerConfig( @@ -564,11 +565,11 @@ class BrnDefaultConfigUtils { /// 数字增强信息配置 static BrnEnhanceNumberCardConfig defaultEnhanceNumberInfoConfig = BrnEnhanceNumberCardConfig( - runningSpace: 16, - itemRunningSpace: 8, - titleTextStyle: BrnTextStyle(fontSize: 28, fontWeight: FontWeight.w600), + runningSpace: 16.0, + itemRunningSpace: 8.0, + titleTextStyle: BrnTextStyle(fontSize: 28.0, fontWeight: FontWeight.w600), descTextStyle: BrnTextStyle( - fontSize: 12, + fontSize: 12.0, color: defaultCommonConfig.colorTextSecondary, ), dividerWidth: 0.5, @@ -576,9 +577,10 @@ class BrnDefaultConfigUtils { /// TabBar配置 static BrnTabBarConfig defaultTabBarConfig = BrnTabBarConfig( - tabHeight: 50, - indicatorHeight: 2, - indicatorWidth: 24, + backgroundColor: Colors.white, + tabHeight: 50.0, + indicatorHeight: 2.0, + indicatorWidth: 24.0, labelStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontSize: defaultCommonConfig.fontSizeSubHead, @@ -594,15 +596,15 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeCaption, ), - tagNormalBgColor: defaultCommonConfig.brandPrimary?.withAlpha(0x14), + tagNormalBgColor: defaultCommonConfig.brandPrimary.withAlpha(0x14), tagSelectedTextStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontSize: defaultCommonConfig.fontSizeCaption, ), tagSelectedBgColor: defaultCommonConfig.fillBody, - tagSpacing: 12, + tagSpacing: 12.0, preLineTagCount: 4, - tagHeight: 32, + tagHeight: 32.0, ); /// 筛选项配置 @@ -628,7 +630,7 @@ class BrnDefaultConfigUtils { tagRadius: defaultCommonConfig.radiusSm, tagNormalBackgroundColor: defaultCommonConfig.fillBody, tagSelectedBackgroundColor: - defaultCommonConfig.brandPrimary?.withOpacity(0.12), + defaultCommonConfig.brandPrimary.withOpacity(0.12), rangeTitleTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeSubHead, @@ -711,7 +713,7 @@ class BrnDefaultConfigUtils { appbarBackgroundColor: Colors.black, appbarBrightness: Brightness.dark, tabBarUnSelectedLabelStyle: BrnTextStyle( - fontSize: 16, + fontSize: 16.0, color: Color(0XFFCCCCCC), ), tabBarLabelStyle: BrnTextStyle( diff --git a/lib/src/theme/configs/brn_abnormal_state_config.dart b/lib/src/theme/configs/brn_abnormal_state_config.dart index 805dc1ad..d39a889b 100644 --- a/lib/src/theme/configs/brn_abnormal_state_config.dart +++ b/lib/src/theme/configs/brn_abnormal_state_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -6,16 +7,24 @@ import 'package:bruno/src/theme/configs/brn_common_config.dart'; /// 描述: 空页面配置类 class BrnAbnormalStateConfig extends BrnBaseConfig { BrnAbnormalStateConfig({ - this.titleTextStyle, - this.contentTextStyle, - this.operateTextStyle, - this.btnRadius, - this.singleTextStyle, - this.doubleTextStyle, - this.singleMinWidth, - this.doubleMinWidth, + BrnTextStyle? titleTextStyle, + BrnTextStyle? contentTextStyle, + BrnTextStyle? operateTextStyle, + double? btnRadius, + BrnTextStyle? singleTextStyle, + BrnTextStyle? doubleTextStyle, + double? singleMinWidth, + double? doubleMinWidth, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleTextStyle = titleTextStyle, + _contentTextStyle = contentTextStyle, + _operateTextStyle = operateTextStyle, + _btnRadius = btnRadius, + _singleTextStyle = singleTextStyle, + _doubleTextStyle = doubleTextStyle, + _singleMinWidth = singleMinWidth, + _doubleMinWidth = doubleMinWidth, + super(configId: configId); /// 文案区域标题 /// @@ -24,7 +33,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 文案区域内容 /// @@ -32,7 +41,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; /// 操作区域文本样式 /// @@ -40,11 +49,11 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? operateTextStyle; + BrnTextStyle? _operateTextStyle; /// 圆角 /// default value is [BrnCommonConfig.radiusSm] - double? btnRadius; + double? _btnRadius; /// 单按钮文本样式 /// @@ -52,7 +61,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBaseInverse], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? singleTextStyle; + BrnTextStyle? _singleTextStyle; /// 双按钮文本样式 /// @@ -60,15 +69,46 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? doubleTextStyle; + BrnTextStyle? _doubleTextStyle; /// 单按钮的按钮最小宽度 /// 默认值为 160 - double? singleMinWidth; + double? _singleMinWidth; /// 多按钮的按钮最小宽度 /// 默认值为 120 - double? doubleMinWidth; + double? _doubleMinWidth; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.titleTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.contentTextStyle; + + BrnTextStyle get operateTextStyle => + _operateTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.operateTextStyle; + + double get btnRadius => + _btnRadius ?? BrnDefaultConfigUtils.defaultAbnormalStateConfig.btnRadius; + + BrnTextStyle get singleTextStyle => + _singleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.singleTextStyle; + + BrnTextStyle get doubleTextStyle => + _doubleTextStyle ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.doubleTextStyle; + + double get singleMinWidth => + _singleMinWidth ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.singleMinWidth; + + double get doubleMinWidth => + _doubleMinWidth ?? + BrnDefaultConfigUtils.defaultAbnormalStateConfig.doubleMinWidth; @override void initThemeConfig( @@ -81,43 +121,43 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnAbnormalStateConfig? abnormalStateConfig = BrnThemeConfigurator.instance + BrnAbnormalStateConfig abnormalStateConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .abnormalStateConfig; - titleTextStyle = abnormalStateConfig?.titleTextStyle?.merge( + _titleTextStyle = abnormalStateConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, ).merge(titleTextStyle), ); - contentTextStyle = abnormalStateConfig?.contentTextStyle?.merge( + _contentTextStyle = abnormalStateConfig.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeSubHead, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - operateTextStyle = abnormalStateConfig?.operateTextStyle?.merge( + _operateTextStyle = abnormalStateConfig.operateTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(operateTextStyle), + ).merge(_operateTextStyle), ); - singleTextStyle = abnormalStateConfig?.singleTextStyle?.merge( + _singleTextStyle = abnormalStateConfig.singleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, - ).merge(singleTextStyle), + ).merge(_singleTextStyle), ); - doubleTextStyle = abnormalStateConfig?.doubleTextStyle?.merge( + _doubleTextStyle = abnormalStateConfig.doubleTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(doubleTextStyle), + ).merge(_doubleTextStyle), ); - btnRadius ??= abnormalStateConfig?.btnRadius; - singleMinWidth ??= abnormalStateConfig?.singleMinWidth; - doubleMinWidth ??= abnormalStateConfig?.doubleMinWidth; + _btnRadius ??= abnormalStateConfig._btnRadius; + _singleMinWidth ??= abnormalStateConfig._singleMinWidth; + _doubleMinWidth ??= abnormalStateConfig._doubleMinWidth; } BrnAbnormalStateConfig copyWith({ @@ -131,33 +171,28 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { double? doubleMinWidth, }) { return BrnAbnormalStateConfig( - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - operateTextStyle: operateTextStyle ?? this.operateTextStyle, - btnRadius: btnRadius ?? this.btnRadius, - singleTextStyle: singleTextStyle ?? this.singleTextStyle, - doubleTextStyle: doubleTextStyle ?? this.doubleTextStyle, - singleMinWidth: singleMinWidth ?? this.singleMinWidth, - doubleMinWidth: doubleMinWidth ?? this.doubleMinWidth, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + operateTextStyle: operateTextStyle ?? _operateTextStyle, + btnRadius: btnRadius ?? _btnRadius, + singleTextStyle: singleTextStyle ?? _singleTextStyle, + doubleTextStyle: doubleTextStyle ?? _doubleTextStyle, + singleMinWidth: singleMinWidth ?? _singleMinWidth, + doubleMinWidth: doubleMinWidth ?? _doubleMinWidth, ); } BrnAbnormalStateConfig merge(BrnAbnormalStateConfig? other) { if (other == null) return this; return copyWith( - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - operateTextStyle: operateTextStyle?.merge(other.operateTextStyle) ?? - other.operateTextStyle, - btnRadius: other.btnRadius, - singleTextStyle: singleTextStyle?.merge(other.singleTextStyle) ?? - other.singleTextStyle, - doubleTextStyle: doubleTextStyle?.merge(other.doubleTextStyle) ?? - other.doubleTextStyle, - singleMinWidth: other.singleMinWidth, - doubleMinWidth: other.doubleMinWidth, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + operateTextStyle: operateTextStyle.merge(other._operateTextStyle), + btnRadius: other._btnRadius, + singleTextStyle: singleTextStyle.merge(other._singleTextStyle), + doubleTextStyle: doubleTextStyle.merge(other._doubleTextStyle), + singleMinWidth: other._singleMinWidth, + doubleMinWidth: other._doubleMinWidth, ); } } diff --git a/lib/src/theme/configs/brn_action_sheet_config.dart b/lib/src/theme/configs/brn_action_sheet_config.dart index 6b975ac3..b383cf94 100644 --- a/lib/src/theme/configs/brn_action_sheet_config.dart +++ b/lib/src/theme/configs/brn_action_sheet_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,23 +10,34 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultActionSheetConfig] BrnActionSheetConfig({ - this.titleStyle, - this.itemTitleStyle, - this.itemTitleStyleLink, - this.itemTitleStyleAlert, - this.itemDescStyle, - this.itemDescStyleLink, - this.itemDescStyleAlert, - this.cancelStyle, - this.topRadius, - this.contentPadding, - this.titlePadding, + BrnTextStyle? titleStyle, + BrnTextStyle? itemTitleStyle, + BrnTextStyle? itemTitleStyleLink, + BrnTextStyle? itemTitleStyleAlert, + BrnTextStyle? itemDescStyle, + BrnTextStyle? itemDescStyleLink, + BrnTextStyle? itemDescStyleAlert, + BrnTextStyle? cancelStyle, + double? topRadius, + EdgeInsets? contentPadding, + EdgeInsets? titlePadding, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleStyle = titleStyle, + _itemTitleStyle = itemTitleStyle, + _itemTitleStyleLink = itemTitleStyleLink, + _itemTitleStyleAlert = itemTitleStyleAlert, + _itemDescStyle = itemDescStyle, + _itemDescStyleLink = itemDescStyleLink, + _itemDescStyleAlert = itemDescStyleAlert, + _cancelStyle = cancelStyle, + _topRadius = topRadius, + _contentPadding = contentPadding, + _titlePadding = titlePadding, + super(configId: configId); /// ActionSheet 的顶部圆角 /// 默认值为 [BrnCommonConfig.radiusLg] - double? topRadius; + double? _topRadius; /// 标题样式 /// @@ -33,7 +45,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; /// 元素标题默认样式 /// @@ -41,7 +53,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize:[BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? itemTitleStyle; + BrnTextStyle? _itemTitleStyle; /// 元素标题链接样式 /// @@ -50,7 +62,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemTitleStyleLink; + BrnTextStyle? _itemTitleStyleLink; /// 元素警示项标题样式 /// @@ -59,7 +71,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemTitleStyleAlert; + BrnTextStyle? _itemTitleStyleAlert; /// 元素描述默认样式 /// @@ -68,7 +80,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyle; + BrnTextStyle? _itemDescStyle; /// 元素标题描述链接样式 /// @@ -77,7 +89,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyleLink; + BrnTextStyle? _itemDescStyleLink; /// 元素警示项标题描述样式 /// @@ -86,7 +98,7 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemDescStyleAlert; + BrnTextStyle? _itemDescStyleAlert; /// 取消按钮样式 /// @@ -95,17 +107,59 @@ class BrnActionSheetConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? cancelStyle; + BrnTextStyle? _cancelStyle; /// 内容左右间距 /// /// EdgeInsets.symmetric(horizontal: 60, vertical: 12) - EdgeInsets? contentPadding; + EdgeInsets? _contentPadding; /// 标题左右间距 /// /// EdgeInsets.symmetric(horizontal: 60, vertical: 16) - EdgeInsets? titlePadding; + EdgeInsets? _titlePadding; + + double get topRadius => + _topRadius ?? BrnDefaultConfigUtils.defaultActionSheetConfig.topRadius; + + BrnTextStyle get titleStyle => + _titleStyle ?? BrnDefaultConfigUtils.defaultActionSheetConfig.titleStyle; + + BrnTextStyle get itemTitleStyle => + _itemTitleStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyle; + + BrnTextStyle get itemTitleStyleLink => + _itemTitleStyleLink ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyleLink; + + BrnTextStyle get itemTitleStyleAlert => + _itemTitleStyleAlert ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemTitleStyleAlert; + + BrnTextStyle get itemDescStyle => + _itemDescStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyle; + + BrnTextStyle get itemDescStyleLink => + _itemDescStyleLink ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyleLink; + + BrnTextStyle get itemDescStyleAlert => + _itemDescStyleAlert ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.itemDescStyleAlert; + + BrnTextStyle get cancelStyle => + _cancelStyle ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.cancelStyle; + + EdgeInsets get contentPadding => + _contentPadding ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.contentPadding; + + EdgeInsets get titlePadding => + _titlePadding ?? + BrnDefaultConfigUtils.defaultActionSheetConfig.titlePadding; @override void initThemeConfig( @@ -118,61 +172,61 @@ class BrnActionSheetConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnActionSheetConfig? actionSheetConfig = BrnThemeConfigurator.instance + BrnActionSheetConfig actionSheetConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .actionSheetConfig; - titlePadding ??= actionSheetConfig?.titlePadding; - contentPadding ??= actionSheetConfig?.contentPadding; - titleStyle = actionSheetConfig?.titleStyle?.merge( + _titlePadding ??= actionSheetConfig.titlePadding; + _contentPadding ??= actionSheetConfig.contentPadding; + _titleStyle = actionSheetConfig.titleStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(titleStyle), + ).merge(_titleStyle), ); - itemTitleStyle = actionSheetConfig?.itemTitleStyle?.merge( + _itemTitleStyle = actionSheetConfig.itemTitleStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(itemTitleStyle), + ).merge(_itemTitleStyle), ); - itemTitleStyleLink = actionSheetConfig?.itemTitleStyleLink?.merge( + _itemTitleStyleLink = actionSheetConfig.itemTitleStyleLink.merge( BrnTextStyle( color: commonConfig.colorLink, fontSize: commonConfig.fontSizeSubHead, - ).merge(itemTitleStyleLink), + ).merge(_itemTitleStyleLink), ); - itemTitleStyleAlert = actionSheetConfig?.itemTitleStyleAlert?.merge( + _itemTitleStyleAlert = actionSheetConfig.itemTitleStyleAlert.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeBase, - ).merge(itemTitleStyleAlert), + ).merge(_itemTitleStyleAlert), ); - itemDescStyle = actionSheetConfig?.itemDescStyle?.merge( + _itemDescStyle = actionSheetConfig.itemDescStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyle), + ).merge(_itemDescStyle), ); - itemDescStyleLink = actionSheetConfig?.itemDescStyleLink?.merge( + _itemDescStyleLink = actionSheetConfig.itemDescStyleLink.merge( BrnTextStyle( color: commonConfig.colorLink, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyleLink), + ).merge(_itemDescStyleLink), ); - itemDescStyleAlert = actionSheetConfig?.itemDescStyleAlert?.merge( + _itemDescStyleAlert = actionSheetConfig.itemDescStyleAlert.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeCaption, - ).merge(itemDescStyleAlert), + ).merge(_itemDescStyleAlert), ); - cancelStyle = actionSheetConfig?.cancelStyle?.merge( + _cancelStyle = actionSheetConfig.cancelStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(cancelStyle), + ).merge(_cancelStyle), ); - topRadius ??= commonConfig.radiusLg; + _topRadius ??= commonConfig.radiusLg; } BrnActionSheetConfig copyWith({ @@ -189,41 +243,34 @@ class BrnActionSheetConfig extends BrnBaseConfig { EdgeInsets? titlePadding, }) { return BrnActionSheetConfig( - titleStyle: titleStyle ?? this.titleStyle, - itemTitleStyle: itemTitleStyle ?? this.itemTitleStyle, - itemTitleStyleLink: itemTitleStyleLink ?? this.itemTitleStyleLink, - itemTitleStyleAlert: itemTitleStyleAlert ?? this.itemTitleStyleAlert, - itemDescStyle: itemDescStyle ?? this.itemDescStyle, - itemDescStyleLink: itemDescStyleLink ?? this.itemDescStyleLink, - itemDescStyleAlert: itemDescStyleAlert ?? this.itemDescStyleAlert, - cancelStyle: cancelStyle ?? this.cancelStyle, - topRadius: topRadius ?? this.topRadius, - contentPadding: contentPadding ?? this.contentPadding, - titlePadding: titlePadding ?? this.titlePadding, + titleStyle: titleStyle ?? _titleStyle, + itemTitleStyle: itemTitleStyle ?? _itemTitleStyle, + itemTitleStyleLink: itemTitleStyleLink ?? _itemTitleStyleLink, + itemTitleStyleAlert: itemTitleStyleAlert ?? _itemTitleStyleAlert, + itemDescStyle: itemDescStyle ?? _itemDescStyle, + itemDescStyleLink: itemDescStyleLink ?? _itemDescStyleLink, + itemDescStyleAlert: itemDescStyleAlert ?? _itemDescStyleAlert, + cancelStyle: cancelStyle ?? _cancelStyle, + topRadius: topRadius ?? _topRadius, + contentPadding: contentPadding ?? _contentPadding, + titlePadding: titlePadding ?? _titlePadding, ); } BrnActionSheetConfig merge(BrnActionSheetConfig? other) { if (other == null) return this; return copyWith( - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - itemTitleStyle: - itemTitleStyle?.merge(other.itemTitleStyle) ?? other.itemTitleStyle, - itemTitleStyleLink: itemTitleStyleLink?.merge(other.itemTitleStyleLink) ?? - other.itemTitleStyleLink, - itemTitleStyleAlert: - itemTitleStyleAlert?.merge(other.itemTitleStyleAlert) ?? - other.itemTitleStyleAlert, - itemDescStyle: - itemDescStyle?.merge(other.itemDescStyle) ?? other.itemDescStyle, - itemDescStyleLink: itemDescStyleLink?.merge(other.itemDescStyleLink) ?? - other.itemDescStyleLink, - itemDescStyleAlert: itemDescStyleAlert?.merge(other.itemDescStyleAlert) ?? - other.itemDescStyleAlert, - cancelStyle: cancelStyle?.merge(other.cancelStyle) ?? other.cancelStyle, - topRadius: other.topRadius, - contentPadding: other.contentPadding, - titlePadding: other.titlePadding, + titleStyle: titleStyle.merge(other._titleStyle), + itemTitleStyle: itemTitleStyle.merge(other._itemTitleStyle), + itemTitleStyleLink: itemTitleStyleLink.merge(other._itemTitleStyleLink), + itemTitleStyleAlert: itemTitleStyleAlert.merge(other._itemTitleStyleAlert), + itemDescStyle: itemDescStyle.merge(other._itemDescStyle), + itemDescStyleLink: itemDescStyleLink.merge(other._itemDescStyleLink), + itemDescStyleAlert: itemDescStyleAlert.merge(other._itemDescStyleAlert), + cancelStyle: cancelStyle.merge(other._cancelStyle), + topRadius: other._topRadius, + contentPadding: other._contentPadding, + titlePadding: other._titlePadding, ); } } diff --git a/lib/src/theme/configs/brn_all_config.dart b/lib/src/theme/configs/brn_all_config.dart index d0ca3e93..fe244f36 100644 --- a/lib/src/theme/configs/brn_all_config.dart +++ b/lib/src/theme/configs/brn_all_config.dart @@ -25,22 +25,22 @@ import 'package:bruno/src/theme/configs/brn_tag_config.dart'; /// 当没有配置组件的特定属性时使用上一级特定配置 class BrnAllThemeConfig { BrnAllThemeConfig({ - commonConfig, - appBarConfig, - buttonConfig, - dialogConfig, - formItemConfig, - cardTitleConfig, - abnormalStateConfig, - tagConfig, - pairInfoTableConfig, - pairRichInfoGridConfig, - actionSheetConfig, - pickerConfig, - enhanceNumberCardConfig, - tabBarConfig, - selectionConfig, - galleryDetailConfig, + BrnCommonConfig? commonConfig, + BrnAppBarConfig? appBarConfig, + BrnButtonConfig? buttonConfig, + BrnDialogConfig? dialogConfig, + BrnFormItemConfig? formItemConfig, + BrnCardTitleConfig? cardTitleConfig, + BrnAbnormalStateConfig? abnormalStateConfig, + BrnTagConfig? tagConfig, + BrnPairInfoTableConfig? pairInfoTableConfig, + BrnPairRichInfoGridConfig? pairRichInfoGridConfig, + BrnActionSheetConfig? actionSheetConfig, + BrnPickerConfig? pickerConfig, + BrnEnhanceNumberCardConfig? enhanceNumberCardConfig, + BrnTabBarConfig? tabBarConfig, + BrnSelectionConfig? selectionConfig, + BrnGalleryDetailConfig? galleryDetailConfig, String configId = GLOBAL_CONFIG_ID, }) : _commonConfig = commonConfig, _appBarConfig = appBarConfig, diff --git a/lib/src/theme/configs/brn_appbar_config.dart b/lib/src/theme/configs/brn_appbar_config.dart index fbcf1479..c8b07521 100644 --- a/lib/src/theme/configs/brn_appbar_config.dart +++ b/lib/src/theme/configs/brn_appbar_config.dart @@ -2,6 +2,7 @@ import 'package:bruno/src/components/navbar/brn_appbar_theme.dart'; import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/constants/brn_strings_constants.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -15,36 +16,58 @@ class BrnAppBarConfig extends BrnBaseConfig { /// BrnAppBar 主题配置,遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultAppBarConfig] BrnAppBarConfig({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + Color? backgroundColor, + double? appBarHeight, + BrnWidgetBuilder? leadIconBuilder, + BrnTextStyle? titleStyle, + BrnTextStyle? actionsStyle, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, + Widget? flexibleSpace, + SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _backgroundColor = backgroundColor, + _appBarHeight = appBarHeight, + _leadIconBuilder = leadIconBuilder, + _titleStyle = titleStyle, + _actionsStyle = actionsStyle, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + _systemUiOverlayStyle = systemUiOverlayStyle, + super(configId: configId); BrnAppBarConfig.dark({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + Color? backgroundColor, + double? appBarHeight, + BrnWidgetBuilder? leadIconBuilder, + BrnTextStyle? titleStyle, + BrnTextStyle? actionsStyle, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, + Widget? flexibleSpace, + SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId) { + }) : _backgroundColor = backgroundColor, + _appBarHeight = appBarHeight, + _leadIconBuilder = leadIconBuilder, + _titleStyle = titleStyle, + _actionsStyle = actionsStyle, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + _systemUiOverlayStyle = systemUiOverlayStyle, + super(configId: configId) { backgroundColor = Color(0xff2E313B); leadIconBuilder = () => Image.asset( BrnAsset.ICON_BACK_WHITE, @@ -67,54 +90,79 @@ class BrnAppBarConfig extends BrnBaseConfig { } BrnAppBarConfig.light({ - this.backgroundColor, - this.appBarHeight, - this.leadIconBuilder, - this.titleStyle, - this.actionsStyle, - this.titleMaxLength, - this.leftAndRightPadding, - this.itemSpacing, - this.titlePadding, - this.iconSize, - this.flexibleSpace, - this.systemUiOverlayStyle, + Color? backgroundColor, + double? appBarHeight, + BrnWidgetBuilder? leadIconBuilder, + BrnTextStyle? titleStyle, + BrnTextStyle? actionsStyle, + int? titleMaxLength, + double? leftAndRightPadding, + double? itemSpacing, + EdgeInsets? titlePadding, + double? iconSize, + Widget? flexibleSpace, + SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId) { - backgroundColor = Colors.white; - leadIconBuilder = () => Image.asset( + }) : _backgroundColor = backgroundColor, + _appBarHeight = appBarHeight, + _leadIconBuilder = leadIconBuilder, + _titleStyle = titleStyle, + _actionsStyle = actionsStyle, + _titleMaxLength = titleMaxLength, + _leftAndRightPadding = leftAndRightPadding, + _itemSpacing = itemSpacing, + _titlePadding = titlePadding, + _iconSize = iconSize, + _systemUiOverlayStyle = systemUiOverlayStyle, + super(configId: configId) { + _backgroundColor = Colors.white; + _leadIconBuilder = () => Image.asset( BrnAsset.ICON_BACK_BLACK, package: BrnStrings.flutterPackageName, width: BrnAppBarTheme.iconSize, height: BrnAppBarTheme.iconSize, fit: BoxFit.fitHeight, ); - titleStyle = BrnTextStyle( + _titleStyle = BrnTextStyle( fontSize: BrnAppBarTheme.titleFontSize, fontWeight: FontWeight.w600, color: BrnAppBarTheme.lightTextColor, ); - actionsStyle = BrnTextStyle( + _actionsStyle = BrnTextStyle( color: BrnAppBarTheme.lightTextColor, fontSize: BrnAppBarTheme.actionFontSize, fontWeight: FontWeight.w600, ); - systemUiOverlayStyle = SystemUiOverlayStyle.dark; + _systemUiOverlayStyle = SystemUiOverlayStyle.dark; } /// AppBar 的背景色 - Color? backgroundColor; + Color? _backgroundColor; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultAppBarConfig.backgroundColor; /// AppBar 的高度 - double? appBarHeight; + double? _appBarHeight; + + double get appBarHeight => + _appBarHeight ?? BrnDefaultConfigUtils.defaultAppBarConfig.appBarHeight; /// 返回按钮的child widget,一般为Image - BrnWidgetBuilder? leadIconBuilder; + BrnWidgetBuilder? _leadIconBuilder; + + BrnWidgetBuilder get leadIconBuilder => + _leadIconBuilder ?? + BrnDefaultConfigUtils.defaultAppBarConfig.leadIconBuilder; /// 标题样式,仅当直接 title 设置为 String 生效 /// /// **注意**:`fontSize` 必须传大小,否则报错 - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; + + BrnTextStyle get titleStyle => + _titleStyle ?? BrnDefaultConfigUtils.defaultAppBarConfig.titleStyle; /// 右侧文字按钮样式,仅当直接actions里面元素为BrnTextAction类型生效 /// @@ -125,30 +173,52 @@ class BrnAppBarConfig extends BrnBaseConfig { /// fontSize: BrnAppBarTheme.actionFontSize, /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? actionsStyle; + BrnTextStyle? _actionsStyle; + + BrnTextStyle get actionsStyle => + _actionsStyle ?? BrnDefaultConfigUtils.defaultAppBarConfig.actionsStyle; /// AppBar title 的最大字符数 8 - int? titleMaxLength; + int? _titleMaxLength; + + int get titleMaxLength => + _titleMaxLength ?? + BrnDefaultConfigUtils.defaultAppBarConfig.titleMaxLength; /// 左右边距 - double? leftAndRightPadding; + double? _leftAndRightPadding; + + double get leftAndRightPadding => + _leftAndRightPadding ?? + BrnDefaultConfigUtils.defaultAppBarConfig.leftAndRightPadding; /// 元素间间距 - double? itemSpacing; + double? _itemSpacing; + + double get itemSpacing => + _itemSpacing ?? BrnDefaultConfigUtils.defaultAppBarConfig.itemSpacing; /// title的padding - EdgeInsets? titlePadding; + EdgeInsets? _titlePadding; + + EdgeInsets get titlePadding => + _titlePadding ?? BrnDefaultConfigUtils.defaultAppBarConfig.titlePadding; /// leadIcon 宽高,需要相同 /// 默认为 20 - double? iconSize; + double? _iconSize; + + double get iconSize => + _iconSize ?? BrnDefaultConfigUtils.defaultAppBarConfig.iconSize; - /// [AppBar] 中 flexibleSpace - Widget? flexibleSpace; /// statusBar 样式 /// 默认为 [SystemUiOverlayStyle.dark] - SystemUiOverlayStyle? systemUiOverlayStyle; + SystemUiOverlayStyle? _systemUiOverlayStyle; + + SystemUiOverlayStyle get systemUiOverlayStyle => + _systemUiOverlayStyle ?? + BrnDefaultConfigUtils.defaultAppBarConfig.systemUiOverlayStyle; @override void initThemeConfig( @@ -161,22 +231,21 @@ class BrnAppBarConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnAppBarConfig? appbarConfig = BrnThemeConfigurator.instance + BrnAppBarConfig appbarConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .appBarConfig; - this.backgroundColor ??= appbarConfig?.backgroundColor; - this.appBarHeight ??= appbarConfig?.appBarHeight; - this.leadIconBuilder ??= appbarConfig?.leadIconBuilder; - this.titleStyle = appbarConfig?.titleStyle?.merge(titleStyle); - this.actionsStyle = appbarConfig?.actionsStyle?.merge(actionsStyle); - this.titleMaxLength ??= appbarConfig?.titleMaxLength; - this.leftAndRightPadding ??= appbarConfig?.leftAndRightPadding; - this.itemSpacing ??= appbarConfig?.itemSpacing; - this.titlePadding ??= appbarConfig?.titlePadding; - this.iconSize ??= appbarConfig?.iconSize; - this.flexibleSpace ??= appbarConfig?.flexibleSpace; - this.systemUiOverlayStyle ??= appbarConfig?.systemUiOverlayStyle; + _backgroundColor ??= appbarConfig._backgroundColor; + _appBarHeight ??= appbarConfig._appBarHeight; + _leadIconBuilder ??= appbarConfig._leadIconBuilder; + _titleStyle = appbarConfig.titleStyle.merge(_titleStyle); + _actionsStyle = appbarConfig.actionsStyle.merge(_actionsStyle); + _titleMaxLength ??= appbarConfig._titleMaxLength; + _leftAndRightPadding ??= appbarConfig._leftAndRightPadding; + _itemSpacing ??= appbarConfig._itemSpacing; + _titlePadding ??= appbarConfig._titlePadding; + _iconSize ??= appbarConfig._iconSize; + _systemUiOverlayStyle ??= appbarConfig._systemUiOverlayStyle; } BrnAppBarConfig copyWith({ @@ -194,37 +263,34 @@ class BrnAppBarConfig extends BrnBaseConfig { SystemUiOverlayStyle? systemUiOverlayStyle, }) { return BrnAppBarConfig( - backgroundColor: backgroundColor ?? this.backgroundColor, - appBarHeight: appBarHeight ?? this.appBarHeight, - leadIconBuilder: leadIconBuilder ?? this.leadIconBuilder, - titleStyle: titleStyle ?? this.titleStyle, - actionsStyle: actionsStyle ?? this.actionsStyle, - titleMaxLength: titleMaxLength ?? this.titleMaxLength, - leftAndRightPadding: leftAndRightPadding ?? this.leftAndRightPadding, - itemSpacing: itemSpacing ?? this.itemSpacing, - titlePadding: titlePadding ?? this.titlePadding, - iconSize: iconSize ?? this.iconSize, - flexibleSpace: flexibleSpace ?? this.flexibleSpace, - systemUiOverlayStyle: systemUiOverlayStyle ?? this.systemUiOverlayStyle, + backgroundColor: backgroundColor ?? _backgroundColor, + appBarHeight: appBarHeight ?? _appBarHeight, + leadIconBuilder: leadIconBuilder ?? _leadIconBuilder, + titleStyle: titleStyle ?? _titleStyle, + actionsStyle: actionsStyle ?? _actionsStyle, + titleMaxLength: titleMaxLength ?? _titleMaxLength, + leftAndRightPadding: leftAndRightPadding ?? _leftAndRightPadding, + itemSpacing: itemSpacing ?? _itemSpacing, + titlePadding: titlePadding ?? _titlePadding, + iconSize: iconSize ?? _iconSize, + systemUiOverlayStyle: systemUiOverlayStyle ?? _systemUiOverlayStyle, ); } BrnAppBarConfig merge(BrnAppBarConfig? other) { if (other == null) return this; return copyWith( - backgroundColor: other.backgroundColor, - appBarHeight: other.appBarHeight, - leadIconBuilder: other.leadIconBuilder, - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - actionsStyle: - actionsStyle?.merge(other.actionsStyle) ?? other.actionsStyle, - titleMaxLength: other.titleMaxLength, - leftAndRightPadding: other.leftAndRightPadding, - itemSpacing: other.itemSpacing, - titlePadding: other.titlePadding, - iconSize: other.iconSize, - flexibleSpace: other.flexibleSpace, - systemUiOverlayStyle: other.systemUiOverlayStyle, + backgroundColor: other._backgroundColor, + appBarHeight: other._appBarHeight, + leadIconBuilder: other._leadIconBuilder, + titleStyle: titleStyle.merge(other._titleStyle), + actionsStyle: actionsStyle.merge(other._actionsStyle), + titleMaxLength: other._titleMaxLength, + leftAndRightPadding: other._leftAndRightPadding, + itemSpacing: other._itemSpacing, + titlePadding: other._titlePadding, + iconSize: other._iconSize, + systemUiOverlayStyle: other._systemUiOverlayStyle, ); } } diff --git a/lib/src/theme/configs/brn_button_config.dart b/lib/src/theme/configs/brn_button_config.dart index 7dafe47a..d6e29919 100644 --- a/lib/src/theme/configs/brn_button_config.dart +++ b/lib/src/theme/configs/brn_button_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,32 +8,62 @@ class BrnButtonConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultButtonConfig] BrnButtonConfig({ - this.bigButtonRadius, - this.bigButtonHeight, - this.bigButtonFontSize, - this.smallButtonRadius, - this.smallButtonHeight, - this.smallButtonFontSize, + double? bigButtonRadius, + double? bigButtonHeight, + double? bigButtonFontSize, + double? smallButtonRadius, + double? smallButtonHeight, + double? smallButtonFontSize, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _bigButtonRadius = bigButtonRadius, + _bigButtonHeight = bigButtonHeight, + _bigButtonFontSize = bigButtonFontSize, + _smallButtonRadius = smallButtonRadius, + _smallButtonHeight = smallButtonHeight, + _smallButtonFontSize = smallButtonFontSize, + super(configId: configId); /// 默认为 6 - double? bigButtonRadius; + double? _bigButtonRadius; + + double get bigButtonRadius => + _bigButtonRadius ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonRadius; /// 默认为 48 - double? bigButtonHeight; + double? _bigButtonHeight; + + double get bigButtonHeight => + _bigButtonHeight ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonHeight; /// 默认为 16 - double? bigButtonFontSize; + double? _bigButtonFontSize; + + double get bigButtonFontSize => + _bigButtonFontSize ?? + BrnDefaultConfigUtils.defaultButtonConfig.bigButtonFontSize; /// 默认为 4 - double? smallButtonRadius; + double? _smallButtonRadius; + + double get smallButtonRadius => + _smallButtonRadius ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonRadius; /// 默认为 32 - double? smallButtonHeight; + double? _smallButtonHeight; + + double get smallButtonHeight => + _smallButtonHeight ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonHeight; /// 默认为 14 - double? smallButtonFontSize; + double? _smallButtonFontSize; + + double get smallButtonFontSize => + _smallButtonFontSize ?? + BrnDefaultConfigUtils.defaultButtonConfig.smallButtonFontSize; @override void initThemeConfig( @@ -44,16 +75,16 @@ class BrnButtonConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnButtonConfig? userConfig = BrnThemeConfigurator.instance + BrnButtonConfig userConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .buttonConfig; - bigButtonRadius ??= userConfig?.bigButtonRadius; - bigButtonHeight ??= userConfig?.bigButtonHeight; - bigButtonFontSize ??= userConfig?.bigButtonFontSize; - smallButtonRadius ??= userConfig?.smallButtonRadius; - smallButtonHeight ??= userConfig?.smallButtonHeight; - smallButtonFontSize ??= userConfig?.smallButtonFontSize; + _bigButtonRadius ??= userConfig._bigButtonRadius; + _bigButtonHeight ??= userConfig._bigButtonHeight; + _bigButtonFontSize ??= userConfig._bigButtonFontSize; + _smallButtonRadius ??= userConfig._smallButtonRadius; + _smallButtonHeight ??= userConfig._smallButtonHeight; + _smallButtonFontSize ??= userConfig._smallButtonFontSize; } BrnButtonConfig copyWith({ @@ -65,24 +96,24 @@ class BrnButtonConfig extends BrnBaseConfig { double? smallButtonFontSize, }) { return BrnButtonConfig( - bigButtonRadius: bigButtonRadius ?? this.bigButtonRadius, - bigButtonHeight: bigButtonHeight ?? this.bigButtonHeight, - bigButtonFontSize: bigButtonFontSize ?? this.bigButtonFontSize, - smallButtonRadius: smallButtonRadius ?? this.smallButtonRadius, - smallButtonHeight: smallButtonHeight ?? this.smallButtonHeight, - smallButtonFontSize: smallButtonFontSize ?? this.smallButtonFontSize, + bigButtonRadius: bigButtonRadius ?? _bigButtonRadius, + bigButtonHeight: bigButtonHeight ?? _bigButtonHeight, + bigButtonFontSize: bigButtonFontSize ?? _bigButtonFontSize, + smallButtonRadius: smallButtonRadius ?? _smallButtonRadius, + smallButtonHeight: smallButtonHeight ?? _smallButtonHeight, + smallButtonFontSize: smallButtonFontSize ?? _smallButtonFontSize, ); } BrnButtonConfig merge(BrnButtonConfig? other) { if (other == null) return this; return copyWith( - bigButtonRadius: other.bigButtonRadius, - bigButtonHeight: other.bigButtonHeight, - bigButtonFontSize: other.bigButtonFontSize, - smallButtonRadius: other.smallButtonRadius, - smallButtonHeight: other.smallButtonHeight, - smallButtonFontSize: other.smallButtonFontSize, + bigButtonRadius: other._bigButtonRadius, + bigButtonHeight: other._bigButtonHeight, + bigButtonFontSize: other._bigButtonFontSize, + smallButtonRadius: other._smallButtonRadius, + smallButtonHeight: other._smallButtonHeight, + smallButtonFontSize: other._smallButtonFontSize, ); } } diff --git a/lib/src/theme/configs/brn_card_title_config.dart b/lib/src/theme/configs/brn_card_title_config.dart index 84cc2242..95ea6a70 100644 --- a/lib/src/theme/configs/brn_card_title_config.dart +++ b/lib/src/theme/configs/brn_card_title_config.dart @@ -1,3 +1,4 @@ +import 'package:bruno/bruno.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -7,16 +8,24 @@ import 'package:flutter/material.dart'; /// 卡片标题 配置类 class BrnCardTitleConfig extends BrnBaseConfig { BrnCardTitleConfig({ - this.titleWithHeightTextStyle, - this.detailTextStyle, - this.accessoryTextStyle, - this.cardTitlePadding, - this.titleTextStyle, - this.subtitleTextStyle, - this.alignment, - this.cardBackgroundColor, + BrnTextStyle? titleWithHeightTextStyle, + BrnTextStyle? detailTextStyle, + BrnTextStyle? accessoryTextStyle, + EdgeInsets? cardTitlePadding, + BrnTextStyle? titleTextStyle, + BrnTextStyle? subtitleTextStyle, + PlaceholderAlignment? alignment, + Color? cardBackgroundColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleWithHeightTextStyle = titleWithHeightTextStyle, + _detailTextStyle = detailTextStyle, + _accessoryTextStyle = accessoryTextStyle, + _cardTitlePadding = cardTitlePadding, + _titleTextStyle = titleTextStyle, + _subtitleTextStyle = subtitleTextStyle, + _alignment = alignment, + _cardBackgroundColor = cardBackgroundColor, + super(configId: configId); /// 标题外边距间距 /// @@ -24,7 +33,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// top: [BrnCommonConfig.vSpacingXl], /// bottom: [BrnCommonConfig.vSpacingMd], /// ) - EdgeInsets? cardTitlePadding; + EdgeInsets? _cardTitlePadding; + + EdgeInsets get cardTitlePadding => + _cardTitlePadding ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.cardTitlePadding; /// 标题文本样式 /// @@ -34,7 +47,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// fontWeight: FontWeight.w600, /// height: 25 / 18, /// ) - BrnTextStyle? titleWithHeightTextStyle; + BrnTextStyle? _titleWithHeightTextStyle; + + BrnTextStyle get titleWithHeightTextStyle => + _titleWithHeightTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.titleWithHeightTextStyle; /// 标题文本样式 /// @@ -43,7 +60,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.titleTextStyle; /// 标题右边的副标题文本样式 /// @@ -51,7 +72,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? subtitleTextStyle; + BrnTextStyle? _subtitleTextStyle; + + BrnTextStyle get subtitleTextStyle => + _subtitleTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.subtitleTextStyle; /// 详情文本样式 /// @@ -59,7 +84,11 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? detailTextStyle; + BrnTextStyle? _detailTextStyle; + + BrnTextStyle get detailTextStyle => + _detailTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.detailTextStyle; /// 辅助文本样式 /// @@ -67,15 +96,26 @@ class BrnCardTitleConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? accessoryTextStyle; + BrnTextStyle? _accessoryTextStyle; + + BrnTextStyle get accessoryTextStyle => + _accessoryTextStyle ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.accessoryTextStyle; /// 对齐方式 /// 默认为 [PlaceholderAlignment.middle] - PlaceholderAlignment? alignment; + PlaceholderAlignment? _alignment; + + PlaceholderAlignment get alignment => + _alignment ?? BrnDefaultConfigUtils.defaultCardTitleConfig.alignment; /// 卡片背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? cardBackgroundColor; + Color? _cardBackgroundColor; + + Color get cardBackgroundColor => + _cardBackgroundColor ?? + BrnDefaultConfigUtils.defaultCardTitleConfig.cardBackgroundColor; /// cardTitleConfig 获取逻辑详见 [BrnThemeConfigurator.getConfig] 方法 @override @@ -88,48 +128,48 @@ class BrnCardTitleConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnCardTitleConfig? cardTitleConfig = BrnThemeConfigurator.instance + BrnCardTitleConfig cardTitleConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .cardTitleConfig; - cardBackgroundColor ??= commonConfig.fillBase; - cardTitlePadding ??= EdgeInsets.only( - left: cardTitleConfig?.cardTitlePadding?.left ?? 0, - top: commonConfig.vSpacingXl ?? 0, - right: cardTitleConfig?.cardTitlePadding?.right ?? 0, - bottom: commonConfig.vSpacingMd ?? 0, + _cardBackgroundColor ??= commonConfig.fillBase; + _cardTitlePadding ??= EdgeInsets.only( + left: cardTitleConfig.cardTitlePadding.left, + top: commonConfig.vSpacingXl, + right: cardTitleConfig.cardTitlePadding.right, + bottom: commonConfig.vSpacingMd, ); - titleWithHeightTextStyle = cardTitleConfig?.titleWithHeightTextStyle?.merge( + _titleWithHeightTextStyle = cardTitleConfig.titleWithHeightTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleWithHeightTextStyle), + ).merge(_titleWithHeightTextStyle), ); - titleTextStyle = cardTitleConfig?.titleTextStyle?.merge( + _titleTextStyle = cardTitleConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - subtitleTextStyle = cardTitleConfig?.subtitleTextStyle?.merge( + _subtitleTextStyle = cardTitleConfig.subtitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(subtitleTextStyle), + ).merge(_subtitleTextStyle), ); - accessoryTextStyle = cardTitleConfig?.accessoryTextStyle?.merge( + _accessoryTextStyle = cardTitleConfig.accessoryTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeHead, - ).merge(accessoryTextStyle), + ).merge(_accessoryTextStyle), ); - detailTextStyle = cardTitleConfig?.detailTextStyle?.merge( + _detailTextStyle = cardTitleConfig.detailTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(detailTextStyle), + ).merge(_detailTextStyle), ); - alignment ??= cardTitleConfig?.alignment; + _alignment ??= cardTitleConfig._alignment; } BrnCardTitleConfig copyWith({ @@ -143,35 +183,30 @@ class BrnCardTitleConfig extends BrnBaseConfig { Color? cardBackgroundColor, }) { return BrnCardTitleConfig( - cardTitlePadding: cardTitlePadding ?? this.cardTitlePadding, + cardTitlePadding: cardTitlePadding ?? _cardTitlePadding, titleWithHeightTextStyle: - titleWithHeightTextStyle ?? this.titleWithHeightTextStyle, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - subtitleTextStyle: subtitleTextStyle ?? this.subtitleTextStyle, - detailTextStyle: detailTextStyle ?? this.detailTextStyle, - accessoryTextStyle: accessoryTextStyle ?? this.accessoryTextStyle, - alignment: alignment ?? this.alignment, - cardBackgroundColor: cardBackgroundColor ?? this.cardBackgroundColor, + titleWithHeightTextStyle ?? _titleWithHeightTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + subtitleTextStyle: subtitleTextStyle ?? _subtitleTextStyle, + detailTextStyle: detailTextStyle ?? _detailTextStyle, + accessoryTextStyle: accessoryTextStyle ?? _accessoryTextStyle, + alignment: alignment ?? _alignment, + cardBackgroundColor: cardBackgroundColor ?? _cardBackgroundColor, ); } BrnCardTitleConfig merge(BrnCardTitleConfig? other) { if (other == null) return this; return copyWith( - cardTitlePadding: other.cardTitlePadding, + cardTitlePadding: other._cardTitlePadding, titleWithHeightTextStyle: - titleWithHeightTextStyle?.merge(other.titleWithHeightTextStyle) ?? - other.titleWithHeightTextStyle, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - subtitleTextStyle: subtitleTextStyle?.merge(other.subtitleTextStyle) ?? - other.subtitleTextStyle, - detailTextStyle: detailTextStyle?.merge(other.detailTextStyle) ?? - other.detailTextStyle, - accessoryTextStyle: accessoryTextStyle?.merge(other.accessoryTextStyle) ?? - other.accessoryTextStyle, - alignment: other.alignment, - cardBackgroundColor: other.cardBackgroundColor, + titleWithHeightTextStyle.merge(other._titleWithHeightTextStyle), + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + subtitleTextStyle: subtitleTextStyle.merge(other._subtitleTextStyle), + detailTextStyle: detailTextStyle.merge(other._detailTextStyle), + accessoryTextStyle: accessoryTextStyle.merge(other._accessoryTextStyle), + alignment: other._alignment, + cardBackgroundColor: other._cardBackgroundColor, ); } } diff --git a/lib/src/theme/configs/brn_common_config.dart b/lib/src/theme/configs/brn_common_config.dart index c5b1e887..1e433123 100644 --- a/lib/src/theme/configs/brn_common_config.dart +++ b/lib/src/theme/configs/brn_common_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/painting.dart'; @@ -6,114 +7,216 @@ import 'package:flutter/painting.dart'; /// 配置属性:色值、字体大小、间距、圆角 class BrnCommonConfig extends BrnBaseConfig { BrnCommonConfig({ - this.brandPrimary, - this.brandPrimaryTap, - this.brandSuccess, - this.brandWarning, - this.brandError, - this.brandImportant, - this.brandImportantValue, - this.brandAuxiliary, - this.colorTextBase, - this.colorTextImportant, - this.colorTextBaseInverse, - this.colorTextSecondary, - this.colorTextDisabled, - this.colorTextHint, - this.colorLink, - this.fillBase, - this.fillBody, - this.fillMask, - this.borderColorBase, - this.dividerColorBase, - this.fontSizeDIN, - this.fontSizeHeadLg, - this.fontSizeBase, - this.fontSizeHead, - this.fontSizeSubHead, - this.fontSizeCaption, - this.fontSizeCaptionSm, - this.radiusXs, - this.radiusSm, - this.radiusMd, - this.radiusLg, - this.borderWidthSm, - this.borderWidthMd, - this.borderWidthLg, - this.hSpacingXs, - this.hSpacingSm, - this.hSpacingMd, - this.hSpacingLg, - this.hSpacingXl, - this.hSpacingXxl, - this.vSpacingXs, - this.vSpacingSm, - this.vSpacingMd, - this.vSpacingLg, - this.vSpacingXl, - this.vSpacingXxl, - this.iconSizeXxs, - this.iconSizeXs, - this.iconSizeSm, - this.iconSizeMd, - this.iconSizeLg, + Color? brandPrimary, + Color? brandPrimaryTap, + Color? brandSuccess, + Color? brandWarning, + Color? brandError, + Color? brandImportant, + Color? brandImportantValue, + Color? brandAuxiliary, + Color? colorTextBase, + Color? colorTextImportant, + Color? colorTextBaseInverse, + Color? colorTextSecondary, + Color? colorTextDisabled, + Color? colorTextHint, + Color? colorLink, + Color? fillBase, + Color? fillBody, + Color? fillMask, + Color? borderColorBase, + Color? dividerColorBase, + double? fontSizeDIN, + double? fontSizeHeadLg, + double? fontSizeBase, + double? fontSizeHead, + double? fontSizeSubHead, + double? fontSizeCaption, + double? fontSizeCaptionSm, + double? radiusXs, + double? radiusSm, + double? radiusMd, + double? radiusLg, + double? borderWidthSm, + double? borderWidthMd, + double? borderWidthLg, + double? hSpacingXs, + double? hSpacingSm, + double? hSpacingMd, + double? hSpacingLg, + double? hSpacingXl, + double? hSpacingXxl, + double? vSpacingXs, + double? vSpacingSm, + double? vSpacingMd, + double? vSpacingLg, + double? vSpacingXl, + double? vSpacingXxl, + double? iconSizeXxs, + double? iconSizeXs, + double? iconSizeSm, + double? iconSizeMd, + double? iconSizeLg, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _brandPrimary = brandPrimary, + _brandPrimaryTap = brandPrimaryTap, + _brandSuccess = brandSuccess, + _brandWarning = brandWarning, + _brandError = brandError, + _brandImportant = brandImportant, + _brandImportantValue = brandImportantValue, + _brandAuxiliary = brandAuxiliary, + _colorTextBase = colorTextBase, + _colorTextImportant = colorTextImportant, + _colorTextBaseInverse = colorTextBaseInverse, + _colorTextSecondary = colorTextSecondary, + _colorTextDisabled = colorTextDisabled, + _colorTextHint = colorTextHint, + _colorLink = colorLink, + _fillBase = fillBase, + _fillBody = fillBody, + _fillMask = fillMask, + _borderColorBase = borderColorBase, + _dividerColorBase = dividerColorBase, + _fontSizeDIN = fontSizeDIN, + _fontSizeHeadLg = fontSizeHeadLg, + _fontSizeBase = fontSizeBase, + _fontSizeHead = fontSizeHead, + _fontSizeSubHead = fontSizeSubHead, + _fontSizeCaption = fontSizeCaption, + _fontSizeCaptionSm = fontSizeCaptionSm, + _radiusXs = radiusXs, + _radiusSm = radiusSm, + _radiusMd = radiusMd, + _radiusLg = radiusLg, + _borderWidthSm = borderWidthSm, + _borderWidthMd = borderWidthMd, + _borderWidthLg = borderWidthLg, + _hSpacingXs = hSpacingXs, + _hSpacingSm = hSpacingSm, + _hSpacingMd = hSpacingMd, + _hSpacingLg = hSpacingLg, + _hSpacingXl = hSpacingXl, + _hSpacingXxl = hSpacingXxl, + _vSpacingXs = vSpacingXs, + _vSpacingSm = vSpacingSm, + _vSpacingMd = vSpacingMd, + _vSpacingLg = vSpacingLg, + _vSpacingXl = vSpacingXl, + _vSpacingXxl = vSpacingXxl, + _iconSizeXxs = iconSizeXxs, + _iconSizeXs = iconSizeXs, + _iconSizeSm = iconSizeSm, + _iconSizeMd = iconSizeMd, + _iconSizeLg = iconSizeLg, + super(configId: configId); BrnCommonConfig.autoFlatConfig({ - this.brandPrimary, - this.brandPrimaryTap, - this.brandSuccess, - this.brandWarning, - this.brandError, - this.brandImportant, - this.brandImportantValue, - this.brandAuxiliary, - this.colorTextBase, - this.colorTextImportant, - this.colorTextBaseInverse, - this.colorTextSecondary, - this.colorTextDisabled, - this.colorTextHint, - this.colorLink, - this.fillBase, - this.fillBody, - this.fillMask, - this.borderColorBase, - this.dividerColorBase, - this.fontSizeDIN, - this.fontSizeHeadLg, - this.fontSizeBase, - this.fontSizeHead, - this.fontSizeSubHead, - this.fontSizeCaption, - this.fontSizeCaptionSm, - this.radiusXs, - this.radiusSm, - this.radiusMd, - this.radiusLg, - this.borderWidthSm, - this.borderWidthMd, - this.borderWidthLg, - this.hSpacingXs, - this.hSpacingSm, - this.hSpacingMd, - this.hSpacingLg, - this.hSpacingXl, - this.hSpacingXxl, - this.vSpacingXs, - this.vSpacingSm, - this.vSpacingMd, - this.vSpacingLg, - this.vSpacingXl, - this.vSpacingXxl, - this.iconSizeXxs, - this.iconSizeXs, - this.iconSizeSm, - this.iconSizeMd, - this.iconSizeLg, + Color? brandPrimary, + Color? brandPrimaryTap, + Color? brandSuccess, + Color? brandWarning, + Color? brandError, + Color? brandImportant, + Color? brandImportantValue, + Color? brandAuxiliary, + Color? colorTextBase, + Color? colorTextImportant, + Color? colorTextBaseInverse, + Color? colorTextSecondary, + Color? colorTextDisabled, + Color? colorTextHint, + Color? colorLink, + Color? fillBase, + Color? fillBody, + Color? fillMask, + Color? borderColorBase, + Color? dividerColorBase, + double? fontSizeDIN, + double? fontSizeHeadLg, + double? fontSizeBase, + double? fontSizeHead, + double? fontSizeSubHead, + double? fontSizeCaption, + double? fontSizeCaptionSm, + double? radiusXs, + double? radiusSm, + double? radiusMd, + double? radiusLg, + double? borderWidthSm, + double? borderWidthMd, + double? borderWidthLg, + double? hSpacingXs, + double? hSpacingSm, + double? hSpacingMd, + double? hSpacingLg, + double? hSpacingXl, + double? hSpacingXxl, + double? vSpacingXs, + double? vSpacingSm, + double? vSpacingMd, + double? vSpacingLg, + double? vSpacingXl, + double? vSpacingXxl, + double? iconSizeXxs, + double? iconSizeXs, + double? iconSizeSm, + double? iconSizeMd, + double? iconSizeLg, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId, autoFlatConfig: true); + }) : _brandPrimary = brandPrimary, + _brandPrimaryTap = brandPrimaryTap, + _brandSuccess = brandSuccess, + _brandWarning = brandWarning, + _brandError = brandError, + _brandImportant = brandImportant, + _brandImportantValue = brandImportantValue, + _brandAuxiliary = brandAuxiliary, + _colorTextBase = colorTextBase, + _colorTextImportant = colorTextImportant, + _colorTextBaseInverse = colorTextBaseInverse, + _colorTextSecondary = colorTextSecondary, + _colorTextDisabled = colorTextDisabled, + _colorTextHint = colorTextHint, + _colorLink = colorLink, + _fillBase = fillBase, + _fillBody = fillBody, + _fillMask = fillMask, + _borderColorBase = borderColorBase, + _dividerColorBase = dividerColorBase, + _fontSizeDIN = fontSizeDIN, + _fontSizeHeadLg = fontSizeHeadLg, + _fontSizeBase = fontSizeBase, + _fontSizeHead = fontSizeHead, + _fontSizeSubHead = fontSizeSubHead, + _fontSizeCaption = fontSizeCaption, + _fontSizeCaptionSm = fontSizeCaptionSm, + _radiusXs = radiusXs, + _radiusSm = radiusSm, + _radiusMd = radiusMd, + _radiusLg = radiusLg, + _borderWidthSm = borderWidthSm, + _borderWidthMd = borderWidthMd, + _borderWidthLg = borderWidthLg, + _hSpacingXs = hSpacingXs, + _hSpacingSm = hSpacingSm, + _hSpacingMd = hSpacingMd, + _hSpacingLg = hSpacingLg, + _hSpacingXl = hSpacingXl, + _hSpacingXxl = hSpacingXxl, + _vSpacingXs = vSpacingXs, + _vSpacingSm = vSpacingSm, + _vSpacingMd = vSpacingMd, + _vSpacingLg = vSpacingLg, + _vSpacingXl = vSpacingXl, + _vSpacingXxl = vSpacingXxl, + _iconSizeXxs = iconSizeXxs, + _iconSizeXs = iconSizeXs, + _iconSizeSm = iconSizeSm, + _iconSizeMd = iconSizeMd, + _iconSizeLg = iconSizeLg, + super(configId: configId, autoFlatConfig: true); /// 基本单位 static const double hd = 1; @@ -126,86 +229,86 @@ class BrnCommonConfig extends BrnBaseConfig { /// 品牌色 /// 默认为 Color(0xFF0984F9) - Color? brandPrimary; + Color? _brandPrimary; /// 主题色按下效果 /// 默认为 Color(0x190984F9) - Color? brandPrimaryTap; + Color? _brandPrimaryTap; /// 成功色 /// 默认为 Color(0xFF00AE66) - Color? brandSuccess; + Color? _brandSuccess; /// 警告色 /// 默认为 Color(0xFFFAAD14) - Color? brandWarning; + Color? _brandWarning; /// 失败色 /// 默认为 Color(0xFFFA3F3F) - Color? brandError; + Color? _brandError; /// 重要-多用于红点色 /// 默认为 Color(0xFFFA3F3F) - Color? brandImportant; + Color? _brandImportant; /// 重要数值色 /// 默认为 Color(0xFFFF5722) - Color? brandImportantValue; + Color? _brandImportantValue; /// 辅助色 /// 默认为 Color(0xFF44C2FF) - Color? brandAuxiliary; + Color? _brandAuxiliary; /// 文本色相关 /// /// 基础文字纯黑色 /// 默认为 Color(0xFF222222) - Color? colorTextBase; + Color? _colorTextBase; /// 基础文字重要色 /// 默认为 Color(0xFF666666) - Color? colorTextImportant; + Color? _colorTextImportant; /// 基础文字-反色 /// 默认为 Color(0xFFFFFFFF) - Color? colorTextBaseInverse; + Color? _colorTextBaseInverse; /// 辅助文字色 /// 默认为 Color(0xFF999999) - Color? colorTextSecondary; + Color? _colorTextSecondary; /// 失效或不可更改文字色 /// 默认为 Color(0xFF999999) - Color? colorTextDisabled; + Color? _colorTextDisabled; /// 文本框提示暗文文字色 /// 默认为 Color(0xFFCCCCCC) - Color? colorTextHint; + Color? _colorTextHint; /// 跟随主题色[brandPrimary] - Color? colorLink; + Color? _colorLink; /// 背景色相关 /// /// 组件背景色 /// 默认为 Color(0xFFFFFFFF) - Color? fillBase; + Color? _fillBase; /// 页面背景色 /// 默认为 Color(0xFFF8F8F8) - Color? fillBody; + Color? _fillBody; /// 遮罩背景 /// 默认为 Color(0x99000000) - Color? fillMask; + Color? _fillMask; /// 边框色 /// 默认为 Color(0xFFF0F0F0) - Color? borderColorBase; + Color? _borderColorBase; /// 分割线色 /// 默认为 Color(0xFFF0F0F0) - Color? dividerColorBase; + Color? _dividerColorBase; /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// 尺寸 ///////////////////////////////////// @@ -215,113 +318,280 @@ class BrnCommonConfig extends BrnBaseConfig { /// /// 特殊数据展示,DIN Condensed数字字体,用于强吸引 /// 默认为 28 - double? fontSizeDIN; + double? _fontSizeDIN; /// 标题字体 /// 名称/页面大标题 /// 默认为 22 - double? fontSizeHeadLg; + double? _fontSizeHeadLg; /// 标题字体 /// 内容模块标题/一级标题 /// 默认为 18 - double? fontSizeHead; + double? _fontSizeHead; /// 子标题字体 /// 标题/录入文字/大按钮文字/二级标题 /// 默认为 16 - double? fontSizeSubHead; + double? _fontSizeSubHead; /// 基础字体 /// 内容副文本/普通说明文字 /// 默认为 14 - double? fontSizeBase; + double? _fontSizeBase; /// 辅助字体-普通 /// 默认为 12 - double? fontSizeCaption; + double? _fontSizeCaption; ///辅助字体-小 /// 默认为 11 - double? fontSizeCaptionSm; + double? _fontSizeCaptionSm; /// 圆角尺寸 /// 默认为 2.0 - double? radiusXs; + double? _radiusXs; /// 默认为 4.0 - double? radiusSm; + double? _radiusSm; /// 默认为 6.0 - double? radiusMd; + double? _radiusMd; /// 默认为 8.0 - double? radiusLg; + double? _radiusLg; /// 边框尺寸 /// /// 默认为 0.5 - double? borderWidthSm; + double? _borderWidthSm; /// 默认为 1 - double? borderWidthMd; + double? _borderWidthMd; /// 默认为 2 - double? borderWidthLg; + double? _borderWidthLg; /// 水平间距 /// 默认为 8 - double? hSpacingXs; + double? _hSpacingXs; /// 默认为 12 - double? hSpacingSm; + double? _hSpacingSm; /// 默认为 16 - double? hSpacingMd; + double? _hSpacingMd; /// 默认为 20 - double? hSpacingLg; + double? _hSpacingLg; /// 默认为 24 - double? hSpacingXl; + double? _hSpacingXl; /// 默认为 42 - double? hSpacingXxl; + double? _hSpacingXxl; /// 垂直间距 /// 默认为 4 - double? vSpacingXs; + double? _vSpacingXs; /// 默认为 8 - double? vSpacingSm; + double? _vSpacingSm; /// 默认为 12 - double? vSpacingMd; + double? _vSpacingMd; /// 默认为 14 - double? vSpacingLg; + double? _vSpacingLg; /// 默认为 16 - double? vSpacingXl; + double? _vSpacingXl; /// 默认为 28 - double? vSpacingXxl; + double? _vSpacingXxl; /// 图标尺寸 /// 默认为 8 - double? iconSizeXxs; + double? _iconSizeXxs; /// 默认为 12 - double? iconSizeXs; + double? _iconSizeXs; /// 默认为 14 - double? iconSizeSm; + double? _iconSizeSm; /// 默认为 16 - double? iconSizeMd; + double? _iconSizeMd; /// 默认为 32 - double? iconSizeLg; + double? _iconSizeLg; + + Color get brandPrimary => + _brandPrimary ?? BrnDefaultConfigUtils.defaultCommonConfig.brandPrimary; + + Color get brandPrimaryTap => + _brandPrimaryTap ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandPrimaryTap; + + Color get brandSuccess => + _brandSuccess ?? BrnDefaultConfigUtils.defaultCommonConfig.brandSuccess; + + Color get brandWarning => + _brandWarning ?? BrnDefaultConfigUtils.defaultCommonConfig.brandWarning; + + Color get brandError => + _brandError ?? BrnDefaultConfigUtils.defaultCommonConfig.brandError; + + Color get brandImportant => + _brandImportant ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandImportant; + + Color get brandImportantValue => + _brandImportantValue ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandImportantValue; + + Color get brandAuxiliary => + _brandAuxiliary ?? + BrnDefaultConfigUtils.defaultCommonConfig.brandAuxiliary; + + Color get colorTextBase => + _colorTextBase ?? BrnDefaultConfigUtils.defaultCommonConfig.colorTextBase; + + Color get colorTextImportant => + _colorTextImportant ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextImportant; + + Color get colorTextBaseInverse => + _colorTextBaseInverse ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextBaseInverse; + + Color get colorTextSecondary => + _colorTextSecondary ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextSecondary; + + Color get colorTextDisabled => + _colorTextDisabled ?? + BrnDefaultConfigUtils.defaultCommonConfig.colorTextDisabled; + + Color get colorTextHint => + _colorTextHint ?? BrnDefaultConfigUtils.defaultCommonConfig.colorTextHint; + + Color get colorLink => + _colorLink ?? BrnDefaultConfigUtils.defaultCommonConfig.colorLink; + + Color get fillBase => + _fillBase ?? BrnDefaultConfigUtils.defaultCommonConfig.fillBase; + + Color get fillBody => + _fillBody ?? BrnDefaultConfigUtils.defaultCommonConfig.fillBody; + + Color get fillMask => + _fillMask ?? BrnDefaultConfigUtils.defaultCommonConfig.fillMask; + + Color get borderColorBase => + _borderColorBase ?? + BrnDefaultConfigUtils.defaultCommonConfig.borderColorBase; + + Color get dividerColorBase => + _dividerColorBase ?? + BrnDefaultConfigUtils.defaultCommonConfig.dividerColorBase; + + double get fontSizeDIN => + _fontSizeDIN ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeDIN; + + double get fontSizeHeadLg => + _fontSizeHeadLg ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeHeadLg; + + double get fontSizeHead => + _fontSizeHead ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeHead; + + double get fontSizeSubHead => + _fontSizeSubHead ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeSubHead; + + double get fontSizeBase => + _fontSizeBase ?? BrnDefaultConfigUtils.defaultCommonConfig.fontSizeBase; + + double get fontSizeCaption => + _fontSizeCaption ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeCaption; + + double get fontSizeCaptionSm => + _fontSizeCaptionSm ?? + BrnDefaultConfigUtils.defaultCommonConfig.fontSizeCaptionSm; + + double get radiusXs => + _radiusXs ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusXs; + + double get radiusSm => + _radiusSm ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusSm; + + double get radiusMd => + _radiusMd ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusMd; + + double get radiusLg => + _radiusLg ?? BrnDefaultConfigUtils.defaultCommonConfig.radiusLg; + + double get borderWidthSm => + _borderWidthSm ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthSm; + + double get borderWidthMd => + _borderWidthMd ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthMd; + + double get borderWidthLg => + _borderWidthLg ?? BrnDefaultConfigUtils.defaultCommonConfig.borderWidthLg; + + double get hSpacingXs => + _hSpacingXs ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXs; + + double get hSpacingSm => + _hSpacingSm ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingSm; + + double get hSpacingMd => + _hSpacingMd ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingMd; + + double get hSpacingLg => + _hSpacingLg ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingLg; + + double get hSpacingXl => + _hSpacingXl ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXl; + + double get hSpacingXxl => + _hSpacingXxl ?? BrnDefaultConfigUtils.defaultCommonConfig.hSpacingXxl; + + double get vSpacingXs => + _vSpacingXs ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXs; + + double get vSpacingSm => + _vSpacingSm ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingSm; + + double get vSpacingMd => + _vSpacingMd ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingMd; + + double get vSpacingLg => + _vSpacingLg ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingLg; + + double get vSpacingXl => + _vSpacingXl ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXl; + + double get vSpacingXxl => + _vSpacingXxl ?? BrnDefaultConfigUtils.defaultCommonConfig.vSpacingXxl; + + double get iconSizeXxs => + _iconSizeXxs ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeXxs; + + double get iconSizeXs => + _iconSizeXs ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeXs; + + double get iconSizeSm => + _iconSizeSm ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeSm; + + double get iconSizeMd => + _iconSizeMd ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeMd; + + double get iconSizeLg => + _iconSizeLg ?? BrnDefaultConfigUtils.defaultCommonConfig.iconSizeLg; /// 优先级 [GLOBAL_CONFIG_ID] 获取配置 > [BRUNO_CONFIG_ID] 获取配置 @override @@ -335,56 +605,56 @@ class BrnCommonConfig extends BrnBaseConfig { ); /// 获取合适的 完整配置(BrnAllConfig) - this.colorTextBase ??= commonConfig.colorTextBase; - this.colorTextImportant ??= commonConfig.colorTextImportant; - this.colorTextBaseInverse ??= commonConfig.colorTextBaseInverse; - this.colorTextSecondary ??= commonConfig.colorTextSecondary; - this.colorTextHint ??= commonConfig.colorTextHint; - this.colorTextDisabled ??= commonConfig.colorTextDisabled; - this.brandAuxiliary ??= commonConfig.brandAuxiliary; - this.colorLink ??= commonConfig.colorLink; - this.fillBase ??= commonConfig.fillBase; - this.fillBody ??= commonConfig.fillBody; - this.fillMask ??= commonConfig.fillMask; - this.brandPrimary ??= commonConfig.brandPrimary; - this.brandPrimaryTap ??= commonConfig.brandPrimaryTap; - this.brandSuccess ??= commonConfig.brandSuccess; - this.brandWarning ??= commonConfig.brandWarning; - this.brandError ??= commonConfig.brandError; - this.brandImportant ??= commonConfig.brandImportant; - this.brandImportantValue ??= commonConfig.brandImportantValue; - this.borderColorBase ??= commonConfig.borderColorBase; - this.dividerColorBase ??= commonConfig.dividerColorBase; - this.fontSizeDIN ??= commonConfig.fontSizeDIN; - this.fontSizeHeadLg ??= commonConfig.fontSizeHeadLg; - this.fontSizeBase ??= commonConfig.fontSizeBase; - this.fontSizeHead ??= commonConfig.fontSizeHead; - this.fontSizeSubHead ??= commonConfig.fontSizeSubHead; - this.fontSizeCaption ??= commonConfig.fontSizeCaption; - this.fontSizeCaptionSm ??= commonConfig.fontSizeCaptionSm; - this.radiusXs ??= commonConfig.radiusXs; - this.radiusSm ??= commonConfig.radiusSm; - this.radiusMd ??= commonConfig.radiusMd; - this.radiusLg ??= commonConfig.radiusLg; - this.borderWidthSm ??= commonConfig.borderWidthSm; - this.borderWidthMd ??= commonConfig.borderWidthMd; - this.borderWidthLg ??= commonConfig.borderWidthLg; - this.hSpacingXs ??= commonConfig.hSpacingXs; - this.hSpacingSm ??= commonConfig.hSpacingSm; - this.hSpacingMd ??= commonConfig.hSpacingMd; - this.hSpacingLg ??= commonConfig.hSpacingLg; - this.hSpacingXl ??= commonConfig.hSpacingXl; - this.hSpacingXxl ??= commonConfig.hSpacingXxl; - this.vSpacingXs ??= commonConfig.vSpacingXs; - this.vSpacingSm ??= commonConfig.vSpacingSm; - this.vSpacingMd ??= commonConfig.vSpacingMd; - this.vSpacingLg ??= commonConfig.vSpacingLg; - this.vSpacingXl ??= commonConfig.vSpacingXl; - this.vSpacingXxl ??= commonConfig.vSpacingXxl; - this.iconSizeXxs ??= commonConfig.iconSizeXxs; - this.iconSizeXs ??= commonConfig.iconSizeXs; - this.iconSizeSm ??= commonConfig.iconSizeSm; - this.iconSizeMd ??= commonConfig.iconSizeMd; - this.iconSizeLg ??= commonConfig.iconSizeLg; + _colorTextBase ??= commonConfig._colorTextBase; + _colorTextImportant ??= commonConfig._colorTextImportant; + _colorTextBaseInverse ??= commonConfig._colorTextBaseInverse; + _colorTextSecondary ??= commonConfig._colorTextSecondary; + _colorTextHint ??= commonConfig._colorTextHint; + _colorTextDisabled ??= commonConfig._colorTextDisabled; + _brandAuxiliary ??= commonConfig._brandAuxiliary; + _colorLink ??= commonConfig._colorLink; + _fillBase ??= commonConfig._fillBase; + _fillBody ??= commonConfig._fillBody; + _fillMask ??= commonConfig._fillMask; + _brandPrimary ??= commonConfig._brandPrimary; + _brandPrimaryTap ??= commonConfig._brandPrimaryTap; + _brandSuccess ??= commonConfig._brandSuccess; + _brandWarning ??= commonConfig._brandWarning; + _brandError ??= commonConfig._brandError; + _brandImportant ??= commonConfig._brandImportant; + _brandImportantValue ??= commonConfig._brandImportantValue; + _borderColorBase ??= commonConfig._borderColorBase; + _dividerColorBase ??= commonConfig._dividerColorBase; + _fontSizeDIN ??= commonConfig._fontSizeDIN; + _fontSizeHeadLg ??= commonConfig._fontSizeHeadLg; + _fontSizeBase ??= commonConfig._fontSizeBase; + _fontSizeHead ??= commonConfig._fontSizeHead; + _fontSizeSubHead ??= commonConfig._fontSizeSubHead; + _fontSizeCaption ??= commonConfig._fontSizeCaption; + _fontSizeCaptionSm ??= commonConfig._fontSizeCaptionSm; + _radiusXs ??= commonConfig._radiusXs; + _radiusSm ??= commonConfig._radiusSm; + _radiusMd ??= commonConfig._radiusMd; + _radiusLg ??= commonConfig._radiusLg; + _borderWidthSm ??= commonConfig._borderWidthSm; + _borderWidthMd ??= commonConfig._borderWidthMd; + _borderWidthLg ??= commonConfig._borderWidthLg; + _hSpacingXs ??= commonConfig._hSpacingXs; + _hSpacingSm ??= commonConfig._hSpacingSm; + _hSpacingMd ??= commonConfig._hSpacingMd; + _hSpacingLg ??= commonConfig._hSpacingLg; + _hSpacingXl ??= commonConfig._hSpacingXl; + _hSpacingXxl ??= commonConfig._hSpacingXxl; + _vSpacingXs ??= commonConfig._vSpacingXs; + _vSpacingSm ??= commonConfig._vSpacingSm; + _vSpacingMd ??= commonConfig._vSpacingMd; + _vSpacingLg ??= commonConfig._vSpacingLg; + _vSpacingXl ??= commonConfig._vSpacingXl; + _vSpacingXxl ??= commonConfig._vSpacingXxl; + _iconSizeXxs ??= commonConfig._iconSizeXxs; + _iconSizeXs ??= commonConfig._iconSizeXs; + _iconSizeSm ??= commonConfig._iconSizeSm; + _iconSizeMd ??= commonConfig._iconSizeMd; + _iconSizeLg ??= commonConfig._iconSizeLg; } } diff --git a/lib/src/theme/configs/brn_dialog_config.dart b/lib/src/theme/configs/brn_dialog_config.dart index 75b949fb..7bd99306 100644 --- a/lib/src/theme/configs/brn_dialog_config.dart +++ b/lib/src/theme/configs/brn_dialog_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,43 +8,74 @@ import 'package:flutter/material.dart'; /// 描述: Dialog 弹框主配置类 class BrnDialogConfig extends BrnBaseConfig { BrnDialogConfig({ - this.dialogWidth, - this.radius, - this.iconPadding, - this.titlePaddingSm, - this.titlePaddingLg, - this.titleTextStyle, - this.titleTextAlign, - this.contentPaddingSm, - this.contentPaddingLg, - this.contentTextStyle, - this.contentTextAlign, - this.warningPaddingSm, - this.warningPaddingLg, - this.warningTextStyle, - this.warningTextAlign, - this.dividerPadding, - this.mainActionTextStyle, - this.assistActionsTextStyle, - this.mainActionBackgroundColor, - this.assistActionsBackgroundColor, - this.bottomHeight, - this.backgroundColor, + dialogWidth, + radius, + iconPadding, + titlePaddingSm, + titlePaddingLg, + titleTextStyle, + titleTextAlign, + contentPaddingSm, + contentPaddingLg, + contentTextStyle, + contentTextAlign, + warningPaddingSm, + warningPaddingLg, + warningTextStyle, + warningTextAlign, + dividerPadding, + mainActionTextStyle, + assistActionsTextStyle, + mainActionBackgroundColor, + assistActionsBackgroundColor, + bottomHeight, + backgroundColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _dialogWidth = dialogWidth, + _radius = radius, + _iconPadding = iconPadding, + _titlePaddingSm = titlePaddingSm, + _titlePaddingLg = titlePaddingLg, + _titleTextStyle = titleTextStyle, + _titleTextAlign = titleTextAlign, + _contentPaddingSm = contentPaddingSm, + _contentPaddingLg = contentPaddingLg, + _contentTextStyle = contentTextStyle, + _contentTextAlign = contentTextAlign, + _warningPaddingSm = warningPaddingSm, + _warningPaddingLg = warningPaddingLg, + _warningTextStyle = warningTextStyle, + _warningTextAlign = warningTextAlign, + _dividerPadding = dividerPadding, + _mainActionTextStyle = mainActionTextStyle, + _assistActionsTextStyle = assistActionsTextStyle, + _mainActionBackgroundColor = mainActionBackgroundColor, + _assistActionsBackgroundColor = assistActionsBackgroundColor, + _bottomHeight = bottomHeight, + _backgroundColor = backgroundColor, + super(configId: configId); /// Dialog 宽度 /// 默认为 300 - double? dialogWidth; + double? _dialogWidth; + + double get dialogWidth => + _dialogWidth ?? BrnDefaultConfigUtils.defaultDialogConfig.dialogWidth; /// Dialog 四周圆角 /// 默认为 [BrnCommonConfig.radiusLg] - double? radius; + double? _radius; + + double get radius => + _radius ?? BrnDefaultConfigUtils.defaultDialogConfig.radius; /// Dialog icon 距离顶部的边距 /// /// EdgeInsets.only(top: [BrnCommonConfig.vSpacingXxl]) - EdgeInsets? iconPadding; + EdgeInsets? _iconPadding; + + EdgeInsets get iconPadding => + _iconPadding ?? BrnDefaultConfigUtils.defaultDialogConfig.iconPadding; /// title 在顶部有 icon 时的边距 /// @@ -52,7 +84,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXxl], /// right: [BrnCommonConfig.hSpacingXxl], /// ) - EdgeInsets? titlePaddingSm; + EdgeInsets? _titlePaddingSm; + + EdgeInsets get titlePaddingSm => + _titlePaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.titlePaddingSm; /// title 当顶部无 icon 时的边距 /// @@ -61,7 +97,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXxl], /// right: [BrnCommonConfig.hSpacingXxl], /// ) - EdgeInsets? titlePaddingLg; + EdgeInsets? _titlePaddingLg; + + EdgeInsets get titlePaddingLg => + _titlePaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.titlePaddingLg; /// title 标题样式 /// @@ -70,11 +110,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.titleTextStyle; /// 标题的文字对齐 /// 默认为 [TextAlign.center] - TextAlign? titleTextAlign; + TextAlign? _titleTextAlign; + + TextAlign get titleTextAlign => + _titleTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.titleTextAlign; /// content 当顶部有 title 或者 icon 时的边距 /// @@ -83,7 +131,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? contentPaddingSm; + EdgeInsets? _contentPaddingSm; + + EdgeInsets get contentPaddingSm => + _contentPaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentPaddingSm; /// content 当顶部无 title 或者 icon 时的边距 /// @@ -92,7 +144,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? contentPaddingLg; + EdgeInsets? _contentPaddingLg; + + EdgeInsets get contentPaddingLg => + _contentPaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentPaddingLg; /// message 内容样式 /// @@ -100,11 +156,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextImportant], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentTextStyle; /// 内容文字的对齐 /// 默认为 [TextAlign.center] - TextAlign? contentTextAlign; + TextAlign? _contentTextAlign; + + TextAlign get contentTextAlign => + _contentTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.contentTextAlign; /// warning 当顶部有 title/icon/content 时的边距 /// @@ -113,7 +177,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? warningPaddingSm; + EdgeInsets? _warningPaddingSm; + + EdgeInsets get warningPaddingSm => + _warningPaddingSm ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningPaddingSm; /// warning 当顶部无 title/icon/content 时的边距 /// @@ -122,7 +190,11 @@ class BrnDialogConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingXl], /// right: [BrnCommonConfig.hSpacingXl], /// ) - EdgeInsets? warningPaddingLg; + EdgeInsets? _warningPaddingLg; + + EdgeInsets get warningPaddingLg => + _warningPaddingLg ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningPaddingLg; /// 警告样式 /// @@ -130,16 +202,28 @@ class BrnDialogConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandError], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? warningTextStyle; + BrnTextStyle? _warningTextStyle; + + BrnTextStyle get warningTextStyle => + _warningTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningTextStyle; /// 警示文案文字的对齐 /// 默认为 [TextAlign.center] - TextAlign? warningTextAlign; + TextAlign? _warningTextAlign; + + TextAlign get warningTextAlign => + _warningTextAlign ?? + BrnDefaultConfigUtils.defaultDialogConfig.warningTextAlign; /// action 顶部 divider 的上方边距 /// /// EdgeInsets.only(top: 28) - EdgeInsets? dividerPadding; + EdgeInsets? _dividerPadding; + + EdgeInsets get dividerPadding => + _dividerPadding ?? + BrnDefaultConfigUtils.defaultDialogConfig.dividerPadding; /// 主色调按钮样式 /// @@ -148,11 +232,19 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? mainActionTextStyle; + BrnTextStyle? _mainActionTextStyle; + + BrnTextStyle get mainActionTextStyle => + _mainActionTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.mainActionTextStyle; /// 主色调按钮的背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? mainActionBackgroundColor; + Color? _mainActionBackgroundColor; + + Color get mainActionBackgroundColor => + _mainActionBackgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.mainActionBackgroundColor; /// 其他按钮的样式(超2个时按钮样式) /// BrnTextStyle( @@ -160,19 +252,34 @@ class BrnDialogConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? assistActionsTextStyle; + BrnTextStyle? _assistActionsTextStyle; + + BrnTextStyle get assistActionsTextStyle => + _assistActionsTextStyle ?? + BrnDefaultConfigUtils.defaultDialogConfig.assistActionsTextStyle; /// 其他按钮的背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? assistActionsBackgroundColor; + Color? _assistActionsBackgroundColor; + + Color get assistActionsBackgroundColor => + _assistActionsBackgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.assistActionsBackgroundColor; /// 底部按钮高度 /// 默认为 44.0 - double? bottomHeight; + double? _bottomHeight; + + double get bottomHeight => + _bottomHeight ?? BrnDefaultConfigUtils.defaultDialogConfig.bottomHeight; /// Dialog背景 /// 默认为 [BrnCommonConfig.fillBase] - Color? backgroundColor; + Color? _backgroundColor; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultDialogConfig.backgroundColor; /// 按优先级,打平 【Bruno 内置配置】 < 【用户全局的默认配置】 < 【用户特殊配置】 < 【临时组件配置】 /// @@ -192,92 +299,92 @@ class BrnDialogConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnDialogConfig? dialogConfig = BrnThemeConfigurator.instance + BrnDialogConfig dialogConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .dialogConfig; - dialogWidth ??= dialogConfig?.dialogWidth; - radius ??= commonConfig.radiusLg; - titlePaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXxl ?? 0, - right: commonConfig.hSpacingXxl ?? 0, - top: dialogConfig?.titlePaddingSm?.top ?? 0, - bottom: dialogConfig?.titlePaddingSm?.bottom ?? 0, + _dialogWidth ??= dialogConfig.dialogWidth; + _radius ??= commonConfig.radiusLg; + _titlePaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXxl, + right: commonConfig.hSpacingXxl, + top: dialogConfig.titlePaddingSm.top, + bottom: dialogConfig.titlePaddingSm.bottom, ); - titlePaddingLg ??= EdgeInsets.only( - left: commonConfig.hSpacingXxl ?? 0, - right: commonConfig.hSpacingXxl ?? 0, - top: dialogConfig?.titlePaddingLg?.top ?? 0, - bottom: dialogConfig?.titlePaddingLg?.bottom ?? 0, + _titlePaddingLg ??= EdgeInsets.only( + left: commonConfig.hSpacingXxl, + right: commonConfig.hSpacingXxl, + top: dialogConfig.titlePaddingLg.top, + bottom: dialogConfig.titlePaddingLg.bottom, ); - iconPadding ??= EdgeInsets.only( - left: dialogConfig?.iconPadding?.left ?? 0, - top: commonConfig.vSpacingXxl ?? 0, - right: dialogConfig?.iconPadding?.right ?? 0, - bottom: dialogConfig?.iconPadding?.bottom ?? 0, + _iconPadding ??= EdgeInsets.only( + left: dialogConfig.iconPadding.left, + top: commonConfig.vSpacingXxl, + right: dialogConfig.iconPadding.right, + bottom: dialogConfig.iconPadding.bottom, ); - titleTextStyle = dialogConfig?.titleTextStyle?.merge( + _titleTextStyle = dialogConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - contentTextStyle = dialogConfig?.contentTextStyle?.merge( + _contentTextStyle = dialogConfig.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextImportant, fontSize: commonConfig.fontSizeBase, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - warningTextStyle = dialogConfig?.warningTextStyle?.merge( + _warningTextStyle = dialogConfig.warningTextStyle.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeBase, - ).merge(warningTextStyle), + ).merge(_warningTextStyle), ); - mainActionTextStyle = dialogConfig?.mainActionTextStyle?.merge( + _mainActionTextStyle = dialogConfig.mainActionTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(mainActionTextStyle), + ).merge(_mainActionTextStyle), ); - assistActionsTextStyle = dialogConfig?.assistActionsTextStyle?.merge( + _assistActionsTextStyle = dialogConfig.assistActionsTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(assistActionsTextStyle), + ).merge(_assistActionsTextStyle), ); - contentPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.contentPaddingSm?.top ?? 0, - bottom: dialogConfig?.contentPaddingSm?.bottom ?? 0, + _contentPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.contentPaddingSm.top, + bottom: dialogConfig.contentPaddingSm.bottom, ); - contentPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.contentPaddingLg?.top ?? 0, - bottom: dialogConfig?.contentPaddingLg?.bottom ?? 0, + _contentPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.contentPaddingLg.top, + bottom: dialogConfig.contentPaddingLg.bottom, ); - warningPaddingSm ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.warningPaddingSm?.top ?? 0, - bottom: dialogConfig?.warningPaddingSm?.bottom ?? 0, + _warningPaddingSm ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.warningPaddingSm.top, + bottom: dialogConfig.warningPaddingSm.bottom, ); - warningPaddingLg ??= EdgeInsets.only( - left: commonConfig.hSpacingXl ?? 0, - right: commonConfig.hSpacingXl ?? 0, - top: dialogConfig?.warningPaddingLg?.top ?? 0, - bottom: dialogConfig?.warningPaddingLg?.bottom ?? 0, + _warningPaddingLg ??= EdgeInsets.only( + left: commonConfig.hSpacingXl, + right: commonConfig.hSpacingXl, + top: dialogConfig.warningPaddingLg.top, + bottom: dialogConfig.warningPaddingLg.bottom, ); - titleTextAlign ??= dialogConfig?.titleTextAlign; - contentTextAlign ??= dialogConfig?.contentTextAlign; - warningTextAlign ??= dialogConfig?.warningTextAlign; - mainActionBackgroundColor ??= commonConfig.fillBase; - assistActionsBackgroundColor ??= commonConfig.fillBase; - bottomHeight ??= dialogConfig?.bottomHeight; - dividerPadding ??= dialogConfig?.dividerPadding; - backgroundColor ??= commonConfig.fillBase; + _titleTextAlign ??= dialogConfig.titleTextAlign; + _contentTextAlign ??= dialogConfig.contentTextAlign; + _warningTextAlign ??= dialogConfig.warningTextAlign; + _mainActionBackgroundColor ??= commonConfig.fillBase; + _assistActionsBackgroundColor ??= commonConfig.fillBase; + _bottomHeight ??= dialogConfig.bottomHeight; + _dividerPadding ??= dialogConfig.dividerPadding; + _backgroundColor ??= commonConfig.fillBase; } BrnDialogConfig copyWith({ @@ -305,66 +412,59 @@ class BrnDialogConfig extends BrnBaseConfig { Color? backgroundColor, }) { return BrnDialogConfig( - dialogWidth: dialogWidth ?? this.dialogWidth, - radius: radius ?? this.radius, - iconPadding: iconPadding ?? this.iconPadding, - titlePaddingSm: titlePaddingSm ?? this.titlePaddingSm, - titlePaddingLg: titlePaddingLg ?? this.titlePaddingLg, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - titleTextAlign: titleTextAlign ?? this.titleTextAlign, - contentPaddingSm: contentPaddingSm ?? this.contentPaddingSm, - contentPaddingLg: contentPaddingLg ?? this.contentPaddingLg, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - contentTextAlign: contentTextAlign ?? this.contentTextAlign, - warningPaddingSm: warningPaddingSm ?? this.warningPaddingSm, - warningPaddingLg: warningPaddingLg ?? this.warningPaddingLg, - warningTextStyle: warningTextStyle ?? this.warningTextStyle, - warningTextAlign: warningTextAlign ?? this.warningTextAlign, - dividerPadding: dividerPadding ?? this.dividerPadding, - mainActionTextStyle: mainActionTextStyle ?? this.mainActionTextStyle, - assistActionsTextStyle: - assistActionsTextStyle ?? this.assistActionsTextStyle, + dialogWidth: dialogWidth ?? _dialogWidth, + radius: radius ?? _radius, + iconPadding: iconPadding ?? _iconPadding, + titlePaddingSm: titlePaddingSm ?? _titlePaddingSm, + titlePaddingLg: titlePaddingLg ?? _titlePaddingLg, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + titleTextAlign: titleTextAlign ?? _titleTextAlign, + contentPaddingSm: contentPaddingSm ?? _contentPaddingSm, + contentPaddingLg: contentPaddingLg ?? _contentPaddingLg, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + contentTextAlign: contentTextAlign ?? _contentTextAlign, + warningPaddingSm: warningPaddingSm ?? _warningPaddingSm, + warningPaddingLg: warningPaddingLg ?? _warningPaddingLg, + warningTextStyle: warningTextStyle ?? _warningTextStyle, + warningTextAlign: warningTextAlign ?? _warningTextAlign, + dividerPadding: dividerPadding ?? _dividerPadding, + mainActionTextStyle: mainActionTextStyle ?? _mainActionTextStyle, + assistActionsTextStyle: assistActionsTextStyle ?? _assistActionsTextStyle, mainActionBackgroundColor: - mainActionBackgroundColor ?? this.mainActionBackgroundColor, + mainActionBackgroundColor ?? _mainActionBackgroundColor, assistActionsBackgroundColor: - assistActionsBackgroundColor ?? this.assistActionsBackgroundColor, - bottomHeight: bottomHeight ?? this.bottomHeight, - backgroundColor: backgroundColor ?? this.backgroundColor, + assistActionsBackgroundColor ?? _assistActionsBackgroundColor, + bottomHeight: bottomHeight ?? _bottomHeight, + backgroundColor: backgroundColor ?? _backgroundColor, ); } BrnDialogConfig merge(BrnDialogConfig? other) { if (other == null) return this; return copyWith( - dialogWidth: other.dialogWidth, - radius: other.radius, - iconPadding: other.iconPadding, - titlePaddingSm: other.titlePaddingSm, - titlePaddingLg: other.titlePaddingLg, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - titleTextAlign: other.titleTextAlign, - contentPaddingSm: other.contentPaddingSm, - contentPaddingLg: other.contentPaddingLg, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - contentTextAlign: other.contentTextAlign, - warningPaddingSm: other.warningPaddingSm, - warningPaddingLg: other.warningPaddingLg, - warningTextStyle: warningTextStyle?.merge(other.warningTextStyle) ?? - other.warningTextStyle, - warningTextAlign: other.warningTextAlign, - dividerPadding: other.dividerPadding, - mainActionTextStyle: - mainActionTextStyle?.merge(other.mainActionTextStyle) ?? - other.mainActionTextStyle, + dialogWidth: other._dialogWidth, + radius: other._radius, + iconPadding: other._iconPadding, + titlePaddingSm: other._titlePaddingSm, + titlePaddingLg: other._titlePaddingLg, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + titleTextAlign: other._titleTextAlign, + contentPaddingSm: other._contentPaddingSm, + contentPaddingLg: other._contentPaddingLg, + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + contentTextAlign: other._contentTextAlign, + warningPaddingSm: other._warningPaddingSm, + warningPaddingLg: other._warningPaddingLg, + warningTextStyle: warningTextStyle.merge(other._warningTextStyle), + warningTextAlign: other._warningTextAlign, + dividerPadding: other._dividerPadding, + mainActionTextStyle: mainActionTextStyle.merge(other._mainActionTextStyle), assistActionsTextStyle: - assistActionsTextStyle?.merge(other.assistActionsTextStyle) ?? - other.assistActionsTextStyle, - mainActionBackgroundColor: other.mainActionBackgroundColor, - assistActionsBackgroundColor: other.assistActionsBackgroundColor, - bottomHeight: other.bottomHeight, - backgroundColor: other.backgroundColor, + assistActionsTextStyle.merge(other._assistActionsTextStyle), + mainActionBackgroundColor: other._mainActionBackgroundColor, + assistActionsBackgroundColor: other._assistActionsBackgroundColor, + bottomHeight: other._bottomHeight, + backgroundColor: other._backgroundColor, ); } } diff --git a/lib/src/theme/configs/brn_enhance_number_card_config.dart b/lib/src/theme/configs/brn_enhance_number_card_config.dart index d0243fd4..12c261aa 100644 --- a/lib/src/theme/configs/brn_enhance_number_card_config.dart +++ b/lib/src/theme/configs/brn_enhance_number_card_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -8,23 +9,48 @@ class BrnEnhanceNumberCardConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig] BrnEnhanceNumberCardConfig({ - this.runningSpace, - this.itemRunningSpace, - this.titleTextStyle, - this.descTextStyle, - this.dividerWidth, + double? runningSpace, + double? itemRunningSpace, + BrnTextStyle? titleTextStyle, + BrnTextStyle? descTextStyle, + double? dividerWidth, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _runningSpace = runningSpace, + _itemRunningSpace = itemRunningSpace, + _titleTextStyle = titleTextStyle, + _descTextStyle = descTextStyle, + _dividerWidth = dividerWidth, + super(configId: configId); /// 如果超过一行,行间距 - double? runningSpace; + double? _runningSpace; + + double get runningSpace => + _runningSpace ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.runningSpace; /// Item的上半部分和下半部分的间距 - double? itemRunningSpace; - double? dividerWidth; + double? _itemRunningSpace; + + double get itemRunningSpace => + _itemRunningSpace ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.itemRunningSpace; + + double? _dividerWidth; + + double get dividerWidth => + _dividerWidth ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.dividerWidth; + BrnTextStyle? _titleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.titleTextStyle; + BrnTextStyle? _descTextStyle; - BrnTextStyle? titleTextStyle; - BrnTextStyle? descTextStyle; + BrnTextStyle get descTextStyle => + _descTextStyle ?? + BrnDefaultConfigUtils.defaultEnhanceNumberInfoConfig.descTextStyle; @override void initThemeConfig( @@ -36,18 +62,18 @@ class BrnEnhanceNumberCardConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnEnhanceNumberCardConfig? userConfig = BrnThemeConfigurator.instance + BrnEnhanceNumberCardConfig userConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .enhanceNumberCardConfig; - runningSpace ??= userConfig?.runningSpace; - itemRunningSpace ??= userConfig?.itemRunningSpace; - dividerWidth ??= userConfig?.dividerWidth; - titleTextStyle = userConfig?.titleTextStyle?.merge( - BrnTextStyle(color: commonConfig.colorTextBase).merge(titleTextStyle), + _runningSpace ??= userConfig._runningSpace; + _itemRunningSpace ??= userConfig._itemRunningSpace; + _dividerWidth ??= userConfig._dividerWidth; + _titleTextStyle = userConfig.titleTextStyle.merge( + BrnTextStyle(color: commonConfig.colorTextBase).merge(_titleTextStyle), ); - descTextStyle = userConfig?.descTextStyle?.merge( - BrnTextStyle(color: commonConfig.colorTextSecondary).merge(descTextStyle), + _descTextStyle = userConfig.descTextStyle.merge( + BrnTextStyle(color: commonConfig.colorTextSecondary).merge(_descTextStyle), ); } @@ -59,24 +85,22 @@ class BrnEnhanceNumberCardConfig extends BrnBaseConfig { BrnTextStyle? descTextStyle, }) { return BrnEnhanceNumberCardConfig( - runningSpace: runningSpace ?? this.runningSpace, - itemRunningSpace: itemRunningSpace ?? this.itemRunningSpace, - dividerWidth: dividerWidth ?? this.dividerWidth, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - descTextStyle: descTextStyle ?? this.descTextStyle, + runningSpace: runningSpace ?? _runningSpace, + itemRunningSpace: itemRunningSpace ?? _itemRunningSpace, + dividerWidth: dividerWidth ?? _dividerWidth, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + descTextStyle: descTextStyle ?? _descTextStyle, ); } BrnEnhanceNumberCardConfig merge(BrnEnhanceNumberCardConfig? other) { if (other == null) return this; return copyWith( - runningSpace: other.runningSpace, - itemRunningSpace: other.itemRunningSpace, - dividerWidth: other.dividerWidth, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - descTextStyle: - descTextStyle?.merge(other.descTextStyle) ?? other.descTextStyle, + runningSpace: other._runningSpace, + itemRunningSpace: other._itemRunningSpace, + dividerWidth: other._dividerWidth, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + descTextStyle: descTextStyle.merge(other._descTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_form_config.dart b/lib/src/theme/configs/brn_form_config.dart index 210e3e95..0a932215 100644 --- a/lib/src/theme/configs/brn_form_config.dart +++ b/lib/src/theme/configs/brn_form_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,24 +10,40 @@ class BrnFormItemConfig extends BrnBaseConfig { /// 遵循全局配置 /// 默认为 [BrnDefaultConfigUtils.defaultFormItemConfig] BrnFormItemConfig({ - this.titleTextStyle, - this.subTitleTextStyle, - this.errorTextStyle, - this.hintTextStyle, - this.contentTextStyle, - this.formPadding, - this.titlePaddingSm, - this.titlePaddingLg, - this.optionsMiddlePadding, - this.subTitlePadding, - this.errorPadding, - this.disableTextStyle, - this.tipsTextStyle, - this.headTitleTextStyle, - this.optionTextStyle, - this.optionSelectedTextStyle, + BrnTextStyle? titleTextStyle, + BrnTextStyle? subTitleTextStyle, + BrnTextStyle? errorTextStyle, + BrnTextStyle? hintTextStyle, + BrnTextStyle? contentTextStyle, + EdgeInsets? formPadding, + EdgeInsets? titlePaddingSm, + EdgeInsets? titlePaddingLg, + EdgeInsets? optionsMiddlePadding, + EdgeInsets? subTitlePadding, + EdgeInsets? errorPadding, + BrnTextStyle? disableTextStyle, + BrnTextStyle? tipsTextStyle, + BrnTextStyle? headTitleTextStyle, + BrnTextStyle? optionTextStyle, + BrnTextStyle? optionSelectedTextStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _titleTextStyle = titleTextStyle, + _subTitleTextStyle = subTitleTextStyle, + _errorTextStyle = errorTextStyle, + _hintTextStyle = hintTextStyle, + _contentTextStyle = contentTextStyle, + _formPadding = formPadding, + _titlePaddingSm = titlePaddingSm, + _titlePaddingLg = titlePaddingLg, + _optionsMiddlePadding = optionsMiddlePadding, + _subTitlePadding = subTitlePadding, + _errorPadding = errorPadding, + _disableTextStyle = disableTextStyle, + _tipsTextStyle = tipsTextStyle, + _headTitleTextStyle = headTitleTextStyle, + _optionTextStyle = optionTextStyle, + _optionSelectedTextStyle = optionSelectedTextStyle, + super(configId: configId); BrnFormItemConfig.generatorFromConfigId(String configId) { initThemeConfig(configId); @@ -38,7 +55,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeHead], /// ) - BrnTextStyle? headTitleTextStyle; + BrnTextStyle? _headTitleTextStyle; /// 左侧标题文本样式 /// @@ -46,7 +63,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 左侧辅助文本样式 /// @@ -54,7 +71,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? subTitleTextStyle; + BrnTextStyle? _subTitleTextStyle; /// 左侧 Error 文本样式 /// @@ -62,7 +79,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandError], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? errorTextStyle; + BrnTextStyle? _errorTextStyle; /// 右侧 输入、选择提示文本样式 /// @@ -70,7 +87,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? hintTextStyle; + BrnTextStyle? _hintTextStyle; /// 右侧 主要内容样式 /// @@ -78,7 +95,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? contentTextStyle; + BrnTextStyle? _contentTextStyle; /// 表单项 当有星号标识 上下右边距 /// @@ -88,22 +105,22 @@ class BrnFormItemConfig extends BrnBaseConfig { /// right: [BrnCommonConfig.hSpacingLg], /// bottom: [BrnCommonConfig.vSpacingLg], /// ) - EdgeInsets? formPadding; + EdgeInsets? _formPadding; /// 表单项 当有星号标识 左边距 /// /// EdgeInsets.only(left: 10) - EdgeInsets? titlePaddingSm; + EdgeInsets? _titlePaddingSm; /// 表单项 当无星号标识 左右边距 /// /// EdgeInsets.only(left: [BrnCommonConfig.hSpacingLg]) - EdgeInsets? titlePaddingLg; + EdgeInsets? _titlePaddingLg; /// 选项之间间距 单选 or 多选 /// /// EdgeInsets.only(left: [BrnCommonConfig.hSpacingMd]) - EdgeInsets? optionsMiddlePadding; + EdgeInsets? _optionsMiddlePadding; /// 选项普通文本样式 /// @@ -112,7 +129,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// height: 1.3, /// ) - BrnTextStyle? optionTextStyle; + BrnTextStyle? _optionTextStyle; /// 选项选中文本样式 /// @@ -121,7 +138,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// height: 1.3, /// ) - BrnTextStyle? optionSelectedTextStyle; + BrnTextStyle? _optionSelectedTextStyle; /// 子标题 左上间距 /// @@ -129,7 +146,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingLg], /// top: [BrnCommonConfig.vSpacingXs], /// ) - EdgeInsets? subTitlePadding; + EdgeInsets? _subTitlePadding; /// error提示 左上间距 /// @@ -137,7 +154,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// left: [BrnCommonConfig.hSpacingLg], /// top: [BrnCommonConfig.vSpacingXs], /// ) - EdgeInsets? errorPadding; + EdgeInsets? _errorPadding; /// 不可修改内容展示 /// @@ -145,7 +162,7 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextDisabled], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? disableTextStyle; + BrnTextStyle? _disableTextStyle; /// 提示文本样式 /// @@ -153,7 +170,69 @@ class BrnFormItemConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? tipsTextStyle; + BrnTextStyle? _tipsTextStyle; + + BrnTextStyle get headTitleTextStyle => + _headTitleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.headTitleTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titleTextStyle; + + BrnTextStyle get subTitleTextStyle => + _subTitleTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.subTitleTextStyle; + + BrnTextStyle get errorTextStyle => + _errorTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.errorTextStyle; + + BrnTextStyle get hintTextStyle => + _hintTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.hintTextStyle; + + BrnTextStyle get contentTextStyle => + _contentTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.contentTextStyle; + + EdgeInsets get formPadding => + _formPadding ?? BrnDefaultConfigUtils.defaultFormItemConfig.formPadding; + + EdgeInsets get titlePaddingSm => + _titlePaddingSm ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titlePaddingSm; + + EdgeInsets get titlePaddingLg => + _titlePaddingLg ?? + BrnDefaultConfigUtils.defaultFormItemConfig.titlePaddingLg; + + EdgeInsets get optionsMiddlePadding => + _optionsMiddlePadding ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionsMiddlePadding; + + BrnTextStyle get optionTextStyle => + _optionTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionTextStyle; + + BrnTextStyle get optionSelectedTextStyle => + _optionSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.optionSelectedTextStyle; + + EdgeInsets get subTitlePadding => + _subTitlePadding ?? + BrnDefaultConfigUtils.defaultFormItemConfig.subTitlePadding; + + EdgeInsets get errorPadding => + _errorPadding ?? BrnDefaultConfigUtils.defaultFormItemConfig.errorPadding; + + BrnTextStyle get disableTextStyle => + _disableTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.disableTextStyle; + + BrnTextStyle get tipsTextStyle => + _tipsTextStyle ?? + BrnDefaultConfigUtils.defaultFormItemConfig.tipsTextStyle; /// 举例: /// ① 尝试获取最近的配置 [topRadius] 若配不为 null,直接使用该配置. @@ -171,91 +250,91 @@ class BrnFormItemConfig extends BrnBaseConfig { ); /// 用户全局form组件配置 - BrnFormItemConfig? formItemThemeData = BrnThemeConfigurator.instance + BrnFormItemConfig formItemThemeData = BrnThemeConfigurator.instance .getConfig(configId: configId) .formItemConfig; - titlePaddingSm ??= formItemThemeData?.titlePaddingSm; - titlePaddingLg ??= formItemThemeData?.titlePaddingLg; - optionSelectedTextStyle = formItemThemeData?.optionSelectedTextStyle?.merge( + _titlePaddingSm ??= formItemThemeData.titlePaddingSm; + _titlePaddingLg ??= formItemThemeData.titlePaddingLg; + _optionSelectedTextStyle = formItemThemeData.optionSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(optionSelectedTextStyle), + ).merge(_optionSelectedTextStyle), ); - optionTextStyle = formItemThemeData?.optionTextStyle?.merge( + _optionTextStyle = formItemThemeData.optionTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(optionTextStyle), + ).merge(_optionTextStyle), ); - headTitleTextStyle = formItemThemeData?.headTitleTextStyle?.merge( + _headTitleTextStyle = formItemThemeData.headTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(headTitleTextStyle), + ).merge(_headTitleTextStyle), ); - errorPadding ??= EdgeInsets.only( - left: commonConfig.hSpacingLg ?? 0, - right: formItemThemeData?.errorPadding?.right ?? 0, - top: commonConfig.vSpacingXs ?? 0, - bottom: formItemThemeData?.errorPadding?.bottom ?? 0, + _errorPadding ??= EdgeInsets.only( + left: commonConfig.hSpacingLg, + right: formItemThemeData.errorPadding.right, + top: commonConfig.vSpacingXs, + bottom: formItemThemeData.errorPadding.bottom, ); - subTitlePadding ??= EdgeInsets.only( - left: commonConfig.hSpacingLg ?? 0, - right: formItemThemeData?.subTitlePadding?.right ?? 0, - top: commonConfig.vSpacingXs ?? 0, - bottom: formItemThemeData?.subTitlePadding?.bottom ?? 0, + _subTitlePadding ??= EdgeInsets.only( + left: commonConfig.hSpacingLg, + right: formItemThemeData.subTitlePadding.right, + top: commonConfig.vSpacingXs, + bottom: formItemThemeData.subTitlePadding.bottom, ); - formPadding ??= EdgeInsets.only( - left: formItemThemeData?.formPadding?.left ?? 0, - right: commonConfig.hSpacingLg ?? 0, - top: commonConfig.vSpacingLg ?? 0, - bottom: commonConfig.vSpacingLg ?? 0, + _formPadding ??= EdgeInsets.only( + left: formItemThemeData.formPadding.left, + right: commonConfig.hSpacingLg, + top: commonConfig.vSpacingLg, + bottom: commonConfig.vSpacingLg, ); - tipsTextStyle = formItemThemeData?.tipsTextStyle?.merge( + _tipsTextStyle = formItemThemeData.tipsTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(tipsTextStyle), + ).merge(_tipsTextStyle), ); - disableTextStyle = formItemThemeData?.disableTextStyle?.merge( + _disableTextStyle = formItemThemeData.disableTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextDisabled, fontSize: commonConfig.fontSizeSubHead, - ).merge(disableTextStyle), + ).merge(_disableTextStyle), ); - contentTextStyle = formItemThemeData?.contentTextStyle?.merge( + _contentTextStyle = formItemThemeData.contentTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(contentTextStyle), + ).merge(_contentTextStyle), ); - hintTextStyle = formItemThemeData?.hintTextStyle?.merge( + _hintTextStyle = formItemThemeData.hintTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeSubHead, - ).merge(hintTextStyle), + ).merge(_hintTextStyle), ); - titleTextStyle = formItemThemeData?.titleTextStyle?.merge( + _titleTextStyle = formItemThemeData.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - subTitleTextStyle = formItemThemeData?.subTitleTextStyle?.merge( + _subTitleTextStyle = formItemThemeData.subTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeCaption, - ).merge(subTitleTextStyle), + ).merge(_subTitleTextStyle), ); - errorTextStyle = formItemThemeData?.errorTextStyle?.merge( + _errorTextStyle = formItemThemeData.errorTextStyle.merge( BrnTextStyle( color: commonConfig.brandError, fontSize: commonConfig.fontSizeCaption, - ).merge(errorTextStyle), + ).merge(_errorTextStyle), ); - optionsMiddlePadding ??= formItemThemeData?.optionsMiddlePadding; + _optionsMiddlePadding ??= formItemThemeData.optionsMiddlePadding; } BrnFormItemConfig copyWith({ @@ -277,56 +356,46 @@ class BrnFormItemConfig extends BrnBaseConfig { BrnTextStyle? optionSelectedTextStyle, }) { return BrnFormItemConfig( - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - subTitleTextStyle: subTitleTextStyle ?? this.subTitleTextStyle, - errorTextStyle: errorTextStyle ?? this.errorTextStyle, - hintTextStyle: hintTextStyle ?? this.hintTextStyle, - contentTextStyle: contentTextStyle ?? this.contentTextStyle, - formPadding: formPadding ?? this.formPadding, - titlePaddingSm: titlePaddingSm ?? this.titlePaddingSm, - titlePaddingLg: titlePaddingLg ?? this.titlePaddingLg, - optionsMiddlePadding: optionsMiddlePadding ?? this.optionsMiddlePadding, - subTitlePadding: subTitlePadding ?? this.subTitlePadding, - errorPadding: errorPadding ?? this.errorPadding, - disableTextStyle: disableTextStyle ?? this.disableTextStyle, - tipsTextStyle: tipsTextStyle ?? this.tipsTextStyle, - headTitleTextStyle: headTitleTextStyle ?? this.headTitleTextStyle, - optionTextStyle: optionTextStyle ?? this.optionTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + subTitleTextStyle: subTitleTextStyle ?? _subTitleTextStyle, + errorTextStyle: errorTextStyle ?? _errorTextStyle, + hintTextStyle: hintTextStyle ?? _hintTextStyle, + contentTextStyle: contentTextStyle ?? _contentTextStyle, + formPadding: formPadding ?? _formPadding, + titlePaddingSm: titlePaddingSm ?? _titlePaddingSm, + titlePaddingLg: titlePaddingLg ?? _titlePaddingLg, + optionsMiddlePadding: optionsMiddlePadding ?? _optionsMiddlePadding, + subTitlePadding: subTitlePadding ?? _subTitlePadding, + errorPadding: errorPadding ?? _errorPadding, + disableTextStyle: disableTextStyle ?? _disableTextStyle, + tipsTextStyle: tipsTextStyle ?? _tipsTextStyle, + headTitleTextStyle: headTitleTextStyle ?? _headTitleTextStyle, + optionTextStyle: optionTextStyle ?? _optionTextStyle, optionSelectedTextStyle: - optionSelectedTextStyle ?? this.optionSelectedTextStyle, + optionSelectedTextStyle ?? _optionSelectedTextStyle, ); } BrnFormItemConfig merge(BrnFormItemConfig? other) { if (other == null) return this; return copyWith( - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - subTitleTextStyle: subTitleTextStyle?.merge(other.subTitleTextStyle) ?? - other.subTitleTextStyle, - errorTextStyle: - errorTextStyle?.merge(other.errorTextStyle) ?? other.errorTextStyle, - hintTextStyle: - hintTextStyle?.merge(other.hintTextStyle) ?? other.hintTextStyle, - contentTextStyle: contentTextStyle?.merge(other.contentTextStyle) ?? - other.contentTextStyle, - formPadding: other.formPadding, - titlePaddingSm: other.titlePaddingSm, - titlePaddingLg: other.titlePaddingLg, - optionsMiddlePadding: other.optionsMiddlePadding, - subTitlePadding: other.subTitlePadding, - errorPadding: other.errorPadding, - disableTextStyle: disableTextStyle?.merge(other.disableTextStyle) ?? - other.disableTextStyle, - tipsTextStyle: - tipsTextStyle?.merge(other.tipsTextStyle) ?? other.tipsTextStyle, - headTitleTextStyle: headTitleTextStyle?.merge(other.headTitleTextStyle) ?? - other.headTitleTextStyle, - optionTextStyle: optionTextStyle?.merge(other.optionTextStyle) ?? - other.optionTextStyle, + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + subTitleTextStyle: subTitleTextStyle.merge(other._subTitleTextStyle), + errorTextStyle: errorTextStyle.merge(other._errorTextStyle), + hintTextStyle: hintTextStyle.merge(other._hintTextStyle), + contentTextStyle: contentTextStyle.merge(other._contentTextStyle), + formPadding: other._formPadding, + titlePaddingSm: other._titlePaddingSm, + titlePaddingLg: other._titlePaddingLg, + optionsMiddlePadding: other._optionsMiddlePadding, + subTitlePadding: other._subTitlePadding, + errorPadding: other._errorPadding, + disableTextStyle: disableTextStyle.merge(other._disableTextStyle), + tipsTextStyle: tipsTextStyle.merge(other._tipsTextStyle), + headTitleTextStyle: headTitleTextStyle.merge(other._headTitleTextStyle), + optionTextStyle: optionTextStyle.merge(other._optionTextStyle), optionSelectedTextStyle: - optionSelectedTextStyle?.merge(other.optionSelectedTextStyle) ?? - other.optionSelectedTextStyle, + optionSelectedTextStyle.merge(other._optionSelectedTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_gallery_detail_config.dart b/lib/src/theme/configs/brn_gallery_detail_config.dart index 2dcbd9cb..0030e8e4 100644 --- a/lib/src/theme/configs/brn_gallery_detail_config.dart +++ b/lib/src/theme/configs/brn_gallery_detail_config.dart @@ -1,5 +1,6 @@ import 'package:bruno/src/components/navbar/brn_appbar_theme.dart'; import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -10,86 +11,99 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// 遵循全局配置 /// 默认为 [BrnDefaultConfigUtils.defaultGalleryDetailConfig] BrnGalleryDetailConfig({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, + BrnTextStyle? appbarTitleStyle, + BrnTextStyle? appbarActionStyle, + Color? appbarBackgroundColor, + Brightness? appbarBrightness, + BrnTextStyle? tabBarUnSelectedLabelStyle, + BrnTextStyle? tabBarLabelStyle, + Color? tabBarBackgroundColor, + Color? pageBackgroundColor, + Color? bottomBackgroundColor, + BrnTextStyle? titleStyle, + BrnTextStyle? contentStyle, + BrnTextStyle? actionStyle, + Color? iconColor, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _appbarTitleStyle = appbarTitleStyle, + _appbarActionStyle = appbarActionStyle, + _appbarBackgroundColor = appbarBackgroundColor, + _appbarBrightness = appbarBrightness, + _tabBarUnSelectedLabelStyle = tabBarUnSelectedLabelStyle, + _tabBarLabelStyle = tabBarLabelStyle, + _tabBarBackgroundColor = tabBarBackgroundColor, + _pageBackgroundColor = pageBackgroundColor, + _bottomBackgroundColor = bottomBackgroundColor, + _titleStyle = titleStyle, + _contentStyle = contentStyle, + _actionStyle = actionStyle, + _iconColor = iconColor, + super(configId: configId); /// 黑色主题 BrnGalleryDetailConfig.dark({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, + appbarTitleStyle, + appbarActionStyle, + appbarBackgroundColor, + appbarBrightness, + tabBarUnSelectedLabelStyle, + tabBarLabelStyle, + tabBarBackgroundColor, + pageBackgroundColor, + bottomBackgroundColor, + titleStyle, + contentStyle, + actionStyle, + iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { - appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - appbarActionStyle = BrnTextStyle(color: BrnAppBarTheme.lightTextColor); - appbarBackgroundColor = Colors.black; - appbarBrightness = Brightness.dark; - tabBarUnSelectedLabelStyle = BrnTextStyle(color: Color(0XFFCCCCCC)); - tabBarLabelStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - tabBarBackgroundColor = Colors.black; - pageBackgroundColor = Colors.black; - bottomBackgroundColor = Color(0X88000000); - titleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - contentStyle = BrnTextStyle(color: Color(0xFFCCCCCC)); - actionStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); - iconColor = Colors.white; + _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _appbarActionStyle = BrnTextStyle(color: BrnAppBarTheme.lightTextColor); + _appbarBackgroundColor = Colors.black; + _appbarBrightness = Brightness.dark; + _tabBarUnSelectedLabelStyle = BrnTextStyle(color: Color(0XFFCCCCCC)); + _tabBarLabelStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _tabBarBackgroundColor = Colors.black; + _pageBackgroundColor = Colors.black; + _bottomBackgroundColor = Color(0X88000000); + _titleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _contentStyle = BrnTextStyle(color: Color(0xFFCCCCCC)); + _actionStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); + _iconColor = Colors.white; } /// 白色主题 BrnGalleryDetailConfig.light({ - this.appbarTitleStyle, - this.appbarActionStyle, - this.appbarBackgroundColor, - this.appbarBrightness, - this.tabBarUnSelectedLabelStyle, - this.tabBarLabelStyle, - this.tabBarBackgroundColor, - this.pageBackgroundColor, - this.bottomBackgroundColor, - this.titleStyle, - this.contentStyle, - this.actionStyle, - this.iconColor, + appbarTitleStyle, + appbarActionStyle, + appbarBackgroundColor, + appbarBrightness, + tabBarUnSelectedLabelStyle, + tabBarLabelStyle, + tabBarBackgroundColor, + pageBackgroundColor, + bottomBackgroundColor, + titleStyle, + contentStyle, + actionStyle, + iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { - appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBase); - appbarActionStyle = BrnTextStyle(color: commonConfig.colorTextBase); - appbarBackgroundColor = commonConfig.fillBody; - appbarBrightness = Brightness.light; - tabBarUnSelectedLabelStyle = BrnTextStyle( + _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _appbarActionStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _appbarBackgroundColor = commonConfig.fillBody; + _appbarBrightness = Brightness.light; + _tabBarUnSelectedLabelStyle = BrnTextStyle( color: commonConfig.colorTextBase, ); - tabBarLabelStyle = BrnTextStyle(color: commonConfig.brandPrimary); - tabBarBackgroundColor = commonConfig.fillBody; - pageBackgroundColor = commonConfig.fillBody; - bottomBackgroundColor = commonConfig.fillBody?.withOpacity(.85); - titleStyle = BrnTextStyle(color: commonConfig.colorTextBase); - contentStyle = BrnTextStyle(color: commonConfig.colorTextBase); - actionStyle = BrnTextStyle(color: commonConfig.colorTextSecondary); - iconColor = commonConfig.colorTextSecondary; + _tabBarLabelStyle = BrnTextStyle(color: commonConfig.brandPrimary); + _tabBarBackgroundColor = commonConfig.fillBody; + _pageBackgroundColor = commonConfig.fillBody; + _bottomBackgroundColor = commonConfig.fillBody.withOpacity(.85); + _titleStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _contentStyle = BrnTextStyle(color: commonConfig.colorTextBase); + _actionStyle = BrnTextStyle(color: commonConfig.colorTextSecondary); + _iconColor = commonConfig.colorTextSecondary; } /// appbar brightness待定 @@ -101,7 +115,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? appbarTitleStyle; + BrnTextStyle? _appbarTitleStyle; /// 右侧操作区域文案样式 /// @@ -110,15 +124,15 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: BrnAppBarTheme.actionFontSize, /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? appbarActionStyle; + BrnTextStyle? _appbarActionStyle; /// appBar 背景色 /// 默认为 Colors.black - Color? appbarBackgroundColor; + Color? _appbarBackgroundColor; /// appbar brightness /// 默认为 [Brightness.dark] - Brightness? appbarBrightness; + Brightness? _appbarBrightness; /// tabBar 标题普通样式 /// @@ -126,7 +140,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: Colors.red, /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? tabBarUnSelectedLabelStyle; + BrnTextStyle? _tabBarUnSelectedLabelStyle; /// tabBar 标题选中样式 /// @@ -135,19 +149,19 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? tabBarLabelStyle; + BrnTextStyle? _tabBarLabelStyle; /// tabBar 背景色 /// 默认为 Colors.black - Color? tabBarBackgroundColor; + Color? _tabBarBackgroundColor; /// 页面 背景色 /// 默认为 Colors.black - Color? pageBackgroundColor; + Color? _pageBackgroundColor; /// 底部内容区域的背景色 /// 默认为 Color(0x88000000) - Color? bottomBackgroundColor; + Color? _bottomBackgroundColor; /// 标题文案样式 /// @@ -156,7 +170,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleStyle; + BrnTextStyle? _titleStyle; /// 内容文案样式 /// @@ -164,7 +178,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: Color(0xFFCCCCCC), /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? contentStyle; + BrnTextStyle? _contentStyle; /// 右侧展开收起样式 /// @@ -172,11 +186,63 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBaseInverse], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? actionStyle; + BrnTextStyle? _actionStyle; /// icon 颜色 /// 默认为 Colors.white - Color? iconColor; + Color? _iconColor; + + BrnTextStyle get appbarTitleStyle => + _appbarTitleStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarTitleStyle; + + BrnTextStyle get appbarActionStyle => + _appbarActionStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarActionStyle; + + Color get appbarBackgroundColor => + _appbarBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarBackgroundColor; + + Brightness get appbarBrightness => + _appbarBrightness ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.appbarBrightness; + + BrnTextStyle get tabBarUnSelectedLabelStyle => + _tabBarUnSelectedLabelStyle ?? + BrnDefaultConfigUtils + .defaultGalleryDetailConfig.tabBarUnSelectedLabelStyle; + + BrnTextStyle get tabBarLabelStyle => + _tabBarLabelStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.tabBarLabelStyle; + + Color get tabBarBackgroundColor => + _tabBarBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.tabBarBackgroundColor; + + Color get pageBackgroundColor => + _pageBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.pageBackgroundColor; + + Color get bottomBackgroundColor => + _bottomBackgroundColor ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.bottomBackgroundColor; + + BrnTextStyle get titleStyle => + _titleStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.titleStyle; + + BrnTextStyle get contentStyle => + _contentStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.contentStyle; + + BrnTextStyle get actionStyle => + _actionStyle ?? + BrnDefaultConfigUtils.defaultGalleryDetailConfig.actionStyle; + + Color get iconColor => + _iconColor ?? BrnDefaultConfigUtils.defaultGalleryDetailConfig.iconColor; @override void initThemeConfig( @@ -189,55 +255,56 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnGalleryDetailConfig? galleryDetailConfig = BrnThemeConfigurator.instance + BrnGalleryDetailConfig galleryDetailConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .galleryDetailConfig; - appbarTitleStyle = galleryDetailConfig?.appbarTitleStyle?.merge( + _appbarTitleStyle = galleryDetailConfig.appbarTitleStyle.merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, - ).merge(appbarTitleStyle), + ).merge(_appbarTitleStyle), ); - appbarActionStyle = galleryDetailConfig?.appbarActionStyle?.merge( - appbarActionStyle, + _appbarActionStyle = galleryDetailConfig.appbarActionStyle.merge( + _appbarActionStyle, ); - appbarBrightness ??= galleryDetailConfig?.appbarBrightness; - appbarBackgroundColor ??= galleryDetailConfig?.appbarBackgroundColor; - tabBarUnSelectedLabelStyle = galleryDetailConfig?.tabBarUnSelectedLabelStyle - ?.merge(BrnTextStyle(fontSize: commonConfig.fontSizeSubHead)) - .merge(tabBarUnSelectedLabelStyle); - tabBarLabelStyle = galleryDetailConfig?.tabBarLabelStyle - ?.merge( + _appbarBrightness ??= galleryDetailConfig.appbarBrightness; + _appbarBackgroundColor ??= galleryDetailConfig.appbarBackgroundColor; + _tabBarUnSelectedLabelStyle = galleryDetailConfig + .tabBarUnSelectedLabelStyle + .merge(BrnTextStyle(fontSize: commonConfig.fontSizeSubHead)) + .merge(_tabBarUnSelectedLabelStyle); + _tabBarLabelStyle = galleryDetailConfig.tabBarLabelStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeSubHead, ), ) - .merge(tabBarLabelStyle); - tabBarBackgroundColor ??= galleryDetailConfig?.tabBarBackgroundColor; - pageBackgroundColor ??= galleryDetailConfig?.pageBackgroundColor; - bottomBackgroundColor ??= galleryDetailConfig?.bottomBackgroundColor; - titleStyle = galleryDetailConfig?.titleStyle - ?.merge( + .merge(_tabBarLabelStyle); + _tabBarBackgroundColor ??= galleryDetailConfig._tabBarBackgroundColor; + _pageBackgroundColor ??= galleryDetailConfig._pageBackgroundColor; + _bottomBackgroundColor ??= galleryDetailConfig._bottomBackgroundColor; + _titleStyle = galleryDetailConfig.titleStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeHead, ), ) - .merge(titleStyle); - contentStyle = galleryDetailConfig?.contentStyle - ?.merge(BrnTextStyle(fontSize: commonConfig.fontSizeBase)) - .merge(contentStyle); - actionStyle = galleryDetailConfig?.actionStyle - ?.merge( + .merge(_titleStyle); + _contentStyle = galleryDetailConfig.contentStyle + .merge(BrnTextStyle(fontSize: commonConfig.fontSizeBase)) + .merge(_contentStyle); + _actionStyle = galleryDetailConfig.actionStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBaseInverse, fontSize: commonConfig.fontSizeBase, ), ) - .merge(actionStyle); - iconColor ??= galleryDetailConfig?.iconColor; + .merge(_actionStyle); + _iconColor ??= galleryDetailConfig._iconColor; } BrnGalleryDetailConfig copyWith({ @@ -259,48 +326,41 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { Color? iconColor, }) { return BrnGalleryDetailConfig( - appbarTitleStyle: appbarTitleStyle ?? this.appbarTitleStyle, - appbarActionStyle: appbarActionStyle ?? this.appbarActionStyle, - appbarBackgroundColor: - appbarBackgroundColor ?? this.appbarBackgroundColor, - appbarBrightness: appbarBrightness ?? this.appbarBrightness, + appbarTitleStyle: appbarTitleStyle ?? _appbarTitleStyle, + appbarActionStyle: appbarActionStyle ?? _appbarActionStyle, + appbarBackgroundColor: appbarBackgroundColor ?? _appbarBackgroundColor, + appbarBrightness: appbarBrightness ?? _appbarBrightness, tabBarUnSelectedLabelStyle: - tabBarUnSelectedLabelStyle ?? this.tabBarUnSelectedLabelStyle, - tabBarLabelStyle: tabBarLabelStyle ?? this.tabBarLabelStyle, - tabBarBackgroundColor: - tabBarBackgroundColor ?? this.tabBarBackgroundColor, - pageBackgroundColor: pageBackgroundColor ?? this.pageBackgroundColor, - bottomBackgroundColor: - bottomBackgroundColor ?? this.bottomBackgroundColor, - titleStyle: titleStyle ?? this.titleStyle, - contentStyle: contentStyle ?? this.contentStyle, - actionStyle: actionStyle ?? this.actionStyle, - iconColor: iconColor ?? this.iconColor, + tabBarUnSelectedLabelStyle ?? _tabBarUnSelectedLabelStyle, + tabBarLabelStyle: tabBarLabelStyle ?? _tabBarLabelStyle, + tabBarBackgroundColor: tabBarBackgroundColor ?? _tabBarBackgroundColor, + pageBackgroundColor: pageBackgroundColor ?? _pageBackgroundColor, + bottomBackgroundColor: bottomBackgroundColor ?? _bottomBackgroundColor, + titleStyle: titleStyle ?? _titleStyle, + contentStyle: contentStyle ?? _contentStyle, + actionStyle: actionStyle ?? _actionStyle, + iconColor: iconColor ?? _iconColor, ); } BrnGalleryDetailConfig merge(BrnGalleryDetailConfig? other) { if (other == null) return this; return copyWith( - appbarTitleStyle: appbarTitleStyle?.merge(other.appbarTitleStyle) ?? - other.appbarTitleStyle, - appbarActionStyle: appbarActionStyle?.merge(other.appbarActionStyle) ?? - other.appbarActionStyle, - appbarBackgroundColor: other.appbarBackgroundColor, - appbarBrightness: other.appbarBrightness, + appbarTitleStyle: appbarTitleStyle.merge(other._appbarTitleStyle), + appbarActionStyle: appbarActionStyle.merge(other._appbarActionStyle), + appbarBackgroundColor: other._appbarBackgroundColor, + appbarBrightness: other._appbarBrightness, tabBarUnSelectedLabelStyle: - tabBarUnSelectedLabelStyle?.merge(other.tabBarUnSelectedLabelStyle) ?? - other.tabBarUnSelectedLabelStyle, - tabBarLabelStyle: tabBarLabelStyle?.merge(other.tabBarLabelStyle) ?? - other.tabBarLabelStyle, - tabBarBackgroundColor: other.tabBarBackgroundColor, - pageBackgroundColor: other.pageBackgroundColor, - bottomBackgroundColor: other.bottomBackgroundColor, - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, + tabBarUnSelectedLabelStyle.merge(other._tabBarUnSelectedLabelStyle), + tabBarLabelStyle: tabBarLabelStyle.merge(other._tabBarLabelStyle), + tabBarBackgroundColor: other._tabBarBackgroundColor, + pageBackgroundColor: other._pageBackgroundColor, + bottomBackgroundColor: other._bottomBackgroundColor, + titleStyle: titleStyle.merge(other._titleStyle), contentStyle: - contentStyle?.merge(other.contentStyle) ?? other.contentStyle, - actionStyle: actionStyle?.merge(other.actionStyle) ?? other.actionStyle, - iconColor: other.iconColor, + contentStyle.merge(other._contentStyle), + actionStyle: actionStyle.merge(other._actionStyle), + iconColor: other._iconColor, ); } } diff --git a/lib/src/theme/configs/brn_pair_info_config.dart b/lib/src/theme/configs/brn_pair_info_config.dart index 50b68802..987dfb67 100644 --- a/lib/src/theme/configs/brn_pair_info_config.dart +++ b/lib/src/theme/configs/brn_pair_info_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -8,19 +9,24 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPairInfoTableConfig] BrnPairInfoTableConfig({ - this.rowSpacing, - this.itemSpacing, - this.keyTextStyle, - this.valueTextStyle, - this.linkTextStyle, + double? rowSpacing, + double? itemSpacing, + BrnTextStyle? keyTextStyle, + BrnTextStyle? valueTextStyle, + BrnTextStyle? linkTextStyle, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _rowSpacing = rowSpacing, + _itemSpacing = itemSpacing, + _keyTextStyle = keyTextStyle, + _valueTextStyle = valueTextStyle, + _linkTextStyle = linkTextStyle, + super(configId: configId); /// 行间距 纵向 - double? rowSpacing; + double? _rowSpacing; /// BrnInfoModal 属性配置 行间距 - double? itemSpacing; + double? _itemSpacing; /// BrnInfoModal key文字样式 /// @@ -29,7 +35,7 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? keyTextStyle; + BrnTextStyle? _keyTextStyle; /// BrnInfoModal value文字样式 /// @@ -38,7 +44,7 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? valueTextStyle; + BrnTextStyle? _valueTextStyle; /// BrnInfoModal 链接文字样式 /// @@ -47,7 +53,27 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { /// fontWeight: FontWeight.w400, /// fontSize: [BrnCommonConfig.fontSizeBase] /// ) - BrnTextStyle? linkTextStyle; + BrnTextStyle? _linkTextStyle; + + double get rowSpacing => + _rowSpacing ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.rowSpacing; + + double get itemSpacing => + _itemSpacing ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.itemSpacing; + + BrnTextStyle get keyTextStyle => + _keyTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.keyTextStyle; + + BrnTextStyle get valueTextStyle => + _valueTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.valueTextStyle; + + BrnTextStyle get linkTextStyle => + _linkTextStyle ?? + BrnDefaultConfigUtils.defaultPairInfoTableConfig.linkTextStyle; @override void initThemeConfig( @@ -60,30 +86,30 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPairInfoTableConfig? pairInfoTableConfig = BrnThemeConfigurator.instance + BrnPairInfoTableConfig pairInfoTableConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .pairInfoTableConfig; - rowSpacing ??= pairInfoTableConfig?.rowSpacing; - keyTextStyle = pairInfoTableConfig?.keyTextStyle?.merge( + _rowSpacing ??= pairInfoTableConfig._rowSpacing; + _keyTextStyle = pairInfoTableConfig.keyTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(keyTextStyle), + ).merge(_keyTextStyle), ); - valueTextStyle = pairInfoTableConfig?.valueTextStyle?.merge( + _valueTextStyle = pairInfoTableConfig.valueTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(valueTextStyle), + ).merge(_valueTextStyle), ); - linkTextStyle = pairInfoTableConfig?.linkTextStyle?.merge( + _linkTextStyle = pairInfoTableConfig.linkTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(linkTextStyle), + ).merge(_linkTextStyle), ); - itemSpacing ??= pairInfoTableConfig?.itemSpacing; + _itemSpacing ??= pairInfoTableConfig._itemSpacing; } BrnPairInfoTableConfig copyWith({ @@ -94,25 +120,22 @@ class BrnPairInfoTableConfig extends BrnBaseConfig { BrnTextStyle? linkTextStyle, }) { return BrnPairInfoTableConfig( - rowSpacing: rowSpacing ?? this.rowSpacing, - itemSpacing: itemSpacing ?? this.itemSpacing, - keyTextStyle: keyTextStyle ?? this.keyTextStyle, - valueTextStyle: valueTextStyle ?? this.valueTextStyle, - linkTextStyle: linkTextStyle ?? this.linkTextStyle, + rowSpacing: rowSpacing ?? _rowSpacing, + itemSpacing: itemSpacing ?? _itemSpacing, + keyTextStyle: keyTextStyle ?? _keyTextStyle, + valueTextStyle: valueTextStyle ?? _valueTextStyle, + linkTextStyle: linkTextStyle ?? _linkTextStyle, ); } BrnPairInfoTableConfig merge(BrnPairInfoTableConfig? other) { if (other == null) return this; return copyWith( - rowSpacing: other.rowSpacing, - itemSpacing: other.itemSpacing, - keyTextStyle: - keyTextStyle?.merge(other.keyTextStyle) ?? other.keyTextStyle, - valueTextStyle: - valueTextStyle?.merge(other.valueTextStyle) ?? other.valueTextStyle, - linkTextStyle: - linkTextStyle?.merge(other.linkTextStyle) ?? other.linkTextStyle, + rowSpacing: other._rowSpacing, + itemSpacing: other._itemSpacing, + keyTextStyle: keyTextStyle.merge(other._keyTextStyle), + valueTextStyle: valueTextStyle.merge(other._valueTextStyle), + linkTextStyle: linkTextStyle.merge(other._linkTextStyle), ); } } @@ -121,23 +144,29 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPairRichInfoGridConfig] BrnPairRichInfoGridConfig({ - this.rowSpacing, - this.itemSpacing, - this.itemHeight, - this.keyTextStyle, - this.valueTextStyle, - this.linkTextStyle, + double? rowSpacing, + double? itemSpacing, + double? itemHeight, + BrnTextStyle? keyTextStyle, + BrnTextStyle? valueTextStyle, + BrnTextStyle? linkTextStyle, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _rowSpacing = rowSpacing, + _itemSpacing = itemSpacing, + _itemHeight = itemHeight, + _keyTextStyle = keyTextStyle, + _valueTextStyle = valueTextStyle, + _linkTextStyle = linkTextStyle, + super(configId: configId); /// 行间距 纵向 - double? rowSpacing; + double? _rowSpacing; /// 元素间距 横向 - double? itemSpacing; + double? _itemSpacing; /// 元素高度 - double? itemHeight; + double? _itemHeight; /// key文字样式 /// @@ -146,7 +175,7 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? keyTextStyle; + BrnTextStyle? _keyTextStyle; /// value文字样式 /// @@ -155,7 +184,7 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? valueTextStyle; + BrnTextStyle? _valueTextStyle; /// 链接文字样式 /// @@ -164,7 +193,31 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? linkTextStyle; + BrnTextStyle? _linkTextStyle; + + double get rowSpacing => + _rowSpacing ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.rowSpacing; + + double get itemSpacing => + _itemSpacing ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.itemSpacing; + + double get itemHeight => + _itemHeight ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.itemHeight; + + BrnTextStyle get keyTextStyle => + _keyTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.keyTextStyle; + + BrnTextStyle get valueTextStyle => + _valueTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.valueTextStyle; + + BrnTextStyle get linkTextStyle => + _linkTextStyle ?? + BrnDefaultConfigUtils.defaultPairRichInfoGridConfig.linkTextStyle; @override void initThemeConfig( @@ -177,31 +230,31 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPairRichInfoGridConfig? pairRichInfoGridConfig = BrnThemeConfigurator + BrnPairRichInfoGridConfig pairRichInfoGridConfig = BrnThemeConfigurator .instance .getConfig(configId: configId) .pairRichInfoGridConfig; - rowSpacing ??= pairRichInfoGridConfig?.rowSpacing; - itemSpacing ??= pairRichInfoGridConfig?.itemSpacing; - itemHeight ??= pairRichInfoGridConfig?.itemHeight; - keyTextStyle = pairRichInfoGridConfig?.keyTextStyle?.merge( + _rowSpacing ??= pairRichInfoGridConfig._rowSpacing; + _itemSpacing ??= pairRichInfoGridConfig._itemSpacing; + _itemHeight ??= pairRichInfoGridConfig._itemHeight; + _keyTextStyle = pairRichInfoGridConfig.keyTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeBase, - ).merge(keyTextStyle), + ).merge(_keyTextStyle), ); - valueTextStyle = pairRichInfoGridConfig?.valueTextStyle?.merge( + _valueTextStyle = pairRichInfoGridConfig.valueTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(valueTextStyle), + ).merge(_valueTextStyle), ); - linkTextStyle = pairRichInfoGridConfig?.linkTextStyle?.merge( + _linkTextStyle = pairRichInfoGridConfig.linkTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(linkTextStyle), + ).merge(_linkTextStyle), ); } @@ -215,27 +268,24 @@ class BrnPairRichInfoGridConfig extends BrnBaseConfig { BrnTextStyle? titleTextsStyle, }) { return BrnPairRichInfoGridConfig( - rowSpacing: rowSpacing ?? this.rowSpacing, - itemSpacing: itemSpacing ?? this.itemSpacing, - itemHeight: itemHeight ?? this.itemHeight, - keyTextStyle: keyTextStyle ?? this.keyTextStyle, - valueTextStyle: valueTextStyle ?? this.valueTextStyle, - linkTextStyle: linkTextStyle ?? this.linkTextStyle, + rowSpacing: rowSpacing ?? _rowSpacing, + itemSpacing: itemSpacing ?? _itemSpacing, + itemHeight: itemHeight ?? _itemHeight, + keyTextStyle: keyTextStyle ?? _keyTextStyle, + valueTextStyle: valueTextStyle ?? _valueTextStyle, + linkTextStyle: linkTextStyle ?? _linkTextStyle, ); } BrnPairRichInfoGridConfig merge(BrnPairRichInfoGridConfig? other) { if (other == null) return this; return copyWith( - rowSpacing: other.rowSpacing, - itemSpacing: other.itemSpacing, - itemHeight: other.itemHeight, - keyTextStyle: - keyTextStyle?.merge(other.keyTextStyle) ?? other.keyTextStyle, - valueTextStyle: - valueTextStyle?.merge(other.valueTextStyle) ?? other.valueTextStyle, - linkTextStyle: - linkTextStyle?.merge(other.linkTextStyle) ?? other.linkTextStyle, + rowSpacing: other._rowSpacing, + itemSpacing: other._itemSpacing, + itemHeight: other._itemHeight, + keyTextStyle: keyTextStyle.merge(other._keyTextStyle), + valueTextStyle: valueTextStyle.merge(other._valueTextStyle), + linkTextStyle: linkTextStyle.merge(other._linkTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_picker_config.dart b/lib/src/theme/configs/brn_picker_config.dart index ec23f606..92b903ba 100644 --- a/lib/src/theme/configs/brn_picker_config.dart +++ b/lib/src/theme/configs/brn_picker_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,23 +10,34 @@ class BrnPickerConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultPickerConfig] BrnPickerConfig({ - this.backgroundColor, - this.cancelTextStyle, - this.confirmTextStyle, - this.titleTextStyle, - this.pickerHeight, - this.titleHeight, - this.itemHeight, - this.itemTextStyle, - this.itemTextSelectedStyle, - this.dividerColor, - this.cornerRadius, + Color? backgroundColor, + BrnTextStyle? cancelTextStyle, + BrnTextStyle? confirmTextStyle, + BrnTextStyle? titleTextStyle, + double? pickerHeight, + double? titleHeight, + double? itemHeight, + BrnTextStyle? itemTextStyle, + BrnTextStyle? itemTextSelectedStyle, + Color? dividerColor, + double? cornerRadius, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _backgroundColor = backgroundColor, + _cancelTextStyle = cancelTextStyle, + _confirmTextStyle = confirmTextStyle, + _titleTextStyle = titleTextStyle, + _pickerHeight = pickerHeight, + _titleHeight = titleHeight, + _itemHeight = itemHeight, + _itemTextStyle = itemTextStyle, + _itemTextSelectedStyle = itemTextSelectedStyle, + _dividerColor = dividerColor, + _cornerRadius = cornerRadius, + super(configId: configId); /// 日期选择器的背景色 /// 默认为 [PICKER_BACKGROUND_COLOR] - Color? backgroundColor; + Color? _backgroundColor; /// 取消文字的样式 /// @@ -33,7 +45,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? cancelTextStyle; + BrnTextStyle? _cancelTextStyle; /// 确认文字的样式 /// @@ -41,7 +53,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? confirmTextStyle; + BrnTextStyle? _confirmTextStyle; /// 标题文字的样式 /// @@ -50,19 +62,19 @@ class BrnPickerConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWidget:FontWeight.w600, /// ) - BrnTextStyle? titleTextStyle; + BrnTextStyle? _titleTextStyle; /// 日期选择器的高度 /// 默认为 [PICKER_HEIGHT] - double? pickerHeight; + double? _pickerHeight; /// 日期选择器标题的高度 /// 默认为 [PICKER_TITLE_HEIGHT] - double? titleHeight; + double? _titleHeight; /// 日期选择器列表的高度 /// 默认为 [PICKER_ITEM_HEIGHT] - double? itemHeight; + double? _itemHeight; /// 日期选择器列表的文字样式 /// @@ -70,7 +82,7 @@ class BrnPickerConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeHead], /// ) - BrnTextStyle? itemTextStyle; + BrnTextStyle? _itemTextStyle; /// 日期选择器列表选中的文字样式 /// @@ -79,10 +91,48 @@ class BrnPickerConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeHead], /// fontWidget: FontWeight.w600, /// ) - BrnTextStyle? itemTextSelectedStyle; + BrnTextStyle? _itemTextSelectedStyle; + + Color? _dividerColor; + double? _cornerRadius; - Color? dividerColor; - double? cornerRadius; + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultPickerConfig.backgroundColor; + + BrnTextStyle get cancelTextStyle => + _cancelTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.cancelTextStyle; + + BrnTextStyle get confirmTextStyle => + _confirmTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.confirmTextStyle; + + BrnTextStyle get titleTextStyle => + _titleTextStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.titleTextStyle; + + double get pickerHeight => + _pickerHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.pickerHeight; + + double get titleHeight => + _titleHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.titleHeight; + + double get itemHeight => + _itemHeight ?? BrnDefaultConfigUtils.defaultPickerConfig.itemHeight; + + BrnTextStyle get itemTextStyle => + _itemTextStyle ?? BrnDefaultConfigUtils.defaultPickerConfig.itemTextStyle; + + BrnTextStyle get itemTextSelectedStyle => + _itemTextSelectedStyle ?? + BrnDefaultConfigUtils.defaultPickerConfig.itemTextSelectedStyle; + + Color get dividerColor => + _dividerColor ?? BrnDefaultConfigUtils.defaultPickerConfig.dividerColor; + + double get cornerRadius => + _cornerRadius ?? BrnDefaultConfigUtils.defaultPickerConfig.cornerRadius; @override void initThemeConfig( @@ -95,47 +145,47 @@ class BrnPickerConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnPickerConfig? pickerConfig = BrnThemeConfigurator.instance + BrnPickerConfig pickerConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .pickerConfig; - backgroundColor ??= pickerConfig?.backgroundColor; - pickerHeight ??= pickerConfig?.pickerHeight; - titleHeight ??= pickerConfig?.titleHeight; - itemHeight ??= pickerConfig?.itemHeight; - dividerColor ??= pickerConfig?.dividerColor; - cornerRadius ??= pickerConfig?.cornerRadius; - titleTextStyle = pickerConfig?.titleTextStyle?.merge( + _backgroundColor ??= pickerConfig.backgroundColor; + _pickerHeight ??= pickerConfig.pickerHeight; + _titleHeight ??= pickerConfig.titleHeight; + _itemHeight ??= pickerConfig.itemHeight; + _dividerColor ??= pickerConfig.dividerColor; + _cornerRadius ??= pickerConfig.cornerRadius; + _titleTextStyle = pickerConfig.titleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); - cancelTextStyle = pickerConfig?.cancelTextStyle - ?.merge( + _cancelTextStyle = pickerConfig.cancelTextStyle + .merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, ), ) - .merge(cancelTextStyle); - confirmTextStyle = pickerConfig?.confirmTextStyle?.merge( + .merge(_cancelTextStyle); + _confirmTextStyle = pickerConfig.confirmTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(confirmTextStyle), + ).merge(_confirmTextStyle), ); - itemTextStyle = pickerConfig?.itemTextStyle?.merge( + _itemTextStyle = pickerConfig.itemTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeHead, - ).merge(itemTextStyle), + ).merge(_itemTextStyle), ); - itemTextSelectedStyle = pickerConfig?.itemTextSelectedStyle?.merge( + _itemTextSelectedStyle = pickerConfig.itemTextSelectedStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeHead, - ).merge(itemTextSelectedStyle), + ).merge(_itemTextSelectedStyle), ); } @@ -153,41 +203,35 @@ class BrnPickerConfig extends BrnBaseConfig { double? cornerRadius, }) { return BrnPickerConfig( - backgroundColor: backgroundColor ?? this.backgroundColor, - cancelTextStyle: cancelTextStyle ?? this.cancelTextStyle, - confirmTextStyle: confirmTextStyle ?? this.confirmTextStyle, - titleTextStyle: titleTextStyle ?? this.titleTextStyle, - pickerHeight: pickerHeight ?? this.pickerHeight, - titleHeight: titleHeight ?? this.titleHeight, - itemHeight: itemHeight ?? this.itemHeight, - itemTextStyle: itemTextStyle ?? this.itemTextStyle, - itemTextSelectedStyle: - itemTextSelectedStyle ?? this.itemTextSelectedStyle, - dividerColor: dividerColor ?? this.dividerColor, - cornerRadius: cornerRadius ?? this.cornerRadius, + backgroundColor: backgroundColor ?? _backgroundColor, + cancelTextStyle: cancelTextStyle ?? _cancelTextStyle, + confirmTextStyle: confirmTextStyle ?? _confirmTextStyle, + titleTextStyle: titleTextStyle ?? _titleTextStyle, + pickerHeight: pickerHeight ?? _pickerHeight, + titleHeight: titleHeight ?? _titleHeight, + itemHeight: itemHeight ?? _itemHeight, + itemTextStyle: itemTextStyle ?? _itemTextStyle, + itemTextSelectedStyle: itemTextSelectedStyle ?? _itemTextSelectedStyle, + dividerColor: dividerColor ?? _dividerColor, + cornerRadius: cornerRadius ?? _cornerRadius, ); } BrnPickerConfig merge(BrnPickerConfig? other) { if (other == null) return this; return copyWith( - backgroundColor: other.backgroundColor, - cancelTextStyle: cancelTextStyle?.merge(other.cancelTextStyle) ?? - other.cancelTextStyle, - confirmTextStyle: confirmTextStyle?.merge(other.confirmTextStyle) ?? - other.confirmTextStyle, - titleTextStyle: - titleTextStyle?.merge(other.titleTextStyle) ?? other.titleTextStyle, - pickerHeight: other.pickerHeight, - titleHeight: other.titleHeight, - itemHeight: other.itemHeight, - itemTextStyle: - itemTextStyle?.merge(other.itemTextStyle) ?? other.itemTextStyle, + backgroundColor: other._backgroundColor, + cancelTextStyle: cancelTextStyle.merge(other._cancelTextStyle), + confirmTextStyle: confirmTextStyle.merge(other._confirmTextStyle), + titleTextStyle: titleTextStyle.merge(other._titleTextStyle), + pickerHeight: other._pickerHeight, + titleHeight: other._titleHeight, + itemHeight: other._itemHeight, + itemTextStyle: itemTextStyle.merge(other._itemTextStyle), itemTextSelectedStyle: - itemTextSelectedStyle?.merge(other.itemTextSelectedStyle) ?? - other.itemTextSelectedStyle, - dividerColor: other.dividerColor, - cornerRadius: other.cornerRadius, + itemTextSelectedStyle.merge(other._itemTextSelectedStyle), + dividerColor: other._dividerColor, + cornerRadius: other._cornerRadius, ); } } diff --git a/lib/src/theme/configs/brn_selection_config.dart b/lib/src/theme/configs/brn_selection_config.dart index 25f7b8cd..1dc0019b 100644 --- a/lib/src/theme/configs/brn_selection_config.dart +++ b/lib/src/theme/configs/brn_selection_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,34 +10,60 @@ class BrnSelectionConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.defaultSelectionConfig] BrnSelectionConfig({ - this.menuNormalTextStyle, - this.menuSelectedTextStyle, - this.tagNormalTextStyle, - this.tagSelectedTextStyle, - this.tagRadius, - this.tagNormalBackgroundColor, - this.tagSelectedBackgroundColor, - this.hintTextStyle, - this.rangeTitleTextStyle, - this.inputTextStyle, - this.itemNormalTextStyle, - this.itemSelectedTextStyle, - this.itemBoldTextStyle, - this.deepNormalBgColor, - this.deepSelectBgColor, - this.middleNormalBgColor, - this.middleSelectBgColor, - this.lightNormalBgColor, - this.lightSelectBgColor, - this.resetTextStyle, - this.titleForMoreTextStyle, - this.optionTextStyle, - this.moreTextStyle, - this.flayerNormalTextStyle, - this.flayerSelectedTextStyle, - this.flayerBoldTextStyle, + BrnTextStyle? menuNormalTextStyle, + BrnTextStyle? menuSelectedTextStyle, + BrnTextStyle? tagNormalTextStyle, + BrnTextStyle? tagSelectedTextStyle, + double? tagRadius, + Color? tagNormalBackgroundColor, + Color? tagSelectedBackgroundColor, + BrnTextStyle? hintTextStyle, + BrnTextStyle? rangeTitleTextStyle, + BrnTextStyle? inputTextStyle, + BrnTextStyle? itemNormalTextStyle, + BrnTextStyle? itemSelectedTextStyle, + BrnTextStyle? itemBoldTextStyle, + Color? deepNormalBgColor, + Color? deepSelectBgColor, + Color? middleNormalBgColor, + Color? middleSelectBgColor, + Color? lightNormalBgColor, + Color? lightSelectBgColor, + BrnTextStyle? resetTextStyle, + BrnTextStyle? titleForMoreTextStyle, + BrnTextStyle? optionTextStyle, + BrnTextStyle? moreTextStyle, + BrnTextStyle? flayerNormalTextStyle, + BrnTextStyle? flayerSelectedTextStyle, + BrnTextStyle? flayerBoldTextStyle, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _menuNormalTextStyle = menuNormalTextStyle, + _menuSelectedTextStyle = menuSelectedTextStyle, + _tagNormalTextStyle = tagNormalTextStyle, + _tagSelectedTextStyle = tagSelectedTextStyle, + _tagRadius = tagRadius, + _tagNormalBackgroundColor = tagNormalBackgroundColor, + _tagSelectedBackgroundColor = tagSelectedBackgroundColor, + _hintTextStyle = hintTextStyle, + _rangeTitleTextStyle = rangeTitleTextStyle, + _inputTextStyle = inputTextStyle, + _itemNormalTextStyle = itemNormalTextStyle, + _itemSelectedTextStyle = itemSelectedTextStyle, + _itemBoldTextStyle = itemBoldTextStyle, + _deepNormalBgColor = deepNormalBgColor, + _deepSelectBgColor = deepSelectBgColor, + _middleNormalBgColor = middleNormalBgColor, + _middleSelectBgColor = middleSelectBgColor, + _lightNormalBgColor = lightNormalBgColor, + _lightSelectBgColor = lightSelectBgColor, + _resetTextStyle = resetTextStyle, + _titleForMoreTextStyle = titleForMoreTextStyle, + _optionTextStyle = optionTextStyle, + _moreTextStyle = moreTextStyle, + _flayerNormalTextStyle = flayerNormalTextStyle, + _flayerSelectedTextStyle = flayerSelectedTextStyle, + _flayerBoldTextStyle = flayerBoldTextStyle, + super(configId: configId); /// menu 正常文本样式 /// @@ -45,7 +72,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.normal, /// ) - BrnTextStyle? menuNormalTextStyle; + BrnTextStyle? _menuNormalTextStyle; /// menu 选中文本样式 /// @@ -54,7 +81,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? menuSelectedTextStyle; + BrnTextStyle? _menuSelectedTextStyle; /// tag 正常文本样式 /// @@ -63,7 +90,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w400, /// ) - BrnTextStyle? tagNormalTextStyle; + BrnTextStyle? _tagNormalTextStyle; /// tag 选中文本样式 /// @@ -72,19 +99,19 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? tagSelectedTextStyle; + BrnTextStyle? _tagSelectedTextStyle; /// tag 圆角 /// 默认为 [BrnCommonConfig.radiusSm] - double? tagRadius; + double? _tagRadius; /// tag 正常背景色 /// 默认为 [BrnCommonConfig.fillBody] - Color? tagNormalBackgroundColor; + Color? _tagNormalBackgroundColor; /// tag 选中背景色 /// 默认为 [BrnCommonConfig.brandPrimary].withOpacity(0.12) - Color? tagSelectedBackgroundColor; + Color? _tagSelectedBackgroundColor; /// 输入选项标题文本样式 /// @@ -93,7 +120,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? rangeTitleTextStyle; + BrnTextStyle? _rangeTitleTextStyle; /// 输入提示文本样式 /// @@ -101,7 +128,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextHint], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? hintTextStyle; + BrnTextStyle? _hintTextStyle; /// 输入框默认文本样式 /// @@ -109,7 +136,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? inputTextStyle; + BrnTextStyle? _inputTextStyle; /// item 正常字体样式 /// @@ -117,7 +144,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? itemNormalTextStyle; + BrnTextStyle? _itemNormalTextStyle; /// item 选中文本样式 /// @@ -126,7 +153,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemSelectedTextStyle; + BrnTextStyle? _itemSelectedTextStyle; /// item 仅加粗样式 /// @@ -135,31 +162,31 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? itemBoldTextStyle; + BrnTextStyle? _itemBoldTextStyle; /// 三级 item 背景色 /// 默认为 Color(0xFFF0F0F0) - Color? deepNormalBgColor; + Color? _deepNormalBgColor; /// 三级 item 选中背景色 /// 默认为 Color(0xFFF8F8F8) - Color? deepSelectBgColor; + Color? _deepSelectBgColor; /// 二级 item 背景色 /// 默认为 Color(0xFFF8F8F8) - Color? middleNormalBgColor; + Color? _middleNormalBgColor; /// 二级 item 选中背景色 /// 默认为 Colors.white - Color? middleSelectBgColor; + Color? _middleSelectBgColor; /// 一级 item 背景色 /// 默认为 Colors.white - Color? lightNormalBgColor; + Color? _lightNormalBgColor; /// 一级 item 选中背景色 /// 默认为 Colors.white - Color? lightSelectBgColor; + Color? _lightSelectBgColor; /// 重置按钮颜色 /// @@ -167,7 +194,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextImportant], /// fontSize: [BrnCommonConfig.fontSizeCaption] /// ) - BrnTextStyle? resetTextStyle; + BrnTextStyle? _resetTextStyle; /// 更多筛选-标题文本样式 /// @@ -176,7 +203,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeBase], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? titleForMoreTextStyle; + BrnTextStyle? _titleForMoreTextStyle; /// 选项-显示文本 /// @@ -184,7 +211,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeBase], /// ) - BrnTextStyle? optionTextStyle; + BrnTextStyle? _optionTextStyle; /// 更多文本样式 /// @@ -192,7 +219,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextSecondary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? moreTextStyle; + BrnTextStyle? _moreTextStyle; /// 跳转二级页-正常文本样式 /// @@ -201,7 +228,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.normal, /// ) - BrnTextStyle? flayerNormalTextStyle; + BrnTextStyle? _flayerNormalTextStyle; /// 跳转二级页-选中文本样式 /// @@ -210,7 +237,7 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? flayerSelectedTextStyle; + BrnTextStyle? _flayerSelectedTextStyle; /// 跳转二级页-加粗文本样式 /// @@ -219,7 +246,110 @@ class BrnSelectionConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// fontWeight: FontWeight.w600 /// ) - BrnTextStyle? flayerBoldTextStyle; + BrnTextStyle? _flayerBoldTextStyle; + + BrnTextStyle get menuNormalTextStyle => + _menuNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.menuNormalTextStyle; + + BrnTextStyle get menuSelectedTextStyle => + _menuSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.menuSelectedTextStyle; + + BrnTextStyle get tagNormalTextStyle => + _tagNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagNormalTextStyle; + + BrnTextStyle get tagSelectedTextStyle => + _tagSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagSelectedTextStyle; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultSelectionConfig.tagRadius; + + Color get tagNormalBackgroundColor => + _tagNormalBackgroundColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagNormalBackgroundColor; + + Color get tagSelectedBackgroundColor => + _tagSelectedBackgroundColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.tagSelectedBackgroundColor; + + BrnTextStyle get rangeTitleTextStyle => + _rangeTitleTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.rangeTitleTextStyle; + + BrnTextStyle get hintTextStyle => + _hintTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.hintTextStyle; + + BrnTextStyle get inputTextStyle => + _inputTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.inputTextStyle; + + BrnTextStyle get itemNormalTextStyle => + _itemNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemNormalTextStyle; + + BrnTextStyle get itemSelectedTextStyle => + _itemSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemSelectedTextStyle; + + BrnTextStyle get itemBoldTextStyle => + _itemBoldTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.itemBoldTextStyle; + + Color get deepNormalBgColor => + _deepNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.deepNormalBgColor; + + Color get deepSelectBgColor => + _deepSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.deepSelectBgColor; + + Color get middleNormalBgColor => + _middleNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.middleNormalBgColor; + + Color get middleSelectBgColor => + _middleSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.middleSelectBgColor; + + Color get lightNormalBgColor => + _lightNormalBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.lightNormalBgColor; + + Color get lightSelectBgColor => + _lightSelectBgColor ?? + BrnDefaultConfigUtils.defaultSelectionConfig.lightSelectBgColor; + + BrnTextStyle get resetTextStyle => + _resetTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.resetTextStyle; + + BrnTextStyle get titleForMoreTextStyle => + _titleForMoreTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.titleForMoreTextStyle; + + BrnTextStyle get optionTextStyle => + _optionTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.optionTextStyle; + + BrnTextStyle get moreTextStyle => + _moreTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.moreTextStyle; + + BrnTextStyle get flayerNormalTextStyle => + _flayerNormalTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerNormalTextStyle; + + BrnTextStyle get flayerSelectedTextStyle => + _flayerSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerSelectedTextStyle; + + BrnTextStyle get flayerBoldTextStyle => + _flayerBoldTextStyle ?? + BrnDefaultConfigUtils.defaultSelectionConfig.flayerBoldTextStyle; @override void initThemeConfig( @@ -232,118 +362,119 @@ class BrnSelectionConfig extends BrnBaseConfig { ); /// 用户全局筛选配置 - BrnSelectionConfig? selectionConfig = BrnThemeConfigurator.instance + BrnSelectionConfig selectionConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .selectionConfig; - lightSelectBgColor ??= selectionConfig?.lightSelectBgColor; - lightNormalBgColor ??= selectionConfig?.lightNormalBgColor; - middleSelectBgColor ??= selectionConfig?.middleSelectBgColor; - middleNormalBgColor ??= selectionConfig?.middleNormalBgColor; - deepSelectBgColor ??= selectionConfig?.deepSelectBgColor; - deepNormalBgColor ??= selectionConfig?.deepNormalBgColor; - tagSelectedBackgroundColor ??= commonConfig.brandPrimary?.withOpacity(0.12); - tagNormalBackgroundColor ??= commonConfig.fillBody; - tagRadius ??= commonConfig.radiusSm; - flayerBoldTextStyle = selectionConfig?.flayerBoldTextStyle?.merge( + _lightSelectBgColor ??= selectionConfig._lightSelectBgColor; + _lightNormalBgColor ??= selectionConfig._lightNormalBgColor; + _middleSelectBgColor ??= selectionConfig._middleSelectBgColor; + _middleNormalBgColor ??= selectionConfig._middleNormalBgColor; + _deepSelectBgColor ??= selectionConfig._deepSelectBgColor; + _deepNormalBgColor ??= selectionConfig._deepNormalBgColor; + _tagSelectedBackgroundColor ??= + commonConfig.brandPrimary.withOpacity(0.12); + _tagNormalBackgroundColor ??= commonConfig.fillBody; + _tagRadius ??= commonConfig.radiusSm; + _flayerBoldTextStyle = selectionConfig.flayerBoldTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerBoldTextStyle), + ).merge(_flayerBoldTextStyle), ); - flayerSelectedTextStyle = selectionConfig?.flayerSelectedTextStyle?.merge( + _flayerSelectedTextStyle = selectionConfig.flayerSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerSelectedTextStyle), + ).merge(_flayerSelectedTextStyle), ); - flayerNormalTextStyle = selectionConfig?.flayerNormalTextStyle?.merge( + _flayerNormalTextStyle = selectionConfig.flayerNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(flayerNormalTextStyle), + ).merge(_flayerNormalTextStyle), ); - moreTextStyle = selectionConfig?.moreTextStyle?.merge( + _moreTextStyle = selectionConfig.moreTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextSecondary, fontSize: commonConfig.fontSizeCaption, - ).merge(moreTextStyle), + ).merge(_moreTextStyle), ); - optionTextStyle = selectionConfig?.optionTextStyle?.merge( + _optionTextStyle = selectionConfig.optionTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(optionTextStyle), + ).merge(_optionTextStyle), ); - titleForMoreTextStyle = selectionConfig?.titleForMoreTextStyle?.merge( + _titleForMoreTextStyle = selectionConfig.titleForMoreTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(titleForMoreTextStyle), + ).merge(_titleForMoreTextStyle), ); - resetTextStyle = selectionConfig?.resetTextStyle?.merge(BrnTextStyle( + _resetTextStyle = selectionConfig.resetTextStyle.merge(BrnTextStyle( color: commonConfig.colorTextImportant, fontSize: commonConfig.fontSizeCaption, - ).merge(resetTextStyle)); - itemBoldTextStyle = selectionConfig?.itemBoldTextStyle?.merge( + ).merge(_resetTextStyle)); + _itemBoldTextStyle = selectionConfig.itemBoldTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(itemBoldTextStyle), + ).merge(_itemBoldTextStyle), ); - itemSelectedTextStyle = selectionConfig?.itemSelectedTextStyle?.merge( + _itemSelectedTextStyle = selectionConfig.itemSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(itemSelectedTextStyle), + ).merge(_itemSelectedTextStyle), ); - itemNormalTextStyle = selectionConfig?.itemNormalTextStyle?.merge( + _itemNormalTextStyle = selectionConfig.itemNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(itemNormalTextStyle), + ).merge(_itemNormalTextStyle), ); - inputTextStyle = selectionConfig?.inputTextStyle?.merge( + _inputTextStyle = selectionConfig.inputTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(inputTextStyle), + ).merge(_inputTextStyle), ); - hintTextStyle = selectionConfig?.hintTextStyle?.merge( + _hintTextStyle = selectionConfig.hintTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextHint, fontSize: commonConfig.fontSizeBase, - ).merge(hintTextStyle), + ).merge(_hintTextStyle), ); - rangeTitleTextStyle = selectionConfig?.rangeTitleTextStyle?.merge( + _rangeTitleTextStyle = selectionConfig.rangeTitleTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(rangeTitleTextStyle), + ).merge(_rangeTitleTextStyle), ); - tagSelectedTextStyle = selectionConfig?.tagSelectedTextStyle?.merge( + _tagSelectedTextStyle = selectionConfig.tagSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(tagSelectedTextStyle), + ).merge(_tagSelectedTextStyle), ); - tagNormalTextStyle = selectionConfig?.tagNormalTextStyle?.merge( + _tagNormalTextStyle = selectionConfig.tagNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagNormalTextStyle), + ).merge(_tagNormalTextStyle), ); - menuNormalTextStyle = selectionConfig?.menuNormalTextStyle?.merge( + _menuNormalTextStyle = selectionConfig.menuNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeBase, - ).merge(menuNormalTextStyle), + ).merge(_menuNormalTextStyle), ); - menuSelectedTextStyle = selectionConfig?.menuSelectedTextStyle?.merge( + _menuSelectedTextStyle = selectionConfig.menuSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeBase, - ).merge(menuSelectedTextStyle), + ).merge(_menuSelectedTextStyle), ); } @@ -376,97 +507,71 @@ class BrnSelectionConfig extends BrnBaseConfig { BrnTextStyle? flayerBoldTextStyle, }) { return BrnSelectionConfig( - menuNormalTextStyle: menuNormalTextStyle ?? this.menuNormalTextStyle, - menuSelectedTextStyle: - menuSelectedTextStyle ?? this.menuSelectedTextStyle, - tagNormalTextStyle: tagTextStyle ?? this.tagNormalTextStyle, - tagSelectedTextStyle: tagSelectedTextStyle ?? this.tagSelectedTextStyle, - tagRadius: tagRadius ?? this.tagRadius, - tagNormalBackgroundColor: - tagBackgroundColor ?? this.tagNormalBackgroundColor, + menuNormalTextStyle: menuNormalTextStyle ?? _menuNormalTextStyle, + menuSelectedTextStyle: menuSelectedTextStyle ?? _menuSelectedTextStyle, + tagNormalTextStyle: tagTextStyle ?? _tagNormalTextStyle, + tagSelectedTextStyle: tagSelectedTextStyle ?? _tagSelectedTextStyle, + tagRadius: tagRadius ?? _tagRadius, + tagNormalBackgroundColor: tagBackgroundColor ?? _tagNormalBackgroundColor, tagSelectedBackgroundColor: - tagSelectedBackgroundColor ?? this.tagSelectedBackgroundColor, - hintTextStyle: hintTextStyle ?? this.hintTextStyle, - rangeTitleTextStyle: rangeTitleTextStyle ?? this.rangeTitleTextStyle, - inputTextStyle: inputTextStyle ?? this.inputTextStyle, - itemNormalTextStyle: itemNormalTextStyle ?? this.itemNormalTextStyle, - itemSelectedTextStyle: - itemSelectedTextStyle ?? this.itemSelectedTextStyle, - itemBoldTextStyle: itemBoldTextStyle ?? this.itemBoldTextStyle, - deepNormalBgColor: deepNormalBgColor ?? this.deepNormalBgColor, - deepSelectBgColor: deepSelectBgColor ?? this.deepSelectBgColor, - middleNormalBgColor: middleNormalBgColor ?? this.middleNormalBgColor, - middleSelectBgColor: middleSelectBgColor ?? this.middleSelectBgColor, - lightNormalBgColor: lightNormalBgColor ?? this.lightNormalBgColor, - lightSelectBgColor: lightSelectBgColor ?? this.lightSelectBgColor, - resetTextStyle: resetTextStyle ?? this.resetTextStyle, - titleForMoreTextStyle: - titleForMoreTextStyle ?? this.titleForMoreTextStyle, - optionTextStyle: optionTextStyle ?? this.optionTextStyle, - moreTextStyle: moreTextStyle ?? this.moreTextStyle, - flayerNormalTextStyle: - flayerNormalTextStyle ?? this.flayerNormalTextStyle, + tagSelectedBackgroundColor ?? _tagSelectedBackgroundColor, + hintTextStyle: hintTextStyle ?? _hintTextStyle, + rangeTitleTextStyle: rangeTitleTextStyle ?? _rangeTitleTextStyle, + inputTextStyle: inputTextStyle ?? _inputTextStyle, + itemNormalTextStyle: itemNormalTextStyle ?? _itemNormalTextStyle, + itemSelectedTextStyle: itemSelectedTextStyle ?? _itemSelectedTextStyle, + itemBoldTextStyle: itemBoldTextStyle ?? _itemBoldTextStyle, + deepNormalBgColor: deepNormalBgColor ?? _deepNormalBgColor, + deepSelectBgColor: deepSelectBgColor ?? _deepSelectBgColor, + middleNormalBgColor: middleNormalBgColor ?? _middleNormalBgColor, + middleSelectBgColor: middleSelectBgColor ?? _middleSelectBgColor, + lightNormalBgColor: lightNormalBgColor ?? _lightNormalBgColor, + lightSelectBgColor: lightSelectBgColor ?? _lightSelectBgColor, + resetTextStyle: resetTextStyle ?? _resetTextStyle, + titleForMoreTextStyle: titleForMoreTextStyle ?? _titleForMoreTextStyle, + optionTextStyle: optionTextStyle ?? _optionTextStyle, + moreTextStyle: moreTextStyle ?? _moreTextStyle, + flayerNormalTextStyle: flayerNormalTextStyle ?? _flayerNormalTextStyle, flayerSelectedTextStyle: - flayerSelectedTextStyle ?? this.flayerSelectedTextStyle, - flayerBoldTextStyle: flayerBoldTextStyle ?? this.flayerBoldTextStyle, + flayerSelectedTextStyle ?? _flayerSelectedTextStyle, + flayerBoldTextStyle: flayerBoldTextStyle ?? _flayerBoldTextStyle, ); } BrnSelectionConfig merge(BrnSelectionConfig other) { return copyWith( - menuNormalTextStyle: - menuNormalTextStyle?.merge(other.menuNormalTextStyle) ?? - other.menuNormalTextStyle, + menuNormalTextStyle: menuNormalTextStyle.merge(other._menuNormalTextStyle), menuSelectedTextStyle: - menuSelectedTextStyle?.merge(other.menuSelectedTextStyle) ?? - other.menuSelectedTextStyle, - tagTextStyle: tagNormalTextStyle?.merge(other.tagNormalTextStyle) ?? - other.tagNormalTextStyle, + menuSelectedTextStyle.merge(other._menuSelectedTextStyle), + tagTextStyle: tagNormalTextStyle.merge(other._tagNormalTextStyle), tagSelectedTextStyle: - tagSelectedTextStyle?.merge(other.tagSelectedTextStyle) ?? - other.tagSelectedTextStyle, - tagRadius: other.tagRadius, - tagBackgroundColor: other.tagNormalBackgroundColor, - tagSelectedBackgroundColor: other.tagSelectedBackgroundColor, - hintTextStyle: - hintTextStyle?.merge(other.hintTextStyle) ?? other.hintTextStyle, - rangeTitleTextStyle: - rangeTitleTextStyle?.merge(other.rangeTitleTextStyle) ?? - other.rangeTitleTextStyle, - inputTextStyle: - inputTextStyle?.merge(other.inputTextStyle) ?? other.inputTextStyle, - itemNormalTextStyle: - itemNormalTextStyle?.merge(other.itemNormalTextStyle) ?? - other.itemNormalTextStyle, + tagSelectedTextStyle.merge(other._tagSelectedTextStyle), + tagRadius: other._tagRadius, + tagBackgroundColor: other._tagNormalBackgroundColor, + tagSelectedBackgroundColor: other._tagSelectedBackgroundColor, + hintTextStyle: hintTextStyle.merge(other._hintTextStyle), + rangeTitleTextStyle: rangeTitleTextStyle.merge(other._rangeTitleTextStyle), + inputTextStyle: inputTextStyle.merge(other._inputTextStyle), + itemNormalTextStyle: itemNormalTextStyle.merge(other._itemNormalTextStyle), itemSelectedTextStyle: - itemSelectedTextStyle?.merge(other.itemSelectedTextStyle) ?? - other.itemSelectedTextStyle, - itemBoldTextStyle: itemBoldTextStyle?.merge(other.itemBoldTextStyle) ?? - other.itemBoldTextStyle, - deepNormalBgColor: other.deepNormalBgColor, - deepSelectBgColor: other.deepSelectBgColor, - middleNormalBgColor: other.middleNormalBgColor, - middleSelectBgColor: other.middleSelectBgColor, - lightNormalBgColor: other.lightNormalBgColor, - lightSelectBgColor: other.lightSelectBgColor, - resetTextStyle: - resetTextStyle?.merge(other.resetTextStyle) ?? other.resetTextStyle, + itemSelectedTextStyle.merge(other._itemSelectedTextStyle), + itemBoldTextStyle: itemBoldTextStyle.merge(other._itemBoldTextStyle), + deepNormalBgColor: other._deepNormalBgColor, + deepSelectBgColor: other._deepSelectBgColor, + middleNormalBgColor: other._middleNormalBgColor, + middleSelectBgColor: other._middleSelectBgColor, + lightNormalBgColor: other._lightNormalBgColor, + lightSelectBgColor: other._lightSelectBgColor, + resetTextStyle: resetTextStyle.merge(other._resetTextStyle), titleForMoreTextStyle: - titleForMoreTextStyle?.merge(other.titleForMoreTextStyle) ?? - other.titleForMoreTextStyle, - optionTextStyle: optionTextStyle?.merge(other.optionTextStyle) ?? - other.optionTextStyle, - moreTextStyle: - moreTextStyle?.merge(other.moreTextStyle) ?? other.moreTextStyle, + titleForMoreTextStyle.merge(other._titleForMoreTextStyle), + optionTextStyle: optionTextStyle.merge(other._optionTextStyle), + moreTextStyle: moreTextStyle.merge(other._moreTextStyle), flayerNormalTextStyle: - flayerNormalTextStyle?.merge(other.flayerNormalTextStyle) ?? - other.flayerNormalTextStyle, + flayerNormalTextStyle.merge(other._flayerNormalTextStyle), flayerSelectedTextStyle: - flayerSelectedTextStyle?.merge(other.flayerSelectedTextStyle) ?? - other.flayerSelectedTextStyle, - flayerBoldTextStyle: - flayerBoldTextStyle?.merge(other.flayerBoldTextStyle) ?? - other.flayerBoldTextStyle, + flayerSelectedTextStyle.merge(other._flayerSelectedTextStyle), + flayerBoldTextStyle: flayerBoldTextStyle.merge(other._flayerBoldTextStyle), ); } } diff --git a/lib/src/theme/configs/brn_tabbar_config.dart b/lib/src/theme/configs/brn_tabbar_config.dart index 69a3e7b1..457ae2c8 100644 --- a/lib/src/theme/configs/brn_tabbar_config.dart +++ b/lib/src/theme/configs/brn_tabbar_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -9,34 +10,48 @@ class BrnTabBarConfig extends BrnBaseConfig { /// 遵循外部主题配置 /// 默认为 [BrnDefaultConfigUtils.tabBarConfig] BrnTabBarConfig({ - this.tabHeight, - this.indicatorHeight, - this.indicatorWidth, - this.labelStyle, - this.unselectedLabelStyle, - this.backgroundColor, - this.tagNormalTextStyle, - this.tagNormalBgColor, - this.tagSelectedTextStyle, - this.tagSelectedBgColor, - this.tagRadius, - this.tagSpacing, - this.preLineTagCount, - this.tagHeight, + double? tabHeight, + double? indicatorHeight, + double? indicatorWidth, + BrnTextStyle? labelStyle, + BrnTextStyle? unselectedLabelStyle, + Color? backgroundColor, + BrnTextStyle? tagNormalTextStyle, + Color? tagNormalBgColor, + BrnTextStyle? tagSelectedTextStyle, + Color? tagSelectedBgColor, + double? tagRadius, + double? tagSpacing, + int? preLineTagCount, + double? tagHeight, String configId: GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _tabHeight = tabHeight, + _indicatorHeight = indicatorHeight, + _indicatorWidth = indicatorWidth, + _labelStyle = labelStyle, + _unselectedLabelStyle = unselectedLabelStyle, + _backgroundColor = backgroundColor, + _tagNormalTextStyle = tagNormalTextStyle, + _tagNormalBgColor = tagNormalBgColor, + _tagSelectedTextStyle = tagSelectedTextStyle, + _tagSelectedBgColor = tagSelectedBgColor, + _tagRadius = tagRadius, + _tagSpacing = tagSpacing, + _preLineTagCount = preLineTagCount, + _tagHeight = tagHeight, + super(configId: configId); /// TabBar 的整体高度 /// 默认为 50 - double? tabHeight; + double? _tabHeight; /// 指示器的高度 /// 默认为 2 - double? indicatorHeight; + double? _indicatorHeight; /// 指示器的宽度 /// 默认为 24 - double? indicatorWidth; + double? _indicatorWidth; /// 选中 Tab 文本的样式 /// @@ -44,7 +59,7 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? labelStyle; + BrnTextStyle? _labelStyle; /// 未选中 Tab 文本的样式 /// @@ -52,11 +67,11 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeSubHead], /// ) - BrnTextStyle? unselectedLabelStyle; + BrnTextStyle? _unselectedLabelStyle; /// 背景色 /// 默认为 [BrnCommonConfig.fillBase] - Color? backgroundColor; + Color? _backgroundColor; /// 标签字体样式 /// @@ -64,11 +79,11 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagNormalTextStyle; + BrnTextStyle? _tagNormalTextStyle; /// 标签背景色 /// 默认为 [BrnCommonConfig.brandPrimary].withAlpha(0x14), - Color? tagNormalBgColor; + Color? _tagNormalBgColor; /// 标签字体样式 /// @@ -76,27 +91,78 @@ class BrnTabBarConfig extends BrnBaseConfig { /// color:[BrnCommonConfig.brandPrimary], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagSelectedTextStyle; + BrnTextStyle? _tagSelectedTextStyle; /// 标签选中背景色 /// 默认为 [BrnCommonConfig.fillBody] - Color? tagSelectedBgColor; + Color? _tagSelectedBgColor; /// tag圆角 /// 默认为 [BrnCommonConfig.radiusSm] - double? tagRadius; + double? _tagRadius; /// tag间距 /// 默认为 12 - double? tagSpacing; + double? _tagSpacing; /// 每行的tag数 /// 默认为 4 - int? preLineTagCount; + int? _preLineTagCount; /// tag高度 /// 默认为 32 - double? tagHeight; + double? _tagHeight; + + double get tabHeight => + _tabHeight ?? BrnDefaultConfigUtils.defaultTabBarConfig.tabHeight; + + double get indicatorHeight => + _indicatorHeight ?? + BrnDefaultConfigUtils.defaultTabBarConfig.indicatorHeight; + + double get indicatorWidth => + _indicatorWidth ?? + BrnDefaultConfigUtils.defaultTabBarConfig.indicatorWidth; + + BrnTextStyle get labelStyle => + _labelStyle ?? BrnDefaultConfigUtils.defaultTabBarConfig.labelStyle; + + BrnTextStyle get unselectedLabelStyle => + _unselectedLabelStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.unselectedLabelStyle; + + Color get backgroundColor => + _backgroundColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.backgroundColor; + + BrnTextStyle get tagNormalTextStyle => + _tagNormalTextStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagNormalTextStyle; + + Color get tagNormalBgColor => + _tagNormalBgColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagNormalBgColor; + + BrnTextStyle get tagSelectedTextStyle => + _tagSelectedTextStyle ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagSelectedTextStyle; + + Color get tagSelectedBgColor => + _tagSelectedBgColor ?? + BrnDefaultConfigUtils.defaultTabBarConfig.tagSelectedBgColor; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagRadius; + + double get tagSpacing => + _tagSpacing ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagSpacing; + + int get preLineTagCount => + _preLineTagCount ?? + BrnDefaultConfigUtils.defaultTabBarConfig.preLineTagCount; + + double get tagHeight => + _tagHeight ?? BrnDefaultConfigUtils.defaultTabBarConfig.tagHeight; @override void initThemeConfig( @@ -108,44 +174,44 @@ class BrnTabBarConfig extends BrnBaseConfig { currentLevelCommonConfig: currentLevelCommonConfig, ); - BrnTabBarConfig? tabBarConfig = BrnThemeConfigurator.instance + BrnTabBarConfig tabBarConfig = BrnThemeConfigurator.instance .getConfig(configId: configId) .tabBarConfig; - tabHeight ??= tabBarConfig?.tabHeight; - indicatorHeight ??= tabBarConfig?.indicatorHeight; - indicatorWidth ??= tabBarConfig?.indicatorWidth; - labelStyle = tabBarConfig?.labelStyle?.merge( + _tabHeight ??= tabBarConfig._tabHeight; + _indicatorHeight ??= tabBarConfig._indicatorHeight; + _indicatorWidth ??= tabBarConfig._indicatorWidth; + _labelStyle = tabBarConfig.labelStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeSubHead, - ).merge(labelStyle), + ).merge(_labelStyle), ); - unselectedLabelStyle = tabBarConfig?.unselectedLabelStyle?.merge( + _unselectedLabelStyle = tabBarConfig.unselectedLabelStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(unselectedLabelStyle), + ).merge(_unselectedLabelStyle), ); - backgroundColor ??= tabBarConfig?.backgroundColor; - tagNormalTextStyle = tabBarConfig?.tagNormalTextStyle?.merge( + _backgroundColor ??= tabBarConfig._backgroundColor; + _tagNormalTextStyle = tabBarConfig.tagNormalTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagNormalTextStyle), + ).merge(_tagNormalTextStyle), ); - tagSelectedTextStyle = tabBarConfig?.tagSelectedTextStyle?.merge( + _tagSelectedTextStyle = tabBarConfig.tagSelectedTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(tagSelectedTextStyle), + ).merge(_tagSelectedTextStyle), ); - tagNormalBgColor ??= tabBarConfig?.tagNormalBgColor; - tagSelectedBgColor ??= tabBarConfig?.tagSelectedBgColor; - tagRadius ??= commonConfig.radiusSm; - tagSpacing ??= tabBarConfig?.tagSpacing; - preLineTagCount ??= tabBarConfig?.preLineTagCount; - tagHeight ??= tabBarConfig?.tagHeight; + _tagNormalBgColor ??= tabBarConfig._tagNormalBgColor; + _tagSelectedBgColor ??= tabBarConfig._tagSelectedBgColor; + _tagRadius ??= commonConfig.radiusSm; + _tagSpacing ??= tabBarConfig._tagSpacing; + _preLineTagCount ??= tabBarConfig._preLineTagCount; + _tagHeight ??= tabBarConfig._tagHeight; } BrnTabBarConfig copyWith({ @@ -165,45 +231,42 @@ class BrnTabBarConfig extends BrnBaseConfig { double? tagHeight, }) { return BrnTabBarConfig( - tabHeight: tabHeight ?? this.tabHeight, - indicatorHeight: indicatorHeight ?? this.indicatorHeight, - indicatorWidth: indicatorWidth ?? this.indicatorWidth, - labelStyle: labelStyle ?? this.labelStyle, - unselectedLabelStyle: unselectedLabelStyle ?? this.unselectedLabelStyle, - backgroundColor: backgroundColor ?? this.backgroundColor, - tagNormalTextStyle: tagNormalTextStyle ?? this.tagNormalTextStyle, - tagNormalBgColor: tagNormalColor ?? this.tagNormalBgColor, - tagSelectedTextStyle: tagSelectedTextStyle ?? this.tagSelectedTextStyle, - tagSelectedBgColor: tagSelectedColor ?? this.tagSelectedBgColor, - tagRadius: tagRadius ?? this.tagRadius, - tagSpacing: tagSpacing ?? this.tagSpacing, - preLineTagCount: preLineTagSize ?? this.preLineTagCount, - tagHeight: tagHeight ?? this.tagHeight, + tabHeight: tabHeight ?? _tabHeight, + indicatorHeight: indicatorHeight ?? _indicatorHeight, + indicatorWidth: indicatorWidth ?? _indicatorWidth, + labelStyle: labelStyle ?? _labelStyle, + unselectedLabelStyle: unselectedLabelStyle ?? _unselectedLabelStyle, + backgroundColor: backgroundColor ?? _backgroundColor, + tagNormalTextStyle: tagNormalTextStyle ?? _tagNormalTextStyle, + tagNormalBgColor: tagNormalColor ?? _tagNormalBgColor, + tagSelectedTextStyle: tagSelectedTextStyle ?? _tagSelectedTextStyle, + tagSelectedBgColor: tagSelectedColor ?? _tagSelectedBgColor, + tagRadius: tagRadius ?? _tagRadius, + tagSpacing: tagSpacing ?? _tagSpacing, + preLineTagCount: preLineTagSize ?? _preLineTagCount, + tagHeight: tagHeight ?? _tagHeight, ); } BrnTabBarConfig merge(BrnTabBarConfig? other) { if (other == null) return this; return copyWith( - tabHeight: other.tabHeight, - indicatorHeight: other.indicatorHeight, - indicatorWidth: other.indicatorWidth, - labelStyle: labelStyle?.merge(other.labelStyle) ?? other.labelStyle, + tabHeight: other._tabHeight, + indicatorHeight: other._indicatorHeight, + indicatorWidth: other._indicatorWidth, + labelStyle: labelStyle.merge(other._labelStyle), unselectedLabelStyle: - unselectedLabelStyle?.merge(other.unselectedLabelStyle) ?? - other.unselectedLabelStyle, - backgroundColor: other.backgroundColor, - tagNormalTextStyle: tagNormalTextStyle?.merge(other.tagNormalTextStyle) ?? - other.tagNormalTextStyle, - tagNormalColor: other.tagNormalBgColor, + unselectedLabelStyle.merge(other._unselectedLabelStyle), + backgroundColor: other._backgroundColor, + tagNormalTextStyle: tagNormalTextStyle.merge(other._tagNormalTextStyle), + tagNormalColor: other._tagNormalBgColor, tagSelectedTextStyle: - tagSelectedTextStyle?.merge(other.tagSelectedTextStyle) ?? - other.tagSelectedTextStyle, - tagSelectedColor: other.tagSelectedBgColor, - tagRadius: other.tagRadius, - tagSpacing: other.tagSpacing, - preLineTagSize: other.preLineTagCount, - tagHeight: other.tagHeight, + tagSelectedTextStyle.merge(other._tagSelectedTextStyle), + tagSelectedColor: other._tagSelectedBgColor, + tagRadius: other._tagRadius, + tagSpacing: other._tagSpacing, + preLineTagSize: other._preLineTagCount, + tagHeight: other._tagHeight, ); } } diff --git a/lib/src/theme/configs/brn_tag_config.dart b/lib/src/theme/configs/brn_tag_config.dart index 113493c6..39b03a26 100644 --- a/lib/src/theme/configs/brn_tag_config.dart +++ b/lib/src/theme/configs/brn_tag_config.dart @@ -1,4 +1,5 @@ import 'package:bruno/src/theme/base/brn_base_config.dart'; +import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/base/brn_text_style.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; @@ -7,16 +8,24 @@ import 'package:flutter/painting.dart'; /// 标签配置类 class BrnTagConfig extends BrnBaseConfig { BrnTagConfig({ - this.tagTextStyle, - this.selectTagTextStyle, - this.tagRadius, - this.tagBackgroundColor, - this.selectedTagBackgroundColor, - this.tagHeight, - this.tagWidth, - this.tagMinWidth, + BrnTextStyle? tagTextStyle, + BrnTextStyle? selectTagTextStyle, + double? tagRadius, + Color? tagBackgroundColor, + Color? selectedTagBackgroundColor, + double? tagHeight, + double? tagWidth, + double? tagMinWidth, String configId = GLOBAL_CONFIG_ID, - }) : super(configId: configId); + }) : _tagTextStyle = tagTextStyle, + _selectTagTextStyle = selectTagTextStyle, + _tagRadius = tagRadius, + _tagBackgroundColor = tagBackgroundColor, + _selectedTagBackgroundColor = selectedTagBackgroundColor, + _tagHeight = tagHeight, + _tagWidth = tagWidth, + _tagMinWidth = tagMinWidth, + super(configId: configId); /// tag 文本样式 /// @@ -24,7 +33,7 @@ class BrnTagConfig extends BrnBaseConfig { /// color: [BrnCommonConfig.colorTextBase], /// fontSize: [BrnCommonConfig.fontSizeCaption], /// ) - BrnTextStyle? tagTextStyle; + BrnTextStyle? _tagTextStyle; /// tag选中文本样式 /// @@ -33,31 +42,58 @@ class BrnTagConfig extends BrnBaseConfig { /// fontSize: [BrnCommonConfig.fontSizeCaption], /// fontWeight: FontWeight.w600, /// ) - BrnTextStyle? selectTagTextStyle; + BrnTextStyle? _selectTagTextStyle; /// 标签背景色 /// default [BrnCommonConfig.fillBody] - Color? tagBackgroundColor; + Color? _tagBackgroundColor; /// 选中背景色 /// default [BrnCommonConfig.brandPrimary] - Color? selectedTagBackgroundColor; + Color? _selectedTagBackgroundColor; /// 标签圆角 /// 默认为 [BrnCommonConfig.radiusXs] - double? tagRadius; + double? _tagRadius; /// 标签高度,跟 fixWidthMode 无关 /// 默认为 34 - double? tagHeight; + double? _tagHeight; /// 标签宽度,且仅在组件设置了固定宽度(fixWidthMode 为 true)时才生效 /// 默认为 75 - double? tagWidth; + double? _tagWidth; /// 标签最小宽度 /// 默认为 75 - double? tagMinWidth; + double? _tagMinWidth; + + BrnTextStyle get tagTextStyle => + _tagTextStyle ?? BrnDefaultConfigUtils.defaultTagConfig.tagTextStyle; + + BrnTextStyle get selectTagTextStyle => + _selectTagTextStyle ?? + BrnDefaultConfigUtils.defaultTagConfig.selectTagTextStyle; + + Color get tagBackgroundColor => + _tagBackgroundColor ?? + BrnDefaultConfigUtils.defaultTagConfig.tagBackgroundColor; + + Color get selectedTagBackgroundColor => + _selectedTagBackgroundColor ?? + BrnDefaultConfigUtils.defaultTagConfig.selectedTagBackgroundColor; + + double get tagRadius => + _tagRadius ?? BrnDefaultConfigUtils.defaultTagConfig.tagRadius; + + double get tagHeight => + _tagHeight ?? BrnDefaultConfigUtils.defaultTagConfig.tagHeight; + + double get tagWidth => + _tagWidth ?? BrnDefaultConfigUtils.defaultTagConfig.tagWidth; + + double get tagMinWidth => + _tagMinWidth ?? BrnDefaultConfigUtils.defaultTagConfig.tagMinWidth; @override void initThemeConfig( @@ -70,26 +106,26 @@ class BrnTagConfig extends BrnBaseConfig { ); /// 用户全局组件配置 - BrnTagConfig? tagConfig = + BrnTagConfig tagConfig = BrnThemeConfigurator.instance.getConfig(configId: configId).tagConfig; - tagHeight ??= tagConfig?.tagHeight; - tagWidth ??= tagConfig?.tagWidth; - tagMinWidth ??= tagConfig?.tagMinWidth; - tagRadius ??= commonConfig.radiusXs; - tagBackgroundColor ??= commonConfig.fillBody; - selectedTagBackgroundColor ??= commonConfig.brandPrimary; - tagTextStyle = tagConfig?.tagTextStyle?.merge( + _tagHeight ??= tagConfig._tagHeight; + _tagWidth ??= tagConfig._tagWidth; + _tagMinWidth ??= tagConfig._tagMinWidth; + _tagRadius ??= commonConfig.radiusXs; + _tagBackgroundColor ??= commonConfig.fillBody; + _selectedTagBackgroundColor ??= commonConfig.brandPrimary; + _tagTextStyle = tagConfig.tagTextStyle.merge( BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeCaption, - ).merge(tagTextStyle), + ).merge(_tagTextStyle), ); - selectTagTextStyle = tagConfig?.selectTagTextStyle?.merge( + _selectTagTextStyle = tagConfig.selectTagTextStyle.merge( BrnTextStyle( color: commonConfig.brandPrimary, fontSize: commonConfig.fontSizeCaption, - ).merge(selectTagTextStyle), + ).merge(_selectTagTextStyle), ); } @@ -104,29 +140,28 @@ class BrnTagConfig extends BrnBaseConfig { double? tagMinWidth, }) { return BrnTagConfig( - tagTextStyle: textStyle ?? this.tagTextStyle, - selectTagTextStyle: selectTextStyle ?? this.selectTagTextStyle, - tagRadius: radius ?? this.tagRadius, - tagBackgroundColor: backgroundColor ?? this.tagBackgroundColor, + tagTextStyle: textStyle ?? _tagTextStyle, + selectTagTextStyle: selectTextStyle ?? _selectTagTextStyle, + tagRadius: radius ?? _tagRadius, + tagBackgroundColor: backgroundColor ?? _tagBackgroundColor, selectedTagBackgroundColor: - selectedBackgroundColor ?? this.selectedTagBackgroundColor, - tagHeight: height ?? this.tagHeight, - tagWidth: width ?? this.tagWidth, - tagMinWidth: tagMinWidth ?? this.tagMinWidth, + selectedBackgroundColor ?? _selectedTagBackgroundColor, + tagHeight: height ?? _tagHeight, + tagWidth: width ?? _tagWidth, + tagMinWidth: tagMinWidth ?? _tagMinWidth, ); } BrnTagConfig merge(BrnTagConfig other) { return copyWith( - textStyle: tagTextStyle?.merge(other.tagTextStyle) ?? other.tagTextStyle, - selectTextStyle: selectTagTextStyle?.merge(other.selectTagTextStyle) ?? - other.selectTagTextStyle, - radius: other.tagRadius, - backgroundColor: other.tagBackgroundColor, - selectedBackgroundColor: other.selectedTagBackgroundColor, - height: other.tagHeight, - width: other.tagWidth, - tagMinWidth: other.tagMinWidth, + textStyle: tagTextStyle.merge(other._tagTextStyle), + selectTextStyle: selectTagTextStyle.merge(other._selectTagTextStyle), + radius: other._tagRadius, + backgroundColor: other._tagBackgroundColor, + selectedBackgroundColor: other._selectedTagBackgroundColor, + height: other._tagHeight, + width: other._tagWidth, + tagMinWidth: other._tagMinWidth, ); } } From f97bf0754f020d0570d345dd9ed81f146796664d Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 28 Dec 2021 20:29:51 +0800 Subject: [PATCH 03/31] =?UTF-8?q?theme:=E5=8E=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BF=A1=E6=81=AF=E5=8F=8A=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/ios/Podfile | 86 ++++++++++++++++++- example/ios/Runner.xcodeproj/project.pbxproj | 16 ++++ .../contents.xcworkspacedata | 2 +- example/lib/main.dart | 3 - .../scroll_actor_tab_example.dart | 1 - .../lib/sample/theme/config_test_utils.dart | 10 --- .../configs/brn_abnormal_state_config.dart | 2 +- lib/src/theme/configs/brn_appbar_config.dart | 79 ++++++----------- .../configs/brn_gallery_detail_config.dart | 32 +------ 9 files changed, 130 insertions(+), 101 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 08502eec..0ee4a537 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,10 +1,90 @@ -# Uncomment the next line to define a global platform for your project +# Uncomment this line to define a global platform for your project # platform :ios, '9.0' +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + generated_key_values = {} + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) do |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + generated_key_values[podname] = podpath + else + puts "Invalid plugin specification: #{line}" + end + end + generated_key_values +end + target 'Runner' do - # Comment the next line if you don't want to use dynamic frameworks use_frameworks! + use_modular_headers! + + # Flutter Pod + + copied_flutter_dir = File.join(__dir__, 'Flutter') + copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') + copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') + unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) + # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. + # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. + # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. + + generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') + unless File.exist?(generated_xcode_build_settings_path) + raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) + cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; + + unless File.exist?(copied_framework_path) + FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) + end + unless File.exist?(copied_podspec_path) + FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) + end + end + + # Keep pod path relative so it can be checked into Podfile.lock. + pod 'Flutter', :path => 'Flutter' + + # Plugin Pods + + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.each do |name, path| + symlink = File.join('.symlinks', 'plugins', name) + File.symlink(path, symlink) + pod name, :path => File.join(symlink, 'ios') + end +end - # Pods for Runner +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end end diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index e891e69b..bacab8cf 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -146,6 +146,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + DC926F330116FD87C8E402BA /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -255,6 +256,21 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + DC926F330116FD87C8E402BA /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 919434a6..1d526a16 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "group:Runner.xcodeproj"> diff --git a/example/lib/main.dart b/example/lib/main.dart index ec337f68..202b0652 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,11 +1,8 @@ -import 'package:bruno/bruno.dart'; import 'package:example/sample/home/home.dart'; import 'package:flutter/material.dart'; void main() { - BrnInitializer.register(allThemeConfig: BrnAllThemeConfig(appBarConfig: BrnAppBarConfig(backgroundColor:Colors.orange))); runApp(MyApp()); - } class MyApp extends StatelessWidget { diff --git a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart index 0182569e..9060636a 100644 --- a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart +++ b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart @@ -8,7 +8,6 @@ class ScrollActorTabExample extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: BrnAppBar( - themeData: BrnAppBarConfig(backgroundColor: Colors.green), title: '锚点', ), body: BrnAnchorTab( diff --git a/example/lib/sample/theme/config_test_utils.dart b/example/lib/sample/theme/config_test_utils.dart index f91dd885..0d741da6 100644 --- a/example/lib/sample/theme/config_test_utils.dart +++ b/example/lib/sample/theme/config_test_utils.dart @@ -158,16 +158,6 @@ class TestConfigUtils { titleMaxLength: 20, titleStyle: BrnTextStyle(color: Color(0xff222222), fontWeight: FontWeight.w600, fontSize: 24), actionsStyle: BrnTextStyle(color: Color(0xFF3072F6), fontWeight: FontWeight.w600, fontSize: 18), - flexibleSpace: Container( - width: double.infinity, - height: MediaQueryData.fromWindow(window).padding.top + 57, - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Color(0xfffafafa), - Color(0xfff5f5f5), - ], begin: Alignment.topCenter, end: Alignment.bottomCenter), - ), - ), ); static BrnButtonConfig defaultButtonConfig = BrnButtonConfig( diff --git a/lib/src/theme/configs/brn_abnormal_state_config.dart b/lib/src/theme/configs/brn_abnormal_state_config.dart index d39a889b..67b829ff 100644 --- a/lib/src/theme/configs/brn_abnormal_state_config.dart +++ b/lib/src/theme/configs/brn_abnormal_state_config.dart @@ -129,7 +129,7 @@ class BrnAbnormalStateConfig extends BrnBaseConfig { BrnTextStyle( color: commonConfig.colorTextBase, fontSize: commonConfig.fontSizeSubHead, - ).merge(titleTextStyle), + ).merge(_titleTextStyle), ); _contentTextStyle = abnormalStateConfig.contentTextStyle.merge( BrnTextStyle( diff --git a/lib/src/theme/configs/brn_appbar_config.dart b/lib/src/theme/configs/brn_appbar_config.dart index c8b07521..a220c951 100644 --- a/lib/src/theme/configs/brn_appbar_config.dart +++ b/lib/src/theme/configs/brn_appbar_config.dart @@ -26,7 +26,6 @@ class BrnAppBarConfig extends BrnBaseConfig { double? itemSpacing, EdgeInsets? titlePadding, double? iconSize, - Widget? flexibleSpace, SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, }) : _backgroundColor = backgroundColor, @@ -43,86 +42,64 @@ class BrnAppBarConfig extends BrnBaseConfig { super(configId: configId); BrnAppBarConfig.dark({ - Color? backgroundColor, double? appBarHeight, - BrnWidgetBuilder? leadIconBuilder, - BrnTextStyle? titleStyle, - BrnTextStyle? actionsStyle, int? titleMaxLength, double? leftAndRightPadding, double? itemSpacing, EdgeInsets? titlePadding, double? iconSize, - Widget? flexibleSpace, - SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : _backgroundColor = backgroundColor, - _appBarHeight = appBarHeight, - _leadIconBuilder = leadIconBuilder, - _titleStyle = titleStyle, - _actionsStyle = actionsStyle, + }) : _appBarHeight = appBarHeight, _titleMaxLength = titleMaxLength, _leftAndRightPadding = leftAndRightPadding, _itemSpacing = itemSpacing, _titlePadding = titlePadding, _iconSize = iconSize, - _systemUiOverlayStyle = systemUiOverlayStyle, super(configId: configId) { - backgroundColor = Color(0xff2E313B); - leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_WHITE, - package: BrnStrings.flutterPackageName, - width: BrnAppBarTheme.iconSize, - height: BrnAppBarTheme.iconSize, - fit: BoxFit.fitHeight, - ); - titleStyle = BrnTextStyle( + _backgroundColor = Color(0xff2E313B); + _leadIconBuilder = () => Image.asset( + BrnAsset.ICON_BACK_WHITE, + package: BrnStrings.flutterPackageName, + width: BrnAppBarTheme.iconSize, + height: BrnAppBarTheme.iconSize, + fit: BoxFit.fitHeight, + ); + _titleStyle = BrnTextStyle( fontSize: BrnAppBarTheme.titleFontSize, fontWeight: FontWeight.w600, color: BrnAppBarTheme.darkTextColor, ); - actionsStyle = BrnTextStyle( + _actionsStyle = BrnTextStyle( color: BrnAppBarTheme.darkTextColor, fontSize: BrnAppBarTheme.actionFontSize, fontWeight: FontWeight.w600, ); - systemUiOverlayStyle = SystemUiOverlayStyle.light; + _systemUiOverlayStyle = SystemUiOverlayStyle.light; } BrnAppBarConfig.light({ - Color? backgroundColor, double? appBarHeight, - BrnWidgetBuilder? leadIconBuilder, - BrnTextStyle? titleStyle, - BrnTextStyle? actionsStyle, int? titleMaxLength, double? leftAndRightPadding, double? itemSpacing, EdgeInsets? titlePadding, double? iconSize, - Widget? flexibleSpace, - SystemUiOverlayStyle? systemUiOverlayStyle, String configId = GLOBAL_CONFIG_ID, - }) : _backgroundColor = backgroundColor, - _appBarHeight = appBarHeight, - _leadIconBuilder = leadIconBuilder, - _titleStyle = titleStyle, - _actionsStyle = actionsStyle, + }) : _appBarHeight = appBarHeight, _titleMaxLength = titleMaxLength, _leftAndRightPadding = leftAndRightPadding, _itemSpacing = itemSpacing, _titlePadding = titlePadding, _iconSize = iconSize, - _systemUiOverlayStyle = systemUiOverlayStyle, super(configId: configId) { _backgroundColor = Colors.white; _leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_BLACK, - package: BrnStrings.flutterPackageName, - width: BrnAppBarTheme.iconSize, - height: BrnAppBarTheme.iconSize, - fit: BoxFit.fitHeight, - ); + BrnAsset.ICON_BACK_BLACK, + package: BrnStrings.flutterPackageName, + width: BrnAppBarTheme.iconSize, + height: BrnAppBarTheme.iconSize, + fit: BoxFit.fitHeight, + ); _titleStyle = BrnTextStyle( fontSize: BrnAppBarTheme.titleFontSize, fontWeight: FontWeight.w600, @@ -141,7 +118,7 @@ class BrnAppBarConfig extends BrnBaseConfig { Color get backgroundColor => _backgroundColor ?? - BrnDefaultConfigUtils.defaultAppBarConfig.backgroundColor; + BrnDefaultConfigUtils.defaultAppBarConfig.backgroundColor; /// AppBar 的高度 double? _appBarHeight; @@ -154,7 +131,7 @@ class BrnAppBarConfig extends BrnBaseConfig { BrnWidgetBuilder get leadIconBuilder => _leadIconBuilder ?? - BrnDefaultConfigUtils.defaultAppBarConfig.leadIconBuilder; + BrnDefaultConfigUtils.defaultAppBarConfig.leadIconBuilder; /// 标题样式,仅当直接 title 设置为 String 生效 /// @@ -183,14 +160,14 @@ class BrnAppBarConfig extends BrnBaseConfig { int get titleMaxLength => _titleMaxLength ?? - BrnDefaultConfigUtils.defaultAppBarConfig.titleMaxLength; + BrnDefaultConfigUtils.defaultAppBarConfig.titleMaxLength; /// 左右边距 double? _leftAndRightPadding; double get leftAndRightPadding => _leftAndRightPadding ?? - BrnDefaultConfigUtils.defaultAppBarConfig.leftAndRightPadding; + BrnDefaultConfigUtils.defaultAppBarConfig.leftAndRightPadding; /// 元素间间距 double? _itemSpacing; @@ -211,20 +188,19 @@ class BrnAppBarConfig extends BrnBaseConfig { double get iconSize => _iconSize ?? BrnDefaultConfigUtils.defaultAppBarConfig.iconSize; - /// statusBar 样式 /// 默认为 [SystemUiOverlayStyle.dark] SystemUiOverlayStyle? _systemUiOverlayStyle; SystemUiOverlayStyle get systemUiOverlayStyle => _systemUiOverlayStyle ?? - BrnDefaultConfigUtils.defaultAppBarConfig.systemUiOverlayStyle; + BrnDefaultConfigUtils.defaultAppBarConfig.systemUiOverlayStyle; @override void initThemeConfig( - String configId, { - BrnCommonConfig? currentLevelCommonConfig, - }) { + String configId, { + BrnCommonConfig? currentLevelCommonConfig, + }) { super.initThemeConfig( configId, currentLevelCommonConfig: currentLevelCommonConfig, @@ -259,7 +235,6 @@ class BrnAppBarConfig extends BrnBaseConfig { double? itemSpacing, EdgeInsets? titlePadding, double? iconSize, - Widget? flexibleSpace, SystemUiOverlayStyle? systemUiOverlayStyle, }) { return BrnAppBarConfig( diff --git a/lib/src/theme/configs/brn_gallery_detail_config.dart b/lib/src/theme/configs/brn_gallery_detail_config.dart index 0030e8e4..b7155350 100644 --- a/lib/src/theme/configs/brn_gallery_detail_config.dart +++ b/lib/src/theme/configs/brn_gallery_detail_config.dart @@ -42,19 +42,6 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// 黑色主题 BrnGalleryDetailConfig.dark({ - appbarTitleStyle, - appbarActionStyle, - appbarBackgroundColor, - appbarBrightness, - tabBarUnSelectedLabelStyle, - tabBarLabelStyle, - tabBarBackgroundColor, - pageBackgroundColor, - bottomBackgroundColor, - titleStyle, - contentStyle, - actionStyle, - iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBaseInverse); @@ -74,19 +61,6 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { /// 白色主题 BrnGalleryDetailConfig.light({ - appbarTitleStyle, - appbarActionStyle, - appbarBackgroundColor, - appbarBrightness, - tabBarUnSelectedLabelStyle, - tabBarLabelStyle, - tabBarBackgroundColor, - pageBackgroundColor, - bottomBackgroundColor, - titleStyle, - contentStyle, - actionStyle, - iconColor, String configId = GLOBAL_CONFIG_ID, }) : super(configId: configId) { _appbarTitleStyle = BrnTextStyle(color: commonConfig.colorTextBase); @@ -270,8 +244,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { ); _appbarBrightness ??= galleryDetailConfig.appbarBrightness; _appbarBackgroundColor ??= galleryDetailConfig.appbarBackgroundColor; - _tabBarUnSelectedLabelStyle = galleryDetailConfig - .tabBarUnSelectedLabelStyle + _tabBarUnSelectedLabelStyle = galleryDetailConfig.tabBarUnSelectedLabelStyle .merge(BrnTextStyle(fontSize: commonConfig.fontSizeSubHead)) .merge(_tabBarUnSelectedLabelStyle); _tabBarLabelStyle = galleryDetailConfig.tabBarLabelStyle @@ -357,8 +330,7 @@ class BrnGalleryDetailConfig extends BrnBaseConfig { pageBackgroundColor: other._pageBackgroundColor, bottomBackgroundColor: other._bottomBackgroundColor, titleStyle: titleStyle.merge(other._titleStyle), - contentStyle: - contentStyle.merge(other._contentStyle), + contentStyle: contentStyle.merge(other._contentStyle), actionStyle: actionStyle.merge(other._actionStyle), iconColor: other._iconColor, ); From 44ba17a527b4a3f443c50b21127957bfeb2a7442 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 28 Dec 2021 22:48:09 +0800 Subject: [PATCH 04/31] =?UTF-8?q?theme:=E5=A2=9E=E5=8A=A0=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/theme/configs/brn_dialog_config.dart | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/src/theme/configs/brn_dialog_config.dart b/lib/src/theme/configs/brn_dialog_config.dart index 7bd99306..cab28d71 100644 --- a/lib/src/theme/configs/brn_dialog_config.dart +++ b/lib/src/theme/configs/brn_dialog_config.dart @@ -8,28 +8,28 @@ import 'package:flutter/material.dart'; /// 描述: Dialog 弹框主配置类 class BrnDialogConfig extends BrnBaseConfig { BrnDialogConfig({ - dialogWidth, - radius, - iconPadding, - titlePaddingSm, - titlePaddingLg, - titleTextStyle, - titleTextAlign, - contentPaddingSm, - contentPaddingLg, - contentTextStyle, - contentTextAlign, - warningPaddingSm, - warningPaddingLg, - warningTextStyle, - warningTextAlign, - dividerPadding, - mainActionTextStyle, - assistActionsTextStyle, - mainActionBackgroundColor, - assistActionsBackgroundColor, - bottomHeight, - backgroundColor, + double? dialogWidth, + double? radius, + EdgeInsets? iconPadding, + EdgeInsets? titlePaddingSm, + EdgeInsets? titlePaddingLg, + BrnTextStyle? titleTextStyle, + TextAlign? titleTextAlign, + EdgeInsets? contentPaddingSm, + EdgeInsets? contentPaddingLg, + BrnTextStyle? contentTextStyle, + TextAlign? contentTextAlign, + EdgeInsets? warningPaddingSm, + EdgeInsets? warningPaddingLg, + BrnTextStyle? warningTextStyle, + TextAlign? warningTextAlign, + EdgeInsets? dividerPadding, + BrnTextStyle? mainActionTextStyle, + BrnTextStyle? assistActionsTextStyle, + Color? mainActionBackgroundColor, + Color? assistActionsBackgroundColor, + double? bottomHeight, + Color? backgroundColor, String configId = GLOBAL_CONFIG_ID, }) : _dialogWidth = dialogWidth, _radius = radius, @@ -458,7 +458,8 @@ class BrnDialogConfig extends BrnBaseConfig { warningTextStyle: warningTextStyle.merge(other._warningTextStyle), warningTextAlign: other._warningTextAlign, dividerPadding: other._dividerPadding, - mainActionTextStyle: mainActionTextStyle.merge(other._mainActionTextStyle), + mainActionTextStyle: + mainActionTextStyle.merge(other._mainActionTextStyle), assistActionsTextStyle: assistActionsTextStyle.merge(other._assistActionsTextStyle), mainActionBackgroundColor: other._mainActionBackgroundColor, From c19203f63423eb62541e2d40b30f38a64eedb818 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Fri, 31 Dec 2021 16:05:05 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E5=A4=8D=20Ev?= =?UTF-8?q?entBus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/utils/brn_event_bus.dart | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/src/utils/brn_event_bus.dart b/lib/src/utils/brn_event_bus.dart index f9c96247..9d3832a6 100644 --- a/lib/src/utils/brn_event_bus.dart +++ b/lib/src/utils/brn_event_bus.dart @@ -32,16 +32,15 @@ class EventBus { static EventBus? _instance; - factory EventBus.init() { - _instance = EventBus(); + factory EventBus._() { + if(_instance == null) { + _instance = EventBus(); + } return _instance!; } static EventBus get instance { - if (_instance == null) { - EventBus.init(); - } - return _instance!; + return EventBus._(); } StreamController _streamController; @@ -64,7 +63,7 @@ class EventBus { /// resumed or cancelled. So it's usually better to just cancel and later /// subscribe again (avoids memory leak). /// - Stream on() { + Stream on() { if (T == dynamic) { return streamController.stream as Stream; } @@ -80,19 +79,5 @@ class EventBus { void destroy() { _streamController.close(); } - static EventBus? _instance; - - factory EventBus.init() { - if (_instance == null) { - _instance = EventBus(); - } - return _instance!; - } - static EventBus get instance { - if (_instance == null) { - EventBus.init(); - } - return _instance!; - } } From 6e0834b62cb91087faec99454283820a154cc403 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 4 Jan 2022 17:38:07 +0800 Subject: [PATCH 06/31] =?UTF-8?q?=E8=BF=81=E7=A7=BBexample=20=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=B8=E9=87=8F=E5=91=BD=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/icons/icon_uparrow.png | Bin 452 -> 0 bytes example/lib/main.dart | 2 + .../actionsheet/actionsheet_entry_page.dart | 42 ++-- ...ionsheet_selected_list_custom_example.dart | 2 + .../actionsheet_selected_list_example.dart | 2 + .../components/appraise/appraise_example.dart | 2 + .../bottom_tabbar/bottom_tabbar_example.dart | 2 + .../components/button/big_fu_example.dart | 2 + .../components/button/big_ghost_example.dart | 2 + .../components/button/big_main_example.dart | 2 + .../button/big_outline_example.dart | 2 + .../button/bottom_button_entry_page.dart | 2 + .../button/brn_small_outline_example.dart | 2 + .../button/brn_text_button_panel_example.dart | 2 + .../components/button/button_entry_page.dart | 2 + .../button/button_panel_entry_page.dart | 2 + .../button/button_panel_example.dart | 2 + .../button/common_collection_example.dart | 2 + .../button/icon_button_example.dart | 2 + .../button/selection_collection_example.dart | 2 + .../components/button/small_main_example.dart | 2 + .../calendar/calendarview_example.dart | 2 + .../components/card/brn_shadow_example.dart | 2 + .../bubble/brn_expanded_bubble_example.dart | 2 + .../card/bubble/bubble_entry_page.dart | 2 + .../card/bubble/common_bubble_example.dart | 2 + .../content/brn_two_rich_content_example.dart | 2 + .../content/brn_two_text_content_example.dart | 2 + .../keyvalue_align_content_example.dart | 4 +- .../keyvalue_close_content_example.dart | 2 + .../card/content/number_item_example.dart | 2 + .../card/content/text_content_entry_page.dart | 2 + .../content/text_value_arrow_example.dart | 2 + .../card_title/brn_action_title_example.dart | 2 + .../card_title/brn_common_title_example.dart | 2 + .../components/card_title/title_example.dart | 2 + .../charts/chart_entry_example.dart | 2 + .../charts/doughnut_chart_example.dart | 2 + .../charts/line/brn_broken_line_example.dart | 2 + .../charts/line/db_data_node_model.dart | 2 + .../charts/progress_bar_chart_example.dart | 2 + .../charts/progress_chart_entry_page.dart | 2 + .../components/dialog/dialog_entry_page.dart | 18 +- .../components/empty/abnormal_entry_page.dart | 2 + .../empty/abnormal_state_example.dart | 2 + .../form/all_item_style_example.dart | 2 + .../form/form_item_entry_example.dart | 2 + .../components/form/form_page_example.dart | 2 + .../expansion_group_example.dart | 2 + .../form/group_example/group_add_example.dart | 2 + .../group_example/normal_group_example.dart | 2 + .../items_example/base_title_example.dart | 2 + .../items_example/multi_choice_example.dart | 2 + .../multi_choice_protrait_example.dart | 2 + .../items_example/radio_input_example.dart | 2 + .../items_example/radio_protrait_example.dart | 2 + .../items_example/range_input_example.dart | 2 + .../items_example/ratio_input_example.dart | 2 + .../select_all_title_example.dart | 2 + .../form/items_example/star_example.dart | 2 + .../items_example/step_input_example.dart | 2 + .../text_block_input_example.dart | 2 + .../items_example/text_input_example.dart | 2 + .../text_quick_select_input_example.dart | 2 + .../items_example/text_select_example.dart | 2 + .../form/items_example/title_example.dart | 2 + .../items_example/title_select_example.dart | 2 + .../gallery/gallery_detail_example.dart | 2 + .../gallery_detail_page_theme_example.dart | 2 + .../components/gallery/gallery_example.dart | 2 + .../components/guide/force_guide_example.dart | 2 + .../components/guide/guide_entry_page.dart | 2 + .../components/guide/soft_intro_example.dart | 2 + .../components/input/input_example.dart | 2 + .../components/line/dashed_line_example.dart | 2 + .../loading/loading_widget_example.dart | 2 + .../components/navbar/appbar_entry_page.dart | 2 + .../navbar/nav_bar_example_page.dart | 2 + .../noticebar/brn_notice_bar_example.dart | 2 + .../noticebar/notice_bar_example.dart | 2 + .../notice_bar_with_button_example.dart | 2 + .../picker/cutomer_bottom_picker_example.dart | 2 + .../picker/date_picker_example.dart | 2 + .../picker/multi_picker_example.dart | 2 + .../components/picker/picker_entry_page.dart | 2 + .../popup/overlay_window_example.dart | 2 + .../components/popup/popwindow_example.dart | 2 + .../components/rating/rating_example.dart | 8 +- .../scroll_actor_tab_example.dart | 2 + .../selectcity/selected_city_example.dart | 2 + .../components/selection/filter_entity.dart | 2 + .../flat_selection_five_tags_example.dart | 2 + .../flat_selection_four_tags_example.dart | 2 + .../flat_selection_three_tags_example.dart | 2 + .../selection/selection_entry_page.dart | 2 + .../selection/selection_flat_entry_page.dart | 2 + ...ionview_custom_floating_layer_example.dart | 2 + ...view_customhandle_filter_example_page.dart | 2 + ...selectionview_customview_example_page.dart | 2 + ...electionview_date_filter_example_page.dart | 2 + ...selectionview_date_range_example_page.dart | 2 + .../selectionview_interceptor_example.dart | 2 + ...view_limit_max_selected_count_example.dart | 2 + ...electionview_more_filter_example_page.dart | 2 + ...selectionview_multi_list_example_page.dart | 2 + ...electionview_multi_range_example_page.dart | 2 + ...nview_simple_multi_check_example_page.dart | 2 + ...nview_simple_single_list_example_page.dart | 2 + .../step/brn_horizontal_step_example.dart | 2 + .../sample/components/step/step_example.dart | 2 + .../components/step/step_line_example.dart | 2 + .../sugsearch/search_text_example.dart | 1 + .../components/switch/checkbox_example.dart | 2 + .../components/switch/radio_example.dart | 2 + .../tabbar/brn_switch_title_example.dart | 2 + .../components/tabbar/brn_tab_example.dart | 2 + .../tabbar/brn_tabbar_sticky_example.dart | 2 + .../tabbar/sub_switch_title_example.dart | 2 + .../components/tag/border_tag_example.dart | 2 + .../components/tag/custom_tag_example.dart | 2 + .../components/tag/delete_tag_example.dart | 2 + .../components/tag/select_tag_example.dart | 2 + .../components/tag/state_tag_example.dart | 2 + .../sample/components/tag/tag_example.dart | 2 + .../components/tag/tag_row_example.dart | 2 + .../components/toast/toast_example.dart | 2 + example/lib/sample/home/card_data_config.dart | 2 + .../home/expandable_container_widget.dart | 2 + example/lib/sample/home/group_card.dart | 2 + example/lib/sample/home/home.dart | 2 + example/lib/sample/home/list_item.dart | 2 + .../lib/sample/theme/config_test_utils.dart | 2 + example/pubspec.yaml | 4 +- .../brn_selected_list_action_sheet.dart | 2 +- .../actionsheet/brn_share_action_sheet.dart | 4 +- .../brn_appraise_emoji_list_view.dart | 30 +-- .../appraise/brn_appraise_header.dart | 2 +- .../brn_multiple_bottom_button.dart | 6 +- .../collection/brn_text_button_panel.dart | 4 +- .../calendar/brn_calendar_view.dart | 8 +- .../content_card/brn_enhance_number_card.dart | 4 +- .../content_card/brn_pair_info_rich_grid.dart | 2 +- .../content_card/brn_pair_info_table.dart | 16 +- .../card_title/brn_action_card_title.dart | 2 +- .../dialog/brn_content_export_dialog.dart | 2 +- .../components/dialog/brn_share_dialog.dart | 4 +- .../components/dialog/brn_single_select.dart | 2 +- .../general/brn_quick_select_input_item.dart | 2 +- .../items/general/brn_range_input_item.dart | 6 +- .../items/general/brn_star_input_item.dart | 6 +- .../items/general/brn_step_input_item.dart | 14 +- .../items/general/brn_text_input_item.dart | 2 +- .../items/general/brn_text_select_item.dart | 4 +- .../general/brn_title_select_input_item.dart | 6 +- .../form/items/group/brn_normal_group.dart | 2 +- .../items/group/element_expand_widget.dart | 2 +- .../form/items/misc/brn_add_label_item.dart | 2 +- .../form/items/misc/brn_title_item.dart | 2 +- .../undetermined/brn_expandable_group.dart | 4 +- .../components/form/utils/brn_form_util.dart | 10 +- .../gallery/config/brn_bottom_card.dart | 4 +- lib/src/components/guide/brn_tip_widget.dart | 2 +- lib/src/components/navbar/brn_search_bar.dart | 4 +- .../components/noticebar/brn_notice_bar.dart | 40 ++-- .../brn_select_tags_with_input_picker.dart | 2 +- .../bean/brn_multi_column_picker_entity.dart | 4 +- .../components/popup/brn_popup_window.dart | 4 +- lib/src/components/radio/brn_checkbox.dart | 8 +- .../components/radio/brn_radio_button.dart | 8 +- .../components/rating/brn_rating_star.dart | 6 +- .../brn_single_select_city_page.dart | 2 +- .../bean/brn_selection_common_entity.dart | 10 +- .../selection/brn_simple_selection.dart | 2 +- .../widget/brn_flat_selection_item.dart | 4 +- .../widget/brn_layer_more_selection_page.dart | 2 +- .../brn_selection_menu_item_widget.dart | 8 +- .../brn_selection_more_item_widget.dart | 4 +- .../components/step/brn_horizontal_steps.dart | 14 +- .../components/sugsearch/brn_search_text.dart | 4 +- .../components/tabbar/normal/brn_tab_bar.dart | 4 +- .../tag/tagview/brn_delete_tag.dart | 4 +- lib/src/constants/brn_asset_constants.dart | 197 +++++++++--------- lib/src/constants/brn_constants.dart | 24 +-- lib/src/constants/brn_fonts_constants.dart | 12 +- .../theme/base/brn_default_config_utils.dart | 2 +- lib/src/theme/brn_theme.dart | 3 + lib/src/theme/configs/brn_appbar_config.dart | 4 +- .../theme/img/brn_theme_default_utils.dart | 4 +- 188 files changed, 564 insertions(+), 301 deletions(-) delete mode 100644 assets/icons/icon_uparrow.png diff --git a/assets/icons/icon_uparrow.png b/assets/icons/icon_uparrow.png deleted file mode 100644 index b1d4cbf3a9918c37fdba49da7c2e47f07a02a8a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 452 zcmeAS@N?(olHy`uVBq!ia0vp^x**KK1|+Sd9?b$$jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(=G?|Dm){R;N%5N({9_}y24<@x!?>=%|jbY*|R zAiIFMq=D}Oqm={uCYc$_Ubap8y6M5vZUr@|O**GbWsV=WIiD}G<)S#R0G~zTo%kDU ze`45o-A%Z^?d@I5?>E18%lj_yZ?K)AxkJi|`G!mkYb-+!mtLD6!*}VYb+wD5_lCGw zTeJ4`vhVu(#bGP^`wRQCI?U4zOZYa}Ychl}@5!i~!f-e#X3~uKlt1%$*Ltq&v~@b) zw9O-H;Y0NaE!%w3mX>nmPCa7Xa?8n>D_2qOP+RWWZBO+5{}vvYxMS|qf65}~G;j7< z^`2mMzj8n^(6p9=|L_MVM{A#~i|dy0Ka@I9cWLX_TDfa5KLR~G!Qum}fVx { void _showShareSevenStyle(BuildContext context) { List firstRowList = List(); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_WEIXIN, + BrnShareItemConstants.shareWeiXin, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_BROWSER, + BrnShareItemConstants.shareBrowser, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_COPY_LINK, + BrnShareItemConstants.shareCopyLink, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_FRIEND, + BrnShareItemConstants.shareFriend, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_LINK, + BrnShareItemConstants.shareLink, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_QQ, + BrnShareItemConstants.shareQQ, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_CUSTOM, + BrnShareItemConstants.shareCustom, customImage: BrunoTools.getAssetImage("images/icon_custom_share.png"), customTitle: "自定义", canClick: true, @@ -437,35 +439,35 @@ class _ActionSheetEntryPageState extends State { List firstRowList = List(); List secondRowList = List(); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_QZONE, + BrnShareItemConstants.shareQZone, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_SAVE_IMAGE, + BrnShareItemConstants.shareSaveImage, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_SMS, + BrnShareItemConstants.shareSms, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_WEIBO, + BrnShareItemConstants.shareWeiBo, canClick: true, )); secondRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_QZONE, + BrnShareItemConstants.shareQZone, canClick: false, )); secondRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_SAVE_IMAGE, + BrnShareItemConstants.shareSaveImage, canClick: false, )); secondRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_SMS, + BrnShareItemConstants.shareSms, canClick: false, )); secondRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_WEIBO, + BrnShareItemConstants.shareWeiBo, canClick: false, )); BrnShareActionSheet actionSheet = new BrnShareActionSheet( @@ -491,15 +493,15 @@ class _ActionSheetEntryPageState extends State { List firstRowList = List(); List secondRowList = List(); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_WEIXIN, + BrnShareItemConstants.shareWeiXin, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_FRIEND, + BrnShareItemConstants.shareFriend, canClick: true, )); secondRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_CUSTOM, + BrnShareItemConstants.shareCustom, customImage: BrunoTools.getAssetImage("images/icon_custom_share.png"), customTitle: "自定义", canClick: true, @@ -518,11 +520,11 @@ class _ActionSheetEntryPageState extends State { void _showShareTwoStyle(BuildContext context) { List firstRowList = List(); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_WEIXIN, + BrnShareItemConstants.shareWeiXin, canClick: true, )); firstRowList.add(BrnShareItem( - BrnShareItemConstants.SHARE_FRIEND, + BrnShareItemConstants.shareFriend, canClick: true, )); BrnShareActionSheet actionSheet = new BrnShareActionSheet( diff --git a/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart b/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart index d018de8a..b7a0bf47 100644 --- a/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart +++ b/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart b/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart index e4d14f88..efbad49b 100644 --- a/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart +++ b/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/appraise/appraise_example.dart b/example/lib/sample/components/appraise/appraise_example.dart index c092d228..aca18fb4 100644 --- a/example/lib/sample/components/appraise/appraise_example.dart +++ b/example/lib/sample/components/appraise/appraise_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart b/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart index c63100a0..dc593e66 100644 --- a/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart +++ b/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_fu_example.dart b/example/lib/sample/components/button/big_fu_example.dart index cb560015..95b8d02f 100644 --- a/example/lib/sample/components/button/big_fu_example.dart +++ b/example/lib/sample/components/button/big_fu_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_ghost_example.dart b/example/lib/sample/components/button/big_ghost_example.dart index e9089d19..3b3d0e43 100644 --- a/example/lib/sample/components/button/big_ghost_example.dart +++ b/example/lib/sample/components/button/big_ghost_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_main_example.dart b/example/lib/sample/components/button/big_main_example.dart index 827b528c..250f4ce9 100644 --- a/example/lib/sample/components/button/big_main_example.dart +++ b/example/lib/sample/components/button/big_main_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_outline_example.dart b/example/lib/sample/components/button/big_outline_example.dart index 74835b5a..7adb4d96 100644 --- a/example/lib/sample/components/button/big_outline_example.dart +++ b/example/lib/sample/components/button/big_outline_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/bottom_button_entry_page.dart b/example/lib/sample/components/button/bottom_button_entry_page.dart index 314ceeb8..ce2ef9cf 100644 --- a/example/lib/sample/components/button/bottom_button_entry_page.dart +++ b/example/lib/sample/components/button/bottom_button_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/common_collection_example.dart'; import 'package:example/sample/components/button/selection_collection_example.dart'; diff --git a/example/lib/sample/components/button/brn_small_outline_example.dart b/example/lib/sample/components/button/brn_small_outline_example.dart index f5ad0957..25d5fae5 100644 --- a/example/lib/sample/components/button/brn_small_outline_example.dart +++ b/example/lib/sample/components/button/brn_small_outline_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/brn_text_button_panel_example.dart b/example/lib/sample/components/button/brn_text_button_panel_example.dart index 0ebc055e..27d0ec77 100644 --- a/example/lib/sample/components/button/brn_text_button_panel_example.dart +++ b/example/lib/sample/components/button/brn_text_button_panel_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/button_entry_page.dart b/example/lib/sample/components/button/button_entry_page.dart index c851ed43..427d8fb4 100644 --- a/example/lib/sample/components/button/button_entry_page.dart +++ b/example/lib/sample/components/button/button_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/big_main_example.dart'; import 'package:example/sample/components/button/big_outline_example.dart'; diff --git a/example/lib/sample/components/button/button_panel_entry_page.dart b/example/lib/sample/components/button/button_panel_entry_page.dart index 3d6ef593..ad0a903d 100644 --- a/example/lib/sample/components/button/button_panel_entry_page.dart +++ b/example/lib/sample/components/button/button_panel_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/brn_text_button_panel_example.dart'; import 'package:example/sample/components/button/button_panel_example.dart'; diff --git a/example/lib/sample/components/button/button_panel_example.dart b/example/lib/sample/components/button/button_panel_example.dart index 716e7687..e5b139bc 100644 --- a/example/lib/sample/components/button/button_panel_example.dart +++ b/example/lib/sample/components/button/button_panel_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/common_collection_example.dart b/example/lib/sample/components/button/common_collection_example.dart index 249d6bd0..7591e4ea 100644 --- a/example/lib/sample/components/button/common_collection_example.dart +++ b/example/lib/sample/components/button/common_collection_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/icon_button_example.dart b/example/lib/sample/components/button/icon_button_example.dart index b67f415e..bda32e1b 100644 --- a/example/lib/sample/components/button/icon_button_example.dart +++ b/example/lib/sample/components/button/icon_button_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/selection_collection_example.dart b/example/lib/sample/components/button/selection_collection_example.dart index 40bcbe64..f882204b 100644 --- a/example/lib/sample/components/button/selection_collection_example.dart +++ b/example/lib/sample/components/button/selection_collection_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/small_main_example.dart b/example/lib/sample/components/button/small_main_example.dart index 62296eee..e7fb3e5a 100644 --- a/example/lib/sample/components/button/small_main_example.dart +++ b/example/lib/sample/components/button/small_main_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/calendar/calendarview_example.dart b/example/lib/sample/components/calendar/calendarview_example.dart index 26e4178e..a713b3d7 100644 --- a/example/lib/sample/components/calendar/calendarview_example.dart +++ b/example/lib/sample/components/calendar/calendarview_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/brn_shadow_example.dart b/example/lib/sample/components/card/brn_shadow_example.dart index 679166c7..f06001b8 100644 --- a/example/lib/sample/components/card/brn_shadow_example.dart +++ b/example/lib/sample/components/card/brn_shadow_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart index 1c8754c0..5df330ba 100644 --- a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart +++ b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/bubble/bubble_entry_page.dart b/example/lib/sample/components/card/bubble/bubble_entry_page.dart index 550304cc..ff6fd2d2 100644 --- a/example/lib/sample/components/card/bubble/bubble_entry_page.dart +++ b/example/lib/sample/components/card/bubble/bubble_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/bubble/common_bubble_example.dart'; import 'package:example/sample/components/card/bubble/brn_expanded_bubble_example.dart'; diff --git a/example/lib/sample/components/card/bubble/common_bubble_example.dart b/example/lib/sample/components/card/bubble/common_bubble_example.dart index 86532787..5c4486b7 100644 --- a/example/lib/sample/components/card/bubble/common_bubble_example.dart +++ b/example/lib/sample/components/card/bubble/common_bubble_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart index fc9c112d..40b06a40 100644 --- a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart +++ b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/brn_two_text_content_example.dart b/example/lib/sample/components/card/content/brn_two_text_content_example.dart index 3f011d6e..8f1352ab 100644 --- a/example/lib/sample/components/card/content/brn_two_text_content_example.dart +++ b/example/lib/sample/components/card/content/brn_two_text_content_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/keyvalue_align_content_example.dart b/example/lib/sample/components/card/content/keyvalue_align_content_example.dart index 57527374..7d8afa98 100644 --- a/example/lib/sample/components/card/content/keyvalue_align_content_example.dart +++ b/example/lib/sample/components/card/content/keyvalue_align_content_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; @@ -301,7 +303,7 @@ class _TextContentExampleState extends State { ), Transform.rotate( angle: pi, - child: BrunoTools.getAssetImage('icons/icon_uparrow.png')), + child: BrunoTools.getAssetImage('icons/icon_up_arrow.png')), ], ), decoration: BoxDecoration( diff --git a/example/lib/sample/components/card/content/keyvalue_close_content_example.dart b/example/lib/sample/components/card/content/keyvalue_close_content_example.dart index acf2022c..aa4606c9 100644 --- a/example/lib/sample/components/card/content/keyvalue_close_content_example.dart +++ b/example/lib/sample/components/card/content/keyvalue_close_content_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/number_item_example.dart b/example/lib/sample/components/card/content/number_item_example.dart index 07bbba84..c7e4709b 100644 --- a/example/lib/sample/components/card/content/number_item_example.dart +++ b/example/lib/sample/components/card/content/number_item_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/text_content_entry_page.dart b/example/lib/sample/components/card/content/text_content_entry_page.dart index 2a3dfe12..da1888b8 100644 --- a/example/lib/sample/components/card/content/text_content_entry_page.dart +++ b/example/lib/sample/components/card/content/text_content_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/content/keyvalue_align_content_example.dart'; import 'package:example/sample/components/card/content/keyvalue_close_content_example.dart'; diff --git a/example/lib/sample/components/card/content/text_value_arrow_example.dart b/example/lib/sample/components/card/content/text_value_arrow_example.dart index 56d52af9..0b3b329b 100644 --- a/example/lib/sample/components/card/content/text_value_arrow_example.dart +++ b/example/lib/sample/components/card/content/text_value_arrow_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card_title/brn_action_title_example.dart b/example/lib/sample/components/card_title/brn_action_title_example.dart index ba92ad98..ef0926d1 100644 --- a/example/lib/sample/components/card_title/brn_action_title_example.dart +++ b/example/lib/sample/components/card_title/brn_action_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card_title/brn_common_title_example.dart b/example/lib/sample/components/card_title/brn_common_title_example.dart index 9c5a0478..8337ee66 100644 --- a/example/lib/sample/components/card_title/brn_common_title_example.dart +++ b/example/lib/sample/components/card_title/brn_common_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card_title/title_example.dart b/example/lib/sample/components/card_title/title_example.dart index 66b73224..ede686df 100644 --- a/example/lib/sample/components/card_title/title_example.dart +++ b/example/lib/sample/components/card_title/title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card_title/brn_action_title_example.dart'; import 'package:example/sample/components/card_title/brn_common_title_example.dart'; diff --git a/example/lib/sample/components/charts/chart_entry_example.dart b/example/lib/sample/components/charts/chart_entry_example.dart index d66f5f19..0a74e5cc 100644 --- a/example/lib/sample/components/charts/chart_entry_example.dart +++ b/example/lib/sample/components/charts/chart_entry_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/charts/doughnut_chart_example.dart b/example/lib/sample/components/charts/doughnut_chart_example.dart index 49d6c6dd..e97f2e3f 100644 --- a/example/lib/sample/components/charts/doughnut_chart_example.dart +++ b/example/lib/sample/components/charts/doughnut_chart_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/charts/line/brn_broken_line_example.dart b/example/lib/sample/components/charts/line/brn_broken_line_example.dart index fe4b71b2..13b8d0f4 100644 --- a/example/lib/sample/components/charts/line/brn_broken_line_example.dart +++ b/example/lib/sample/components/charts/line/brn_broken_line_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/charts/line/db_data_node_model.dart b/example/lib/sample/components/charts/line/db_data_node_model.dart index 7e0464e4..93625b79 100644 --- a/example/lib/sample/components/charts/line/db_data_node_model.dart +++ b/example/lib/sample/components/charts/line/db_data_node_model.dart @@ -1,5 +1,7 @@ /// @desc 看板卡片中用于描述数据指标的模型,也能用于数据块的定义,内部嵌套了一个itemList +// @dart=2.9 + class DBDataNodeModel { String key; String name; diff --git a/example/lib/sample/components/charts/progress_bar_chart_example.dart b/example/lib/sample/components/charts/progress_bar_chart_example.dart index 0b6c98c4..c30c8316 100644 --- a/example/lib/sample/components/charts/progress_bar_chart_example.dart +++ b/example/lib/sample/components/charts/progress_bar_chart_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/charts/progress_chart_entry_page.dart b/example/lib/sample/components/charts/progress_chart_entry_page.dart index bb0b34c9..db8840de 100644 --- a/example/lib/sample/components/charts/progress_chart_entry_page.dart +++ b/example/lib/sample/components/charts/progress_chart_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/dialog/dialog_entry_page.dart b/example/lib/sample/components/dialog/dialog_entry_page.dart index ff961be6..189311e0 100644 --- a/example/lib/sample/components/dialog/dialog_entry_page.dart +++ b/example/lib/sample/components/dialog/dialog_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:flutter/material.dart'; @@ -762,9 +764,9 @@ class DialogEntryPage extends StatelessWidget { BrnShareDialog brnShareDialog = new BrnShareDialog( context: context, shareChannels: [ - BrnShareItemConstants.SHARE_WEIXIN, - BrnShareItemConstants.SHARE_LINK, - BrnShareItemConstants.SHARE_CUSTOM + BrnShareItemConstants.shareWeiXin, + BrnShareItemConstants.shareLink, + BrnShareItemConstants.shareCustom ], titleText: "测试标题", descText: "测试辅助信息测试辅助信息测试辅助信息测试辅助信息测试辅助信息", @@ -792,11 +794,11 @@ class DialogEntryPage extends StatelessWidget { BrnShareDialog brnShareDialog = new BrnShareDialog( context: context, shareChannels: [ - BrnShareItemConstants.SHARE_WEIXIN, - BrnShareItemConstants.SHARE_CUSTOM, - BrnShareItemConstants.SHARE_CUSTOM, - BrnShareItemConstants.SHARE_LINK, - BrnShareItemConstants.SHARE_CUSTOM + BrnShareItemConstants.shareWeiXin, + BrnShareItemConstants.shareCustom, + BrnShareItemConstants.shareCustom, + BrnShareItemConstants.shareLink, + BrnShareItemConstants.shareCustom ], titleText: "测试标题", descText: "测试辅助信息测试辅助信息测试辅助信息测试辅助信息测试辅助信息", diff --git a/example/lib/sample/components/empty/abnormal_entry_page.dart b/example/lib/sample/components/empty/abnormal_entry_page.dart index a0fa3ffa..2c39489b 100644 --- a/example/lib/sample/components/empty/abnormal_entry_page.dart +++ b/example/lib/sample/components/empty/abnormal_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/empty/abnormal_state_example.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/empty/abnormal_state_example.dart b/example/lib/sample/components/empty/abnormal_state_example.dart index 8fa335fc..e6308d80 100644 --- a/example/lib/sample/components/empty/abnormal_state_example.dart +++ b/example/lib/sample/components/empty/abnormal_state_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/all_item_style_example.dart b/example/lib/sample/components/form/all_item_style_example.dart index ab695efd..5e02a78a 100644 --- a/example/lib/sample/components/form/all_item_style_example.dart +++ b/example/lib/sample/components/form/all_item_style_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/form/group_example/expansion_group_example.dart'; import 'package:example/sample/components/form/group_example/group_add_example.dart'; diff --git a/example/lib/sample/components/form/form_item_entry_example.dart b/example/lib/sample/components/form/form_item_entry_example.dart index 25b63537..f65383b2 100644 --- a/example/lib/sample/components/form/form_item_entry_example.dart +++ b/example/lib/sample/components/form/form_item_entry_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/form/all_item_style_example.dart'; import 'package:example/sample/components/form/form_page_example.dart'; diff --git a/example/lib/sample/components/form/form_page_example.dart b/example/lib/sample/components/form/form_page_example.dart index aa46c4bb..e0820de9 100644 --- a/example/lib/sample/components/form/form_page_example.dart +++ b/example/lib/sample/components/form/form_page_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; /// 退回订单 页面展示 diff --git a/example/lib/sample/components/form/group_example/expansion_group_example.dart b/example/lib/sample/components/form/group_example/expansion_group_example.dart index 248937bb..d4591836 100644 --- a/example/lib/sample/components/form/group_example/expansion_group_example.dart +++ b/example/lib/sample/components/form/group_example/expansion_group_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/group_example/group_add_example.dart b/example/lib/sample/components/form/group_example/group_add_example.dart index 7516c930..1507f0ff 100644 --- a/example/lib/sample/components/form/group_example/group_add_example.dart +++ b/example/lib/sample/components/form/group_example/group_add_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/group_example/normal_group_example.dart b/example/lib/sample/components/form/group_example/normal_group_example.dart index 8edefddd..705c2283 100644 --- a/example/lib/sample/components/form/group_example/normal_group_example.dart +++ b/example/lib/sample/components/form/group_example/normal_group_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/base_title_example.dart b/example/lib/sample/components/form/items_example/base_title_example.dart index f251cb35..03ef2f2c 100644 --- a/example/lib/sample/components/form/items_example/base_title_example.dart +++ b/example/lib/sample/components/form/items_example/base_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/multi_choice_example.dart b/example/lib/sample/components/form/items_example/multi_choice_example.dart index bae807bf..7930fa3e 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart index 9621128e..3d6667f3 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/radio_input_example.dart b/example/lib/sample/components/form/items_example/radio_input_example.dart index cf2045dd..660138e4 100644 --- a/example/lib/sample/components/form/items_example/radio_input_example.dart +++ b/example/lib/sample/components/form/items_example/radio_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/radio_protrait_example.dart b/example/lib/sample/components/form/items_example/radio_protrait_example.dart index 27b60220..11a29c9d 100644 --- a/example/lib/sample/components/form/items_example/radio_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/radio_protrait_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/range_input_example.dart b/example/lib/sample/components/form/items_example/range_input_example.dart index b04a42d9..e48eaa25 100644 --- a/example/lib/sample/components/form/items_example/range_input_example.dart +++ b/example/lib/sample/components/form/items_example/range_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/ratio_input_example.dart b/example/lib/sample/components/form/items_example/ratio_input_example.dart index 72f19a93..74027c82 100644 --- a/example/lib/sample/components/form/items_example/ratio_input_example.dart +++ b/example/lib/sample/components/form/items_example/ratio_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/select_all_title_example.dart b/example/lib/sample/components/form/items_example/select_all_title_example.dart index 2b2d991d..882c4259 100644 --- a/example/lib/sample/components/form/items_example/select_all_title_example.dart +++ b/example/lib/sample/components/form/items_example/select_all_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/star_example.dart b/example/lib/sample/components/form/items_example/star_example.dart index 484bc0a4..2215f140 100644 --- a/example/lib/sample/components/form/items_example/star_example.dart +++ b/example/lib/sample/components/form/items_example/star_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/step_input_example.dart b/example/lib/sample/components/form/items_example/step_input_example.dart index ca1ea523..950a70bc 100644 --- a/example/lib/sample/components/form/items_example/step_input_example.dart +++ b/example/lib/sample/components/form/items_example/step_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_block_input_example.dart b/example/lib/sample/components/form/items_example/text_block_input_example.dart index bd15cc0a..f15273f3 100644 --- a/example/lib/sample/components/form/items_example/text_block_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_block_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_input_example.dart b/example/lib/sample/components/form/items_example/text_input_example.dart index 401b42dc..f55b432e 100644 --- a/example/lib/sample/components/form/items_example/text_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart index 8703111f..2e1a9358 100644 --- a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/example/lib/sample/components/form/items_example/text_select_example.dart b/example/lib/sample/components/form/items_example/text_select_example.dart index 3e8de41a..7ddf1f66 100644 --- a/example/lib/sample/components/form/items_example/text_select_example.dart +++ b/example/lib/sample/components/form/items_example/text_select_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/example/lib/sample/components/form/items_example/title_example.dart b/example/lib/sample/components/form/items_example/title_example.dart index 227cd61a..970f43ad 100644 --- a/example/lib/sample/components/form/items_example/title_example.dart +++ b/example/lib/sample/components/form/items_example/title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index 9fe73327..a1512996 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/example/lib/sample/components/gallery/gallery_detail_example.dart b/example/lib/sample/components/gallery/gallery_detail_example.dart index 9680766f..597679d5 100644 --- a/example/lib/sample/components/gallery/gallery_detail_example.dart +++ b/example/lib/sample/components/gallery/gallery_detail_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart b/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart index b47d65c6..9c908fd7 100644 --- a/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart +++ b/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/gallery/gallery_detail_example.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/gallery/gallery_example.dart b/example/lib/sample/components/gallery/gallery_example.dart index 1df173bf..cd69afb5 100644 --- a/example/lib/sample/components/gallery/gallery_example.dart +++ b/example/lib/sample/components/gallery/gallery_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/gallery/gallery_detail_page_theme_example.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/guide/force_guide_example.dart b/example/lib/sample/components/guide/force_guide_example.dart index 0803c653..cac44b5b 100644 --- a/example/lib/sample/components/guide/force_guide_example.dart +++ b/example/lib/sample/components/guide/force_guide_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:async'; import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/guide/guide_entry_page.dart b/example/lib/sample/components/guide/guide_entry_page.dart index a48c0515..1e616ab3 100644 --- a/example/lib/sample/components/guide/guide_entry_page.dart +++ b/example/lib/sample/components/guide/guide_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/guide/force_guide_example.dart'; import 'package:example/sample/components/guide/soft_intro_example.dart'; diff --git a/example/lib/sample/components/guide/soft_intro_example.dart b/example/lib/sample/components/guide/soft_intro_example.dart index 2fed63f6..1853fb2a 100644 --- a/example/lib/sample/components/guide/soft_intro_example.dart +++ b/example/lib/sample/components/guide/soft_intro_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:async'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/input/input_example.dart b/example/lib/sample/components/input/input_example.dart index a6e654b9..04ef557a 100644 --- a/example/lib/sample/components/input/input_example.dart +++ b/example/lib/sample/components/input/input_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/example/lib/sample/components/line/dashed_line_example.dart b/example/lib/sample/components/line/dashed_line_example.dart index 8ffd30a6..f3d738c7 100644 --- a/example/lib/sample/components/line/dashed_line_example.dart +++ b/example/lib/sample/components/line/dashed_line_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/loading/loading_widget_example.dart b/example/lib/sample/components/loading/loading_widget_example.dart index f1f64c84..f1d43967 100644 --- a/example/lib/sample/components/loading/loading_widget_example.dart +++ b/example/lib/sample/components/loading/loading_widget_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/navbar/appbar_entry_page.dart b/example/lib/sample/components/navbar/appbar_entry_page.dart index 31f4f747..7a0cb152 100644 --- a/example/lib/sample/components/navbar/appbar_entry_page.dart +++ b/example/lib/sample/components/navbar/appbar_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:example/sample/components/navbar/nav_bar_example_page.dart'; diff --git a/example/lib/sample/components/navbar/nav_bar_example_page.dart b/example/lib/sample/components/navbar/nav_bar_example_page.dart index fa51a1ef..717c46be 100644 --- a/example/lib/sample/components/navbar/nav_bar_example_page.dart +++ b/example/lib/sample/components/navbar/nav_bar_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; diff --git a/example/lib/sample/components/noticebar/brn_notice_bar_example.dart b/example/lib/sample/components/noticebar/brn_notice_bar_example.dart index fa7c06b2..76e44153 100644 --- a/example/lib/sample/components/noticebar/brn_notice_bar_example.dart +++ b/example/lib/sample/components/noticebar/brn_notice_bar_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:example/sample/components/noticebar/notice_bar_example.dart'; diff --git a/example/lib/sample/components/noticebar/notice_bar_example.dart b/example/lib/sample/components/noticebar/notice_bar_example.dart index 438dc52a..f75bf591 100644 --- a/example/lib/sample/components/noticebar/notice_bar_example.dart +++ b/example/lib/sample/components/noticebar/notice_bar_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart b/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart index 4f710353..91618eef 100644 --- a/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart +++ b/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart b/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart index 144f9981..70c94902 100644 --- a/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart +++ b/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/picker/date_picker_example.dart b/example/lib/sample/components/picker/date_picker_example.dart index 46408e2b..d2c9b332 100644 --- a/example/lib/sample/components/picker/date_picker_example.dart +++ b/example/lib/sample/components/picker/date_picker_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/picker/multi_picker_example.dart b/example/lib/sample/components/picker/multi_picker_example.dart index 00ff73c3..33f33bd7 100644 --- a/example/lib/sample/components/picker/multi_picker_example.dart +++ b/example/lib/sample/components/picker/multi_picker_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/picker/picker_entry_page.dart b/example/lib/sample/components/picker/picker_entry_page.dart index 508db7ca..c5484461 100644 --- a/example/lib/sample/components/picker/picker_entry_page.dart +++ b/example/lib/sample/components/picker/picker_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:convert'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/popup/overlay_window_example.dart b/example/lib/sample/components/popup/overlay_window_example.dart index cad07a2c..b58e0c81 100644 --- a/example/lib/sample/components/popup/overlay_window_example.dart +++ b/example/lib/sample/components/popup/overlay_window_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/popup/popwindow_example.dart b/example/lib/sample/components/popup/popwindow_example.dart index cb01d1d6..e5d5c1c9 100644 --- a/example/lib/sample/components/popup/popwindow_example.dart +++ b/example/lib/sample/components/popup/popwindow_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/rating/rating_example.dart b/example/lib/sample/components/rating/rating_example.dart index 4c1addfc..32a6de06 100644 --- a/example/lib/sample/components/rating/rating_example.dart +++ b/example/lib/sample/components/rating/rating_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -72,12 +74,12 @@ class _RatingExampleState extends State { Widget _buildRating(RatingState state) { switch (state) { case RatingState.select: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR, 16, 16, color: Color(0xFF3571DC)); + return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, 16, 16, color: Color(0xFF3571DC)); case RatingState.half: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR_HALF, 16, 16); + return BrunoTools.getAssetSizeImage(BrnAsset.iconStarHalf, 16, 16); case RatingState.unselect: default: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR, 16, 16, color: Color(0xFFF0F0F0)); + return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, 16, 16, color: Color(0xFFF0F0F0)); } } } diff --git a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart index 9060636a..d40acf31 100644 --- a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart +++ b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/selectcity/selected_city_example.dart b/example/lib/sample/components/selectcity/selected_city_example.dart index 9082bd77..fc6d8a7b 100644 --- a/example/lib/sample/components/selectcity/selected_city_example.dart +++ b/example/lib/sample/components/selectcity/selected_city_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:convert'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/selection/filter_entity.dart b/example/lib/sample/components/selection/filter_entity.dart index 23f2d8e5..f350d117 100644 --- a/example/lib/sample/components/selection/filter_entity.dart +++ b/example/lib/sample/components/selection/filter_entity.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; class BrnFilterEntity { diff --git a/example/lib/sample/components/selection/flat_selection_five_tags_example.dart b/example/lib/sample/components/selection/flat_selection_five_tags_example.dart index e4e7f2e6..ff03d625 100644 --- a/example/lib/sample/components/selection/flat_selection_five_tags_example.dart +++ b/example/lib/sample/components/selection/flat_selection_five_tags_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/flat_selection_four_tags_example.dart b/example/lib/sample/components/selection/flat_selection_four_tags_example.dart index 9edd42e3..0db9c2f3 100644 --- a/example/lib/sample/components/selection/flat_selection_four_tags_example.dart +++ b/example/lib/sample/components/selection/flat_selection_four_tags_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/flat_selection_three_tags_example.dart b/example/lib/sample/components/selection/flat_selection_three_tags_example.dart index 16de0f0a..463095dc 100644 --- a/example/lib/sample/components/selection/flat_selection_three_tags_example.dart +++ b/example/lib/sample/components/selection/flat_selection_three_tags_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selection_entry_page.dart b/example/lib/sample/components/selection/selection_entry_page.dart index d9b54394..bf325871 100644 --- a/example/lib/sample/components/selection/selection_entry_page.dart +++ b/example/lib/sample/components/selection/selection_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:convert'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/selection/selection_flat_entry_page.dart b/example/lib/sample/components/selection/selection_flat_entry_page.dart index 4dfda15b..e8a8efb6 100644 --- a/example/lib/sample/components/selection/selection_flat_entry_page.dart +++ b/example/lib/sample/components/selection/selection_flat_entry_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:convert'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart b/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart index 016d6571..c7d6bdee 100644 --- a/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart +++ b/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/bubble/common_bubble_example.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart b/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart index ae7f7681..d8df37b3 100644 --- a/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_customview_example_page.dart b/example/lib/sample/components/selection/selectionview_customview_example_page.dart index d2e9475a..216b8567 100644 --- a/example/lib/sample/components/selection/selectionview_customview_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_customview_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_date_filter_example_page.dart b/example/lib/sample/components/selection/selectionview_date_filter_example_page.dart index ac39b12e..6b9ecbb7 100644 --- a/example/lib/sample/components/selection/selectionview_date_filter_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_date_filter_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart index dbec59e6..ec41dd0e 100644 --- a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_interceptor_example.dart b/example/lib/sample/components/selection/selectionview_interceptor_example.dart index 2c3cbf96..2b2053cc 100644 --- a/example/lib/sample/components/selection/selectionview_interceptor_example.dart +++ b/example/lib/sample/components/selection/selectionview_interceptor_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart b/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart index d70a16b2..ee5cc674 100644 --- a/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart +++ b/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_more_filter_example_page.dart b/example/lib/sample/components/selection/selectionview_more_filter_example_page.dart index 4d334be6..71737ef5 100644 --- a/example/lib/sample/components/selection/selectionview_more_filter_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_more_filter_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/big_fu_example.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart b/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart index 3d3c6172..fcc8b8a8 100644 --- a/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart b/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart index bd5555de..f5acd339 100644 --- a/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_simple_multi_check_example_page.dart b/example/lib/sample/components/selection/selectionview_simple_multi_check_example_page.dart index 4b680414..5f406d81 100755 --- a/example/lib/sample/components/selection/selectionview_simple_multi_check_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_simple_multi_check_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/selection/filter_entity.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart b/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart index b05f00ef..1f56fd65 100755 --- a/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/selection/filter_entity.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/step/brn_horizontal_step_example.dart b/example/lib/sample/components/step/brn_horizontal_step_example.dart index 5f92beb6..938e2c90 100644 --- a/example/lib/sample/components/step/brn_horizontal_step_example.dart +++ b/example/lib/sample/components/step/brn_horizontal_step_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/step/step_example.dart b/example/lib/sample/components/step/step_example.dart index b07eee16..13b1ae74 100644 --- a/example/lib/sample/components/step/step_example.dart +++ b/example/lib/sample/components/step/step_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/step/brn_horizontal_step_example.dart'; import 'package:example/sample/components/step/step_line_example.dart'; diff --git a/example/lib/sample/components/step/step_line_example.dart b/example/lib/sample/components/step/step_line_example.dart index 7e2ad87f..61f70c6f 100644 --- a/example/lib/sample/components/step/step_line_example.dart +++ b/example/lib/sample/components/step/step_line_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/sugsearch/search_text_example.dart b/example/lib/sample/components/sugsearch/search_text_example.dart index d29ebe20..1347faff 100644 --- a/example/lib/sample/components/sugsearch/search_text_example.dart +++ b/example/lib/sample/components/sugsearch/search_text_example.dart @@ -1,3 +1,4 @@ + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/switch/checkbox_example.dart b/example/lib/sample/components/switch/checkbox_example.dart index 33894921..ed0f0dd6 100644 --- a/example/lib/sample/components/switch/checkbox_example.dart +++ b/example/lib/sample/components/switch/checkbox_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/switch/radio_example.dart b/example/lib/sample/components/switch/radio_example.dart index a07db2f1..eee90493 100644 --- a/example/lib/sample/components/switch/radio_example.dart +++ b/example/lib/sample/components/switch/radio_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tabbar/brn_switch_title_example.dart b/example/lib/sample/components/tabbar/brn_switch_title_example.dart index 55b826c9..d2879f89 100644 --- a/example/lib/sample/components/tabbar/brn_switch_title_example.dart +++ b/example/lib/sample/components/tabbar/brn_switch_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tabbar/brn_tab_example.dart b/example/lib/sample/components/tabbar/brn_tab_example.dart index dd05f85f..1f527dcd 100644 --- a/example/lib/sample/components/tabbar/brn_tab_example.dart +++ b/example/lib/sample/components/tabbar/brn_tab_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart index 886dd88b..be0d3cf6 100644 --- a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart +++ b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tabbar/sub_switch_title_example.dart b/example/lib/sample/components/tabbar/sub_switch_title_example.dart index 4c870862..667b48fd 100644 --- a/example/lib/sample/components/tabbar/sub_switch_title_example.dart +++ b/example/lib/sample/components/tabbar/sub_switch_title_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/border_tag_example.dart b/example/lib/sample/components/tag/border_tag_example.dart index aff03ec1..0ca214f4 100644 --- a/example/lib/sample/components/tag/border_tag_example.dart +++ b/example/lib/sample/components/tag/border_tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/custom_tag_example.dart b/example/lib/sample/components/tag/custom_tag_example.dart index db9f8083..990a6992 100644 --- a/example/lib/sample/components/tag/custom_tag_example.dart +++ b/example/lib/sample/components/tag/custom_tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/delete_tag_example.dart b/example/lib/sample/components/tag/delete_tag_example.dart index 8a4a657e..d58f7a42 100644 --- a/example/lib/sample/components/tag/delete_tag_example.dart +++ b/example/lib/sample/components/tag/delete_tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/select_tag_example.dart b/example/lib/sample/components/tag/select_tag_example.dart index 56f56e24..d1e43090 100644 --- a/example/lib/sample/components/tag/select_tag_example.dart +++ b/example/lib/sample/components/tag/select_tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/state_tag_example.dart b/example/lib/sample/components/tag/state_tag_example.dart index 3363d57a..2650e082 100644 --- a/example/lib/sample/components/tag/state_tag_example.dart +++ b/example/lib/sample/components/tag/state_tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/tag_example.dart b/example/lib/sample/components/tag/tag_example.dart index 60aca84c..f47dba72 100644 --- a/example/lib/sample/components/tag/tag_example.dart +++ b/example/lib/sample/components/tag/tag_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/tag/border_tag_example.dart'; import 'package:example/sample/components/tag/custom_tag_example.dart'; diff --git a/example/lib/sample/components/tag/tag_row_example.dart b/example/lib/sample/components/tag/tag_row_example.dart index ed035494..0148a89a 100644 --- a/example/lib/sample/components/tag/tag_row_example.dart +++ b/example/lib/sample/components/tag/tag_row_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/toast/toast_example.dart b/example/lib/sample/components/toast/toast_example.dart index a2c94304..39c7a348 100644 --- a/example/lib/sample/components/toast/toast_example.dart +++ b/example/lib/sample/components/toast/toast_example.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/home/card_data_config.dart b/example/lib/sample/home/card_data_config.dart index 99e7684f..79ce55e6 100644 --- a/example/lib/sample/home/card_data_config.dart +++ b/example/lib/sample/home/card_data_config.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:convert'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/home/expandable_container_widget.dart b/example/lib/sample/home/expandable_container_widget.dart index 517d15c6..468b4af5 100644 --- a/example/lib/sample/home/expandable_container_widget.dart +++ b/example/lib/sample/home/expandable_container_widget.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart=2.9 + import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/example/lib/sample/home/group_card.dart b/example/lib/sample/home/group_card.dart index 10d5dbf4..ea4bc592 100644 --- a/example/lib/sample/home/group_card.dart +++ b/example/lib/sample/home/group_card.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; import 'package:example/sample/home/card_data_config.dart'; diff --git a/example/lib/sample/home/home.dart b/example/lib/sample/home/home.dart index 9b3abc45..179aa98d 100644 --- a/example/lib/sample/home/home.dart +++ b/example/lib/sample/home/home.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/card_data_config.dart'; import 'package:example/sample/home/group_card.dart'; diff --git a/example/lib/sample/home/list_item.dart b/example/lib/sample/home/list_item.dart index 616f1729..70ad5974 100644 --- a/example/lib/sample/home/list_item.dart +++ b/example/lib/sample/home/list_item.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/theme/config_test_utils.dart b/example/lib/sample/theme/config_test_utils.dart index 0d741da6..8a0d7feb 100644 --- a/example/lib/sample/theme/config_test_utils.dart +++ b/example/lib/sample/theme/config_test_utils.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:ui'; import 'package:bruno/bruno.dart'; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ac490489..ffb77c08 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: @@ -35,7 +35,7 @@ dev_dependencies: sdk: flutter dependency_overrides: - intl: 0.16.0 + intl: ^0.17.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart b/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart index 73bc76d1..d2c7bf0e 100644 --- a/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart +++ b/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart @@ -513,7 +513,7 @@ class _BrnActionSheetSelectedItemListState padding: const EdgeInsets.only( left: 5, right: 20), child: BrunoTools.getAssetImage( - BrnAsset.ICON_TRASH_BIN)), + BrnAsset.iconTrashBin)), ), ), ], diff --git a/lib/src/components/actionsheet/brn_share_action_sheet.dart b/lib/src/components/actionsheet/brn_share_action_sheet.dart index 6795d509..bf18f5f9 100644 --- a/lib/src/components/actionsheet/brn_share_action_sheet.dart +++ b/lib/src/components/actionsheet/brn_share_action_sheet.dart @@ -119,11 +119,11 @@ class BrnShareActionSheet extends StatelessWidget { channel = secondShareChannels[index]; } // 判断是否为自定义标题 - title = (channel.shareType == BrnShareItemConstants.SHARE_CUSTOM) + title = (channel.shareType == BrnShareItemConstants.shareCustom) ? (channel.customTitle ?? "") : BrnShareItemConstants.shareItemTitleList[channel.shareType]; // 判断是否为自定义,如果不是自定义图标,则判断是否可点击(决定是否使用置灰图标) - image = (channel.shareType == BrnShareItemConstants.SHARE_CUSTOM) + image = (channel.shareType == BrnShareItemConstants.shareCustom) ? channel.customImage : (channel.canClick ? BrunoTools.getAssetImage( diff --git a/lib/src/components/appraise/brn_appraise_emoji_list_view.dart b/lib/src/components/appraise/brn_appraise_emoji_list_view.dart index 7881a723..5ac4e945 100644 --- a/lib/src/components/appraise/brn_appraise_emoji_list_view.dart +++ b/lib/src/components/appraise/brn_appraise_emoji_list_view.dart @@ -36,29 +36,29 @@ class BrnAppraiseEmojiListView extends StatefulWidget { class _BrnAppraiseEmojiListViewState extends State { /// 未选中表情,灰色 List _unselectedIcons = [ - BrnAsset.ICON_APPRAISE_BAD_UNSELECTED, - BrnAsset.ICON_APPRAISE_NOT_GOOD_UNSELECTED, - BrnAsset.ICON_APPRAISE_OK_UNSELECTED, - BrnAsset.ICON_APPRAISE_GOOD_UNSELECTED, - BrnAsset.ICON_APPRAISE_SURPRISE_UNSELECTED, + BrnAsset.iconAppraiseBadUnselected, + BrnAsset.iconAppraiseNotGoodUnselected, + BrnAsset.iconAppraiseOkUnselected, + BrnAsset.iconAppraiseGoodUnselected, + BrnAsset.iconAppraiseSurpriseUnselected, ]; /// 默认表情,黄色 List _defaultIcons = [ - BrnAsset.ICON_APPRAISE_BAD_DEFAULT, - BrnAsset.ICON_APPRAISE_NOT_GOOD_DEFAULT, - BrnAsset.ICON_APPRAISE_OK_DEFAULT, - BrnAsset.ICON_APPRAISE_GOOD_DEFAULT, - BrnAsset.ICON_APPRAISE_SURPRISE_DEFAULT, + BrnAsset.iconAppraiseBadDefault, + BrnAsset.iconAppraiseNotGoodDefault, + BrnAsset.iconAppraiseOkDefault, + BrnAsset.iconAppraiseGoodDefault, + BrnAsset.iconAppraiseSurpriseDefault, ]; /// 选中表情,gif List _selectedIcons = [ - BrnAsset.ICON_APPRAISE_BAD_SELECTED, - BrnAsset.ICON_APPRAISE_NOT_GOOD_SELECTED, - BrnAsset.ICON_APPRAISE_OK_SELECTED, - BrnAsset.ICON_APPRAISE_GOOD_SELECTED, - BrnAsset.ICON_APPRAISE_SURPRISE_SELECTED, + BrnAsset.iconAppraiseBadSelected, + BrnAsset.iconAppraiseNotGoodSelected, + BrnAsset.iconAppraiseOkSelected, + BrnAsset.iconAppraiseGoodSelected, + BrnAsset.iconAppraiseSurpriseSelected, ]; int _selectedIndex = -1; diff --git a/lib/src/components/appraise/brn_appraise_header.dart b/lib/src/components/appraise/brn_appraise_header.dart index c0263f32..972a2f8b 100644 --- a/lib/src/components/appraise/brn_appraise_header.dart +++ b/lib/src/components/appraise/brn_appraise_header.dart @@ -102,7 +102,7 @@ class BrnAppraiseHeader extends StatelessWidget { } Navigator.of(context).pop(); }, - child: BrunoTools.getAssetImage(BrnAsset.ICON_PICKER_CLOSE), + child: BrunoTools.getAssetImage(BrnAsset.iconPickerClose), ), ], ), diff --git a/lib/src/components/button/collection/brn_multiple_bottom_button.dart b/lib/src/components/button/collection/brn_multiple_bottom_button.dart index 2a71ba67..fd5164d4 100644 --- a/lib/src/components/button/collection/brn_multiple_bottom_button.dart +++ b/lib/src/components/button/collection/brn_multiple_bottom_button.dart @@ -142,14 +142,14 @@ class _BrnMultipleBottomButtonState extends State { Widget _selectedCountWidget() { Image unfoldWidget = BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_SELECTED_UP_TRIANGLE, + BrnAsset.iconSelectedUpTriangle, BrnThemeConfigurator.instance.getConfig().commonConfig.brandPrimary); Image foldWidget = - BrunoTools.getAssetImage(BrnAsset.ICON_UNSELECT_DOWN_TRIANGLE); + BrunoTools.getAssetImage(BrnAsset.iconUnSelectDownTriangle); Image cantFoldWidget = BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_UNSELECT_DOWN_TRIANGLE, Color(0XCCCCCCCC)); + BrnAsset.iconUnSelectDownTriangle, Color(0XCCCCCCCC)); return GestureDetector( onTap: () { diff --git a/lib/src/components/button/collection/brn_text_button_panel.dart b/lib/src/components/button/collection/brn_text_button_panel.dart index 5110dd21..5b7c96d5 100644 --- a/lib/src/components/button/collection/brn_text_button_panel.dart +++ b/lib/src/components/button/collection/brn_text_button_panel.dart @@ -155,8 +155,8 @@ class _BrnTextButtonPanelState extends State { ); Widget imageWidget = _isExpanded - ? BrunoTools.getAssetImage(BrnAsset.ICON_UP_ARROW) - : BrunoTools.getAssetImage(BrnAsset.ICON_DOWN_ARROW); + ? BrunoTools.getAssetImage(BrnAsset.iconUpArrow) + : BrunoTools.getAssetImage(BrnAsset.iconDownArrow); return GestureDetector( child: Row( diff --git a/lib/src/components/calendar/brn_calendar_view.dart b/lib/src/components/calendar/brn_calendar_view.dart index 20229323..8f8427a4 100644 --- a/lib/src/components/calendar/brn_calendar_view.dart +++ b/lib/src/components/calendar/brn_calendar_view.dart @@ -177,9 +177,9 @@ class _CustomCalendarViewState extends State { color: Colors.transparent, padding: EdgeInsets.only(left: 15), child: isPreIconEnable - ? BrunoTools.getAssetImage(BrnAsset.ICON_CALENDAR_PRE_MONTH) + ? BrunoTools.getAssetImage(BrnAsset.iconCalendarPreMonth) : BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_CALENDAR_PRE_MONTH, Color(0xFFCCCCCC)), + BrnAsset.iconCalendarPreMonth, Color(0xFFCCCCCC)), alignment: Alignment.center, ), ), @@ -218,9 +218,9 @@ class _CustomCalendarViewState extends State { padding: EdgeInsets.only(right: 15), child: isNextIconEnable ? BrunoTools.getAssetImage( - BrnAsset.ICON_CALENDAR_NEXT_MONTH) + BrnAsset.iconCalendarNextMonth) : BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_CALENDAR_NEXT_MONTH, Color(0xFFCCCCCC)), + BrnAsset.iconCalendarNextMonth, Color(0xFFCCCCCC)), alignment: Alignment.center, ), ) diff --git a/lib/src/components/card/content_card/brn_enhance_number_card.dart b/lib/src/components/card/content_card/brn_enhance_number_card.dart index 6fa74843..34259e21 100644 --- a/lib/src/components/card/content_card/brn_enhance_number_card.dart +++ b/lib/src/components/card/content_card/brn_enhance_number_card.dart @@ -248,10 +248,10 @@ class BrnEnhanceNumberCard extends StatelessWidget { ); if (model.iconTapCallBack != null) { Widget icon = - BrunoTools.getAssetSizeImage(BrnAsset.ICON_QUESTION, 14, 14); + BrunoTools.getAssetSizeImage(BrnAsset.iconQuestion, 14, 14); if (model.numberInfoIcon == BrnNumberInfoIcon.ARROW) { - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_RIGHT_ARROW, 14, 14); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 14, 14); } debugPrint('${tp.height}'); debugPrint(model.title); diff --git a/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart b/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart index 11a7dc11..1704695f 100644 --- a/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart +++ b/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart @@ -239,7 +239,7 @@ class BrnRichGridInfo { child: Padding( padding: EdgeInsets.only(left: isKey ? 0 : 4), child: BrunoTools.getAssetSizeImage( - BrnAsset.ICON_PAIR_INFO_QUESTION, 14, 14), + BrnAsset.iconPairInfoQuestion, 14, 14), )); } diff --git a/lib/src/components/card/content_card/brn_pair_info_table.dart b/lib/src/components/card/content_card/brn_pair_info_table.dart index e5000e9a..16c74d7f 100644 --- a/lib/src/components/card/content_card/brn_pair_info_table.dart +++ b/lib/src/components/card/content_card/brn_pair_info_table.dart @@ -236,7 +236,7 @@ class _BrnPairInfoTableState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(child: valueWidget), - BrunoTools.getAssetImage(BrnAsset.ICON_RIGHT_ARROW), + BrunoTools.getAssetImage(BrnAsset.iconRightArrow), ], ); } @@ -271,7 +271,7 @@ class _BrnPairInfoTableState extends State { } BrnInfoModal _foldButtonWidget() { - Image img = BrunoTools.getAssetImage('icons/icon_uparrow.png'); + Image img = BrunoTools.getAssetImage(BrnAsset.iconUpArrow); Transform trsm = Transform.rotate(angle: pi, child: img); Row row = Row( children: [ @@ -330,7 +330,7 @@ class _BrnPairInfoTableState extends State { } BrnInfoModal _expandedButtonWidget() { - Image img = BrunoTools.getAssetImage('icons/icon_uparrow.png'); + Image img = BrunoTools.getAssetImage(BrnAsset.iconUpArrow); Row row = Row( children: [ Padding( @@ -473,7 +473,7 @@ mixin PairInfoPart { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(child: valueWidget), - BrunoTools.getAssetImage(BrnAsset.ICON_RIGHT_ARROW), + BrunoTools.getAssetImage(BrnAsset.iconRightArrow), ], ); } @@ -874,7 +874,7 @@ class BrnInfoModal { keyCallback(); } }, - child: BrunoTools.getAssetImage(BrnAsset.ICON_QUESTION), + child: BrunoTools.getAssetImage(BrnAsset.iconQuestion), ), Text( ':', @@ -907,7 +907,7 @@ class BrnInfoModal { valueCallback(); } }, - child: BrunoTools.getAssetImage(BrnAsset.ICON_QUESTION), + child: BrunoTools.getAssetImage(BrnAsset.iconQuestion), ) ], ); @@ -925,7 +925,7 @@ class BrnInfoModal { keyCallback(); } }, - child: BrunoTools.getAssetImage(BrnAsset.ICON_QUESTION), + child: BrunoTools.getAssetImage(BrnAsset.iconQuestion), )); keyGen.addText(':', textStyle: themeData.keyTextStyle?.generateTextStyle()); @@ -942,7 +942,7 @@ class BrnInfoModal { valueCallback(); } }, - child: BrunoTools.getAssetImage(BrnAsset.ICON_QUESTION), + child: BrunoTools.getAssetImage(BrnAsset.iconQuestion), )); } valueWidget = valueGen.build(); diff --git a/lib/src/components/card_title/brn_action_card_title.dart b/lib/src/components/card_title/brn_action_card_title.dart index 49c54dcd..5ab94b37 100644 --- a/lib/src/components/card_title/brn_action_card_title.dart +++ b/lib/src/components/card_title/brn_action_card_title.dart @@ -142,7 +142,7 @@ class BrnActionCardTitle extends StatelessWidget { } Widget _arrowWidget() { - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_RIGHT_ARROW, 16, 16); + return BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16); } Widget _accessoryTextWidget(BrnCardTitleConfig defaultConfig) { diff --git a/lib/src/components/dialog/brn_content_export_dialog.dart b/lib/src/components/dialog/brn_content_export_dialog.dart index 2c8b96b5..87fd5598 100644 --- a/lib/src/components/dialog/brn_content_export_dialog.dart +++ b/lib/src/components/dialog/brn_content_export_dialog.dart @@ -102,7 +102,7 @@ class BrnContentExportWidget extends StatelessWidget { behavior: HitTestBehavior.opaque, child: Padding( padding: EdgeInsets.all(15), - child: BrunoTools.getAssetImage(BrnAsset.ICON_PICKER_CLOSE), + child: BrunoTools.getAssetImage(BrnAsset.iconPickerClose), ))); } return Container(); diff --git a/lib/src/components/dialog/brn_share_dialog.dart b/lib/src/components/dialog/brn_share_dialog.dart index 05bf2196..954aa737 100644 --- a/lib/src/components/dialog/brn_share_dialog.dart +++ b/lib/src/components/dialog/brn_share_dialog.dart @@ -159,7 +159,7 @@ class BrnShareDialog extends StatelessWidget { child: Container( width: 30, height: 30, - child: BrunoTools.getAssetImage(BrnAsset.ICON_PICKER_CLOSE), + child: BrunoTools.getAssetImage(BrnAsset.iconPickerClose), ), onTap: () { Navigator.of(context).pop(); @@ -203,7 +203,7 @@ class BrnShareDialog extends StatelessWidget { for (int index = 0; index < shareChannels.length; index++) { title = null; image = null; - if (shareChannels[index] == BrnShareItemConstants.SHARE_CUSTOM) { + if (shareChannels[index] == BrnShareItemConstants.shareCustom) { // 获取自定义channel信息 title = getCustomChannelTitle(index); image = getCustomChannelWidget(index); diff --git a/lib/src/components/dialog/brn_single_select.dart b/lib/src/components/dialog/brn_single_select.dart index 959fb696..6a2bafe2 100644 --- a/lib/src/components/dialog/brn_single_select.dart +++ b/lib/src/components/dialog/brn_single_select.dart @@ -244,7 +244,7 @@ class BrnSingleSelectDialogWidgetState child: Padding( padding: EdgeInsets.all(15), child: BrunoTools.getAssetImage( - BrnAsset.ICON_PICKER_CLOSE), + BrnAsset.iconPickerClose), ))) : Container() ], diff --git a/lib/src/components/form/items/general/brn_quick_select_input_item.dart b/lib/src/components/form/items/general/brn_quick_select_input_item.dart index e200ba5b..8bf54770 100644 --- a/lib/src/components/form/items/general/brn_quick_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_quick_select_input_item.dart @@ -346,7 +346,7 @@ class QuickButtonsState extends State { child: Text( str, style: TextStyle( - fontSize: BrnFonts.FONT_12, + fontSize: BrnFonts.f12, ), ), onPressed: () { diff --git a/lib/src/components/form/items/general/brn_range_input_item.dart b/lib/src/components/form/items/general/brn_range_input_item.dart index eb7fda17..cf7f98eb 100644 --- a/lib/src/components/form/items/general/brn_range_input_item.dart +++ b/lib/src/components/form/items/general/brn_range_input_item.dart @@ -233,7 +233,7 @@ class BrnRangeInputFormItemState extends State { widget.minUnit ?? "", style: TextStyle( color: Color(0xFF101010), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), )), Container( @@ -242,7 +242,7 @@ class BrnRangeInputFormItemState extends State { "—", style: TextStyle( color: Color(0xFF101010), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), )), Container( @@ -288,7 +288,7 @@ class BrnRangeInputFormItemState extends State { widget.maxUnit ?? "", style: TextStyle( color: Color(0xFF101010), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), )), ], diff --git a/lib/src/components/form/items/general/brn_star_input_item.dart b/lib/src/components/form/items/general/brn_star_input_item.dart index 32223668..e8ade984 100644 --- a/lib/src/components/form/items/general/brn_star_input_item.dart +++ b/lib/src/components/form/items/general/brn_star_input_item.dart @@ -193,13 +193,13 @@ class BrnStarsFormItemState extends State { Image getStar(int index, int selectCount, int sum) { if (selectCount <= 0) { - return BrunoTools.getAssetImage(BrnAsset.ICON_STAR_UNSELECT); + return BrunoTools.getAssetImage(BrnAsset.iconStarUnSelect); } if (index < selectCount) { - return BrunoTools.getAssetImage(BrnAsset.ICON_STAR_SELECT); + return BrunoTools.getAssetImage(BrnAsset.iconStarSelect); } - return BrunoTools.getAssetImage(BrnAsset.ICON_STAR_UNSELECT); + return BrunoTools.getAssetImage(BrnAsset.iconStarUnSelect); } } diff --git a/lib/src/components/form/items/general/brn_step_input_item.dart b/lib/src/components/form/items/general/brn_step_input_item.dart index 248a6385..ac081f2a 100644 --- a/lib/src/components/form/items/general/brn_step_input_item.dart +++ b/lib/src/components/form/items/general/brn_step_input_item.dart @@ -179,7 +179,7 @@ class BrnStepInputFormItemState extends State { "${widget.value}", style: TextStyle( color: Color(0xFF222222), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), ), ), @@ -237,14 +237,14 @@ class BrnStepInputFormItemState extends State { Image getAddIcon() { if (widget.isEdit != null && !widget.isEdit) { - return BrunoTools.getAssetImage(BrnAsset.ICON_ADD_DISABLE); + return BrunoTools.getAssetImage(BrnAsset.iconAddDisable); } if (isReachMaxLevel()) { - return BrunoTools.getAssetImage(BrnAsset.ICON_ADD_DISABLE); + return BrunoTools.getAssetImage(BrnAsset.iconAddDisable); } - return BrunoTools.getAssetImage(BrnAsset.ICON_ADD_ENABLE); + return BrunoTools.getAssetImage(BrnAsset.iconAddEnable); } bool isReachMaxLevel() { @@ -263,14 +263,14 @@ class BrnStepInputFormItemState extends State { Image getMinusIcon() { if (widget.isEdit != null && !widget.isEdit) { - return BrunoTools.getAssetImage(BrnAsset.ICON_MINUS_DISABLE); + return BrunoTools.getAssetImage(BrnAsset.iconMinusDisable); } if (isReachMinLevel()) { - return BrunoTools.getAssetImage(BrnAsset.ICON_MINUS_DISABLE); + return BrunoTools.getAssetImage(BrnAsset.iconMinusDisable); } - return BrunoTools.getAssetImage(BrnAsset.ICON_MINUS_ENABLE); + return BrunoTools.getAssetImage(BrnAsset.iconMinusEnable); } bool isReachMinLevel() { diff --git a/lib/src/components/form/items/general/brn_text_input_item.dart b/lib/src/components/form/items/general/brn_text_input_item.dart index fa52c00c..79559c7b 100644 --- a/lib/src/components/form/items/general/brn_text_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_input_item.dart @@ -211,7 +211,7 @@ class BrnTextInputFormItemState extends State { widget.unit ?? "", style: TextStyle( color: Color(0xFF101010), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), )), ), diff --git a/lib/src/components/form/items/general/brn_text_select_item.dart b/lib/src/components/form/items/general/brn_text_select_item.dart index 22e7490e..ed520208 100644 --- a/lib/src/components/form/items/general/brn_text_select_item.dart +++ b/lib/src/components/form/items/general/brn_text_select_item.dart @@ -149,7 +149,7 @@ class BrnTextSelectFormItem extends StatefulWidget { } } -double _fontSize = BrnFonts.FONT_16; +double _fontSize = BrnFonts.f16; StrutStyle _contentStructStyle = StrutStyle( forceStrutHeight: true, height: 1, leading: 0.5, fontSize: _fontSize); @@ -291,7 +291,7 @@ class BrnTextSelectFormItemState extends State { forceStrutHeight: true, height: 1, leading: 0.5, - fontSize: BrnFonts.FONT_14), + fontSize: BrnFonts.f14), style: BrnFormUtil.getTipsTextStyle(widget.themeData), ), ), diff --git a/lib/src/components/form/items/general/brn_title_select_input_item.dart b/lib/src/components/form/items/general/brn_title_select_input_item.dart index 03479b54..90193d38 100644 --- a/lib/src/components/form/items/general/brn_title_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_title_select_input_item.dart @@ -275,8 +275,8 @@ class BrnTitleSelectInputFormItemState builder: (BuildContext context, AsyncSnapshot snapshot) { return snapshot.data ? BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_SELECTED_UP_TRIANGLE) - : BrunoTools.getAssetImage(BrnAsset.ICON_UNSELECT_DOWN_TRIANGLE); + BrnAsset.iconSelectedUpTriangle) + : BrunoTools.getAssetImage(BrnAsset.iconUnSelectDownTriangle); }, ), ); @@ -298,7 +298,7 @@ class BrnTitleSelectInputFormItemState border: InputBorder.none, hintStyle: TextStyle( color: Color(0xFFCCCCCC), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, textBaseline: TextBaseline.alphabetic), hintText: widget.hint ?? '请输入', counterText: "", diff --git a/lib/src/components/form/items/group/brn_normal_group.dart b/lib/src/components/form/items/group/brn_normal_group.dart index f7cee515..73c7584f 100644 --- a/lib/src/components/form/items/group/brn_normal_group.dart +++ b/lib/src/components/form/items/group/brn_normal_group.dart @@ -136,7 +136,7 @@ class BrnNormalFormGroupState extends State { widget.deleteLabel ?? "", style: TextStyle( color: Color(0xFFFA3F3F), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), ), ), diff --git a/lib/src/components/form/items/group/element_expand_widget.dart b/lib/src/components/form/items/group/element_expand_widget.dart index 0f1fb5e7..887f6c33 100644 --- a/lib/src/components/form/items/group/element_expand_widget.dart +++ b/lib/src/components/form/items/group/element_expand_widget.dart @@ -227,7 +227,7 @@ class _ExpansionElementState extends State widget.deleteText ?? "", style: TextStyle( color: Color(0xFFFA3F3F), - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), ), ), diff --git a/lib/src/components/form/items/misc/brn_add_label_item.dart b/lib/src/components/form/items/misc/brn_add_label_item.dart index 500c8cb0..645fbb66 100644 --- a/lib/src/components/form/items/misc/brn_add_label_item.dart +++ b/lib/src/components/form/items/misc/brn_add_label_item.dart @@ -59,7 +59,7 @@ class BrnAddLabelState extends State { .getConfig() .commonConfig .brandPrimary, - fontSize: BrnFonts.FONT_18, + fontSize: BrnFonts.f18, ), ), ), diff --git a/lib/src/components/form/items/misc/brn_title_item.dart b/lib/src/components/form/items/misc/brn_title_item.dart index 2ae42450..a9451a14 100644 --- a/lib/src/components/form/items/misc/brn_title_item.dart +++ b/lib/src/components/form/items/misc/brn_title_item.dart @@ -135,7 +135,7 @@ class BrnTitleFormItemState extends State { widget.operationLabel ?? "", style: TextStyle( color: widget.themeData.commonConfig.brandPrimary, - fontSize: BrnFonts.FONT_16, + fontSize: BrnFonts.f16, ), )), ), diff --git a/lib/src/components/form/undetermined/brn_expandable_group.dart b/lib/src/components/form/undetermined/brn_expandable_group.dart index eb05a0fa..1db00a64 100644 --- a/lib/src/components/form/undetermined/brn_expandable_group.dart +++ b/lib/src/components/form/undetermined/brn_expandable_group.dart @@ -129,9 +129,9 @@ class _BrnExpansionElementState extends State if (_isExpanded) { arrowIcon = - BrunoTools.getAssetSizeImage(BrnAsset.ICON_DOWN_ARROW, 12, 12); + BrunoTools.getAssetSizeImage(BrnAsset.iconDownArrow, 12, 12); } else { - arrowIcon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_UP_ARROW, 12, 12); + arrowIcon = BrunoTools.getAssetSizeImage(BrnAsset.iconUpArrow, 12, 12); } } diff --git a/lib/src/components/form/utils/brn_form_util.dart b/lib/src/components/form/utils/brn_form_util.dart index 1dd28e05..78ddb05a 100644 --- a/lib/src/components/form/utils/brn_form_util.dart +++ b/lib/src/components/form/utils/brn_form_util.dart @@ -117,9 +117,9 @@ class BrnFormUtil { static Widget getPrefixIcon(String type) { if (type == BrnPrefixIconType.TYPE_ADD) { - return BrunoTools.getAssetImageWithBandColor(BrnAsset.ICON_ADD_FORM_ITEM); + return BrunoTools.getAssetImageWithBandColor(BrnAsset.iconAddFormItem); } else if (type == BrnPrefixIconType.TYPE_REMOVE) { - return BrunoTools.getAssetImage(BrnAsset.ICON_REMOVE_FORM_ITEM); + return BrunoTools.getAssetImage(BrnAsset.iconRemoveFormItem); } else { return Container(); } @@ -146,7 +146,7 @@ class BrnFormUtil { padding: isRequire ? EdgeInsets.only(right: 2) : EdgeInsets.only(right: 0), child: isRequire - ? BrunoTools.getAssetSizeImage(BrnAsset.ICON_REQUIRE_RED, 8, 8, + ? BrunoTools.getAssetSizeImage(BrnAsset.iconRequireRed, 8, 8, color: Color(0xFFFA3F3F)) : null, ); @@ -155,11 +155,11 @@ class BrnFormUtil { /// 视觉同学要求修改右箭头图标 static Image getRightArrowIcon() { return BrunoTools.getAssetSizeImage( - BrnAsset.ICON_RIGHT_ARROW, rightArrowSize, rightArrowSize); + BrnAsset.iconRightArrow, rightArrowSize, rightArrowSize); } static Image getQuestionMarkIcon() { - return BrunoTools.getAssetImage(BrnAsset.ICON_QUESTION); + return BrunoTools.getAssetImage(BrnAsset.iconQuestion); } /// 设置录入项总的padding, 不包括顶部和底部padding diff --git a/lib/src/components/gallery/config/brn_bottom_card.dart b/lib/src/components/gallery/config/brn_bottom_card.dart index 3e2dc624..8d6f0ebd 100644 --- a/lib/src/components/gallery/config/brn_bottom_card.dart +++ b/lib/src/components/gallery/config/brn_bottom_card.dart @@ -83,7 +83,7 @@ class _BrnPhotoBottomCardState extends State Transform.rotate( angle: pi, child: BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_UPARROW, widget.themeData.iconColor), + BrnAsset.iconUpArrow, widget.themeData.iconColor), ) ], ), @@ -119,7 +119,7 @@ class _BrnPhotoBottomCardState extends State ?.generateTextStyle()), ), BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_UPARROW, widget.themeData.iconColor) + BrnAsset.iconUpArrow, widget.themeData.iconColor) ], ), ) diff --git a/lib/src/components/guide/brn_tip_widget.dart b/lib/src/components/guide/brn_tip_widget.dart index b5b66a7b..94c42557 100644 --- a/lib/src/components/guide/brn_tip_widget.dart +++ b/lib/src/components/guide/brn_tip_widget.dart @@ -200,7 +200,7 @@ class BrnTipInfoWidget extends StatelessWidget { onClose(); }, child: BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_CLOSE, Colors.black), + BrnAsset.iconClose, Colors.black), ), ), ], diff --git a/lib/src/components/navbar/brn_search_bar.dart b/lib/src/components/navbar/brn_search_bar.dart index 974cd9b8..4efe58a9 100644 --- a/lib/src/components/navbar/brn_search_bar.dart +++ b/lib/src/components/navbar/brn_search_bar.dart @@ -270,7 +270,7 @@ class __SearchInputWidgetState extends State<_SearchInputWidget> { Padding( padding: EdgeInsets.only(right: 8.0), child: - BrunoTools.getAssetSizeImage(BrnAsset.ICON_SEARCH, 16, 16), + BrunoTools.getAssetSizeImage(BrnAsset.iconSearch, 16, 16), ), Expanded( child: TextField( @@ -343,7 +343,7 @@ class __SearchInputWidgetState extends State<_SearchInputWidget> { right: valueNotifier.value ? 24 : 20, left: valueNotifier.value ? 24 : 20), child: Image.asset( - 'assets/${BrnAsset.ICON_DELETE_TEXT}', + 'assets/${BrnAsset.iconDeleteText}', color: _defaultClearIconColor, scale: 3.0, height: 16, diff --git a/lib/src/components/noticebar/brn_notice_bar.dart b/lib/src/components/noticebar/brn_notice_bar.dart index c8ad8fbe..1ba2dc20 100644 --- a/lib/src/components/noticebar/brn_notice_bar.dart +++ b/lib/src/components/noticebar/brn_notice_bar.dart @@ -154,73 +154,73 @@ class BrnNoticeBar extends StatelessWidget { class NoticeStyles { ///红色+失败+箭头 static NoticeStyle failWithArrow = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_FAIL), + BrunoTools.getAssetImage(BrnAsset.iconNoticeFail), Color(0xFFFA3F3F), Color(0xFFFEEDED), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_ARROW_RED)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeArrowRed)); ///红色+失败+关闭 static NoticeStyle failWithClose = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_FAIL), + BrunoTools.getAssetImage(BrnAsset.iconNoticeFail), Color(0xFFFA3F3F), Color(0xFFFEEDED), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_CLOSE_RED)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeCloseRed)); ///蓝色+进行中+箭头 static NoticeStyle runningWithArrow = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_RUNNING), + BrunoTools.getAssetImage(BrnAsset.iconNoticeRunning), Color(0xFF0984F9), Color(0xFFE0EDFF), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_ARROW_BLUE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeArrowBlue)); ///蓝色+进行中+关闭 static NoticeStyle runningWithClose = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_RUNNING), + BrunoTools.getAssetImage(BrnAsset.iconNoticeRunning), Color(0xFF0984F9), Color(0xFFE0EDFF), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_CLOSE_BLUE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeCloseBlue)); ///绿色+完成+箭头 static NoticeStyle succeedWithArrow = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_SUCCEED), + BrunoTools.getAssetImage(BrnAsset.iconNoticeSucceed), Color(0xFF00AE66), Color(0xFFEBFFF7), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_ARROW_GREEN)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeArrowGreen)); ///绿色+完成+关闭 static NoticeStyle succeedWithClose = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_SUCCEED), + BrunoTools.getAssetImage(BrnAsset.iconNoticeSucceed), Color(0xFF00AE66), Color(0xFFEBFFF7), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_CLOSE_GREEN)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeCloseGreen)); ///橘色+警告+箭头 static NoticeStyle warningWithArrow = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_WARNING), + BrunoTools.getAssetImage(BrnAsset.iconNoticeWarning), Color(0xFFFAAD14), Color(0xFFFDFCEC), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_ARROW_ORANGE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeArrowOrange)); ///橘色+警告+关闭 static NoticeStyle warningWithClose = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_WARNING), + BrunoTools.getAssetImage(BrnAsset.iconNoticeWarning), Color(0xFFFAAD14), Color(0xFFFDFCEC), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_CLOSE_ORANGE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeCloseOrange)); ///橘色+通知+箭头 static NoticeStyle normalNoticeWithArrow = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE), + BrunoTools.getAssetImage(BrnAsset.iconNotice), Color(0xFFFAAD14), Color(0xFFFDFCEC), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_ARROW_ORANGE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeArrowOrange)); ///橘色+通知+关闭 static NoticeStyle normalNoticeWithClose = NoticeStyle( - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE), + BrunoTools.getAssetImage(BrnAsset.iconNotice), Color(0xFFFAAD14), Color(0xFFFDFCEC), - BrunoTools.getAssetImage(BrnAsset.ICON_NOTICE_CLOSE_ORANGE)); + BrunoTools.getAssetImage(BrnAsset.iconNoticeCloseOrange)); } /// 通知样式 diff --git a/lib/src/components/picker/brn_select_tags_with_input_picker.dart b/lib/src/components/picker/brn_select_tags_with_input_picker.dart index 3fe88715..7c21e2f0 100644 --- a/lib/src/components/picker/brn_select_tags_with_input_picker.dart +++ b/lib/src/components/picker/brn_select_tags_with_input_picker.dart @@ -265,7 +265,7 @@ class _BrnSelectTagsWithInputPickerWidgetState }, child: Padding( padding: EdgeInsets.all(4), - child: BrunoTools.getAssetImage(BrnAsset.ICON_PICKER_CLOSE), + child: BrunoTools.getAssetImage(BrnAsset.iconPickerClose), )) ], ), diff --git a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart index 89c42137..81b95621 100644 --- a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart +++ b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart @@ -47,7 +47,7 @@ class BrnPickerEntity { /// 默认支持最大选中个数为 65535 this.maxSelectedCount = - maxSelectedCount ?? BrnSelectionConstant.MAX_SELECT_COUNT; + maxSelectedCount ?? BrnSelectionConstant.maxSelectCount; } static BrnPickerEntity fromMap(Map map) { @@ -65,7 +65,7 @@ class BrnPickerEntity { int.tryParse(map['maxSelectedCount']) != null) { entity.maxSelectedCount = int.tryParse(map['maxSelectedCount']); } else { - entity.maxSelectedCount = BrnSelectionConstant.MAX_SELECT_COUNT; + entity.maxSelectedCount = BrnSelectionConstant.maxSelectCount; } entity.extMap = map['ext'] ?? {}; // entity.children = map['children'] ?? []; diff --git a/lib/src/components/popup/brn_popup_window.dart b/lib/src/components/popup/brn_popup_window.dart index 67691420..95e41d38 100644 --- a/lib/src/components/popup/brn_popup_window.dart +++ b/lib/src/components/popup/brn_popup_window.dart @@ -326,7 +326,7 @@ class _BrnPopupWindowState extends State { child: Padding( padding: EdgeInsets.only(left: 6), child: BrunoTools.getAssetImage( - BrnAsset.ICON_POPUP_CLOSE), + BrnAsset.iconPopupClose), )) : TextSpan(text: "") ])) @@ -346,7 +346,7 @@ class _BrnPopupWindowState extends State { ? Padding( padding: EdgeInsets.only(left: 6), child: BrunoTools.getAssetImage( - BrnAsset.ICON_POPUP_CLOSE), + BrnAsset.iconPopupClose), ) : Text("") ], diff --git a/lib/src/components/radio/brn_checkbox.dart b/lib/src/components/radio/brn_checkbox.dart index 00762859..5efaf772 100644 --- a/lib/src/components/radio/brn_checkbox.dart +++ b/lib/src/components/radio/brn_checkbox.dart @@ -81,12 +81,12 @@ class BrnCheckboxState extends State { mainAxisAlignment: widget.mainAxisAlignment, mainAxisSize: widget.mainAxisSize, selectedImage: BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_RADIO_MULTI_SELECTED), - unselectedImage: BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_UNSELECTED), + BrnAsset.iconRadioMultiSelected), + unselectedImage: BrunoTools.getAssetImage(BrnAsset.iconRadioUnSelected), disSelectedImage: - BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_DISABLE_SINGLE_SELECTED), + BrunoTools.getAssetImage(BrnAsset.iconRadioDisableSingleSelected), disUnselectedImage: - BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_DISABLE_UNSELECTED), + BrunoTools.getAssetImage(BrnAsset.iconRadioDisableUnselected), child: widget.child, onRadioItemClick: () { setState(() { diff --git a/lib/src/components/radio/brn_radio_button.dart b/lib/src/components/radio/brn_radio_button.dart index bfcb9e28..93c3217b 100644 --- a/lib/src/components/radio/brn_radio_button.dart +++ b/lib/src/components/radio/brn_radio_button.dart @@ -66,12 +66,12 @@ class BrnRadioButton extends StatelessWidget { mainAxisAlignment: mainAxisAlignment, mainAxisSize: mainAxisSize, selectedImage: BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_RADIO_SINGLE_SELECTED), - unselectedImage: BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_UNSELECTED), + BrnAsset.iconRadioSingleSelected), + unselectedImage: BrunoTools.getAssetImage(BrnAsset.iconRadioUnSelected), disSelectedImage: - BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_DISABLE_MULTI_SELECTED), + BrunoTools.getAssetImage(BrnAsset.iconRadioDisableMultiSelected), disUnselectedImage: - BrunoTools.getAssetImage(BrnAsset.ICON_RADIO_DISABLE_UNSELECTED), + BrunoTools.getAssetImage(BrnAsset.iconRadioDisableUnselected), child: child, onRadioItemClick: () { onValueChangedAtIndex(radioIndex, true); diff --git a/lib/src/components/rating/brn_rating_star.dart b/lib/src/components/rating/brn_rating_star.dart index fb48e128..dbb0bec1 100644 --- a/lib/src/components/rating/brn_rating_star.dart +++ b/lib/src/components/rating/brn_rating_star.dart @@ -132,12 +132,12 @@ class _BrnRatingStarState extends State { Widget _buildRating(RatingState state) { switch (state) { case RatingState.select: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR, 16, 16); + return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, 16, 16); case RatingState.half: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR_HALF, 16, 16); + return BrunoTools.getAssetSizeImage(BrnAsset.iconStarHalf, 16, 16); case RatingState.unselect: default: - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STAR, 16, 16, + return BrunoTools.getAssetSizeImage(BrnAsset.iconStar, 16, 16, color: Color(0xFFF0F0F0)); } } diff --git a/lib/src/components/selectcity/brn_single_select_city_page.dart b/lib/src/components/selectcity/brn_single_select_city_page.dart index a7a13fe6..ba17a40d 100644 --- a/lib/src/components/selectcity/brn_single_select_city_page.dart +++ b/lib/src/components/selectcity/brn_single_select_city_page.dart @@ -168,7 +168,7 @@ class _BrnSingleSelectCityPageState extends State { textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF222222), - fontSize: BrnFonts.FONT_12, + fontSize: BrnFonts.f12, fontWeight: FontWeight.w400, ), ), diff --git a/lib/src/components/selection/bean/brn_selection_common_entity.dart b/lib/src/components/selection/bean/brn_selection_common_entity.dart index 37d4d053..fc56f700 100644 --- a/lib/src/components/selection/bean/brn_selection_common_entity.dart +++ b/lib/src/components/selection/bean/brn_selection_common_entity.dart @@ -136,7 +136,7 @@ class BrnSelectionEntity { /// 默认支持最大选中个数为 65535 this.maxSelectedCount = - maxSelectedCount ?? BrnSelectionConstant.MAX_SELECT_COUNT; + maxSelectedCount ?? BrnSelectionConstant.maxSelectCount; } /// 构造简单筛选数据 @@ -153,7 +153,7 @@ class BrnSelectionEntity { /// 默认支持最大选中个数为 65535 this.maxSelectedCount = - maxSelectedCount ?? BrnSelectionConstant.MAX_SELECT_COUNT; + maxSelectedCount ?? BrnSelectionConstant.maxSelectCount; } BrnSelectionEntity.fromJson(Map map) { @@ -168,7 +168,7 @@ class BrnSelectionEntity { int.tryParse(map['maxSelectedCount']) != null) { maxSelectedCount = int.tryParse(map['maxSelectedCount']); } else { - maxSelectedCount = BrnSelectionConstant.MAX_SELECT_COUNT; + maxSelectedCount = BrnSelectionConstant.maxSelectCount; } extMap = map['ext'] ?? {}; children = List() @@ -192,7 +192,7 @@ class BrnSelectionEntity { int.tryParse(map['maxSelectedCount']) != null) { entity.maxSelectedCount = int.tryParse(map['maxSelectedCount']); } else { - entity.maxSelectedCount = BrnSelectionConstant.MAX_SELECT_COUNT; + entity.maxSelectedCount = BrnSelectionConstant.maxSelectCount; } entity.extMap = map['ext'] ?? {}; entity.children = List() @@ -432,7 +432,7 @@ class BrnSelectionEntity { BrnSelectionEntity getRootEntity(BrnSelectionEntity rootEntity) { if (rootEntity.parent == null || rootEntity.parent.maxSelectedCount == - BrnSelectionConstant.MAX_SELECT_COUNT) { + BrnSelectionConstant.maxSelectCount) { return rootEntity; } else { return getRootEntity(rootEntity.parent); diff --git a/lib/src/components/selection/brn_simple_selection.dart b/lib/src/components/selection/brn_simple_selection.dart index 9268dc6a..627c56c3 100644 --- a/lib/src/components/selection/brn_simple_selection.dart +++ b/lib/src/components/selection/brn_simple_selection.dart @@ -47,7 +47,7 @@ class BrnSimpleSelection extends StatefulWidget { @required this.onSimpleSelectionChanged, this.onMenuItemClick, }) : this.isRadio = true, - this.maxSelectedCount = BrnSelectionConstant.MAX_SELECT_COUNT, + this.maxSelectedCount = BrnSelectionConstant.maxSelectCount, super(key: key); /// 多选构造函数 diff --git a/lib/src/components/selection/widget/brn_flat_selection_item.dart b/lib/src/components/selection/widget/brn_flat_selection_item.dart index 5e5448d3..483c86fb 100644 --- a/lib/src/components/selection/widget/brn_flat_selection_item.dart +++ b/lib/src/components/selection/widget/brn_flat_selection_item.dart @@ -383,7 +383,7 @@ class __MoreArrowState extends State<_MoreArrow> { @override Widget build(BuildContext context) { String asset = - isExpanded ? BrnAsset.ICON_UP_ARROW : BrnAsset.ICON_DOWN_ARROW; + isExpanded ? BrnAsset.iconUpArrow : BrnAsset.iconDownArrow; return GestureDetector( behavior: HitTestBehavior.opaque, @@ -707,7 +707,7 @@ class _FilterLayerTypeWidgetState extends State { Container( height: 16, width: 16, - child: BrunoTools.getAssetImage(BrnAsset.ICON_RIGHT_ARROW), + child: BrunoTools.getAssetImage(BrnAsset.iconRightArrow), ) ], ), diff --git a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart index 3ff717c1..8350209f 100644 --- a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart +++ b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart @@ -441,7 +441,7 @@ class _BrnLayerMoreSelectionPageState extends State height: 16, width: 16, child: tmp.isSelected - ? BrnThemeImg.instance.checkedStatus + ? BrunoTools.getAssetImage(BrnAsset.selectCheckedStatus) : BrunoTools.getAssetImage(BrnAsset.iconUnSelect), ) ], diff --git a/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart b/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart index 22cf01f8..5fdcd784 100644 --- a/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart @@ -56,16 +56,16 @@ class BrnSelectionMenuItemWidget extends StatelessWidget { child: isHighLight ? (active ? BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_ARROWUP_SELECT, + BrnAsset.iconArrowUpSelect, configId: themeData.configId) : BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_ARROWDOWN_SELECT)) + BrnAsset.iconArrowDownSelect)) : (active ? BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_ARROWUP_SELECT, + BrnAsset.iconArrowUpSelect, configId: themeData.configId) : BrunoTools.getAssetImage( - BrnAsset.ICON_ARROWDOWN_UNSELECT))) + BrnAsset.iconArrowDownUnSelect))) ], ), ), diff --git a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart index 024299e5..7ac7f89c 100644 --- a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart @@ -335,7 +335,7 @@ class __MoreArrowState extends State<_MoreArrow> { @override Widget build(BuildContext context) { String asset = - isExpanded ? BrnAsset.ICON_UP_ARROW : BrnAsset.ICON_DOWN_ARROW; + isExpanded ? BrnAsset.iconUpArrow : BrnAsset.iconDownArrow; return GestureDetector( behavior: HitTestBehavior.opaque, @@ -670,7 +670,7 @@ class _FilterLayerTypeWidgetState extends State { Container( height: 16, width: 16, - child: BrunoTools.getAssetImage(BrnAsset.ICON_RIGHT_ARROW), + child: BrunoTools.getAssetImage(BrnAsset.iconRightArrow), ) ], ), diff --git a/lib/src/components/step/brn_horizontal_steps.dart b/lib/src/components/step/brn_horizontal_steps.dart index 500134bf..46c59670 100644 --- a/lib/src/components/step/brn_horizontal_steps.dart +++ b/lib/src/components/step/brn_horizontal_steps.dart @@ -207,19 +207,19 @@ class BrnHorizontalStepsState extends State { Widget icon; switch (index) { case 1: - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_2, 20, 20); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconStep2, 20, 20); break; case 2: - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_3, 20, 20); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconStep3, 20, 20); break; case 3: - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_4, 20, 20); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconStep4, 20, 20); break; case 4: - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_5, 20, 20); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconStep5, 20, 20); break; default: - icon = BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_DOING, 20, 20); + icon = BrunoTools.getAssetSizeImage(BrnAsset.iconStepDoing, 20, 20); break; } return icon; @@ -252,7 +252,7 @@ class BrnHorizontalStepsState extends State { return widget.completedIcon; } // 使用组件默认的icon - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_COMPLETED, 20, 20, + return BrunoTools.getAssetSizeImage(BrnAsset.iconStepCompleted, 20, 20, color: BrnThemeConfigurator.instance .getConfig() .commonConfig @@ -269,7 +269,7 @@ class BrnHorizontalStepsState extends State { return widget.doingIcon; } // 使用组件默认的icon - return BrunoTools.getAssetSizeImage(BrnAsset.ICON_STEP_DOING, 20, 20, + return BrunoTools.getAssetSizeImage(BrnAsset.iconStepDoing, 20, 20, color: BrnThemeConfigurator.instance .getConfig() .commonConfig diff --git a/lib/src/components/sugsearch/brn_search_text.dart b/lib/src/components/sugsearch/brn_search_text.dart index 421cb5a2..266e8d90 100644 --- a/lib/src/components/sugsearch/brn_search_text.dart +++ b/lib/src/components/sugsearch/brn_search_text.dart @@ -198,7 +198,7 @@ class _SearchTextState extends State { child: Center( child: Container( child: Image.asset( - 'assets/${BrnAsset.ICON_SEARCH}', + 'assets/${BrnAsset.iconSearch}', package: BrnStrings.flutterPackageName, height: 16, width: 16, @@ -288,7 +288,7 @@ class _SearchTextState extends State { padding: const EdgeInsets.symmetric(horizontal: 12.0), child: BrunoTools.getAssetImage( - BrnAsset.ICON_DELETE_TEXT, + BrnAsset.iconDeleteText, ), ), ), diff --git a/lib/src/components/tabbar/normal/brn_tab_bar.dart b/lib/src/components/tabbar/normal/brn_tab_bar.dart index e3d5cf2e..06a6aa12 100644 --- a/lib/src/components/tabbar/normal/brn_tab_bar.dart +++ b/lib/src/components/tabbar/normal/brn_tab_bar.dart @@ -329,9 +329,9 @@ class BrnTabBarState extends State { ], ), child: !_brnTabbarController.isShow - ? BrunoTools.getAssetImage(BrnAsset.ICON_TRIANGLE_DOWN) + ? BrunoTools.getAssetImage(BrnAsset.iconTriangleDown) : BrunoTools.getAssetImageWithBandColor( - BrnAsset.ICON_TRIANGLE_UP)), + BrnAsset.iconTriangleUp)), ), ); } diff --git a/lib/src/components/tag/tagview/brn_delete_tag.dart b/lib/src/components/tag/tagview/brn_delete_tag.dart index 609a3fa0..2a5bb4c9 100644 --- a/lib/src/components/tag/tagview/brn_delete_tag.dart +++ b/lib/src/components/tag/tagview/brn_delete_tag.dart @@ -211,10 +211,10 @@ class DeleteTagItemWidget extends StatelessWidget { //删除图标 deleteIcon: deleteIconSize != null ? BrunoTools.getAssetSizeImage( - BrnAsset.ICON_CLOSE, deleteIconSize.width, deleteIconSize.height, + BrnAsset.iconClose, deleteIconSize.width, deleteIconSize.height, color: deleteIconColor) : BrunoTools.getAssetImageWithColor( - BrnAsset.ICON_CLOSE, deleteIconColor), + BrnAsset.iconClose, deleteIconColor), onDeleted: () { debugPrint('$index'); didDeleted(index); diff --git a/lib/src/constants/brn_asset_constants.dart b/lib/src/constants/brn_asset_constants.dart index b8ec1fcd..abb01801 100644 --- a/lib/src/constants/brn_asset_constants.dart +++ b/lib/src/constants/brn_asset_constants.dart @@ -21,165 +21,164 @@ class BrnAsset { static const String iconBottomPickerRightTopBg = "images/icon_bottom_picker_right_top_bg.png"; - static const String ICON_ARROWUP_SELECT = "images/icon_arrow_up_selected.png"; - static const String ICON_REFRESH = "assets/images/icon_refresh.png"; - static const String ICON_ARROWDOWN_SELECT = + static const String iconArrowUpSelect = "images/icon_arrow_up_selected.png"; + static const String iconRefresh = "assets/images/icon_refresh.png"; + static const String iconArrowDownSelect = "images/icon_arrow_down_selected.png"; - static const String ICON_ARROWDOWN_UNSELECT = + static const String iconArrowDownUnSelect = "images/icon_arrow_down_unselected.png"; - static const String ICON_ARROW_RIGHT_1 = "icons/icon_right_arrow_1.png"; - static const String SELECT_CHECKED_STATUS = + static const String iconArrowRight = "icons/icon_right_arrow_1.png"; + static const String selectCheckedStatus = "images/select_checked_status.png"; - static const String SELECT_NORMAL_STATUS = "icons/normol_border.png"; - static const String ICON_SELECTED_UP_TRIANGLE = + static const String selectNormalStatus = "icons/normol_border.png"; + static const String iconSelectedUpTriangle = "icons/icon_selcted_triangle.png"; - static const String ICON_UNSELECT_DOWN_TRIANGLE = + static const String iconUnSelectDownTriangle = "icons/icon_unselected_triangle.png"; - static const String ICON_REQUIRE_RED = 'icons/icon_require_red.png'; - static const String ICON_RIGHT_ARROW = 'icons/icon_right_arrow.png'; - static const String ICON_BACK_WHITE = 'assets/icons/icon_back_white.png'; - static const String ICON_BACK_BLACK = 'assets/icons/icon_back_black.png'; - static const String ICON_STEP_2 = 'icons/icon_step_2.png'; - static const String ICON_STEP_3 = 'icons/icon_step_3.png'; - static const String ICON_STEP_4 = 'icons/icon_step_4.png'; - static const String ICON_STEP_5 = 'icons/icon_step_5.png'; - static const String ICON_STEP_DOING = 'icons/icon_step_doing.png'; - static const String ICON_STEP_COMPLETED = 'icons/icon_step_completed.png'; - - static const String ICON_DELETE_TEXT = 'icons/ic_delete_grey.png'; - static const String ICON_SEARCH = 'icons/ic_search.png'; - - static const String ICON_POPUP_CLOSE = 'icons/icon_popup_close.png'; - static const String ICON_CLOSE = 'icons/icon_close.png'; - static const String ICON_CALENDAR_PRE_MONTH = + static const String iconRequireRed = 'icons/icon_require_red.png'; + static const String iconRightArrow = 'icons/icon_right_arrow.png'; + static const String iconBackWhite = 'assets/icons/icon_back_white.png'; + static const String iconBackBlack = 'assets/icons/icon_back_black.png'; + static const String iconStep2 = 'icons/icon_step_2.png'; + static const String iconStep3 = 'icons/icon_step_3.png'; + static const String iconStep4 = 'icons/icon_step_4.png'; + static const String iconStep5 = 'icons/icon_step_5.png'; + static const String iconStepDoing = 'icons/icon_step_doing.png'; + static const String iconStepCompleted = 'icons/icon_step_completed.png'; + + static const String iconDeleteText = 'icons/ic_delete_grey.png'; + static const String iconSearch = 'icons/ic_search.png'; + + static const String iconPopupClose = 'icons/icon_popup_close.png'; + static const String iconClose = 'icons/icon_close.png'; + static const String iconCalendarPreMonth = 'icons/icon_calendar_pre_month.png'; - static const String ICON_CALENDAR_NEXT_MONTH = + static const String iconCalendarNextMonth = 'icons/icon_calendar_next_month.png'; - static const String ICON_UP_ARROW = 'icons/icon_up_arrow.png'; - static const String ICON_DOWN_ARROW = 'icons/icon_down_arrow.png'; - static const String ICON_TRASH_BIN = 'icons/icon_trash.png'; - static const String ICON_STAR_UNSELECT = 'icons/icon_star_unselect.png'; - static const String ICON_STAR_SELECT = 'icons/icon_star_select.png'; - static const String ICON_ADD_FORM_ITEM = 'icons/icon_add_form_item.png'; - static const String ICON_REMOVE_FORM_ITEM = 'icons/icon_remove_form_item.png'; + static const String iconUpArrow = 'icons/icon_up_arrow.png'; + static const String iconDownArrow = 'icons/icon_down_arrow.png'; + static const String iconTrashBin = 'icons/icon_trash.png'; + static const String iconStarUnSelect = 'icons/icon_star_unselect.png'; + static const String iconStarSelect = 'icons/icon_star_select.png'; + static const String iconAddFormItem = 'icons/icon_add_form_item.png'; + static const String iconRemoveFormItem = 'icons/icon_remove_form_item.png'; - static const String ICON_TRIANGLE_DOWN = 'icons/icon_triangle_down.png'; - static const String ICON_TRIANGLE_UP = 'icons/icon_triangle_up.png'; + static const String iconTriangleDown = 'icons/icon_triangle_down.png'; + static const String iconTriangleUp = 'icons/icon_triangle_up.png'; - static const String ICON_PAIR_INFO_QUESTION = + static const String iconPairInfoQuestion = 'icons/icon_pait_info_question.png'; - static const String ICON_PICKER_CLOSE = 'images/icon_guanbi.png'; + static const String iconPickerClose = 'images/icon_guanbi.png'; - static const String ICON_NOTICE = 'icons/icon_notice.png'; - static const String ICON_NOTICE_ARROW_BLUE = + static const String iconNotice = 'icons/icon_notice.png'; + static const String iconNoticeArrowBlue = 'icons/icon_notice_arrow_blue.png'; - static const String ICON_NOTICE_ARROW_GREEN = + static const String iconNoticeArrowGreen = 'icons/icon_notice_arrow_green.png'; - static const String ICON_NOTICE_ARROW_ORANGE = + static const String iconNoticeArrowOrange = 'icons/icon_notice_arrow_orange.png'; - static const String ICON_NOTICE_ARROW_RED = 'icons/icon_notice_arrow_red.png'; - static const String ICON_NOTICE_CLOSE_BLUE = + static const String iconNoticeArrowRed = 'icons/icon_notice_arrow_red.png'; + static const String iconNoticeCloseBlue = 'icons/icon_notice_close_blue.png'; - static const String ICON_NOTICE_CLOSE_GREEN = + static const String iconNoticeCloseGreen = 'icons/icon_notice_close_green.png'; - static const String ICON_NOTICE_CLOSE_ORANGE = + static const String iconNoticeCloseOrange = 'icons/icon_notice_close_orange.png'; - static const String ICON_NOTICE_CLOSE_RED = 'icons/icon_notice_close_red.png'; - static const String ICON_NOTICE_FAIL = 'icons/icon_notice_fail.png'; - static const String ICON_NOTICE_RUNNING = 'icons/icon_notice_running.png'; - static const String ICON_NOTICE_SUCCEED = 'icons/icon_notice_succeed.png'; - static const String ICON_NOTICE_WARNING = 'icons/icon_notice_warning.png'; + static const String iconNoticeCloseRed = 'icons/icon_notice_close_red.png'; + static const String iconNoticeFail = 'icons/icon_notice_fail.png'; + static const String iconNoticeRunning = 'icons/icon_notice_running.png'; + static const String iconNoticeSucceed = 'icons/icon_notice_succeed.png'; + static const String iconNoticeWarning = 'icons/icon_notice_warning.png'; - static const String ICON_OPERATION_OTHER_RIGHT = + static const String iconOperationOtherRight = 'icons/icon_operation_line_right.png'; - static const String ICON_OPERATION_OTHER_LEFT = + static const String iconOperationOtherLeft = 'icons/icon_operation_line_left.png'; - static const String ICON_RESULT_SUCCESS = 'icons/icon_result_success.png'; - static const String ICON_RESULT_ERROR = 'icons/icon_result_error.png'; - static const String ICON_STAR = 'icons/icon_star.png'; - static const String ICON_STAR_HALF = 'icons/icon_star_half.png'; - static const String ICON_UPARROW = 'icons/icon_uparrow.png'; - static const String ICOS_QRCODE_BG = 'assets/images/icon_qrcode_bg.png'; - static const String ICONS_QRCODE_FAILED = + static const String iconResultSuccess = 'icons/icon_result_success.png'; + static const String iconResultError = 'icons/icon_result_error.png'; + static const String iconStar = 'icons/icon_star.png'; + static const String iconStarHalf = 'icons/icon_star_half.png'; + static const String iconQrCodeBg = 'assets/images/icon_qrcode_bg.png'; + static const String iconsQrCodeFailed = '/assets/images/icon_qrcode_failed.png'; - static const String ICONS_REFRESH_WHITE = + static const String iconsRefreshWhite = 'assets/images/icon_refresh_white.png'; - static const String ICONS_AVATAR_NEW = '/assets/icons/img_avatar_new.png'; + static const String iconsAvatarNew = '/assets/icons/img_avatar_new.png'; - static const String ICON_AUDIOPALYER_PLAY = 'icons/icon_audioplayer_play.png'; - static const String ICON_AUDIOPALYER_PAUSE = + static const String iconAudioPlayer = 'icons/icon_audioplayer_play.png'; + static const String iconAudioPlayerPause = 'icons/icon_audioplayer_pause.png'; - static const String ICON_GREY_PLACE_HOLDER = 'icons/grey_place_holder.png'; + static const String iconGreyPlaceHolder = 'icons/grey_place_holder.png'; - static const String ICON_QUOTATION_MARK = 'icons/ic_quotation_mark.png'; + static const String iconQuotationMark = 'icons/ic_quotation_mark.png'; - static const String IMG_BACKGROUND_CARD = 'images/img_bg_card.png'; + static const String imgBackgroundCard = 'images/img_bg_card.png'; - static const String IMG_BG_BLUR = 'images/img_bg_blur.png'; + static const String imgBgBlur = 'images/img_bg_blur.png'; /// 用于图片右上角删除icon 的展示 - static const String ICON_DELETE = 'icons/icon_delete.png'; + static const String iconDelete = 'icons/icon_delete.png'; - static const String ICON_IM = 'images/icon_im_blue.png'; - static const String ICON_CALL = 'images/icon_call.png'; - static const String ICON_CALL_DISABLE = 'images/icon_call_disable.png'; - static const String PERSON_PLACE_HOLDER = + static const String iconIm = 'images/icon_im_blue.png'; + static const String iconCall = 'images/icon_call.png'; + static const String iconCallDisable = 'images/icon_call_disable.png'; + static const String personPlaceHolder = 'packages/bruno/assets/icons/img_avatar_new.png'; /// radio组件,用于单选和多选 - static const String ICON_RADIO_MULTI_SELECTED = + static const String iconRadioMultiSelected = 'icons/radio/multiple_selected.png'; - static const String ICON_RADIO_UNSELECTED = 'icons/radio/unselected.png'; - static const String ICON_RADIO_DISABLE_MULTI_SELECTED = + static const String iconRadioUnSelected = 'icons/radio/unselected.png'; + static const String iconRadioDisableMultiSelected = 'icons/radio/disable_multi_selected.png'; - static const String ICON_RADIO_DISABLE_UNSELECTED = + static const String iconRadioDisableUnselected = 'icons/radio/disable_unselected.png'; - static const String ICON_RADIO_SINGLE_SELECTED = + static const String iconRadioSingleSelected = 'icons/radio/single_selected.png'; - static const String ICON_RADIO_DISABLE_SINGLE_SELECTED = + static const String iconRadioDisableSingleSelected = 'icons/radio/disable_single_selected.png'; /// 评价组件--表情 - static const String ICON_APPRAISE_BAD_UNSELECTED = + static const String iconAppraiseBadUnselected = 'assets/images/icon_appraise_bad_unselected.png'; - static const String ICON_APPRAISE_NOT_GOOD_UNSELECTED = + static const String iconAppraiseNotGoodUnselected = 'assets/images/icon_appraise_not_good_unselected.png'; - static const String ICON_APPRAISE_OK_UNSELECTED = + static const String iconAppraiseOkUnselected = 'assets/images/icon_appraise_ok_unselected.png'; - static const String ICON_APPRAISE_GOOD_UNSELECTED = + static const String iconAppraiseGoodUnselected = 'assets/images/icon_appraise_good_unselected.png'; - static const String ICON_APPRAISE_SURPRISE_UNSELECTED = + static const String iconAppraiseSurpriseUnselected = 'assets/images/icon_appraise_surprise_unselected.png'; - static const String ICON_APPRAISE_BAD_DEFAULT = + static const String iconAppraiseBadDefault = 'assets/images/icon_appraise_bad_default.png'; - static const String ICON_APPRAISE_NOT_GOOD_DEFAULT = + static const String iconAppraiseNotGoodDefault = 'assets/images/icon_appraise_not_good_default.png'; - static const String ICON_APPRAISE_OK_DEFAULT = + static const String iconAppraiseOkDefault = 'assets/images/icon_appraise_ok_default.png'; - static const String ICON_APPRAISE_GOOD_DEFAULT = + static const String iconAppraiseGoodDefault = 'assets/images/icon_appraise_good_default.png'; - static const String ICON_APPRAISE_SURPRISE_DEFAULT = + static const String iconAppraiseSurpriseDefault = 'assets/images/icon_appraise_surprise_default.png'; - static const String ICON_APPRAISE_BAD_SELECTED = + static const String iconAppraiseBadSelected = 'assets/images/icon_appraise_bad_selected.png'; - static const String ICON_APPRAISE_NOT_GOOD_SELECTED = + static const String iconAppraiseNotGoodSelected = 'assets/images/icon_appraise_not_good_selected.png'; - static const String ICON_APPRAISE_OK_SELECTED = + static const String iconAppraiseOkSelected = 'assets/images/icon_appraise_ok_selected.png'; - static const String ICON_APPRAISE_GOOD_SELECTED = + static const String iconAppraiseGoodSelected = 'assets/images/icon_appraise_good_selected.png'; - static const String ICON_APPRAISE_SURPRISE_SELECTED = + static const String iconAppraiseSurpriseSelected = 'assets/images/icon_appraise_surprise_selected.png'; - static const String ICON_QUESTION = "icons/icon_question.png"; + static const String iconQuestion = "icons/icon_question.png"; /// 录入项icon - static const String ICON_ADD_DISABLE = "icons/icon_add_disable.png"; - static const String ICON_ADD_ENABLE = "icons/icon_add_enable.png"; + static const String iconAddDisable = "icons/icon_add_disable.png"; + static const String iconAddEnable = "icons/icon_add_enable.png"; - static const String ICON_MINUS_DISABLE = "icons/icon_minus_disable.png"; - static const String ICON_MINUS_ENABLE = "icons/icon_minus_enable.png"; + static const String iconMinusDisable = "icons/icon_minus_disable.png"; + static const String iconMinusEnable = "icons/icon_minus_enable.png"; } diff --git a/lib/src/constants/brn_constants.dart b/lib/src/constants/brn_constants.dart index 3c90445d..72dbc7e5 100644 --- a/lib/src/constants/brn_constants.dart +++ b/lib/src/constants/brn_constants.dart @@ -42,39 +42,39 @@ class BrnShareItemConstants { ]; /// 微信 - static const int SHARE_WEIXIN = 0; + static const int shareWeiXin = 0; /// 朋友圈 - static const int SHARE_FRIEND = 1; + static const int shareFriend = 1; /// qq - static const int SHARE_QQ = 2; + static const int shareQQ = 2; /// qq空间 - static const int SHARE_QZONE = 3; + static const int shareQZone = 3; /// 微博 - static const int SHARE_WEIBO = 4; + static const int shareWeiBo = 4; /// 链接 - static const int SHARE_LINK = 5; + static const int shareLink = 5; /// 短信 - static const int SHARE_SMS = 6; + static const int shareSms = 6; /// 剪贴板 - static const int SHARE_COPY_LINK = 7; + static const int shareCopyLink = 7; /// 浏览器 - static const int SHARE_BROWSER = 8; + static const int shareBrowser = 8; /// 相册 - static const int SHARE_SAVE_IMAGE = 9; + static const int shareSaveImage = 9; /// 自定义 - static const int SHARE_CUSTOM = 100; + static const int shareCustom = 100; } class BrnSelectionConstant { - static const int MAX_SELECT_COUNT = 65535; + static const int maxSelectCount = 65535; } diff --git a/lib/src/constants/brn_fonts_constants.dart b/lib/src/constants/brn_fonts_constants.dart index c9a30757..a6ecea8c 100644 --- a/lib/src/constants/brn_fonts_constants.dart +++ b/lib/src/constants/brn_fonts_constants.dart @@ -1,10 +1,10 @@ class BrnFonts { const BrnFonts._(); - static const double FONT_12 = 12; - static const double FONT_14 = 14; - static const double FONT_16 = 16; - static const double FONT_18 = 18; - static const double FONT_20 = 20; - static const double FONT_22 = 22; + static const double f12 = 12; + static const double f14 = 14; + static const double f16 = 16; + static const double f18 = 18; + static const double f20 = 20; + static const double f22 = 22; } diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index 66861fb3..03c565fc 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -405,7 +405,7 @@ class BrnDefaultConfigUtils { backgroundColor: Colors.white, appBarHeight: BrnAppBarTheme.appBarHeight, leadIconBuilder: () => Image.asset( - BrnAsset.ICON_BACK_BLACK, + BrnAsset.iconBackBlack, package: BrnStrings.flutterPackageName, width: BrnAppBarTheme.iconSize, height: BrnAppBarTheme.iconSize, diff --git a/lib/src/theme/brn_theme.dart b/lib/src/theme/brn_theme.dart index 6699bbff..243bea0c 100644 --- a/lib/src/theme/brn_theme.dart +++ b/lib/src/theme/brn_theme.dart @@ -25,3 +25,6 @@ export 'configs/brn_tabbar_config.dart'; export 'configs/brn_tag_config.dart'; export 'img/brn_theme_default_utils.dart'; export 'brn_initializer.dart'; +export 'brn_theme_configurator.dart'; +export 'img/brn_theme_default_utils.dart'; + diff --git a/lib/src/theme/configs/brn_appbar_config.dart b/lib/src/theme/configs/brn_appbar_config.dart index a220c951..bc2323b4 100644 --- a/lib/src/theme/configs/brn_appbar_config.dart +++ b/lib/src/theme/configs/brn_appbar_config.dart @@ -58,7 +58,7 @@ class BrnAppBarConfig extends BrnBaseConfig { super(configId: configId) { _backgroundColor = Color(0xff2E313B); _leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_WHITE, + BrnAsset.iconBackWhite, package: BrnStrings.flutterPackageName, width: BrnAppBarTheme.iconSize, height: BrnAppBarTheme.iconSize, @@ -94,7 +94,7 @@ class BrnAppBarConfig extends BrnBaseConfig { super(configId: configId) { _backgroundColor = Colors.white; _leadIconBuilder = () => Image.asset( - BrnAsset.ICON_BACK_BLACK, + BrnAsset.iconBackBlack, package: BrnStrings.flutterPackageName, width: BrnAppBarTheme.iconSize, height: BrnAppBarTheme.iconSize, diff --git a/lib/src/theme/img/brn_theme_default_utils.dart b/lib/src/theme/img/brn_theme_default_utils.dart index df2ebcc0..33d7be55 100644 --- a/lib/src/theme/img/brn_theme_default_utils.dart +++ b/lib/src/theme/img/brn_theme_default_utils.dart @@ -34,7 +34,7 @@ class BrnThemeImg { Image get checkedStatus => _defaultBrunoImg.checkedStatus ?? - BrunoTools.getAssetImage(BrnAsset.SELECT_CHECKED_STATUS); + BrunoTools.getAssetImage(BrnAsset.selectCheckedStatus); Image get stepIcon { return _defaultBrunoImg.stepIcon ?? @@ -56,7 +56,7 @@ class BrnDefaultThemeImgUtil extends BrnThemeImgUtils { @override Image get checkedStatus { return BrunoTools.getAssetImageWithBandColor( - BrnAsset.SELECT_CHECKED_STATUS); + BrnAsset.selectCheckedStatus); } @override From 5db665dad56217fdae62cd48d4b92c40668d1222 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 5 Jan 2022 17:51:27 +0800 Subject: [PATCH 07/31] migrate brn_empty_status.dart --- .../components/empty/brn_empty_status.dart | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/src/components/empty/brn_empty_status.dart b/lib/src/components/empty/brn_empty_status.dart index bd244d91..7c4ba7d2 100644 --- a/lib/src/components/empty/brn_empty_status.dart +++ b/lib/src/components/empty/brn_empty_status.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/constants/brn_strings_constants.dart'; @@ -28,7 +28,7 @@ class BrnAbnormalStateUtils { /// status: 页面状态类型为[EmptyState] static Widget getEmptyWidgetByState(BuildContext context, AbnormalState status, BrnEmptyStatusIndexedActionClickCallback action, - {Image img}) { + {Image? img}) { if (AbnormalState.getDataFailed == status) { return BrnAbnormalStateWidget( img: img ?? BrunoTools.getAssetImage(BrnAsset.emptyState), @@ -74,22 +74,22 @@ typedef BrnEmptyStatusIndexedActionClickCallback = void Function(int index); // ignore: must_be_immutable class BrnAbnormalStateWidget extends StatelessWidget { /// 图片 - final Image img; + final Image? img; /// 标题 - final String title; + final String? title; /// 内容 - final String content; + final String? content; /// 操作区类型 final OperateAreaType operateAreaType; /// 操作区文案 - final List operateTexts; + final List? operateTexts; /// 点击事件回调 - final BrnEmptyStatusIndexedActionClickCallback action; + final BrnEmptyStatusIndexedActionClickCallback? action; /// 是否可点击页面回调配合[action]使用 /// 当为true时调用[action]回调,当为false时不做处理 @@ -98,7 +98,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { /// 顶部距离走自动计算逻辑:父视图高度的8%,可自己指定高度 /// 默认为null - final double topOffset; + final double? topOffset; /// 背景色设置 /// 默认Colors.white @@ -111,7 +111,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { /// 默认 false final bool isCenterVertical; - BrnAbnormalStateConfig themeData; + BrnAbnormalStateConfig? themeData; BrnAbnormalStateWidget({ this.img, @@ -129,7 +129,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { }) { this.themeData ??= BrnAbnormalStateConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .abnormalStateConfig .merge(this.themeData); } @@ -138,12 +138,12 @@ class BrnAbnormalStateWidget extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: () { - if (this.enablePageTap) { - action(0); + if (this.enablePageTap && action!=null) { + action!(0); } }, child: Container( - color: bgColor ?? Colors.white, + color: bgColor, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: isCenterVertical @@ -171,7 +171,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { : EdgeInsets.only(top: topOffset ?? height * topPercent), child: img, ) - : Container(); + : SizedBox.shrink(); } ///文案区域:标题 @@ -180,11 +180,11 @@ class BrnAbnormalStateWidget extends StatelessWidget { ? Container( alignment: Alignment.center, padding: EdgeInsets.fromLTRB(60, 24, 60, 0), - child: Text(title, + child: Text(title!, textAlign: TextAlign.center, - style: themeData?.titleTextStyle?.generateTextStyle()), + style: themeData!.titleTextStyle.generateTextStyle()), ) - : Container(); + : SizedBox.shrink(); } ///文案区域:内容 @@ -193,11 +193,11 @@ class BrnAbnormalStateWidget extends StatelessWidget { ? Container( alignment: Alignment.center, padding: EdgeInsets.fromLTRB(60, 12, 60, 0), - child: Text(content, + child: Text(content!, textAlign: TextAlign.center, - style: themeData?.contentTextStyle?.generateTextStyle()), + style: themeData!.contentTextStyle.generateTextStyle()), ) - : Container(); + : SizedBox.shrink(); } ///操作区域 @@ -207,24 +207,24 @@ class BrnAbnormalStateWidget extends StatelessWidget { padding: EdgeInsets.only(top: 36), child: _buildOperateContentWidget(), ) - : Container(); + : SizedBox.shrink(); } ///操作区按钮 _buildOperateContentWidget() { if (OperateAreaType.SingleButton == operateAreaType) { return GestureDetector( - onTap: () => action(0), + onTap: () => action!(0), child: Container( - constraints: BoxConstraints(minWidth: themeData.singleMinWidth), + constraints: BoxConstraints(minWidth: themeData!.singleMinWidth), padding: EdgeInsets.fromLTRB(48, 16, 48, 16), decoration: BoxDecoration( - color: themeData.commonConfig.brandPrimary, + color: themeData!.commonConfig.brandPrimary, borderRadius: - BorderRadius.all(Radius.circular(themeData?.btnRadius))), - child: Text(operateTexts[0] ?? "", + BorderRadius.all(Radius.circular(themeData!.btnRadius))), + child: Text(operateTexts?[0] ?? '', textAlign: TextAlign.center, - style: themeData?.singleTextStyle?.generateTextStyle()), + style: themeData!.singleTextStyle.generateTextStyle()), ), ); } else if (OperateAreaType.DoubleButton == operateAreaType) { @@ -232,17 +232,17 @@ class BrnAbnormalStateWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ GestureDetector( - onTap: () => action(0), + onTap: () => action!(0), child: Container( - constraints: BoxConstraints(minWidth: themeData.doubleMinWidth), + constraints: BoxConstraints(minWidth: themeData!.doubleMinWidth), padding: EdgeInsets.fromLTRB(36, 16, 36, 16), decoration: BoxDecoration( - color: themeData.commonConfig.brandPrimary.withAlpha(0x14), + color: themeData!.commonConfig.brandPrimary.withAlpha(0x14), borderRadius: - BorderRadius.all(Radius.circular(themeData?.btnRadius))), - child: Text(operateTexts[0] ?? "", + BorderRadius.all(Radius.circular(themeData!.btnRadius))), + child: Text(operateTexts?[0] ?? '', textAlign: TextAlign.center, - style: themeData?.doubleTextStyle?.generateTextStyle()), + style: themeData!.doubleTextStyle.generateTextStyle()), ), ), Container( @@ -250,26 +250,26 @@ class BrnAbnormalStateWidget extends StatelessWidget { color: Colors.transparent, ), GestureDetector( - onTap: () => action(1), + onTap: () => action!(1), child: Container( - constraints: BoxConstraints(minWidth: themeData.doubleMinWidth), + constraints: BoxConstraints(minWidth: themeData!.doubleMinWidth), padding: EdgeInsets.fromLTRB(36, 16, 36, 16), decoration: BoxDecoration( - color: themeData.commonConfig.brandPrimary.withAlpha(0x14), + color: themeData!.commonConfig.brandPrimary.withAlpha(0x14), borderRadius: - BorderRadius.all(Radius.circular(themeData?.btnRadius))), - child: Text(operateTexts[1] ?? "", + BorderRadius.all(Radius.circular(themeData!.btnRadius))), + child: Text(operateTexts?[1] ?? '', textAlign: TextAlign.center, - style: themeData?.doubleTextStyle?.generateTextStyle()), + style: themeData!.doubleTextStyle.generateTextStyle()), ), ), ], ); } else if (OperateAreaType.TextButton == operateAreaType) { return GestureDetector( - onTap: () => action(0), - child: Text(operateTexts[0] ?? "", - style: themeData?.operateTextStyle?.generateTextStyle())); + onTap: () => action!(0), + child: Text(operateTexts?[0] ??'', + style: themeData!.operateTextStyle.generateTextStyle())); } return Container(); } From 7c12fc8eec4703da6ca52c455c5834cb326731b0 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Thu, 6 Jan 2022 16:29:45 +0800 Subject: [PATCH 08/31] =?UTF-8?q?=E5=88=A0=E9=99=A4=20BrnThemeImg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/brn_layer_more_selection_page.dart | 1 - lib/src/theme/brn_initializer.dart | 7 -- lib/src/theme/brn_theme.dart | 3 - .../theme/img/brn_theme_default_utils.dart | 66 ------------------- lib/src/theme/img/brn_theme_img_utils.dart | 15 ----- 5 files changed, 92 deletions(-) delete mode 100644 lib/src/theme/img/brn_theme_default_utils.dart delete mode 100644 lib/src/theme/img/brn_theme_img_utils.dart diff --git a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart index 8350209f..ae4bb552 100644 --- a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart +++ b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart @@ -8,7 +8,6 @@ import 'package:bruno/src/components/toast/brn_toast.dart'; import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_selection_config.dart'; -import 'package:bruno/src/theme/img/brn_theme_default_utils.dart'; import 'package:bruno/src/utils/brn_tools.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/lib/src/theme/brn_initializer.dart b/lib/src/theme/brn_initializer.dart index 2cc30df0..b90c0b5b 100644 --- a/lib/src/theme/brn_initializer.dart +++ b/lib/src/theme/brn_initializer.dart @@ -1,7 +1,5 @@ import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_all_config.dart'; -import 'package:bruno/src/theme/img/brn_theme_default_utils.dart'; -import 'package:bruno/src/theme/img/brn_theme_img_utils.dart'; /// Bruno 初始化 class BrnInitializer { @@ -9,12 +7,7 @@ class BrnInitializer { static register({ BrnAllThemeConfig? allThemeConfig, String configId = GLOBAL_CONFIG_ID, - BrnThemeImgUtils? brunoImgUtils, }) { - /// 配置图片 - if (brunoImgUtils != null) { - BrnThemeImg.register(brunoImgUtils: brunoImgUtils); - } /// 配置主题定制 BrnThemeConfigurator.instance.register(allThemeConfig, configId: configId); diff --git a/lib/src/theme/brn_theme.dart b/lib/src/theme/brn_theme.dart index 243bea0c..6300080e 100644 --- a/lib/src/theme/brn_theme.dart +++ b/lib/src/theme/brn_theme.dart @@ -23,8 +23,5 @@ export 'configs/brn_picker_config.dart'; export 'configs/brn_selection_config.dart'; export 'configs/brn_tabbar_config.dart'; export 'configs/brn_tag_config.dart'; -export 'img/brn_theme_default_utils.dart'; export 'brn_initializer.dart'; export 'brn_theme_configurator.dart'; -export 'img/brn_theme_default_utils.dart'; - diff --git a/lib/src/theme/img/brn_theme_default_utils.dart b/lib/src/theme/img/brn_theme_default_utils.dart deleted file mode 100644 index 33d7be55..00000000 --- a/lib/src/theme/img/brn_theme_default_utils.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:bruno/src/constants/brn_asset_constants.dart'; -import 'package:bruno/src/theme/img/brn_theme_img_utils.dart'; -import 'package:bruno/src/utils/brn_tools.dart'; -import 'package:flutter/material.dart'; - -class BrnThemeImg { - BrnThemeImg._( - BrnThemeImgUtils? brunoImgUtils, - ) : _defaultBrunoImg = brunoImgUtils ?? BrnDefaultThemeImgUtil(); - - factory BrnThemeImg.register({BrnThemeImgUtils? brunoImgUtils}) { - _instance = BrnThemeImg._(brunoImgUtils); - return _instance!; - } - - static BrnThemeImg get instance { - if (_instance == null) { - BrnThemeImg.register(); - } - return _instance!; - } - - static BrnThemeImg? _instance; - - BrnThemeImgUtils _defaultBrunoImg; - - Image get arrowRefreshUp => - _defaultBrunoImg.arrowRefreshUp ?? - BrunoTools.getAssetImage(BrnAsset.refreshArrowUp); - - Image get arrowRefreshDown => - _defaultBrunoImg.arrowRefreshDown ?? - BrunoTools.getAssetImage(BrnAsset.refreshArrowDown); - - Image get checkedStatus => - _defaultBrunoImg.checkedStatus ?? - BrunoTools.getAssetImage(BrnAsset.selectCheckedStatus); - - Image get stepIcon { - return _defaultBrunoImg.stepIcon ?? - BrunoTools.getAssetImage(BrnAsset.stepTitle); - } -} - -class BrnDefaultThemeImgUtil extends BrnThemeImgUtils { - @override - Image get arrowRefreshUp { - return BrunoTools.getAssetImageWithBandColor(BrnAsset.refreshArrowUp); - } - - @override - Image get arrowRefreshDown { - return BrunoTools.getAssetImageWithBandColor(BrnAsset.refreshArrowDown); - } - - @override - Image get checkedStatus { - return BrunoTools.getAssetImageWithBandColor( - BrnAsset.selectCheckedStatus); - } - - @override - Image get stepIcon { - return BrunoTools.getAssetImageWithBandColor(BrnAsset.stepTitle); - } -} diff --git a/lib/src/theme/img/brn_theme_img_utils.dart b/lib/src/theme/img/brn_theme_img_utils.dart deleted file mode 100644 index 83de205d..00000000 --- a/lib/src/theme/img/brn_theme_img_utils.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -abstract class BrnThemeImgUtils { - /// 下拉刷新的向上icon - Image? get arrowRefreshUp; - - /// 下拉刷新的向下icon - Image? get arrowRefreshDown; - - /// 选中与否的Icon - Image? get checkedStatus; - - /// 步骤的title - Image? get stepIcon; -} From c00cfd5318901c00e4211028e57fe4fa51038aed Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Thu, 6 Jan 2022 16:47:12 +0800 Subject: [PATCH 09/31] =?UTF-8?q?fix:tagConfig=20merge=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/theme/configs/brn_tag_config.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/theme/configs/brn_tag_config.dart b/lib/src/theme/configs/brn_tag_config.dart index 39b03a26..6af4dae1 100644 --- a/lib/src/theme/configs/brn_tag_config.dart +++ b/lib/src/theme/configs/brn_tag_config.dart @@ -152,7 +152,8 @@ class BrnTagConfig extends BrnBaseConfig { ); } - BrnTagConfig merge(BrnTagConfig other) { + BrnTagConfig merge(BrnTagConfig? other) { + if (other == null) return this; return copyWith( textStyle: tagTextStyle.merge(other._tagTextStyle), selectTextStyle: selectTagTextStyle.merge(other._selectTagTextStyle), From ada5216abb007fcd3909c5e3535e323cc644b35f Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Fri, 7 Jan 2022 10:39:40 +0800 Subject: [PATCH 10/31] fix:revert tagConfig --- lib/src/components/tag/tagview/brn_delete_tag.dart | 2 +- lib/src/components/tag/tagview/brn_select_tag.dart | 2 +- lib/src/theme/configs/brn_tag_config.dart | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/components/tag/tagview/brn_delete_tag.dart b/lib/src/components/tag/tagview/brn_delete_tag.dart index 5a7a12e6..3683211f 100644 --- a/lib/src/components/tag/tagview/brn_delete_tag.dart +++ b/lib/src/components/tag/tagview/brn_delete_tag.dart @@ -76,7 +76,7 @@ class BrnDeleteTag extends StatefulWidget { themeData = BrnThemeConfigurator.instance .getConfig(configId: themeData!.configId) .tagConfig - .merge(themeData); + .merge(this.themeData!); } @override diff --git a/lib/src/components/tag/tagview/brn_select_tag.dart b/lib/src/components/tag/tagview/brn_select_tag.dart index 62f01fe4..b3f6d16f 100644 --- a/lib/src/components/tag/tagview/brn_select_tag.dart +++ b/lib/src/components/tag/tagview/brn_select_tag.dart @@ -92,7 +92,7 @@ class BrnSelectTag extends StatefulWidget { this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) .tagConfig - .merge(this.themeData); + .merge(this.themeData!); } @override diff --git a/lib/src/theme/configs/brn_tag_config.dart b/lib/src/theme/configs/brn_tag_config.dart index 6af4dae1..39b03a26 100644 --- a/lib/src/theme/configs/brn_tag_config.dart +++ b/lib/src/theme/configs/brn_tag_config.dart @@ -152,8 +152,7 @@ class BrnTagConfig extends BrnBaseConfig { ); } - BrnTagConfig merge(BrnTagConfig? other) { - if (other == null) return this; + BrnTagConfig merge(BrnTagConfig other) { return copyWith( textStyle: tagTextStyle.merge(other._tagTextStyle), selectTextStyle: selectTagTextStyle.merge(other._selectTagTextStyle), From beec378fc95e1408be1f328c7830bce70048ff57 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Fri, 7 Jan 2022 12:07:05 +0800 Subject: [PATCH 11/31] =?UTF-8?q?fix:BrnAbnormalStateWidget=E7=A9=BA?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/empty/brn_empty_status.dart | 30 +++++++++++-------- .../selectcity/brn_base_azlistview_page.dart | 4 +-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/src/components/empty/brn_empty_status.dart b/lib/src/components/empty/brn_empty_status.dart index 7c4ba7d2..6d832c02 100644 --- a/lib/src/components/empty/brn_empty_status.dart +++ b/lib/src/components/empty/brn_empty_status.dart @@ -1,5 +1,3 @@ - - import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/constants/brn_strings_constants.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -27,8 +25,8 @@ class BrnAbnormalStateUtils { /// 通过状态获取对应空页面widget /// status: 页面状态类型为[EmptyState] static Widget getEmptyWidgetByState(BuildContext context, - AbnormalState status, BrnEmptyStatusIndexedActionClickCallback action, - {Image? img}) { + AbnormalState status, + {Image? img,BrnEmptyStatusIndexedActionClickCallback? action}) { if (AbnormalState.getDataFailed == status) { return BrnAbnormalStateWidget( img: img ?? BrunoTools.getAssetImage(BrnAsset.emptyState), @@ -214,7 +212,9 @@ class BrnAbnormalStateWidget extends StatelessWidget { _buildOperateContentWidget() { if (OperateAreaType.SingleButton == operateAreaType) { return GestureDetector( - onTap: () => action!(0), + onTap: () { + if (action != null) action!(0); + }, child: Container( constraints: BoxConstraints(minWidth: themeData!.singleMinWidth), padding: EdgeInsets.fromLTRB(48, 16, 48, 16), @@ -222,7 +222,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { color: themeData!.commonConfig.brandPrimary, borderRadius: BorderRadius.all(Radius.circular(themeData!.btnRadius))), - child: Text(operateTexts?[0] ?? '', + child: Text(operateTexts![0] ?? '', textAlign: TextAlign.center, style: themeData!.singleTextStyle.generateTextStyle()), ), @@ -232,7 +232,9 @@ class BrnAbnormalStateWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ GestureDetector( - onTap: () => action!(0), + onTap: () { + if (action != null) action!(0); + }, child: Container( constraints: BoxConstraints(minWidth: themeData!.doubleMinWidth), padding: EdgeInsets.fromLTRB(36, 16, 36, 16), @@ -240,7 +242,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { color: themeData!.commonConfig.brandPrimary.withAlpha(0x14), borderRadius: BorderRadius.all(Radius.circular(themeData!.btnRadius))), - child: Text(operateTexts?[0] ?? '', + child: Text(operateTexts![0] ?? '', textAlign: TextAlign.center, style: themeData!.doubleTextStyle.generateTextStyle()), ), @@ -250,7 +252,9 @@ class BrnAbnormalStateWidget extends StatelessWidget { color: Colors.transparent, ), GestureDetector( - onTap: () => action!(1), + onTap: () { + if (action != null) action!(1); + }, child: Container( constraints: BoxConstraints(minWidth: themeData!.doubleMinWidth), padding: EdgeInsets.fromLTRB(36, 16, 36, 16), @@ -258,7 +262,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { color: themeData!.commonConfig.brandPrimary.withAlpha(0x14), borderRadius: BorderRadius.all(Radius.circular(themeData!.btnRadius))), - child: Text(operateTexts?[1] ?? '', + child: Text(operateTexts![1] ?? '', textAlign: TextAlign.center, style: themeData!.doubleTextStyle.generateTextStyle()), ), @@ -267,8 +271,10 @@ class BrnAbnormalStateWidget extends StatelessWidget { ); } else if (OperateAreaType.TextButton == operateAreaType) { return GestureDetector( - onTap: () => action!(0), - child: Text(operateTexts?[0] ??'', + onTap: () { + if (action != null) action!(0); + }, + child: Text(operateTexts![0] ??'', style: themeData!.operateTextStyle.generateTextStyle())); } return Container(); diff --git a/lib/src/components/selectcity/brn_base_azlistview_page.dart b/lib/src/components/selectcity/brn_base_azlistview_page.dart index c05e9950..a73c1027 100644 --- a/lib/src/components/selectcity/brn_base_azlistview_page.dart +++ b/lib/src/components/selectcity/brn_base_azlistview_page.dart @@ -72,7 +72,7 @@ class _BaseAZListViewPageState extends State { if (snapShot.connectionState == ConnectionState.done) { if (snapShot.hasError) { return BrnAbnormalStateUtils.getEmptyWidgetByState( - context, AbnormalState.networkConnectError, (index) { + context, AbnormalState.networkConnectError,action: (index) { setState(() {}); }); } else { @@ -98,7 +98,7 @@ class _BaseAZListViewPageState extends State { if (_dataList.isEmpty && top.isEmpty) { return BrnAbnormalStateUtils.getEmptyWidgetByState( - context, AbnormalState.noData, (index) {}); + context, AbnormalState.noData,); } suspensionTag = top.isEmpty ? _dataList[0].tag : top[0].tag; From 162fcfe575c190e513f123cdf8d0cfd453a1996d Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 11 Jan 2022 17:06:25 +0800 Subject: [PATCH 12/31] Migrated tabbar to null-safety --- .../bottom/brn_bottom_tab_bar_item.dart | 17 +- .../bottom/brn_bottom_tab_bar_main.dart | 115 +++++---- .../indicator/brn_custom_width_indicator.dart | 20 +- .../brn_fixed_underline_decoration.dart | 18 +- .../indicator/brn_triangle_decoration.dart | 54 ++--- .../tabbar/normal/brn_sub_switch_title.dart | 24 +- .../tabbar/normal/brn_switch_title.dart | 36 +-- .../components/tabbar/normal/brn_tab_bar.dart | 222 +++++++++--------- .../tabbar/normal/brn_tabbar_controller.dart | 12 +- 9 files changed, 255 insertions(+), 263 deletions(-) diff --git a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_item.dart b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_item.dart index 70d63a90..0e8422a9 100644 --- a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_item.dart +++ b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:ui' show Color; @@ -9,15 +9,14 @@ import 'package:flutter/material.dart'; /// 特别注意:Tab的右上角小红点可能不符合UI规范,可以使用BrnBadge小红点组件 class BrnBottomTabBarItem { const BrnBottomTabBarItem({ - @required this.icon, + required this.icon, this.title, - Widget activeIcon, + Widget? activeIcon, this.backgroundColor, this.badge, this.badgeNo, this.maxBadgeNo = 99, - }) : activeIcon = activeIcon ?? icon, - assert(icon != null); + }) : activeIcon = activeIcon ?? icon; /// 未选中时的icon final Widget icon; @@ -26,16 +25,16 @@ class BrnBottomTabBarItem { final Widget activeIcon; /// Tab标题名 - final Widget title; + final Widget? title; /// 背景色 - final Color backgroundColor; + final Color? backgroundColor; /// 未读信息 - final Widget badge; + final Widget? badge; /// 未读信息个数 - final String badgeNo; + final String? badgeNo; /// 未读消息最大个数 final int maxBadgeNo; diff --git a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart index 2a16b303..1ff2b67d 100644 --- a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart +++ b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:collection' show Queue; import 'dart:math' as math; @@ -12,9 +12,9 @@ const double _kActiveFontSize = 10.0; const double _kInactiveFontSize = 9.0; const double _kTopMargin = 6.0; const double _kBottomMargin = 0.0; -const double _kmiddleInterval = 4.0; +const double _kMiddleInterval = 4.0; -/// Tabbar显示状态 +/// tabBar显示状态 enum BrnBottomTabBarDisplayType { /// 固定显示状态 fixed, @@ -28,8 +28,8 @@ enum BrnBottomTabBarDisplayType { /// 特别注意:默认关闭点击动画,为固定显示状态 class BrnBottomTabBar extends StatefulWidget { BrnBottomTabBar({ - Key key, - @required this.items, + Key? key, + required this.items, this.onTap, this.currentIndex = 0, BrnBottomTabBarDisplayType type = BrnBottomTabBarDisplayType.fixed, @@ -38,25 +38,22 @@ class BrnBottomTabBar extends StatefulWidget { this.isAnimation = false, this.badgeColor, this.isInkResponse = false, - }) : assert(items != null), - assert(items.length >= 1), + }) : assert(items.length >= 1), assert( items.every((BrnBottomTabBarItem item) => item.title != null) == true, 'Every item must have a non-null title', ), assert(0 <= currentIndex && currentIndex < items.length), - assert(iconSize != null), - type = type ?? - (items.length <= 3 + type = items.length <= 3 ? BrnBottomTabBarDisplayType.fixed - : BrnBottomTabBarDisplayType.shifting), + : BrnBottomTabBarDisplayType.shifting, super(key: key); /// 动画是否可见,默认:true final bool isAnimation; /// 未读弹窗背景颜色,默认:fixedColor - final Color badgeColor; + final Color? badgeColor; /// InkResponse:是否可访问, 默认:true final bool isInkResponse; @@ -65,7 +62,7 @@ class BrnBottomTabBar extends StatefulWidget { final List items; /// Tab点击之后的回调函数 - final ValueChanged onTap; + final ValueChanged? onTap; /// 当前活动项的索引值 final int currentIndex; @@ -74,7 +71,7 @@ class BrnBottomTabBar extends StatefulWidget { final BrnBottomTabBarDisplayType type; /// 底部Tab所选中时的颜色 - final Color fixedColor; + final Color? fixedColor; /// Tab中图标的大小 final double iconSize; @@ -98,29 +95,29 @@ class _BottomNavigationTile extends StatelessWidget { this.isAnimation = true, this.isInkResponse = true, this.badgeColor, - }) : assert(selected != null); + }) ; final BrnBottomTabBarDisplayType type; final BrnBottomTabBarItem item; final Animation animation; final double iconSize; - final VoidCallback onTap; - final ColorTween colorTween; - final double flex; + final VoidCallback? onTap; + final ColorTween? colorTween; + final double? flex; final bool selected; - final String indexLabel; + final String? indexLabel; final bool isAnimation; final bool isInkResponse; - final Color badgeColor; + final Color? badgeColor; /// 构建icon Widget _buildIcon() { - double tweenStart; - Color iconColor; + double? tweenStart; + Color? iconColor; switch (type) { case BrnBottomTabBarDisplayType.fixed: tweenStart = 8.0; - iconColor = colorTween.evaluate(animation); + iconColor = colorTween?.evaluate(animation); break; case BrnBottomTabBarDisplayType.shifting: tweenStart = 16.0; @@ -150,7 +147,7 @@ class _BottomNavigationTile extends StatelessWidget { ); } - /// 构建固定Lable + /// 构建固定Label /// 修改icon与text间距在这里修改 Widget _buildFixedLabel() { double scale = isAnimation @@ -164,11 +161,11 @@ class _BottomNavigationTile extends StatelessWidget { heightFactor: 1.0, child: Container( margin: const EdgeInsets.only( - bottom: _kBottomMargin, top: _kmiddleInterval), + bottom: _kBottomMargin, top: _kMiddleInterval), child: DefaultTextStyle.merge( style: TextStyle( fontSize: _kActiveFontSize, - color: colorTween.evaluate(animation), + color: colorTween?.evaluate(animation), ), /// 使用矩阵变化控制字体大小 @@ -186,7 +183,7 @@ class _BottomNavigationTile extends StatelessWidget { ); } - /// 构建可变Lable + /// 构建可变Label Widget _buildShiftingLabel() { return Align( alignment: Alignment.bottomCenter, @@ -208,7 +205,7 @@ class _BottomNavigationTile extends StatelessWidget { fontSize: _kActiveFontSize, color: Colors.blue, ), - child: item.title, + child: item.title!, ), ), ), @@ -216,8 +213,8 @@ class _BottomNavigationTile extends StatelessWidget { } /// 构建未读消息弹窗 - Widget _buildBadge() { - if (item.badge == null && (item.badgeNo == null || item.badgeNo.isEmpty)) { + Widget? _buildBadge() { + if (item.badge == null && (item.badgeNo == null || item.badgeNo!.isEmpty)) { return Container(); } if (item.badge != null) { @@ -233,7 +230,7 @@ class _BottomNavigationTile extends StatelessWidget { borderRadius: BorderRadius.all(Radius.circular(10))), child: Text( /// 设置未读数 > item.maxBadgeNo 则报加+ 默认 99 - '${int.parse(item.badgeNo) > item.maxBadgeNo ? '${item.maxBadgeNo}+' : item.badgeNo}', + '${int.parse(item.badgeNo!) > item.maxBadgeNo ? '${item.maxBadgeNo}+' : item.badgeNo}', style: TextStyle(fontSize: 10, color: Colors.white), ), ); @@ -241,7 +238,7 @@ class _BottomNavigationTile extends StatelessWidget { /// 构建底字体缩放动画 /// label: 传入的文字组件 - Widget _buildInkWidget(Widget label) { + Widget _buildInkWidget(Widget? label) { if (isInkResponse) { return InkResponse( onTap: onTap, @@ -251,7 +248,7 @@ class _BottomNavigationTile extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ _buildIcon(), - label, + label!, ], ), ); @@ -264,7 +261,7 @@ class _BottomNavigationTile extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ _buildIcon(), - label, + label!, ], )); } @@ -275,15 +272,15 @@ class _BottomNavigationTile extends StatelessWidget { /// 需要将flex分配中的更改划分为更小的块 /// 制作流畅的动画。我们通过将flex值相乘来实现这一点 /// (这是一个整数)乘以一个大数。 - int size; - Widget label; + late int size; + Widget? label; switch (type) { case BrnBottomTabBarDisplayType.fixed: size = 1; label = _buildFixedLabel(); break; case BrnBottomTabBarDisplayType.shifting: - size = (flex * 1000.0).round(); + size = (flex! * 1000.0).round(); label = _buildShiftingLabel(); break; } @@ -296,7 +293,7 @@ class _BottomNavigationTile extends StatelessWidget { selected: selected, child: Stack( children: [ - Positioned(right: 4, top: 4, child: _buildBadge()), + Positioned(right: 4, top: 4, child: _buildBadge()!), _buildInkWidget(label), Semantics( label: indexLabel, @@ -312,13 +309,13 @@ class _BottomNavigationTile extends StatelessWidget { class _BottomTabBarState extends State with TickerProviderStateMixin { List _controllers = []; - List _animations; + late List _animations; /// 当前正在执行图标变色逻辑的队列 final Queue<_Circle> _circles = Queue<_Circle>(); /// 执行完动画之后的背景颜色 - Color _backgroundColor; + Color? _backgroundColor; static final Animatable _flexTween = Tween(begin: 1.0, end: 1.5); @@ -375,7 +372,7 @@ class _BottomTabBarState extends State _Circle( state: this, index: index, - color: widget.items[index].backgroundColor, + color: widget.items[index].backgroundColor!, vsync: this, )..controller.addStatusListener( (AnimationStatus status) { @@ -429,13 +426,12 @@ class _BottomTabBarState extends State List _createTiles() { final MaterialLocalizations localizations = MaterialLocalizations.of(context); - assert(localizations != null); final List children = []; switch (widget.type) { case BrnBottomTabBarDisplayType.fixed: final ThemeData themeData = Theme.of(context); final TextTheme textTheme = themeData.textTheme; - Color themeColor; + Color? themeColor; switch (themeData.brightness) { case Brightness.light: themeColor = themeData.primaryColor; @@ -445,7 +441,7 @@ class _BottomTabBarState extends State break; } final ColorTween colorTween = ColorTween( - begin: textTheme.caption.color, + begin: textTheme.caption!.color, end: widget.fixedColor ?? themeColor, ); for (int i = 0; i < widget.items.length; i += 1) { @@ -456,7 +452,7 @@ class _BottomTabBarState extends State _animations[i], widget.iconSize, onTap: () { - if (widget.onTap != null) widget.onTap(i); + if (widget.onTap != null) widget.onTap!(i); }, colorTween: colorTween, selected: i == widget.currentIndex, @@ -480,7 +476,7 @@ class _BottomTabBarState extends State _animations[i], widget.iconSize, onTap: () { - if (widget.onTap != null) widget.onTap(i); + if (widget.onTap != null) widget.onTap!(i); }, flex: _evaluateFlex(_animations[i]), selected: i == widget.currentIndex, @@ -520,7 +516,7 @@ class _BottomTabBarState extends State /// 下标题距底部距离 final double additionalBottomPadding = math.max(MediaQuery.of(context).padding.bottom - _kBottomMargin, 0.0); - Color backgroundColor; + Color? backgroundColor; switch (widget.type) { case BrnBottomTabBarDisplayType.fixed: break; @@ -579,13 +575,11 @@ class _BottomTabBarState extends State /// 功能:实现点击飞溅动画 class _Circle { _Circle({ - @required this.state, - @required this.index, - @required this.color, - @required TickerProvider vsync, - }) : assert(state != null), - assert(index != null), - assert(color != null) { + required this.state, + required this.index, + required this.color, + required TickerProvider vsync, + }) { controller = AnimationController( duration: kThemeAnimationDuration, vsync: vsync, @@ -600,8 +594,8 @@ class _Circle { final _BottomTabBarState state; final int index; final Color color; - AnimationController controller; - CurvedAnimation animation; + late AnimationController controller; + late CurvedAnimation animation; double get horizontalLeadingOffset { double weightSum(Iterable> animations) { @@ -631,10 +625,9 @@ class _Circle { /// 绘制动画色彩飞溅的圆圈 class _RadialPainter extends CustomPainter { _RadialPainter({ - @required this.circles, - @required this.textDirection, - }) : assert(circles != null), - assert(textDirection != null); + required this.circles, + required this.textDirection, + }); final List<_Circle> circles; final TextDirection textDirection; @@ -663,7 +656,7 @@ class _RadialPainter extends CustomPainter { final Paint paint = Paint()..color = circle.color; final Rect rect = Rect.fromLTWH(0.0, 0.0, size.width, size.height); canvas.clipRect(rect); - double leftFraction; + late double leftFraction; switch (textDirection) { case TextDirection.rtl: leftFraction = 1.0 - circle.horizontalLeadingOffset; diff --git a/lib/src/components/tabbar/indicator/brn_custom_width_indicator.dart b/lib/src/components/tabbar/indicator/brn_custom_width_indicator.dart index f305e256..a3d36225 100644 --- a/lib/src/components/tabbar/indicator/brn_custom_width_indicator.dart +++ b/lib/src/components/tabbar/indicator/brn_custom_width_indicator.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:flutter/material.dart'; @@ -27,35 +27,35 @@ class CustomWidthUnderlineTabIndicator extends Decoration { final double width; @override - Decoration lerpFrom(Decoration a, double t) { + Decoration? lerpFrom(Decoration? a, double t) { if (a is CustomWidthUnderlineTabIndicator) { return CustomWidthUnderlineTabIndicator( borderSide: BorderSide.lerp(a.borderSide, borderSide, t), - insets: EdgeInsetsGeometry.lerp(a.insets, insets, t), + insets: EdgeInsetsGeometry.lerp(a.insets, insets, t)!, ); } return super.lerpFrom(a, t); } @override - Decoration lerpTo(Decoration b, double t) { + Decoration? lerpTo(Decoration? b, double t) { if (b is CustomWidthUnderlineTabIndicator) { return CustomWidthUnderlineTabIndicator( borderSide: BorderSide.lerp(borderSide, b.borderSide, t), - insets: EdgeInsetsGeometry.lerp(insets, b.insets, t), + insets: EdgeInsetsGeometry.lerp(insets, b.insets, t)!, ); } return super.lerpTo(b, t); } @override - _UnderlinePainter createBoxPainter([VoidCallback onChanged]) { + _UnderlinePainter createBoxPainter([VoidCallback? onChanged]) { return _UnderlinePainter(this, width, onChanged); } } class _UnderlinePainter extends BoxPainter { - _UnderlinePainter(this.decoration, this.width, VoidCallback onChanged) + _UnderlinePainter(this.decoration, this.width, VoidCallback? onChanged) : assert(decoration != null), super(onChanged); @@ -72,7 +72,7 @@ class _UnderlinePainter extends BoxPainter { assert(textDirection != null); final Rect indicator = insets.resolve(textDirection).deflateRect(rect); //希望的宽度 - double wantWidth = width ?? 24; + double wantWidth = width; //取中间坐标 double cw = (indicator.left + indicator.right) / 2; return Rect.fromLTWH(cw - wantWidth / 2, @@ -83,8 +83,8 @@ class _UnderlinePainter extends BoxPainter { void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { assert(configuration != null); assert(configuration.size != null); - final Rect rect = offset & configuration.size; - final TextDirection textDirection = configuration.textDirection; + final Rect rect = offset & configuration.size!; + final TextDirection textDirection = configuration.textDirection!; final Rect indicator = _indicatorRectFor(rect, textDirection).deflate(borderSide.width / 2.0); final Paint paint = borderSide.toPaint()..strokeCap = StrokeCap.round; diff --git a/lib/src/components/tabbar/indicator/brn_fixed_underline_decoration.dart b/lib/src/components/tabbar/indicator/brn_fixed_underline_decoration.dart index 7641a3f1..f0a27e8a 100644 --- a/lib/src/components/tabbar/indicator/brn_fixed_underline_decoration.dart +++ b/lib/src/components/tabbar/indicator/brn_fixed_underline_decoration.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -48,35 +48,35 @@ class BrnFixedUnderlineIndicator extends Decoration { final Color color; @override - Decoration lerpFrom(Decoration a, double t) { + Decoration? lerpFrom(Decoration? a, double t) { if (a is BrnFixedUnderlineIndicator) { return BrnFixedUnderlineIndicator( borderSide: BorderSide.lerp(a.borderSide, borderSide, t), - insets: EdgeInsetsGeometry.lerp(a.insets, insets, t), + insets: EdgeInsetsGeometry.lerp(a.insets, insets, t)!, ); } return super.lerpFrom(a, t); } @override - Decoration lerpTo(Decoration b, double t) { + Decoration? lerpTo(Decoration? b, double t) { if (b is BrnFixedUnderlineIndicator) { return BrnFixedUnderlineIndicator( borderSide: BorderSide.lerp(borderSide, b.borderSide, t), - insets: EdgeInsetsGeometry.lerp(insets, b.insets, t), + insets: EdgeInsetsGeometry.lerp(insets, b.insets, t)!, ); } return super.lerpTo(b, t); } @override - _FixedUnderlinePainter createBoxPainter([VoidCallback onChanged]) { + _FixedUnderlinePainter createBoxPainter([VoidCallback? onChanged]) { return _FixedUnderlinePainter(this, onChanged); } } class _FixedUnderlinePainter extends BoxPainter { - _FixedUnderlinePainter(this.decoration, VoidCallback onChanged) + _FixedUnderlinePainter(this.decoration, VoidCallback? onChanged) : assert(decoration != null), super(onChanged); @@ -102,8 +102,8 @@ class _FixedUnderlinePainter extends BoxPainter { void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { assert(configuration != null); assert(configuration.size != null); - final Rect rect = offset & configuration.size; - final TextDirection textDirection = configuration.textDirection; + final Rect rect = offset & configuration.size!; + final TextDirection textDirection = configuration.textDirection!; final Rect indicator = _indicatorRectFor(rect, textDirection).deflate(borderSide.width / 2.0); final Paint paint = borderSide.toPaint()..strokeCap = StrokeCap.square; diff --git a/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart b/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart index 8375f46e..82925132 100644 --- a/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart +++ b/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; /// 三角形指示器 参考ShapeDecoration class BrnTriangleIndicator extends Decoration { - final Color color; // 指示器颜色 + final Color? color; // 指示器颜色 final double lineWidth; final double triWidth; // 三角形底边长 final double triHeight; // 三角形高 - final Gradient gradient; - final DecorationImage image; - final List shadows; - final ShapeBorder shape; + final Gradient? gradient; + final DecorationImage? image; + final List? shadows; + final ShapeBorder? shape; const BrnTriangleIndicator({ this.color = Colors.white, @@ -30,23 +30,23 @@ class BrnTriangleIndicator extends Decoration { }); factory BrnTriangleIndicator.fromBoxDecoration(BoxDecoration source) { - ShapeBorder shape; + ShapeBorder? shape; assert(source.shape != null); switch (source.shape) { case BoxShape.circle: if (source.border != null) { - assert(source.border.isUniform); - shape = CircleBorder(side: source.border.top); + assert(source.border!.isUniform); + shape = CircleBorder(side: source.border!.top); } else { shape = const CircleBorder(); } break; case BoxShape.rectangle: if (source.borderRadius != null) { - assert(source.border == null || source.border.isUniform); + assert(source.border == null || source.border!.isUniform); shape = RoundedRectangleBorder( side: source.border?.top ?? BorderSide.none, - borderRadius: source.borderRadius, + borderRadius: source.borderRadius!, ); } else { shape = source.border ?? const Border(); @@ -67,35 +67,35 @@ class BrnTriangleIndicator extends Decoration { /// /// This value may be misleading. See the discussion at [ShapeBorder.dimensions]. @override - EdgeInsets get padding => shape.dimensions; + EdgeInsets get padding => shape!.dimensions as EdgeInsets; @override bool get isComplex => shadows != null; @override - BrnTriangleIndicator lerpFrom(Decoration a, double t) { + BrnTriangleIndicator? lerpFrom(Decoration? a, double t) { if (a is BoxDecoration) { return BrnTriangleIndicator.lerp( BrnTriangleIndicator.fromBoxDecoration(a), this, t); } else if (a == null || a is BrnTriangleIndicator) { - return BrnTriangleIndicator.lerp(a, this, t); + return BrnTriangleIndicator.lerp(a as BrnTriangleIndicator?, this, t); } - return super.lerpFrom(a, t); + return super.lerpFrom(a, t) as BrnTriangleIndicator?; } @override - BrnTriangleIndicator lerpTo(Decoration b, double t) { + BrnTriangleIndicator? lerpTo(Decoration? b, double t) { if (b is BoxDecoration) { return BrnTriangleIndicator.lerp( this, BrnTriangleIndicator.fromBoxDecoration(b), t); } else if (b == null || b is BrnTriangleIndicator) { - return BrnTriangleIndicator.lerp(this, b, t); + return BrnTriangleIndicator.lerp(this, b as BrnTriangleIndicator?, t); } - return super.lerpTo(b, t); + return super.lerpTo(b, t) as BrnTriangleIndicator?; } - static BrnTriangleIndicator lerp( - BrnTriangleIndicator a, BrnTriangleIndicator b, double t) { + static BrnTriangleIndicator? lerp( + BrnTriangleIndicator? a, BrnTriangleIndicator? b, double t) { assert(t != null); if (a == null && b == null) return null; if (a != null && b != null) { @@ -105,7 +105,7 @@ class BrnTriangleIndicator extends Decoration { return BrnTriangleIndicator( color: Color.lerp(a?.color, b?.color, t), gradient: Gradient.lerp(a?.gradient, b?.gradient, t), - image: t < 0.5 ? a.image : b.image, + image: t < 0.5 ? a!.image : b!.image, shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t), ); @@ -156,14 +156,14 @@ class BrnTriangleIndicator extends Decoration { } @override - bool hitTest(Size size, Offset position, {TextDirection textDirection}) { - return shape + bool hitTest(Size size, Offset position, {TextDirection? textDirection}) { + return shape! .getOuterPath(Offset.zero & size, textDirection: textDirection) .contains(position); } @override - _TriangleDecorationPainter createBoxPainter([VoidCallback onChanged]) { + _TriangleDecorationPainter createBoxPainter([VoidCallback? onChanged]) { assert(onChanged != null || image == null); Path path = Path(); Paint paint = Paint()..isAntiAlias = true; @@ -174,7 +174,7 @@ class BrnTriangleIndicator extends Decoration { /// An object that paints a [BrnTriangleIndicator] into a canvas. class _TriangleDecorationPainter extends BoxPainter { _TriangleDecorationPainter( - this._decoration, this._path, this._paint, VoidCallback onChanged) + this._decoration, this._path, this._paint, VoidCallback? onChanged) : assert(_decoration != null), super(onChanged); @@ -197,7 +197,7 @@ class _TriangleDecorationPainter extends BoxPainter { _path.lineTo(_vertexX + width / 2, _vertexY + height / 2); _path.close(); - _paint..color = _decoration.color; + _paint..color = _decoration.color!; _paint..strokeWidth = _decoration.lineWidth; canvas.drawPath(_path, _paint); @@ -213,7 +213,7 @@ class _TriangleDecorationPainter extends BoxPainter { void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { assert(configuration != null); assert(configuration.size != null); - final Rect rect = offset & configuration.size; + final Rect rect = offset & configuration.size!; _paintTriangle(canvas, offset, rect, configuration); } diff --git a/lib/src/components/tabbar/normal/brn_sub_switch_title.dart b/lib/src/components/tabbar/normal/brn_sub_switch_title.dart index edbc73ea..47d43f5c 100644 --- a/lib/src/components/tabbar/normal/brn_sub_switch_title.dart +++ b/lib/src/components/tabbar/normal/brn_sub_switch_title.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/material.dart'; @@ -14,18 +14,18 @@ class BrnSubSwitchTitle extends StatefulWidget { final int defaultSelectIndex; /// 选中回调 - final void Function(int index) onSelect; + final void Function(int index)? onSelect; /// 二级标题的padding /// 默认 EdgeInsets.only(right: 20) - final EdgeInsets padding; + final EdgeInsets? padding; /// tab切换控制器,默认不需要传递 - final TabController controller; + final TabController? controller; const BrnSubSwitchTitle({ - Key key, - @required this.nameList, + Key? key, + required this.nameList, this.defaultSelectIndex = 0, this.onSelect, this.padding, @@ -38,9 +38,9 @@ class BrnSubSwitchTitle extends StatefulWidget { class _BrnSubSwitchTitleState extends State with TickerProviderStateMixin { - List widgetList; + List? widgetList; - TabController _controller; + TabController? _controller; int _defaultSelectIndex = 0; @@ -51,7 +51,7 @@ class _BrnSubSwitchTitleState extends State _controller = widget.controller ?? TabController( initialIndex: _defaultSelectIndex, - length: widget.nameList?.length ?? 0, + length: widget.nameList.length, vsync: this, ); } @@ -61,7 +61,7 @@ class _BrnSubSwitchTitleState extends State super.didUpdateWidget(oldWidget); _defaultSelectIndex = widget.defaultSelectIndex; if (_controller != null) { - _controller.index = _defaultSelectIndex; + _controller!.index = _defaultSelectIndex; } } @@ -71,7 +71,7 @@ class _BrnSubSwitchTitleState extends State } Widget _toggleButtonsWidget(context) { - if (widget.nameList == null || widget.nameList.isEmpty) { + if (widget.nameList.isEmpty) { return Container( height: 0, width: 0, @@ -117,7 +117,7 @@ class _BrnSubSwitchTitleState extends State ), onTap: (index) { if (null != widget.onSelect) { - widget.onSelect(index); + widget.onSelect!(index); } }, ); diff --git a/lib/src/components/tabbar/normal/brn_switch_title.dart b/lib/src/components/tabbar/normal/brn_switch_title.dart index 10c2cf2f..2ddcdba4 100644 --- a/lib/src/components/tabbar/normal/brn_switch_title.dart +++ b/lib/src/components/tabbar/normal/brn_switch_title.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/line/brn_line.dart'; import 'package:bruno/src/components/tabbar/indicator/brn_custom_width_indicator.dart'; @@ -17,7 +17,7 @@ class BrnSwitchTitle extends StatefulWidget { /// 选中时的回调 /// index 选中的title的索引 - final void Function(int index) onSelect; + final void Function(int index)? onSelect; /// 标题的 padding,默认 `EdgeInsets.fromLTRB(0, 14, 20, 14)` final EdgeInsets padding; @@ -30,17 +30,17 @@ class BrnSwitchTitle extends StatefulWidget { /// 控制tab切换,默认不需要传递 /// 只在需要外部控制tab切换时传递 - final TabController controller; + final TabController? controller; /// 选中时的标题样式,默认 `TextStyle(fontWeight: FontWeight.w600,fontSize: 18)` - final TextStyle selectedTextStyle; + final TextStyle? selectedTextStyle; /// 未选中时的标题样式,默认 `TextStyle(fontWeight: FontWeight.w600,fontSize: 18)` - final TextStyle unselectedTextStyle; + final TextStyle? unselectedTextStyle; const BrnSwitchTitle( - {Key key, - @required this.nameList, + {Key? key, + required this.nameList, this.defaultSelectIndex = 0, this.onSelect, this.indicatorWeight = 2.0, @@ -59,7 +59,7 @@ class _BrnSwitchTitleState extends State with TickerProviderStateMixin { static final Color _color = Color(0XFF243238); - TabController _controller; + TabController? _controller; int _defaultSelectIndex = 0; @@ -68,7 +68,7 @@ class _BrnSwitchTitleState extends State super.didUpdateWidget(oldWidget); _defaultSelectIndex = widget.defaultSelectIndex; if (_controller != null) { - _controller.index = _defaultSelectIndex; + _controller!.index = _defaultSelectIndex; } } @@ -86,7 +86,7 @@ class _BrnSwitchTitleState extends State @override Widget build(BuildContext context) { - if (widget.nameList != null && widget.nameList.length > 1) { + if (widget.nameList.length > 1) { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -112,7 +112,7 @@ class _BrnSwitchTitleState extends State Text tx = Text(name); /// 有下划线的时候,需要将下划线的高度3减去 - double tempBottomPadding = widget.padding?.bottom ?? 0; + double tempBottomPadding = widget.padding.bottom; double bottomPadding = widget.nameList.length == 1 ? tempBottomPadding : tempBottomPadding - 3; @@ -122,20 +122,20 @@ class _BrnSwitchTitleState extends State return Container( padding: EdgeInsets.fromLTRB( - widget.padding?.left ?? 0, - widget.padding?.top ?? 0, - widget.padding?.right ?? 0, + widget.padding.left, + widget.padding.top, + widget.padding.right, bottomPadding), child: tx, ); }).toList(); Decoration _indicator = CustomWidthUnderlineTabIndicator( - width: widget.indicatorWidth ?? 24.0, + width: widget.indicatorWidth, insets: EdgeInsets.only( - left: widget.padding?.left ?? 0, right: widget.padding?.right ?? 0), + left: widget.padding.left, right: widget.padding.right), borderSide: BorderSide( - width: widget.indicatorWeight ?? 2.0, + width: widget.indicatorWeight, color: BrnThemeConfigurator.instance.getConfig().commonConfig.brandPrimary, ), @@ -175,7 +175,7 @@ class _BrnSwitchTitleState extends State indicatorWeight: 0, onTap: (index) { if (null != widget.onSelect && widget.nameList.length > 1) { - widget.onSelect(index); + widget.onSelect!(index); } }, ), diff --git a/lib/src/components/tabbar/normal/brn_tab_bar.dart b/lib/src/components/tabbar/normal/brn_tab_bar.dart index 06a6aa12..86f7a346 100644 --- a/lib/src/components/tabbar/normal/brn_tab_bar.dart +++ b/lib/src/components/tabbar/normal/brn_tab_bar.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:ui'; @@ -22,7 +22,7 @@ typedef BrnTabBarOnTap = Function(BrnTabBarState state, int index); // ignore: must_be_immutable class BrnTabBar extends StatefulWidget { /// BrnTabBarBadge填充的数据,长度匹配控制器的TabController.length - final List tabs; + final List? tabs; /// [BrnTabBar] 的tab模式 /// 默认:[BrnTabBarBadgeMode.average](按照屏幕平均分配模式) @@ -32,51 +32,51 @@ class BrnTabBar extends StatefulWidget { final bool isScroll; /// Tabbar的整体高度 - final double tabHeight; + final double? tabHeight; /// TabBar的padding final EdgeInsetsGeometry padding; /// 控制Tab的切换 - final TabController controller; + final TabController? controller; /// TabBar背景颜色 final Color backgroundcolor; /// 指示器的颜色 - final Color indicatorColor; + final Color? indicatorColor; /// 指示器的高度 - final double indicatorWeight; + final double? indicatorWeight; /// 指示器的宽度 - final double indicatorWidth; + final double? indicatorWidth; final EdgeInsetsGeometry indicatorPadding; /// 选中Tab文本的颜色 - final Color labelColor; + final Color? labelColor; /// 选中Tab文本的样式 - final TextStyle labelStyle; + final TextStyle? labelStyle; /// Tab文本的Padding final EdgeInsetsGeometry labelPadding; /// 未选中Tab文本的颜色 - final Color unselectedLabelColor; + final Color? unselectedLabelColor; /// 未中Tab文本的样式 - final TextStyle unselectedLabelStyle; + final TextStyle? unselectedLabelStyle; /// 处理拖拽开始行为方式,默认DragStartBehavior.start final DragStartBehavior dragStartBehavior; /// Tab的选中点击事件 - final BrnTabBarOnTap onTap; + final BrnTabBarOnTap? onTap; /// 添加的Tab的宽度(指定tabWidth就不会均分屏幕宽度) - final double tabWidth; + final double? tabWidth; /// 是否显示分隔线 final bool hasDivider; @@ -88,27 +88,27 @@ class BrnTabBar extends StatefulWidget { final bool showMore; /// 展开更多弹框标题 - final String moreWindowText; + final String? moreWindowText; /// 更多弹框弹出的时候 - final VoidCallback onMorePop; + final VoidCallback? onMorePop; /// 更多弹框关闭控制器 - final BrnCloseWindowController closeController; + final BrnCloseWindowController? closeController; /// tag间距 - final double tagSpacing; + final double? tagSpacing; /// 每行tag数 - final int preLineTagCount; + final int? preLineTagCount; /// tag高度 - final double tagHeight; + final double? tagHeight; - BrnTabBarConfig themeData; + BrnTabBarConfig? themeData; BrnTabBar({ - @required this.tabs, + required this.tabs, this.mode = BrnTabBarBadgeMode.average, this.isScroll = false, this.tabHeight, @@ -139,7 +139,7 @@ class BrnTabBar extends StatefulWidget { this.tagHeight, }) : assert(tabs == null || tabs is List) { this.themeData ??= BrnTabBarConfig(); - this.themeData = this.themeData.merge(BrnTabBarConfig( + this.themeData = this.themeData!.merge(BrnTabBarConfig( tabHeight: tabHeight, indicatorHeight: indicatorWeight, indicatorWidth: indicatorWidth, @@ -150,7 +150,7 @@ class BrnTabBar extends StatefulWidget { tagHeight: tagHeight, )); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .tabBarConfig .merge(this.themeData); } @@ -170,33 +170,33 @@ enum BrnTabBarBadgeMode { class BrnTabBarState extends State { /// 小红点容器的样式 - BadgeShape _badgeShape; + late BadgeShape _badgeShape; /// 小红点文案 - String _badgeText; + late String _badgeText; /// 小红点容器内边距 - EdgeInsets _badgePadding; + late EdgeInsets _badgePadding; /// 小红点上偏移量 - double _paddingTop; + late double _paddingTop = 0; /// 小红点右偏移量 - double _paddingRight; + late double _paddingRight = 0; /// 小红点圆角 - BorderRadiusGeometry _borderRadius; + late BorderRadiusGeometry _borderRadius; /// 展开更多的按钮宽度 final double _moreSpacing = 50; /// BrnTabBarBadge展开更多数据处理控制器 - BrnTabbarController _brnTabbarController; + late BrnTabbarController _brnTabbarController; /// BrnTabBarBadge展开更多关闭处理控制器 - BrnCloseWindowController _closeWindowController; + BrnCloseWindowController? _closeWindowController; - BrnTabBarState(BrnCloseWindowController closeController) { + BrnTabBarState(BrnCloseWindowController? closeController) { this._closeWindowController = closeController; } @@ -205,11 +205,11 @@ class BrnTabBarState extends State { super.initState(); _brnTabbarController = BrnTabbarController(); // 监听更多弹框tab选中变化的时候 - _brnTabbarController?.addListener(() { + _brnTabbarController.addListener(() { _closeWindowController?.syncWindowState(_brnTabbarController.isShow); // 更新TabBar选中位置 if (widget.controller != null) { - widget.controller.animateTo(_brnTabbarController.selectIndex); + widget.controller!.animateTo(_brnTabbarController.selectIndex); } // 刷新选中TabBar小红点 refreshBadgeState(_brnTabbarController.selectIndex); @@ -217,10 +217,10 @@ class BrnTabBarState extends State { setState(() {}); }); - _closeWindowController?.getCloseController()?.stream?.listen((event) { - _brnTabbarController?.hide(); - _brnTabbarController?.entry?.remove(); - _brnTabbarController?.entry = null; + _closeWindowController?.getCloseController().stream.listen((event) { + _brnTabbarController.hide(); + _brnTabbarController.entry?.remove(); + _brnTabbarController.entry = null; }); widget.controller?.addListener(_handleTabIndexChangeTick); @@ -233,10 +233,10 @@ class BrnTabBarState extends State { } void _handleTabIndexChangeTick() { - if (widget.controller.index.toDouble() == - widget.controller.animation.value) { - _brnTabbarController?.selectIndex = widget.controller?.index ?? 0; - _brnTabbarController?.isShow = false; + if (widget.controller!.index.toDouble() == + widget.controller!.animation!.value) { + _brnTabbarController.selectIndex = widget.controller?.index ?? 0; + _brnTabbarController.isShow = false; } } @@ -244,8 +244,8 @@ class BrnTabBarState extends State { Widget build(BuildContext context) { return Container( padding: widget.padding, - constraints: BoxConstraints(minHeight: widget.themeData.tabHeight), - color: widget.themeData.backgroundColor, + constraints: BoxConstraints(minHeight: widget.themeData!.tabHeight), + color: widget.themeData!.backgroundColor, child: widget.showMore ? Row( children: [ @@ -265,34 +265,34 @@ class BrnTabBarState extends State { return TabBar( tabs: fillWidgetByDataList(), controller: widget.controller, - isScrollable: widget.tabs.length > 4 || + isScrollable: widget.tabs!.length > 4 || widget.tabWidth != null || widget.isScroll, - labelColor: widget.labelColor ?? widget.themeData.labelStyle.color, + labelColor: widget.labelColor ?? widget.themeData!.labelStyle.color, labelStyle: widget.labelStyle ?? - widget.themeData.labelStyle.generateTextStyle(), + widget.themeData!.labelStyle.generateTextStyle(), labelPadding: widget.labelPadding, unselectedLabelColor: widget.unselectedLabelColor ?? - widget.themeData.unselectedLabelStyle.color, + widget.themeData!.unselectedLabelStyle.color, unselectedLabelStyle: widget.unselectedLabelStyle ?? - widget.themeData.unselectedLabelStyle.generateTextStyle(), + widget.themeData!.unselectedLabelStyle.generateTextStyle(), dragStartBehavior: widget.dragStartBehavior, onTap: (index) { if (widget.onTap != null) { - widget.onTap(this, index); - _brnTabbarController?.setSelectIndex(index); - _brnTabbarController?.isShow = false; - _brnTabbarController?.entry?.remove(); - _brnTabbarController?.entry = null; + widget.onTap!(this, index); + _brnTabbarController.setSelectIndex(index); + _brnTabbarController.isShow = false; + _brnTabbarController.entry?.remove(); + _brnTabbarController.entry = null; } }, indicator: CustomWidthUnderlineTabIndicator( insets: widget.indicatorPadding, borderSide: BorderSide( - width: widget.themeData.indicatorHeight, - color: widget.indicatorColor ?? widget.themeData.labelStyle.color, + width: widget.themeData!.indicatorHeight, + color: widget.indicatorColor ?? widget.themeData!.labelStyle.color!, ), - width: widget.themeData.indicatorWidth, + width: widget.themeData!.indicatorWidth, )); } @@ -303,11 +303,11 @@ class BrnTabBarState extends State { child: GestureDetector( onTap: () { if (!_brnTabbarController.isShow && - widget.controller.index.toDouble() == - widget.controller.animation.value) { - _brnTabbarController?.show(); + widget.controller!.index.toDouble() == + widget.controller!.animation!.value) { + _brnTabbarController.show(); if (widget.onMorePop != null) { - widget.onMorePop(); + widget.onMorePop!(); } showMoreWindow(context); setState(() {}); @@ -318,7 +318,7 @@ class BrnTabBarState extends State { }, child: Container( width: _moreSpacing, - height: widget.themeData.tabHeight, + height: widget.themeData!.tabHeight, decoration: BoxDecoration( color: Colors.white, boxShadow: [ @@ -339,7 +339,7 @@ class BrnTabBarState extends State { // 更新选中tab的小红点状态 void refreshBadgeState(int index) { setState(() { - BadgeTab badgeTab = widget.tabs[index]; + BadgeTab badgeTab = widget.tabs![index]; if (badgeTab != null && badgeTab.isAutoDismiss) { badgeTab.badgeNum = null; badgeTab.badgeText = null; @@ -349,10 +349,10 @@ class BrnTabBarState extends State { } List fillWidgetByDataList() { - List widgets = List(); - List tabList = widget.tabs; + List widgets = []; + List? tabList = widget.tabs; if (tabList != null && tabList.isNotEmpty) { - double minWidth; + double? minWidth; if (widget.tabWidth != null) { minWidth = widget.tabWidth; } else { @@ -399,11 +399,11 @@ class BrnTabBarState extends State { )), Badge( showBadge: (badgeTab.badgeNum != null - ? badgeTab.badgeNum > 0 + ? badgeTab.badgeNum! > 0 : false) || badgeTab.showRedBadge || (badgeTab.badgeText != null - ? badgeTab.badgeText.isNotEmpty + ? badgeTab.badgeText!.isNotEmpty : false), badgeContent: Text( _badgeText, @@ -418,7 +418,7 @@ class BrnTabBarState extends State { padding: _badgePadding, position: BadgePosition.topEnd(top: _paddingTop, end: _paddingRight), - child: Text(badgeTab.text, + child: Text(badgeTab.text!, maxLines: 1, softWrap: true, overflow: TextOverflow.ellipsis), @@ -440,7 +440,7 @@ class BrnTabBarState extends State { // 定制的等分tab样式 Widget _wrapAverageWidget( - BadgeTab badgeTab, double minWidth, bool lastElement) { + BadgeTab badgeTab, double? minWidth, bool lastElement) { caculateBadgeParams(badgeTab); return Container( width: minWidth, @@ -464,11 +464,11 @@ class BrnTabBarState extends State { )), Badge( showBadge: (badgeTab.badgeNum != null - ? badgeTab.badgeNum > 0 + ? badgeTab.badgeNum! > 0 : false) || badgeTab.showRedBadge || (badgeTab.badgeText != null - ? badgeTab.badgeText.isNotEmpty + ? badgeTab.badgeText!.isNotEmpty : false), badgeContent: Text( _badgeText, @@ -483,7 +483,7 @@ class BrnTabBarState extends State { padding: _badgePadding, position: BadgePosition.topEnd( top: _paddingTop, end: _paddingRight), - child: Text(badgeTab.text, + child: Text(badgeTab.text!, maxLines: 1, softWrap: true, overflow: TextOverflow.ellipsis), @@ -507,14 +507,14 @@ class BrnTabBarState extends State { // 计算小红点尺寸相关参数 void caculateBadgeParams(BadgeTab badgeTab) { if (badgeTab.badgeNum != null) { - if (badgeTab.badgeNum < 10) { + if (badgeTab.badgeNum! < 10) { _badgePadding = EdgeInsets.all(5); _badgeShape = BadgeShape.circle; _badgeText = badgeTab.badgeNum?.toString() ?? ""; _paddingTop = -8; _paddingRight = -18; _borderRadius = BorderRadius.all(Radius.circular(8.5)); - } else if (badgeTab.badgeNum > 99) { + } else if (badgeTab.badgeNum! > 99) { _badgePadding = EdgeInsets.fromLTRB(4, 3, 4, 2); _badgeShape = BadgeShape.square; _badgeText = "99+"; @@ -530,7 +530,7 @@ class BrnTabBarState extends State { _borderRadius = BorderRadius.all(Radius.circular(8.5)); } } else { - if (badgeTab.badgeText != null && badgeTab.badgeText.isNotEmpty) { + if (badgeTab.badgeText != null && badgeTab.badgeText!.isNotEmpty) { _badgePadding = EdgeInsets.fromLTRB(5, 3, 5, 2); _badgeShape = BadgeShape.square; _badgeText = badgeTab.badgeText?.toString() ?? ""; @@ -553,7 +553,7 @@ class BrnTabBarState extends State { // 展开更多 void showMoreWindow(BuildContext context) { - final RenderBox dropDownItemRenderBox = context.findRenderObject(); + final RenderBox dropDownItemRenderBox = context.findRenderObject() as RenderBox; var position = dropDownItemRenderBox.localToGlobal(Offset.zero, ancestor: null); var size = dropDownItemRenderBox.size; @@ -591,10 +591,10 @@ class BrnTabBarState extends State { tabs: widget.tabs, moreWindowText: widget.moreWindowText, brnTabbarController: _brnTabbarController, - themeData: widget.themeData, - spacing: widget.themeData.tagSpacing, - preLineTagCount: widget.themeData.preLineTagCount, - tagHeight: widget.themeData.tagHeight, + themeData: widget.themeData!, + spacing: widget.themeData!.tagSpacing, + preLineTagCount: widget.themeData!.preLineTagCount, + tagHeight: widget.themeData!.tagHeight, ), ), ), @@ -610,17 +610,17 @@ class BrnTabBarState extends State { resetEntry(); } _brnTabbarController.entry = overlayEntry; - Overlay.of(context).insert(_brnTabbarController.entry); + Overlay.of(context)!.insert(_brnTabbarController.entry!); } void resetEntry() { - _brnTabbarController.entry.remove(); + _brnTabbarController.entry!.remove(); _brnTabbarController.entry = null; } void hideMoreWindow() { - if (_brnTabbarController?.isShow ?? false) { - _brnTabbarController?.hide(); + if (_brnTabbarController.isShow) { + _brnTabbarController.hide(); resetEntry(); } } @@ -629,28 +629,28 @@ class BrnTabBarState extends State { // 更多弹框样式 // ignore: must_be_immutable class _TabBarOverlayWidget extends StatefulWidget { - List tabs; + List? tabs; - String moreWindowText; + String? moreWindowText; - BrnTabbarController brnTabbarController; + BrnTabbarController? brnTabbarController; BrnTabBarConfig themeData; /// tag间距 - double spacing; + double? spacing; /// 每行tag数 - int preLineTagCount; + int? preLineTagCount; /// tag高度 - double tagHeight; + double? tagHeight; _TabBarOverlayWidget( {this.tabs, this.moreWindowText, this.brnTabbarController, - this.themeData, + required this.themeData, this.spacing, this.preLineTagCount, this.tagHeight}); @@ -661,7 +661,7 @@ class _TabBarOverlayWidget extends StatefulWidget { class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { /// tag宽度 - double _tagWidth; + double? _tagWidth; double _padding = 20; @@ -698,7 +698,7 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { children: [ Visibility( visible: widget.moreWindowText != null && - widget.moreWindowText.isNotEmpty, + widget.moreWindowText!.isNotEmpty, child: Padding( padding: EdgeInsets.only(bottom: 16), child: Text( @@ -726,12 +726,12 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { Widget _createMoreItems() { // 计算tag的宽度 _tagWidth = (_parentWidth - - widget.spacing * (widget.preLineTagCount - 1) - + widget.spacing! * (widget.preLineTagCount! - 1) - _padding * 2) / - widget.preLineTagCount; + widget.preLineTagCount!; - List widgets = List(); - List tabList = widget.tabs; + List widgets = []; + List? tabList = widget.tabs; if (tabList != null && tabList.isNotEmpty) { for (int i = 0; i < tabList.length; i++) { BadgeTab badgeTab = tabList[i]; @@ -739,7 +739,7 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { } } return Wrap( - spacing: widget.spacing, + spacing: widget.spacing!, runSpacing: 12, children: widgets, ); @@ -748,14 +748,14 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { Widget _createMoreItemWidget(BadgeTab badgeTab, int index) { return GestureDetector( onTap: () { - if (widget.brnTabbarController.selectIndex == index) { + if (widget.brnTabbarController!.selectIndex == index) { widget.brnTabbarController?.setSelectIndex(index); widget.brnTabbarController?.isShow = false; widget.brnTabbarController?.entry?.remove(); widget.brnTabbarController?.entry = null; setState(() {}); } else { - widget.brnTabbarController.setSelectIndex(index); + widget.brnTabbarController!.setSelectIndex(index); widget.brnTabbarController?.isShow = false; widget.brnTabbarController?.entry?.remove(); widget.brnTabbarController?.entry = null; @@ -765,21 +765,21 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { child: Container( alignment: Alignment.center, decoration: BoxDecoration( - color: widget.brnTabbarController.selectIndex == index + color: widget.brnTabbarController!.selectIndex == index ? widget.themeData.tagSelectedBgColor : widget.themeData.tagNormalBgColor, borderRadius: BorderRadius.circular(widget.themeData.tagRadius)), height: widget.tagHeight, width: _tagWidth, child: Text( - badgeTab.text, + badgeTab.text!, textAlign: TextAlign.center, maxLines: 1, softWrap: true, overflow: TextOverflow.ellipsis, - style: widget.brnTabbarController.selectIndex == index - ? widget.themeData.tagSelectedTextStyle?.generateTextStyle() - : widget.themeData.tagNormalTextStyle?.generateTextStyle(), + style: widget.brnTabbarController!.selectIndex == index + ? widget.themeData.tagSelectedTextStyle.generateTextStyle() + : widget.themeData.tagNormalTextStyle.generateTextStyle(), ), ), ); @@ -796,19 +796,19 @@ class BadgeTab { this.showRedBadge = false, this.isAutoDismiss = true}); - final Key key; + final Key? key; /// Tab文本 - final String text; + final String? text; /// 红点数字 - int badgeNum; + int? badgeNum; /// tab顶部文本信息 - String topText; + String? topText; /// 红点显示的文本 - String badgeText; + String? badgeText; /// 是否显示小红点,默认badgeNum没设置,不显示 bool showRedBadge; diff --git a/lib/src/components/tabbar/normal/brn_tabbar_controller.dart b/lib/src/components/tabbar/normal/brn_tabbar_controller.dart index 3ed1c24c..f68b2a6b 100644 --- a/lib/src/components/tabbar/normal/brn_tabbar_controller.dart +++ b/lib/src/components/tabbar/normal/brn_tabbar_controller.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:async'; @@ -8,7 +8,7 @@ class BrnTabbarController extends ChangeNotifier { /// /// 更多选项距离顶部距离 /// - double top; + late double top; /// /// 是否显示更多选项弹框 @@ -18,12 +18,12 @@ class BrnTabbarController extends ChangeNotifier { /// /// 屏幕高度 /// - double screenHeight; + double? screenHeight; /// /// 展开更多图层 /// - OverlayEntry entry; + OverlayEntry? entry; /// /// 选中的角标 @@ -47,7 +47,7 @@ class BrnTabbarController extends ChangeNotifier { } class CloseWindowEvent { - bool isShow = false; + bool? isShow = false; CloseWindowEvent({this.isShow}); } @@ -76,6 +76,6 @@ class BrnCloseWindowController { } void closeMoreWindow() { - _closeController?.add(CloseWindowEvent()); + _closeController.add(CloseWindowEvent()); } } From 103ab13472ffdbebe5b20f87cdb71b06aa7df1a5 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 11 Jan 2022 18:27:29 +0800 Subject: [PATCH 13/31] Migrated scroll_anchor to null-safety --- .../scroll_anchor/brn_scroll_anchor_tab.dart | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart b/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart index b9bcb32a..8e6f841d 100644 --- a/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart +++ b/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:async'; import 'dart:ui'; @@ -20,15 +20,15 @@ class BrnAnchorTab extends StatefulWidget { final BrnAnchorTabBarStyle tabBarStyle; final AnchorTabWidgetIndexedBuilder widgetIndexedBuilder; final AnchorTabIndexedBuilder tabIndexedBuilder; - final Widget tabDivider; + final Widget? tabDivider; //设置tab与widget的个数 final int itemCount; BrnAnchorTab( - {@required this.widgetIndexedBuilder, - @required this.tabIndexedBuilder, - @required this.itemCount, + {required this.widgetIndexedBuilder, + required this.tabIndexedBuilder, + required this.itemCount, this.tabDivider, this.tabBarStyle = const BrnAnchorTabBarStyle()}); @@ -40,31 +40,31 @@ class BrnAnchorTab extends StatefulWidget { class _BrnScrollAnchorTabWidgetState extends State with SingleTickerProviderStateMixin { //用于控制 滑动 - ScrollController scrollController; + late ScrollController scrollController; //用于 滑动 和 tab 之间的通信 - StreamController streamController; + late StreamController streamController; //用于控制tab - TabController tabController; + late TabController tabController; //滑动组件的 key - GlobalKey key; + late GlobalKey key; //当前选中的索引 - int currentIndex; + int currentIndex = 0; //滑动组件的元素、 - List bodyWidgetList; + late List bodyWidgetList; //滑动组件的元素的key - List bodyKeyList; + late List bodyKeyList; //每个元素在滑动组件中的位置 - List cardOffsetList; + late List cardOffsetList; //tab - List tabList; + late List tabList; //是否点击滑动 bool tab = false; @@ -79,18 +79,17 @@ class _BrnScrollAnchorTabWidgetState extends State key = GlobalKey(); cardOffsetList = List.filled(widget.itemCount, -1.0); - bodyWidgetList = List(); - bodyKeyList = List(); - tabList = List(); + bodyWidgetList = []; + bodyKeyList = []; + tabList = []; - currentIndex = 0; tabController = TabController(length: widget.itemCount, vsync: this); fillKeyList(); fillList(); fillTab(); - WidgetsBinding.instance.addPostFrameCallback((da) { + WidgetsBinding.instance!.addPostFrameCallback((da) { fillOffset(); scrollController.addListener(() { updateOffset(); @@ -108,7 +107,7 @@ class _BrnScrollAnchorTabWidgetState extends State return Column( mainAxisSize: MainAxisSize.min, children: [ - StreamBuilder( + StreamBuilder( initialData: currentIndex, stream: streamController.stream, builder: (context, snap) { @@ -160,14 +159,12 @@ class _BrnScrollAnchorTabWidgetState extends State } void fillList() { - if (widget.widgetIndexedBuilder != null) { - for (int i = 0, n = widget.itemCount; i < n; i++) { - bodyWidgetList.add( - Container( - key: bodyKeyList[i], - child: widget.widgetIndexedBuilder(context, i)), - ); - } + for (int i = 0, n = widget.itemCount; i < n; i++) { + bodyWidgetList.add( + Container( + key: bodyKeyList[i], + child: widget.widgetIndexedBuilder(context, i)), + ); } } @@ -178,7 +175,7 @@ class _BrnScrollAnchorTabWidgetState extends State } void fillOffset() { - Offset globalToLocal = (key.currentContext.findRenderObject() as RenderBox) + Offset globalToLocal = (key.currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero); listDy = globalToLocal.dy; @@ -186,7 +183,7 @@ class _BrnScrollAnchorTabWidgetState extends State if (cardOffsetList[i] == -1.0) if (bodyKeyList[i].currentContext != null) { double cardOffset = - (bodyKeyList[i].currentContext.findRenderObject() as RenderBox) + (bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero) //相对于原点 控件的位置 .dy; //y点坐标 @@ -196,11 +193,9 @@ class _BrnScrollAnchorTabWidgetState extends State } void fillTab() { - if (widget.tabIndexedBuilder != null) { for (int i = 0, n = widget.itemCount; i < n; i++) { tabList.add(widget.tabIndexedBuilder(context, i)); } - } } void updateOffset() { @@ -208,7 +203,7 @@ class _BrnScrollAnchorTabWidgetState extends State if (cardOffsetList[i] == -1.0) if (bodyKeyList[i].currentContext != null) { double cardOffset = - (bodyKeyList[i].currentContext.findRenderObject() as RenderBox) + (bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero) //相对于原点 控件的位置 .dy; //y点坐标 @@ -238,21 +233,21 @@ class _BrnScrollAnchorTabWidgetState extends State } class BrnAnchorTabBarStyle { - final Color indicatorColor; + final Color? indicatorColor; final double indicatorWeight; final EdgeInsetsGeometry indicatorPadding; - final Color labelColor; + final Color? labelColor; - final Color unselectedLabelColor; + final Color? unselectedLabelColor; - final TextStyle labelStyle; + final TextStyle? labelStyle; - final EdgeInsetsGeometry labelPadding; + final EdgeInsetsGeometry? labelPadding; - final TextStyle unselectedLabelStyle; + final TextStyle? unselectedLabelStyle; final DragStartBehavior dragStartBehavior; From 5748da7ba1093a8dd00e82db5a89ca80e205f0af Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Mon, 17 Jan 2022 15:43:04 +0800 Subject: [PATCH 14/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=BF=81=E7=A7=BBt?= =?UTF-8?q?abar=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scroll_anchor/brn_scroll_anchor_tab.dart | 86 +++++++++---------- .../bottom/brn_bottom_tab_bar_main.dart | 14 ++- .../indicator/brn_triangle_decoration.dart | 2 +- .../components/tabbar/normal/brn_tab_bar.dart | 21 +++-- .../tabbar/normal/brn_tabbar_controller.dart | 2 +- 5 files changed, 68 insertions(+), 57 deletions(-) diff --git a/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart b/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart index 8e6f841d..29b3fea2 100644 --- a/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart +++ b/lib/src/components/scroll_anchor/brn_scroll_anchor_tab.dart @@ -40,31 +40,31 @@ class BrnAnchorTab extends StatefulWidget { class _BrnScrollAnchorTabWidgetState extends State with SingleTickerProviderStateMixin { //用于控制 滑动 - late ScrollController scrollController; + late ScrollController _scrollController; //用于 滑动 和 tab 之间的通信 - late StreamController streamController; + late StreamController _streamController; //用于控制tab - late TabController tabController; + late TabController _tabController; //滑动组件的 key - late GlobalKey key; + late GlobalKey _key; //当前选中的索引 int currentIndex = 0; //滑动组件的元素、 - late List bodyWidgetList; + late List _bodyWidgetList; //滑动组件的元素的key - late List bodyKeyList; + late List _bodyKeyList; //每个元素在滑动组件中的位置 - late List cardOffsetList; + late List _cardOffsetList; //tab - late List tabList; + late List _tabList; //是否点击滑动 bool tab = false; @@ -74,16 +74,16 @@ class _BrnScrollAnchorTabWidgetState extends State @override void initState() { - streamController = StreamController(); - scrollController = ScrollController(); + _streamController = StreamController(); + _scrollController = ScrollController(); - key = GlobalKey(); - cardOffsetList = List.filled(widget.itemCount, -1.0); - bodyWidgetList = []; - bodyKeyList = []; - tabList = []; + _key = GlobalKey(); + _cardOffsetList = List.filled(widget.itemCount, -1.0); + _bodyWidgetList = []; + _bodyKeyList = []; + _tabList = []; - tabController = TabController(length: widget.itemCount, vsync: this); + _tabController = TabController(length: widget.itemCount, vsync: this); fillKeyList(); fillList(); @@ -91,11 +91,11 @@ class _BrnScrollAnchorTabWidgetState extends State WidgetsBinding.instance!.addPostFrameCallback((da) { fillOffset(); - scrollController.addListener(() { + _scrollController.addListener(() { updateOffset(); - currentIndex = createIndex(scrollController.offset); + currentIndex = createIndex(_scrollController.offset); //防止再次 发送消息 - if (!tab) streamController.add(currentIndex); + if (!tab) _streamController.add(currentIndex); }); }); @@ -109,9 +109,9 @@ class _BrnScrollAnchorTabWidgetState extends State children: [ StreamBuilder( initialData: currentIndex, - stream: streamController.stream, + stream: _streamController.stream, builder: (context, snap) { - tabController.index = currentIndex; + _tabController.index = currentIndex; return BrnTabBar( indicatorColor: widget.tabBarStyle.indicatorColor, indicatorWeight: widget.tabBarStyle.indicatorWeight, @@ -122,14 +122,14 @@ class _BrnScrollAnchorTabWidgetState extends State unselectedLabelColor: widget.tabBarStyle.unselectedLabelColor, unselectedLabelStyle: widget.tabBarStyle.unselectedLabelStyle, dragStartBehavior: widget.tabBarStyle.dragStartBehavior, - controller: tabController, - tabs: tabList, + controller: _tabController, + tabs: _tabList, onTap: (state, index) { state.refreshBadgeState(index); currentIndex = index; tab = true; - scrollController - .animateTo(cardOffsetList[index], + _scrollController + .animateTo(_cardOffsetList[index], duration: Duration(milliseconds: 100), curve: Curves.linear) .whenComplete(() { @@ -148,10 +148,10 @@ class _BrnScrollAnchorTabWidgetState extends State child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, - children: bodyWidgetList, + children: _bodyWidgetList, ), - key: key, - controller: scrollController, + key: _key, + controller: _scrollController, ), ) ], @@ -160,9 +160,9 @@ class _BrnScrollAnchorTabWidgetState extends State void fillList() { for (int i = 0, n = widget.itemCount; i < n; i++) { - bodyWidgetList.add( + _bodyWidgetList.add( Container( - key: bodyKeyList[i], + key: _bodyKeyList[i], child: widget.widgetIndexedBuilder(context, i)), ); } @@ -170,44 +170,44 @@ class _BrnScrollAnchorTabWidgetState extends State void fillKeyList() { for (int i = 0, n = widget.itemCount; i < n; i++) { - bodyKeyList.add(GlobalKey()); + _bodyKeyList.add(GlobalKey()); } } void fillOffset() { - Offset globalToLocal = (key.currentContext!.findRenderObject() as RenderBox) + Offset globalToLocal = (_key.currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero); listDy = globalToLocal.dy; for (int i = 0, n = widget.itemCount; i < n; i++) { - if (cardOffsetList[i] == -1.0) if (bodyKeyList[i].currentContext != + if (_cardOffsetList[i] == -1.0) if (_bodyKeyList[i].currentContext != null) { double cardOffset = - (bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) + (_bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero) //相对于原点 控件的位置 .dy; //y点坐标 - cardOffsetList[i] = cardOffset + scrollController.offset - listDy; + _cardOffsetList[i] = cardOffset + _scrollController.offset - listDy; } } } void fillTab() { for (int i = 0, n = widget.itemCount; i < n; i++) { - tabList.add(widget.tabIndexedBuilder(context, i)); + _tabList.add(widget.tabIndexedBuilder(context, i)); } } void updateOffset() { for (int i = 0, n = widget.itemCount; i < n; i++) { - if (cardOffsetList[i] == -1.0) if (bodyKeyList[i].currentContext != + if (_cardOffsetList[i] == -1.0) if (_bodyKeyList[i].currentContext != null) { double cardOffset = - (bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) + (_bodyKeyList[i].currentContext!.findRenderObject() as RenderBox) .localToGlobal(Offset.zero) //相对于原点 控件的位置 .dy; //y点坐标 - cardOffsetList[i] = cardOffset + scrollController.offset - listDy; + _cardOffsetList[i] = cardOffset + _scrollController.offset - listDy; } } } @@ -216,7 +216,7 @@ class _BrnScrollAnchorTabWidgetState extends State int createIndex(double offset) { int index = 0; for (int i = 0, n = widget.itemCount; i < n; i++) { - if (offset >= cardOffsetList[i] && (offset <= cardOffsetList[i + 1])) { + if (offset >= _cardOffsetList[i] && (offset <= _cardOffsetList[i + 1])) { return i; } } @@ -226,9 +226,9 @@ class _BrnScrollAnchorTabWidgetState extends State @override void dispose() { super.dispose(); - tabController.dispose(); - streamController.close(); - scrollController.dispose(); + _tabController.dispose(); + _streamController.close(); + _scrollController.dispose(); } } diff --git a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart index 1ff2b67d..40cb9016 100644 --- a/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart +++ b/lib/src/components/tabbar/bottom/brn_bottom_tab_bar_main.dart @@ -230,12 +230,24 @@ class _BottomNavigationTile extends StatelessWidget { borderRadius: BorderRadius.all(Radius.circular(10))), child: Text( /// 设置未读数 > item.maxBadgeNo 则报加+ 默认 99 - '${int.parse(item.badgeNo!) > item.maxBadgeNo ? '${item.maxBadgeNo}+' : item.badgeNo}', + _getUnReadText(), style: TextStyle(fontSize: 10, color: Colors.white), ), ); } + String _getUnReadText(){ + int _badgeNo = 0; + try { + if (item.badgeNo != null) { + _badgeNo = int.parse(item.badgeNo!); + } + } catch (e) { + debugPrint('badgeNo has FormatException'); + } + return '${_badgeNo > item.maxBadgeNo ? '${item.maxBadgeNo}+' : _badgeNo}'; + } + /// 构建底字体缩放动画 /// label: 传入的文字组件 Widget _buildInkWidget(Widget? label) { diff --git a/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart b/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart index 82925132..60bccfb6 100644 --- a/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart +++ b/lib/src/components/tabbar/indicator/brn_triangle_decoration.dart @@ -105,7 +105,7 @@ class BrnTriangleIndicator extends Decoration { return BrnTriangleIndicator( color: Color.lerp(a?.color, b?.color, t), gradient: Gradient.lerp(a?.gradient, b?.gradient, t), - image: t < 0.5 ? a!.image : b!.image, + image: t < 0.5 ? a?.image : b?.image, shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t), ); diff --git a/lib/src/components/tabbar/normal/brn_tab_bar.dart b/lib/src/components/tabbar/normal/brn_tab_bar.dart index 86f7a346..b1c16e4a 100644 --- a/lib/src/components/tabbar/normal/brn_tab_bar.dart +++ b/lib/src/components/tabbar/normal/brn_tab_bar.dart @@ -1,5 +1,3 @@ - - import 'dart:ui'; import 'package:badges/badges.dart'; @@ -179,10 +177,10 @@ class BrnTabBarState extends State { late EdgeInsets _badgePadding; /// 小红点上偏移量 - late double _paddingTop = 0; + double _paddingTop = 0; /// 小红点右偏移量 - late double _paddingRight = 0; + double _paddingRight = 0; /// 小红点圆角 late BorderRadiusGeometry _borderRadius; @@ -233,8 +231,8 @@ class BrnTabBarState extends State { } void _handleTabIndexChangeTick() { - if (widget.controller!.index.toDouble() == - widget.controller!.animation!.value) { + if (widget.controller?.index.toDouble() == + widget.controller?.animation?.value) { _brnTabbarController.selectIndex = widget.controller?.index ?? 0; _brnTabbarController.isShow = false; } @@ -553,7 +551,8 @@ class BrnTabBarState extends State { // 展开更多 void showMoreWindow(BuildContext context) { - final RenderBox dropDownItemRenderBox = context.findRenderObject() as RenderBox; + final RenderBox dropDownItemRenderBox = + context.findRenderObject() as RenderBox; var position = dropDownItemRenderBox.localToGlobal(Offset.zero, ancestor: null); var size = dropDownItemRenderBox.size; @@ -572,7 +571,7 @@ class BrnTabBarState extends State { }, child: Container( padding: EdgeInsets.only( - top: _brnTabbarController.top, + top: _brnTabbarController.top!, ), child: Stack( children: [ @@ -584,7 +583,7 @@ class BrnTabBarState extends State { child: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - - _brnTabbarController.top, + _brnTabbarController.top!, child: Padding( padding: EdgeInsets.all(0), child: _TabBarOverlayWidget( @@ -614,7 +613,7 @@ class BrnTabBarState extends State { } void resetEntry() { - _brnTabbarController.entry!.remove(); + _brnTabbarController.entry?.remove(); _brnTabbarController.entry = null; } @@ -772,7 +771,7 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { height: widget.tagHeight, width: _tagWidth, child: Text( - badgeTab.text!, + badgeTab.text ?? '', textAlign: TextAlign.center, maxLines: 1, softWrap: true, diff --git a/lib/src/components/tabbar/normal/brn_tabbar_controller.dart b/lib/src/components/tabbar/normal/brn_tabbar_controller.dart index f68b2a6b..b0337c54 100644 --- a/lib/src/components/tabbar/normal/brn_tabbar_controller.dart +++ b/lib/src/components/tabbar/normal/brn_tabbar_controller.dart @@ -8,7 +8,7 @@ class BrnTabbarController extends ChangeNotifier { /// /// 更多选项距离顶部距离 /// - late double top; + double? top; /// /// 是否显示更多选项弹框 From 1c33fd99505dd109dea954b55bd418c1e5d71723 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 18 Jan 2022 14:43:41 +0800 Subject: [PATCH 15/31] migrate form to null safety --- .../items_example/step_input_example.dart | 2 - .../form/base/brn_form_item_type.dart | 2 +- .../form/base/input_item_interface.dart | 6 +- .../general/brn_multi_choice_input_item.dart | 109 ++++++--------- .../brn_multi_choice_portrait_input_item.dart | 113 +++++++--------- .../general/brn_quick_select_input_item.dart | 105 +++++++------- .../items/general/brn_radio_input_item.dart | 96 +++++++------ .../brn_radio_portrait_input_item.dart | 61 ++++----- .../items/general/brn_range_input_item.dart | 67 +++++---- .../items/general/brn_ratio_input_item.dart | 38 +++--- .../items/general/brn_star_input_item.dart | 28 ++-- .../items/general/brn_step_input_item.dart | 110 ++++++--------- .../general/brn_text_block_input_item.dart | 60 ++++---- .../items/general/brn_text_input_item.dart | 57 ++++---- .../items/general/brn_text_select_item.dart | 58 ++++---- .../general/brn_title_select_input_item.dart | 114 ++++++++-------- .../form/items/group/brn_expand_group.dart | 42 +++--- .../form/items/group/brn_normal_group.dart | 47 +++---- .../items/group/element_expand_widget.dart | 45 +++--- .../form/items/misc/brn_add_label_item.dart | 16 +-- .../form/items/misc/brn_title_item.dart | 36 +++-- .../form/items/title/brn_base_title_item.dart | 32 ++--- .../title/brn_select_all_title_item.dart | 61 ++++----- .../undetermined/brn_expandable_group.dart | 40 +++--- .../brn_portrait_radio_group.dart | 101 +++++++------- .../components/form/utils/brn_form_util.dart | 128 ++++++++---------- 26 files changed, 727 insertions(+), 847 deletions(-) diff --git a/example/lib/sample/components/form/items_example/step_input_example.dart b/example/lib/sample/components/form/items_example/step_input_example.dart index 950a70bc..a52ebdea 100644 --- a/example/lib/sample/components/form/items_example/step_input_example.dart +++ b/example/lib/sample/components/form/items_example/step_input_example.dart @@ -63,7 +63,6 @@ class StepInputExamplePage extends StatelessWidget { title: "自然到访保护期", subTitle: "这里是副标题", tipLabel: "标签", - value: 0, maxLimit: 5, minLimit: 1, onTip: () { @@ -96,7 +95,6 @@ class StepInputExamplePage extends StatelessWidget { title: "自然到访保护期", subTitle: "这里是副标题", tipLabel: "标签", - value: 0, maxLimit: 5, minLimit: 1, onTip: () { diff --git a/lib/src/components/form/base/brn_form_item_type.dart b/lib/src/components/form/base/brn_form_item_type.dart index 9a19b6f2..7b03723e 100644 --- a/lib/src/components/form/base/brn_form_item_type.dart +++ b/lib/src/components/form/base/brn_form_item_type.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + class BrnPrefixIconType { static const String TYPE_NORMAL = "type_normal"; diff --git a/lib/src/components/form/base/input_item_interface.dart b/lib/src/components/form/base/input_item_interface.dart index 232b3216..13662ce4 100644 --- a/lib/src/components/form/base/input_item_interface.dart +++ b/lib/src/components/form/base/input_item_interface.dart @@ -1,17 +1,17 @@ /// 用于model兼容回调 /// 主要用于各种点击事件 -// @dart=2.9 + typedef OnBrnFormSelectAll = void Function(int index, bool isSelect); /// 主要用于各种输入值变化 typedef OnBrnFormRadioValueChanged = void Function( - String oldStr, String newStr); + String? oldStr, String? newStr); typedef OnBrnFormSwitchChanged = void Function(bool oldValue, bool newValue); typedef OnBrnFormValueChanged = void Function(int oldValue, int newValue); typedef OnBrnFormMultiChoiceValueChanged = void Function( - List oldValue, List newValue); + List oldValue, List? newValue); typedef OnBrnFormBtnSelectChanged = void Function( List oldValue, List newValue); diff --git a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart index 74aa6c2a..59fb57ee 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart @@ -1,10 +1,7 @@ -// @dart=2.9 - import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; -import 'package:bruno/src/components/radio/brn_radio_core.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -19,23 +16,23 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnMultiChoiceInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.MULTI_CHOICE_INPUT_TYPE; + final String type = BrnInputItemType.MULTI_CHOICE_INPUT_TYPE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,51 +47,51 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 特殊字段 - List value; + final List value; /// 内容 - List options; + final List options; /// 局部禁用list - List enableList; + final List enableList; /// 选项选中状态变化回调 - final OnBrnFormMultiChoiceValueChanged onChanged; + final OnBrnFormMultiChoiceValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnMultiChoiceInputFormItem( - {Key key, + {Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: true, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = true, this.onAddTap, this.onRemoveTap, this.onTip, - this.value, - this.options, - this.enableList, + this.value = const [], + this.options = const [], + this.enableList = const [], this.onChanged, this.themeData}) : super() { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -108,11 +105,10 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { class BrnMultiChoiceInputFormItemState extends State { // 标记选项的选中状态,内部变量无须初始化。初始化选中状态通过设置value字段设置 - List _selectStatus; + List? _selectStatus; @override void initState() { - _initSpecialParams(); _initSelectedStatus(); super.initState(); } @@ -170,8 +166,8 @@ class BrnMultiChoiceInputFormItemState ); } - List getCheckboxList(List options) { - List result = List(); + List getCheckboxList(List? options) { + List result = []; if (options == null || options.isEmpty) { result.add(Container()); return result; @@ -196,18 +192,18 @@ class BrnMultiChoiceInputFormItemState radioIndex: index, disable: getRadioEnableState(index), isSelected: - (_selectStatus != null && pos < _selectStatus.length) - ? _selectStatus[pos] + (_selectStatus != null && pos < _selectStatus!.length) + ? _selectStatus![pos]! : false, onValueChangedAtIndex: (position, value) { - _selectStatus[position] = value; - List oldValue = List()..addAll(widget.value); + _selectStatus![position] = value; + List oldValue = []..addAll(widget.value); setState(() { widget.value.clear(); - for (int i = 0; i < _selectStatus.length; ++i) { - if (_selectStatus[i]) { + for (int i = 0; i < _selectStatus!.length; ++i) { + if (_selectStatus![i]!) { widget.value.add(widget.options[i]); } } @@ -226,13 +222,13 @@ class BrnMultiChoiceInputFormItemState return result; } - TextStyle getOptionTextStyle(int index) { - TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (index < 0 || index >= _selectStatus.length) { + TextStyle? getOptionTextStyle(int index) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + if (index < 0 || index >= _selectStatus!.length) { return result; } - if (_selectStatus[index]) { + if (_selectStatus![index]!) { result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); } @@ -240,8 +236,7 @@ class BrnMultiChoiceInputFormItemState result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); } - if (widget.enableList != null && - widget.enableList.isNotEmpty && + if (widget.enableList.isNotEmpty && widget.enableList.length > index && !widget.enableList[index]) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); @@ -255,41 +250,25 @@ class BrnMultiChoiceInputFormItemState return true; } - if (widget.enableList == null || - widget.enableList.isEmpty || - widget.enableList.length < index) { + if (widget.enableList.isEmpty || widget.enableList.length < index) { return false; } return !widget.enableList[index]; } - void _initSpecialParams() { - if (widget.value == null) { - widget.value = List(); - } - - if (widget.options == null) { - widget.options = List(); - } - - if (widget.enableList == null) { - widget.enableList = List(); - } - } - void _initSelectedStatus() { - if (widget.options != null && widget.options.isNotEmpty) { - _selectStatus = List(widget.options.length); + if (widget.options.isNotEmpty) { + _selectStatus = List.filled(widget.options.length, false); } else { - _selectStatus = List(); + _selectStatus = []; } - for (int index = 0; index < _selectStatus.length; ++index) { - _selectStatus[index] = false; + for (int index = 0; index < _selectStatus!.length; ++index) { + _selectStatus![index] = false; } - if (widget.value == null || widget.value.isEmpty) { + if (widget.value.isEmpty) { return; } @@ -299,7 +278,7 @@ class BrnMultiChoiceInputFormItemState if (pos < 0) { return; } - _selectStatus[pos] = true; + _selectStatus![pos] = true; } } } diff --git a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart index c8de97fb..0e52bf9c 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart @@ -1,11 +1,8 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/line/brn_line.dart'; import 'package:bruno/src/components/radio/brn_checkbox.dart'; -import 'package:bruno/src/components/radio/brn_radio_core.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -20,7 +17,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.MULTI_CHOICE_PORTRAIT_INPUT_TYPE; @@ -29,14 +26,14 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -51,51 +48,51 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 特殊字段 - List value; + final List value; /// 内容 - List options; + final List options; /// 局部禁用list - List enableList; + final List enableList; /// 选项选中状态变化回调 - final OnBrnFormMultiChoiceValueChanged onChanged; + final OnBrnFormMultiChoiceValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnMultiChoicePortraitInputFormItem( - {Key key, + {Key? key, this.label, - this.title: "", - this.subTitle, + this.title = "", + this.subTitle = "", this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, this.onAddTap, this.onRemoveTap, this.onTip, - this.value, - this.options, - this.enableList, + this.value = const [], + this.options = const [], + this.enableList = const [], this.onChanged, this.themeData}) : super() { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -109,11 +106,10 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { class BrnMultiChoicePortraitInputFormItemState extends State { // 标记选项的选中状态,内部变量无须初始化。初始化选中状态通过设置value字段设置 - List _selectStatus; + List? _selectStatus; @override void initState() { - _initSpecialParams(); _initSelectedStatus(); super.initState(); } @@ -172,8 +168,8 @@ class BrnMultiChoicePortraitInputFormItemState ); } - List getCheckboxList(List options) { - List result = List(); + List getCheckboxList(List? options) { + List result = []; if (options == null || options.isEmpty) { result.add(Container()); return result; @@ -192,18 +188,18 @@ class BrnMultiChoicePortraitInputFormItemState mainAxisSize: MainAxisSize.max, radioIndex: index, disable: getRadioEnableState(index), - isSelected: (_selectStatus != null && index < _selectStatus.length) - ? _selectStatus[index] + isSelected: (_selectStatus != null && index < _selectStatus!.length) + ? _selectStatus![index]! : false, onValueChangedAtIndex: (position, value) { - _selectStatus[position] = value; - List oldValue = List()..addAll(widget.value); + _selectStatus![position] = value; + List oldValue = []..addAll(widget.value); setState(() { widget.value.clear(); - for (int i = 0; i < _selectStatus.length; ++i) { - if (_selectStatus[i]) { + for (int i = 0; i < _selectStatus!.length; ++i) { + if (_selectStatus![i]!) { widget.value.add(widget.options[i]); } } @@ -220,22 +216,21 @@ class BrnMultiChoicePortraitInputFormItemState return result; } - TextStyle getOptionTextStyle(int index) { - TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (index < 0 || index >= _selectStatus.length) { + TextStyle? getOptionTextStyle(int index) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + if (index < 0 || index >= _selectStatus!.length) { return result; } - if (_selectStatus[index]) { + if (_selectStatus![index]!) { result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); } - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); } - if (widget.enableList != null && - widget.enableList.isNotEmpty && + if (widget.enableList.isNotEmpty && widget.enableList.length > index && !widget.enableList[index]) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); @@ -245,45 +240,29 @@ class BrnMultiChoicePortraitInputFormItemState } bool getRadioEnableState(int index) { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return true; } - if (widget.enableList == null || - widget.enableList.isEmpty || - widget.enableList.length < index) { + if (widget.enableList.isEmpty || widget.enableList.length < index) { return false; } return !widget.enableList[index]; } - void _initSpecialParams() { - if (widget.value == null) { - widget.value = List(); - } - - if (widget.options == null) { - widget.options = List(); - } - - if (widget.enableList == null) { - widget.enableList = List(); - } - } - void _initSelectedStatus() { - if (widget.options != null && widget.options.isNotEmpty) { - _selectStatus = List(widget.options.length); + if (widget.options.isNotEmpty) { + _selectStatus = List.filled(widget.options.length, false); } else { - _selectStatus = List(); + _selectStatus = []; } - for (int index = 0; index < _selectStatus.length; ++index) { - _selectStatus[index] = false; + for (int index = 0; index < _selectStatus!.length; ++index) { + _selectStatus![index] = false; } - if (widget.value == null || widget.value.isEmpty) { + if (widget.value.isEmpty) { return; } @@ -293,7 +272,7 @@ class BrnMultiChoicePortraitInputFormItemState if (pos < 0) { return; } - _selectStatus[pos] = true; + _selectStatus![pos] = true; } } } diff --git a/lib/src/components/form/items/general/brn_quick_select_input_item.dart b/lib/src/components/form/items/general/brn_quick_select_input_item.dart index 8bf54770..5acb1bfa 100644 --- a/lib/src/components/form/items/general/brn_quick_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_quick_select_input_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; @@ -19,7 +19,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnTextQuickSelectFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.TEXT_QUICK_SELECT_INPUT_TYPE; @@ -28,14 +28,14 @@ class BrnTextQuickSelectFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,44 +50,44 @@ class BrnTextQuickSelectFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 点击录入区回调 - final VoidCallback onTap; + final VoidCallback? onTap; - final ValueChanged onBtnSelectChanged; + final ValueChanged? onBtnSelectChanged; /// 录入项 hint 提示 final String hint; /// 录入项 值 - String value; + String? value; /// 快捷操作按钮选项文案列表 - List btnsTxt; + List? btnsTxt; /// 快捷按钮区的初始选中状态,可不传,则内部自动生成并维护 - List selectBtnList; + List? selectBtnList; /// 快捷按钮区的是否可用状态,可不传,内部生成并维护 - List enableBtnList; + List? enableBtnList; /// 用户自定义快捷按钮视图 - Widget btns; + Widget? btns; /// 快捷按钮较多时是否可滑动,默认为 fasle,不可滑动 final bool isBtnsScroll; - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTextQuickSelectFormItem( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -112,7 +112,7 @@ class BrnTextQuickSelectFormItem extends StatefulWidget { : super(key: key) { themeData ??= BrnFormItemConfig(); themeData = BrnThemeConfigurator.instance - .getConfig(configId: themeData.configId) + .getConfig(configId: themeData!.configId) .formItemConfig .merge(themeData); } @@ -174,7 +174,7 @@ class BrnTextQuickSelectFormItemState } if (widget.onTap != null) { - widget.onTap(); + widget.onTap!(); } }, child: Row( @@ -217,9 +217,9 @@ class BrnTextQuickSelectFormItemState } Widget buildText() { - if (widget.value != null && widget.value.isNotEmpty) { + if (widget.value != null && widget.value!.isNotEmpty) { return Text( - widget.value, + widget.value!, textAlign: TextAlign.end, style: BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit), ); @@ -235,23 +235,23 @@ class BrnTextQuickSelectFormItemState // ignore: must_be_immutable class QuickButtonsWidget extends StatefulWidget { - List btnsTxt; - List selectBtnList; - List enableBtnList; - Widget btns; - bool isBtnsScroll; + List? btnsTxt; + List? selectBtnList; + List? enableBtnList; + Widget? btns; + bool? isBtnsScroll; bool isEdit; - ValueChanged onBtnSelectChanged; + ValueChanged? onBtnSelectChanged; QuickButtonsWidget({ - Key key, + Key? key, this.btnsTxt, this.selectBtnList, this.enableBtnList, this.btns, this.isBtnsScroll, - this.isEdit: true, + this.isEdit = true, this.onBtnSelectChanged, }); @@ -272,7 +272,7 @@ class QuickButtonsState extends State { @override Widget build(BuildContext context) { - return getQuickButtons(); + return getQuickButtons()!; } @override @@ -294,15 +294,15 @@ class QuickButtonsState extends State { if (widget.selectBtnList == null) { _useInnerStatus = true; - widget.selectBtnList = List.filled(widget.btnsTxt.length, false); + widget.selectBtnList = List.filled(widget.btnsTxt!.length, false); } if (widget.enableBtnList == null) { - widget.enableBtnList = List.filled(widget.btnsTxt.length, true); + widget.enableBtnList = List.filled(widget.btnsTxt!.length, true); } } - Widget getQuickButtons() { + Widget? getQuickButtons() { if (!widget.isEdit) { return Container(); } @@ -310,7 +310,7 @@ class QuickButtonsState extends State { if (widget.btns != null) { return widget.btns; } else if (widget.btnsTxt != null) { - if (widget.isBtnsScroll) { + if (widget.isBtnsScroll!) { return ListView( scrollDirection: Axis.horizontal, children: getBtnsByText(), @@ -329,13 +329,8 @@ class QuickButtonsState extends State { List getBtnsByText() { List result = []; - for (int index = 0; index < widget.btnsTxt.length; ++index) { - String str = widget.btnsTxt[index]; - - if (str == null) { - continue; - } - + for (int index = 0; index < widget.btnsTxt!.length; ++index) { + String? str = widget.btnsTxt![index]; result.add(Container( padding: EdgeInsets.fromLTRB(6, 0, 6, 0), child: FlatButton( @@ -352,16 +347,16 @@ class QuickButtonsState extends State { onPressed: () { if (!widget.isEdit || (widget.enableBtnList != null && - !widget.enableBtnList[index])) { + !widget.enableBtnList![index])) { return; } if (widget.onBtnSelectChanged != null) { - widget.onBtnSelectChanged(index); + widget.onBtnSelectChanged!(index); } if (_useInnerStatus) { // 如果是内部维护的状态,需要改变按钮的状态 - widget.selectBtnList[index] = - widget.selectBtnList[index] ? false : true; + widget.selectBtnList![index] = + widget.selectBtnList![index] ? false : true; } setState(() {}); /* @@ -386,20 +381,20 @@ class QuickButtonsState extends State { } Color getButtonColor(int index) { - if (widget.btnsTxt != null && widget.btnsTxt.isEmpty) { + if (widget.btnsTxt != null && widget.btnsTxt!.isEmpty) { return Color(0xFFF8F8F8); } /// 这个按钮不可点击 if (widget.enableBtnList != null && - index < widget.enableBtnList.length && - !widget.enableBtnList[index]) { + index < widget.enableBtnList!.length && + !widget.enableBtnList![index]) { return Color(0xFFF8F8F8); } if (widget.selectBtnList != null && - index < widget.selectBtnList.length && - widget.selectBtnList[index]) { + index < widget.selectBtnList!.length && + widget.selectBtnList![index]) { return Color(0x1F0984F9); } else { return Color(0xFFF8F8F8); @@ -407,25 +402,25 @@ class QuickButtonsState extends State { } Color getBtnTextColor(int index) { - if (widget.btnsTxt != null && widget.btnsTxt.isEmpty) { + if (widget.btnsTxt != null && widget.btnsTxt!.isEmpty) { return Color(0xFF222222); } /// 这个按钮不可点击 if (widget.enableBtnList != null && - index < widget.enableBtnList.length && - !widget.enableBtnList[index]) { + index < widget.enableBtnList!.length && + !widget.enableBtnList![index]) { return Color(0xFF999999); } if (widget.selectBtnList == null || - widget.selectBtnList.length != widget.btnsTxt.length) { + widget.selectBtnList!.length != widget.btnsTxt!.length) { return Color(0xFF222222); } if (widget.selectBtnList != null && - index < widget.selectBtnList.length && - widget.selectBtnList[index]) { + index < widget.selectBtnList!.length && + widget.selectBtnList![index]) { return Color(0xFF0984F9); } else { return Color(0xFF222222); diff --git a/lib/src/components/form/items/general/brn_radio_input_item.dart b/lib/src/components/form/items/general/brn_radio_input_item.dart index 0620f6c0..81e570d6 100644 --- a/lib/src/components/form/items/general/brn_radio_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_input_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -17,25 +17,26 @@ import 'package:flutter/widgets.dart'; /// 包括"标题"、"副标题"、"错误信息提示"、"必填项提示"、"添加/删除按钮"、"消息提示"、 /// "单选项"等元素 /// -// ignore: must_be_immutable2 + +// ignore: must_be_immutable class BrnRadioInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.RADIO_INPUT_TYPE; + final String type = BrnInputItemType.RADIO_INPUT_TYPE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项,默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,41 +51,41 @@ class BrnRadioInputFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 录入项 值 - String value; + String? value; /// 选项 - List options; + List? options; /// 局部禁用list - List enableList; + List? enableList; /// 选项选中状态变化回调 - final OnBrnFormRadioValueChanged onChanged; + final OnBrnFormRadioValueChanged? onChanged; /// 标题显示的最大行数,默认值 1 - final int titleMaxLines; + final int? titleMaxLines; /// 左边标题部分/右边选项部分的宽度比例。例如 1/2 显示就传 0.5。 /// 右边选项部分的显示宽度 = min(选项部分的实际宽度, 选项部分的比例计算宽度) - double layoutRatio; + double? layoutRatio; /// 是否自动布局 - bool _isAutoLayout; + bool? _isAutoLayout; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnRadioInputFormItem({ - Key key, + Key? key, this.label, this.title: "", this.subTitle, @@ -105,14 +106,14 @@ class BrnRadioInputFormItem extends StatefulWidget { }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); this._isAutoLayout = false; } BrnRadioInputFormItem.autoLayout({ - Key key, + Key? key, this.label, this.title: "", this.subTitle, @@ -135,7 +136,7 @@ class BrnRadioInputFormItem extends StatefulWidget { this._isAutoLayout = true; this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -148,7 +149,7 @@ class BrnRadioInputFormItem extends StatefulWidget { class BrnRadioInputFormItemState extends State { double _kRadioTitleLeftPadding = 6; - double _kRadionIconWidth = 16; + double _kRadioIconWidth = 16; @override Widget build(BuildContext context) { @@ -174,7 +175,7 @@ class BrnRadioInputFormItemState extends State { double _getTitleMaxWidth(BuildContext context, BoxConstraints constraints) { // 计算表单右边部分的宽度 double contentRatio = BrnFormUtil.getAutoLayoutContentRatio( - tipLabelHidden: widget.tipLabel == null || widget.tipLabel.isEmpty, + tipLabelHidden: widget.tipLabel == null || widget.tipLabel!.isEmpty, layoutRatio: widget.layoutRatio); double ratioWidth = constraints.maxWidth * contentRatio; double maxWidth = min(ratioWidth, _calculateTextWidth(context)); @@ -226,7 +227,7 @@ class BrnRadioInputFormItemState extends State { child: GestureDetector( onTap: () { if (widget.onTip != null) { - widget.onTip(); + widget.onTip!(); } }, child: Row( @@ -262,22 +263,19 @@ class BrnRadioInputFormItemState extends State { /// 计算Text所占宽度 double _calculateTextWidth(BuildContext context) { - List options; - if (widget.options.isNotEmpty ?? false) { + List? options; + if (widget.options != null && widget.options!.isNotEmpty) { // 模型里边的数据 options = widget.options; - } else if (widget.options.isNotEmpty ?? false) { - // widget 里边的数据 - options = widget.options; } // 计算所有备选文案的文字长度 double totalTextWidth = 0; - if (options.isNotEmpty ?? false) { + if (options!.isNotEmpty) { int idx = -1; - for (String item in options) { + for (String? item in options) { idx += 1; - TextStyle optionStyle = getOptionTextStyle(item, idx); + TextStyle? optionStyle = getOptionTextStyle(item, idx); TextPainter painter = TextPainter( locale: Localizations.localeOf(context), textAlign: TextAlign.start, @@ -288,9 +286,9 @@ class BrnRadioInputFormItemState extends State { // 6 是备选文案和单选按钮之间的间距 // 16 是 radio 按钮的宽度 double optionWidth = painter.width + - BrnFormUtil.optionsMiddlePadding(widget.themeData).left + + BrnFormUtil.optionsMiddlePadding(widget.themeData)!.left + _kRadioTitleLeftPadding + - _kRadionIconWidth; + _kRadioIconWidth; totalTextWidth += optionWidth; } } @@ -298,7 +296,7 @@ class BrnRadioInputFormItemState extends State { } Widget _buildTitleTextWidget() { - return Text(widget.title ?? "", + return Text(widget.title , overflow: widget.titleMaxLines == null ? TextOverflow.clip : TextOverflow.ellipsis, @@ -347,9 +345,9 @@ class BrnRadioInputFormItemState extends State { ); } - List getRadioList(List options) { - List result = List(); - String option; + List getRadioList(List? options) { + List result = []; + String? option; if (options == null || options.isEmpty) { result.add(Container()); return result; @@ -368,18 +366,18 @@ class BrnRadioInputFormItemState extends State { child: Container( padding: EdgeInsets.only(left: _kRadioTitleLeftPadding), child: Text( - option, + option!, style: getOptionTextStyle(option, index), )), disable: getRadioEnableState(index), radioIndex: index, - isSelected: index == widget.options.indexOf(widget.value), + isSelected: index == widget.options!.indexOf(widget.value ?? ""), onValueChangedAtIndex: (int position, bool selected) { if (getRadioEnableState(position)) { return; } - String oldValue = widget.value; + String? oldValue = widget.value; widget.value = options[index]; BrnFormUtil.notifyRadioStatusChanged( widget.onChanged, context, oldValue, widget.value); @@ -395,8 +393,8 @@ class BrnRadioInputFormItemState extends State { return result; } - TextStyle getOptionTextStyle(String opt, int index) { - TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData); + TextStyle? getOptionTextStyle(String? opt, int index) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); if (opt == null) { return result; } @@ -410,9 +408,9 @@ class BrnRadioInputFormItemState extends State { } if (widget.enableList != null && - widget.enableList.isNotEmpty && - widget.enableList.length > index && - !widget.enableList[index]) { + widget.enableList!.isNotEmpty && + widget.enableList!.length > index && + !widget.enableList![index]) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); } @@ -425,11 +423,11 @@ class BrnRadioInputFormItemState extends State { } if (widget.enableList == null || - widget.enableList.isEmpty || - widget.enableList.length < index) { + widget.enableList!.isEmpty || + widget.enableList!.length < index) { return false; } - return !widget.enableList[index]; + return !widget.enableList![index]; } } diff --git a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart index 54a50d7e..0f6e68e4 100644 --- a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart @@ -1,11 +1,10 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/line/brn_line.dart'; -import 'package:bruno/src/components/radio/brn_radio_core.dart'; import 'package:bruno/src/theme/brn_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -19,7 +18,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnRadioPortraitInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.RADIO_INPUT_TYPE; @@ -28,14 +27,14 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,31 +49,31 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 录入项 值 - String value; + String? value; /// 选项 - List options; + List? options; /// 局部禁用list - List enableList; + List? enableList; /// 选项选中状态变化回调 - final OnBrnFormRadioValueChanged onChanged; + final OnBrnFormRadioValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnRadioPortraitInputFormItem( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -94,7 +93,7 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -161,9 +160,9 @@ class BrnRadioPortraitInputFormItemState ); } - List getRadioList(List options) { - List result = List(); - String option; + List getRadioList(List? options) { + List result = []; + String? option; if (options == null || options.isEmpty) { result.add(Container()); return result; @@ -178,7 +177,7 @@ class BrnRadioPortraitInputFormItemState padding: EdgeInsets.only(top: 14, bottom: 14), child: BrnRadioButton( child: Text( - option, + option!, style: getOptionTextStyle(option, index), ), childOnRight: false, @@ -186,12 +185,12 @@ class BrnRadioPortraitInputFormItemState mainAxisSize: MainAxisSize.max, disable: getRadioEnableState(index), radioIndex: index, - isSelected: index == widget.options.indexOf(widget.value), + isSelected: index == widget.options!.indexOf(widget.value), onValueChangedAtIndex: (int position, bool isSelected) { if (getRadioEnableState(position)) { return; } - String oldValue = widget.value; + String? oldValue = widget.value; widget.value = options[position]; BrnFormUtil.notifyRadioStatusChanged( widget.onChanged, context, oldValue, widget.value); @@ -207,9 +206,9 @@ class BrnRadioPortraitInputFormItemState return result; } - TextStyle getOptionTextStyle(String opt, int index) { - TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (opt == null /*|| widget.value == null*/) { + TextStyle? getOptionTextStyle(String? opt, int index) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + if (opt == null) { return result; } @@ -217,14 +216,14 @@ class BrnRadioPortraitInputFormItemState result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); } - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); } if (widget.enableList != null && - widget.enableList.isNotEmpty && - widget.enableList.length > index && - !widget.enableList[index]) { + widget.enableList!.isNotEmpty && + widget.enableList!.length > index && + !widget.enableList![index]) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); } @@ -237,11 +236,11 @@ class BrnRadioPortraitInputFormItemState } if (widget.enableList == null || - widget.enableList.isEmpty || - widget.enableList.length < index) { + widget.enableList!.isEmpty || + widget.enableList!.length < index) { return false; } - return !widget.enableList[index]; + return !widget.enableList![index]; } } diff --git a/lib/src/components/form/items/general/brn_range_input_item.dart b/lib/src/components/form/items/general/brn_range_input_item.dart index cf7f98eb..a2906483 100644 --- a/lib/src/components/form/items/general/brn_range_input_item.dart +++ b/lib/src/components/form/items/general/brn_range_input_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; @@ -14,9 +14,10 @@ import 'package:flutter/services.dart'; /// 包括"标题"、"副标题"、"错误信息提示"、"必填项提示"、"添加/删除按钮"、"消息提示"、 /// "输入框"等元素 /// +// ignore: must_be_immutable class BrnRangeInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.TEXT_RANGE_INPUT_TYPE; @@ -25,14 +26,14 @@ class BrnRangeInputFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -52,13 +53,13 @@ class BrnRangeInputFormItem extends StatefulWidget { final bool isPrefixIconEnabled; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 最小值提示语 final String hintMin; @@ -67,36 +68,36 @@ class BrnRangeInputFormItem extends StatefulWidget { final String hintMax; /// 最小值单位 - final String minUnit; + final String? minUnit; /// 最大值单位 - final String maxUnit; + final String? maxUnit; /// 最小值输入框最大字符数 - final int leftMaxCount; + final int? leftMaxCount; /// 最大值输入框最大字符数 - final int rightMaxCount; + final int? rightMaxCount; /// 输入内容类型,参见[BrnInputType] - final String inputType; + final String? inputType; - final TextEditingController minController; - final TextEditingController maxController; - List minInputFormatters; - List maxInputFormatters; + final TextEditingController? minController; + final TextEditingController? maxController; + List? minInputFormatters; + List? maxInputFormatters; /// 最小值输入回调 - final ValueChanged onMinChanged; + final ValueChanged? onMinChanged; /// 最大值输入回调 - final ValueChanged onMaxChanged; + final ValueChanged? onMaxChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnRangeInputFormItem( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -109,8 +110,8 @@ class BrnRangeInputFormItem extends StatefulWidget { this.onAddTap, this.onRemoveTap, this.onTip, - this.hintMin: "请输入", - this.hintMax: "请输入", + this.hintMin: '最小', + this.hintMax: '最大', this.minUnit, this.maxUnit, this.leftMaxCount, @@ -126,7 +127,7 @@ class BrnRangeInputFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -138,15 +139,13 @@ class BrnRangeInputFormItem extends StatefulWidget { } class BrnRangeInputFormItemState extends State { - TextEditingController _minController; - TextEditingController _maxController; - - BrnFormItemConfig config; + late TextEditingController _minController; + late TextEditingController _maxController; + late BrnFormItemConfig config; @override void initState() { config = BrnThemeConfigurator.instance.getConfig().formItemConfig; - _minController = widget.minController ?? TextEditingController(); _maxController = widget.maxController ?? TextEditingController(); @@ -207,7 +206,7 @@ class BrnRangeInputFormItemState extends State { border: InputBorder.none, hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), - hintText: widget.hintMin ?? '最小', + hintText: widget.hintMin, counterText: "", contentPadding: EdgeInsets.all(0), isDense: true, @@ -262,7 +261,7 @@ class BrnRangeInputFormItemState extends State { border: InputBorder.none, hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), - hintText: widget.hintMax ?? '最大', + hintText: widget.hintMax, counterText: "", contentPadding: EdgeInsets.all(0), isDense: true, @@ -310,11 +309,7 @@ class BrnRangeInputFormItemState extends State { void dispose() { super.dispose(); // 如果controller由外部创建不需要销毁, 若由内部创建则需要销毁 - if (widget.minController == null) { - _minController?.dispose(); - } - if (widget.maxController == null) { - _maxController?.dispose(); - } + _minController.dispose(); + _maxController.dispose(); } } diff --git a/lib/src/components/form/items/general/brn_ratio_input_item.dart b/lib/src/components/form/items/general/brn_ratio_input_item.dart index 43d9e152..10411815 100644 --- a/lib/src/components/form/items/general/brn_ratio_input_item.dart +++ b/lib/src/components/form/items/general/brn_ratio_input_item.dart @@ -1,7 +1,6 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; -import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; @@ -18,7 +17,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnRatioInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.TEXT_INPUT_RATIO_TYPE; @@ -27,14 +26,14 @@ class BrnRatioInputFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -54,30 +53,30 @@ class BrnRatioInputFormItem extends StatefulWidget { final bool isPrefixIconEnabled; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; ///内容 final String hint; /// 输入内容类型 - final String inputType; - final TextEditingController controller; - List inputFormatters; + final String? inputType; + final TextEditingController? controller; + List? inputFormatters; /// 输入回调 - final ValueChanged onChanged; + final ValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnRatioInputFormItem( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -99,7 +98,7 @@ class BrnRatioInputFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -111,12 +110,11 @@ class BrnRatioInputFormItem extends StatefulWidget { } class BrnRatioInputFormItemState extends State { - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { _controller = widget.controller ?? TextEditingController(); - super.initState(); } @@ -177,7 +175,7 @@ class BrnRatioInputFormItemState extends State { border: InputBorder.none, hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), - hintText: widget.hint ?? '请输入', + hintText: widget.hint, counterText: "", contentPadding: EdgeInsets.all(0), isDense: true, @@ -215,8 +213,6 @@ class BrnRatioInputFormItemState extends State { void dispose() { super.dispose(); // 如果controller由外部创建不需要销毁, 若由内部创建则需要销毁 - if (widget.controller == null) { - _controller?.dispose(); - } + _controller.dispose(); } } diff --git a/lib/src/components/form/items/general/brn_star_input_item.dart b/lib/src/components/form/items/general/brn_star_input_item.dart index e8ade984..339f5919 100644 --- a/lib/src/components/form/items/general/brn_star_input_item.dart +++ b/lib/src/components/form/items/general/brn_star_input_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; @@ -19,7 +19,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnStarsFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.STAR_INPUT_TYPE; @@ -28,14 +28,14 @@ class BrnStarsFormItem extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,13 +50,13 @@ class BrnStarsFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 特有字段 int value; @@ -65,13 +65,13 @@ class BrnStarsFormItem extends StatefulWidget { final int sumStar; /// 星值数量变化回调 - final OnBrnFormValueChanged onChanged; + final OnBrnFormValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnStarsFormItem( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -90,7 +90,7 @@ class BrnStarsFormItem extends StatefulWidget { : super() { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -102,7 +102,7 @@ class BrnStarsFormItem extends StatefulWidget { } class BrnStarsFormItemState extends State { - List _result = List(); + List _result = []; @override Widget build(BuildContext context) { @@ -184,10 +184,6 @@ class BrnStarsFormItemState extends State { } bool isEnable() { - if (widget.isEdit == null) { - return true; - } - return widget.isEdit; } diff --git a/lib/src/components/form/items/general/brn_step_input_item.dart b/lib/src/components/form/items/general/brn_step_input_item.dart index ac081f2a..dacefc15 100644 --- a/lib/src/components/form/items/general/brn_step_input_item.dart +++ b/lib/src/components/form/items/general/brn_step_input_item.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; @@ -17,25 +15,26 @@ import 'package:flutter/widgets.dart'; /// 包括"标题"、"副标题"、"错误信息提示"、"必填项提示"、"添加/删除按钮"、"消息提示"、 /// "递增/递减按钮"等元素 /// +// ignore: must_be_immutable class BrnStepInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_STEP_INPUT_TYPE; + final String type = BrnInputItemType.TEXT_STEP_INPUT_TYPE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -50,16 +49,16 @@ class BrnStepInputFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 特有字段 - int value; + final int? value; /// 单步上限值 final int maxLimit; @@ -68,33 +67,34 @@ class BrnStepInputFormItem extends StatefulWidget { final int minLimit; /// 当前值变化回调 - final OnBrnFormValueChanged onChanged; + final OnBrnFormValueChanged? onChanged; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnStepInputFormItem({ - Key key, + Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, this.onAddTap, this.onRemoveTap, this.onTip, - this.value: 0, - this.maxLimit: 10, - this.minLimit: 0, + this.value, + this.maxLimit = 10, + this.minLimit = 0, this.onChanged, this.themeData, - }) : super(key: key) { + }) : assert(value == null || value >= minLimit && value <= maxLimit), + super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -106,6 +106,14 @@ class BrnStepInputFormItem extends StatefulWidget { } class BrnStepInputFormItemState extends State { + late int _value; + + @override + void initState() { + super.initState(); + _value = widget.value ?? widget.minLimit; + } + @override Widget build(BuildContext context) { return Container( @@ -153,18 +161,10 @@ class BrnStepInputFormItemState extends State { return; } - if (widget.value == null) { - widget.value = 1; - BrnFormUtil.notifyValueChanged(widget.onChanged, - context, widget.value + 1, widget.value); - setState(() {}); - return; - } - if (!isReachMinLevel()) { - widget.value = widget.value - 1; - BrnFormUtil.notifyValueChanged(widget.onChanged, - context, widget.value + 1, widget.value); + _value = _value - 1; + BrnFormUtil.notifyValueChanged( + widget.onChanged, context, _value + 1, _value); setState(() {}); } }, @@ -176,7 +176,7 @@ class BrnStepInputFormItemState extends State { alignment: Alignment.center, width: 50, child: Text( - "${widget.value}", + "$_value", style: TextStyle( color: Color(0xFF222222), fontSize: BrnFonts.f16, @@ -193,18 +193,10 @@ class BrnStepInputFormItemState extends State { return; } - if (widget.value == null) { - widget.value = 1; - BrnFormUtil.notifyValueChanged(widget.onChanged, - context, widget.value - 1, widget.value); - setState(() {}); - return; - } - if (!isReachMaxLevel()) { - widget.value = widget.value + 1; - BrnFormUtil.notifyValueChanged(widget.onChanged, - context, widget.value - 1, widget.value); + _value = _value + 1; + BrnFormUtil.notifyValueChanged( + widget.onChanged, context, _value - 1, _value); setState(() {}); } }, @@ -228,15 +220,11 @@ class BrnStepInputFormItemState extends State { } bool isEnable() { - if (widget.isEdit == null) { - return true; - } - return widget.isEdit; } Image getAddIcon() { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return BrunoTools.getAssetImage(BrnAsset.iconAddDisable); } @@ -248,21 +236,14 @@ class BrnStepInputFormItemState extends State { } bool isReachMaxLevel() { - int value = widget.value; - - if (widget.value == null) { - return false; - } - - if (value >= widget.maxLimit) { + if (_value >= widget.maxLimit) { return true; } - return false; } Image getMinusIcon() { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return BrunoTools.getAssetImage(BrnAsset.iconMinusDisable); } @@ -274,16 +255,9 @@ class BrnStepInputFormItemState extends State { } bool isReachMinLevel() { - int value = widget.value; - - if (widget.value == null) { - return false; - } - - if (value <= widget.minLimit) { + if (_value <= widget.minLimit) { return true; } - return false; } } diff --git a/lib/src/components/form/items/general/brn_text_block_input_item.dart b/lib/src/components/form/items/general/brn_text_block_input_item.dart index 3a53bc09..50328308 100644 --- a/lib/src/components/form/items/general/brn_text_block_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_block_input_item.dart @@ -1,7 +1,4 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; -import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme.dart'; import 'package:flutter/material.dart'; @@ -17,23 +14,23 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnTextBlockInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_BLOCK_INPUT_TYPE; + final String type = BrnInputItemType.TEXT_BLOCK_INPUT_TYPE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -53,30 +50,30 @@ class BrnTextBlockInputFormItem extends StatefulWidget { final bool isPrefixIconEnabled; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 输入字符数上限 - final int maxCharCount; + final int? maxCharCount; /// 录入项 hint 提示 final String hint; /// 输入内容类型 - final String inputType; + final String? inputType; /// 指定对输入数据的格式化要求 - List inputFormatters; + final List? inputFormatters; /// 输入回调 - final ValueChanged onChanged; + final ValueChanged? onChanged; - final TextEditingController controller; + final TextEditingController? controller; /// 最小行数,默认值4 final int minLines; @@ -85,25 +82,24 @@ class BrnTextBlockInputFormItem extends StatefulWidget { final int maxLines; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTextBlockInputFormItem( - {Key key, + {Key? key, this.label, - this.type: BrnInputItemType.TEXT_BLOCK_INPUT_TYPE, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, - this.isPrefixIconEnabled: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, + this.isPrefixIconEnabled = false, this.onAddTap, this.onRemoveTap, this.onTip, this.onChanged, - this.hint: "请选择", + this.hint = "请输入", this.maxCharCount, this.inputType, this.inputFormatters, @@ -114,7 +110,7 @@ class BrnTextBlockInputFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -126,7 +122,7 @@ class BrnTextBlockInputFormItem extends StatefulWidget { } class BrnTextBlockInputFormItemState extends State { - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { @@ -184,16 +180,16 @@ class BrnTextBlockInputFormItemState extends State { keyboardType: BrnFormUtil.getInputType(widget.inputType), controller: _controller, maxLength: widget.maxCharCount, - maxLengthEnforced: true, - maxLines: widget.maxLines ?? 20, - minLines: widget.minLines ?? 4, + maxLengthEnforcement: MaxLengthEnforcement.enforced, + maxLines: widget.maxLines, + minLines: widget.minLines, textAlign: TextAlign.left, enabled: widget.isEdit, style: BrnFormUtil.getIsEditTextStyle( widget.themeData, widget.isEdit), inputFormatters: widget.inputFormatters, decoration: InputDecoration( - hintText: widget.hint ?? "请输入", + hintText: widget.hint , hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), contentPadding: EdgeInsets.all(0), border: InputBorder.none, @@ -217,7 +213,7 @@ class BrnTextBlockInputFormItemState extends State { void dispose() { super.dispose(); if (widget.controller == null) { - _controller?.dispose(); + _controller.dispose(); } } } diff --git a/lib/src/components/form/items/general/brn_text_input_item.dart b/lib/src/components/form/items/general/brn_text_input_item.dart index 79559c7b..1a13d5b0 100644 --- a/lib/src/components/form/items/general/brn_text_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_input_item.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -17,23 +15,23 @@ import 'package:flutter/services.dart'; // ignore: must_be_immutable class BrnTextInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_INPUT_TYPE; + final String type = BrnInputItemType.TEXT_INPUT_TYPE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 [BrnPrefixIconType] 类 final String prefixIconType; @@ -53,55 +51,54 @@ class BrnTextInputFormItem extends StatefulWidget { final bool isPrefixIconEnabled; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 固定内容 - final String prefixText; + final String? prefixText; /// 提示文案 final String hint; /// 单位 - final String unit; + final String? unit; /// 输入内容类型 - final String inputType; + final String? inputType; /// 最大可输入字符数 - final int maxCharCount; - List inputFormatters; + final int? maxCharCount; + final List? inputFormatters; /// 输入变化回调 - final ValueChanged onChanged; + final ValueChanged? onChanged; - final TextEditingController controller; + final TextEditingController? controller; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTextInputFormItem({ - Key key, + Key? key, this.label, - this.type: BrnInputItemType.TEXT_INPUT_TYPE, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, - this.isPrefixIconEnabled: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, + this.isPrefixIconEnabled = false, this.onAddTap, this.onRemoveTap, this.onTip, this.prefixText, - this.hint: "请输入", + this.hint = "请输入", this.unit, this.maxCharCount, this.inputType, @@ -112,7 +109,7 @@ class BrnTextInputFormItem extends StatefulWidget { }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -124,7 +121,7 @@ class BrnTextInputFormItem extends StatefulWidget { } class BrnTextInputFormItemState extends State { - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { @@ -186,7 +183,7 @@ class BrnTextInputFormItemState extends State { decoration: InputDecoration( border: InputBorder.none, hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), - hintText: widget.hint ?? '请输入', + hintText: widget.hint, counterText: "", contentPadding: EdgeInsets.all(0), isDense: true, @@ -231,7 +228,7 @@ class BrnTextInputFormItemState extends State { // 如果controller由外部创建不需要销毁, 若由内部创建则需要销毁 if (widget.controller == null) { - _controller?.dispose(); + _controller.dispose(); } } } diff --git a/lib/src/components/form/items/general/brn_text_select_item.dart b/lib/src/components/form/items/general/brn_text_select_item.dart index ed520208..290153c0 100644 --- a/lib/src/components/form/items/general/brn_text_select_item.dart +++ b/lib/src/components/form/items/general/brn_text_select_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -21,19 +21,19 @@ import 'package:flutter/widgets.dart'; /// // ignore: must_be_immutable class BrnTextSelectFormItem extends StatefulWidget { - final String label; + final String? label; /// 录入项的唯一标识,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_SELECT_INPUT_TYPE; + final String type = BrnInputItemType.TEXT_SELECT_INPUT_TYPE; /// 录入项类型,主要用于录入类型页面框架中 final String title; /// 录入项标题 - final String subTitle; + final String? subTitle; /// 录入项子标题 - final String tipLabel; + final String? tipLabel; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, @@ -53,41 +53,41 @@ class BrnTextSelectFormItem extends StatefulWidget { final bool isEdit; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 点击录入区回调 - final VoidCallback onTap; + final VoidCallback? onTap; /// 录入项 hint 提示 final String hint; /// 录入项 值 - final String value; + final String? value; /// 选中文本最大行数 final int valueMaxLines; /// title最大行数 - final int titleMaxLines; + final int? titleMaxLines; ///是否自动布局 - bool _isAutoLayout; + bool? _isAutoLayout; /// 行布局比例值 左边「标题+问号+提示语」 右边「选项值」 /// 左:右 比例值 例如 左:右 = 6:4 则 ratio = 1.5 - double layoutRatio; + double? layoutRatio; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTextSelectFormItem({ - Key key, + Key? key, this.label, this.title: "", this.subTitle, @@ -109,13 +109,13 @@ class BrnTextSelectFormItem extends StatefulWidget { this._isAutoLayout = false; this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } BrnTextSelectFormItem.autoLayout( - {Key key, + {Key? key, this.label, this.title: "", this.subTitle, @@ -138,7 +138,7 @@ class BrnTextSelectFormItem extends StatefulWidget { this._isAutoLayout = true; this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -179,7 +179,7 @@ class BrnTextSelectFormItemState extends State { double _getTitleMaxWidth(BuildContext context, BoxConstraints constraints) { double contentRatio = BrnFormUtil.getAutoLayoutContentRatio( - tipLabelHidden: widget.tipLabel == null || widget.tipLabel.isEmpty, + tipLabelHidden: widget.tipLabel == null || widget.tipLabel!.isEmpty, layoutRatio: widget.layoutRatio); double maxWidth = min( constraints.maxWidth * contentRatio, @@ -237,7 +237,7 @@ class BrnTextSelectFormItemState extends State { GestureDetector _buildRightWidget(BuildContext context) { return GestureDetector( onTap: () { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return; } @@ -269,7 +269,7 @@ class BrnTextSelectFormItemState extends State { child: GestureDetector( onTap: () { if (widget.onTip != null) { - widget.onTip(); + widget.onTip!(); } }, child: Row( @@ -304,7 +304,7 @@ class BrnTextSelectFormItemState extends State { // 标题widget Widget _buildTitleTextWidget() { return Text( - widget.title ?? "", + widget.title, overflow: widget.titleMaxLines == null ? TextOverflow.clip : TextOverflow.ellipsis, @@ -344,7 +344,7 @@ class BrnTextSelectFormItemState extends State { // 计算Text所占宽度 double _calculateTextWidth(BuildContext context) { TextPainter painter; - if (widget.value != null && widget.value.isNotEmpty) { + if (widget.value != null && widget.value!.isNotEmpty) { painter = TextPainter( locale: Localizations.localeOf(context), textAlign: TextAlign.end, @@ -374,11 +374,11 @@ class BrnTextSelectFormItemState extends State { } Widget buildText() { - if (widget.value != null && widget.value.isNotEmpty) { + if (widget.value != null && widget.value!.isNotEmpty) { return Text( - widget.value, + widget.value!, overflow: TextOverflow.ellipsis, - maxLines: widget.valueMaxLines ?? 1, + maxLines: widget.valueMaxLines , textAlign: TextAlign.end, strutStyle: _contentStructStyle, style: BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit, @@ -394,8 +394,8 @@ class BrnTextSelectFormItemState extends State { } } - String getCalculateText() { - String value = '请选择'; + String? getCalculateText() { + String? value = '请选择'; if (!BrunoTools.isEmpty(widget.value)) { value = widget.value; } else if (!BrunoTools.isEmpty(widget.hint)) { @@ -408,7 +408,7 @@ class BrnTextSelectFormItemState extends State { // fontSize : 文字的大小; // maxLines:文本支持最大多少行 static double calculateTextHeight( - BuildContext context, String value, double fontSize, int maxLines) { + BuildContext context, String? value, double fontSize, int maxLines) { TextPainter painter = TextPainter( // AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。 diff --git a/lib/src/components/form/items/general/brn_title_select_input_item.dart b/lib/src/components/form/items/general/brn_title_select_input_item.dart index 90193d38..2b0599fe 100644 --- a/lib/src/components/form/items/general/brn_title_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_title_select_input_item.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'dart:async'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; @@ -23,23 +21,23 @@ import 'package:flutter/services.dart'; // ignore: must_be_immutable class BrnTitleSelectInputFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_INPUT_TITLE_SELECT_TYPE; + final String type = BrnInputItemType.TEXT_INPUT_TITLE_SELECT_TYPE; /// 录入项标题 - String title; + final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -59,19 +57,19 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { final bool isPrefixIconEnabled; /// 点击"+"图标回调 - final VoidCallback onAddTap; + final VoidCallback? onAddTap; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 提示文案 final String hint; /// 最大可输入字符数 - final int maxCount; + final int? maxCount; /// 输入类型 final String inputType; @@ -80,37 +78,37 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { final int selectedIndex; /// title选择列表 - List selectList; - List inputFormatters; + final List? selectList; + final List? inputFormatters; /// 输入文本变化回调 - final ValueChanged onChanged; + final ValueChanged? onChanged; /// title文案选中回调 - final OnBrnFormTitleSelected onTitleSelected; - final TextEditingController controller; + final OnBrnFormTitleSelected? onTitleSelected; + final TextEditingController? controller; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTitleSelectInputFormItem( - {Key key, + {Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, - this.isPrefixIconEnabled: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, + this.isPrefixIconEnabled = false, this.onAddTap, this.onRemoveTap, this.onTip, - this.hint: "请输入", + this.hint = "请输入", this.maxCount, - this.inputType: BrnInputType.TEXT, - this.selectedIndex: -1, + this.inputType = BrnInputType.TEXT, + this.selectedIndex = -1, this.selectList, this.inputFormatters, this.onChanged, @@ -120,7 +118,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -132,10 +130,11 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { class BrnTitleSelectInputFormItemState extends State { - TextEditingController _controller; - StreamController _showController; - StreamController _textController; - GlobalKey _globalKey; + late TextEditingController _controller; + late StreamController _showController; + late StreamController _textController; + late GlobalKey _globalKey; + String _title = ""; @override void initState() { @@ -201,15 +200,16 @@ class BrnTitleSelectInputFormItemState padding: EdgeInsets.only(right: 4), child: GestureDetector( onTap: () { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return; } - RenderBox trigle = _globalKey.currentContext?.findRenderObject(); - Offset offset = trigle?.localToGlobal(Offset.zero); - final RenderBox button = context.findRenderObject(); + RenderBox trigle = + _globalKey.currentContext?.findRenderObject() as RenderBox; + Offset offset = trigle.localToGlobal(Offset.zero); + final RenderBox button = context.findRenderObject() as RenderBox; final RenderBox overlay = - Overlay.of(context).context.findRenderObject(); + Overlay.of(context)!.context.findRenderObject() as RenderBox; final RelativeRect position = RelativeRect.fromRect( Rect.fromPoints( button.localToGlobal(Offset.zero, ancestor: overlay), @@ -219,9 +219,9 @@ class BrnTitleSelectInputFormItemState ); var relativeRect = RelativeRect.fromLTRB( - position.left + offset?.dx ?? 16, + position.left + offset.dx, position.top + 44, - position.right + offset?.dx ?? 16, + position.right + offset.dx, position.bottom + 44); _showController.add(true); Navigator.push( @@ -236,10 +236,10 @@ class BrnTitleSelectInputFormItemState selectList: widget.selectList, selectedIndex: widget.selectedIndex, selectCallback: (item, index) { - widget.title = item; + _title = item; _textController.add(item); if (widget.onTitleSelected != null) { - widget.onTitleSelected(item, index); + widget.onTitleSelected!(item, index); } }, themeData: widget.themeData, @@ -254,10 +254,10 @@ class BrnTitleSelectInputFormItemState }, child: StreamBuilder( stream: _textController.stream, - initialData: widget.title ?? "", + initialData: _title, builder: (context, AsyncSnapshot snapshot) { return Text( - snapshot.data, + snapshot.data!, style: BrnFormUtil.getTitleTextStyle(widget.themeData), ); }, @@ -273,7 +273,7 @@ class BrnTitleSelectInputFormItemState stream: _showController.stream, initialData: false, builder: (BuildContext context, AsyncSnapshot snapshot) { - return snapshot.data + return snapshot.data! ? BrunoTools.getAssetImageWithBandColor( BrnAsset.iconSelectedUpTriangle) : BrunoTools.getAssetImage(BrnAsset.iconUnSelectDownTriangle); @@ -300,7 +300,7 @@ class BrnTitleSelectInputFormItemState color: Color(0xFFCCCCCC), fontSize: BrnFonts.f16, textBaseline: TextBaseline.alphabetic), - hintText: widget.hint ?? '请输入', + hintText: widget.hint, counterText: "", contentPadding: EdgeInsets.all(0), isDense: true, @@ -317,7 +317,7 @@ class BrnTitleSelectInputFormItemState super.dispose(); // 如果controller由外部创建不需要销毁, 若由内部创建则需要销毁 if (widget.controller == null) { - _controller?.dispose(); + _controller.dispose(); } } @@ -327,19 +327,21 @@ class BrnTitleSelectInputFormItemState _controller = widget.controller ?? TextEditingController(); _globalKey = GlobalKey(); + _title = widget.title; } } +// ignore: must_be_immutable class TitleSelectPopWidget extends StatefulWidget { - List selectList; - int selectedIndex; + List? /*!*/ selectList; + int? selectedIndex; final Function(String item, int index) selectCallback; - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; TitleSelectPopWidget( {this.selectList, this.selectedIndex, - this.selectCallback, + required this.selectCallback, this.themeData}); @override @@ -350,8 +352,8 @@ class _TitleSelectPopWidgetState extends State { @override Widget build(BuildContext context) { List showList = []; - for (int i = 0, n = widget.selectList.length; i < n; ++i) { - showList.add(selectItem(widget.selectList[i], i, i == n - 1)); + for (int i = 0, n = widget.selectList!.length; i < n; ++i) { + showList.add(selectItem(widget.selectList![i], i, i == n - 1)); } return Container( padding: EdgeInsets.only(left: 16, right: 16), @@ -365,7 +367,7 @@ class _TitleSelectPopWidgetState extends State { ], color: Colors.white, border: Border.all( - color: widget.themeData.commonConfig.dividerColorBase, width: 0.5), + color: widget.themeData!.commonConfig.dividerColorBase, width: 0.5), borderRadius: BorderRadius.all(Radius.circular(4)), ), child: Column( @@ -400,7 +402,7 @@ class _TitleSelectPopWidgetState extends State { bottom: BorderSide( color: isLast ? Colors.transparent - : widget.themeData.commonConfig.dividerColorBase, + : widget.themeData!.commonConfig.dividerColorBase, width: 0.5)), // 也可控件一边圆角大小 ), child: Text( @@ -408,8 +410,8 @@ class _TitleSelectPopWidgetState extends State { style: TextStyle( decoration: TextDecoration.none, color: isSelected - ? widget.themeData.commonConfig.brandPrimary - : widget.themeData.commonConfig.colorTextBase, + ? widget.themeData!.commonConfig.brandPrimary + : widget.themeData!.commonConfig.colorTextBase, fontWeight: FontWeight.w500, fontSize: 16, ), diff --git a/lib/src/components/form/items/group/brn_expand_group.dart b/lib/src/components/form/items/group/brn_expand_group.dart index 67047f16..4b1d93b5 100644 --- a/lib/src/components/form/items/group/brn_expand_group.dart +++ b/lib/src/components/form/items/group/brn_expand_group.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/items/group/element_expand_widget.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; @@ -16,7 +14,7 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnExpandFormGroup extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 String type = BrnInputItemType.NORMAL_GROUP_TYPE; @@ -25,14 +23,14 @@ class BrnExpandFormGroup extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项错误提示 final String error; @@ -44,32 +42,32 @@ class BrnExpandFormGroup extends StatefulWidget { final bool isEdit; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 初始是否为展开状态 final bool isExpand; /// 右侧文案 - final String deleteLabel; + final String? deleteLabel; /// 内部子项 - List children; + final List? children; BrnExpandFormGroup({ - Key key, + Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.error: "", - this.isEdit: true, - this.isRequire: false, + this.error = "", + this.isEdit = true, + this.isRequire = false, this.onRemoveTap, this.onTip, - this.isExpand: true, + this.isExpand = true, this.deleteLabel, this.children, }); @@ -85,7 +83,7 @@ class BrnExpandFormGroupState extends State { Widget build(BuildContext context) { return Container( child: ExpansionElementWidget( - title: widget.title ?? "", + title: widget.title, subtitle: widget.subTitle, deleteText: widget.deleteLabel, initiallyExpanded: widget.isExpand, @@ -102,17 +100,15 @@ class BrnExpandFormGroupState extends State { } List getSubItem() { - List result = List(); + List result = []; - if (widget.children == null || widget.children.isEmpty) { + if (widget.children == null || widget.children!.isEmpty) { return result; } - for (Widget w in widget.children) { - if (w != null) { - result.add(BrnLine()); - result.add(w); - } + for (Widget w in widget.children!) { + result.add(BrnLine()); + result.add(w); } return result; diff --git a/lib/src/components/form/items/group/brn_normal_group.dart b/lib/src/components/form/items/group/brn_normal_group.dart index 73c7584f..590c5107 100644 --- a/lib/src/components/form/items/group/brn_normal_group.dart +++ b/lib/src/components/form/items/group/brn_normal_group.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/line/brn_line.dart'; @@ -14,9 +12,10 @@ import 'package:flutter/material.dart'; /// /// 包括"标题"、"副标题"、"错误信息提示"、"必填项提示"、"添加/删除按钮"、"消息提示" /// +// ignore: must_be_immutable class BrnNormalFormGroup extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 final String type = BrnInputItemType.NORMAL_GROUP_TYPE; @@ -25,14 +24,14 @@ class BrnNormalFormGroup extends StatefulWidget { final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项错误提示 final String error; @@ -44,29 +43,29 @@ class BrnNormalFormGroup extends StatefulWidget { final bool isEdit; /// 点击"-"图标回调 - final VoidCallback onRemoveTap; + final VoidCallback? onRemoveTap; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 右侧文案 - final String deleteLabel; + final String? deleteLabel; /// 内部子项 - List children; + final List? children; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnNormalFormGroup({ - Key key, + Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.error: "", - this.isEdit: true, - this.isRequire: false, + this.error = "", + this.isEdit = true, + this.isRequire = false, this.onRemoveTap, this.onTip, this.deleteLabel, @@ -74,7 +73,7 @@ class BrnNormalFormGroup extends StatefulWidget { }) : super() { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -104,14 +103,14 @@ class BrnNormalFormGroupState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Offstage( - offstage: (widget.title == null || widget.title.isEmpty), + offstage: (widget.title.isEmpty), child: Container( child: Row( children: [ Container( padding: EdgeInsets.only(left: 20, right: 6), child: Text( - widget.title ?? "", + widget.title, style: BrnFormUtil.getHeadTitleTextStyle( widget.themeData, isBold: true), @@ -151,7 +150,7 @@ class BrnNormalFormGroupState extends State { alignment: Alignment.centerLeft, padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData), child: Offstage( - offstage: (widget.subTitle == null || widget.subTitle.isEmpty), + offstage: (widget.subTitle == null || widget.subTitle!.isEmpty), child: Text( widget.subTitle ?? "", style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), @@ -172,15 +171,13 @@ class BrnNormalFormGroupState extends State { List getSubItem() { List result = []; - if (widget.children == null || widget.children.isEmpty) { + if (widget.children == null || widget.children!.isEmpty) { return result; } - for (Widget w in widget.children) { - if (w != null) { - result.add(BrnLine()); - result.add(w); - } + for (Widget w in widget.children!) { + result.add(BrnLine()); + result.add(w); } return result; diff --git a/lib/src/components/form/items/group/element_expand_widget.dart b/lib/src/components/form/items/group/element_expand_widget.dart index 887f6c33..69513e03 100644 --- a/lib/src/components/form/items/group/element_expand_widget.dart +++ b/lib/src/components/form/items/group/element_expand_widget.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -33,8 +33,8 @@ class ExpansionElementWidget extends StatefulWidget { /// the tile to reveal or hide the [children]. The [initiallyExpanded] property must /// be non-null. ExpansionElementWidget({ - Key key, - @required this.title, + Key? key, + this.title = "", this.subtitle, this.backgroundColor, this.onExpansionChanged, @@ -43,11 +43,10 @@ class ExpansionElementWidget extends StatefulWidget { this.deleteText, this.callback, this.themeData, - }) : assert(initiallyExpanded != null), - super(key: key) { + }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -57,19 +56,19 @@ class ExpansionElementWidget extends StatefulWidget { /// Typically a [Text] widget. final String title; - final String deleteText; + final String? deleteText; /// Additional content displayed below the title. /// /// Typically a [Text] widget. - final String subtitle; + final String? subtitle; /// Called when the tile expands or collapses. /// /// When the tile starts expanding, this function is called with the value /// true. When the tile starts collapsing, this function is called with /// the value false. - final ValueChanged onExpansionChanged; + final ValueChanged? onExpansionChanged; /// The widgets that are displayed when the tile expands. /// @@ -77,14 +76,14 @@ class ExpansionElementWidget extends StatefulWidget { final List children; /// The color to display behind the sublist when expanded. - final Color backgroundColor; + final Color? backgroundColor; /// Specifies if the list tile is initially expanded (true) or collapsed (false, the default). final bool initiallyExpanded; - final VoidCallback callback; + final VoidCallback? callback; - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; @override _ExpansionElementState createState() => _ExpansionElementState(); @@ -105,13 +104,13 @@ class _ExpansionElementState extends State final ColorTween _iconColorTween = ColorTween(); final ColorTween _backgroundColorTween = ColorTween(); - AnimationController _controller; - Animation _iconTurns; - Animation _heightFactor; + late AnimationController _controller; + late Animation _iconTurns; + late Animation _heightFactor; bool _isExpanded = false; - Widget arrowIcon; + late Widget arrowIcon; @override void initState() { @@ -165,10 +164,10 @@ class _ExpansionElementState extends State PageStorage.of(context)?.writeState(context, _isExpanded); }); if (widget.onExpansionChanged != null) - widget.onExpansionChanged(_isExpanded); + widget.onExpansionChanged!(_isExpanded); } - Widget _buildHeader(BuildContext context, Widget child) { + Widget _buildHeader(BuildContext context, Widget? child) { final Color borderSideColor = /*_borderColor.value ??*/ Colors.transparent; final Color backgroundColor = /*_backgroundColor.value ??*/ Colors .transparent; @@ -200,7 +199,7 @@ class _ExpansionElementState extends State Container( padding: EdgeInsets.only(right: 6), child: Text( - widget.title ?? "", + widget.title, style: BrnFormUtil.getHeadTitleTextStyle( widget.themeData, isBold: true), @@ -218,7 +217,7 @@ class _ExpansionElementState extends State child: GestureDetector( onTap: () { if (widget.callback != null) { - widget.callback(); + widget.callback!(); } }, child: Container( @@ -243,7 +242,7 @@ class _ExpansionElementState extends State alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 20, top: 4, bottom: 14), child: Offstage( - offstage: (widget.subtitle == null || widget.subtitle.isEmpty), + offstage: (widget.subtitle == null || widget.subtitle!.isEmpty), child: Text( widget.subtitle ?? "", style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), @@ -273,8 +272,8 @@ class _ExpansionElementState extends State /// title 文字颜色 _headerColorTween - ..begin = theme.textTheme.subtitle1.color - ..end = theme.textTheme.subtitle1.color; + ..begin = theme.textTheme.subtitle1!.color + ..end = theme.textTheme.subtitle1!.color; /// 展开收起图标颜色 _iconColorTween diff --git a/lib/src/components/form/items/misc/brn_add_label_item.dart b/lib/src/components/form/items/misc/brn_add_label_item.dart index 645fbb66..681a854f 100644 --- a/lib/src/components/form/items/misc/brn_add_label_item.dart +++ b/lib/src/components/form/items/misc/brn_add_label_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class BrnAddLabel extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.LABEL_ADD; + final String type = BrnInputItemType.LABEL_ADD; /// 标题文案 final String title; @@ -22,13 +22,13 @@ class BrnAddLabel extends StatefulWidget { final bool isEdit; /// 点击录入区回调 - final VoidCallback onTap; + final VoidCallback? onTap; BrnAddLabel({ - Key key, + Key? key, this.label, - this.title: "", - this.isEdit: true, + this.title= "", + this.isEdit= true, this.onTap, }); @@ -53,7 +53,7 @@ class BrnAddLabelState extends State { color: Colors.white, padding: EdgeInsets.fromLTRB(20, 15, 0, 15), child: Text( - widget.title ?? "", + widget.title, style: TextStyle( color: BrnThemeConfigurator.instance .getConfig() diff --git a/lib/src/components/form/items/misc/brn_title_item.dart b/lib/src/components/form/items/misc/brn_title_item.dart index a9451a14..22dbbd34 100644 --- a/lib/src/components/form/items/misc/brn_title_item.dart +++ b/lib/src/components/form/items/misc/brn_title_item.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -12,23 +10,23 @@ import 'package:flutter/widgets.dart'; // ignore: must_be_immutable class BrnTitleFormItem extends StatefulWidget { /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String label; + final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.LABEL_TITLE; + final String type = BrnInputItemType.LABEL_TITLE; /// 录入项标题 final String title; /// 录入项子标题 - final String subTitle; + final String? subTitle; /// 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 /// 1. 若赋值为 空字符串("")时仅展示"问号"图标, /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 录入项前缀图标样式 "添加项" "删除项" 详见 PrefixIconType类 final String prefixIconType; @@ -43,27 +41,27 @@ class BrnTitleFormItem extends StatefulWidget { final bool isRequire; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 点击操作区标识 - final String operationLabel; + final String? operationLabel; /// 点击回调 - final VoidCallback onTap; + final VoidCallback? onTap; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnTitleFormItem( - {Key key, + {Key? key, this.label, - this.title: "", + this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, - this.error: "", - this.isEdit: true, - this.isRequire: false, + this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.error = "", + this.isEdit = true, + this.isRequire = false, this.onTip, this.operationLabel, this.onTap, @@ -71,7 +69,7 @@ class BrnTitleFormItem extends StatefulWidget { : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -106,7 +104,7 @@ class BrnTitleFormItemState extends State { // 主标题 Container( child: Text( - widget.title ?? "", + widget.title, style: BrnFormUtil.getHeadTitleTextStyle(widget.themeData), )), @@ -134,7 +132,7 @@ class BrnTitleFormItemState extends State { child: Text( widget.operationLabel ?? "", style: TextStyle( - color: widget.themeData.commonConfig.brandPrimary, + color: widget.themeData!.commonConfig.brandPrimary, fontSize: BrnFonts.f16, ), )), diff --git a/lib/src/components/form/items/title/brn_base_title_item.dart b/lib/src/components/form/items/title/brn_base_title_item.dart index f0bb80a0..9fec7d5b 100644 --- a/lib/src/components/form/items/title/brn_base_title_item.dart +++ b/lib/src/components/form/items/title/brn_base_title_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -18,7 +18,7 @@ class BrnBaseTitle extends StatefulWidget { final String title; /// 子标题 - final String subTitle; + final String? subTitle; /// 是否必填项 final bool isRequire; @@ -34,30 +34,30 @@ class BrnBaseTitle extends StatefulWidget { /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 标题Widget - final Widget titleWidget; + final Widget? titleWidget; /// 子标题Widget - final Widget subTitleWidget; + final Widget? subTitleWidget; /// 右侧自定义操作区 - final Widget customActionWidget; + final Widget? customActionWidget; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnBaseTitle({ - Key key, - this.title: "", + Key? key, + this.title= "", this.subTitle, - this.isRequire: false, - this.isEdit: true, - this.error: "", + this.isRequire= false, + this.isEdit= true, + this.error= "", this.tipLabel, this.titleWidget, this.subTitleWidget, @@ -67,7 +67,7 @@ class BrnBaseTitle extends StatefulWidget { }) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -128,7 +128,7 @@ class BrnTitleState extends State { // 副标题 Offstage( - offstage: (widget.subTitle == null || widget.subTitle.isEmpty), + offstage: (widget.subTitle == null || widget.subTitle!.isEmpty), child: getSubTitleWidget(), ), @@ -141,7 +141,7 @@ class BrnTitleState extends State { Widget getTitleWidget() { if (widget.titleWidget != null) { - return widget.titleWidget; + return widget.titleWidget!; } else { return BrnFormUtil.buildTitleWidget(widget.title, widget.themeData); } diff --git a/lib/src/components/form/items/title/brn_select_all_title_item.dart b/lib/src/components/form/items/title/brn_select_all_title_item.dart index d0a4831d..f30ef610 100644 --- a/lib/src/components/form/items/title/brn_select_all_title_item.dart +++ b/lib/src/components/form/items/title/brn_select_all_title_item.dart @@ -1,10 +1,7 @@ -// @dart=2.9 - import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/items/title/brn_base_title_item.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/radio/brn_checkbox.dart'; -import 'package:bruno/src/components/radio/brn_radio_core.dart'; import 'package:bruno/src/theme/brn_theme.dart'; import 'package:flutter/widgets.dart'; @@ -19,7 +16,7 @@ class BrnSelectAllTitle extends StatefulWidget { final String title; /// 子标题 - final String subTitle; + final String? subTitle; /// 是否必填项 final bool isRequire; @@ -35,42 +32,42 @@ class BrnSelectAllTitle extends StatefulWidget { /// 2. 若赋值为非空字符串时 展示"问号图标&文案", /// 3. 若不赋值或赋值为null时 不显示提示项 /// 默认值为 3 - final String tipLabel; + final String? tipLabel; /// 标题Widget - final Widget titleWidget; + final Widget? titleWidget; /// 子标题Widget - final Widget subTitleWidget; + final Widget? subTitleWidget; /// 右侧自定义操作区 - final Widget customActionWidget; + final Widget? customActionWidget; /// 点击"?"图标回调 - final VoidCallback onTip; + final VoidCallback? onTip; /// 全选状态回调 - final OnBrnFormSelectAll onSelectAll; + final OnBrnFormSelectAll? onSelectAll; /// 选中项文案 - final String selectText; + final String? selectText; /// 选中项Widget - final Widget selectTextWidget; + final Widget? selectTextWidget; /// 选中项状态 - bool selectState; + final bool selectState; /// form配置 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; BrnSelectAllTitle({ - Key key, - this.title: "", + Key? key, + this.title = "", this.subTitle, - this.isRequire: false, - this.isEdit: true, - this.error: "", + this.isRequire = false, + this.isEdit = true, + this.error = "", this.tipLabel, this.titleWidget, this.subTitleWidget, @@ -78,13 +75,13 @@ class BrnSelectAllTitle extends StatefulWidget { this.onSelectAll, this.selectText, this.selectTextWidget, - this.selectState: true, + this.selectState = true, this.themeData, this.customActionWidget, }) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -96,16 +93,18 @@ class BrnSelectAllTitle extends StatefulWidget { } class BrnSelectAllTitleState extends State { + late bool _selectState; + @override void initState() { super.initState(); + _selectState = widget.selectState; } @override void didUpdateWidget(BrnSelectAllTitle oldWidget) { super.didUpdateWidget(oldWidget); - - widget.selectState = oldWidget.selectState; + _selectState = oldWidget.selectState; } @override @@ -123,16 +122,16 @@ class BrnSelectAllTitleState extends State { child: getSelectTextWidget(), radioIndex: 0, disable: !widget.isEdit, - isSelected: widget.selectState, + isSelected: _selectState, onValueChangedAtIndex: (position, value) { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return; } - widget.selectState = value; + _selectState = value; if (widget.onSelectAll != null) { - widget.onSelectAll(position, value); + widget.onSelectAll!(position, value); } }, ), @@ -140,7 +139,7 @@ class BrnSelectAllTitleState extends State { ); } - Widget getSelectTextWidget() { + Widget? getSelectTextWidget() { if (widget.selectTextWidget != null) { return widget.selectTextWidget; } else { @@ -153,11 +152,11 @@ class BrnSelectAllTitleState extends State { } } - TextStyle getOptionTextStyle(BrnFormItemConfig themeData) { - if (widget.selectState) { + TextStyle? getOptionTextStyle(BrnFormItemConfig? themeData) { + if (_selectState) { return BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); } - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); } return BrnFormUtil.getOptionTextStyle(widget.themeData); diff --git a/lib/src/components/form/undetermined/brn_expandable_group.dart b/lib/src/components/form/undetermined/brn_expandable_group.dart index 1db00a64..c9b2d3dd 100644 --- a/lib/src/components/form/undetermined/brn_expandable_group.dart +++ b/lib/src/components/form/undetermined/brn_expandable_group.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/constants/brn_asset_constants.dart'; @@ -33,19 +33,18 @@ class BrnExpandableGroup extends StatefulWidget { /// the tile to reveal or hide the [children]. The [initiallyExpanded] property must /// be non-null. BrnExpandableGroup({ - Key key, - @required this.title, + Key? key, + required this.title, this.subtitle, this.backgroundColor, this.onExpansionChanged, this.children = const [], this.initiallyExpanded = false, this.themeData, - }) : assert(initiallyExpanded != null), - super(key: key) { + }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -59,15 +58,14 @@ class BrnExpandableGroup extends StatefulWidget { /// /// Typically a [Text] widget. - @Deprecated('message') - final String subtitle; + final String? subtitle; /// Called when the tile expands or collapses. /// /// When the tile starts expanding, this function is called with the value /// true. When the tile starts collapsing, this function is called with /// the value false. - final ValueChanged onExpansionChanged; + final ValueChanged? onExpansionChanged; /// The widgets that are displayed when the tile expands. /// @@ -75,12 +73,12 @@ class BrnExpandableGroup extends StatefulWidget { final List children; /// The color to display behind the sublist when expanded. - final Color backgroundColor; + final Color? backgroundColor; /// Specifies if the list tile is initially expanded (true) or collapsed (false, the default). final bool initiallyExpanded; - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; @override _BrnExpansionElementState createState() => _BrnExpansionElementState(); @@ -99,13 +97,13 @@ class _BrnExpansionElementState extends State final ColorTween _iconColorTween = ColorTween(); final ColorTween _backgroundColorTween = ColorTween(); - AnimationController _controller; - Animation _iconTurns; - Animation _heightFactor; + late AnimationController _controller; + late Animation _iconTurns; + late Animation _heightFactor; bool _isExpanded = false; - Widget arrowIcon; + Widget? arrowIcon; @override void initState() { @@ -154,10 +152,10 @@ class _BrnExpansionElementState extends State PageStorage.of(context)?.writeState(context, _isExpanded); }); if (widget.onExpansionChanged != null) - widget.onExpansionChanged(_isExpanded); + widget.onExpansionChanged!(_isExpanded); } - Widget _buildHeader(BuildContext context, Widget child) { + Widget _buildHeader(BuildContext context, Widget? child) { final Color backgroundColor = Colors.transparent; return Container( @@ -183,7 +181,7 @@ class _BrnExpansionElementState extends State Container( padding: EdgeInsets.only(right: 6), child: Text( - widget.title ?? "", + widget.title, style: BrnFormUtil.getHeadTitleTextStyle( widget.themeData, isBold: true), @@ -196,7 +194,7 @@ class _BrnExpansionElementState extends State child: Offstage( // ignore: deprecated_member_use_from_same_package offstage: (widget.subtitle == null || - widget.subtitle.isEmpty), + widget.subtitle!.isEmpty), child: Text( // ignore: deprecated_member_use_from_same_package widget.subtitle ?? "", @@ -238,8 +236,8 @@ class _BrnExpansionElementState extends State /// title 文字颜色 _headerColorTween - ..begin = theme.textTheme.subtitle1.color - ..end = theme.textTheme.subtitle1.color; + ..begin = theme.textTheme.subtitle1!.color + ..end = theme.textTheme.subtitle1!.color; /// 展开收起图标颜色 _iconColorTween diff --git a/lib/src/components/form/undetermined/brn_portrait_radio_group.dart b/lib/src/components/form/undetermined/brn_portrait_radio_group.dart index 9346152d..5bf02e8c 100644 --- a/lib/src/components/form/undetermined/brn_portrait_radio_group.dart +++ b/lib/src/components/form/undetermined/brn_portrait_radio_group.dart @@ -1,9 +1,6 @@ -// @dart=2.9 - import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/line/brn_line.dart'; -import 'package:bruno/src/components/radio/brn_radio_core.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -11,7 +8,7 @@ import 'package:flutter/widgets.dart'; /// 备选项点击时的回调。[oldStr] 旧的选项,如果初始没有选中项,该参数为null,[newStr] 新选中的选项。 typedef BrnPortraitRadioGroupOnChanged = void Function( - BrnPortraitRadioGroupOption oldStr, BrnPortraitRadioGroupOption newStr); + BrnPortraitRadioGroupOption? oldStr, BrnPortraitRadioGroupOption newStr); /// 纵向放置的单选 radio 视图。选项可为单行字符串,也可是标题+说明两部分。具体参见 [BrnPortraitRadioGroupOption]。 /// 选项的标题/子标题文字样式分别通过 [BrnFormItemConfig.optionTextStyle] 和 [BrnFormItemConfig.subTitleTextStyle] 控 @@ -22,16 +19,16 @@ class BrnPortraitRadioGroup extends StatefulWidget { final bool isEdit; /// 初始化时默认选中的项,匹配逻辑是 [BrnPortraitRadioGroupOption.title] 和 [BrnPortraitRadioGroupOption.subTitle] 都相等。 - BrnPortraitRadioGroupOption selectedOption; + final BrnPortraitRadioGroupOption? selectedOption; /// 备选项数组,参数类型为 [BrnPortraitRadioGroupOption] - List options; + final List? options; /// 备选项可用状态数组 - final List enableList; + final List? enableList; /// 选项变化回调 - final BrnPortraitRadioGroupOnChanged onChanged; + final BrnPortraitRadioGroupOnChanged? onChanged; /// [options] 中 title subTitle 是否换行展示。 /// false: 换行展示 @@ -40,38 +37,40 @@ class BrnPortraitRadioGroup extends StatefulWidget { final bool isCollapseContent; /// 主题配置数据 - BrnFormItemConfig themeData; + BrnFormItemConfig? themeData; /// 通过传入一个字符串数组 [options],快捷构造出单行选项文案的纵向单选视图。 BrnPortraitRadioGroup.withSimpleList({ - Key key, + Key? key, this.isEdit = true, - String selectedOption, - List options, + String selectedOption = "", + required List options, this.enableList, this.onChanged, this.themeData, this.isCollapseContent = false, - }) { - this.options = options - ?.map((item) => BrnPortraitRadioGroupOption(title: item)) - ?.toList() ?? - List(); - int selectedIndex = options.indexOf(selectedOption); - if (selectedIndex > -1) { - this.selectedOption = this.options[selectedIndex]; - } - + }) : this.options = options + .map((item) => BrnPortraitRadioGroupOption(title: item)) + .toList(), + this.selectedOption = options.indexOf(selectedOption) > -1 + ? BrnPortraitRadioGroupOption( + title: options[options.indexOf(selectedOption)]) + : BrnPortraitRadioGroupOption() +// int selectedIndex = options.indexOf(selectedOption); +// if (selectedIndex > -1) { +// this.selectedOption = this.options![selectedIndex]; +// } + { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } /// 通过 [BrnPortraitRadioGroupOption] 类型的数组 [options],构造纵向单选视图。 BrnPortraitRadioGroup.withOptions({ - Key key, + Key? key, this.isEdit = true, this.selectedOption, this.options, @@ -82,7 +81,7 @@ class BrnPortraitRadioGroup extends StatefulWidget { }) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .formItemConfig .merge(this.themeData); } @@ -94,9 +93,12 @@ class BrnPortraitRadioGroup extends StatefulWidget { } class BrnPortraitRadioGroupState extends State { + late BrnPortraitRadioGroupOption? _selectedOption; + @override void initState() { super.initState(); + _selectedOption = widget.selectedOption; } @override @@ -110,8 +112,8 @@ class BrnPortraitRadioGroupState extends State { ); } - List getRadioList(List options) { - List result = List(); + List getRadioList(List? options) { + List result = []; BrnPortraitRadioGroupOption option; if (options == null || options.isEmpty) { result.add(Container()); @@ -151,16 +153,16 @@ class BrnPortraitRadioGroupState extends State { if (getRadioEnableState(position)) { return; } - BrnPortraitRadioGroupOption oldValue = widget.selectedOption; - widget.selectedOption = options[position]; + BrnPortraitRadioGroupOption? oldValue = _selectedOption; + _selectedOption = options[position]; if (widget.onChanged != null) { - widget.onChanged(oldValue, options[position]); + widget.onChanged!(oldValue, options[position]); } setState(() {}); }, ), Visibility( - visible: option.subTitle != null && option.subTitle.length > 0, + visible: option.subTitle != null && option.subTitle!.length > 0, child: Padding( padding: EdgeInsets.only(top: 4, right: 20), child: Text( @@ -188,8 +190,8 @@ class BrnPortraitRadioGroupState extends State { int getGroupValue() { int selectedIndex = -1; - for (int index = 0; index < widget.options.length; index++) { - if (isSameOption(widget.options[index], widget.selectedOption)) { + for (int index = 0; index < widget.options!.length; index++) { + if (isSameOption(widget.options![index], _selectedOption)) { selectedIndex = index; break; } @@ -198,29 +200,26 @@ class BrnPortraitRadioGroupState extends State { } bool isSameOption( - BrnPortraitRadioGroupOption src, BrnPortraitRadioGroupOption dst) { - if (src == null || dst == null) return false; + BrnPortraitRadioGroupOption src, BrnPortraitRadioGroupOption? dst) { + if (dst == null) return false; return src.title == dst.title && src.subTitle == dst.subTitle; } - TextStyle getOptionTextStyle(BrnPortraitRadioGroupOption opt, int index) { - TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (opt == null /*|| widget.value == null*/) { - return result; - } + TextStyle? getOptionTextStyle(BrnPortraitRadioGroupOption opt, int index) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (isSameOption(opt, widget.selectedOption)) { + if (isSameOption(opt, _selectedOption)) { result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); } - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); } if (widget.enableList != null && - widget.enableList.isNotEmpty && - widget.enableList.length > index && - !widget.enableList[index]) { + widget.enableList!.isNotEmpty && + widget.enableList!.length > index && + !widget.enableList![index]) { result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); } @@ -228,27 +227,27 @@ class BrnPortraitRadioGroupState extends State { } bool getRadioEnableState(int index) { - if (widget.isEdit != null && !widget.isEdit) { + if (!widget.isEdit) { return true; } if (widget.enableList == null || - widget.enableList.isEmpty || - widget.enableList.length < index) { + widget.enableList!.isEmpty || + widget.enableList!.length < index) { return false; } - return !widget.enableList[index]; + return !widget.enableList![index]; } } /// 纵置单选视图的选项模型。文字样式见 [BrnPortraitRadioGroup] 说明。 class BrnPortraitRadioGroupOption { /// 标题 - String title; + String? title; /// 子标题说明文案 - String subTitle; + String? subTitle; BrnPortraitRadioGroupOption({this.title, this.subTitle}); } diff --git a/lib/src/components/form/utils/brn_form_util.dart b/lib/src/components/form/utils/brn_form_util.dart index 78ddb05a..2831c1cd 100644 --- a/lib/src/components/form/utils/brn_form_util.dart +++ b/lib/src/components/form/utils/brn_form_util.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; @@ -14,7 +14,7 @@ class BrnFormUtil { /// 获取添加、删除图标 static Widget buildPrefixIcon(String prefixIconType, bool isEdit, - BuildContext context, VoidCallback onAddTap, VoidCallback onRemoveTap) { + BuildContext context, VoidCallback? onAddTap, VoidCallback? onRemoveTap) { return Offstage( offstage: prefixIconType == BrnPrefixIconType.TYPE_NORMAL, child: Container( @@ -35,13 +35,13 @@ class BrnFormUtil { } /// 获取错误提示widget - static Widget buildErrorWidget(String error, BrnFormItemConfig themeData) { + static Widget buildErrorWidget(String error, BrnFormItemConfig? themeData) { return Container( padding: errorEdgeInsets(themeData), child: Offstage( - offstage: (error == null || error.isEmpty), + offstage: (error.isEmpty), child: Text( - error ?? "", + error, style: getErrorTextStyle(themeData), )), ); @@ -49,7 +49,7 @@ class BrnFormUtil { /// 获取子标题Widget static Widget buildSubTitleWidget( - String subTitle, BrnFormItemConfig themeData) { + String? subTitle, BrnFormItemConfig? themeData) { return Offstage( offstage: (subTitle == null || subTitle.isEmpty), child: Container( @@ -64,14 +64,14 @@ class BrnFormUtil { /// 获取必填项 static Widget buildRequireWidget(bool isRequire) { return Offstage( - offstage: (isRequire == null || !isRequire), + offstage: (!isRequire), child: BrnFormUtil.getRequireIcon(isRequire), ); } /// 获取问号 static Widget buildTipLabelWidget( - String tipLabel, VoidCallback onTip, BrnFormItemConfig themeData) { + String? tipLabel, VoidCallback? onTip, BrnFormItemConfig? themeData) { return Offstage( offstage: (tipLabel == null), child: GestureDetector( @@ -99,19 +99,16 @@ class BrnFormUtil { } /// 获取二级标题Widget - static Widget buildTitleWidget(String title, BrnFormItemConfig themeData) { + static Widget buildTitleWidget(String title, BrnFormItemConfig? themeData) { return Container( child: Text( - title ?? "", + title, style: BrnFormUtil.getTitleTextStyle(themeData), )); } /// 录入项是否可编辑 static bool isEdit(bool isEdit) { - if (isEdit == null) { - return true; - } return isEdit; } @@ -126,7 +123,7 @@ class BrnFormUtil { } static Widget getPrefixIconWithDisable(String type, bool isEnabled) { - return (isEnabled ?? true) + return (isEnabled) ? BrnFormUtil.getPrefixIcon(type) : ColorFiltered( colorFilter: ColorFilter.mode( @@ -140,7 +137,6 @@ class BrnFormUtil { } static Widget getRequireIcon(bool isRequire) { - isRequire ??= false; return Container( padding: @@ -164,13 +160,11 @@ class BrnFormUtil { /// 设置录入项总的padding, 不包括顶部和底部padding static EdgeInsets computeItemEdgeInsets2(String type, bool isRequire) { - isRequire ??= false; return EdgeInsets.fromLTRB(0, 0, 20, 14); } /// 设置内容行padding, 包括顶部和底部padding static EdgeInsets computeEdgeInsets2(String type, bool isRequire) { - isRequire ??= false; if (isRequire && type == BrnPrefixIconType.TYPE_NORMAL) { return EdgeInsets.only(left: 10, top: 14); } @@ -179,14 +173,13 @@ class BrnFormUtil { } static EdgeInsets computeErrorEdgeInsets(String type, bool isRequire) { - isRequire ??= false; return EdgeInsets.only( left: 20, top: 4, ); } - static TextInputType getInputType(String type) { + static TextInputType getInputType(String? type) { TextInputType inputType = TextInputType.text; if (type == null || type.isEmpty) { @@ -234,7 +227,7 @@ class BrnFormUtil { /// 处理点击"添加/删除"按钮动作 static void notifyAddRemoveTap(BuildContext context, String prefixIconType, - VoidCallback onAddTap, VoidCallback onRemoveTap) { + VoidCallback? onAddTap, VoidCallback? onRemoveTap) { if (BrnPrefixIconType.TYPE_ADD == prefixIconType) { if (onAddTap != null) { onAddTap(); @@ -247,21 +240,21 @@ class BrnFormUtil { } /// 处理点击"添加/删除"按钮动作 - static void notifyAddTap(BuildContext context, VoidCallback onAddTap) { + static void notifyAddTap(BuildContext context, VoidCallback? onAddTap) { if (onAddTap != null) { onAddTap(); } } /// 处理点击"添加/删除"按钮动作 - static void notifyRemoveTap(BuildContext context, VoidCallback onRemoveTap) { + static void notifyRemoveTap(BuildContext context, VoidCallback? onRemoveTap) { if (onRemoveTap != null) { onRemoveTap(); } } /// 处理点击"按钮"动作 - static void notifyTap(BuildContext context, VoidCallback onWidgetTap) { + static void notifyTap(BuildContext context, VoidCallback? onWidgetTap) { if (onWidgetTap != null) { onWidgetTap(); } @@ -269,14 +262,14 @@ class BrnFormUtil { /// 处理 输入状态 变化 static void notifyInputChanged( - ValueChanged onTextChanged, String newStr) { + ValueChanged? onTextChanged, String newStr) { if (onTextChanged != null) { onTextChanged(/*oldStr, */ newStr); } } /// 处理 开关 变化 - static void notifySwitchChanged(OnBrnFormSwitchChanged onSwitchChanged, + static void notifySwitchChanged(OnBrnFormSwitchChanged? onSwitchChanged, BuildContext context, bool oldValue, bool newValue) { if (onSwitchChanged != null) { onSwitchChanged(oldValue, newValue); @@ -284,7 +277,7 @@ class BrnFormUtil { } /// 处理 数字值 变化 - static void notifyValueChanged(OnBrnFormValueChanged onValueChanged, + static void notifyValueChanged(OnBrnFormValueChanged? onValueChanged, BuildContext context, int oldVal, int newVal) { if (onValueChanged != null) { onValueChanged(oldVal, newVal); @@ -292,22 +285,22 @@ class BrnFormUtil { } /// 处理 单选选中状态变化 - static void notifyRadioStatusChanged(OnBrnFormRadioValueChanged onTextChanged, - BuildContext context, Object oldVal, Object newVal) { + static void notifyRadioStatusChanged(OnBrnFormRadioValueChanged? onTextChanged, + BuildContext context, Object? oldVal, Object? newVal) { if (onTextChanged != null) { - onTextChanged(oldVal, newVal); + onTextChanged(oldVal as String?, newVal as String?); } } /// 处理 多选选中状态变化 static void notifyMultiChoiceStatusChanged( - OnBrnFormMultiChoiceValueChanged onChoiceChanged, + OnBrnFormMultiChoiceValueChanged? onChoiceChanged, BuildContext context, Object oldVal, - Object newVal, + Object? newVal, ) { if (onChoiceChanged != null) { - onChoiceChanged(oldVal, newVal); + onChoiceChanged(oldVal as List, newVal as List?); } } @@ -316,19 +309,18 @@ class BrnFormUtil { /// /// 选项之间的间距 - static EdgeInsets optionsMiddlePadding(BrnFormItemConfig themeData) { + static EdgeInsets? optionsMiddlePadding(BrnFormItemConfig? themeData) { return themeData?.optionsMiddlePadding; } /// 走主题配置 上下右间距 - static EdgeInsets itemEdgeInsets(BrnFormItemConfig themeData) { + static EdgeInsets? itemEdgeInsets(BrnFormItemConfig? themeData) { return themeData?.formPadding; } /// 标题行的左间距 - static EdgeInsets titleEdgeInsets( - String type, bool isRequire, BrnFormItemConfig themeData) { - isRequire ??= false; + static EdgeInsets? titleEdgeInsets( + String type, bool isRequire, BrnFormItemConfig? themeData) { if (isRequire && type == BrnPrefixIconType.TYPE_NORMAL) { return themeData?.titlePaddingSm; } @@ -336,96 +328,94 @@ class BrnFormUtil { } /// 标题行的左间距 - static EdgeInsets titleEdgeInsetsForHead( - bool isRequire, BrnFormItemConfig themeData) { - isRequire ??= false; + static EdgeInsets? titleEdgeInsetsForHead( + bool isRequire, BrnFormItemConfig? themeData) { return isRequire ? themeData?.titlePaddingSm : themeData?.titlePaddingLg; } /// 子标题的右上间距 - static EdgeInsets subTitleEdgeInsets(BrnFormItemConfig themeData) { + static EdgeInsets? subTitleEdgeInsets(BrnFormItemConfig? themeData) { return themeData?.subTitlePadding; } /// error的右上间距 - static EdgeInsets errorEdgeInsets(BrnFormItemConfig themeData) { + static EdgeInsets? errorEdgeInsets(BrnFormItemConfig? themeData) { return themeData?.errorPadding; } /// 提示文本样式 - static TextStyle getTipsTextStyle(BrnFormItemConfig themeData) { - return themeData?.tipsTextStyle?.generateTextStyle(); + static TextStyle? getTipsTextStyle(BrnFormItemConfig? themeData) { + return themeData?.tipsTextStyle.generateTextStyle(); } /// 获取 右侧 输入、选择默认文本样式 - static TextStyle getHintTextStyle(BrnFormItemConfig themeData, + static TextStyle? getHintTextStyle(BrnFormItemConfig? themeData, {double height = 0}) { if (height > 0) { return BrnTextStyle(height: height) .merge(themeData?.hintTextStyle) - ?.generateTextStyle(); + .generateTextStyle(); } - return themeData?.hintTextStyle?.generateTextStyle(); + return themeData?.hintTextStyle.generateTextStyle(); } /// 获取是否可编辑的字体 - static TextStyle getIsEditTextStyle(BrnFormItemConfig themeData, bool isEdit, + static TextStyle? getIsEditTextStyle(BrnFormItemConfig? themeData, bool isEdit, {double height = 0}) { - isEdit ??= true; if (height > 0) { return isEdit ? BrnTextStyle(height: height) .merge(themeData?.contentTextStyle) - ?.generateTextStyle() + .generateTextStyle() : BrnTextStyle(height: height) .merge(themeData?.disableTextStyle) - ?.generateTextStyle(); + .generateTextStyle(); } return isEdit - ? themeData?.contentTextStyle?.generateTextStyle() - : themeData?.disableTextStyle?.generateTextStyle(); + ? themeData?.contentTextStyle.generateTextStyle() + : themeData?.disableTextStyle.generateTextStyle(); } /// 获取标题文本样式 - static TextStyle getTitleTextStyle(BrnFormItemConfig themeData, + static TextStyle? getTitleTextStyle(BrnFormItemConfig? themeData, {double height = 0}) { if (height > 0) { return BrnTextStyle(height: height) .merge(themeData?.titleTextStyle) - ?.generateTextStyle(); + .generateTextStyle(); } - return themeData?.titleTextStyle?.generateTextStyle(); + return themeData?.titleTextStyle.generateTextStyle(); } /// 获取标题文本样式 - static TextStyle getHeadTitleTextStyle(BrnFormItemConfig themeData, + static TextStyle? getHeadTitleTextStyle(BrnFormItemConfig? themeData, {bool isBold = false}) { if (isBold) { return themeData?.headTitleTextStyle - ?.merge(BrnTextStyle(fontWeight: FontWeight.w600)) - ?.generateTextStyle(); + .merge(BrnTextStyle(fontWeight: FontWeight.w600)) + .generateTextStyle(); } - return themeData?.headTitleTextStyle?.generateTextStyle(); + return themeData?.headTitleTextStyle.generateTextStyle(); } /// 获取左侧辅助样式 - static TextStyle getSubTitleTextStyle(BrnFormItemConfig themeData) { - return themeData?.subTitleTextStyle?.generateTextStyle(); + static TextStyle? getSubTitleTextStyle(BrnFormItemConfig? themeData) { + return themeData?.subTitleTextStyle.generateTextStyle(); } /// 获取error 文本样式 - static TextStyle getErrorTextStyle(BrnFormItemConfig themeData) { - return themeData?.errorTextStyle?.generateTextStyle(); + static TextStyle? getErrorTextStyle(BrnFormItemConfig? themeData) { + return themeData?.errorTextStyle.generateTextStyle(); } /// 获取选项文本样式 - static TextStyle getOptionTextStyle(BrnFormItemConfig themeData) { - return themeData?.optionTextStyle?.generateTextStyle(); + static TextStyle? getOptionTextStyle(BrnFormItemConfig? themeData) { + return themeData?.optionTextStyle.generateTextStyle(); } /// 获取选中选项文本样式 - static TextStyle getOptionSelectedTextStyle(BrnFormItemConfig themeData) { - return themeData?.optionSelectedTextStyle?.generateTextStyle(); + static TextStyle? getOptionSelectedTextStyle(BrnFormItemConfig? themeData) { + return themeData?.optionSelectedTextStyle.generateTextStyle(); } /// @@ -445,7 +435,7 @@ class BrnFormUtil { /// 当左右内容超出默认比例且「无」提示语,则按比例 4:6 布局 /// 有用户自定义比例时用用户自定义比例 static double getAutoLayoutContentRatio( - {bool tipLabelHidden, double layoutRatio}) { + {required bool tipLabelHidden, double? layoutRatio}) { double defaultRatio = tipLabelHidden ? BrnFormUtil.contentRatio : 1 - BrnFormUtil.contentRatio; From 07c308a18cfe7c4536b70fd9c4a9e98dd317ead7 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 18 Jan 2022 16:42:42 +0800 Subject: [PATCH 16/31] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8Dtabbar?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=8F=8Aselection=E8=AD=A6=E5=91=8A=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bruno.dart | 1 - .../components/navbar/brn_empty_appbar.dart | 19 --------------- lib/src/components/navbar/brn_search_bar.dart | 4 ++-- .../bean/brn_selection_common_entity.dart | 15 ++++++------ .../selection/brn_flat_selection.dart | 2 +- .../selection/brn_more_selection.dart | 4 ++-- .../selection/brn_selection_util.dart | 18 +++++--------- .../converter/brn_selection_converter.dart | 2 +- .../widget/brn_flat_selection_item.dart | 10 ++++---- .../widget/brn_layer_more_selection_page.dart | 14 +++++------ ...n_selection_datepicker_animate_widget.dart | 2 +- .../brn_selection_menu_item_widget.dart | 4 ++-- .../widget/brn_selection_menu_widget.dart | 8 +++---- .../brn_selection_more_item_widget.dart | 14 +++++------ ...brn_selection_range_input_item_widget.dart | 10 ++++---- .../widget/brn_selection_range_widget.dart | 24 +++++++++---------- .../components/tabbar/normal/brn_tab_bar.dart | 2 +- 17 files changed, 62 insertions(+), 91 deletions(-) delete mode 100644 lib/src/components/navbar/brn_empty_appbar.dart diff --git a/lib/bruno.dart b/lib/bruno.dart index ff6a001f..07ca0022 100644 --- a/lib/bruno.dart +++ b/lib/bruno.dart @@ -84,7 +84,6 @@ export 'src/components/loading/brn_loading.dart'; //导航栏 export 'src/components/navbar/brn_appbar.dart'; -export 'src/components/navbar/brn_empty_appbar.dart'; //搜索bar export 'src/components/navbar/brn_search_bar.dart'; diff --git a/lib/src/components/navbar/brn_empty_appbar.dart b/lib/src/components/navbar/brn_empty_appbar.dart deleted file mode 100644 index 5ec80181..00000000 --- a/lib/src/components/navbar/brn_empty_appbar.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; - -class BrnEmptyAppBar extends PreferredSize { - final double height; - final Color? color; - - BrnEmptyAppBar(this.height, {this.color}) - : super(child: Container(), preferredSize: const Size(0, 0)); - - @override - Size get preferredSize => Size.fromHeight(height); - - @override - Widget build(BuildContext context) { - return Container( - color: color ?? Colors.white, - ); - } -} diff --git a/lib/src/components/navbar/brn_search_bar.dart b/lib/src/components/navbar/brn_search_bar.dart index c83fbb9d..802ab87e 100644 --- a/lib/src/components/navbar/brn_search_bar.dart +++ b/lib/src/components/navbar/brn_search_bar.dart @@ -167,7 +167,7 @@ class _SearchInputWidget extends StatefulWidget { this.textEditingController, this.searchBarInputChangeCallback, this.searchBarInputSubmitCallback, - this.hint, + this.hint= '请输入搜索内容', this.hintStyle, this.inputTextStyle, this.showDivider = true, @@ -308,7 +308,7 @@ class __SearchInputWidgetState extends State<_SearchInputWidget> { color: _defaultHintTextColor, ), // 提示文本属性,提示字段接受哪种输入的文本。 - hintText: widget.hint ?? "请输入搜索内容", + hintText: widget.hint, ), // 在改变属性,当正在编辑的文本发生更改时调用。 onChanged: (content) { diff --git a/lib/src/components/selection/bean/brn_selection_common_entity.dart b/lib/src/components/selection/bean/brn_selection_common_entity.dart index d35179f2..603093c5 100644 --- a/lib/src/components/selection/bean/brn_selection_common_entity.dart +++ b/lib/src/components/selection/bean/brn_selection_common_entity.dart @@ -163,7 +163,7 @@ class BrnSelectionEntity { entity.maxSelectedCount = BrnSelectionConstant.maxSelectCount; } entity.extMap = map['ext'] ?? {}; - entity.children = []..addAll((map['children'] as List ?? []) + entity.children = []..addAll((map['children'] as List) .map((o) => BrnSelectionEntity.fromMap(o))); entity.filterType = entity.parserFilterTypeWithType(map['type'] ?? ""); return entity; @@ -340,20 +340,19 @@ class BrnSelectionEntity { List selectedListWithoutUnlimit() { List selected = selectedList(); return selected - ?.where((_) => !_.isUnLimit()) - ?.where((_) => + .where((_) => !_.isUnLimit()) + .where((_) => (_.filterType != BrnSelectionFilterType.Range) || (_.filterType == BrnSelectionFilterType.Range && !BrunoTools.isEmpty(_.customMap))) - ?.where((_) => + .where((_) => (_.filterType != BrnSelectionFilterType.DateRange) || (_.filterType == BrnSelectionFilterType.DateRange && !BrunoTools.isEmpty(_.customMap))) - ?.where((_) => + .where((_) => (_.filterType != BrnSelectionFilterType.DateRangeCalendar) || (_.filterType == BrnSelectionFilterType.DateRangeCalendar && !BrunoTools.isEmpty(_.customMap))) - ?.toList() ?? - []; + .toList(); } List selectedList() { @@ -460,7 +459,7 @@ class BrnSelectionEntity { /// 检查自己的兄弟结点是否存在 checkbox 类型。 bool hasCheckBoxBrother() { int? count = - parent?.children.where((f) => f.filterType == BrnSelectionFilterType.Checkbox)?.length; + parent?.children.where((f) => f.filterType == BrnSelectionFilterType.Checkbox).length; return count == null ? false : count > 0; } diff --git a/lib/src/components/selection/brn_flat_selection.dart b/lib/src/components/selection/brn_flat_selection.dart index 744254a8..ae1664f0 100644 --- a/lib/src/components/selection/brn_flat_selection.dart +++ b/lib/src/components/selection/brn_flat_selection.dart @@ -74,7 +74,7 @@ class _BrnFlatSelectionState extends State with SingleTickerPr super.initState(); if (widget.isNeedConfigChild) { - widget.entityDataList?.forEach((f) => f.configRelationshipAndDefaultValue()); + widget.entityDataList.forEach((f) => f.configRelationshipAndDefaultValue()); } widget.controller?.addListener(_handleFlatControllerTick); diff --git a/lib/src/components/selection/brn_more_selection.dart b/lib/src/components/selection/brn_more_selection.dart index 7fb68038..04b5e02f 100644 --- a/lib/src/components/selection/brn_more_selection.dart +++ b/lib/src/components/selection/brn_more_selection.dart @@ -61,7 +61,7 @@ class _BrnMoreSelectionPageState extends State animation = Tween(end: Offset.zero, begin: Offset(1.0, 0.0)).animate(_controller); _controller.forward(); - _originalSelectedItemsList.addAll(widget.entityData.allSelectedList() ?? []); + _originalSelectedItemsList.addAll(widget.entityData.allSelectedList()); for (BrnSelectionEntity entity in _originalSelectedItemsList) { entity.isSelected = true; if (entity.customMap != null) { @@ -128,7 +128,7 @@ class _BrnMoreSelectionPageState extends State @override void dispose() { super.dispose(); - _controller?.dispose(); + _controller.dispose(); } /// 左侧为透明黑,点击直接退出页面 diff --git a/lib/src/components/selection/brn_selection_util.dart b/lib/src/components/selection/brn_selection_util.dart index 4ecf1d52..f4111222 100644 --- a/lib/src/components/selection/brn_selection_util.dart +++ b/lib/src/components/selection/brn_selection_util.dart @@ -28,12 +28,12 @@ class BrnSelectionUtil { } } if (BrnSelectionFilterType.Radio == selectionEntity.filterType) { - selectionEntity?.parent?.clearChildSelection(); + selectionEntity.parent?.clearChildSelection(); selectionEntity.isSelected = true; } if (BrnSelectionFilterType.Date == selectionEntity.filterType) { - selectionEntity?.parent?.clearChildSelection(); + selectionEntity.parent?.clearChildSelection(); /// 日期类型时在外部 Picker 点击确定时设置 选中状态 selectionEntity.isSelected = true; @@ -133,22 +133,16 @@ class BrnSelectionUtil { /// !!! 在设置 isSelected = true之前进行 check。 /// 返回 true 符合条件,false 不符合条件 static bool checkMaxSelectionCount(BrnSelectionEntity entity) { - if (entity == null) return false; return entity.getLimitedRootSelectedChildCount() < entity.getLimitedRootMaxSelectedCount(); } //设置数据为未选中状态 static void resetSelectionDatas(BrnSelectionEntity entity) { - if (entity == null) { - return; - } - entity?.isSelected = false; - entity?.customMap = Map(); - if (entity.children != null) { - for (BrnSelectionEntity subEntity in entity.children) { - resetSelectionDatas(subEntity); - } + entity.isSelected = false; + entity.customMap = Map(); + for (BrnSelectionEntity subEntity in entity.children) { + resetSelectionDatas(subEntity); } } } diff --git a/lib/src/components/selection/converter/brn_selection_converter.dart b/lib/src/components/selection/converter/brn_selection_converter.dart index 7709e7b0..da4f9d74 100644 --- a/lib/src/components/selection/converter/brn_selection_converter.dart +++ b/lib/src/components/selection/converter/brn_selection_converter.dart @@ -38,7 +38,7 @@ class DefaultSelectionQuickFilterConverter implements BrnSelectionConverterDeleg Map getSelectionParamsWithConfigChild(List? selectedResults) { Map params = Map(); if (selectedResults == null) return params; - selectedResults?.forEach((f) => f.configRelationshipAndDefaultValue()); + selectedResults.forEach((f) => f.configRelationshipAndDefaultValue()); return getSelectionParams(selectedResults); } diff --git a/lib/src/components/selection/widget/brn_flat_selection_item.dart b/lib/src/components/selection/widget/brn_flat_selection_item.dart index 4e834bf8..70d3d4ac 100644 --- a/lib/src/components/selection/widget/brn_flat_selection_item.dart +++ b/lib/src/components/selection/widget/brn_flat_selection_item.dart @@ -206,7 +206,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { children: [ Expanded( child: Text( - widget.selectionEntity.title ?? "", + widget.selectionEntity.title, style: widget.themeData.titleForMoreTextStyle.generateTextStyle(), ), ), @@ -480,8 +480,8 @@ class __MoreRangeWidgetState extends State<_MoreRangeWidget> { widget.rangeEntity.customMap!['min'] = minInput; if (minInput.isNotEmpty && maxInput.isNotEmpty) { - int? inputMin = int.tryParse(minController.text ?? ''); - int? inputMax = int.tryParse(maxController.text ?? ''); + int? inputMin = int.tryParse(minController.text); + int? inputMax = int.tryParse(maxController.text); if (inputMin != null && inputMin >= min && @@ -612,7 +612,7 @@ class FilterLayerTypeWidget extends StatefulWidget { class _FilterLayerTypeWidgetState extends State { @override Widget build(BuildContext context) { - widget.selectionEntity?.configDefaultValue(); + widget.selectionEntity.configDefaultValue(); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -687,7 +687,7 @@ class _FilterLayerTypeWidgetState extends State { bool isEmptyCondition() { String condition = getCondition(); - return condition == null || condition.isEmpty; + return condition.isEmpty; } String getCondition() { diff --git a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart index 035bce07..92a7fa9e 100644 --- a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart +++ b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart @@ -84,7 +84,7 @@ class _BrnLayerMoreSelectionPageState extends State @override void dispose() { super.dispose(); - _controller?.dispose(); + _controller.dispose(); } ///左侧是黑色浮层 @@ -290,11 +290,11 @@ class _BrnLayerMoreSelectionPageState extends State Widget _buildLeftItem(int index) { //如果房山 被选中了或者房山处于正在选择的状态 则加粗 - TextStyle? textStyle = widget.themeData?.flayerNormalTextStyle.generateTextStyle(); + TextStyle? textStyle = widget.themeData.flayerNormalTextStyle.generateTextStyle(); if (index == _currentIndex) { - textStyle = widget.themeData?.flayerSelectedTextStyle.generateTextStyle(); + textStyle = widget.themeData.flayerSelectedTextStyle.generateTextStyle(); } else if ((_firstList[index].isSelected) && _firstList[index].selectedList().isNotEmpty) { - textStyle = widget.themeData?.flayerBoldTextStyle.generateTextStyle(); + textStyle = widget.themeData.flayerBoldTextStyle.generateTextStyle(); } List list = _firstList[index].selectedList(); @@ -389,7 +389,7 @@ class _BrnLayerMoreSelectionPageState extends State void _initData() { //填充一级筛选数据 - _firstList = widget.entityData.children ?? []; + _firstList = widget.entityData.children; //找到一级需要显示 的索引 for (int i = 0; i < _firstList.length; i++) { if (_firstList[i].selectedList().isNotEmpty) { @@ -446,8 +446,8 @@ class _BrnLayerMoreSelectionPageState extends State return Text(entity.title, textAlign: TextAlign.left, style: entity.isSelected - ? widget.themeData?.flayerSelectedTextStyle.generateTextStyle() - : widget.themeData?.flayerNormalTextStyle.generateTextStyle()); + ? widget.themeData.flayerSelectedTextStyle.generateTextStyle() + : widget.themeData.flayerNormalTextStyle.generateTextStyle()); } } diff --git a/lib/src/components/selection/widget/brn_selection_datepicker_animate_widget.dart b/lib/src/components/selection/widget/brn_selection_datepicker_animate_widget.dart index 052a8fe3..cb5d211f 100644 --- a/lib/src/components/selection/widget/brn_selection_datepicker_animate_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_datepicker_animate_widget.dart @@ -38,7 +38,7 @@ class _BrnSelectionDatePickerAnimationWidgetState } dispose() { - widget.controller?.removeListener(_onController); + widget.controller.removeListener(_onController); _controller.dispose(); _isControllerDisposed = true; super.dispose(); diff --git a/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart b/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart index 57ef2fe8..cf74bb03 100644 --- a/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_menu_item_widget.dart @@ -45,8 +45,8 @@ class BrnSelectionMenuItemWidget extends StatelessWidget { maxLines: 1, softWrap: true, style: isHighLight - ? themeData.menuSelectedTextStyle?.generateTextStyle() - : themeData.menuNormalTextStyle?.generateTextStyle(), + ? themeData.menuSelectedTextStyle.generateTextStyle() + : themeData.menuNormalTextStyle.generateTextStyle(), ), )), Padding( diff --git a/lib/src/components/selection/widget/brn_selection_menu_widget.dart b/lib/src/components/selection/widget/brn_selection_menu_widget.dart index 8686e8b7..b550a3cf 100644 --- a/lib/src/components/selection/widget/brn_selection_menu_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_menu_widget.dart @@ -111,9 +111,9 @@ class _BrnSelectionMenuWidgetState extends State { } dispose() { - _scrollController?.removeListener(_closeSelectionPopupWindow); - _refreshTitleSubscription?.cancel(); - _closeSelectionPopupWindowSubscription?.cancel(); + _scrollController.removeListener(_closeSelectionPopupWindow); + _refreshTitleSubscription.cancel(); + _closeSelectionPopupWindowSubscription.cancel(); listViewController.hide(); super.dispose(); } @@ -160,7 +160,7 @@ class _BrnSelectionMenuWidgetState extends State { flex: 10, child: Container( height: 0.5, - color: widget.themeData?.commonConfig.dividerColorBase, + color: widget.themeData.commonConfig.dividerColorBase, ), ) ], diff --git a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart index 7a926ff8..2d582503 100644 --- a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart @@ -105,7 +105,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { setState(() { if (!event.filter) { //将所有tag设置为未选中 - event.rangeEntity.parent?.currentTagListForEntity()?.forEach((data) { + event.rangeEntity.parent?.currentTagListForEntity().forEach((data) { data.clearSelectedEntity(); }); } @@ -177,7 +177,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { Expanded( child: Text( widget.selectionEntity.title, - style: widget.themeData?.titleForMoreTextStyle.generateTextStyle(), + style: widget.themeData.titleForMoreTextStyle.generateTextStyle(), ), ), ], @@ -231,8 +231,8 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } data.parent?.children - ?.where((_) => _.filterType == BrnSelectionFilterType.Radio) - ?.forEach((f) => f.isSelected = false); + .where((_) => _.filterType == BrnSelectionFilterType.Radio) + .forEach((f) => f.isSelected = false); data.isSelected = !data.isSelected; //用于发送 标签点击事件 streamController.add(SelectEvent()); @@ -272,7 +272,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { borderRadius: BorderRadius.circular(widget.themeData.tagRadius)), height: 34, child: Text( - showName ?? '', + showName, maxLines: 2, textAlign: TextAlign.center, style: entity.isSelected ? _selectedTextStyle() : _tagTextStyle(), @@ -281,11 +281,11 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } TextStyle? _tagTextStyle() { - return widget.themeData?.tagNormalTextStyle.generateTextStyle(); + return widget.themeData.tagNormalTextStyle.generateTextStyle(); } TextStyle? _selectedTextStyle() { - return widget.themeData?.tagSelectedTextStyle.generateTextStyle(); + return widget.themeData.tagSelectedTextStyle.generateTextStyle(); } void _showDatePicker(BrnSelectionEntity data) { diff --git a/lib/src/components/selection/widget/brn_selection_range_input_item_widget.dart b/lib/src/components/selection/widget/brn_selection_range_input_item_widget.dart index c566ae61..baecf63f 100644 --- a/lib/src/components/selection/widget/brn_selection_range_input_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_range_input_item_widget.dart @@ -85,8 +85,8 @@ class _BrnSelectionRangeItemWidgetState extends State().listen((ClearSelectionFocusEvent event) { - _minFocusNode?.unfocus(); - _maxFocusNode?.unfocus(); + _minFocusNode.unfocus(); + _maxFocusNode.unfocus(); }); super.initState(); @@ -117,7 +117,7 @@ class _BrnSelectionRangeItemWidgetState extends State 0 + var tagContainer = (tagFilterList.length) > 0 ? Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 20), @@ -288,14 +288,13 @@ class _BrnRangeSelectionGroupWidgetState extends State + .where((f) => f.filterType != BrnSelectionFilterType.Range && f.filterType != BrnSelectionFilterType.DateRange && f.filterType != BrnSelectionFilterType.DateRangeCalendar && f.isSelected) - ?.toList(); + .toList(); if (!isCustomInputSelected && BrunoTools.isEmpty(selectedItem)) { for (BrnSelectionEntity item in subFilterList) { if (item.isUnLimit()) { diff --git a/lib/src/components/tabbar/normal/brn_tab_bar.dart b/lib/src/components/tabbar/normal/brn_tab_bar.dart index b1c16e4a..a377db3b 100644 --- a/lib/src/components/tabbar/normal/brn_tab_bar.dart +++ b/lib/src/components/tabbar/normal/brn_tab_bar.dart @@ -676,7 +676,7 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { return MeasureSize( onChange: (size) { setState(() { - _parentWidth = size.width; + _parentWidth = size?.width ?? 0.0; }); }, child: Container( From 0b4c168303ce738523c01173512c8c2782fcbea9 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Mon, 24 Jan 2022 12:49:06 +0800 Subject: [PATCH 17/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../items_example/title_select_example.dart | 2 +- ...selectionview_customview_example_page.dart | 4 +- lib/bruno.dart | 6 +- .../calendar/brn_calendar_view.dart | 47 +++------- .../general/brn_multi_choice_input_item.dart | 48 +++++----- .../brn_multi_choice_portrait_input_item.dart | 44 +++++---- .../general/brn_quick_select_input_item.dart | 24 ++--- .../items/general/brn_radio_input_item.dart | 39 ++++---- .../brn_radio_portrait_input_item.dart | 26 +++--- .../items/general/brn_range_input_item.dart | 20 ++-- .../items/general/brn_ratio_input_item.dart | 18 ++-- .../items/general/brn_star_input_item.dart | 12 +-- .../items/general/brn_step_input_item.dart | 12 +-- .../general/brn_text_block_input_item.dart | 18 ++-- .../items/general/brn_text_input_item.dart | 18 ++-- .../items/general/brn_text_select_item.dart | 22 ++--- .../general/brn_title_select_input_item.dart | 26 +++--- .../group}/brn_expandable_group.dart | 4 +- ...=> brn_expandable_group_with_opreate.dart} | 10 +- .../form/items/group/brn_normal_group.dart | 14 +-- .../group}/brn_portrait_radio_group.dart | 12 +-- .../items/group/element_expand_widget.dart | 4 +- .../form/items/misc/brn_title_item.dart | 12 +-- .../form/items/title/brn_base_title_item.dart | 16 ++-- .../title/brn_select_all_title_item.dart | 6 +- .../components/form/utils/brn_form_util.dart | 92 +++++++++---------- .../selection/brn_more_selection.dart | 15 +-- .../widget/brn_layer_more_selection_page.dart | 2 +- .../brn_selection_more_item_widget.dart | 4 +- 29 files changed, 276 insertions(+), 301 deletions(-) rename lib/src/components/form/{undetermined => items/group}/brn_expandable_group.dart (98%) rename lib/src/components/form/items/group/{brn_expand_group.dart => brn_expandable_group_with_opreate.dart} (93%) rename lib/src/components/form/{undetermined => items/group}/brn_portrait_radio_group.dart (96%) diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index a1512996..b42638fc 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -22,7 +22,7 @@ class TitleSelectInputState extends State { @override void initState() { super.initState(); - _list = List(); + _list = []; _list.add('手机号'); _list.add('座机'); } diff --git a/example/lib/sample/components/selection/selectionview_customview_example_page.dart b/example/lib/sample/components/selection/selectionview_customview_example_page.dart index 216b8567..69ac4c55 100644 --- a/example/lib/sample/components/selection/selectionview_customview_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_customview_example_page.dart @@ -117,10 +117,10 @@ class _SelectionViewExamplePageState extends State { _currentEndSelectedDate = date; setState(() { try { - if (widget.startEndDateChange != null) { - widget.startEndDateChange!( - _currentStartSelectedDate!, - _currentEndSelectedDate!, - ); - } if (widget.dateChange != null) { widget.dateChange!(date); } @@ -628,21 +614,18 @@ class _CustomCalendarViewState extends State { if (date.isAfter(_currentEndSelectedDate!)) { _currentEndSelectedDate = date; } + setState(() { + try { + if (widget.rangeDateChange != null) { + widget.rangeDateChange!(DateTimeRange( + start: _currentStartSelectedDate!, + end: _currentEndSelectedDate!, + )); + } + } catch (_) {} + }); } - setState(() { - try { - if (widget.startEndDateChange != null) { - widget.startEndDateChange!( - _currentStartSelectedDate!, _currentEndSelectedDate!); - } - if (widget.rangeDateChange != null) { - widget.rangeDateChange!(DateTimeRange( - start: _currentStartSelectedDate!, - end: _currentEndSelectedDate!, - )); - } - } catch (_) {} - }); + } String _getChinaWeekName(int weekOfDay) { diff --git a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart index 59fb57ee..0de0347d 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart @@ -1,7 +1,7 @@ -import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; +import 'package:bruno/src/components/radio/brn_checkbox.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -105,7 +105,7 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { class BrnMultiChoiceInputFormItemState extends State { // 标记选项的选中状态,内部变量无须初始化。初始化选中状态通过设置value字段设置 - List? _selectStatus; + List _selectStatus = []; @override void initState() { @@ -117,7 +117,7 @@ class BrnMultiChoiceInputFormItemState Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -130,7 +130,7 @@ class BrnMultiChoiceInputFormItemState ), child: Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -141,9 +141,9 @@ class BrnMultiChoiceInputFormItemState widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -158,9 +158,9 @@ class BrnMultiChoiceInputFormItemState ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); @@ -177,7 +177,7 @@ class BrnMultiChoiceInputFormItemState final int pos = index; result.add( Container( - padding: BrnFormUtil.optionsMiddlePadding(widget.themeData), + padding: BrnFormUtil.optionsMiddlePadding(widget.themeData!), child: Row( children: [ BrnCheckbox( @@ -192,18 +192,18 @@ class BrnMultiChoiceInputFormItemState radioIndex: index, disable: getRadioEnableState(index), isSelected: - (_selectStatus != null && pos < _selectStatus!.length) - ? _selectStatus![pos]! + (pos < _selectStatus.length) + ? _selectStatus[pos] : false, onValueChangedAtIndex: (position, value) { - _selectStatus![position] = value; + _selectStatus[position] = value; List oldValue = []..addAll(widget.value); setState(() { widget.value.clear(); - for (int i = 0; i < _selectStatus!.length; ++i) { - if (_selectStatus![i]!) { + for (int i = 0; i < _selectStatus.length; ++i) { + if (_selectStatus[i]) { widget.value.add(widget.options[i]); } } @@ -223,23 +223,23 @@ class BrnMultiChoiceInputFormItemState } TextStyle? getOptionTextStyle(int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (index < 0 || index >= _selectStatus!.length) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + if (index < 0 || index >= _selectStatus.length) { return result; } - if (_selectStatus![index]!) { - result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + if (_selectStatus[index]) { + result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } if (widget.enableList.isNotEmpty && widget.enableList.length > index && !widget.enableList[index]) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, false); } return result; @@ -260,12 +260,10 @@ class BrnMultiChoiceInputFormItemState void _initSelectedStatus() { if (widget.options.isNotEmpty) { _selectStatus = List.filled(widget.options.length, false); - } else { - _selectStatus = []; } - for (int index = 0; index < _selectStatus!.length; ++index) { - _selectStatus![index] = false; + for (int index = 0; index < _selectStatus.length; ++index) { + _selectStatus[index] = false; } if (widget.value.isEmpty) { @@ -278,7 +276,7 @@ class BrnMultiChoiceInputFormItemState if (pos < 0) { return; } - _selectStatus![pos] = true; + _selectStatus[pos] = true; } } } diff --git a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart index 0e52bf9c..037ab044 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart @@ -106,7 +106,7 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { class BrnMultiChoicePortraitInputFormItemState extends State { // 标记选项的选中状态,内部变量无须初始化。初始化选中状态通过设置value字段设置 - List? _selectStatus; + List _selectStatus = []; @override void initState() { @@ -118,7 +118,7 @@ class BrnMultiChoicePortraitInputFormItemState Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -131,7 +131,7 @@ class BrnMultiChoicePortraitInputFormItemState children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -142,9 +142,9 @@ class BrnMultiChoicePortraitInputFormItemState widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -153,9 +153,9 @@ class BrnMultiChoicePortraitInputFormItemState ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData), + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!), Container( padding: EdgeInsets.only(left: 20, top: 14), @@ -188,18 +188,18 @@ class BrnMultiChoicePortraitInputFormItemState mainAxisSize: MainAxisSize.max, radioIndex: index, disable: getRadioEnableState(index), - isSelected: (_selectStatus != null && index < _selectStatus!.length) - ? _selectStatus![index]! + isSelected: (index < _selectStatus.length) + ? _selectStatus[index] : false, onValueChangedAtIndex: (position, value) { - _selectStatus![position] = value; + _selectStatus[position] = value; List oldValue = []..addAll(widget.value); setState(() { widget.value.clear(); - for (int i = 0; i < _selectStatus!.length; ++i) { - if (_selectStatus![i]!) { + for (int i = 0; i < _selectStatus.length; ++i) { + if (_selectStatus[i]) { widget.value.add(widget.options[i]); } } @@ -217,23 +217,23 @@ class BrnMultiChoicePortraitInputFormItemState } TextStyle? getOptionTextStyle(int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); - if (index < 0 || index >= _selectStatus!.length) { + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + if (index < 0 || index >= _selectStatus.length) { return result; } - if (_selectStatus![index]!) { - result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + if (_selectStatus[index]) { + result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } if (widget.enableList.isNotEmpty && widget.enableList.length > index && !widget.enableList[index]) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, false); } return result; @@ -254,12 +254,10 @@ class BrnMultiChoicePortraitInputFormItemState void _initSelectedStatus() { if (widget.options.isNotEmpty) { _selectStatus = List.filled(widget.options.length, false); - } else { - _selectStatus = []; } - for (int index = 0; index < _selectStatus!.length; ++index) { - _selectStatus![index] = false; + for (int index = 0; index < _selectStatus.length; ++index) { + _selectStatus[index] = false; } if (widget.value.isEmpty) { @@ -272,7 +270,7 @@ class BrnMultiChoicePortraitInputFormItemState if (pos < 0) { return; } - _selectStatus![pos] = true; + _selectStatus[pos] = true; } } } diff --git a/lib/src/components/form/items/general/brn_quick_select_input_item.dart b/lib/src/components/form/items/general/brn_quick_select_input_item.dart index 5acb1bfa..bf8521a7 100644 --- a/lib/src/components/form/items/general/brn_quick_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_quick_select_input_item.dart @@ -129,7 +129,7 @@ class BrnTextQuickSelectFormItemState Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -141,7 +141,7 @@ class BrnTextQuickSelectFormItemState children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -156,11 +156,11 @@ class BrnTextQuickSelectFormItemState // 主标题 BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), // 问号提示 BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -193,7 +193,7 @@ class BrnTextQuickSelectFormItemState ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), /// 快捷按钮区 Container( @@ -210,7 +210,7 @@ class BrnTextQuickSelectFormItemState )), /// 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); @@ -221,13 +221,13 @@ class BrnTextQuickSelectFormItemState return Text( widget.value!, textAlign: TextAlign.end, - style: BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit), + style: BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit), ); } else { return Text( widget.hint, textAlign: TextAlign.end, - style: BrnFormUtil.getHintTextStyle(widget.themeData), + style: BrnFormUtil.getHintTextStyle(widget.themeData!), ); } } @@ -272,7 +272,7 @@ class QuickButtonsState extends State { @override Widget build(BuildContext context) { - return getQuickButtons()!; + return getQuickButtons(); } @override @@ -302,13 +302,13 @@ class QuickButtonsState extends State { } } - Widget? getQuickButtons() { + Widget getQuickButtons() { if (!widget.isEdit) { return Container(); } if (widget.btns != null) { - return widget.btns; + return widget.btns!; } else if (widget.btnsTxt != null) { if (widget.isBtnsScroll!) { return ListView( @@ -322,7 +322,7 @@ class QuickButtonsState extends State { ); } } else { - return Container(); + return SizedBox.shrink(); } } diff --git a/lib/src/components/form/items/general/brn_radio_input_item.dart b/lib/src/components/form/items/general/brn_radio_input_item.dart index 81e570d6..285c5f64 100644 --- a/lib/src/components/form/items/general/brn_radio_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_input_item.dart @@ -2,10 +2,10 @@ import 'dart:math'; -import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/base/brn_form_item_type.dart'; import 'package:bruno/src/components/form/base/input_item_interface.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; +import 'package:bruno/src/components/radio/brn_radio_button.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -155,7 +155,7 @@ class BrnRadioInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -163,10 +163,10 @@ class BrnRadioInputFormItemState extends State { ? _buildAutoLayoutTitleWidget(context) : _buildTitleWidget(context), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), // 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); @@ -192,7 +192,7 @@ class BrnRadioInputFormItemState extends State { Flexible( child: Container( padding: BrnFormUtil.titleEdgeInsets( - widget.prefixIconType, widget.isRequire, widget.themeData), + widget.prefixIconType, widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -244,7 +244,7 @@ class BrnRadioInputFormItemState extends State { child: Text( widget.tipLabel ?? "", overflow: TextOverflow.ellipsis, - style: BrnFormUtil.getTipsTextStyle(widget.themeData), + style: BrnFormUtil.getTipsTextStyle(widget.themeData!), ), ), ], @@ -263,15 +263,10 @@ class BrnRadioInputFormItemState extends State { /// 计算Text所占宽度 double _calculateTextWidth(BuildContext context) { - List? options; - if (widget.options != null && widget.options!.isNotEmpty) { - // 模型里边的数据 - options = widget.options; - } - + List? options = widget.options; // 计算所有备选文案的文字长度 double totalTextWidth = 0; - if (options!.isNotEmpty) { + if (options != null && options.isNotEmpty) { int idx = -1; for (String? item in options) { idx += 1; @@ -286,7 +281,7 @@ class BrnRadioInputFormItemState extends State { // 6 是备选文案和单选按钮之间的间距 // 16 是 radio 按钮的宽度 double optionWidth = painter.width + - BrnFormUtil.optionsMiddlePadding(widget.themeData)!.left + + BrnFormUtil.optionsMiddlePadding(widget.themeData!)!.left + _kRadioTitleLeftPadding + _kRadioIconWidth; totalTextWidth += optionWidth; @@ -301,7 +296,7 @@ class BrnRadioInputFormItemState extends State { ? TextOverflow.clip : TextOverflow.ellipsis, maxLines: widget.titleMaxLines, - style: BrnFormUtil.getTitleTextStyle(widget.themeData)); + style: BrnFormUtil.getTitleTextStyle(widget.themeData!)); } Row _buildTitleWidget(BuildContext context) { @@ -314,7 +309,7 @@ class BrnRadioInputFormItemState extends State { ), child: Container( padding: BrnFormUtil.titleEdgeInsets( - widget.prefixIconType, widget.isRequire, widget.themeData), + widget.prefixIconType, widget.isRequire, widget.themeData!), child: Row( children: [ // 添加/删除图标 @@ -358,7 +353,7 @@ class BrnRadioInputFormItemState extends State { result.add( Container( - padding: BrnFormUtil.optionsMiddlePadding(widget.themeData), + padding: BrnFormUtil.optionsMiddlePadding(widget.themeData!), child: Row( children: [ BrnRadioButton( @@ -371,7 +366,7 @@ class BrnRadioInputFormItemState extends State { )), disable: getRadioEnableState(index), radioIndex: index, - isSelected: index == widget.options!.indexOf(widget.value ?? ""), + isSelected: index == widget.options!.indexOf(widget.value ?? ''), onValueChangedAtIndex: (int position, bool selected) { if (getRadioEnableState(position)) { return; @@ -394,24 +389,24 @@ class BrnRadioInputFormItemState extends State { } TextStyle? getOptionTextStyle(String? opt, int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (opt == null) { return result; } if (opt == widget.value) { - result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } if (widget.enableList != null && widget.enableList!.isNotEmpty && widget.enableList!.length > index && !widget.enableList![index]) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, false); } return result; diff --git a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart index 0f6e68e4..d9b1473b 100644 --- a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart @@ -61,7 +61,7 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { String? value; /// 选项 - List? options; + List? options; /// 局部禁用list List? enableList; @@ -110,7 +110,7 @@ class BrnRadioPortraitInputFormItemState Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -123,7 +123,7 @@ class BrnRadioPortraitInputFormItemState children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -134,9 +134,9 @@ class BrnRadioPortraitInputFormItemState widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -145,9 +145,9 @@ class BrnRadioPortraitInputFormItemState ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData), + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!), Container( padding: EdgeInsets.only(left: 20, top: 14), @@ -185,7 +185,7 @@ class BrnRadioPortraitInputFormItemState mainAxisSize: MainAxisSize.max, disable: getRadioEnableState(index), radioIndex: index, - isSelected: index == widget.options!.indexOf(widget.value), + isSelected: index == widget.options!.indexOf(widget.value ?? ''), onValueChangedAtIndex: (int position, bool isSelected) { if (getRadioEnableState(position)) { return; @@ -206,25 +206,25 @@ class BrnRadioPortraitInputFormItemState return result; } - TextStyle? getOptionTextStyle(String? opt, int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + TextStyle getOptionTextStyle(String? opt, int index) { + TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (opt == null) { return result; } if (opt == widget.value) { - result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } if (widget.enableList != null && widget.enableList!.isNotEmpty && widget.enableList!.length > index && !widget.enableList![index]) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, false); } return result; diff --git a/lib/src/components/form/items/general/brn_range_input_item.dart b/lib/src/components/form/items/general/brn_range_input_item.dart index a2906483..729cb201 100644 --- a/lib/src/components/form/items/general/brn_range_input_item.dart +++ b/lib/src/components/form/items/general/brn_range_input_item.dart @@ -156,7 +156,7 @@ class BrnRangeInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -169,7 +169,7 @@ class BrnRangeInputFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -180,9 +180,9 @@ class BrnRangeInputFormItemState extends State { widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -201,11 +201,11 @@ class BrnRangeInputFormItemState extends State { maxLines: 1, maxLength: widget.leftMaxCount, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit), + widget.themeData!, widget.isEdit), decoration: InputDecoration( border: InputBorder.none, hintStyle: - BrnFormUtil.getHintTextStyle(widget.themeData), + BrnFormUtil.getHintTextStyle(widget.themeData!), hintText: widget.hintMin, counterText: "", contentPadding: EdgeInsets.all(0), @@ -256,11 +256,11 @@ class BrnRangeInputFormItemState extends State { maxLines: 1, maxLength: widget.rightMaxCount, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit), + widget.themeData!, widget.isEdit), decoration: InputDecoration( border: InputBorder.none, hintStyle: - BrnFormUtil.getHintTextStyle(widget.themeData), + BrnFormUtil.getHintTextStyle(widget.themeData!), hintText: widget.hintMax, counterText: "", contentPadding: EdgeInsets.all(0), @@ -297,9 +297,9 @@ class BrnRangeInputFormItemState extends State { ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/general/brn_ratio_input_item.dart b/lib/src/components/form/items/general/brn_ratio_input_item.dart index 10411815..effafcec 100644 --- a/lib/src/components/form/items/general/brn_ratio_input_item.dart +++ b/lib/src/components/form/items/general/brn_ratio_input_item.dart @@ -122,7 +122,7 @@ class BrnRatioInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -135,7 +135,7 @@ class BrnRatioInputFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -146,9 +146,9 @@ class BrnRatioInputFormItemState extends State { widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -159,7 +159,7 @@ class BrnRatioInputFormItemState extends State { child: Text( "1 : ", style: - BrnFormUtil.getTitleTextStyle(widget.themeData), + BrnFormUtil.getTitleTextStyle(widget.themeData!), )), Container( width: 60, @@ -169,12 +169,12 @@ class BrnRatioInputFormItemState extends State { enabled: widget.isEdit, maxLines: 1, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit), + widget.themeData!, widget.isEdit), inputFormatters: widget.inputFormatters, decoration: InputDecoration( border: InputBorder.none, hintStyle: - BrnFormUtil.getHintTextStyle(widget.themeData), + BrnFormUtil.getHintTextStyle(widget.themeData!), hintText: widget.hint, counterText: "", contentPadding: EdgeInsets.all(0), @@ -201,9 +201,9 @@ class BrnRatioInputFormItemState extends State { ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/general/brn_star_input_item.dart b/lib/src/components/form/items/general/brn_star_input_item.dart index 339f5919..87dd8c20 100644 --- a/lib/src/components/form/items/general/brn_star_input_item.dart +++ b/lib/src/components/form/items/general/brn_star_input_item.dart @@ -108,7 +108,7 @@ class BrnStarsFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -117,7 +117,7 @@ class BrnStarsFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: ConstrainedBox( constraints: BoxConstraints( maxHeight: 25, @@ -132,9 +132,9 @@ class BrnStarsFormItemState extends State { widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ))), Row( @@ -145,9 +145,9 @@ class BrnStarsFormItemState extends State { ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/general/brn_step_input_item.dart b/lib/src/components/form/items/general/brn_step_input_item.dart index dacefc15..631ab199 100644 --- a/lib/src/components/form/items/general/brn_step_input_item.dart +++ b/lib/src/components/form/items/general/brn_step_input_item.dart @@ -118,7 +118,7 @@ class BrnStepInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -131,7 +131,7 @@ class BrnStepInputFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -142,9 +142,9 @@ class BrnStepInputFormItemState extends State { widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -211,9 +211,9 @@ class BrnStepInputFormItemState extends State { ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/general/brn_text_block_input_item.dart b/lib/src/components/form/items/general/brn_text_block_input_item.dart index 50328308..11cff245 100644 --- a/lib/src/components/form/items/general/brn_text_block_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_block_input_item.dart @@ -134,7 +134,7 @@ class BrnTextBlockInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -144,7 +144,7 @@ class BrnTextBlockInputFormItemState extends State { ), child: Container( padding: BrnFormUtil.titleEdgeInsets( - widget.prefixIconType, widget.isRequire, widget.themeData), + widget.prefixIconType, widget.isRequire, widget.themeData!), child: Row( children: [ // 添加/删除 按钮 @@ -158,24 +158,24 @@ class BrnTextBlockInputFormItemState extends State { BrnFormUtil.buildRequireWidget(widget.isRequire), // title - BrnFormUtil.buildTitleWidget(widget.title, widget.themeData), + BrnFormUtil.buildTitleWidget(widget.title, widget.themeData!), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), // 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData), + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!), // 输入框 Container( - padding: BrnFormUtil.errorEdgeInsets(widget.themeData), + padding: BrnFormUtil.errorEdgeInsets(widget.themeData!), child: TextField( keyboardType: BrnFormUtil.getInputType(widget.inputType), controller: _controller, @@ -186,11 +186,11 @@ class BrnTextBlockInputFormItemState extends State { textAlign: TextAlign.left, enabled: widget.isEdit, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit), + widget.themeData!, widget.isEdit), inputFormatters: widget.inputFormatters, decoration: InputDecoration( hintText: widget.hint , - hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), + hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData!), contentPadding: EdgeInsets.all(0), border: InputBorder.none, isDense: true, diff --git a/lib/src/components/form/items/general/brn_text_input_item.dart b/lib/src/components/form/items/general/brn_text_input_item.dart index 1a13d5b0..5521af36 100644 --- a/lib/src/components/form/items/general/brn_text_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_input_item.dart @@ -133,7 +133,7 @@ class BrnTextInputFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -145,7 +145,7 @@ class BrnTextInputFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon( @@ -156,7 +156,7 @@ class BrnTextInputFormItemState extends State { widget.onRemoveTap), BrnFormUtil.buildRequireWidget(widget.isRequire), BrnFormUtil.buildTitleWidget( - widget.title, widget.themeData), + widget.title, widget.themeData!), Offstage( offstage: (widget.prefixText == null), child: Container( @@ -164,11 +164,11 @@ class BrnTextInputFormItemState extends State { child: Text( widget.prefixText ?? "", style: BrnFormUtil.getTitleTextStyle( - widget.themeData), + widget.themeData!), )), ), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -179,10 +179,10 @@ class BrnTextInputFormItemState extends State { maxLines: 1, maxLength: widget.maxCharCount, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit), + widget.themeData!, widget.isEdit), decoration: InputDecoration( border: InputBorder.none, - hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData), + hintStyle: BrnFormUtil.getHintTextStyle(widget.themeData!), hintText: widget.hint, counterText: "", contentPadding: EdgeInsets.all(0), @@ -215,8 +215,8 @@ class BrnTextInputFormItemState extends State { ], ), ), - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/general/brn_text_select_item.dart b/lib/src/components/form/items/general/brn_text_select_item.dart index 290153c0..2d8d3aee 100644 --- a/lib/src/components/form/items/general/brn_text_select_item.dart +++ b/lib/src/components/form/items/general/brn_text_select_item.dart @@ -168,10 +168,10 @@ class BrnTextSelectFormItemState extends State { : _buildTitleWidget(context), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), // 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); @@ -292,7 +292,7 @@ class BrnTextSelectFormItemState extends State { height: 1, leading: 0.5, fontSize: BrnFonts.f14), - style: BrnFormUtil.getTipsTextStyle(widget.themeData), + style: BrnFormUtil.getTipsTextStyle(widget.themeData!), ), ), ], @@ -310,7 +310,7 @@ class BrnTextSelectFormItemState extends State { : TextOverflow.ellipsis, maxLines: widget.titleMaxLines, strutStyle: _contentStructStyle, - style: BrnFormUtil.getTitleTextStyle(widget.themeData, height: 1), + style: BrnFormUtil.getTitleTextStyle(widget.themeData!, height: 1), ); } @@ -353,7 +353,7 @@ class BrnTextSelectFormItemState extends State { text: TextSpan( text: widget.value, style: BrnFormUtil.getIsEditTextStyle( - widget.themeData, widget.isEdit, + widget.themeData!, widget.isEdit, height: 1), )); } else { @@ -364,7 +364,7 @@ class BrnTextSelectFormItemState extends State { strutStyle: _contentStructStyle, text: TextSpan( text: widget.hint, - style: BrnFormUtil.getHintTextStyle(widget.themeData, height: 1), + style: BrnFormUtil.getHintTextStyle(widget.themeData!, height: 1), )); } painter.layout(); @@ -381,7 +381,7 @@ class BrnTextSelectFormItemState extends State { maxLines: widget.valueMaxLines , textAlign: TextAlign.end, strutStyle: _contentStructStyle, - style: BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit, + style: BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit, height: 1), ); } else { @@ -389,15 +389,15 @@ class BrnTextSelectFormItemState extends State { widget.hint, textAlign: TextAlign.end, strutStyle: _contentStructStyle, - style: BrnFormUtil.getHintTextStyle(widget.themeData, height: 1), + style: BrnFormUtil.getHintTextStyle(widget.themeData!, height: 1), ); } } - String? getCalculateText() { - String? value = '请选择'; + String getCalculateText() { + String value = '请选择'; if (!BrunoTools.isEmpty(widget.value)) { - value = widget.value; + value = widget.value!; } else if (!BrunoTools.isEmpty(widget.hint)) { value = widget.hint; } diff --git a/lib/src/components/form/items/general/brn_title_select_input_item.dart b/lib/src/components/form/items/general/brn_title_select_input_item.dart index 2b0599fe..0a307cb3 100644 --- a/lib/src/components/form/items/general/brn_title_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_title_select_input_item.dart @@ -78,7 +78,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { final int selectedIndex; /// title选择列表 - final List? selectList; + final List selectList; final List? inputFormatters; /// 输入文本变化回调 @@ -93,6 +93,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { BrnTitleSelectInputFormItem( {Key? key, + required this.selectList, this.label, this.title = "", this.subTitle, @@ -109,7 +110,6 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { this.maxCount, this.inputType = BrnInputType.TEXT, this.selectedIndex = -1, - this.selectList, this.inputFormatters, this.onChanged, this.onTitleSelected, @@ -146,7 +146,7 @@ class BrnTitleSelectInputFormItemState Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -166,8 +166,8 @@ class BrnTitleSelectInputFormItemState ], ), ), - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!), ], ), ); @@ -176,7 +176,7 @@ class BrnTitleSelectInputFormItemState Widget _buildLeftMenu() { return Container( padding: BrnFormUtil.titleEdgeInsets( - widget.prefixIconType, widget.isRequire, widget.themeData), + widget.prefixIconType, widget.isRequire, widget.themeData!), child: Row( children: [ BrnFormUtil.buildPrefixIcon(widget.prefixIconType, widget.isEdit, @@ -188,7 +188,7 @@ class BrnTitleSelectInputFormItemState _buildTriangle(), BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ); @@ -258,7 +258,7 @@ class BrnTitleSelectInputFormItemState builder: (context, AsyncSnapshot snapshot) { return Text( snapshot.data!, - style: BrnFormUtil.getTitleTextStyle(widget.themeData), + style: BrnFormUtil.getTitleTextStyle(widget.themeData!), ); }, ), @@ -289,7 +289,7 @@ class BrnTitleSelectInputFormItemState controller: _controller, enabled: widget.isEdit, maxLength: widget.maxCount, - style: BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit), + style: BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit), onChanged: (text) { BrnFormUtil.notifyInputChanged(widget.onChanged, text); }, @@ -333,13 +333,13 @@ class BrnTitleSelectInputFormItemState // ignore: must_be_immutable class TitleSelectPopWidget extends StatefulWidget { - List? /*!*/ selectList; + List selectList; int? selectedIndex; final Function(String item, int index) selectCallback; BrnFormItemConfig? themeData; TitleSelectPopWidget( - {this.selectList, + {required this.selectList, this.selectedIndex, required this.selectCallback, this.themeData}); @@ -352,8 +352,8 @@ class _TitleSelectPopWidgetState extends State { @override Widget build(BuildContext context) { List showList = []; - for (int i = 0, n = widget.selectList!.length; i < n; ++i) { - showList.add(selectItem(widget.selectList![i], i, i == n - 1)); + for (int i = 0, n = widget.selectList.length; i < n; ++i) { + showList.add(selectItem(widget.selectList[i], i, i == n - 1)); } return Container( padding: EdgeInsets.only(left: 16, right: 16), diff --git a/lib/src/components/form/undetermined/brn_expandable_group.dart b/lib/src/components/form/items/group/brn_expandable_group.dart similarity index 98% rename from lib/src/components/form/undetermined/brn_expandable_group.dart rename to lib/src/components/form/items/group/brn_expandable_group.dart index c9b2d3dd..0c56bd95 100644 --- a/lib/src/components/form/undetermined/brn_expandable_group.dart +++ b/lib/src/components/form/items/group/brn_expandable_group.dart @@ -183,7 +183,7 @@ class _BrnExpansionElementState extends State child: Text( widget.title, style: BrnFormUtil.getHeadTitleTextStyle( - widget.themeData, + widget.themeData!, isBold: true), )), // 副标题 @@ -199,7 +199,7 @@ class _BrnExpansionElementState extends State // ignore: deprecated_member_use_from_same_package widget.subtitle ?? "", style: BrnFormUtil.getSubTitleTextStyle( - widget.themeData), + widget.themeData!), ), ), ), diff --git a/lib/src/components/form/items/group/brn_expand_group.dart b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart similarity index 93% rename from lib/src/components/form/items/group/brn_expand_group.dart rename to lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart index 4b1d93b5..2c22f16b 100644 --- a/lib/src/components/form/items/group/brn_expand_group.dart +++ b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart @@ -17,7 +17,7 @@ class BrnExpandFormGroup extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.NORMAL_GROUP_TYPE; + final String type = BrnInputItemType.NORMAL_GROUP_TYPE; /// 录入项标题 final String title; @@ -54,7 +54,7 @@ class BrnExpandFormGroup extends StatefulWidget { final String? deleteLabel; /// 内部子项 - final List? children; + final List children; BrnExpandFormGroup({ Key? key, @@ -69,7 +69,7 @@ class BrnExpandFormGroup extends StatefulWidget { this.onTip, this.isExpand = true, this.deleteLabel, - this.children, + required this.children, }); @override @@ -102,11 +102,11 @@ class BrnExpandFormGroupState extends State { List getSubItem() { List result = []; - if (widget.children == null || widget.children!.isEmpty) { + if (widget.children.isEmpty) { return result; } - for (Widget w in widget.children!) { + for (Widget w in widget.children) { result.add(BrnLine()); result.add(w); } diff --git a/lib/src/components/form/items/group/brn_normal_group.dart b/lib/src/components/form/items/group/brn_normal_group.dart index 590c5107..954da95c 100644 --- a/lib/src/components/form/items/group/brn_normal_group.dart +++ b/lib/src/components/form/items/group/brn_normal_group.dart @@ -52,7 +52,7 @@ class BrnNormalFormGroup extends StatefulWidget { final String? deleteLabel; /// 内部子项 - final List? children; + final List children; /// form配置 BrnFormItemConfig? themeData; @@ -69,7 +69,7 @@ class BrnNormalFormGroup extends StatefulWidget { this.onRemoveTap, this.onTip, this.deleteLabel, - this.children, + required this.children, }) : super() { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance @@ -112,7 +112,7 @@ class BrnNormalFormGroupState extends State { child: Text( widget.title, style: BrnFormUtil.getHeadTitleTextStyle( - widget.themeData, + widget.themeData!, isBold: true), )), ], @@ -148,12 +148,12 @@ class BrnNormalFormGroupState extends State { // 副标题 Container( alignment: Alignment.centerLeft, - padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData), + padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData!), child: Offstage( offstage: (widget.subTitle == null || widget.subTitle!.isEmpty), child: Text( widget.subTitle ?? "", - style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), + style: BrnFormUtil.getSubTitleTextStyle(widget.themeData!), ), ), ), @@ -171,11 +171,11 @@ class BrnNormalFormGroupState extends State { List getSubItem() { List result = []; - if (widget.children == null || widget.children!.isEmpty) { + if (widget.children.isEmpty) { return result; } - for (Widget w in widget.children!) { + for (Widget w in widget.children) { result.add(BrnLine()); result.add(w); } diff --git a/lib/src/components/form/undetermined/brn_portrait_radio_group.dart b/lib/src/components/form/items/group/brn_portrait_radio_group.dart similarity index 96% rename from lib/src/components/form/undetermined/brn_portrait_radio_group.dart rename to lib/src/components/form/items/group/brn_portrait_radio_group.dart index 5bf02e8c..5654c886 100644 --- a/lib/src/components/form/undetermined/brn_portrait_radio_group.dart +++ b/lib/src/components/form/items/group/brn_portrait_radio_group.dart @@ -1,6 +1,6 @@ -import 'package:bruno/bruno.dart'; import 'package:bruno/src/components/form/utils/brn_form_util.dart'; import 'package:bruno/src/components/line/brn_line.dart'; +import 'package:bruno/src/components/radio/brn_radio_button.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:bruno/src/theme/configs/brn_form_config.dart'; import 'package:flutter/material.dart'; @@ -170,7 +170,7 @@ class BrnPortraitRadioGroupState extends State { overflow: widget.isCollapseContent ? TextOverflow.ellipsis : null, maxLines: widget.isCollapseContent ? 1 : null, - style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), + style: BrnFormUtil.getSubTitleTextStyle(widget.themeData!), ), ), ) @@ -206,21 +206,21 @@ class BrnPortraitRadioGroupState extends State { } TextStyle? getOptionTextStyle(BrnPortraitRadioGroupOption opt, int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData); + TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (isSameOption(opt, _selectedOption)) { - result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } if (widget.enableList != null && widget.enableList!.isNotEmpty && widget.enableList!.length > index && !widget.enableList![index]) { - result = BrnFormUtil.getIsEditTextStyle(widget.themeData, false); + result = BrnFormUtil.getIsEditTextStyle(widget.themeData!, false); } return result; diff --git a/lib/src/components/form/items/group/element_expand_widget.dart b/lib/src/components/form/items/group/element_expand_widget.dart index 69513e03..72164ba6 100644 --- a/lib/src/components/form/items/group/element_expand_widget.dart +++ b/lib/src/components/form/items/group/element_expand_widget.dart @@ -201,7 +201,7 @@ class _ExpansionElementState extends State child: Text( widget.title, style: BrnFormUtil.getHeadTitleTextStyle( - widget.themeData, + widget.themeData!, isBold: true), )), RotationTransition( @@ -245,7 +245,7 @@ class _ExpansionElementState extends State offstage: (widget.subtitle == null || widget.subtitle!.isEmpty), child: Text( widget.subtitle ?? "", - style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), + style: BrnFormUtil.getSubTitleTextStyle(widget.themeData!), ), ), ), diff --git a/lib/src/components/form/items/misc/brn_title_item.dart b/lib/src/components/form/items/misc/brn_title_item.dart index 22dbbd34..0ad7d6c9 100644 --- a/lib/src/components/form/items/misc/brn_title_item.dart +++ b/lib/src/components/form/items/misc/brn_title_item.dart @@ -85,7 +85,7 @@ class BrnTitleFormItemState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -98,7 +98,7 @@ class BrnTitleFormItemState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsets(widget.prefixIconType, - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ // 主标题 @@ -106,12 +106,12 @@ class BrnTitleFormItemState extends State { child: Text( widget.title, style: - BrnFormUtil.getHeadTitleTextStyle(widget.themeData), + BrnFormUtil.getHeadTitleTextStyle(widget.themeData!), )), // 问号提示 BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -143,10 +143,10 @@ class BrnTitleFormItemState extends State { ), // 副标题 - BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData), + BrnFormUtil.buildSubTitleWidget(widget.subTitle, widget.themeData!), // 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); diff --git a/lib/src/components/form/items/title/brn_base_title_item.dart b/lib/src/components/form/items/title/brn_base_title_item.dart index 9fec7d5b..f3b08453 100644 --- a/lib/src/components/form/items/title/brn_base_title_item.dart +++ b/lib/src/components/form/items/title/brn_base_title_item.dart @@ -88,7 +88,7 @@ class BrnTitleState extends State { Widget build(BuildContext context) { return Container( color: Colors.white, - padding: BrnFormUtil.itemEdgeInsets(widget.themeData), + padding: BrnFormUtil.itemEdgeInsets(widget.themeData!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -101,7 +101,7 @@ class BrnTitleState extends State { children: [ Container( padding: BrnFormUtil.titleEdgeInsetsForHead( - widget.isRequire, widget.themeData), + widget.isRequire, widget.themeData!), child: Row( children: [ // 必填项符号 @@ -112,7 +112,7 @@ class BrnTitleState extends State { // 问号提示 BrnFormUtil.buildTipLabelWidget( - widget.tipLabel, widget.onTip, widget.themeData), + widget.tipLabel, widget.onTip, widget.themeData!), ], ), ), @@ -133,7 +133,7 @@ class BrnTitleState extends State { ), // 错误提示 - BrnFormUtil.buildErrorWidget(widget.error, widget.themeData) + BrnFormUtil.buildErrorWidget(widget.error, widget.themeData!) ], ), ); @@ -143,22 +143,22 @@ class BrnTitleState extends State { if (widget.titleWidget != null) { return widget.titleWidget!; } else { - return BrnFormUtil.buildTitleWidget(widget.title, widget.themeData); + return BrnFormUtil.buildTitleWidget(widget.title, widget.themeData!); } } Widget getSubTitleWidget() { if (widget.subTitleWidget != null) { return Container( - padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData), + padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData!), child: widget.subTitleWidget, ); } else { return Container( - padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData), + padding: BrnFormUtil.subTitleEdgeInsets(widget.themeData!), child: Text( widget.subTitle ?? "", - style: BrnFormUtil.getSubTitleTextStyle(widget.themeData), + style: BrnFormUtil.getSubTitleTextStyle(widget.themeData!), )); } } diff --git a/lib/src/components/form/items/title/brn_select_all_title_item.dart b/lib/src/components/form/items/title/brn_select_all_title_item.dart index f30ef610..d6941b64 100644 --- a/lib/src/components/form/items/title/brn_select_all_title_item.dart +++ b/lib/src/components/form/items/title/brn_select_all_title_item.dart @@ -154,11 +154,11 @@ class BrnSelectAllTitleState extends State { TextStyle? getOptionTextStyle(BrnFormItemConfig? themeData) { if (_selectState) { - return BrnFormUtil.getOptionSelectedTextStyle(widget.themeData); + return BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } if (!widget.isEdit) { - return BrnFormUtil.getIsEditTextStyle(widget.themeData, widget.isEdit); + return BrnFormUtil.getIsEditTextStyle(widget.themeData!, widget.isEdit); } - return BrnFormUtil.getOptionTextStyle(widget.themeData); + return BrnFormUtil.getOptionTextStyle(widget.themeData!); } } diff --git a/lib/src/components/form/utils/brn_form_util.dart b/lib/src/components/form/utils/brn_form_util.dart index 2831c1cd..78102bfe 100644 --- a/lib/src/components/form/utils/brn_form_util.dart +++ b/lib/src/components/form/utils/brn_form_util.dart @@ -35,7 +35,7 @@ class BrnFormUtil { } /// 获取错误提示widget - static Widget buildErrorWidget(String error, BrnFormItemConfig? themeData) { + static Widget buildErrorWidget(String error, BrnFormItemConfig themeData) { return Container( padding: errorEdgeInsets(themeData), child: Offstage( @@ -49,7 +49,7 @@ class BrnFormUtil { /// 获取子标题Widget static Widget buildSubTitleWidget( - String? subTitle, BrnFormItemConfig? themeData) { + String? subTitle, BrnFormItemConfig themeData) { return Offstage( offstage: (subTitle == null || subTitle.isEmpty), child: Container( @@ -71,7 +71,7 @@ class BrnFormUtil { /// 获取问号 static Widget buildTipLabelWidget( - String? tipLabel, VoidCallback? onTip, BrnFormItemConfig? themeData) { + String? tipLabel, VoidCallback? onTip, BrnFormItemConfig themeData) { return Offstage( offstage: (tipLabel == null), child: GestureDetector( @@ -99,7 +99,7 @@ class BrnFormUtil { } /// 获取二级标题Widget - static Widget buildTitleWidget(String title, BrnFormItemConfig? themeData) { + static Widget buildTitleWidget(String title, BrnFormItemConfig themeData) { return Container( child: Text( title, @@ -296,11 +296,11 @@ class BrnFormUtil { static void notifyMultiChoiceStatusChanged( OnBrnFormMultiChoiceValueChanged? onChoiceChanged, BuildContext context, - Object oldVal, - Object? newVal, + List oldVal, + List newVal, ) { if (onChoiceChanged != null) { - onChoiceChanged(oldVal as List, newVal as List?); + onChoiceChanged(oldVal, newVal); } } @@ -309,113 +309,113 @@ class BrnFormUtil { /// /// 选项之间的间距 - static EdgeInsets? optionsMiddlePadding(BrnFormItemConfig? themeData) { - return themeData?.optionsMiddlePadding; + static EdgeInsets? optionsMiddlePadding(BrnFormItemConfig themeData) { + return themeData.optionsMiddlePadding; } /// 走主题配置 上下右间距 - static EdgeInsets? itemEdgeInsets(BrnFormItemConfig? themeData) { - return themeData?.formPadding; + static EdgeInsets itemEdgeInsets(BrnFormItemConfig themeData) { + return themeData.formPadding; } /// 标题行的左间距 - static EdgeInsets? titleEdgeInsets( - String type, bool isRequire, BrnFormItemConfig? themeData) { + static EdgeInsets titleEdgeInsets( + String type, bool isRequire, BrnFormItemConfig themeData) { if (isRequire && type == BrnPrefixIconType.TYPE_NORMAL) { - return themeData?.titlePaddingSm; + return themeData.titlePaddingSm; } - return themeData?.titlePaddingLg; + return themeData.titlePaddingLg; } /// 标题行的左间距 - static EdgeInsets? titleEdgeInsetsForHead( - bool isRequire, BrnFormItemConfig? themeData) { - return isRequire ? themeData?.titlePaddingSm : themeData?.titlePaddingLg; + static EdgeInsets titleEdgeInsetsForHead( + bool isRequire, BrnFormItemConfig themeData) { + return isRequire ? themeData.titlePaddingSm : themeData.titlePaddingLg; } /// 子标题的右上间距 - static EdgeInsets? subTitleEdgeInsets(BrnFormItemConfig? themeData) { - return themeData?.subTitlePadding; + static EdgeInsets subTitleEdgeInsets(BrnFormItemConfig themeData) { + return themeData.subTitlePadding; } /// error的右上间距 - static EdgeInsets? errorEdgeInsets(BrnFormItemConfig? themeData) { - return themeData?.errorPadding; + static EdgeInsets errorEdgeInsets(BrnFormItemConfig themeData) { + return themeData.errorPadding; } /// 提示文本样式 - static TextStyle? getTipsTextStyle(BrnFormItemConfig? themeData) { - return themeData?.tipsTextStyle.generateTextStyle(); + static TextStyle getTipsTextStyle(BrnFormItemConfig themeData) { + return themeData.tipsTextStyle.generateTextStyle(); } /// 获取 右侧 输入、选择默认文本样式 - static TextStyle? getHintTextStyle(BrnFormItemConfig? themeData, + static TextStyle getHintTextStyle(BrnFormItemConfig themeData, {double height = 0}) { if (height > 0) { return BrnTextStyle(height: height) - .merge(themeData?.hintTextStyle) + .merge(themeData.hintTextStyle) .generateTextStyle(); } - return themeData?.hintTextStyle.generateTextStyle(); + return themeData.hintTextStyle.generateTextStyle(); } /// 获取是否可编辑的字体 - static TextStyle? getIsEditTextStyle(BrnFormItemConfig? themeData, bool isEdit, + static TextStyle getIsEditTextStyle(BrnFormItemConfig themeData, bool isEdit, {double height = 0}) { if (height > 0) { return isEdit ? BrnTextStyle(height: height) - .merge(themeData?.contentTextStyle) + .merge(themeData.contentTextStyle) .generateTextStyle() : BrnTextStyle(height: height) - .merge(themeData?.disableTextStyle) + .merge(themeData.disableTextStyle) .generateTextStyle(); } return isEdit - ? themeData?.contentTextStyle.generateTextStyle() - : themeData?.disableTextStyle.generateTextStyle(); + ? themeData.contentTextStyle.generateTextStyle() + : themeData.disableTextStyle.generateTextStyle(); } /// 获取标题文本样式 - static TextStyle? getTitleTextStyle(BrnFormItemConfig? themeData, + static TextStyle? getTitleTextStyle(BrnFormItemConfig themeData, {double height = 0}) { if (height > 0) { return BrnTextStyle(height: height) - .merge(themeData?.titleTextStyle) + .merge(themeData.titleTextStyle) .generateTextStyle(); } - return themeData?.titleTextStyle.generateTextStyle(); + return themeData.titleTextStyle.generateTextStyle(); } /// 获取标题文本样式 - static TextStyle? getHeadTitleTextStyle(BrnFormItemConfig? themeData, + static TextStyle getHeadTitleTextStyle(BrnFormItemConfig themeData, {bool isBold = false}) { if (isBold) { - return themeData?.headTitleTextStyle + return themeData.headTitleTextStyle .merge(BrnTextStyle(fontWeight: FontWeight.w600)) .generateTextStyle(); } - return themeData?.headTitleTextStyle.generateTextStyle(); + return themeData.headTitleTextStyle.generateTextStyle(); } /// 获取左侧辅助样式 - static TextStyle? getSubTitleTextStyle(BrnFormItemConfig? themeData) { - return themeData?.subTitleTextStyle.generateTextStyle(); + static TextStyle getSubTitleTextStyle(BrnFormItemConfig themeData) { + return themeData.subTitleTextStyle.generateTextStyle(); } /// 获取error 文本样式 - static TextStyle? getErrorTextStyle(BrnFormItemConfig? themeData) { - return themeData?.errorTextStyle.generateTextStyle(); + static TextStyle getErrorTextStyle(BrnFormItemConfig themeData) { + return themeData.errorTextStyle.generateTextStyle(); } /// 获取选项文本样式 - static TextStyle? getOptionTextStyle(BrnFormItemConfig? themeData) { - return themeData?.optionTextStyle.generateTextStyle(); + static TextStyle getOptionTextStyle(BrnFormItemConfig themeData) { + return themeData.optionTextStyle.generateTextStyle(); } /// 获取选中选项文本样式 - static TextStyle? getOptionSelectedTextStyle(BrnFormItemConfig? themeData) { - return themeData?.optionSelectedTextStyle.generateTextStyle(); + static TextStyle getOptionSelectedTextStyle(BrnFormItemConfig themeData) { + return themeData.optionSelectedTextStyle.generateTextStyle(); } /// diff --git a/lib/src/components/selection/brn_more_selection.dart b/lib/src/components/selection/brn_more_selection.dart index 04b5e02f..7d5e200e 100644 --- a/lib/src/components/selection/brn_more_selection.dart +++ b/lib/src/components/selection/brn_more_selection.dart @@ -47,8 +47,8 @@ class _BrnMoreSelectionPageState extends State with SingleTickerProviderStateMixin { List _originalSelectedItemsList = []; late AnimationController _controller; - late Animation animation; - StreamController clearController = StreamController.broadcast(); + late Animation _animation; + StreamController _clearController = StreamController.broadcast(); bool isValid = true; @override @@ -58,7 +58,7 @@ class _BrnMoreSelectionPageState extends State duration: const Duration(milliseconds: 300), vsync: this, ); - animation = Tween(end: Offset.zero, begin: Offset(1.0, 0.0)).animate(_controller); + _animation = Tween(end: Offset.zero, begin: Offset(1.0, 0.0)).animate(_controller); _controller.forward(); _originalSelectedItemsList.addAll(widget.entityData.allSelectedList()); @@ -83,7 +83,7 @@ class _BrnMoreSelectionPageState extends State animation: _controller, builder: (context, child) { return SlideTransition( - position: animation, + position: _animation, child: child, ); }, @@ -101,7 +101,7 @@ class _BrnMoreSelectionPageState extends State animation: _controller, builder: (context, child) { return SlideTransition( - position: animation, + position: _animation, child: child, ); }, @@ -129,6 +129,7 @@ class _BrnMoreSelectionPageState extends State void dispose() { super.dispose(); _controller.dispose(); + _clearController.close(); } /// 左侧为透明黑,点击直接退出页面 @@ -174,7 +175,7 @@ class _BrnMoreSelectionPageState extends State return ListView.builder( itemBuilder: (context, index) { return BrnMoreSelectionWidget( - clearController: clearController, + clearController: _clearController, selectionEntity: widget.entityData.children[index], onCustomFloatingLayerClick: widget.onCustomFloatingLayerClick, themeData: widget.themeData); @@ -190,7 +191,7 @@ class _BrnMoreSelectionPageState extends State themeData: widget.themeData, clearCallback: () { setState(() { - clearController.add(ClearEvent()); + _clearController.add(ClearEvent()); _clearUIData(widget.entityData); }); }, diff --git a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart index 92a7fa9e..1f1d1a2d 100644 --- a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart +++ b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart @@ -290,7 +290,7 @@ class _BrnLayerMoreSelectionPageState extends State Widget _buildLeftItem(int index) { //如果房山 被选中了或者房山处于正在选择的状态 则加粗 - TextStyle? textStyle = widget.themeData.flayerNormalTextStyle.generateTextStyle(); + TextStyle textStyle = widget.themeData.flayerNormalTextStyle.generateTextStyle(); if (index == _currentIndex) { textStyle = widget.themeData.flayerSelectedTextStyle.generateTextStyle(); } else if ((_firstList[index].isSelected) && _firstList[index].selectedList().isNotEmpty) { diff --git a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart index 2d582503..bb29f3af 100644 --- a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart @@ -280,11 +280,11 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { ); } - TextStyle? _tagTextStyle() { + TextStyle _tagTextStyle() { return widget.themeData.tagNormalTextStyle.generateTextStyle(); } - TextStyle? _selectedTextStyle() { + TextStyle _selectedTextStyle() { return widget.themeData.tagSelectedTextStyle.generateTextStyle(); } From 3f3b4d32ea2f05fba159797ded8cd8f46e271a1a Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Mon, 24 Jan 2022 16:34:18 +0800 Subject: [PATCH 18/31] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=97=AE=E9=A2=98key=E5=92=8Cstyle=E9=9D=9E?= =?UTF-8?q?=E7=A9=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../items/general/brn_multi_choice_input_item.dart | 6 +++--- .../brn_multi_choice_portrait_input_item.dart | 6 +++--- .../form/items/general/brn_radio_input_item.dart | 8 ++++---- .../form/items/general/brn_star_input_item.dart | 2 +- .../items/general/brn_title_select_input_item.dart | 10 +++++----- .../group/brn_expandable_group_with_opreate.dart | 2 +- .../form/items/group/brn_normal_group.dart | 2 +- .../form/items/group/brn_portrait_radio_group.dart | 14 +++++--------- .../form/items/misc/brn_add_label_item.dart | 6 +++--- .../form/items/title/brn_base_title_item.dart | 2 +- .../items/title/brn_select_all_title_item.dart | 4 ++-- lib/src/components/form/utils/brn_form_util.dart | 2 +- 12 files changed, 30 insertions(+), 34 deletions(-) diff --git a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart index 0de0347d..48707df0 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart @@ -88,7 +88,7 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { this.enableList = const [], this.onChanged, this.themeData}) - : super() { + : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) @@ -222,8 +222,8 @@ class BrnMultiChoiceInputFormItemState return result; } - TextStyle? getOptionTextStyle(int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + TextStyle getOptionTextStyle(int index) { + TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (index < 0 || index >= _selectStatus.length) { return result; } diff --git a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart index 037ab044..af1de928 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart @@ -89,7 +89,7 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { this.enableList = const [], this.onChanged, this.themeData}) - : super() { + : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) @@ -216,8 +216,8 @@ class BrnMultiChoicePortraitInputFormItemState return result; } - TextStyle? getOptionTextStyle(int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + TextStyle getOptionTextStyle(int index) { + TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (index < 0 || index >= _selectStatus.length) { return result; } diff --git a/lib/src/components/form/items/general/brn_radio_input_item.dart b/lib/src/components/form/items/general/brn_radio_input_item.dart index 285c5f64..c23a99df 100644 --- a/lib/src/components/form/items/general/brn_radio_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_input_item.dart @@ -340,7 +340,7 @@ class BrnRadioInputFormItemState extends State { ); } - List getRadioList(List? options) { + List getRadioList(List? options) { List result = []; String? option; if (options == null || options.isEmpty) { @@ -361,7 +361,7 @@ class BrnRadioInputFormItemState extends State { child: Container( padding: EdgeInsets.only(left: _kRadioTitleLeftPadding), child: Text( - option!, + option, style: getOptionTextStyle(option, index), )), disable: getRadioEnableState(index), @@ -388,8 +388,8 @@ class BrnRadioInputFormItemState extends State { return result; } - TextStyle? getOptionTextStyle(String? opt, int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + TextStyle getOptionTextStyle(String? opt, int index) { + TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (opt == null) { return result; } diff --git a/lib/src/components/form/items/general/brn_star_input_item.dart b/lib/src/components/form/items/general/brn_star_input_item.dart index 87dd8c20..701ba45a 100644 --- a/lib/src/components/form/items/general/brn_star_input_item.dart +++ b/lib/src/components/form/items/general/brn_star_input_item.dart @@ -87,7 +87,7 @@ class BrnStarsFormItem extends StatefulWidget { this.value: 0, this.onChanged, this.themeData}) - : super() { + : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) diff --git a/lib/src/components/form/items/general/brn_title_select_input_item.dart b/lib/src/components/form/items/general/brn_title_select_input_item.dart index 0a307cb3..fa48630e 100644 --- a/lib/src/components/form/items/general/brn_title_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_title_select_input_item.dart @@ -204,9 +204,9 @@ class BrnTitleSelectInputFormItemState return; } - RenderBox trigle = - _globalKey.currentContext?.findRenderObject() as RenderBox; - Offset offset = trigle.localToGlobal(Offset.zero); + RenderBox? trigle = + _globalKey.currentContext?.findRenderObject() as RenderBox?; + Offset? offset = trigle?.localToGlobal(Offset.zero); final RenderBox button = context.findRenderObject() as RenderBox; final RenderBox overlay = Overlay.of(context)!.context.findRenderObject() as RenderBox; @@ -219,9 +219,9 @@ class BrnTitleSelectInputFormItemState ); var relativeRect = RelativeRect.fromLTRB( - position.left + offset.dx, + position.left + (offset?.dx ?? 0.0), position.top + 44, - position.right + offset.dx, + position.right + (offset?.dx ?? 0.0), position.bottom + 44); _showController.add(true); Navigator.push( diff --git a/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart index 2c22f16b..8d36bf0f 100644 --- a/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart +++ b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart @@ -70,7 +70,7 @@ class BrnExpandFormGroup extends StatefulWidget { this.isExpand = true, this.deleteLabel, required this.children, - }); + }) : super(key: key); @override BrnExpandFormGroupState createState() { diff --git a/lib/src/components/form/items/group/brn_normal_group.dart b/lib/src/components/form/items/group/brn_normal_group.dart index 954da95c..8f2c1aa8 100644 --- a/lib/src/components/form/items/group/brn_normal_group.dart +++ b/lib/src/components/form/items/group/brn_normal_group.dart @@ -70,7 +70,7 @@ class BrnNormalFormGroup extends StatefulWidget { this.onTip, this.deleteLabel, required this.children, - }) : super() { + }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) diff --git a/lib/src/components/form/items/group/brn_portrait_radio_group.dart b/lib/src/components/form/items/group/brn_portrait_radio_group.dart index 5654c886..88ecbf44 100644 --- a/lib/src/components/form/items/group/brn_portrait_radio_group.dart +++ b/lib/src/components/form/items/group/brn_portrait_radio_group.dart @@ -55,12 +55,8 @@ class BrnPortraitRadioGroup extends StatefulWidget { this.selectedOption = options.indexOf(selectedOption) > -1 ? BrnPortraitRadioGroupOption( title: options[options.indexOf(selectedOption)]) - : BrnPortraitRadioGroupOption() -// int selectedIndex = options.indexOf(selectedOption); -// if (selectedIndex > -1) { -// this.selectedOption = this.options![selectedIndex]; -// } - { + : BrnPortraitRadioGroupOption(), + super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) @@ -78,7 +74,7 @@ class BrnPortraitRadioGroup extends StatefulWidget { this.onChanged, this.isCollapseContent = false, this.themeData, - }) { + }) :super(key: key){ this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) @@ -205,8 +201,8 @@ class BrnPortraitRadioGroupState extends State { return src.title == dst.title && src.subTitle == dst.subTitle; } - TextStyle? getOptionTextStyle(BrnPortraitRadioGroupOption opt, int index) { - TextStyle? result = BrnFormUtil.getOptionTextStyle(widget.themeData!); + TextStyle getOptionTextStyle(BrnPortraitRadioGroupOption opt, int index) { + TextStyle result = BrnFormUtil.getOptionTextStyle(widget.themeData!); if (isSameOption(opt, _selectedOption)) { result = BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); diff --git a/lib/src/components/form/items/misc/brn_add_label_item.dart b/lib/src/components/form/items/misc/brn_add_label_item.dart index 681a854f..55d69e7b 100644 --- a/lib/src/components/form/items/misc/brn_add_label_item.dart +++ b/lib/src/components/form/items/misc/brn_add_label_item.dart @@ -27,10 +27,10 @@ class BrnAddLabel extends StatefulWidget { BrnAddLabel({ Key? key, this.label, - this.title= "", - this.isEdit= true, + this.title = "", + this.isEdit = true, this.onTap, - }); + }) : super(key: key); @override BrnAddLabelState createState() { diff --git a/lib/src/components/form/items/title/brn_base_title_item.dart b/lib/src/components/form/items/title/brn_base_title_item.dart index f3b08453..90a1ba0a 100644 --- a/lib/src/components/form/items/title/brn_base_title_item.dart +++ b/lib/src/components/form/items/title/brn_base_title_item.dart @@ -64,7 +64,7 @@ class BrnBaseTitle extends StatefulWidget { this.customActionWidget, this.onTip, this.themeData, - }) { + }) : super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) diff --git a/lib/src/components/form/items/title/brn_select_all_title_item.dart b/lib/src/components/form/items/title/brn_select_all_title_item.dart index d6941b64..9f1c804b 100644 --- a/lib/src/components/form/items/title/brn_select_all_title_item.dart +++ b/lib/src/components/form/items/title/brn_select_all_title_item.dart @@ -78,7 +78,7 @@ class BrnSelectAllTitle extends StatefulWidget { this.selectState = true, this.themeData, this.customActionWidget, - }) { + }):super(key: key) { this.themeData ??= BrnFormItemConfig(); this.themeData = BrnThemeConfigurator.instance .getConfig(configId: this.themeData!.configId) @@ -152,7 +152,7 @@ class BrnSelectAllTitleState extends State { } } - TextStyle? getOptionTextStyle(BrnFormItemConfig? themeData) { + TextStyle getOptionTextStyle(BrnFormItemConfig? themeData) { if (_selectState) { return BrnFormUtil.getOptionSelectedTextStyle(widget.themeData!); } diff --git a/lib/src/components/form/utils/brn_form_util.dart b/lib/src/components/form/utils/brn_form_util.dart index 78102bfe..a11f269f 100644 --- a/lib/src/components/form/utils/brn_form_util.dart +++ b/lib/src/components/form/utils/brn_form_util.dart @@ -377,7 +377,7 @@ class BrnFormUtil { } /// 获取标题文本样式 - static TextStyle? getTitleTextStyle(BrnFormItemConfig themeData, + static TextStyle getTitleTextStyle(BrnFormItemConfig themeData, {double height = 0}) { if (height > 0) { return BrnTextStyle(height: height) From 8b9e3abd807c5b16cf4cd5e824d00e195af4a254 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Mon, 24 Jan 2022 17:32:53 +0800 Subject: [PATCH 19/31] migrate picker to null safety --- .../picker/date_picker_example.dart | 2 +- .../components/picker/picker_entry_page.dart | 12 +- .../components/picker/base/brn_picker.dart | 73 +++++---- .../picker/base/brn_picker_constants.dart | 14 +- .../picker/base/brn_picker_title.dart | 40 ++--- .../picker/base/brn_picker_title_config.dart | 10 +- .../components/picker/brn_bottom_picker.dart | 42 +++--- .../picker/brn_bottom_write_picker.dart | 46 +++--- .../picker/brn_mulit_select_tags_picker.dart | 77 +++++----- .../components/picker/brn_multi_picker.dart | 105 +++++++------ .../picker/brn_picker_cliprrect.dart | 9 +- .../brn_select_tags_with_input_picker.dart | 126 ++++++++-------- .../picker/brn_tags_common_picker.dart | 33 ++-- .../picker/brn_tags_picker_config.dart | 24 +-- .../bean/brn_multi_column_picker_entity.dart | 104 ++++++------- .../brn_multi_column_converter.dart | 35 +++-- .../brn_multi_column_list.dart | 100 ++++++------ .../brn_multi_column_picker.dart | 142 ++++++++---------- .../brn_multi_column_picker_util.dart | 30 ++-- .../btn_multi_column_picker_item.dart | 42 +++--- .../brn_multi_select_data.dart | 2 +- .../brn_multi_select_list_picker.dart | 42 +++--- .../brn_date_picker_constants.dart | 18 +-- .../time_picker/brn_date_time_formatter.dart | 12 +- .../date_picker/brn_date_picker.dart | 92 ++++++------ .../date_picker/brn_date_widget.dart | 94 ++++++------ .../date_picker/brn_datetime_widget.dart | 140 ++++++++--------- .../date_picker/brn_time_widget.dart | 102 ++++++------- .../brn_date_range_picker.dart | 94 ++++++------ .../brn_date_range_side_widget.dart | 99 ++++++------ .../brn_date_range_widget.dart | 86 +++++------ .../brn_time_range_side_widget.dart | 133 ++++++++-------- .../brn_time_range_widget.dart | 90 +++++------ .../bean/brn_selection_common_entity.dart | 4 +- .../brn_selection_more_item_widget.dart | 2 +- .../theme/base/brn_default_config_utils.dart | 8 +- 36 files changed, 1023 insertions(+), 1061 deletions(-) diff --git a/example/lib/sample/components/picker/date_picker_example.dart b/example/lib/sample/components/picker/date_picker_example.dart index d2c9b332..8fffca2a 100644 --- a/example/lib/sample/components/picker/date_picker_example.dart +++ b/example/lib/sample/components/picker/date_picker_example.dart @@ -156,7 +156,7 @@ class DatePickerExamplePage extends StatelessWidget { format = 'HH时:mm分'; BrnPickerTitleConfig timePickerTheme = BrnPickerTitleConfig( title: BrnPickerTitleConfig.Default.title, - showTitle: PICKER_SHOW_TITLE_DEFAULT, + showTitle: pickerShowTitleDefault, titleContent: "选择时间范围"); BrnDateRangePicker.showDatePicker(context, minDateTime: DateTime.parse(MIN_DATETIME), diff --git a/example/lib/sample/components/picker/picker_entry_page.dart b/example/lib/sample/components/picker/picker_entry_page.dart index c5484461..5bde9125 100644 --- a/example/lib/sample/components/picker/picker_entry_page.dart +++ b/example/lib/sample/components/picker/picker_entry_page.dart @@ -82,7 +82,7 @@ class PickerEntryPage extends StatelessWidget { describe: "底部级联选择框", onPressed: () { rootBundle.loadString('assets/list_picker.json').then((data) { - List _selectionData = List() + List _selectionData = [] ..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? []) .map((o) => BrnPickerEntity.fromMap(o))); if (_selectionData != null && _selectionData.length > 0) { @@ -100,7 +100,7 @@ class PickerEntryPage extends StatelessWidget { describe: "底部级联选择框(Title 动态改变)", onPressed: () { rootBundle.loadString('assets/list_picker.json').then((data) { - List _selectionData = List() + List _selectionData = [] ..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? []) .map((o) => BrnPickerEntity.fromMap(o))); if (_selectionData != null && _selectionData.length > 0) { @@ -131,7 +131,7 @@ class PickerEntryPage extends StatelessWidget { ///多选弹框 void _showBottomMultiSelectPicker(BuildContext context) { - List items = new List(); + List items = []; items.add(new BrnMultiSelectBottomPickerItem("100", "这里是标题1")); items.add(new BrnMultiSelectBottomPickerItem("101", "这里是标题2")); items.add(new BrnMultiSelectBottomPickerItem("102", "这里是标题3", isChecked: true)); @@ -353,7 +353,7 @@ class PickerEntryPage extends StatelessWidget { List items = List(); for (int i = 0; i < tags.length; i++) { String it = tags[i]; - BrnTagInputItemBean item = BrnTagInputItemBean(name: it, index: i, needExplane: (i % 2 == 0)); + BrnTagInputItemBean item = BrnTagInputItemBean(name: it, index: i, needExpend: (i % 2 == 0)); items.add(item); } @@ -371,8 +371,8 @@ class PickerEntryPage extends StatelessWidget { tagItemSource: items, tagTitleFontSize: 12, tagTitleColor: Color(0xff222222), - tagBackgroudColor: Color(0xffF8F8F8), - selectedTagBackgroudColor: Color(0x140984F9), + tagBackgroundColor: Color(0xffF8F8F8), + selectedTagBackgroundColor: Color(0x140984F9), selectedTagTitleColor: Color(0xFF0984F9), ), onTagValueGetter: (choice) { diff --git a/lib/src/components/picker/base/brn_picker.dart b/lib/src/components/picker/base/brn_picker.dart index 21f6b401..4b00fc4a 100644 --- a/lib/src/components/picker/base/brn_picker.dart +++ b/lib/src/components/picker/base/brn_picker.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; @@ -12,7 +12,7 @@ import 'package:flutter/widgets.dart'; /// Color of the 'magnifier' lens border. const Color _kHighlighterBorder = Color(0xFFF0F0F0); -const Color _kDefaultBackground = Color(0xFFD2D4DB); +const Color _kDefaultBackground = Color(0xFFFFFFFF); // Eyeballed values comparing with a native picker to produce the right // curvatures and densities. const double _kDefaultDiameterRatio = 3; @@ -61,7 +61,7 @@ class BrnPicker extends StatefulWidget { /// will loop the list back to the beginning. If set to false, the list will /// stop scrolling when you reach the end or the beginning. BrnPicker({ - Key key, + Key? key, this.diameterRatio = _kDefaultDiameterRatio, this.backgroundColor = _kDefaultBackground, this.lineColor = _kHighlighterBorder, @@ -70,9 +70,9 @@ class BrnPicker extends StatefulWidget { this.magnification = 1.0, this.scrollController, this.squeeze = _kSqueeze, - @required this.itemExtent, - @required this.onSelectedItemChanged, - @required List children, + required this.itemExtent, + required this.onSelectedItemChanged, + required List children, bool looping = false, }) : assert(children != null), assert(diameterRatio != null), @@ -106,7 +106,7 @@ class BrnPicker extends StatefulWidget { /// disable the background painting entirely; this is mildly more efficient /// than using [Colors.transparent]. BrnPicker.builder({ - Key key, + Key? key, this.diameterRatio = _kDefaultDiameterRatio, this.backgroundColor = _kDefaultBackground, this.lineColor = _kHighlighterBorder, @@ -115,10 +115,10 @@ class BrnPicker extends StatefulWidget { this.magnification = 1.0, this.scrollController, this.squeeze = _kSqueeze, - @required this.itemExtent, - @required this.onSelectedItemChanged, - @required IndexedWidgetBuilder itemBuilder, - int childCount, + required this.itemExtent, + required this.onSelectedItemChanged, + required IndexedWidgetBuilder itemBuilder, + int? childCount, }) : assert(itemBuilder != null), assert(diameterRatio != null), assert(diameterRatio > 0.0, @@ -153,7 +153,7 @@ class BrnPicker extends StatefulWidget { final Color backgroundColor; ///分割线颜色 - final Color lineColor; + final Color? lineColor; /// {@macro flutter.rendering.wheelList.offAxisFraction} final double offAxisFraction; @@ -167,7 +167,7 @@ class BrnPicker extends StatefulWidget { /// A [FixedExtentScrollController] to read and control the current item. /// /// If null, an implicit one will be created internally. - final FixedExtentScrollController scrollController; + final FixedExtentScrollController? scrollController; /// The uniform height of all children. /// @@ -197,8 +197,8 @@ class BrnPicker extends StatefulWidget { } class _CupertinoPickerState extends State { - int _lastHapticIndex; - FixedExtentScrollController _controller; + int? _lastHapticIndex; + FixedExtentScrollController? _controller; @override void initState() { @@ -249,8 +249,7 @@ class _CupertinoPickerState extends State { if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) return Container(); - final Color widgetBackgroundColor = - widget.backgroundColor ?? const Color(0xFFFFFFFF); + final Color widgetBackgroundColor = widget.backgroundColor; return Positioned.fill( child: IgnorePointer( child: Container( @@ -288,7 +287,7 @@ class _CupertinoPickerState extends State { /// Makes the magnifier lens look so that the colors are normal through /// the lens and partially grayed out around it. Widget _buildMagnifierScreen() { - final Color foreground = widget.backgroundColor?.withAlpha( + final Color foreground = widget.backgroundColor.withAlpha( (widget.backgroundColor.alpha * _kForegroundScreenOpacityFraction) .toInt()); @@ -326,7 +325,7 @@ class _CupertinoPickerState extends State { } Widget _buildUnderMagnifierScreen() { - final Color foreground = widget.backgroundColor?.withAlpha( + final Color foreground = widget.backgroundColor.withAlpha( (widget.backgroundColor.alpha * _kForegroundScreenOpacityFraction) .toInt()); @@ -361,7 +360,7 @@ class _CupertinoPickerState extends State { children: [ Positioned.fill( child: _CupertinoPickerSemantics( - scrollController: widget.scrollController ?? _controller, + scrollController: widget.scrollController ?? _controller!, child: ListWheelScrollView.useDelegate( controller: widget.scrollController ?? _controller, physics: const FixedExtentScrollPhysics(), @@ -406,9 +405,9 @@ class _CupertinoPickerState extends State { // scroll controller. class _CupertinoPickerSemantics extends SingleChildRenderObjectWidget { const _CupertinoPickerSemantics({ - Key key, - Widget child, - @required this.scrollController, + Key? key, + Widget? child, + required this.scrollController, }) : super(key: key, child: child); final FixedExtentScrollController scrollController; @@ -433,16 +432,16 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { this.controller = controller; } - FixedExtentScrollController get controller => _controller; - FixedExtentScrollController _controller; + FixedExtentScrollController? get controller => _controller; + FixedExtentScrollController? _controller; - set controller(FixedExtentScrollController value) { + set controller(FixedExtentScrollController? value) { if (value == _controller) return; if (_controller != null) - _controller.removeListener(_handleScrollUpdate); + _controller!.removeListener(_handleScrollUpdate); else - _currentIndex = value.initialItem ?? 0; - value.addListener(_handleScrollUpdate); + _currentIndex = value!.initialItem; + value!.addListener(_handleScrollUpdate); _controller = value; } @@ -458,17 +457,17 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { int _currentIndex = 0; void _handleIncrease() { - controller.jumpToItem(_currentIndex + 1); + controller!.jumpToItem(_currentIndex + 1); } void _handleDecrease() { if (_currentIndex == 0) return; - controller.jumpToItem(_currentIndex - 1); + controller!.jumpToItem(_currentIndex - 1); } void _handleScrollUpdate() { - if (controller.selectedItem == _currentIndex) return; - _currentIndex = controller.selectedItem; + if (controller!.selectedItem == _currentIndex) return; + _currentIndex = controller!.selectedItem; markNeedsSemanticsUpdate(); } @@ -485,7 +484,7 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { if (children.isEmpty) return super.assembleSemanticsNode(node, config, children); final SemanticsNode scrollable = children.first; - final Map indexedChildren = {}; + final Map indexedChildren = {}; scrollable.visitChildren((SemanticsNode child) { assert(child.indexInParent != null); indexedChildren[child.indexInParent] = child; @@ -494,9 +493,9 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { if (indexedChildren[_currentIndex] == null) { return node.updateWith(config: config); } - config.value = indexedChildren[_currentIndex].label; - final SemanticsNode previousChild = indexedChildren[_currentIndex - 1]; - final SemanticsNode nextChild = indexedChildren[_currentIndex + 1]; + config.value = indexedChildren[_currentIndex]!.label; + final SemanticsNode? previousChild = indexedChildren[_currentIndex - 1]; + final SemanticsNode? nextChild = indexedChildren[_currentIndex + 1]; if (nextChild != null) { config.increasedValue = nextChild.label; config.onIncrease = _handleIncrease; diff --git a/lib/src/components/picker/base/brn_picker_constants.dart b/lib/src/components/picker/base/brn_picker_constants.dart index 977539ea..9ed44cc5 100755 --- a/lib/src/components/picker/base/brn_picker_constants.dart +++ b/lib/src/components/picker/base/brn_picker_constants.dart @@ -1,28 +1,28 @@ import 'package:flutter/material.dart'; /// Default value of DatePicker's item [TextStyle]. -const TextStyle DATETIME_PICKER_ITEM_TEXT_STYLE = TextStyle( +const TextStyle datetimePickerItemTextStyle = TextStyle( color: Color(0xFF222222), fontSize: 18.0, ); /// Default value of DatePicker's background color. -const PICKER_BACKGROUND_COLOR = Colors.white; +const pickerBackgroundColor = Colors.white; /// Default value of whether show title widget or not. -const PICKER_SHOW_TITLE_DEFAULT = true; +const pickerShowTitleDefault = true; /// Default value of DatePicker's height. -const double PICKER_HEIGHT = 240.0; +const double pickerHeight = 240.0; /// Default value of DatePicker's title height. -const double PICKER_TITLE_HEIGHT = 48.0; +const double pickerTitleHeight = 48.0; /// Default value of DatePicker's column height. -const double PICKER_ITEM_HEIGHT = 48.0; +const double pickerItemHeight = 48.0; /// Default value of DatePicker's item [TextStyle]. -const TextStyle PICKER_ITEM_TEXT_STYLE = TextStyle( +const TextStyle pickerItemTextStyle = TextStyle( color: Color(0xFF222222), fontSize: 18.0, ); diff --git a/lib/src/components/picker/base/brn_picker_title.dart b/lib/src/components/picker/base/brn_picker_title.dart index 1f62b309..52241332 100755 --- a/lib/src/components/picker/base/brn_picker_title.dart +++ b/lib/src/components/picker/base/brn_picker_title.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/time_picker/brn_date_picker_constants.dart'; import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; @@ -11,21 +11,21 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class BrnPickerTitle extends StatelessWidget { final BrnPickerTitleConfig pickerTitleConfig; - final DateTimePickerLocale locale; + final DateTimePickerLocale? locale; final DateVoidCallback onCancel, onConfirm; - BrnPickerConfig themeData; + late BrnPickerConfig? themeData; BrnPickerTitle({ - Key key, + Key? key, this.locale, - @required this.onCancel, - @required this.onConfirm, - this.pickerTitleConfig, + required this.onCancel, + required this.onConfirm, + this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.themeData, }) : super(key: key) { this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -33,16 +33,16 @@ class BrnPickerTitle extends StatelessWidget { @override Widget build(BuildContext context) { if (pickerTitleConfig.title != null) { - return pickerTitleConfig.title; + return pickerTitleConfig.title!; } return Container( - height: themeData.titleHeight, + height: themeData!.titleHeight, decoration: ShapeDecoration( - color: themeData.backgroundColor, + color: themeData!.backgroundColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( - topLeft: Radius.circular(themeData.cornerRadius), - topRight: Radius.circular(themeData.cornerRadius), + topLeft: Radius.circular(themeData!.cornerRadius), + topRight: Radius.circular(themeData!.cornerRadius), ), ), ), @@ -51,7 +51,7 @@ class BrnPickerTitle extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - height: themeData.titleHeight - 0.5, + height: themeData!.titleHeight - 0.5, padding: EdgeInsets.symmetric(horizontal: 20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -64,7 +64,7 @@ class BrnPickerTitle extends StatelessWidget { ), Text( pickerTitleConfig.titleContent, - style: themeData.titleTextStyle.generateTextStyle(), + style: themeData!.titleTextStyle.generateTextStyle(), ), GestureDetector( child: _renderConfirmWidget(context), @@ -76,7 +76,7 @@ class BrnPickerTitle extends StatelessWidget { ), ), Divider( - color: themeData.dividerColor, + color: themeData!.dividerColor, indent: 0.0, height: 0.5, ), @@ -87,9 +87,9 @@ class BrnPickerTitle extends StatelessWidget { /// render cancel button widget Widget _renderCancelWidget(BuildContext context) { - Widget cancelWidget = pickerTitleConfig.cancel; + Widget? cancelWidget = pickerTitleConfig.cancel; if (cancelWidget == null) { - TextStyle textStyle = themeData.cancelTextStyle.generateTextStyle(); + TextStyle textStyle = themeData!.cancelTextStyle.generateTextStyle(); cancelWidget = Text( '取消', style: textStyle, @@ -101,9 +101,9 @@ class BrnPickerTitle extends StatelessWidget { /// render confirm button widget Widget _renderConfirmWidget(BuildContext context) { - Widget confirmWidget = pickerTitleConfig.confirm; + Widget? confirmWidget = pickerTitleConfig.confirm; if (confirmWidget == null) { - TextStyle textStyle = themeData.confirmTextStyle.generateTextStyle(); + TextStyle textStyle = themeData!.confirmTextStyle.generateTextStyle(); confirmWidget = Text( '完成', style: textStyle, diff --git a/lib/src/components/picker/base/brn_picker_title_config.dart b/lib/src/components/picker/base/brn_picker_title_config.dart index f84677a7..84d0cafc 100755 --- a/lib/src/components/picker/base/brn_picker_title_config.dart +++ b/lib/src/components/picker/base/brn_picker_title_config.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_constants.dart'; import 'package:flutter/material.dart'; @@ -17,20 +17,20 @@ class BrnPickerTitleConfig { this.cancel, this.confirm, this.title, - this.showTitle: PICKER_SHOW_TITLE_DEFAULT, + this.showTitle: pickerShowTitleDefault, this.titleContent: "请选择", }); static const BrnPickerTitleConfig Default = const BrnPickerTitleConfig(); /// Custom cancel [Widget]. - final Widget cancel; + final Widget? cancel; /// Custom confirm [Widget]. - final Widget confirm; + final Widget? confirm; /// Custom title [Widget]. If specify a title widget, the cancel and confirm widgets will not display. - final Widget title; + final Widget? title; /// Whether display title widget or not. If set false, the default cancel and confirm widgets will not display, but the custom title widget will display if had specified one custom title widget. final bool showTitle; diff --git a/lib/src/components/picker/brn_bottom_picker.dart b/lib/src/components/picker/brn_bottom_picker.dart index 2668896b..91a531c9 100644 --- a/lib/src/components/picker/brn_bottom_picker.dart +++ b/lib/src/components/picker/brn_bottom_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_title.dart'; import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; @@ -26,12 +26,12 @@ import 'package:flutter/rendering.dart'; class BrnBottomPicker { static void show( BuildContext context, { - @required contentWidget, + required contentWidget, String title = '请选择', dynamic confirm, dynamic cancel, - VoidCallback onConfirm, - VoidCallback onCancel, + VoidCallback? onConfirm, + VoidCallback? onCancel, bool barrierDismissible = true, bool showTitle = true, }) { @@ -50,7 +50,7 @@ class BrnBottomPicker { pickerTitleConfig: BrnPickerTitleConfig(titleContent: title, showTitle: showTitle), ); - return theme != null ? Theme(data: theme, child: pageChild) : pageChild; + return Theme(data: theme, child: pageChild); }, barrierDismissible: barrierDismissible, barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, @@ -75,14 +75,14 @@ class BrnBottomPickerWidget extends StatefulWidget { final Widget contentWidget; final dynamic confirm; final dynamic cancel; - final Function() onConfirmPressed; - final Function() onCancelPressed; + final Function()? onConfirmPressed; + final Function()? onCancelPressed; final barrierDismissible; final BrnPickerTitleConfig pickerTitleConfig; const BrnBottomPickerWidget({ - Key key, - this.contentWidget, + Key? key, + required this.contentWidget, this.confirm, this.cancel, this.onConfirmPressed, @@ -99,8 +99,8 @@ class BrnBottomPickerWidget extends StatefulWidget { class BrnBottomPickerWidgetState extends State with TickerProviderStateMixin { - AnimationController _controller; - Animation _animation; + late AnimationController _controller; + late Animation _animation; @override void initState() { @@ -117,7 +117,7 @@ class BrnBottomPickerWidgetState extends State Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { - _controller?.reverse(); + _controller.reverse(); return true; }, child: Scaffold( @@ -136,12 +136,12 @@ class BrnBottomPickerWidgetState extends State @override void dispose() { super.dispose(); - _controller?.dispose(); + _controller.dispose(); } Widget _buildBottomWidget() { return SlideTransition( - position: _animation, + position: _animation as Animation, child: BrnPickerClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(BrnThemeConfigurator.instance @@ -177,14 +177,14 @@ class BrnBottomPickerWidgetState extends State if (widget.onCancelPressed == null) { _closeDialog(); } else { - widget.onCancelPressed(); + widget.onCancelPressed!(); } }, onConfirm: () { if (widget.onConfirmPressed == null) { _closeDialog(); } else { - widget.onConfirmPressed(); + widget.onConfirmPressed!(); } }, pickerTitleConfig: BrnPickerTitleConfig( @@ -194,8 +194,8 @@ class BrnBottomPickerWidgetState extends State ); } - Widget _buildConfirmWidget() { - Widget confirmWidget; + Widget? _buildConfirmWidget() { + Widget? confirmWidget; if (widget.confirm is Widget) { confirmWidget = widget.confirm; } else if (widget.confirm is String) { @@ -206,8 +206,8 @@ class BrnBottomPickerWidgetState extends State return confirmWidget; } - Widget _buildCancelWidget() { - Widget cancelWidget; + Widget? _buildCancelWidget() { + Widget? cancelWidget; if (widget.cancel is Widget) { cancelWidget = widget.cancel; } else if (widget.cancel is String) { @@ -231,7 +231,7 @@ class BrnBottomPickerWidgetState extends State ); } - Widget _buildDefaultCancel(String string) { + Widget _buildDefaultCancel(String? string) { return Text( string ?? '取消', style: TextStyle( diff --git a/lib/src/components/picker/brn_bottom_write_picker.dart b/lib/src/components/picker/brn_bottom_write_picker.dart index 83cb45d8..553e810f 100644 --- a/lib/src/components/picker/brn_bottom_write_picker.dart +++ b/lib/src/components/picker/brn_bottom_write_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; import 'package:bruno/src/components/picker/brn_bottom_picker.dart'; @@ -7,11 +7,11 @@ import 'package:flutter/material.dart'; ///取消输入事件回调 typedef BrnBottomWritePickerClickCallback = Future Function( - String content); + String? content); ///确认输入事件回调 typedef BrnBottomWritePickerConfirmClickCallback = Future Function( - BuildContext dialogContext, String content); + BuildContext dialogContext, String? content); class BrnBottomWritePicker extends StatefulWidget { /// 弹窗左边自定义文案,默认 '取消' @@ -30,22 +30,22 @@ class BrnBottomWritePicker extends StatefulWidget { final int maxLength; /// 取消输入事件回调 - final BrnBottomWritePickerClickCallback onCancel; + final BrnBottomWritePickerClickCallback? onCancel; /// 确认输入内容事件回调 - final BrnBottomWritePickerConfirmClickCallback onConfirm; + final BrnBottomWritePickerConfirmClickCallback? onConfirm; /// 弹窗右边文案颜色 - final Color rightTextColor; + final Color? rightTextColor; /// 光标颜色 - final Color cursorColor; + final Color? cursorColor; /// 默认文本 - final String defaultText; + final String? defaultText; /// 用于对 TextField 更精细的控制,若传入该字段,[defaultText] 参数将失效,可使用 TextEditingController.text 进行赋值。 - final TextEditingController textEditingController; + final TextEditingController? textEditingController; const BrnBottomWritePicker( {this.maxLength = 200, @@ -71,14 +71,14 @@ class BrnBottomWritePicker extends StatefulWidget { String leftTag = "取消", String title = "", String rightTag = "确认", - BrnBottomWritePickerClickCallback onCancel, - BrnBottomWritePickerConfirmClickCallback onConfirm, + BrnBottomWritePickerClickCallback? onCancel, + BrnBottomWritePickerConfirmClickCallback? onConfirm, bool confirmDismiss = false, bool cancelDismiss = true, - Color rightTextColor, - Color cursorColor, - String defaultText, - TextEditingController textEditingController}) { + Color? rightTextColor, + Color? cursorColor, + String? defaultText, + TextEditingController? textEditingController}) { final ThemeData theme = Theme.of(context); showGeneralDialog( context: context, @@ -105,26 +105,24 @@ class BrnBottomWritePicker extends StatefulWidget { defaultText: defaultText, textEditingController: textEditingController, ); - return theme != null - ? Theme(data: theme, child: pageChild) - : pageChild; + return Theme(data: theme, child: pageChild); }); } } class _BottomWritePickerState extends State { - TextEditingController _controller; + TextEditingController? _controller; @override void initState() { super.initState(); if (_controller == null) { - if (widget.defaultText != null && widget.defaultText.length > 0) { + if (widget.defaultText != null && widget.defaultText!.length > 0) { _controller = TextEditingController.fromValue(TextEditingValue( - text: widget.defaultText, + text: widget.defaultText!, selection: TextSelection.fromPosition(TextPosition( affinity: TextAffinity.downstream, - offset: widget.defaultText.length)))); + offset: widget.defaultText!.length)))); } else { _controller = TextEditingController(); } @@ -173,12 +171,12 @@ class _BottomWritePickerState extends State { cancel: widget.leftTag, onConfirmPressed: () { if (widget.onConfirm != null) { - widget.onConfirm(context, _controller?.text); + widget.onConfirm!(context, _controller?.text); } }, onCancelPressed: () { if (widget.onCancel != null) { - widget.onCancel(_controller?.text); + widget.onCancel!(_controller?.text); } }, barrierDismissible: true, diff --git a/lib/src/components/picker/brn_mulit_select_tags_picker.dart b/lib/src/components/picker/brn_mulit_select_tags_picker.dart index 30218dc0..8f501f3c 100644 --- a/lib/src/components/picker/brn_mulit_select_tags_picker.dart +++ b/lib/src/components/picker/brn_mulit_select_tags_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; import 'package:bruno/src/components/picker/brn_tags_common_picker.dart'; @@ -25,14 +25,15 @@ typedef BrnMultiSelectTagOnItemClick = void Function( /// 多选标签弹框,适用于底部弹出 Picker,且选择样式为 Tag 的场景。 /// 功能:多选标签弹框,适用于从底部弹出的情况,属于 Picker; /// 可自定义标题、默认选中、字体大小等。 +// ignore: must_be_immutable class BrnMultiSelectTagsPicker extends CommonTagsPicker { BrnMultiSelectTagsPicker({ - Key key, - @required this.context, - @required this.onConfirm, + Key? key, + required this.context, + required this.onConfirm, this.onCancel, - @required this.tagPickerConfig, - @required this.onTagValueGetter, + required this.tagPickerConfig, + required this.onTagValueGetter, this.onMaxSelectClick, this.onItemClick, this.maxSelectItemCount = 0, @@ -40,7 +41,7 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { this.itemHeight = 34.0, this.layoutStyle = BrnMultiSelectTagsLayoutStyle.average, BrnPickerTitleConfig pickerTitleConfig = BrnPickerTitleConfig.Default, - BrnPickerConfig themeData, + BrnPickerConfig? themeData, }) : super( key: key, context: context, @@ -56,16 +57,16 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { final ValueChanged onConfirm; /// 点击取消按钮 - final VoidCallback onCancel; + final VoidCallback? onCancel; /// 当点击到最大数目时的点击事件 - final VoidCallback onMaxSelectClick; + final VoidCallback? onMaxSelectClick; /// 点击某个按钮的回调 - final BrnMultiSelectTagOnItemClick onItemClick; + final BrnMultiSelectTagOnItemClick? onItemClick; /// 一行多少个数据,默认4个 - final int crossAxisCount; + final int? crossAxisCount; /// 最多选择多少个item,默认可以无限选 final int maxSelectItemCount; @@ -84,8 +85,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { final double itemHeight; /// 操作类型属性 - List _selectedTags; - List _sourceTags; + late List _selectedTags; + late List _sourceTags; @override void show() { @@ -99,8 +100,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { } @override - Widget createBuilder(BuildContext context, VoidCallback onUpdate) { - if (this.tagPickerConfig?.tagItemSource?.isNotEmpty ?? false) { + Widget createBuilder(BuildContext context, VoidCallback? onUpdate) { + if (this.tagPickerConfig.tagItemSource.isNotEmpty) { return _buildContent(context, onUpdate); } else { return Container( @@ -112,12 +113,12 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { } } - Widget _buildContent(BuildContext context, VoidCallback onUpdate) { + Widget _buildContent(BuildContext context, VoidCallback? onUpdate) { if (this.layoutStyle == BrnMultiSelectTagsLayoutStyle.average) { return LayoutBuilder( builder: (_, constraints) { - double maxwidth = constraints.maxWidth; - return _buildGridViewWidget(context, onUpdate, maxwidth); + double maxWidth = constraints.maxWidth; + return _buildGridViewWidget(context, onUpdate, maxWidth); }, ); } else { @@ -127,11 +128,11 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { ///等宽度的布局 Widget _buildGridViewWidget( - BuildContext context, VoidCallback onUpdate, double maxWidth) { + BuildContext context, VoidCallback? onUpdate, double maxWidth) { int brnCrossAxisCount = - (this.crossAxisCount == 0 || this.crossAxisCount == null) + (this.crossAxisCount == null || this.crossAxisCount == 0) ? 4 - : this.crossAxisCount; + : this.crossAxisCount!; double width = (maxWidth - (brnCrossAxisCount - 1) * 12 - 40) / brnCrossAxisCount; //计算宽高比 @@ -143,9 +144,9 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { .getConfig() .commonConfig .colorTextImportant; - Color tagBackgroudColor = + Color tagBackgroundColor = this.tagPickerConfig.tagBackgroudColor ?? Color(0xffF8F8F8); - Color selectedTagBackgroudColor = + Color selectedTagBackgroundColor = this.tagPickerConfig.selectedTagBackgroudColor ?? BrnThemeConfigurator.instance .getConfig() @@ -177,8 +178,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { selected: selected, padding: edgeInsets, pressElevation: 0, - backgroundColor: tagBackgroudColor, - selectedColor: selectedTagBackgroudColor, + backgroundColor: tagBackgroundColor, + selectedColor: selectedTagBackgroundColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(2.0)), label: Container( @@ -201,12 +202,12 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { value == true) { if (this.onMaxSelectClick != null) { // ignore: unnecessary_statements - this.onMaxSelectClick(); + this.onMaxSelectClick!(); } return; } _clickTag(value, choice); - onUpdate(); + onUpdate!(); }, ); }).toList(), @@ -215,7 +216,7 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { } ///流式布局 - Widget _buildWrapViewWidget(BuildContext context, VoidCallback onUpdate) { + Widget _buildWrapViewWidget(BuildContext context, VoidCallback? onUpdate) { Color selectedTagTitleColor = this.tagPickerConfig.selectedTagTitleColor ?? BrnThemeConfigurator.instance.getConfig().commonConfig.brandPrimary; Color tagTitleColor = this.tagPickerConfig.tagTitleColor ?? @@ -223,9 +224,9 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { .getConfig() .commonConfig .colorTextImportant; - Color tagBackgroudColor = + Color tagBackgroundColor = this.tagPickerConfig.tagBackgroudColor ?? Color(0xffF8F8F8); - Color selectedTagBackgroudColor = + Color selectedTagBackgroundColor = this.tagPickerConfig.selectedTagBackgroudColor ?? BrnThemeConfigurator.instance .getConfig() @@ -247,8 +248,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { selected: selected, padding: edgeInsets, pressElevation: 0, - backgroundColor: tagBackgroudColor, - selectedColor: selectedTagBackgroudColor, + backgroundColor: tagBackgroundColor, + selectedColor: selectedTagBackgroundColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(2.0)), label: Text( @@ -268,12 +269,12 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { value == true) { if (this.onMaxSelectClick != null) { // ignore: unnecessary_statements - this.onMaxSelectClick(); + this.onMaxSelectClick!(); } return; } _clickTag(value, choice); - onUpdate(); + onUpdate!(); }, ); }).toList(), @@ -281,12 +282,12 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { } void _dataSetup() { - List tagItems = List(); - List tagSelectItems = List(); + List tagItems = []; + List tagSelectItems = []; for (BrnTagItemBean item in this.tagPickerConfig.tagItemSource) { tagItems.add(item); //选中的按钮 - if (item.isSelect == true && item.name != null) { + if (item.isSelect == true) { tagSelectItems.add(item); } } @@ -308,7 +309,7 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { ///点击tag if (this.onItemClick != null) { - this.onItemClick(tagName, selected); + this.onItemClick!(tagName, selected); } } } diff --git a/lib/src/components/picker/brn_multi_picker.dart b/lib/src/components/picker/brn_multi_picker.dart index d1834051..7f2ac315 100644 --- a/lib/src/components/picker/brn_multi_picker.dart +++ b/lib/src/components/picker/brn_multi_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker.dart'; import 'package:bruno/src/components/picker/base/brn_picker_title.dart'; @@ -7,8 +7,7 @@ import 'package:bruno/src/components/picker/brn_picker_cliprrect.dart'; import 'package:bruno/src/theme/brn_theme.dart'; import 'package:flutter/material.dart'; -///数据选择控件高度 -const pickerHeight = 240.0; +import 'base/brn_picker_constants.dart'; /// 可以自定义实现 item Widget样式,更灵活 /// [isSelect] 是否被选中 @@ -33,10 +32,10 @@ abstract class BrnMultiDataPickerDelegate { int numberOfRowsInComponent(int component); /// 定义某列某行所显示的内容,component 代表列的索引,index 代表 第component列中的第 index 个元素 - String titleForRowInComponent(int component, int index); + String? titleForRowInComponent(int component, int index); /// 定义每列内容的高度 - double rowHeightForComponent(int component); + double? rowHeightForComponent(int component); /// 定义选择更改后的操作 void selectRowInComponent(int component, int row); @@ -52,7 +51,7 @@ class BrnMultiDataPicker extends StatefulWidget { final String title; ///多级数据选择标题文案样式 - final TextStyle titleTextStyle; + final TextStyle? titleTextStyle; /// 多级数据选择弹窗所要覆盖页面的context final BuildContext context; @@ -61,55 +60,55 @@ class BrnMultiDataPicker extends StatefulWidget { final BrnMultiDataPickerDelegate delegate; ///多级数据选择确认文案样式 - final TextStyle confirmTextStyle; + final TextStyle? confirmTextStyle; ///多级数据选择取消文案样式 - final TextStyle cancelTextStyle; + final TextStyle? cancelTextStyle; /// 多级数据选择每一级的默认标题 - final List pickerTitles; + final List? pickerTitles; /// 多级数据选择每一级默认标题的字体大小 - final double pickerTitleFontSize; + final double? pickerTitleFontSize; /// 多级数据选择每一级默认标题的文案颜色 - final Color pickerTitleColor; + final Color? pickerTitleColor; /// 多级数据选择数据字体大小 - final double textFontSize; + final double? textFontSize; /// 多级数据选择数据文案颜色 - final Color textColor; + final Color? textColor; /// 多级数据选择数据选中文案颜色 - final Color textSelectedColor; + final Color? textSelectedColor; /// 多级数据选择数据widget容器 - final List controllers = List(); + final List controllers = []; /// 多级数据选择确认点击回调 - final ConfirmButtonClick confirmClick; + final ConfirmButtonClick? confirmClick; /// 选择轮盘的滚动行为 - final ScrollBehavior behavior; + final ScrollBehavior? behavior; /// 返回自定义 itemWidget 的回调 - final BrnMultiDataPickerCreateWidgetCallback createItemWidget; + final BrnMultiDataPickerCreateWidgetCallback? createItemWidget; /// 是否复位数据位置。默认 true final bool sync; - BrnPickerConfig themeData; + BrnPickerConfig? themeData; BrnMultiDataPicker( - {Key key, - @required this.context, - @required this.delegate, + {Key? key, + required this.context, + required this.delegate, this.title = "", this.titleTextStyle, this.confirmTextStyle, this.cancelTextStyle, - this.pickerTitles, + this.pickerTitles = const [], this.pickerTitleFontSize, this.pickerTitleColor, this.textFontSize, @@ -119,10 +118,9 @@ class BrnMultiDataPicker extends StatefulWidget { this.confirmClick, this.createItemWidget, this.themeData, - this.sync = true}) - : assert(delegate != null) { + this.sync = true}) { this.themeData ??= BrnPickerConfig(); - this.themeData = this.themeData.merge(BrnPickerConfig( + this.themeData = this.themeData!.merge(BrnPickerConfig( cancelTextStyle: BrnTextStyle.withStyle(cancelTextStyle), confirmTextStyle: BrnTextStyle.withStyle(confirmTextStyle), titleTextStyle: BrnTextStyle.withStyle(titleTextStyle), @@ -132,7 +130,7 @@ class BrnMultiDataPicker extends StatefulWidget { )); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -155,7 +153,7 @@ class BrnMultiDataPicker extends StatefulWidget { } class _BrnMultiDataPickerState extends State { - List _selectedIndexList = List(); + List _selectedIndexList = []; @override void initState() { @@ -168,7 +166,7 @@ class _BrnMultiDataPickerState extends State { @override Widget build(BuildContext context) { return Container( - height: widget.themeData.pickerHeight + widget.themeData.titleHeight, + height: widget.themeData!.pickerHeight + widget.themeData!.titleHeight, child: Material( type: MaterialType.transparency, child: new Column( @@ -176,8 +174,8 @@ class _BrnMultiDataPickerState extends State { children: [ BrnPickerClipRRect( borderRadius: BorderRadius.only( - topLeft: Radius.circular(widget.themeData.cornerRadius), - topRight: Radius.circular(widget.themeData.cornerRadius), + topLeft: Radius.circular(widget.themeData!.cornerRadius), + topRight: Radius.circular(widget.themeData!.cornerRadius), ), child: _configHeaderWidget(), ), @@ -200,7 +198,8 @@ class _BrnMultiDataPickerState extends State { }, onConfirm: () { Navigator.of(context).pop(_selectedIndexList); - widget?.confirmClick(_selectedIndexList); + if (widget.confirmClick != null) + widget.confirmClick!(_selectedIndexList); }, ); } @@ -218,7 +217,7 @@ class _BrnMultiDataPickerState extends State { } List _pickersWithTitle() { - List pickersWithTitle = List(); + List pickersWithTitle = []; for (int i = 0; i < widget.delegate.numberOfComponent(); i++) { int initRow = widget.delegate.initSelectedRowForComponent(i); FixedExtentScrollController controller = @@ -236,7 +235,7 @@ class _BrnMultiDataPickerState extends State { child: Padding( padding: EdgeInsets.only(top: 25), child: Text( - widget.pickerTitles[i], + widget.pickerTitles == null ? '' : widget.pickerTitles![i], style: TextStyle( fontSize: widget.pickerTitleFontSize, color: widget.pickerTitleColor), @@ -252,7 +251,7 @@ class _BrnMultiDataPickerState extends State { //picker数据 List _pickers() { - List pickers = List(); + List pickers = []; for (int i = 0; i < widget.delegate.numberOfComponent(); i++) { int initRow = widget.delegate.initSelectedRowForComponent(i); FixedExtentScrollController controller = @@ -268,34 +267,34 @@ class _BrnMultiDataPickerState extends State { //构建单列数据 Widget _configSinglePicker(int component) { return MyPicker( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, controller: widget.controllers[component], key: Key(component.toString()), createWidgetList: () { if (widget.createItemWidget != null) { - List widgetList = List(); + List widgetList = []; for (int i = 0; i < widget.delegate.numberOfRowsInComponent(component); i++) { bool isSelect = _selectedIndexList[component] == i; widgetList.add(widget.createItemWidget != null - ? widget.createItemWidget( + ? widget.createItemWidget!( isSelect, component, i, _selectedIndexList) : Container()); } return widgetList; } else { - List list = List(); + List list = []; for (int i = 0; i < widget.delegate.numberOfRowsInComponent(component); i++) { list.add(Center( child: Text( - widget.delegate.titleForRowInComponent(component, i), + widget.delegate.titleForRowInComponent(component, i) ?? '', style: _selectedIndexList[component] == i - ? widget.themeData.itemTextSelectedStyle.generateTextStyle() - : widget.themeData.itemTextStyle.generateTextStyle(), + ? widget.themeData!.itemTextSelectedStyle.generateTextStyle() + : widget.themeData!.itemTextStyle.generateTextStyle(), ), )); } @@ -303,7 +302,7 @@ class _BrnMultiDataPickerState extends State { } }, itemExtent: widget.delegate.rowHeightForComponent(component) ?? - widget.themeData.itemHeight, + widget.themeData!.itemHeight, changed: (int index) { widget.delegate.selectRowInComponent(component, index); _selectedIndexList[component] = index; @@ -311,7 +310,7 @@ class _BrnMultiDataPickerState extends State { for (int i = component + 1; i < widget.delegate.numberOfComponent(); i++) { - List list = List(); + List list = []; for (int j = 0; j < widget.delegate.numberOfRowsInComponent(component); j++) { @@ -334,22 +333,22 @@ class _BrnMultiDataPickerState extends State { /// 一级数据选择widget class MyPicker extends StatefulWidget { ///创建数据widget列表 - final CreateWidgetList createWidgetList; + final CreateWidgetList? createWidgetList; ///数据选择改变回调 - final ValueChanged changed; + final ValueChanged? changed; - final Key key; + final Key? key; /// 数据显示高度 final double itemExtent; /// 滚动行为 - final ScrollBehavior scrollBehavior; + final ScrollBehavior? scrollBehavior; - final FixedExtentScrollController controller; + final FixedExtentScrollController? controller; final Color backgroundColor; - final Color lineColor; + final Color? lineColor; MyPicker({ this.createWidgetList, @@ -371,7 +370,7 @@ class MyPicker extends StatefulWidget { class _MyPickerState extends State { @override Widget build(BuildContext context) { - var children = widget.createWidgetList(); + var children = widget.createWidgetList!(); return Container( child: ScrollConfiguration( behavior: widget.scrollBehavior ?? _DefaultScrollBehavior(), @@ -383,7 +382,7 @@ class _MyPickerState extends State { lineColor: widget.lineColor, onSelectedItemChanged: (index) { if (widget.changed != null) { - widget.changed(index); + widget.changed!(index); } }, children: children.length > 0 diff --git a/lib/src/components/picker/brn_picker_cliprrect.dart b/lib/src/components/picker/brn_picker_cliprrect.dart index c3313044..ca5ac7e3 100644 --- a/lib/src/components/picker/brn_picker_cliprrect.dart +++ b/lib/src/components/picker/brn_picker_cliprrect.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -8,12 +6,11 @@ import 'package:flutter/widgets.dart'; /// [borderRadius] 默认值为 BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0)), class BrnPickerClipRRect extends ClipRRect { const BrnPickerClipRRect({ - Key key, + Key? key, BorderRadius borderRadius = const BorderRadius.only( topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), - Widget child, - }) : assert(borderRadius != null), - super(key: key, borderRadius: borderRadius, child: child); + Widget? child, + }) : super(key: key, borderRadius: borderRadius, child: child); } diff --git a/lib/src/components/picker/brn_select_tags_with_input_picker.dart b/lib/src/components/picker/brn_select_tags_with_input_picker.dart index 7c21e2f0..8b5f089e 100644 --- a/lib/src/components/picker/brn_select_tags_with_input_picker.dart +++ b/lib/src/components/picker/brn_select_tags_with_input_picker.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/picker/brn_picker_cliprrect.dart'; import 'package:bruno/src/constants/brn_asset_constants.dart'; import 'package:bruno/src/theme/brn_theme_configurator.dart'; @@ -13,7 +11,7 @@ typedef SelectTagWithInputValueGetter = String Function(V data); ///提交按钮事件回调 typedef BrnTagInputConfirmClickCallback = Future Function( BuildContext dialogContext, - List selectedTags, + List? selectedTags, String content); ///关闭 picker回调 @@ -31,19 +29,19 @@ class BrnSelectTagsWithInputPicker extends Dialog { final int maxLength; ///输入内容事件回调 - final BrnTagInputConfirmClickCallback confirm; + final BrnTagInputConfirmClickCallback? confirm; ///关闭 picker 回调 - final BrnTagInputCancelClickCallBack cancelCallBack; + final BrnTagInputCancelClickCallBack? cancelCallBack; ///光标颜色 - final Color cursorColor; + final Color? cursorColor; /// 默认文本 - final String defaultText; + final String? defaultText; /// 用于对 TextField 更精细的控制,若传入该字段,[defaultText] 参数将失效,可使用 TextEditingController.text 进行赋值。 - final TextEditingController textEditingController; + final TextEditingController? textEditingController; /// 强制显示文本框 final bool forceShowTextInput; @@ -68,8 +66,8 @@ class BrnSelectTagsWithInputPicker extends Dialog { this.multiSelect = false, this.defaultText, this.textEditingController, - @required this.tagPickerConfig, - @required this.onTagValueGetter}); + required this.tagPickerConfig, + required this.onTagValueGetter}); @override Widget build(BuildContext context) { @@ -91,21 +89,21 @@ class BrnSelectTagsWithInputPicker extends Dialog { } class BrnSelectTagsWithInputPickerWidget extends StatefulWidget { - final String title; - final BrnTagInputConfirmClickCallback confirm; - final BrnTagInputCancelClickCallBack cancelCallBack; - final int maxLength; - final String hintText; - final Color cursorColor; - final bool forceShowTextInput; - final bool multiSelect; - final String defaultText; - final TextEditingController textEditingController; - final BrnTagsInputPickerConfig tagPickerBean; - final SelectTagWithInputValueGetter onTagValueGetter; + final String? title; + final BrnTagInputConfirmClickCallback? confirm; + final BrnTagInputCancelClickCallBack? cancelCallBack; + final int? maxLength; + final String? hintText; + final Color? cursorColor; + final bool? forceShowTextInput; + final bool? multiSelect; + final String? defaultText; + final TextEditingController? textEditingController; + final BrnTagsInputPickerConfig? tagPickerBean; + final SelectTagWithInputValueGetter? onTagValueGetter; const BrnSelectTagsWithInputPickerWidget( - {Key key, + {Key? key, this.title, this.confirm, this.cancelCallBack, @@ -128,13 +126,13 @@ class BrnSelectTagsWithInputPickerWidget extends StatefulWidget { class _BrnSelectTagsWithInputPickerWidgetState extends State with AutomaticKeepAliveClientMixin { - TextEditingController _textEditingController; + TextEditingController? _textEditingController; /// 暂定只支持两列标签 int brnCrossAxisCount = 2; - List _selectedTags; - List _sourceTags; + late List _selectedTags; + late List _sourceTags; @override void initState() { @@ -142,11 +140,11 @@ class _BrnSelectTagsWithInputPickerWidgetState _dataSetup(); _textEditingController = widget.textEditingController ?? TextEditingController.fromValue(TextEditingValue( - text: widget.defaultText == null ? "" : widget.defaultText, + text: widget.defaultText == null ? "" : widget.defaultText!, selection: TextSelection.fromPosition(TextPosition( affinity: TextAffinity.downstream, offset: widget.defaultText != null - ? widget.defaultText.length + ? widget.defaultText!.length : 0)))); } @@ -171,7 +169,7 @@ class _BrnSelectTagsWithInputPickerWidgetState ), child: Column( mainAxisSize: MainAxisSize.min, - children: (widget.tagPickerBean?.tagItemSource?.isNotEmpty ?? false) + children: (widget.tagPickerBean?.tagItemSource.isNotEmpty ?? false) ? _buildBody(context) : _buildNoTagsBody(context), ), @@ -218,9 +216,9 @@ class _BrnSelectTagsWithInputPickerWidgetState } void _dataSetup() { - List tagItems = List(); - List tagSelectedItems = List(); - for (BrnTagInputItemBean item in widget.tagPickerBean.tagItemSource) { + List tagItems = []; + List tagSelectedItems = []; + for (BrnTagInputItemBean item in widget.tagPickerBean!.tagItemSource) { tagItems.add(item); //选中的按钮 if (item.isSelect == true && item.name != null) { @@ -231,7 +229,7 @@ class _BrnSelectTagsWithInputPickerWidgetState this._sourceTags = tagItems; // 重新排序,name 越长,越靠后 this._sourceTags.sort((left, right) { - return (left.name.length).compareTo(right.name.length); + return (left.name!.length).compareTo(right.name!.length); }); // 默认选中tags @@ -246,7 +244,7 @@ class _BrnSelectTagsWithInputPickerWidgetState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - widget.title, + widget.title!, style: TextStyle( color: BrnThemeConfigurator.instance .getConfig() @@ -259,7 +257,7 @@ class _BrnSelectTagsWithInputPickerWidgetState InkWell( onTap: () { if (widget.cancelCallBack != null) { - widget.cancelCallBack(context); + widget.cancelCallBack!(context); } Navigator.of(context).pop(); }, @@ -283,7 +281,7 @@ class _BrnSelectTagsWithInputPickerWidgetState double preferredWidthWithText(String content) { double originalTextWidth = paintWidthWithTextStyle( - content, TextStyle(fontSize: widget.tagPickerBean.tagTitleFontSize)); + content, TextStyle(fontSize: widget.tagPickerBean!.tagTitleFontSize)); double maxTextWidthInHalf = (MediaQuery.of(context).size.width - (brnCrossAxisCount - 1) * 12 - 20 * 2) / @@ -295,17 +293,17 @@ class _BrnSelectTagsWithInputPickerWidgetState } Widget _tagsArea(BuildContext context) { - Color selectedTagTitleColor = widget.tagPickerBean.selectedTagTitleColor ?? + Color selectedTagTitleColor = widget.tagPickerBean!.selectedTagTitleColor ?? BrnThemeConfigurator.instance.getConfig().commonConfig.brandPrimary; - Color tagTitleColor = widget.tagPickerBean.tagTitleColor ?? + Color tagTitleColor = widget.tagPickerBean!.tagTitleColor ?? BrnThemeConfigurator.instance .getConfig() .commonConfig .colorTextImportant; - Color tagBackgroudColor = - widget.tagPickerBean.tagBackgroudColor ?? Color(0xffF8F8F8); - Color selectedTagBackgroudColor = - widget.tagPickerBean.selectedTagBackgroudColor ?? + Color tagBackgroundColor = + widget.tagPickerBean!.tagBackgroundColor ?? Color(0xffF8F8F8); + Color selectedTagBackgroundColor = + widget.tagPickerBean!.selectedTagBackgroundColor ?? BrnThemeConfigurator.instance .getConfig() .commonConfig @@ -320,11 +318,11 @@ class _BrnSelectTagsWithInputPickerWidgetState children: this._sourceTags.map((choice) { bool selected = choice.isSelect; Color titleColor = selected ? selectedTagTitleColor : tagTitleColor; - String textToDisplay = widget.onTagValueGetter(choice); + String textToDisplay = widget.onTagValueGetter!(choice); return ChoiceChip( selected: selected, - backgroundColor: tagBackgroudColor, - selectedColor: selectedTagBackgroudColor, + backgroundColor: tagBackgroundColor, + selectedColor: selectedTagBackgroundColor, pressElevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4.0)), @@ -333,7 +331,7 @@ class _BrnSelectTagsWithInputPickerWidgetState labelStyle: TextStyle( color: titleColor, fontWeight: selected ? FontWeight.w600 : FontWeight.w400, - fontSize: widget.tagPickerBean.tagTitleFontSize), + fontSize: widget.tagPickerBean!.tagTitleFontSize), label: Container( width: preferredWidthWithText(textToDisplay), child: Text( @@ -353,7 +351,7 @@ class _BrnSelectTagsWithInputPickerWidgetState void _clickTag(bool selected, BrnTagInputItemBean tagName) { if (selected) { - if (!widget.multiSelect) { + if (!widget.multiSelect!) { this._selectedTags.forEach((tagItem) { tagItem.isSelect = false; }); @@ -423,8 +421,8 @@ class _BrnSelectTagsWithInputPickerWidgetState onTap: () { if (!isCommitBtnEnable()) return; if (widget.confirm != null) { - widget.confirm( - context, this._selectedTags, _textEditingController.text); + widget.confirm!( + context, this._selectedTags, _textEditingController!.text); } }, child: Container( @@ -454,20 +452,20 @@ class _BrnSelectTagsWithInputPickerWidgetState bool isCommitBtnEnable() { return this._selectedTags.length > 0 && - (isShowTextInput() ? _textEditingController.text.length > 0 : true); + (isShowTextInput() ? _textEditingController!.text.length > 0 : true); } bool isShowTextInput() { - if (widget.forceShowTextInput) { + if (widget.forceShowTextInput!) { return true; } for (int i = 0; i < this._selectedTags.length; i++) { BrnTagInputItemBean brnTagInputItemBean = this._selectedTags[i]; - if (true == brnTagInputItemBean.needExplane) { + if (true == brnTagInputItemBean.needExpend) { return true; } } - _textEditingController.clear(); + _textEditingController!.clear(); return false; } @@ -478,25 +476,25 @@ class _BrnSelectTagsWithInputPickerWidgetState /// 数据源 class BrnTagInputItemBean { /// 标签展示的文案 - String name; + String? name; ///选中状态 bool isSelect; ///选中tag的index - int index; + int? index; /// 选中后是否展示文本输入框 - bool needExplane; + bool needExpend; /// 附带的更多数据,方便在点击回调中取用。 - Map ext; + Map? ext; BrnTagInputItemBean({ this.name, this.isSelect = false, this.index, - this.needExplane = false, + this.needExpend = false, this.ext, }); } @@ -506,18 +504,18 @@ class BrnTagsInputPickerConfig { {this.tagTitleFontSize = 16.0, this.tagTitleColor, this.selectedTagTitleColor, - this.tagBackgroudColor, - this.selectedTagBackgroudColor, + this.tagBackgroundColor, + this.selectedTagBackgroundColor, this.tagItemSource = const []}) { this.tagTitleColor = BrnThemeConfigurator.instance.getConfig().commonConfig.colorTextBase; } double tagTitleFontSize; - Color tagTitleColor; - Color selectedTagTitleColor; - Color tagBackgroudColor; - Color selectedTagBackgroudColor; + Color? tagTitleColor; + Color? selectedTagTitleColor; + Color? tagBackgroundColor; + Color? selectedTagBackgroundColor; List tagItemSource; } diff --git a/lib/src/components/picker/brn_tags_common_picker.dart b/lib/src/components/picker/brn_tags_common_picker.dart index aac2b73c..d6cb4a5e 100644 --- a/lib/src/components/picker/brn_tags_common_picker.dart +++ b/lib/src/components/picker/brn_tags_common_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_title.dart'; import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; @@ -13,21 +13,22 @@ enum BrnCommonPickBackType { } typedef TagsPickerContentBuilder = Widget Function( - BuildContext context, VoidCallback onUpdate); + BuildContext context, VoidCallback? onUpdate); /// 创建时传入Builder 或者 子类实现 createBuilder 函数 +// ignore: must_be_immutable class CommonTagsPicker extends StatefulWidget { final BuildContext context; - final ValueChanged onConfirm; - final VoidCallback onCancel; - final TagsPickerContentBuilder contentBuilder; + final ValueChanged? onConfirm; + final VoidCallback? onCancel; + final TagsPickerContentBuilder? contentBuilder; final BrnPickerTitleConfig pickerTitleConfig; - BrnPickerConfig themeData; + BrnPickerConfig? themeData; CommonTagsPicker( - {Key key, - @required this.context, + {Key? key, + required this.context, this.onConfirm, this.onCancel, this.contentBuilder, @@ -36,7 +37,7 @@ class CommonTagsPicker extends StatefulWidget { : super(key: key) { this.themeData ??= BrnPickerConfig(); this.themeData = this - .themeData + .themeData! .merge(BrnThemeConfigurator.instance.getConfig().pickerConfig); } @@ -49,11 +50,11 @@ class CommonTagsPicker extends StatefulWidget { }).then((type) { if (type == BrnCommonPickBackType.confirm) { if (onConfirm != null) { - onConfirm(getConfirmData()); + onConfirm!(getConfirmData()); } } else { if (onCancel != null) { - onCancel(); + onCancel!(); } } }); @@ -61,7 +62,7 @@ class CommonTagsPicker extends StatefulWidget { /// 子类重写实现builder @protected - Widget createBuilder(BuildContext context, VoidCallback onUpdate) { + Widget? createBuilder(BuildContext context, VoidCallback? onUpdate) { return null; } @@ -80,7 +81,7 @@ class CommonTagsPicker extends StatefulWidget { } class _CommonPickerState extends State { - VoidCallback _onUpdate; + VoidCallback? _onUpdate; @override void initState() { @@ -135,9 +136,9 @@ class _CommonPickerState extends State { /// 创建内容视图 Widget _createContentWidget() { - Widget contentWidget; + Widget? contentWidget; if (widget.contentBuilder != null) { - contentWidget = widget.contentBuilder(context, _onUpdate); + contentWidget = widget.contentBuilder!(context, _onUpdate); } else { contentWidget = widget.createBuilder(context, _onUpdate); } @@ -150,7 +151,7 @@ class _CommonPickerState extends State { ); } return Container( - padding: EdgeInsets.only(top: widget.themeData.titleHeight), // 流出头部视图 + padding: EdgeInsets.only(top: widget.themeData!.titleHeight), // 流出头部视图 child: ListView( shrinkWrap: true, // 列表高度自适应 controller: ScrollController(keepScrollOffset: false), // 若视图小于弹窗则不滑动 diff --git a/lib/src/components/picker/brn_tags_picker_config.dart b/lib/src/components/picker/brn_tags_picker_config.dart index 7fc4477b..1303df3c 100644 --- a/lib/src/components/picker/brn_tags_picker_config.dart +++ b/lib/src/components/picker/brn_tags_picker_config.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/material.dart'; @@ -26,19 +26,19 @@ class BrnTagsPickerHeaderConfig { final double headerHeight; final String title; - Color titleColor; + Color? titleColor; final double titleFontSize; final String confirmTitle; - final Color confirmColor; + final Color? confirmColor; final double confirmFontSize; final String cancelTitle; - Color cancelColor; + Color? cancelColor; final double cancelFontSize; //分割线颜色 - final Color dividingLineColor; + final Color? dividingLineColor; } class BrnTagsPickerConfig { @@ -58,19 +58,19 @@ class BrnTagsPickerConfig { double tagTitleFontSize; ///tag 文字颜色 - Color tagTitleColor; + Color? tagTitleColor; ///选中的tag颜色 - Color selectedTagTitleColor; + Color? selectedTagTitleColor; ///tag 背景颜色 - Color tagBackgroudColor; + Color? tagBackgroudColor; ///选中的颜色 - Color selectedTagBackgroudColor; + Color? selectedTagBackgroudColor; ///内部item的边距 - EdgeInsets chipPadding; + EdgeInsets? chipPadding; ///数据源 List tagItemSource; @@ -84,13 +84,13 @@ class BrnTagItemBean { String code; ///code唯一标识 - int index; + int? index; ///是被选中 bool isSelect; ///自己添加的扩展 - Map ext; + Map? ext; BrnTagItemBean( {this.name = '', diff --git a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart index 81b95621..4c87d871 100644 --- a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart +++ b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/constants/brn_constants.dart'; import 'package:bruno/src/utils/brn_tools.dart'; @@ -17,20 +15,20 @@ enum PickerWindowType { } class BrnPickerEntity { - String uniqueId; //唯一的id - String + String? uniqueId; //唯一的id + String? type; //类型 目前支持的类型有不限(unlimit)、单选(radio)、复选(checkbox), 最终被解析成 PickerFilterType 类型 - String key; //回传给服务器 - String value; //回传给服务器 - String name; //显示的文案 - String defaultValue; + String? key; //回传给服务器 + String? value; //回传给服务器 + String? name; //显示的文案 + String? defaultValue; List children; //下级筛选项 - Map extMap; //扩展字段,目前只有min和max + Map? extMap; //扩展字段,目前只有min和max bool isSelected; //是否选中 int maxSelectedCount; - BrnPickerEntity parent; //上级筛选项 - PickerFilterType filterType; //筛选类型 + BrnPickerEntity? parent; //上级筛选项 + PickerFilterType? filterType; //筛选类型 BrnPickerEntity( {this.uniqueId, @@ -38,20 +36,16 @@ class BrnPickerEntity { this.value, this.defaultValue, this.name, - this.children, + this.children = const [], this.isSelected = false, this.extMap, this.type, - this.maxSelectedCount}) { + this.maxSelectedCount = BrnSelectionConstant.maxSelectCount}) { this.filterType = this.parserFilterTypeWithType(this.type); - - /// 默认支持最大选中个数为 65535 - this.maxSelectedCount = - maxSelectedCount ?? BrnSelectionConstant.maxSelectCount; } - static BrnPickerEntity fromMap(Map map) { - if (map == null) return null; + static BrnPickerEntity fromMap(Map? map) { + if (map == null) return BrnPickerEntity(); BrnPickerEntity entity = BrnPickerEntity(); entity.uniqueId = map['id'] ?? ""; entity.name = map['name'] ?? ""; @@ -63,14 +57,15 @@ class BrnPickerEntity { entity.value = map['value'] ?? ""; if (map['maxSelectedCount'] != null && int.tryParse(map['maxSelectedCount']) != null) { - entity.maxSelectedCount = int.tryParse(map['maxSelectedCount']); + entity.maxSelectedCount = int.tryParse(map['maxSelectedCount']) ?? + BrnSelectionConstant.maxSelectCount; } else { entity.maxSelectedCount = BrnSelectionConstant.maxSelectCount; } entity.extMap = map['ext'] ?? {}; // entity.children = map['children'] ?? []; - entity.children = List() - ..addAll((map['children'] as List ?? []) + entity.children = [] + ..addAll((map['children'] as List? ?? []) .map((o) => BrnPickerEntity.fromMap(o))); return entity; } @@ -81,11 +76,11 @@ class BrnPickerEntity { } void configDefaultValue() { - if (this.children != null && this.children.length > 0) { + if (this.children.length > 0) { for (BrnPickerEntity entity in this.children) { if (!BrunoTools.isEmpty(defaultValue)) { - List values = defaultValue.split(','); - entity.isSelected = values != null && values.contains(entity.value); + List values = defaultValue!.split(','); + entity.isSelected = values.contains(entity.value); } entity.configDefaultValue(); } @@ -95,7 +90,7 @@ class BrnPickerEntity { } void configRelationship() { - if (this.children != null && this.children.length > 0) { + if (this.children.length > 0) { for (BrnPickerEntity entity in this.children) { entity.parent = this; entity.configRelationship(); @@ -112,7 +107,7 @@ class BrnPickerEntity { return PickerWindowType.List; } - PickerFilterType parserFilterTypeWithType(String type) { + PickerFilterType parserFilterTypeWithType(String? type) { if (type == "unlimit") { return PickerFilterType.UnLimit; } else if (type == "radio") { @@ -124,7 +119,7 @@ class BrnPickerEntity { } void clearChildSelection() { - if (this.children != null && this.children.length > 0) { + if (this.children.length > 0) { for (BrnPickerEntity entity in this.children) { entity.isSelected = false; entity.clearChildSelection(); @@ -133,18 +128,14 @@ class BrnPickerEntity { } List selectedLastColumnList() { - List list = List(); - if (this.children != null && this.children.length > 0) { - List firstList = List(); + List list = []; + if (this.children.length > 0) { + List firstList = []; for (BrnPickerEntity firstEntity in this.children) { - if (firstEntity != null && - firstEntity.children != null && - firstEntity.children.length > 0) { - List secondList = List(); + if (firstEntity.children.length > 0) { + List secondList = []; for (BrnPickerEntity secondEntity in firstEntity.children) { - if (secondEntity != null && - secondEntity.children != null && - secondEntity.children.length > 0) { + if (secondEntity.children.length > 0) { List thirds = this.currentSelectListForEntity(secondEntity); if (thirds.length > 0) { @@ -152,12 +143,12 @@ class BrnPickerEntity { } else if (secondEntity.isSelected) { secondList.add(secondEntity); } - } else if (secondEntity != null && secondEntity.isSelected) { + } else if (secondEntity.isSelected) { secondList.add(secondEntity); } } list.addAll(secondList); - } else if (firstEntity != null && firstEntity.isSelected) { + } else if (firstEntity.isSelected) { firstList.add(firstEntity); } } @@ -168,27 +159,25 @@ class BrnPickerEntity { List selectedListWithoutUnlimit() { List selected = selectedList(); - return selected?.where((_) => !_.isUnLimit())?.toList() ?? List(); + return selected.where((_) => !_.isUnLimit()).toList() ; } List selectedList() { - List results = List(); + List results = []; List firstColumn = this.currentSelectListForEntity(this); results.addAll(firstColumn); - if (firstColumn != null && firstColumn.length > 0) { + if (firstColumn.length > 0) { for (BrnPickerEntity firstEntity in firstColumn) { - if (firstEntity != null) { List secondColumn = this.currentSelectListForEntity(firstEntity); results.addAll(secondColumn); - if (secondColumn != null && secondColumn.length > 0) { + if (secondColumn.length > 0) { for (BrnPickerEntity secondEntity in secondColumn) { List thirdColumn = this.currentSelectListForEntity(secondEntity); results.addAll(thirdColumn); } } - } } } return results; @@ -196,8 +185,8 @@ class BrnPickerEntity { /// 返回状态为选中的子节点 List currentSelectListForEntity(BrnPickerEntity entity) { - List list = List(); - if (entity.children != null && entity.children.length > 0) { + List list = []; + if (entity.children.length > 0) { for (BrnPickerEntity entity in entity.children) { if (entity.isSelected) { list.add(entity); @@ -223,13 +212,11 @@ class BrnPickerEntity { /// 判断当前的筛选 Item 是否为当前层次中第一个被选中的 Item。 /// 用于展开筛选弹窗时显示选中效果。 int getIndexInCurrentLevel() { - if (parent == null || - parent.children == null || - parent.children.length == 0) return -1; + if (parent == null || parent!.children.length == 0) return -1; - for (BrnPickerEntity entity in parent.children) { + for (BrnPickerEntity entity in parent!.children) { if (entity == this) { - return parent.children.indexOf(entity); + return parent!.children.indexOf(entity); } } return -1; @@ -237,11 +224,10 @@ class BrnPickerEntity { bool isInLastLevel() { if (parent == null || - parent.children == null || - parent.children.length == 0) return true; + parent!.children.length == 0) return true; - for (BrnPickerEntity entity in parent.children) { - if (entity.children != null && entity.children.length > 0) { + for (BrnPickerEntity entity in parent!.children) { + if (entity.children.length > 0) { return false; } } @@ -255,13 +241,13 @@ class BrnPickerEntity { } void clearSelectedEntity() { - List tmp = List(); + List tmp = []; BrnPickerEntity node = this; tmp.add(node); while (tmp.isNotEmpty) { node = tmp.removeLast(); node.isSelected = false; - node.children?.forEach((data) { + node.children.forEach((data) { tmp.add(data); }); } diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_converter.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_converter.dart index 06ffd420..c4c60f41 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_converter.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_converter.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart'; import 'package:bruno/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart'; @@ -15,7 +15,7 @@ class BrnMultiRangeSelConverter { } Map> getSelectionParams( - List selectedResults, + List? selectedResults, {bool includeUnlimitSelection = false}) { Map> params = Map(); if (selectedResults == null) return params; @@ -28,19 +28,19 @@ class BrnMultiRangeSelConverter { } else if (levelCount == 2) { params.addAll(getCurrentSelectionEntityParams(menuItemEntity, includeUnlimitSelection: includeUnlimitSelection)); - menuItemEntity.children?.forEach((firstLevelItem) => mergeParams( + menuItemEntity.children.forEach((firstLevelItem) => mergeParams( params, getCurrentSelectionEntityParams(firstLevelItem, includeUnlimitSelection: includeUnlimitSelection))); } else if (levelCount == 3) { params.addAll(getCurrentSelectionEntityParams(menuItemEntity, includeUnlimitSelection: includeUnlimitSelection)); - menuItemEntity.children?.forEach((firstLevelItem) { + menuItemEntity.children.forEach((firstLevelItem) { mergeParams( params, getCurrentSelectionEntityParams(firstLevelItem, includeUnlimitSelection: includeUnlimitSelection)); - firstLevelItem.children?.forEach((secondLevelItem) { + firstLevelItem.children.forEach((secondLevelItem) { mergeParams( params, getCurrentSelectionEntityParams(secondLevelItem, @@ -52,14 +52,14 @@ class BrnMultiRangeSelConverter { return params; } - Map> mergeParams( - Map> params, - Map> selectedParams) { - selectedParams?.forEach((String key, List value) { - if (params != null && params.containsKey(key)) { + Map> mergeParams( + Map> params, + Map> selectedParams) { + selectedParams.forEach((String? key, List value) { + if ( params.containsKey(key)) { params[key]?.addAll(value); } else { - params?.addAll(selectedParams); + params.addAll(selectedParams); } }); return params; @@ -69,20 +69,19 @@ class BrnMultiRangeSelConverter { BrnPickerEntity selectionEntity, {bool includeUnlimitSelection = false}) { Map> params = Map(); - String parentKey = selectionEntity.key; + String parentKey = selectionEntity.key ?? ''; var selectedEntity = selectionEntity.children - ?.where((BrnPickerEntity f) => f.isSelected) - ?.where((BrnPickerEntity f) { + .where((BrnPickerEntity f) => f.isSelected) + .where((BrnPickerEntity f) { if (includeUnlimitSelection) { return true; } else { return !BrunoTools.isEmpty(f.value); } }) - ?.map((BrnPickerEntity f) => f) - ?.toList(); - List selectedParams = - selectedEntity == null ? [] : selectedEntity; + .map((BrnPickerEntity f) => f) + .toList(); + List selectedParams = selectedEntity; if (!BrunoTools.isEmpty(selectedParams) && !BrunoTools.isEmpty(parentKey)) { params[parentKey] = selectedParams; } diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart index be9667eb..3679739f 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart'; import 'package:bruno/src/components/picker/multi_range_picker/brn_multi_column_picker.dart'; @@ -12,25 +12,25 @@ import 'package:flutter/material.dart'; /// [index] 点击位置处于当前列的位置 /// [entity] 被点击位置的数据 typedef bool BrnOnSelectEntityInterceptor( - int listIndex, int index, BrnPickerEntity entity); + int? listIndex, int index, BrnPickerEntity entity); // ignore: must_be_immutable class BrnMultiColumnListWidget extends StatefulWidget { - List _selectedItems; - int focusedIndex = -1; - List items; + List? _selectedItems; + int? focusedIndex = -1; + List? items; Color normalColor; Color selectedColor; - Color backgroundColor; - Color selectedBackgroundColor; - int flex; - BrnOnEntityTap singleListItemPick; - int currentListIndex; + Color? backgroundColor; + Color? selectedBackgroundColor; + int? flex; + BrnOnEntityTap? singleListItemPick; + int? currentListIndex; double maxHeight; - BrnOnSelectEntityInterceptor onSelectEntityInterceptor; + BrnOnSelectEntityInterceptor? onSelectEntityInterceptor; BrnMultiColumnListWidget({ - @required this.items, + required this.items, this.normalColor = const Color(0Xff4a4e59), this.selectedColor = const Color(0xff41bc6a), this.maxHeight = 0, @@ -42,18 +42,18 @@ class BrnMultiColumnListWidget extends StatefulWidget { this.onSelectEntityInterceptor, }) { if (items == null) { - items = List(); + items = []; } - items.forEach((element) { + items!.forEach((element) { element.configRelationship(); }); currentListIndex = BrnMultiColumnPickerUtil.getCurrentColumnIndex( - items.length > 0 ? items[0] : null); + items!.length > 0 ? items![0] : null); - _selectedItems = items?.where((f) => f.isSelected)?.toList(); + _selectedItems = items?.where((f) => f.isSelected).toList(); if (_selectedItems == null) { - _selectedItems = List(); + _selectedItems = []; } } @@ -61,7 +61,7 @@ class BrnMultiColumnListWidget extends StatefulWidget { _BrnMultiColumnListWidgetState createState() => _BrnMultiColumnListWidgetState(); - List getSelectedItems() { + List? getSelectedItems() { return _selectedItems; } } @@ -70,9 +70,9 @@ class _BrnMultiColumnListWidgetState extends State { @override Widget build(BuildContext context) { return Expanded( - flex: widget.flex, + flex: widget.flex!, child: Container( - constraints: (widget.maxHeight == null || widget.maxHeight == 0) + constraints: (widget.maxHeight == 0) ? BoxConstraints.expand() : BoxConstraints(maxHeight: widget.maxHeight), color: widget.backgroundColor, @@ -80,10 +80,10 @@ class _BrnMultiColumnListWidgetState extends State { shrinkWrap: true, padding: EdgeInsets.only(top: 0), scrollDirection: Axis.vertical, - itemCount: widget.items.length, + itemCount: widget.items!.length, separatorBuilder: (BuildContext context, int index) => Container(), itemBuilder: (BuildContext context, int index) { - BrnPickerEntity item = widget.items[index]; + BrnPickerEntity item = widget.items![index]; /// 点击筛选,展开弹窗时,默认展示上次选中的筛选项。 bool isCurrentFocused = _isItemFocused(index, item); @@ -99,14 +99,16 @@ class _BrnMultiColumnListWidgetState extends State { isFirstLevel: (1 == widget.currentListIndex) ? true : false, itemSelectFunction: (BrnPickerEntity entity) { if (widget.onSelectEntityInterceptor != null && - widget.onSelectEntityInterceptor( + widget.onSelectEntityInterceptor!( widget.currentListIndex, index, entity) == false) { return; } _processFilterData(entity); - widget.singleListItemPick( - widget.currentListIndex, index, entity); + if(widget.singleListItemPick!=null){ + widget.singleListItemPick!( + widget.currentListIndex ?? 0, index, entity); + } }, ); }, @@ -124,7 +126,7 @@ class _BrnMultiColumnListWidgetState extends State { } /// Item 点击之后的数据处理 - void _processFilterData(BrnPickerEntity selectedEntity) { + void _processFilterData(BrnPickerEntity? selectedEntity) { if (null == selectedEntity) { return; } @@ -139,8 +141,8 @@ class _BrnMultiColumnListWidgetState extends State { int totalLevel = BrnMultiColumnPickerUtil.getTotalColumnCount(selectedEntity); - if (selectedEntity.isUnLimit()) { - selectedEntity.parent.clearChildSelection(); + if (selectedEntity.isUnLimit() && selectedEntity.parent !=null) { + selectedEntity.parent!.clearChildSelection(); } /// 设置选中数据。 @@ -157,21 +159,23 @@ class _BrnMultiColumnListWidgetState extends State { /// Warning !!! /// (两列、三列时)第一列节点是否被选中取决于它的子节点是否被选中, /// 只有当它子节点被选中时才会认为第一列的节点相应被选中。 - if (widget.items != null && widget.items.length > 0) { - widget.items[0].parent?.isSelected = widget.items[0].parent.children + if (widget.items != null && + widget.items!.length > 0 && + widget.items![0].parent != null ) { + widget.items![0].parent?.isSelected = widget.items![0].parent!.children .where((BrnPickerEntity f) => f.isSelected) .length > 0; } - for (BrnPickerEntity item in widget.items) { + for (BrnPickerEntity item in widget.items!) { if (item.isSelected) { - if (!widget._selectedItems.contains(item)) { - widget._selectedItems.add(item); + if (!widget._selectedItems!.contains(item)) { + widget._selectedItems!.add(item); } } else { - if (widget._selectedItems.contains(item)) { - widget._selectedItems.remove(item); + if (widget._selectedItems!.contains(item)) { + widget._selectedItems!.remove(item); } } } @@ -180,12 +184,12 @@ class _BrnMultiColumnListWidgetState extends State { void _configFirstList(BrnPickerEntity selectedEntity) { if (PickerFilterType.Radio == selectedEntity.filterType) { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else { ///清除【不限】类型。 @@ -193,7 +197,7 @@ class _BrnMultiColumnListWidgetState extends State { if (selectedEntity.parent == null) { brotherItems = widget.items; } else { - brotherItems = selectedEntity.parent.children; + brotherItems = selectedEntity.parent!.children; } for (BrnPickerEntity entity in brotherItems) { if (entity.isUnLimit()) { @@ -205,20 +209,20 @@ class _BrnMultiColumnListWidgetState extends State { } } - void _configSecondList(BrnPickerEntity selectedEntity, int currentListIndex) { + void _configSecondList(BrnPickerEntity selectedEntity, int? currentListIndex) { if (currentListIndex == 1) { if (PickerFilterType.Checkbox != selectedEntity.filterType) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); } } else { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 if (PickerFilterType.Radio == selectedEntity.filterType) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else { ///清除【不限】类型。 @@ -226,7 +230,7 @@ class _BrnMultiColumnListWidgetState extends State { if (selectedEntity.parent == null) { brotherItems = widget.items; } else { - brotherItems = selectedEntity.parent.children; + brotherItems = selectedEntity.parent!.children; } for (BrnPickerEntity entity in brotherItems) { if (entity.isUnLimit()) { @@ -239,20 +243,20 @@ class _BrnMultiColumnListWidgetState extends State { } } - void _configThirdList(BrnPickerEntity selectedEntity, int currentListIndex) { + void _configThirdList(BrnPickerEntity selectedEntity, int? currentListIndex) { if (currentListIndex == 1) { if (PickerFilterType.Checkbox != selectedEntity.filterType) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); } } else { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 if (PickerFilterType.Radio == selectedEntity.filterType) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { - selectedEntity.parent.clearChildSelection(); + selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; } else { ///清除【不限】类型。 @@ -260,7 +264,7 @@ class _BrnMultiColumnListWidgetState extends State { if (selectedEntity.parent == null) { brotherItems = widget.items; } else { - brotherItems = selectedEntity.parent.children; + brotherItems = selectedEntity.parent!.children; } for (BrnPickerEntity entity in brotherItems) { if (entity.isUnLimit()) { diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart index 59c9ac33..80667415 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/base/brn_picker_title.dart'; import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; @@ -25,7 +25,7 @@ typedef void BrnOnEntityTap( /// [secondIndex] 第二列被选中数据的位置 /// [thirdIndex] 第三列被选中数据的位置 typedef void BrnOnPickerConfirm(Map> results, - int firstIndex, int secondIndex, int thirdIndex); + int? firstIndex, int? secondIndex, int? thirdIndex); /// 从屏幕下方弹起的多级筛选选择器 /// 可设置筛项的层级、多选、单选等筛选相关功能 @@ -35,7 +35,7 @@ class BrnMultiColumnPicker extends StatefulWidget { final BrnPickerEntity entity; /// 初始化时的选中选项 - final List defaultFocusedIndexes; + final List? defaultFocusedIndexes; /// Picker展示最大高度,默认 280 final double maxHeight; @@ -48,23 +48,23 @@ class BrnMultiColumnPicker extends StatefulWidget { final bool isIncludeUnLimit; /// 选择数据后回调函数 - final BrnOnPickerConfirm onConfirm; + final BrnOnPickerConfirm? onConfirm; /// 选择项目后回调函数 - final BrnOnEntityTap onEntityTap; + final BrnOnEntityTap? onEntityTap; /// 当前选项是否可以被选中:返回 true 可以被选中 false 不可以被选中 - final BrnOnSelectEntityInterceptor canSelectEntryInterceptor; + final BrnOnSelectEntityInterceptor? canSelectEntryInterceptor; /// 主题定制,只有 Picker Title 部分样式生效 - BrnPickerConfig themeData; + BrnPickerConfig? themeData; /// Picker Title 数据配置 final BrnPickerTitleConfig pickerTitleConfig; BrnMultiColumnPicker( - {Key key, - @required this.entity, + {Key? key, + required this.entity, this.maxHeight = 280.0, this.showSelectedCount = false, this.isIncludeUnLimit = false, @@ -77,7 +77,7 @@ class BrnMultiColumnPicker extends StatefulWidget { : super(key: key) { this.themeData ??= BrnPickerConfig(); this.themeData = this - .themeData + .themeData! .merge(BrnThemeConfigurator.instance.getConfig().pickerConfig); } @@ -88,23 +88,23 @@ class BrnMultiColumnPicker extends StatefulWidget { class _BrnSelectionGroupViewState extends State { static const BrnMultiRangeSelConverter defaultConverter = const BrnMultiRangeSelConverter(); - List _firstList = List(); - List _secondList = List(); - List _thirdList = List(); - List _originalSelectedItemsList = List(); - int _firstIndex; - int _secondIndex; - int _thirdIndex; + List _firstList = []; + List? _secondList = []; + List? _thirdList = []; + List _originalSelectedItemsList = []; + int? _firstIndex; + int? _secondIndex; + int? _thirdIndex; int get _columnCount { return BrnMultiColumnPickerUtil.getTotalColumnCount(widget.entity); } /// 未选中状态颜色,默认 Color(0Xff4a4e59) - Color _normalColor; + late Color _normalColor; /// 选中状态颜色,默认 Color(0xff41bc6a) - Color _selectedColor; + late Color _selectedColor; @override void initState() { @@ -123,8 +123,8 @@ class _BrnSelectionGroupViewState extends State { height: widget.maxHeight + 48, child: BrnPickerClipRRect( borderRadius: BorderRadius.only( - topLeft: Radius.circular(widget.themeData.cornerRadius), - topRight: Radius.circular(widget.themeData.cornerRadius), + topLeft: Radius.circular(widget.themeData!.cornerRadius), + topRight: Radius.circular(widget.themeData!.cornerRadius), ), child: Column( children: _configWidgets(), @@ -135,7 +135,7 @@ class _BrnSelectionGroupViewState extends State { //pragma mark -- config widgets List _configWidgets() { - List widgetList = List(); + List widgetList = []; widgetList.add( Offstage( offstage: !widget.pickerTitleConfig.showTitle, @@ -159,7 +159,7 @@ class _BrnSelectionGroupViewState extends State { } Widget _listWidget() { - List widgets = List(); + List widgets = []; if (!BrunoTools.isEmpty(_firstList) && BrunoTools.isEmpty(_secondList) && @@ -184,7 +184,7 @@ class _BrnSelectionGroupViewState extends State { _confirmButtonClickEvent(); } if (widget.onEntityTap != null) { - widget.onEntityTap(0, index, entity); + widget.onEntityTap!(0, index, entity); } })); } else if (!BrunoTools.isEmpty(_firstList) && @@ -204,7 +204,7 @@ class _BrnSelectionGroupViewState extends State { (int listIndex, int index, BrnPickerEntity entity) { _setFirstIndex(index); if (widget.onEntityTap != null) { - widget.onEntityTap(0, index, entity); + widget.onEntityTap!(0, index, entity); } })); @@ -221,7 +221,7 @@ class _BrnSelectionGroupViewState extends State { (int listIndex, int index, BrnPickerEntity entity) { _setSecondIndex(index); if (widget.onEntityTap != null) { - widget.onEntityTap(1, index, entity); + widget.onEntityTap!(1, index, entity); } })); } else if (!BrunoTools.isEmpty(_firstList) && @@ -241,7 +241,7 @@ class _BrnSelectionGroupViewState extends State { (int listIndex, int index, BrnPickerEntity entity) { _setFirstIndex(index); if (widget.onEntityTap != null) { - widget.onEntityTap(0, index, entity); + widget.onEntityTap!(0, index, entity); } })); @@ -258,7 +258,7 @@ class _BrnSelectionGroupViewState extends State { (int listIndex, int index, BrnPickerEntity entity) { _setSecondIndex(index); if (widget.onEntityTap != null) { - widget.onEntityTap(1, index, entity); + widget.onEntityTap!(1, index, entity); } })); widgets.add(BrnMultiColumnListWidget( @@ -279,7 +279,7 @@ class _BrnSelectionGroupViewState extends State { } setState(() {}); if (widget.onEntityTap != null) { - widget.onEntityTap(2, index, entity); + widget.onEntityTap!(2, index, entity); } })); } @@ -304,7 +304,7 @@ class _BrnSelectionGroupViewState extends State { Map> result = defaultConverter .convertPickedData([widget.entity], includeUnlimitSelection: widget.isIncludeUnLimit); - widget.onConfirm(result, _firstIndex, _secondIndex, _thirdIndex); + widget.onConfirm!(result, _firstIndex, _secondIndex, _thirdIndex); } } @@ -343,10 +343,10 @@ class _BrnSelectionGroupViewState extends State { // 刷新3个ListView的数据源 void _refreshDataSource() { _firstList = widget.entity.children; - if (_firstIndex >= 0 && _firstList.length > _firstIndex) { - _secondList = _firstList[_firstIndex].children; - if (_secondIndex >= 0 && _secondList.length > _secondIndex) { - _thirdList = _secondList[_secondIndex].children; + if (_firstIndex! >= 0 && _firstList.length > _firstIndex!) { + _secondList = _firstList[_firstIndex!].children; + if (_secondIndex! >= 0 && _secondList!.length > _secondIndex!) { + _thirdList = _secondList![_secondIndex!].children; } else { _thirdList = null; } @@ -358,51 +358,41 @@ class _BrnSelectionGroupViewState extends State { void _configDefaultSelectedData() { _firstList = widget.entity.children; - //是否已选择的item里面有第一列的 - if (_firstList == null) { - _secondIndex = -1; - _secondList = null; - - _thirdIndex = -1; - _thirdList = null; - - return; - } _firstIndex = _getInitialSelectIndex(_firstList); if (_firstIndex == -1) { if (widget.defaultFocusedIndexes != null) { for (int index = 0; - index < widget.defaultFocusedIndexes.length; + index < widget.defaultFocusedIndexes!.length; index++) { - if (index == 0 && widget.defaultFocusedIndexes[index] >= 0) { - _firstIndex = widget.defaultFocusedIndexes[index]; + if (index == 0 && widget.defaultFocusedIndexes![index] >= 0) { + _firstIndex = widget.defaultFocusedIndexes![index]; } - if (index == 1 && _firstIndex >= 0) { - _secondIndex = widget.defaultFocusedIndexes[index]; + if (index == 1 && _firstIndex! >= 0) { + _secondIndex = widget.defaultFocusedIndexes![index]; } - if (index == 2 && _secondIndex >= 0) { - _thirdIndex = widget.defaultFocusedIndexes[index]; + if (index == 2 && _secondIndex! >= 0) { + _thirdIndex = widget.defaultFocusedIndexes![index]; } } } - if (_firstIndex >= 0 && _firstIndex < _firstList.length) { - _secondList = _firstList[_firstIndex].children; + if (_firstIndex! >= 0 && _firstIndex! < _firstList.length) { + _secondList = _firstList[_firstIndex!].children; } if (_secondList == null) { _thirdIndex = -1; _thirdList = null; return; } - if (_secondIndex >= 0 && _secondIndex < _secondList.length) { - _thirdList = _secondList[_secondIndex].children; + if (_secondIndex! >= 0 && _secondIndex! < _secondList!.length) { + _thirdList = _secondList![_secondIndex!].children; } } else { - if (_firstIndex >= 0 && _firstIndex < _firstList.length) { - _secondList = _firstList[_firstIndex].children; + if (_firstIndex! >= 0 && _firstIndex! < _firstList.length) { + _secondList = _firstList[_firstIndex!].children; if (_secondList != null) { _secondIndex = _getInitialSelectIndex(_secondList); } @@ -413,8 +403,8 @@ class _BrnSelectionGroupViewState extends State { _thirdList = null; return; } - if (_secondIndex >= 0 && _secondIndex < _secondList.length) { - _thirdList = _secondList[_secondIndex].children; + if (_secondIndex! >= 0 && _secondIndex! < _secondList!.length) { + _thirdList = _secondList![_secondIndex!].children; if (_thirdList != null) { _thirdIndex = _getInitialSelectIndex(_thirdList); } @@ -425,10 +415,8 @@ class _BrnSelectionGroupViewState extends State { //设置数据为未选中状态 void _resetSelectionDatas(BrnPickerEntity entity) { entity.isSelected = false; - if (entity.children != null) { - for (BrnPickerEntity subEntity in entity.children) { - _resetSelectionDatas(subEntity); - } + for (BrnPickerEntity subEntity in entity.children) { + _resetSelectionDatas(subEntity); } } @@ -437,15 +425,13 @@ class _BrnSelectionGroupViewState extends State { void _setFirstIndex(int firstIndex) { _firstIndex = firstIndex; _secondIndex = -1; - if (widget.entity.children.length > _firstIndex) { + if (widget.entity.children.length > _firstIndex!) { List seconds = - widget.entity.children[_firstIndex].children; - if (seconds != null) { - _secondIndex = _getInitialSelectIndex(seconds); + widget.entity.children[_firstIndex!].children; + _secondIndex = _getInitialSelectIndex(seconds); - if (_secondIndex >= 0) { - _setSecondIndex(_secondIndex); - } + if (_secondIndex! >= 0) { + _setSecondIndex(_secondIndex); } } setState(() { @@ -453,23 +439,21 @@ class _BrnSelectionGroupViewState extends State { }); } - void _setSecondIndex(int secondIndex) { + void _setSecondIndex(int? secondIndex) { _secondIndex = secondIndex; _thirdIndex = -1; List seconds = - widget.entity.children[_firstIndex].children; - if (seconds.length > _secondIndex) { - List thirds = seconds[_secondIndex].children; - if (thirds != null) { - _thirdIndex = _getInitialSelectIndex(thirds); - } + widget.entity.children[_firstIndex!].children; + if (seconds.length > _secondIndex!) { + List thirds = seconds[_secondIndex!].children; + _thirdIndex = _getInitialSelectIndex(thirds); } setState(() { _refreshDataSource(); }); } - int _getInitialSelectIndex(List levelList) { + int _getInitialSelectIndex(List? levelList) { int index = -1; if (levelList == null || levelList.length == 0) { return index; @@ -488,7 +472,7 @@ class _BrnSelectionGroupViewState extends State { // 例如1级为多选,不应该默认选中2级的不限 // 否则每选中任意一个1级选项,就默认有了一个2级的不限 if (entity.isUnLimit() && - entity.parent.filterType != PickerFilterType.Checkbox) { + entity.parent!.filterType != PickerFilterType.Checkbox) { index = levelList.indexOf(entity); break; } diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart index cb9e9959..84278352 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart @@ -1,29 +1,25 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart'; -import 'package:bruno/src/utils/brn_tools.dart'; /// BrnMultiColumnPicker相关工具类 class BrnMultiColumnPickerUtil { /// 筛选项最多不超过三层,故直接写代码判断,本质为深度优先搜索。 - static int getTotalColumnCount(BrnPickerEntity entity) { + static int getTotalColumnCount(BrnPickerEntity? entity) { int count = 0; - BrnPickerEntity rootEntity = entity; - while (rootEntity.parent != null) { - rootEntity = rootEntity.parent; + BrnPickerEntity? rootEntity = entity; + while (rootEntity?.parent != null) { + rootEntity = rootEntity?.parent!; } - if (rootEntity != null && - rootEntity.children != null && + if (rootEntity != null && rootEntity.children.length > 0) { count = count > 1 ? count : 1; for (BrnPickerEntity firstLevelEntity in rootEntity.children) { - if (firstLevelEntity.children != null && - firstLevelEntity.children.length > 0) { + if (firstLevelEntity.children.length > 0) { count = count > 2 ? count : 2; for (BrnPickerEntity secondLevelEntity in firstLevelEntity.children) { - if (secondLevelEntity.children != null && - secondLevelEntity.children.length > 0) { + if (secondLevelEntity.children.length > 0) { count = 3; break; } @@ -35,7 +31,7 @@ class BrnMultiColumnPickerUtil { } /// 确定当前 Item 在第几层级 - static int getCurrentColumnIndex(BrnPickerEntity currentItem) { + static int getCurrentColumnIndex(BrnPickerEntity? currentItem) { int listIndex = -1; if (currentItem != null) { listIndex = 0; @@ -52,9 +48,9 @@ class BrnMultiColumnPickerUtil { /// [entity] 传入当前点击的 Item /// !!! 在设置 isSelected = true之前进行 check。 /// 返回 true 符合条件,false 不符合条件 - static bool isSelectedCountExceed(BrnPickerEntity entity) { - if (entity == null && entity.parent == null) return false; - return entity.parent.getSelectedChildCount() < - entity.parent.maxSelectedCount; + static bool isSelectedCountExceed(BrnPickerEntity? entity) { + if (entity == null && entity?.parent == null) return false; + return entity!.parent!.getSelectedChildCount() < + entity.parent!.maxSelectedCount; } } diff --git a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart index b7342d71..8e94c008 100644 --- a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart +++ b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart'; import 'package:bruno/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart'; @@ -12,17 +12,17 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { final BrnPickerEntity item; final Color normalColor; final Color selectColor; - final Color backgroundColor; - final Color selectedBackgroundColor; - final bool isCurrentFocused; + final Color? backgroundColor; + final Color? selectedBackgroundColor; + final bool? isCurrentFocused; final bool isFirstLevel; final bool isMoreSelectionListType; - final ItemSelectFunction itemSelectFunction; + final ItemSelectFunction? itemSelectFunction; BrnMultiRangePickerCommonItem({ - @required this.item, + required this.item, this.normalColor = const Color(0Xff4a4e59), this.selectColor = const Color(0xff41bc6a), this.backgroundColor, @@ -37,7 +37,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { Widget build(BuildContext context) { var checkbox; if (!item.isUnLimit() && - (item.children == null || item.children.length == 0)) { + (item.children.length == 0)) { if (item.isInLastLevel() && _hasCheckBoxBrother(item)) { checkbox = Container( padding: EdgeInsets.only(left: 6), @@ -57,7 +57,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { return GestureDetector( onTap: () { if (itemSelectFunction != null) { - itemSelectFunction(item); + itemSelectFunction!(item); } }, child: Container( @@ -71,7 +71,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { Container( child: Expanded( child: Text( - item.name + _getSelectedItemCount(item), + item.name! + _getSelectedItemCount(item), softWrap: true, overflow: TextOverflow.ellipsis, textAlign: TextAlign.left, @@ -90,8 +90,8 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { ); } - Color _getItemBGColor() { - if (isCurrentFocused) { + Color? _getItemBGColor() { + if (isCurrentFocused!) { return this.selectedBackgroundColor; } else { return this.backgroundColor; @@ -99,23 +99,23 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { } Color _getItemTextColor() { - Color itemColor = (item.isUnLimit() ? isCurrentFocused : item.isSelected) + Color itemColor = (item.isUnLimit() ? isCurrentFocused : item.isSelected)! ? selectColor : normalColor; if (!item.isInLastLevel()) { - itemColor = isCurrentFocused ? selectColor : normalColor; + itemColor = isCurrentFocused! ? selectColor : normalColor; } return itemColor; } FontWeight _getItemFontWeight() { FontWeight fontWeight = - (item.isUnLimit() ? isCurrentFocused : item.isSelected) + (item.isUnLimit() ? isCurrentFocused : item.isSelected)! ? FontWeight.w600 : FontWeight.normal; if (!item.isInLastLevel()) { - fontWeight = isCurrentFocused ? FontWeight.w600 : FontWeight.normal; + fontWeight = isCurrentFocused! ? FontWeight.w600 : FontWeight.normal; } return fontWeight; } @@ -123,8 +123,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { String _getSelectedItemCount(BrnPickerEntity item) { String itemCount = ""; if ((BrnMultiColumnPickerUtil.getTotalColumnCount(item) < 3 || - !isFirstLevel) && - item.children != null) { + !isFirstLevel)) { int count = item.children.where((f) => f.isSelected && !f.isUnLimit()).length; if (count > 1) { @@ -135,9 +134,12 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { } bool _hasCheckBoxBrother(BrnPickerEntity item) { - int count = item.parent.children - ?.where((f) => f.filterType == PickerFilterType.Checkbox) - ?.length; + int? count; + if (item.parent != null) { + count = item.parent!.children + .where((f) => f.filterType == PickerFilterType.Checkbox) + .length; + } return count == null ? false : count > 0; } } diff --git a/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_data.dart b/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_data.dart index 9ac9a4ba..a48143db 100644 --- a/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_data.dart +++ b/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_data.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + class BrnMultiSelectBottomPickerItem { String code; //选项编号 diff --git a/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_list_picker.dart b/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_list_picker.dart index 9d6bf570..c1427243 100644 --- a/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_list_picker.dart +++ b/lib/src/components/picker/multi_select_bottom_picker/brn_multi_select_list_picker.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/src/components/line/brn_line.dart'; import 'package:bruno/src/components/picker/base/brn_picker_constants.dart'; @@ -24,19 +24,19 @@ typedef BrnMultiSelectListPickerItemClick = void Function( /// 多选列表 Picker class BrnMultiSelectListPicker extends StatefulWidget { - final String title; + final String? title; final List items; - final BrnMultiSelectListPickerSubmit onSubmit; - final VoidCallback onCancel; - final BrnMultiSelectListPickerItemClick onItemClick; + final BrnMultiSelectListPickerSubmit? onSubmit; + final VoidCallback? onCancel; + final BrnMultiSelectListPickerItemClick? onItemClick; final BrnPickerTitleConfig pickerTitleConfig; static void show( BuildContext context, { - @required List items, - BrnMultiSelectListPickerSubmit onSubmit, - VoidCallback onCancel, - BrnMultiSelectListPickerItemClick onItemClick, + required List items, + BrnMultiSelectListPickerSubmit? onSubmit, + VoidCallback? onCancel, + BrnMultiSelectListPickerItemClick? onItemClick, BrnPickerTitleConfig pickerTitleConfig = BrnPickerTitleConfig.Default, bool isDismissible = true, }) { @@ -57,9 +57,9 @@ class BrnMultiSelectListPicker extends StatefulWidget { } BrnMultiSelectListPicker({ - Key key, + Key? key, this.title, - this.items, + required this.items, this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.onSubmit, this.onCancel, @@ -100,15 +100,15 @@ class MultiSelectDialogWidgetState extends State { pickerTitleConfig: widget.pickerTitleConfig, onConfirm: () { List selectedItems = - List(); + []; if (widget.onSubmit != null) { - for (int i = 0; i < widget.items?.length; i++) { + for (int i = 0; i < widget.items.length; i++) { if (widget.items[i].isChecked) { selectedItems.add(widget.items[i]); } } if (widget.onSubmit != null) { - widget.onSubmit(selectedItems); + widget.onSubmit!(selectedItems); } } }, @@ -120,12 +120,12 @@ class MultiSelectDialogWidgetState extends State { ), LimitedBox( maxWidth: double.infinity, - maxHeight: PICKER_HEIGHT, + maxHeight: pickerHeight, child: ListView.builder( shrinkWrap: true, itemBuilder: (context, index) => _buildItem(context, index), - itemCount: widget.items?.length)), + itemCount: widget.items.length)), ], ), ], @@ -135,9 +135,7 @@ class MultiSelectDialogWidgetState extends State { } Widget _buildItem(BuildContext context, int index) { - if (widget.items[index] == null) { - return Container(); - } else { + return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { @@ -145,7 +143,7 @@ class MultiSelectDialogWidgetState extends State { widget.items[index].isChecked = !widget.items[index].isChecked; }); if (widget.onItemClick != null) { - widget.onItemClick(context, index); + widget.onItemClick!(context, index); } }, child: Column( @@ -180,13 +178,13 @@ class MultiSelectDialogWidgetState extends State { ], ), ), - index != widget.items.length - 1 + index != widget.items.length - 1 ? Padding( padding: EdgeInsets.fromLTRB(20, 0, 20, 0), child: BrnLine()) : Container() ], )); - } + } } diff --git a/lib/src/components/picker/time_picker/brn_date_picker_constants.dart b/lib/src/components/picker/time_picker/brn_date_picker_constants.dart index 4b4fbe68..8c8dffe6 100755 --- a/lib/src/components/picker/time_picker/brn_date_picker_constants.dart +++ b/lib/src/components/picker/time_picker/brn_date_picker_constants.dart @@ -1,6 +1,6 @@ /// Selected value of DatePicker. -// @dart=2.9 + typedef DateValueCallback(DateTime dateTime, List selectedIndex); @@ -14,25 +14,25 @@ typedef DateRangeSideValueCallback( typedef DateVoidCallback(); /// Default value of minimum datetime. -const String DATE_PICKER_MIN_DATETIME = "1900-01-01 00:00:00"; +const String datePickerMinDatetime = "1900-01-01 00:00:00"; /// Default value of maximum datetime. -const String DATE_PICKER_MAX_DATETIME = "2100-12-31 23:59:59"; +const String datePickerMaxDatetime = "2100-12-31 23:59:59"; /// Default value of date format -const String DATETIME_PICKER_DATE_FORMAT = 'yyyy-MM-dd'; +const String datetimePickerDateFormat = 'yyyy-MM-dd'; /// Default value of time format -const String DATETIME_PICKER_TIME_FORMAT = 'HH:mm:ss'; +const String datetimePickerTimeFormat = 'HH:mm:ss'; /// Default value of datetime format -const String DATETIME_PICKER_DATETIME_FORMAT = 'yyyyMMdd HH:mm:ss'; +const String datetimePickerDatetimeFormat = 'yyyyMMdd HH:mm:ss'; /// Default value of date format -const String DATETIME_RANGE_PICKER_DATE_FORMAT = 'MM-dd'; +const String datetimeRangePickerDateFormat = 'MM-dd'; /// Default value of time format -const String DATETIME_RANGE_PICKER_TIME_FORMAT = 'HH:mm'; +const String datetimeRangePickerTimeFormat = 'HH:mm'; /// Default value of datetime format -const String DATETIME_RANGE_PICKER_DATETIME_FORMAT = 'MMdd HH:mm'; +const String datetimeRangePickerDatetimeFormat = 'MMdd HH:mm'; diff --git a/lib/src/components/picker/time_picker/brn_date_time_formatter.dart b/lib/src/components/picker/time_picker/brn_date_time_formatter.dart index 210eb24c..bed44c7f 100755 --- a/lib/src/components/picker/time_picker/brn_date_time_formatter.dart +++ b/lib/src/components/picker/time_picker/brn_date_time_formatter.dart @@ -34,11 +34,11 @@ class DateTimeFormatter { } switch (pickerMode) { case BrnDateTimePickerMode.date: - return DATETIME_PICKER_DATE_FORMAT; + return datetimePickerDateFormat; case BrnDateTimePickerMode.time: - return DATETIME_PICKER_TIME_FORMAT; + return datetimePickerTimeFormat; case BrnDateTimePickerMode.datetime: - return DATETIME_PICKER_DATETIME_FORMAT; + return datetimePickerDatetimeFormat; } return ''; } @@ -50,9 +50,9 @@ class DateTimeFormatter { } switch (pickerMode) { case BrnDateTimeRangePickerMode.date: - return DATETIME_RANGE_PICKER_DATE_FORMAT; + return datetimeRangePickerDateFormat; case BrnDateTimeRangePickerMode.time: - return DATETIME_RANGE_PICKER_TIME_FORMAT; + return datetimeRangePickerTimeFormat; } return ''; } @@ -99,7 +99,7 @@ class DateTimeFormatter { temp.insert(0, dayFormat.toString()); } else { // add default date format - temp.insert(0, DATETIME_PICKER_DATE_FORMAT); + temp.insert(0, datetimePickerDateFormat); } result = temp; } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart b/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart index 6b82f1cf..662437ac 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; import 'package:bruno/src/components/picker/brn_picker_cliprrect.dart'; import 'package:bruno/src/components/picker/time_picker/brn_date_picker_constants.dart'; @@ -46,49 +44,49 @@ class BrnDatePicker { bool rootNavigator = false, /// 点击弹框外部区域能否消失 - bool canBarrierDismissible, + bool? canBarrierDismissible, /// 能滚动到的最小日期 - DateTime minDateTime, + DateTime? minDateTime, /// 能滚动到的最大日期 - DateTime maxDateTime, + DateTime? maxDateTime, /// 初始选择的时间。默认当前时间 - DateTime initialDateTime, + DateTime? initialDateTime, /// 时间格式化的格式 - String dateFormat, + String? dateFormat, /// 分钟间切换的差值 int minuteDivider: 1, - DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT, + DateTimePickerLocale locale = DATETIME_PICKER_LOCALE_DEFAULT, /// 时间选择组件显示的时间类型 - BrnDateTimePickerMode pickerMode: BrnDateTimePickerMode.date, + BrnDateTimePickerMode pickerMode = BrnDateTimePickerMode.date, /// 时间选择组件的主题样式 - BrnPickerTitleConfig pickerTitleConfig, + BrnPickerTitleConfig pickerTitleConfig = BrnPickerTitleConfig.Default, /// 点击【取消】回调给调用方的回调事件 - DateVoidCallback onCancel, + DateVoidCallback? onCancel, /// 点击【完成】回调给调用方的数据 - DateVoidCallback onClose, + DateVoidCallback? onClose, /// 时间滚动选择时候的回调事件 - DateValueCallback onChange, + DateValueCallback? onChange, /// 弹框点击外围消失的回调事件 - DateValueCallback onConfirm, - BrnPickerConfig themeData, + DateValueCallback? onConfirm, + BrnPickerConfig? themeData, }) { // handle the range of datetime if (minDateTime == null) { - minDateTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minDateTime = DateTime.parse(datePickerMinDatetime); } if (maxDateTime == null) { - maxDateTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxDateTime = DateTime.parse(datePickerMaxDatetime); } // handle initial DateTime @@ -131,37 +129,37 @@ class _DatePickerRoute extends PopupRoute { this.initialDateTime, this.minuteDivider, this.dateFormat, - this.locale, - this.pickerMode, - this.pickerTitleConfig, + this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.pickerMode = BrnDateTimePickerMode.date, + this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.onCancel, this.onChange, this.onConfirm, this.theme, this.barrierLabel, this.canBarrierDismissible, - RouteSettings settings, + RouteSettings? settings, this.themeData, }) : super(settings: settings) { this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } - final DateTime minDateTime, maxDateTime, initialDateTime; - final String dateFormat; + final DateTime? minDateTime, maxDateTime, initialDateTime; + final String? dateFormat; final DateTimePickerLocale locale; final BrnDateTimePickerMode pickerMode; final BrnPickerTitleConfig pickerTitleConfig; - final VoidCallback onCancel; - final DateValueCallback onChange; - final DateValueCallback onConfirm; - bool canBarrierDismissible; - final int minuteDivider; - final ThemeData theme; - BrnPickerConfig themeData; + final VoidCallback? onCancel; + final DateValueCallback? onChange; + final DateValueCallback? onConfirm; + bool? canBarrierDismissible; + final int? minuteDivider; + final ThemeData? theme; + BrnPickerConfig? themeData; @override Duration get transitionDuration => const Duration(milliseconds: 200); @@ -170,27 +168,27 @@ class _DatePickerRoute extends PopupRoute { bool get barrierDismissible => canBarrierDismissible ?? true; @override - final String barrierLabel; + final String? barrierLabel; @override Color get barrierColor => Colors.black54; - AnimationController _animationController; + AnimationController? _animationController; @override AnimationController createAnimationController() { assert(_animationController == null); _animationController = - BottomSheet.createAnimationController(navigator.overlay); - return _animationController; + BottomSheet.createAnimationController(navigator!.overlay!); + return _animationController!; } @override Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { - double height = themeData.pickerHeight; + double height = themeData!.pickerHeight; if (pickerTitleConfig.title != null || pickerTitleConfig.showTitle) { - height += themeData.titleHeight; + height += themeData!.titleHeight; } Widget bottomSheet = MediaQuery.removePadding( @@ -200,7 +198,7 @@ class _DatePickerRoute extends PopupRoute { ); if (theme != null) { - bottomSheet = Theme(data: theme, child: bottomSheet); + bottomSheet = Theme(data: theme!, child: bottomSheet); } return bottomSheet; } @@ -211,12 +209,12 @@ class _DatePickerComponent extends StatelessWidget { final _DatePickerRoute route; final double _pickerHeight; - _DatePickerComponent({@required this.route, @required pickerHeight}) + _DatePickerComponent({required this.route, required pickerHeight}) : this._pickerHeight = pickerHeight; @override Widget build(BuildContext context) { - Widget pickerWidget; + Widget? pickerWidget; switch (route.pickerMode) { case BrnDateTimePickerMode.date: pickerWidget = BrnDateWidget( @@ -265,16 +263,16 @@ class _DatePickerComponent extends StatelessWidget { } return GestureDetector( child: AnimatedBuilder( - animation: route.animation, - builder: (BuildContext context, Widget child) { + animation: route.animation!, + builder: (BuildContext context, Widget? child) { return ClipRect( child: CustomSingleChildLayout( - delegate: _BottomPickerLayout(route.animation.value, + delegate: _BottomPickerLayout(route.animation!.value, contentHeight: _pickerHeight), child: BrnPickerClipRRect( borderRadius: BorderRadius.only( - topLeft: Radius.circular(route.themeData.cornerRadius), - topRight: Radius.circular(route.themeData.cornerRadius), + topLeft: Radius.circular(route.themeData!.cornerRadius), + topRight: Radius.circular(route.themeData!.cornerRadius), ), child: pickerWidget, ), @@ -290,7 +288,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { _BottomPickerLayout(this.progress, {this.contentHeight}); final double progress; - final double contentHeight; + final double? contentHeight; @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { @@ -298,7 +296,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, - maxHeight: contentHeight, + maxHeight: contentHeight!, ); } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart index 5347991b..1374a0ec 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -21,38 +21,38 @@ const List _solarMonthsOf31Days = const [1, 3, 5, 7, 8, 10, 12]; // ignore: must_be_immutable class BrnDateWidget extends StatefulWidget { BrnDateWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initialDateTime, - this.dateFormat: DATETIME_PICKER_DATE_FORMAT, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, - this.pickerTitleConfig: BrnPickerTitleConfig.Default, + this.dateFormat = datetimePickerDateFormat, + this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.pickerTitleConfig= BrnPickerTitleConfig.Default, this.onCancel, this.onChange, this.onConfirm, this.canPop = true, this.themeData, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) < 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } - final DateTime minDateTime, maxDateTime, initialDateTime; - final String dateFormat; + final DateTime? minDateTime, maxDateTime, initialDateTime; + final String? dateFormat; final DateTimePickerLocale locale; final BrnPickerTitleConfig pickerTitleConfig; - final DateVoidCallback onCancel; - final DateValueCallback onChange, onConfirm; + final DateVoidCallback? onCancel; + final DateValueCallback? onChange, onConfirm; final bool canPop; - BrnPickerConfig themeData; + BrnPickerConfig? themeData; @override State createState() => _BrnDateWidgetState( @@ -60,18 +60,18 @@ class BrnDateWidget extends StatefulWidget { } class _BrnDateWidgetState extends State { - DateTime _minDateTime, _maxDateTime; - int _currYear, _currMonth, _currDay; - List _yearRange, _monthRange, _dayRange; - FixedExtentScrollController _yearScrollCtrl, _monthScrollCtrl, _dayScrollCtrl; + late DateTime _minDateTime, _maxDateTime; + late int _currYear, _currMonth, _currDay; + late List _yearRange, _monthRange, _dayRange; + late FixedExtentScrollController? _yearScrollCtrl, _monthScrollCtrl, _dayScrollCtrl; - Map _scrollCtrlMap; - Map> _valueRangeMap; + late Map _scrollCtrlMap; + late Map?> _valueRangeMap; bool _isChangeDateRange = false; _BrnDateWidgetState( - DateTime minDateTime, DateTime maxDateTime, DateTime initialDateTime) { + DateTime? minDateTime, DateTime? maxDateTime, DateTime? initialDateTime) { // handle current selected year、month、day DateTime initDateTime = initialDateTime ?? DateTime.now(); this._currYear = initDateTime.year; @@ -79,8 +79,8 @@ class _BrnDateWidgetState extends State { this._currDay = initDateTime.day; // handle DateTime range - this._minDateTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - this._maxDateTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + this._minDateTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + this._maxDateTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); // limit the range of year this._yearRange = _calcYearRange(); @@ -141,7 +141,7 @@ class _BrnDateWidgetState extends State { /// pressed cancel widget void _onPressedCancel() { if (widget.onCancel != null) { - widget.onCancel(); + widget.onCancel!(); } if (widget.canPop) Navigator.pop(context); } @@ -150,7 +150,7 @@ class _BrnDateWidgetState extends State { void _onPressedConfirm() { if (widget.onConfirm != null) { DateTime dateTime = DateTime(_currYear, _currMonth, _currDay); - widget.onConfirm(dateTime, _calcSelectIndexList()); + widget.onConfirm!(dateTime, _calcSelectIndexList()); } if (widget.canPop) Navigator.pop(context); } @@ -159,13 +159,13 @@ class _BrnDateWidgetState extends State { void _onSelectedChange() { if (widget.onChange != null) { DateTime dateTime = DateTime(_currYear, _currMonth, _currDay); - widget.onChange(dateTime, _calcSelectIndexList()); + widget.onChange!(dateTime, _calcSelectIndexList()); } } /// find scroll controller by specified format - FixedExtentScrollController _findScrollCtrl(String format) { - FixedExtentScrollController scrollCtrl; + FixedExtentScrollController? _findScrollCtrl(String format) { + FixedExtentScrollController? scrollCtrl; _scrollCtrlMap.forEach((key, value) { if (format.contains(key)) { scrollCtrl = value; @@ -175,8 +175,8 @@ class _BrnDateWidgetState extends State { } /// find item value range by specified format - List _findPickerItemRange(String format) { - List valueRange; + List? _findPickerItemRange(String format) { + List? valueRange; _valueRangeMap.forEach((key, value) { if (format.contains(key)) { valueRange = value; @@ -187,11 +187,11 @@ class _BrnDateWidgetState extends State { /// render the picker widget of year、month and day Widget _renderDatePickerWidget() { - List pickers = List(); + List pickers = []; List formatArr = DateTimeFormatter.splitDateFormat(widget.dateFormat); formatArr.forEach((format) { - List valueRange = _findPickerItemRange(format); + List valueRange = _findPickerItemRange(format)!; Widget pickerColumn = _renderDatePickerColumnComponent( scrollCtrl: _findScrollCtrl(format), @@ -214,21 +214,21 @@ class _BrnDateWidgetState extends State { } Widget _renderDatePickerColumnComponent({ - @required FixedExtentScrollController scrollCtrl, - @required List valueRange, - @required String format, - @required ValueChanged valueChanged, + required FixedExtentScrollController? scrollCtrl, + required List valueRange, + required String format, + required ValueChanged valueChanged, }) { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, - decoration: BoxDecoration(color: widget.themeData.backgroundColor), + height: widget.themeData!.pickerHeight, + decoration: BoxDecoration(color: widget.themeData!.backgroundColor), child: BrnPicker.builder( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, scrollController: scrollCtrl, - itemExtent: widget.themeData.itemHeight, + itemExtent: widget.themeData!.itemHeight, onSelectedItemChanged: valueChanged, childCount: valueRange.last - valueRange.first + 1, itemBuilder: (context, index) => _renderDatePickerItemComponent( @@ -245,15 +245,15 @@ class _BrnDateWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType columnType, int index, int value, String format) { - TextStyle textStyle = widget.themeData.itemTextStyle.generateTextStyle(); + TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || (ColumnType.Month == columnType && index == _calcSelectIndexList()[1]) || (ColumnType.Day == columnType && index == _calcSelectIndexList()[2])) { - textStyle = widget.themeData.itemTextSelectedStyle.generateTextStyle(); + textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( DateTimeFormatter.formatDateTime(value, format, widget.locale), @@ -325,18 +325,18 @@ class _BrnDateWidgetState extends State { if (monthRangeChanged) { // CupertinoPicker refresh data not working (https://github.com/flutter/flutter/issues/22999) int currMonth = _currMonth; - _monthScrollCtrl.jumpToItem(monthRange.last - monthRange.first); + _monthScrollCtrl!.jumpToItem(monthRange.last - monthRange.first); if (currMonth < monthRange.last) { - _monthScrollCtrl.jumpToItem(currMonth - monthRange.first); + _monthScrollCtrl!.jumpToItem(currMonth - monthRange.first); } } if (dayRangeChanged) { // CupertinoPicker refresh data not working (https://github.com/flutter/flutter/issues/22999) int currDay = _currDay; - _dayScrollCtrl.jumpToItem(dayRange.last - dayRange.first); + _dayScrollCtrl!.jumpToItem(dayRange.last - dayRange.first); if (currDay < dayRange.last) { - _dayScrollCtrl.jumpToItem(currDay - dayRange.first); + _dayScrollCtrl!.jumpToItem(currDay - dayRange.first); } } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart index b34e316c..17c748f3 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -17,11 +17,11 @@ enum ColumnType { Year, Month, Day, Hour, Minute, Second } // ignore: must_be_immutable class BrnDateTimeWidget extends StatefulWidget { BrnDateTimeWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initDateTime, - this.dateFormat: DATETIME_PICKER_TIME_FORMAT, + this.dateFormat: datetimePickerTimeFormat, this.locale: DATETIME_PICKER_LOCALE_DEFAULT, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.onCancel, @@ -30,25 +30,25 @@ class BrnDateTimeWidget extends StatefulWidget { this.minuteDivider, this.themeData, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) < 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } - final DateTime minDateTime, maxDateTime, initDateTime; - final int minuteDivider; - final String dateFormat; + final DateTime? minDateTime, maxDateTime, initDateTime; + final int? minuteDivider; + final String? dateFormat; final DateTimePickerLocale locale; final BrnPickerTitleConfig pickerTitleConfig; - final DateVoidCallback onCancel; - final DateValueCallback onChange, onConfirm; - BrnPickerConfig themeData; + final DateVoidCallback? onCancel; + final DateValueCallback? onChange, onConfirm; + BrnPickerConfig? themeData; @override State createState() => _BrnDateTimeWidgetState( @@ -58,37 +58,37 @@ class BrnDateTimeWidget extends StatefulWidget { class _BrnDateTimeWidgetState extends State { final int _defaultMinuteDivider = 1; - DateTime _minTime, _maxTime; - int _currYear, _currMonth, _currDay, _currHour, _currMinute, _currSecond; - List _yearRange, + late DateTime _minTime, _maxTime; + late int _currYear, _currMonth, _currDay, _currHour, _currMinute, _currSecond; + late List _yearRange, _monthRange, _dayRange, _hourRange, _minuteRange, _secondRange; - FixedExtentScrollController _yearScrollCtrl, + late FixedExtentScrollController _yearScrollCtrl, _monthScrollCtrl, _dayScrollCtrl, _hourScrollCtrl, _minuteScrollCtrl, _secondScrollCtrl; - Map _scrollCtrlMap; - Map> _valueRangeMap; + late Map _scrollCtrlMap; + late Map?> _valueRangeMap; bool _isChangeTimeRange = false; - int _minuteDivider; + int? _minuteDivider; - _BrnDateTimeWidgetState(DateTime minTime, DateTime maxTime, DateTime initTime, - int minuteDivider) { + _BrnDateTimeWidgetState(DateTime? minTime, DateTime? maxTime, DateTime? initTime, + int? minuteDivider) { // check minTime value if (minTime == null) { - minTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minTime = DateTime.parse(datePickerMinDatetime); } // check maxTime value if (maxTime == null) { - maxTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxTime = DateTime.parse(datePickerMaxDatetime); } // check initTime value if (initTime == null) { @@ -134,7 +134,7 @@ class _BrnDateTimeWidgetState extends State { this._minuteRange = _calcMinuteRange(); this._currMinute = min(max(_minuteRange.first, _currMinute), _minuteRange.last); - _currMinute -= _currMinute % _minuteDivider; + _currMinute -= _currMinute % _minuteDivider!; // limit the range of second this._secondRange = _calcSecondRange(); @@ -151,7 +151,7 @@ class _BrnDateTimeWidgetState extends State { _hourScrollCtrl = FixedExtentScrollController(initialItem: _currHour - _hourRange.first); _minuteScrollCtrl = FixedExtentScrollController( - initialItem: (_currMinute - _minuteRange.first) ~/ _minuteDivider); + initialItem: (_currMinute - _minuteRange.first) ~/ _minuteDivider!); _secondScrollCtrl = FixedExtentScrollController( initialItem: _currSecond - _secondRange.first); @@ -202,7 +202,7 @@ class _BrnDateTimeWidgetState extends State { /// pressed cancel widget void _onPressedCancel() { if (widget.onCancel != null) { - widget.onCancel(); + widget.onCancel!(); } Navigator.pop(context); } @@ -216,33 +216,33 @@ class _BrnDateTimeWidgetState extends State { /// 如果传入的时间格式不包含 月、天、小时、分钟、秒。则相对应的时间置为 1,1,0,0,0; DateTime dateTime = DateTime( _currYear, - (formatArr?.where((format) => format.contains('M'))?.toList() ?? List()) + (formatArr.where((format) => format.contains('M')).toList()) .length > 0 ? _currMonth : 1, - (formatArr?.where((format) => format.contains('d'))?.toList() ?? List()) + (formatArr.where((format) => format.contains('d')).toList()) .length > 0 ? _currDay : 1, - (formatArr?.where((format) => format.contains('H'))?.toList() ?? List()) + (formatArr.where((format) => format.contains('H')).toList()) .length > 0 ? _currHour : 0, - (formatArr?.where((format) => format.contains('m'))?.toList() ?? List()) + (formatArr.where((format) => format.contains('m')).toList()) .length > 0 ? _currMinute : 0, - (formatArr?.where((format) => format.contains('s'))?.toList() ?? List()) + (formatArr.where((format) => format.contains('s')).toList()) .length > 0 ? _currSecond : 0, ); - widget.onConfirm(dateTime, _calcSelectIndexList()); + widget.onConfirm!(dateTime, _calcSelectIndexList()); } Navigator.pop(context); } @@ -252,13 +252,13 @@ class _BrnDateTimeWidgetState extends State { if (widget.onChange != null) { DateTime dateTime = DateTime( _currYear, _currMonth, _currDay, _currHour, _currMinute, _currSecond); - widget.onChange(dateTime, _calcSelectIndexList()); + widget.onChange!(dateTime, _calcSelectIndexList()); } } /// find scroll controller by specified format - FixedExtentScrollController _findScrollCtrl(String format) { - FixedExtentScrollController scrollCtrl; + FixedExtentScrollController? _findScrollCtrl(String format) { + FixedExtentScrollController? scrollCtrl; _scrollCtrlMap.forEach((key, value) { if (format.contains(key)) { scrollCtrl = value; @@ -268,8 +268,8 @@ class _BrnDateTimeWidgetState extends State { } /// find item value range by specified format - List _findPickerItemRange(String format) { - List valueRange; + List? _findPickerItemRange(String format) { + List? valueRange; _valueRangeMap.forEach((key, value) { if (format.contains(key)) { valueRange = value; @@ -280,13 +280,13 @@ class _BrnDateTimeWidgetState extends State { /// render the picker widget of year、month and day Widget _renderDatePickerWidget() { - List pickers = List(); + List pickers = []; List formatArr = DateTimeFormatter.splitDateFormat(widget.dateFormat); // render time picker column formatArr.forEach((format) { - List valueRange = _findPickerItemRange(format); + List? valueRange = _findPickerItemRange(format); Widget pickerColumn = _renderDatePickerColumnComponent( scrollCtrl: _findScrollCtrl(format), @@ -316,31 +316,31 @@ class _BrnDateTimeWidgetState extends State { } Widget _renderDatePickerColumnComponent( - {@required FixedExtentScrollController scrollCtrl, - @required List valueRange, - @required String format, - @required ValueChanged valueChanged, - int flex, - IndexedWidgetBuilder itemBuilder}) { + {required FixedExtentScrollController? scrollCtrl, + required List? valueRange, + required String format, + required ValueChanged valueChanged, + required int flex, + IndexedWidgetBuilder? itemBuilder}) { Widget columnWidget = Container( width: double.infinity, - height: widget.themeData.pickerHeight, - decoration: BoxDecoration(color: widget.themeData.backgroundColor), + height: widget.themeData!.pickerHeight, + decoration: BoxDecoration(color: widget.themeData!.backgroundColor), child: BrnPicker.builder( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, scrollController: scrollCtrl, - itemExtent: widget.themeData.itemHeight, + itemExtent: widget.themeData!.itemHeight, onSelectedItemChanged: valueChanged, childCount: format.contains('m') ? _calculateMinuteChildCount(valueRange, _minuteDivider) - : valueRange.last - valueRange.first + 1, + : valueRange!.last - valueRange.first + 1, itemBuilder: itemBuilder ?? (context, index) { - int value = valueRange.first + index; + int value = valueRange!.first + index; if (format.contains('m')) { - value = valueRange.first + _minuteDivider * index; + value = valueRange.first + _minuteDivider! * index; } return _renderDatePickerItemComponent( getColumnType(format), index, value, format); @@ -353,17 +353,17 @@ class _BrnDateTimeWidgetState extends State { ); } - _calculateMinuteChildCount(List valueRange, int divider) { + _calculateMinuteChildCount(List? valueRange, int? divider) { if (divider == 0 || divider == 1) { debugPrint("Cant devide by 0"); - return (valueRange.last - valueRange.first + 1); + return (valueRange!.last - valueRange.first + 1); } - return ((valueRange.last - valueRange.first) ~/ divider) + 1; + return ((valueRange!.last - valueRange.first) ~/ divider!) + 1; } // ignore: missing_return - ColumnType getColumnType(String format) { + ColumnType? getColumnType(String format) { if (format.contains('y')) { return ColumnType.Year; } else if (format.contains('M')) { @@ -465,8 +465,8 @@ class _BrnDateTimeWidgetState extends State { /// render hour、minute、second picker item Widget _renderDatePickerItemComponent( - ColumnType columnType, int index, int value, String format) { - TextStyle textStyle = widget.themeData.itemTextStyle.generateTextStyle(); + ColumnType? columnType, int index, int value, String format) { + TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || (ColumnType.Month == columnType && index == _calcSelectIndexList()[1]) || @@ -476,11 +476,11 @@ class _BrnDateTimeWidgetState extends State { index == _calcSelectIndexList()[4]) || (ColumnType.Second == columnType && index == _calcSelectIndexList()[5])) { - textStyle = widget.themeData.itemTextSelectedStyle.generateTextStyle(); + textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( DateTimeFormatter.formatDateTime(value, format, widget.locale), @@ -510,7 +510,7 @@ class _BrnDateTimeWidgetState extends State { /// change the selection of month picker void _changeMinuteSelection(int index) { - int value = _minuteRange.first + index * _minuteDivider; + int value = _minuteRange.first + index * _minuteDivider!; _currMinute = value; _changeTimeRange(); _onSelectedChange(); @@ -576,10 +576,10 @@ class _BrnDateTimeWidgetState extends State { if (minuteRangeChanged) { // CupertinoPicker refresh data not working (https://github.com/flutter/flutter/issues/22999) _minuteScrollCtrl - .jumpToItem((minuteRange.last - minuteRange.first) ~/ _minuteDivider); + .jumpToItem((minuteRange.last - minuteRange.first) ~/ _minuteDivider!); if (_currMinute < minuteRange.last) { _minuteScrollCtrl - .jumpToItem((_currMinute - minuteRange.first) ~/ _minuteDivider); + .jumpToItem((_currMinute - minuteRange.first) ~/ _minuteDivider!); } } @@ -600,7 +600,7 @@ class _BrnDateTimeWidgetState extends State { int monthIndex = _currMonth - _monthRange.first; int dayIndex = _currDay - _dayRange.first; int hourIndex = _currHour - _hourRange.first; - int minuteIndex = (_currMinute - _minuteRange.first) ~/ _minuteDivider; + int minuteIndex = (_currMinute - _minuteRange.first) ~/ _minuteDivider!; int secondIndex = _currSecond - _secondRange.first; return [ yearIndex, @@ -689,10 +689,10 @@ class _BrnDateTimeWidgetState extends State { minHour = _minTime.hour; } - int modValue = _minTime.minute % _minuteDivider; + int modValue = _minTime.minute % _minuteDivider!; int minMinute = modValue == 0 ? _minTime.minute - : (_minTime.minute - modValue + _minuteDivider); + : (_minTime.minute - modValue + _minuteDivider!); if (minMinute == 60) { minHour = minHour + 1 > _maxTime.hour ? _maxTime.hour : minHour + 1; } @@ -717,10 +717,10 @@ class _BrnDateTimeWidgetState extends State { _currDay == _minTime.day && _currHour == _minTime.hour) { // selected minimum day、hour, limit minute range - int modValue = _minTime.minute % _minuteDivider; + int modValue = _minTime.minute % _minuteDivider!; minMinute = modValue == 0 ? _minTime.minute - : (_minTime.minute - modValue + _minuteDivider); + : (_minTime.minute - modValue + _minuteDivider!); if (minMinute == 60) { minMinute = 0; currHour = currHour + 1 > _maxTime.hour ? _maxTime.hour : currHour + 1; @@ -731,7 +731,7 @@ class _BrnDateTimeWidgetState extends State { _currDay == _maxTime.day && _currHour == _maxTime.hour) { // selected maximum day、hour, limit minute range - maxMinute = _maxTime.minute - _maxTime.minute % _minuteDivider; + maxMinute = _maxTime.minute - _maxTime.minute % _minuteDivider!; } return [minMinute, maxMinute]; } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart index e5a8aaec..97c9de76 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -18,11 +18,11 @@ enum ColumnType { Hour, Minute, Second } // ignore: must_be_immutable class BrnTimeWidget extends StatefulWidget { BrnTimeWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initDateTime, - this.dateFormat: DATETIME_PICKER_TIME_FORMAT, + this.dateFormat: datetimePickerTimeFormat, this.locale: DATETIME_PICKER_LOCALE_DEFAULT, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.minuteDivider = 1, @@ -31,25 +31,25 @@ class BrnTimeWidget extends StatefulWidget { this.onConfirm, this.themeData, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) < 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } - final DateTime minDateTime, maxDateTime, initDateTime; - final String dateFormat; + final DateTime? minDateTime, maxDateTime, initDateTime; + final String? dateFormat; final DateTimePickerLocale locale; final BrnPickerTitleConfig pickerTitleConfig; - final DateVoidCallback onCancel; - final DateValueCallback onChange, onConfirm; - final int minuteDivider; + final DateVoidCallback? onCancel; + final DateValueCallback? onChange, onConfirm; + final int? minuteDivider; - BrnPickerConfig themeData; + BrnPickerConfig? themeData; @override State createState() => _BrnTimeWidgetState(this.minDateTime, @@ -59,26 +59,26 @@ class BrnTimeWidget extends StatefulWidget { class _BrnTimeWidgetState extends State { static int _defaultMinuteDivider = 1; - DateTime _minTime, _maxTime; - int _currHour, _currMinute, _currSecond; - int _minuteDivider; - List _hourRange, _minuteRange, _secondRange; - FixedExtentScrollController _hourScrollCtrl, + late DateTime _minTime, _maxTime; + late int _currHour, _currMinute, _currSecond; + late int _minuteDivider; + late List _hourRange, _minuteRange, _secondRange; + late FixedExtentScrollController _hourScrollCtrl, _minuteScrollCtrl, _secondScrollCtrl; - Map _scrollCtrlMap; - Map> _valueRangeMap; + late Map _scrollCtrlMap; + late Map?> _valueRangeMap; bool _isChangeTimeRange = false; - _BrnTimeWidgetState(DateTime minTime, DateTime maxTime, DateTime initTime, - int minuteDivider) { + _BrnTimeWidgetState(DateTime? minTime, DateTime? maxTime, DateTime? initTime, + int? minuteDivider) { if (minTime == null) { - minTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minTime = DateTime.parse(datePickerMinDatetime); } if (maxTime == null) { - maxTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxTime = DateTime.parse(datePickerMaxDatetime); } if (initTime == null) { // init time is now @@ -155,7 +155,7 @@ class _BrnTimeWidgetState extends State { /// pressed cancel widget void _onPressedCancel() { if (widget.onCancel != null) { - widget.onCancel(); + widget.onCancel!(); } Navigator.pop(context); } @@ -166,7 +166,7 @@ class _BrnTimeWidgetState extends State { DateTime now = DateTime.now(); DateTime dateTime = DateTime( now.year, now.month, now.day, _currHour, _currMinute, _currSecond); - widget.onConfirm(dateTime, _calcSelectIndexList()); + widget.onConfirm!(dateTime, _calcSelectIndexList()); } Navigator.pop(context); } @@ -177,13 +177,13 @@ class _BrnTimeWidgetState extends State { DateTime now = DateTime.now(); DateTime dateTime = DateTime( now.year, now.month, now.day, _currHour, _currMinute, _currSecond); - widget.onChange(dateTime, _calcSelectIndexList()); + widget.onChange!(dateTime, _calcSelectIndexList()); } } /// find scroll controller by specified format - FixedExtentScrollController _findScrollCtrl(String format) { - FixedExtentScrollController scrollCtrl; + FixedExtentScrollController? _findScrollCtrl(String format) { + FixedExtentScrollController? scrollCtrl; _scrollCtrlMap.forEach((key, value) { if (format.contains(key)) { scrollCtrl = value; @@ -193,8 +193,8 @@ class _BrnTimeWidgetState extends State { } /// find item value range by specified format - List _findPickerItemRange(String format) { - List valueRange; + List? _findPickerItemRange(String format) { + List? valueRange; _valueRangeMap.forEach((key, value) { if (format.contains(key)) { valueRange = value; @@ -205,11 +205,11 @@ class _BrnTimeWidgetState extends State { /// render the picker widget of year、month and day Widget _renderDatePickerWidget() { - List pickers = List(); + List pickers = []; List formatArr = DateTimeFormatter.splitDateFormat(widget.dateFormat); formatArr.forEach((format) { - List valueRange = _findPickerItemRange(format); + List? valueRange = _findPickerItemRange(format); Widget pickerColumn = _renderDatePickerColumnComponent( scrollCtrl: _findScrollCtrl(format), @@ -232,27 +232,27 @@ class _BrnTimeWidgetState extends State { } Widget _renderDatePickerColumnComponent({ - @required FixedExtentScrollController scrollCtrl, - @required List valueRange, - @required String format, - @required ValueChanged valueChanged, + required FixedExtentScrollController? scrollCtrl, + required List? valueRange, + required String format, + required ValueChanged valueChanged, }) { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, - decoration: BoxDecoration(color: widget.themeData.backgroundColor), + height: widget.themeData!.pickerHeight, + decoration: BoxDecoration(color: widget.themeData!.backgroundColor), child: BrnPicker.builder( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, scrollController: scrollCtrl, - itemExtent: widget.themeData.itemHeight, + itemExtent: widget.themeData!.itemHeight, onSelectedItemChanged: valueChanged, childCount: format.contains('m') ? _calculateMinuteChildCount(valueRange, _minuteDivider) - : valueRange.last - valueRange.first + 1, + : valueRange!.last - valueRange.first + 1, itemBuilder: (context, index) { - int value = valueRange.first + index; + int value = valueRange!.first + index; if (format.contains('m')) { value = _minuteDivider * index; @@ -267,7 +267,7 @@ class _BrnTimeWidgetState extends State { } // ignore: missing_return - ColumnType getColumnType(String format) { + ColumnType? getColumnType(String format) { if (format.contains('H')) { return ColumnType.Hour; } else if (format.contains('m')) { @@ -278,27 +278,27 @@ class _BrnTimeWidgetState extends State { return null; } - _calculateMinuteChildCount(List valueRange, int divider) { + _calculateMinuteChildCount(List? valueRange, int? divider) { if (divider == 0) { debugPrint("Cant devide by 0"); - return (valueRange.last - valueRange.first + 1); + return (valueRange!.last - valueRange.first + 1); } - return (valueRange.last - valueRange.first + 1) ~/ divider; + return (valueRange!.last - valueRange.first + 1) ~/ divider!; } Widget _renderDatePickerItemComponent( - ColumnType columnType, int index, int value, String format) { - TextStyle textStyle = widget.themeData.itemTextStyle.generateTextStyle(); + ColumnType? columnType, int index, int value, String format) { + TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); if ((ColumnType.Hour == columnType && index == _calcSelectIndexList()[0]) || (ColumnType.Minute == columnType && index == _calcSelectIndexList()[1]) || (ColumnType.Second == columnType && index == _calcSelectIndexList()[2])) { - textStyle = widget.themeData.itemTextSelectedStyle.generateTextStyle(); + textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( DateTimeFormatter.formatDateTime(value, format, widget.locale), diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart index 9d975051..69d5738b 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/components/picker/base/brn_picker_title_config.dart'; import 'package:bruno/src/components/picker/brn_picker_cliprrect.dart'; import 'package:bruno/src/components/picker/time_picker/brn_date_picker_constants.dart'; @@ -39,28 +37,28 @@ class BrnDateRangePicker { static void showDatePicker( BuildContext context, { bool isDismissible = true, - DateTime minDateTime, - DateTime maxDateTime, + DateTime? minDateTime, + DateTime? maxDateTime, bool isLimitTimeRange = true, - DateTime initialStartDateTime, - DateTime initialEndDateTime, - String dateFormat, - int minuteDivider, - DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT, - BrnDateTimeRangePickerMode pickerMode: BrnDateTimeRangePickerMode.date, - BrnPickerTitleConfig pickerTitleConfig: BrnPickerTitleConfig.Default, - DateVoidCallback onCancel, - DateVoidCallback onClose, - DateRangeValueCallback onChange, - DateRangeValueCallback onConfirm, - BrnPickerConfig themeData, + DateTime? initialStartDateTime, + DateTime? initialEndDateTime, + String? dateFormat, + int minuteDivider = 1, + DateTimePickerLocale locale = DATETIME_PICKER_LOCALE_DEFAULT, + BrnDateTimeRangePickerMode pickerMode = BrnDateTimeRangePickerMode.date, + BrnPickerTitleConfig pickerTitleConfig = BrnPickerTitleConfig.Default, + DateVoidCallback? onCancel, + required DateVoidCallback? onClose, + DateRangeValueCallback? onChange, + DateRangeValueCallback? onConfirm, + BrnPickerConfig? themeData, }) { // handle the range of datetime if (minDateTime == null) { - minDateTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minDateTime = DateTime.parse(datePickerMinDatetime); } if (maxDateTime == null) { - maxDateTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxDateTime = DateTime.parse(datePickerMaxDatetime); } // handle initial DateTime @@ -93,27 +91,27 @@ class BrnDateRangePicker { MaterialLocalizations.of(context).modalBarrierDismissLabel, themeData: themeData, ), - ).whenComplete(onClose); + ).whenComplete(onClose ?? () {}); } } class _DatePickerRoute extends PopupRoute { - final DateTime minDateTime, + final DateTime? minDateTime, maxDateTime, initialStartDateTime, initialEndDateTime; final bool isLimitTimeRange; - final String dateFormat; + final String? dateFormat; final DateTimePickerLocale locale; final BrnDateTimeRangePickerMode pickerMode; final BrnPickerTitleConfig pickerTitleConfig; - final VoidCallback onCancel; - final DateRangeValueCallback onChange; - final DateRangeValueCallback onConfirm; + final VoidCallback? onCancel; + final DateRangeValueCallback? onChange; + final DateRangeValueCallback? onConfirm; final int minuteDivider; - final ThemeData theme; - final bool isDismissible; - BrnPickerConfig themeData; + final ThemeData? theme; + final bool? isDismissible; + BrnPickerConfig? themeData; _DatePickerRoute({ this.minDateTime, @@ -123,9 +121,9 @@ class _DatePickerRoute extends PopupRoute { this.initialEndDateTime, this.minuteDivider = 1, this.dateFormat, - this.locale, - this.pickerMode, - this.pickerTitleConfig, + this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.pickerMode = BrnDateTimeRangePickerMode.date, + this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.onCancel, this.onChange, this.onConfirm, @@ -133,11 +131,11 @@ class _DatePickerRoute extends PopupRoute { this.barrierLabel, this.isDismissible, this.themeData, - RouteSettings settings, + RouteSettings? settings, }) : super(settings: settings) { this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -149,27 +147,27 @@ class _DatePickerRoute extends PopupRoute { bool get barrierDismissible => isDismissible ?? true; @override - final String barrierLabel; + final String? barrierLabel; @override Color get barrierColor => Colors.black54; - AnimationController _animationController; + AnimationController? _animationController; @override AnimationController createAnimationController() { assert(_animationController == null); _animationController = - BottomSheet.createAnimationController(navigator.overlay); - return _animationController; + BottomSheet.createAnimationController(navigator!.overlay!); + return _animationController!; } @override Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { - double height = themeData.pickerHeight; + double height = themeData!.pickerHeight; if (pickerTitleConfig.title != null || pickerTitleConfig.showTitle) { - height += themeData.titleHeight; + height += themeData!.titleHeight; } Widget bottomSheet = MediaQuery.removePadding( @@ -182,7 +180,7 @@ class _DatePickerRoute extends PopupRoute { ); if (theme != null) { - bottomSheet = Theme(data: theme, child: bottomSheet); + bottomSheet = Theme(data: theme!, child: bottomSheet); } return bottomSheet; } @@ -192,12 +190,12 @@ class _DatePickerComponent extends StatelessWidget { final _DatePickerRoute route; final double _pickerHeight; - _DatePickerComponent({@required this.route, @required pickerHeight}) + _DatePickerComponent({required this.route, required pickerHeight}) : this._pickerHeight = pickerHeight; @override Widget build(BuildContext context) { - Widget pickerWidget; + Widget? pickerWidget; switch (route.pickerMode) { case BrnDateTimeRangePickerMode.date: pickerWidget = BrnDateRangeWidget( @@ -234,16 +232,16 @@ class _DatePickerComponent extends StatelessWidget { } return GestureDetector( child: AnimatedBuilder( - animation: route.animation, - builder: (BuildContext context, Widget child) { + animation: route.animation!, + builder: (BuildContext context, Widget? child) { return ClipRect( child: CustomSingleChildLayout( - delegate: _BottomPickerLayout(route.animation.value, + delegate: _BottomPickerLayout(route.animation!.value, contentHeight: _pickerHeight), child: BrnPickerClipRRect( borderRadius: BorderRadius.only( - topLeft: Radius.circular(route.themeData.cornerRadius), - topRight: Radius.circular(route.themeData.cornerRadius), + topLeft: Radius.circular(route.themeData!.cornerRadius), + topRight: Radius.circular(route.themeData!.cornerRadius), ), child: pickerWidget, ), @@ -259,7 +257,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { _BottomPickerLayout(this.progress, {this.contentHeight}); final double progress; - final double contentHeight; + final double? contentHeight; @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { @@ -267,7 +265,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, - maxHeight: contentHeight, + maxHeight: contentHeight!, ); } diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart index c3113d61..8ab6b5bf 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'dart:math'; import 'package:bruno/src/components/picker/base/brn_picker.dart'; @@ -18,43 +16,43 @@ enum ColumnType { Year, Month, Day } // ignore: must_be_immutable class BrnDateRangeSideWidget extends StatefulWidget { /// 可选最小时间 - final DateTime minDateTime; + final DateTime? minDateTime; /// 可选最大时间 - final DateTime maxDateTime; + final DateTime? maxDateTime; /// 初始开始选中时间 - final DateTime initialStartDateTime; + final DateTime? initialStartDateTime; /// 时间展示格式 - final String dateFormat; + final String? dateFormat; final DateTimePickerLocale locale; /// 时间选择变化时回调 - final DateRangeSideValueCallback onChange; + final DateRangeSideValueCallback? onChange; /// 当前默认选择的时间变化时对外部回调,外部监听该事件同步修改默认初始选中的时间 - final DateRangeSideValueCallback onInitSelectChange; + final DateRangeSideValueCallback? onInitSelectChange; /// 主题定制 - BrnPickerConfig themeData; + BrnPickerConfig? themeData; BrnDateRangeSideWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initialStartDateTime, - this.dateFormat: DATETIME_RANGE_PICKER_DATE_FORMAT, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.dateFormat = datetimeRangePickerDateFormat, + this.locale = DATETIME_PICKER_LOCALE_DEFAULT, this.onInitSelectChange, this.onChange, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) <= 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -68,36 +66,41 @@ class BrnDateRangeSideWidget extends StatefulWidget { } class _DatePickerWidgetState extends State { - DateTime _minDateTime, _maxDateTime; - int _currYear, _currMonth, _currDay; - List _yearRange, _monthRange, _dayRange; - FixedExtentScrollController _yearScrollCtrl, _monthScrollCtrl, _dayScrollCtrl; + late DateTime _minDateTime, _maxDateTime; + late int _currYear, _currMonth, _currDay; + late List _yearRange, _monthRange, _dayRange; + late FixedExtentScrollController _yearScrollCtrl, + _monthScrollCtrl, + _dayScrollCtrl; - Map _scrollCtrlMap; - Map> _valueRangeMap; + late Map _scrollCtrlMap; + late Map?> _valueRangeMap; bool _isChangeDateRange = false; bool _scrolledNotDay = false; - DateRangeSideValueCallback _onInitSelectChange; + DateRangeSideValueCallback? _onInitSelectChange; - _DatePickerWidgetState(DateTime minDateTime, DateTime maxDateTime, - DateTime initialDateTime, DateRangeSideValueCallback onInitSelectChange) { + _DatePickerWidgetState( + DateTime? minDateTime, + DateTime? maxDateTime, + DateTime? initialDateTime, + DateRangeSideValueCallback? onInitSelectChange) { _onInitSelectChange = onInitSelectChange; _initData(initialDateTime, minDateTime, maxDateTime); } void _initData( - DateTime initialDateTime, DateTime minDateTime, DateTime maxDateTime) { + DateTime? initialDateTime, DateTime? minDateTime, DateTime? maxDateTime) { DateTime initDateTime = initialDateTime ?? DateTime.now(); this._currYear = initDateTime.year; this._currMonth = initDateTime.month; this._currDay = initDateTime.day; // handle DateTime range - this._minDateTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - this._maxDateTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + this._minDateTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + this._maxDateTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); // limit the range of year this._yearRange = _calcYearRange(); @@ -132,7 +135,7 @@ class _DatePickerWidgetState extends State { widget.initialStartDateTime, widget.minDateTime, widget.maxDateTime); return GestureDetector( child: Container( - color: widget.themeData.backgroundColor, + color: widget.themeData!.backgroundColor, child: _renderDatePickerWidget()), ); } @@ -141,7 +144,7 @@ class _DatePickerWidgetState extends State { void _onInitSelectedChange() { if (_onInitSelectChange != null) { DateTime dateTime = DateTime(_currYear, _currMonth, _currDay); - _onInitSelectChange(dateTime, _calcSelectIndexList()); + _onInitSelectChange!(dateTime, _calcSelectIndexList()); } } @@ -149,13 +152,13 @@ class _DatePickerWidgetState extends State { void _onSelectedChange() { if (widget.onChange != null) { DateTime dateTime = DateTime(_currYear, _currMonth, _currDay); - widget.onChange(dateTime, _calcSelectIndexList()); + widget.onChange!(dateTime, _calcSelectIndexList()); } } /// find scroll controller by specified format - FixedExtentScrollController _findScrollCtrl(String format) { - FixedExtentScrollController scrollCtrl; + FixedExtentScrollController? _findScrollCtrl(String format) { + FixedExtentScrollController? scrollCtrl; _scrollCtrlMap.forEach((key, value) { if (format.contains(key)) { scrollCtrl = value; @@ -165,8 +168,8 @@ class _DatePickerWidgetState extends State { } /// find item value range by specified format - List _findPickerItemRange(String format) { - List valueRange; + List? _findPickerItemRange(String format) { + List? valueRange; _valueRangeMap.forEach((key, value) { if (format.contains(key)) { valueRange = value; @@ -177,11 +180,11 @@ class _DatePickerWidgetState extends State { /// render the picker widget of year、month and day Widget _renderDatePickerWidget() { - List pickers = List(); + List pickers = []; List formatArr = DateTimeFormatter.splitDateFormat(widget.dateFormat); formatArr.forEach((format) { - List valueRange = _findPickerItemRange(format); + List valueRange = _findPickerItemRange(format)!; Widget pickerColumn = _renderDatePickerColumnComponent( scrollCtrl: _findScrollCtrl(format), @@ -204,10 +207,10 @@ class _DatePickerWidgetState extends State { } Widget _renderDatePickerColumnComponent({ - @required FixedExtentScrollController scrollCtrl, - @required List valueRange, - @required String format, - @required ValueChanged valueChanged, + required FixedExtentScrollController? scrollCtrl, + required List valueRange, + required String format, + required ValueChanged valueChanged, }) { var globalKey; if (_scrolledNotDay && format.contains("d")) { @@ -217,14 +220,14 @@ class _DatePickerWidgetState extends State { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, - decoration: BoxDecoration(color: widget.themeData.backgroundColor), + height: widget.themeData!.pickerHeight, + decoration: BoxDecoration(color: widget.themeData!.backgroundColor), child: BrnPicker.builder( key: globalKey, - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, scrollController: scrollCtrl, - itemExtent: widget.themeData.itemHeight, + itemExtent: widget.themeData!.itemHeight, onSelectedItemChanged: (int index) { if (!format.contains("d")) { _scrolledNotDay = true; @@ -246,15 +249,15 @@ class _DatePickerWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType columnType, int index, int value, String format) { - TextStyle textStyle = widget.themeData.itemTextStyle.generateTextStyle(); + TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || (ColumnType.Month == columnType && index == _calcSelectIndexList()[1]) || (ColumnType.Day == columnType && index == _calcSelectIndexList()[2])) { - textStyle = widget.themeData.itemTextSelectedStyle.generateTextStyle(); + textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( DateTimeFormatter.formatDateTime(value, format, widget.locale), diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart index 5a7294e8..98f5fdb3 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -18,43 +18,43 @@ const List _solarMonthsOf31Days = const [1, 3, 5, 7, 8, 10, 12]; // ignore: must_be_immutable class BrnDateRangeWidget extends StatefulWidget { /// 可选最小时间 - final DateTime minDateTime; + final DateTime? minDateTime; /// 可选最大时间 - final DateTime maxDateTime; + final DateTime? maxDateTime; /// 初始选中的开始时间 - final DateTime initialStartDateTime; + final DateTime? initialStartDateTime; /// 初始选中的结束时间 - final DateTime initialEndDateTime; + final DateTime? initialEndDateTime; /// 时间展示格式 - final String dateFormat; + final String? dateFormat; final DateTimePickerLocale locale; /// cancel 回调 - final DateVoidCallback onCancel; + final DateVoidCallback? onCancel; /// 选中时间变化时的回调,返回选中的开始、结束时间 - final DateRangeValueCallback onChange; + final DateRangeValueCallback? onChange; /// 确定回调,返回选中的开始、结束时间 - final DateRangeValueCallback onConfirm; + final DateRangeValueCallback? onConfirm; /// Picker title 相关内容配置 final BrnPickerTitleConfig pickerTitleConfig; /// Picker 主题配置 - BrnPickerConfig themeData; + BrnPickerConfig? themeData; BrnDateRangeWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initialStartDateTime, this.initialEndDateTime, - this.dateFormat: DATETIME_RANGE_PICKER_DATE_FORMAT, + this.dateFormat: datetimeRangePickerDateFormat, this.locale: DATETIME_PICKER_LOCALE_DEFAULT, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.onCancel, @@ -62,12 +62,12 @@ class BrnDateRangeWidget extends StatefulWidget { this.onConfirm, this.themeData, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) < 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -81,28 +81,28 @@ class BrnDateRangeWidget extends StatefulWidget { } class _DatePickerWidgetState extends State { - DateTime _minDateTime, _maxDateTime; - int _currStartYear, _currStartMonth, _currStartDay; - int _currEndYear, _currEndMonth, _currEndDay; + late DateTime _minDateTime, _maxDateTime; + late int _currStartYear, _currStartMonth, _currStartDay; + late int _currEndYear, _currEndMonth, _currEndDay; - List _monthRange, _startDayRange, _endDayRange; - List _startSelectedIndex; - List _endSelectedIndex; - DateTime _startSelectedDateTime; - DateTime _endSelectedDateTime; + late List _monthRange, _startDayRange, _endDayRange; + late List _startSelectedIndex; + late List _endSelectedIndex; + late DateTime _startSelectedDateTime; + late DateTime _endSelectedDateTime; bool _isFirstScroll = false; bool _isSecondScroll = false; - _DatePickerWidgetState(DateTime minDateTime, DateTime maxDateTime, - DateTime initialStartDateTime, DateTime initialEndDateTime) { + _DatePickerWidgetState(DateTime? minDateTime, DateTime? maxDateTime, + DateTime? initialStartDateTime, DateTime? initialEndDateTime) { // handle current selected year、month、day _initData( initialStartDateTime, initialEndDateTime, minDateTime, maxDateTime); } - void _initData(DateTime initialStartDateTime, DateTime initialEndDateTime, - DateTime minDateTime, DateTime maxDateTime) { + void _initData(DateTime? initialStartDateTime, DateTime? initialEndDateTime, + DateTime? minDateTime, DateTime? maxDateTime) { DateTime initStartDateTime = initialStartDateTime ?? DateTime.now(); DateTime initEndDateTime = initialEndDateTime ?? DateTime.now(); @@ -115,8 +115,8 @@ class _DatePickerWidgetState extends State { this._currEndDay = initEndDateTime.day; // handle DateTime range - this._minDateTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - this._maxDateTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + this._minDateTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + this._maxDateTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); // limit the range of year this._currStartYear = @@ -174,7 +174,7 @@ class _DatePickerWidgetState extends State { /// pressed cancel widget void _onPressedCancel() { if (widget.onCancel != null) { - widget.onCancel(); + widget.onCancel!(); } Navigator.pop(context); } @@ -182,7 +182,7 @@ class _DatePickerWidgetState extends State { /// pressed confirm widget void _onPressedConfirm() { if (widget.onConfirm != null) { - widget.onConfirm(_startSelectedDateTime, _endSelectedDateTime, + widget.onConfirm!(_startSelectedDateTime, _endSelectedDateTime, _startSelectedIndex, _endSelectedIndex); } Navigator.pop(context); @@ -203,12 +203,12 @@ class _DatePickerWidgetState extends State { _isSecondScroll = false; } - List pickers = List(); + List pickers = []; pickers.add(Expanded( flex: 6, child: Container( - height: widget.themeData.pickerHeight, - color: widget.themeData.backgroundColor, + height: widget.themeData!.pickerHeight, + color: widget.themeData!.backgroundColor, child: BrnDateRangeSideWidget( key: firstGlobalKey, dateFormat: widget.dateFormat, @@ -232,8 +232,8 @@ class _DatePickerWidgetState extends State { pickers.add(Expanded( flex: 6, child: Container( - height: widget.themeData.pickerHeight, - color: widget.themeData.backgroundColor, + height: widget.themeData!.pickerHeight, + color: widget.themeData!.backgroundColor, child: BrnDateRangeSideWidget( key: secondGlobalKey, dateFormat: widget.dateFormat, @@ -264,22 +264,22 @@ class _DatePickerWidgetState extends State { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, + height: widget.themeData!.pickerHeight, decoration: BoxDecoration( border: Border(left: BorderSide.none, right: BorderSide.none), - color: widget.themeData.backgroundColor), + color: widget.themeData!.backgroundColor), child: BrnPicker.builder( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, - itemExtent: widget.themeData.itemHeight, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, + itemExtent: widget.themeData!.itemHeight, childCount: 1, itemBuilder: (context, index) { return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( "至", - style: widget.themeData.itemTextStyle.generateTextStyle(), + style: widget.themeData!.itemTextStyle.generateTextStyle(), ), ); }, diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart index ca8e4ad0..88cd5ebb 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -14,46 +14,49 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class BrnTimeRangeSideWidget extends StatefulWidget { /// 可选最小时间 - final DateTime minDateTime; + final DateTime? minDateTime; /// 可选最大时间 - final DateTime maxDateTime; + final DateTime? maxDateTime; /// 初始开始选中时间 - final DateTime initialStartDateTime; + final DateTime? initialStartDateTime; /// 时间展示格式 - final String dateFormat; + final String? dateFormat; final DateTimePickerLocale locale; /// 时间选择变化时回调 - final DateRangeSideValueCallback onChange; + final DateRangeSideValueCallback? onChange; /// 分钟的展示间隔 - final int minuteDivider; + final int? minuteDivider; /// 当前默认选择的时间变化时对外部回调,外部监听该事件同步修改默认初始选中的时间 - final DateRangeSideValueCallback onInitSelectChange; + final DateRangeSideValueCallback? onInitSelectChange; /// 主题定制 - BrnPickerConfig themeData; + BrnPickerConfig? themeData; BrnTimeRangeSideWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.initialStartDateTime, - this.dateFormat: DATETIME_RANGE_PICKER_TIME_FORMAT, + this.dateFormat: datetimeRangePickerTimeFormat, this.locale: DATETIME_PICKER_LOCALE_DEFAULT, this.minuteDivider = 1, this.onChange, this.onInitSelectChange, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) <= 0); this.themeData ??= BrnPickerConfig(); - this.themeData.initThemeConfigPersonal(); + this.themeData = BrnThemeConfigurator.instance + .getConfig(configId: this.themeData!.configId) + .pickerConfig + .merge(this.themeData); } @override @@ -68,38 +71,38 @@ class BrnTimeRangeSideWidget extends StatefulWidget { class _TimePickerWidgetState extends State { final int _defaultMinuteDivider = 1; - DateTime _minTime, _maxTime; - int _currStartHour, _currStartMinute; - int _minuteDivider; - List _hourRange, _minuteRange; - FixedExtentScrollController _startHourScrollCtrl, _startMinuteScrollCtrl; + late DateTime _minTime, _maxTime; + late int _currStartHour, _currStartMinute; + late int _minuteDivider; + late List _hourRange, _minuteRange; + late FixedExtentScrollController _startHourScrollCtrl, _startMinuteScrollCtrl; - Map _startScrollCtrlMap; - Map> _valueRangeMap; + late Map _startScrollCtrlMap; + late Map> _valueRangeMap; bool _isChangeTimeRange = false; bool _scrolledNotMinute = false; - DateRangeSideValueCallback _onInitSelectChange; + DateRangeSideValueCallback? _onInitSelectChange; _TimePickerWidgetState( - DateTime minTime, - DateTime maxTime, - DateTime initStartTime, - int minuteDivider, - DateRangeSideValueCallback onInitSelectChange) { + DateTime? minTime, + DateTime? maxTime, + DateTime? initStartTime, + int? minuteDivider, + DateRangeSideValueCallback? onInitSelectChange) { _onInitSelectChange = onInitSelectChange; _initData(minTime, maxTime, initStartTime, minuteDivider); } - void _initData(DateTime minTime, DateTime maxTime, DateTime initStartTime, - int minuteDivider) { + void _initData(DateTime? minTime, DateTime? maxTime, DateTime? initStartTime, + int? minuteDivider) { if (minTime == null) { - minTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minTime = DateTime.parse(datePickerMinDatetime); } if (maxTime == null) { - maxTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxTime = DateTime.parse(datePickerMaxDatetime); } this._minTime = minTime; this._maxTime = maxTime; @@ -119,16 +122,14 @@ class _TimePickerWidgetState extends State { this._hourRange = _calcHourRange(); this._minuteRange = _calcMinuteRange(); - if (_currStartHour == null || _currStartMinute == null) { - this._currStartHour = initStartTime.hour; - this._currStartHour = - min(max(_hourRange.first, _currStartHour), _hourRange.last); + this._currStartHour = initStartTime.hour; + this._currStartHour = + min(max(_hourRange.first, _currStartHour), _hourRange.last); - this._currStartMinute = initStartTime.minute; - this._currStartMinute = - min(max(_minuteRange.first, _currStartMinute), _minuteRange.last); - _currStartMinute -= _currStartMinute % _minuteDivider; - } + this._currStartMinute = initStartTime.minute; + this._currStartMinute = + min(max(_minuteRange.first, _currStartMinute), _minuteRange.last); + _currStartMinute -= _currStartMinute % _minuteDivider; _onInitSelectedChange(); // create scroll controller _startHourScrollCtrl = FixedExtentScrollController( @@ -148,7 +149,7 @@ class _TimePickerWidgetState extends State { _initData(_minTime, _maxTime, widget.initialStartDateTime, _minuteDivider); return GestureDetector( child: Container( - color: widget.themeData.backgroundColor, + color: widget.themeData!.backgroundColor, child: _renderPickerView(context)), ); } @@ -164,7 +165,7 @@ class _TimePickerWidgetState extends State { DateTime now = DateTime.now(); DateTime startDateTime = DateTime( now.year, now.month, now.day, _currStartHour, _currStartMinute); - _onInitSelectChange(startDateTime, _calcStartSelectIndexList()); + _onInitSelectChange!(startDateTime, _calcStartSelectIndexList()); } } @@ -174,13 +175,13 @@ class _TimePickerWidgetState extends State { DateTime now = DateTime.now(); DateTime startDateTime = DateTime( now.year, now.month, now.day, _currStartHour, _currStartMinute); - widget.onChange(startDateTime, _calcStartSelectIndexList()); + widget.onChange!(startDateTime, _calcStartSelectIndexList()); } } /// find start scroll controller by specified format - FixedExtentScrollController _findScrollCtrl(String format) { - FixedExtentScrollController scrollCtrl; + FixedExtentScrollController? _findScrollCtrl(String format) { + FixedExtentScrollController? scrollCtrl; _startScrollCtrlMap.forEach((key, value) { if (format.contains(key)) { scrollCtrl = value; @@ -190,8 +191,8 @@ class _TimePickerWidgetState extends State { } /// find item value range by specified format - List _findPickerItemRange(String format) { - List valueRange; + List? _findPickerItemRange(String format) { + List? valueRange; _valueRangeMap.forEach((key, value) { if (format.contains(key)) { valueRange = value; @@ -202,11 +203,11 @@ class _TimePickerWidgetState extends State { /// render the picker widget of year、month and day Widget _renderDatePickerWidget() { - List pickers = List(); + List pickers = []; List formatArr = DateTimeFormatter.splitDateFormat(widget.dateFormat); formatArr.forEach((format) { - List valueRange = _findPickerItemRange(format); + List? valueRange = _findPickerItemRange(format); Widget pickerColumn = _renderDatePickerColumnComponent( scrollCtrl: _findScrollCtrl(format), @@ -227,10 +228,10 @@ class _TimePickerWidgetState extends State { } Widget _renderDatePickerColumnComponent({ - @required FixedExtentScrollController scrollCtrl, - @required List valueRange, - @required String format, - @required ValueChanged valueChanged, + required FixedExtentScrollController? scrollCtrl, + required List? valueRange, + required String format, + required ValueChanged valueChanged, }) { var globalKey; if (_scrolledNotMinute && format.contains("m")) { @@ -241,14 +242,14 @@ class _TimePickerWidgetState extends State { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, - color: widget.themeData.backgroundColor, + height: widget.themeData!.pickerHeight, + color: widget.themeData!.backgroundColor, child: BrnPicker.builder( key: globalKey, - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, scrollController: scrollCtrl, - itemExtent: widget.themeData.itemHeight, + itemExtent: widget.themeData!.itemHeight, onSelectedItemChanged: (int index) { if (!format.contains("m")) { _scrolledNotMinute = true; @@ -257,9 +258,9 @@ class _TimePickerWidgetState extends State { }, childCount: format.contains('m') ? _calculateMinuteChildCount(valueRange, _minuteDivider) - : valueRange.last - valueRange.first + 1, + : valueRange!.last - valueRange.first + 1, itemBuilder: (context, index) { - int value = valueRange.first + index; + int value = valueRange!.first + index; if (format.contains('m')) { value = valueRange.first + _minuteDivider * index; @@ -272,24 +273,24 @@ class _TimePickerWidgetState extends State { ); } - _calculateMinuteChildCount(List valueRange, int divider) { + _calculateMinuteChildCount(List? valueRange, int? divider) { if (divider == 0 || divider == 1) { debugPrint("Cant devide by 0"); - return (valueRange.last - valueRange.first + 1); + return (valueRange!.last - valueRange.first + 1); } - return ((valueRange.last - valueRange.first) ~/ divider) + 1; + return ((valueRange!.last - valueRange.first) ~/ divider!) + 1; } Widget _renderDatePickerItemComponent( int index, bool isMinuteColumn, int value, String format) { - TextStyle textStyle = widget.themeData.itemTextStyle.generateTextStyle(); + TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); if ((!isMinuteColumn && (index == _calcStartSelectIndexList()[0])) || ((isMinuteColumn && (index == _calcStartSelectIndexList()[1])))) { - textStyle = widget.themeData.itemTextSelectedStyle.generateTextStyle(); + textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( DateTimeFormatter.formatDateTime(value, format, widget.locale), diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart index 536932ab..9ce1ed76 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -16,32 +16,32 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class BrnTimeRangeWidget extends StatefulWidget { /// 可选最小时间 - final DateTime minDateTime; + final DateTime? minDateTime; /// 可选最大时间 - final DateTime maxDateTime; + final DateTime? maxDateTime; /// 初始开始选中时间 - final DateTime initialStartDateTime; + final DateTime? initialStartDateTime; /// 初始结束选中时间 - final DateTime initialEndDateTime; + final DateTime? initialEndDateTime; /// 是否限制 Picker 选择的时间范围(开始时间≤结束时间) final isLimitTimeRange; /// 时间格式 - final String dateFormat; + final String? dateFormat; final DateTimePickerLocale locale; /// cancel 回调 - final DateVoidCallback onCancel; + final DateVoidCallback? onCancel; /// 选中时间变化时的回调,返回选中的开始、结束时间 - final DateRangeValueCallback onChange; + final DateRangeValueCallback? onChange; /// 确定回调,返回选中的开始、结束时间 - final DateRangeValueCallback onConfirm; + final DateRangeValueCallback? onConfirm; /// Picker title 相关内容配置 final BrnPickerTitleConfig pickerTitleConfig; @@ -50,19 +50,19 @@ class BrnTimeRangeWidget extends StatefulWidget { final int minuteDivider; /// Picker 主题配置 - BrnPickerConfig themeData; + BrnPickerConfig? themeData; /// 内部变量,记录左右两侧是否触发了滚动 bool _isFirstScroll = false, _isSecondScroll = false; BrnTimeRangeWidget({ - Key key, + Key? key, this.minDateTime, this.maxDateTime, this.isLimitTimeRange = true, this.initialStartDateTime, this.initialEndDateTime, - this.dateFormat: DATETIME_RANGE_PICKER_TIME_FORMAT, + this.dateFormat: datetimeRangePickerTimeFormat, this.locale: DATETIME_PICKER_LOCALE_DEFAULT, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.minuteDivider = 1, @@ -71,12 +71,12 @@ class BrnTimeRangeWidget extends StatefulWidget { this.onConfirm, this.themeData, }) : super(key: key) { - DateTime minTime = minDateTime ?? DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = maxDateTime ?? DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = minDateTime ?? DateTime.parse(datePickerMinDatetime); + DateTime maxTime = maxDateTime ?? DateTime.parse(datePickerMaxDatetime); assert(minTime.compareTo(maxTime) < 0); this.themeData ??= BrnPickerConfig(); this.themeData = BrnThemeConfigurator.instance - .getConfig(configId: this.themeData.configId) + .getConfig(configId: this.themeData!.configId) .pickerConfig .merge(this.themeData); } @@ -93,28 +93,28 @@ class BrnTimeRangeWidget extends StatefulWidget { class _TimePickerWidgetState extends State { final int _defaultMinuteDivider = 1; - int _minuteDivider; - DateTime _minTime, _maxTime; - int _currStartHour, _currStartMinute; - int _currEndHour, _currEndMinute; - List _hourRange, _minuteRange; - List _startSelectedIndex; - List _endSelectedIndex; - DateTime _startSelectedDateTime; - DateTime _endSelectedDateTime; - - _TimePickerWidgetState(DateTime minTime, DateTime maxTime, - DateTime initStartTime, DateTime initEndTime, int minuteDivider) { + late int _minuteDivider; + late DateTime _minTime, _maxTime; + late int _currStartHour, _currStartMinute; + late int _currEndHour, _currEndMinute; + late List _hourRange, _minuteRange; + late List _startSelectedIndex; + late List _endSelectedIndex; + late DateTime _startSelectedDateTime; + late DateTime _endSelectedDateTime; + + _TimePickerWidgetState(DateTime? minTime, DateTime? maxTime, + DateTime? initStartTime, DateTime? initEndTime, int minuteDivider) { _initData(minTime, maxTime, initStartTime, initEndTime, minuteDivider); } - void _initData(DateTime minTime, DateTime maxTime, DateTime initStartTime, - DateTime initEndTime, int minuteDivider) { + void _initData(DateTime? minTime, DateTime? maxTime, DateTime? initStartTime, + DateTime? initEndTime, int? minuteDivider) { if (minTime == null) { - minTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); + minTime = DateTime.parse(datePickerMinDatetime); } if (maxTime == null) { - maxTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + maxTime = DateTime.parse(datePickerMaxDatetime); } DateTime now = DateTime.now(); this._minTime = DateTime(now.year, now.month, now.day, minTime.hour, @@ -200,7 +200,7 @@ class _TimePickerWidgetState extends State { /// pressed cancel widget void _onPressedCancel() { if (widget.onCancel != null) { - widget.onCancel(); + widget.onCancel!(); } Navigator.pop(context); } @@ -208,7 +208,7 @@ class _TimePickerWidgetState extends State { /// pressed confirm widget void _onPressedConfirm() { if (widget.onConfirm != null) { - widget.onConfirm(_startSelectedDateTime, _endSelectedDateTime, + widget.onConfirm!(_startSelectedDateTime, _endSelectedDateTime, _startSelectedIndex, _endSelectedIndex); } Navigator.pop(context); @@ -229,12 +229,12 @@ class _TimePickerWidgetState extends State { widget._isSecondScroll = false; } - List pickers = List(); + List pickers = []; pickers.add(Expanded( flex: 6, child: Container( - height: widget.themeData.pickerHeight, - color: widget.themeData.backgroundColor, + height: widget.themeData!.pickerHeight, + color: widget.themeData!.backgroundColor, child: BrnTimeRangeSideWidget( key: firstGlobalKey, dateFormat: widget.dateFormat, @@ -260,8 +260,8 @@ class _TimePickerWidgetState extends State { pickers.add(Expanded( flex: 6, child: Container( - height: widget.themeData.pickerHeight, - color: widget.themeData.backgroundColor, + height: widget.themeData!.pickerHeight, + color: widget.themeData!.backgroundColor, child: BrnTimeRangeSideWidget( key: secondGlobalKey, dateFormat: widget.dateFormat, @@ -336,22 +336,22 @@ class _TimePickerWidgetState extends State { return Expanded( flex: 1, child: Container( - height: widget.themeData.pickerHeight, + height: widget.themeData!.pickerHeight, decoration: BoxDecoration( border: Border(left: BorderSide.none, right: BorderSide.none), - color: widget.themeData.backgroundColor), + color: widget.themeData!.backgroundColor), child: BrnPicker.builder( - backgroundColor: widget.themeData.backgroundColor, - lineColor: widget.themeData.dividerColor, - itemExtent: widget.themeData.itemHeight, + backgroundColor: widget.themeData!.backgroundColor, + lineColor: widget.themeData!.dividerColor, + itemExtent: widget.themeData!.itemHeight, childCount: 1, itemBuilder: (context, index) { return Container( - height: widget.themeData.itemHeight, + height: widget.themeData!.itemHeight, alignment: Alignment.center, child: Text( "至", - style: widget.themeData.itemTextStyle ?? PICKER_ITEM_TEXT_STYLE, + style: widget.themeData!.itemTextStyle as TextStyle? ?? pickerItemTextStyle, ), ); }, diff --git a/lib/src/components/selection/bean/brn_selection_common_entity.dart b/lib/src/components/selection/bean/brn_selection_common_entity.dart index 603093c5..14f96b7a 100644 --- a/lib/src/components/selection/bean/brn_selection_common_entity.dart +++ b/lib/src/components/selection/bean/brn_selection_common_entity.dart @@ -535,8 +535,8 @@ class BrnSelectionEntity { if (this.filterType == BrnSelectionFilterType.Range || this.filterType == BrnSelectionFilterType.DateRange || this.filterType == BrnSelectionFilterType.DateRangeCalendar) { - DateTime minTime = DateTime.parse(DATE_PICKER_MIN_DATETIME); - DateTime maxTime = DateTime.parse(DATE_PICKER_MAX_DATETIME); + DateTime minTime = DateTime.parse(datePickerMinDatetime); + DateTime maxTime = DateTime.parse(datePickerMaxDatetime); int limitMin = int.tryParse(extMap['min']?.toString() ?? "") ?? (this.filterType == BrnSelectionFilterType.DateRange || this.filterType == BrnSelectionFilterType.DateRangeCalendar diff --git a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart index bb29f3af..3d8ce56c 100644 --- a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart @@ -495,7 +495,7 @@ class __MoreRangeWidgetState extends State<_MoreRangeWidget> { item: widget.rangeEntity, isNeedTitle: false, showTextSize: 14, - dateFormat: DATETIME_PICKER_DATE_FORMAT, + dateFormat: datetimePickerDateFormat, minTextEditingController: minController, maxTextEditingController: maxController, themeData: widget.themeData, diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index 03c565fc..cbc06626 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -531,7 +531,7 @@ class BrnDefaultConfigUtils { ); static BrnPickerConfig defaultPickerConfig = BrnPickerConfig( - backgroundColor: PICKER_BACKGROUND_COLOR, + backgroundColor: pickerBackgroundColor, cancelTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeSubHead, @@ -546,9 +546,9 @@ class BrnDefaultConfigUtils { fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), - pickerHeight: PICKER_HEIGHT, - titleHeight: PICKER_TITLE_HEIGHT, - itemHeight: PICKER_ITEM_HEIGHT, + pickerHeight: pickerHeight, + titleHeight: pickerTitleHeight, + itemHeight: pickerItemHeight, dividerColor: Color(0xFFF0F0F0), itemTextStyle: BrnTextStyle( color: defaultCommonConfig.colorTextBase, From 2d7fcc164c9531f3ac0746b50bf551fb90335f2c Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Tue, 25 Jan 2022 16:08:55 +0800 Subject: [PATCH 20/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dpicker=E7=A9=BA?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E8=BF=81=E7=A7=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/picker/base/brn_picker.dart | 2 +- .../picker/base/brn_picker_title.dart | 2 +- .../components/picker/brn_multi_picker.dart | 12 ++--- .../brn_select_tags_with_input_picker.dart | 51 +++++++++++-------- .../bean/brn_multi_column_picker_entity.dart | 4 +- .../brn_multi_column_list.dart | 6 +-- .../btn_multi_column_picker_item.dart | 2 +- .../date_picker/brn_date_picker.dart | 13 +++-- .../date_picker/brn_date_widget.dart | 2 +- .../date_picker/brn_datetime_widget.dart | 2 +- .../date_picker/brn_time_widget.dart | 4 +- .../brn_date_range_picker.dart | 15 +++--- .../brn_date_range_side_widget.dart | 4 +- .../brn_date_range_widget.dart | 2 +- .../brn_time_range_side_widget.dart | 10 ++-- .../brn_time_range_widget.dart | 20 +++----- lib/src/utils/i18n/brn_date_picker_i18n.dart | 20 ++++---- 17 files changed, 87 insertions(+), 84 deletions(-) diff --git a/lib/src/components/picker/base/brn_picker.dart b/lib/src/components/picker/base/brn_picker.dart index 4b00fc4a..2f4a01e9 100644 --- a/lib/src/components/picker/base/brn_picker.dart +++ b/lib/src/components/picker/base/brn_picker.dart @@ -441,7 +441,7 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { _controller!.removeListener(_handleScrollUpdate); else _currentIndex = value!.initialItem; - value!.addListener(_handleScrollUpdate); + value?.addListener(_handleScrollUpdate); _controller = value; } diff --git a/lib/src/components/picker/base/brn_picker_title.dart b/lib/src/components/picker/base/brn_picker_title.dart index 52241332..7079cbbf 100755 --- a/lib/src/components/picker/base/brn_picker_title.dart +++ b/lib/src/components/picker/base/brn_picker_title.dart @@ -13,7 +13,7 @@ class BrnPickerTitle extends StatelessWidget { final BrnPickerTitleConfig pickerTitleConfig; final DateTimePickerLocale? locale; final DateVoidCallback onCancel, onConfirm; - late BrnPickerConfig? themeData; + BrnPickerConfig? themeData; BrnPickerTitle({ Key? key, diff --git a/lib/src/components/picker/brn_multi_picker.dart b/lib/src/components/picker/brn_multi_picker.dart index 7f2ac315..e6ad7cc4 100644 --- a/lib/src/components/picker/brn_multi_picker.dart +++ b/lib/src/components/picker/brn_multi_picker.dart @@ -32,7 +32,7 @@ abstract class BrnMultiDataPickerDelegate { int numberOfRowsInComponent(int component); /// 定义某列某行所显示的内容,component 代表列的索引,index 代表 第component列中的第 index 个元素 - String? titleForRowInComponent(int component, int index); + String titleForRowInComponent(int component, int index); /// 定义每列内容的高度 double? rowHeightForComponent(int component); @@ -108,7 +108,7 @@ class BrnMultiDataPicker extends StatefulWidget { this.titleTextStyle, this.confirmTextStyle, this.cancelTextStyle, - this.pickerTitles = const [], + this.pickerTitles, this.pickerTitleFontSize, this.pickerTitleColor, this.textFontSize, @@ -291,7 +291,7 @@ class _BrnMultiDataPickerState extends State { i++) { list.add(Center( child: Text( - widget.delegate.titleForRowInComponent(component, i) ?? '', + widget.delegate.titleForRowInComponent(component, i), style: _selectedIndexList[component] == i ? widget.themeData!.itemTextSelectedStyle.generateTextStyle() : widget.themeData!.itemTextStyle.generateTextStyle(), @@ -338,8 +338,6 @@ class MyPicker extends StatefulWidget { ///数据选择改变回调 final ValueChanged? changed; - final Key? key; - /// 数据显示高度 final double itemExtent; @@ -351,15 +349,15 @@ class MyPicker extends StatefulWidget { final Color? lineColor; MyPicker({ + Key? key, this.createWidgetList, this.changed, - this.key, this.scrollBehavior, this.itemExtent = 45, this.controller, this.backgroundColor = Colors.white, this.lineColor, - }); + }) : super(key: key); @override State createState() { diff --git a/lib/src/components/picker/brn_select_tags_with_input_picker.dart b/lib/src/components/picker/brn_select_tags_with_input_picker.dart index 8b5f089e..97280e81 100644 --- a/lib/src/components/picker/brn_select_tags_with_input_picker.dart +++ b/lib/src/components/picker/brn_select_tags_with_input_picker.dart @@ -95,8 +95,8 @@ class BrnSelectTagsWithInputPickerWidget extends StatefulWidget { final int? maxLength; final String? hintText; final Color? cursorColor; - final bool? forceShowTextInput; - final bool? multiSelect; + final bool forceShowTextInput; + final bool multiSelect; final String? defaultText; final TextEditingController? textEditingController; final BrnTagsInputPickerConfig? tagPickerBean; @@ -110,8 +110,8 @@ class BrnSelectTagsWithInputPickerWidget extends StatefulWidget { this.maxLength, this.hintText, this.cursorColor, - this.forceShowTextInput, - this.multiSelect, + this.forceShowTextInput = false, + this.multiSelect = false, this.defaultText, this.textEditingController, this.tagPickerBean, @@ -218,18 +218,21 @@ class _BrnSelectTagsWithInputPickerWidgetState void _dataSetup() { List tagItems = []; List tagSelectedItems = []; - for (BrnTagInputItemBean item in widget.tagPickerBean!.tagItemSource) { - tagItems.add(item); - //选中的按钮 - if (item.isSelect == true && item.name != null) { - tagSelectedItems.add(item); + if (widget.tagPickerBean != null) { + for (BrnTagInputItemBean item in widget.tagPickerBean!.tagItemSource) { + tagItems.add(item); + //选中的按钮 + if (item.isSelect == true ) { + tagSelectedItems.add(item); + } } } + this._sourceTags = tagItems; // 重新排序,name 越长,越靠后 this._sourceTags.sort((left, right) { - return (left.name!.length).compareTo(right.name!.length); + return (left.name.length).compareTo(right.name.length); }); // 默认选中tags @@ -244,7 +247,7 @@ class _BrnSelectTagsWithInputPickerWidgetState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - widget.title!, + widget.title ?? '', style: TextStyle( color: BrnThemeConfigurator.instance .getConfig() @@ -293,17 +296,17 @@ class _BrnSelectTagsWithInputPickerWidgetState } Widget _tagsArea(BuildContext context) { - Color selectedTagTitleColor = widget.tagPickerBean!.selectedTagTitleColor ?? + Color selectedTagTitleColor = widget.tagPickerBean?.selectedTagTitleColor ?? BrnThemeConfigurator.instance.getConfig().commonConfig.brandPrimary; - Color tagTitleColor = widget.tagPickerBean!.tagTitleColor ?? + Color tagTitleColor = widget.tagPickerBean?.tagTitleColor ?? BrnThemeConfigurator.instance .getConfig() .commonConfig .colorTextImportant; Color tagBackgroundColor = - widget.tagPickerBean!.tagBackgroundColor ?? Color(0xffF8F8F8); + widget.tagPickerBean?.tagBackgroundColor ?? Color(0xffF8F8F8); Color selectedTagBackgroundColor = - widget.tagPickerBean!.selectedTagBackgroundColor ?? + widget.tagPickerBean?.selectedTagBackgroundColor ?? BrnThemeConfigurator.instance .getConfig() .commonConfig @@ -351,7 +354,7 @@ class _BrnSelectTagsWithInputPickerWidgetState void _clickTag(bool selected, BrnTagInputItemBean tagName) { if (selected) { - if (!widget.multiSelect!) { + if (!widget.multiSelect) { this._selectedTags.forEach((tagItem) { tagItem.isSelect = false; }); @@ -451,12 +454,20 @@ class _BrnSelectTagsWithInputPickerWidgetState } bool isCommitBtnEnable() { + bool needExpend = false; + for (int i = 0; i < this._selectedTags.length; i++) { + BrnTagInputItemBean brnTagInputItemBean = this._selectedTags[i]; + if (true == brnTagInputItemBean.needExpend) { + needExpend = true; + break; + } + } return this._selectedTags.length > 0 && - (isShowTextInput() ? _textEditingController!.text.length > 0 : true); + (needExpend ? _textEditingController!.text.length > 0 : true); } bool isShowTextInput() { - if (widget.forceShowTextInput!) { + if (widget.forceShowTextInput) { return true; } for (int i = 0; i < this._selectedTags.length; i++) { @@ -476,7 +487,7 @@ class _BrnSelectTagsWithInputPickerWidgetState /// 数据源 class BrnTagInputItemBean { /// 标签展示的文案 - String? name; + String name; ///选中状态 bool isSelect; @@ -491,7 +502,7 @@ class BrnTagInputItemBean { Map? ext; BrnTagInputItemBean({ - this.name, + this.name = '', this.isSelect = false, this.index, this.needExpend = false, diff --git a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart index 4c87d871..4ee900f6 100644 --- a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart +++ b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart @@ -20,7 +20,7 @@ class BrnPickerEntity { type; //类型 目前支持的类型有不限(unlimit)、单选(radio)、复选(checkbox), 最终被解析成 PickerFilterType 类型 String? key; //回传给服务器 String? value; //回传给服务器 - String? name; //显示的文案 + String name; //显示的文案 String? defaultValue; List children; //下级筛选项 Map? extMap; //扩展字段,目前只有min和max @@ -35,7 +35,7 @@ class BrnPickerEntity { this.key, this.value, this.defaultValue, - this.name, + this.name = '', this.children = const [], this.isSelected = false, this.extMap, diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart index 3679739f..946b6180 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart @@ -23,7 +23,7 @@ class BrnMultiColumnListWidget extends StatefulWidget { Color selectedColor; Color? backgroundColor; Color? selectedBackgroundColor; - int? flex; + int flex; BrnOnEntityTap? singleListItemPick; int? currentListIndex; double maxHeight; @@ -36,7 +36,7 @@ class BrnMultiColumnListWidget extends StatefulWidget { this.maxHeight = 0, this.backgroundColor, this.selectedBackgroundColor, - this.flex, + this.flex = 1, this.focusedIndex, this.singleListItemPick, this.onSelectEntityInterceptor, @@ -70,7 +70,7 @@ class _BrnMultiColumnListWidgetState extends State { @override Widget build(BuildContext context) { return Expanded( - flex: widget.flex!, + flex: widget.flex, child: Container( constraints: (widget.maxHeight == 0) ? BoxConstraints.expand() diff --git a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart index 8e94c008..e745625b 100644 --- a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart +++ b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart @@ -71,7 +71,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { Container( child: Expanded( child: Text( - item.name! + _getSelectedItemCount(item), + item.name + _getSelectedItemCount(item), softWrap: true, overflow: TextOverflow.ellipsis, textAlign: TextAlign.left, diff --git a/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart b/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart index 662437ac..a9680532 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_date_picker.dart @@ -60,7 +60,7 @@ class BrnDatePicker { /// 分钟间切换的差值 int minuteDivider: 1, - DateTimePickerLocale locale = DATETIME_PICKER_LOCALE_DEFAULT, + DateTimePickerLocale locale = datetimePickerLocaleDefault, /// 时间选择组件显示的时间类型 BrnDateTimePickerMode pickerMode = BrnDateTimePickerMode.date, @@ -129,7 +129,7 @@ class _DatePickerRoute extends PopupRoute { this.initialDateTime, this.minuteDivider, this.dateFormat, - this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.locale = datetimePickerLocaleDefault, this.pickerMode = BrnDateTimePickerMode.date, this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.onCancel, @@ -267,8 +267,7 @@ class _DatePickerComponent extends StatelessWidget { builder: (BuildContext context, Widget? child) { return ClipRect( child: CustomSingleChildLayout( - delegate: _BottomPickerLayout(route.animation!.value, - contentHeight: _pickerHeight), + delegate: _BottomPickerLayout(route.animation!.value, _pickerHeight), child: BrnPickerClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(route.themeData!.cornerRadius), @@ -285,10 +284,10 @@ class _DatePickerComponent extends StatelessWidget { } class _BottomPickerLayout extends SingleChildLayoutDelegate { - _BottomPickerLayout(this.progress, {this.contentHeight}); + _BottomPickerLayout(this.progress, this.contentHeight); final double progress; - final double? contentHeight; + final double contentHeight; @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { @@ -296,7 +295,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, - maxHeight: contentHeight!, + maxHeight: contentHeight, ); } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart index 1374a0ec..b7f6622a 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart @@ -26,7 +26,7 @@ class BrnDateWidget extends StatefulWidget { this.maxDateTime, this.initialDateTime, this.dateFormat = datetimePickerDateFormat, - this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.locale = datetimePickerLocaleDefault, this.pickerTitleConfig= BrnPickerTitleConfig.Default, this.onCancel, this.onChange, diff --git a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart index 17c748f3..010a35dd 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart @@ -22,7 +22,7 @@ class BrnDateTimeWidget extends StatefulWidget { this.maxDateTime, this.initDateTime, this.dateFormat: datetimePickerTimeFormat, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.locale: datetimePickerLocaleDefault, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.onCancel, this.onChange, diff --git a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart index 97c9de76..314b6312 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart @@ -23,7 +23,7 @@ class BrnTimeWidget extends StatefulWidget { this.maxDateTime, this.initDateTime, this.dateFormat: datetimePickerTimeFormat, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.locale: datetimePickerLocaleDefault, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.minuteDivider = 1, this.onCancel, @@ -68,7 +68,7 @@ class _BrnTimeWidgetState extends State { _secondScrollCtrl; late Map _scrollCtrlMap; - late Map?> _valueRangeMap; + late Map> _valueRangeMap; bool _isChangeTimeRange = false; diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart index 69d5738b..023aa757 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_picker.dart @@ -44,11 +44,11 @@ class BrnDateRangePicker { DateTime? initialEndDateTime, String? dateFormat, int minuteDivider = 1, - DateTimePickerLocale locale = DATETIME_PICKER_LOCALE_DEFAULT, + DateTimePickerLocale locale = datetimePickerLocaleDefault, BrnDateTimeRangePickerMode pickerMode = BrnDateTimeRangePickerMode.date, BrnPickerTitleConfig pickerTitleConfig = BrnPickerTitleConfig.Default, DateVoidCallback? onCancel, - required DateVoidCallback? onClose, + DateVoidCallback? onClose, DateRangeValueCallback? onChange, DateRangeValueCallback? onConfirm, BrnPickerConfig? themeData, @@ -121,7 +121,7 @@ class _DatePickerRoute extends PopupRoute { this.initialEndDateTime, this.minuteDivider = 1, this.dateFormat, - this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.locale = datetimePickerLocaleDefault, this.pickerMode = BrnDateTimeRangePickerMode.date, this.pickerTitleConfig = BrnPickerTitleConfig.Default, this.onCancel, @@ -236,8 +236,7 @@ class _DatePickerComponent extends StatelessWidget { builder: (BuildContext context, Widget? child) { return ClipRect( child: CustomSingleChildLayout( - delegate: _BottomPickerLayout(route.animation!.value, - contentHeight: _pickerHeight), + delegate: _BottomPickerLayout(route.animation!.value, _pickerHeight), child: BrnPickerClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(route.themeData!.cornerRadius), @@ -254,10 +253,10 @@ class _DatePickerComponent extends StatelessWidget { } class _BottomPickerLayout extends SingleChildLayoutDelegate { - _BottomPickerLayout(this.progress, {this.contentHeight}); + _BottomPickerLayout(this.progress, this.contentHeight); final double progress; - final double? contentHeight; + final double contentHeight; @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { @@ -265,7 +264,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, - maxHeight: contentHeight!, + maxHeight: contentHeight, ); } diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart index 8ab6b5bf..97a46047 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart @@ -43,7 +43,7 @@ class BrnDateRangeSideWidget extends StatefulWidget { this.maxDateTime, this.initialStartDateTime, this.dateFormat = datetimeRangePickerDateFormat, - this.locale = DATETIME_PICKER_LOCALE_DEFAULT, + this.locale = datetimePickerLocaleDefault, this.onInitSelectChange, this.onChange, }) : super(key: key) { @@ -74,7 +74,7 @@ class _DatePickerWidgetState extends State { _dayScrollCtrl; late Map _scrollCtrlMap; - late Map?> _valueRangeMap; + late Map> _valueRangeMap; bool _isChangeDateRange = false; diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart index 98f5fdb3..e5f311b1 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_widget.dart @@ -55,7 +55,7 @@ class BrnDateRangeWidget extends StatefulWidget { this.initialStartDateTime, this.initialEndDateTime, this.dateFormat: datetimeRangePickerDateFormat, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.locale: datetimePickerLocaleDefault, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.onCancel, this.onChange, diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart index 88cd5ebb..79112dde 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_side_widget.dart @@ -44,7 +44,7 @@ class BrnTimeRangeSideWidget extends StatefulWidget { this.maxDateTime, this.initialStartDateTime, this.dateFormat: datetimeRangePickerTimeFormat, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.locale: datetimePickerLocaleDefault, this.minuteDivider = 1, this.onChange, this.onInitSelectChange, @@ -118,18 +118,18 @@ class _TimePickerWidgetState extends State { this._minuteDivider = minuteDivider; } - // limit the range of hour - this._hourRange = _calcHourRange(); - this._minuteRange = _calcMinuteRange(); - this._currStartHour = initStartTime.hour; + this._hourRange = _calcHourRange(); this._currStartHour = min(max(_hourRange.first, _currStartHour), _hourRange.last); this._currStartMinute = initStartTime.minute; + this._minuteRange = _calcMinuteRange(); this._currStartMinute = min(max(_minuteRange.first, _currStartMinute), _minuteRange.last); _currStartMinute -= _currStartMinute % _minuteDivider; + + _onInitSelectedChange(); // create scroll controller _startHourScrollCtrl = FixedExtentScrollController( diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart index 9ce1ed76..241b48c9 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_time_range_widget.dart @@ -63,7 +63,7 @@ class BrnTimeRangeWidget extends StatefulWidget { this.initialStartDateTime, this.initialEndDateTime, this.dateFormat: datetimeRangePickerTimeFormat, - this.locale: DATETIME_PICKER_LOCALE_DEFAULT, + this.locale: datetimePickerLocaleDefault, this.pickerTitleConfig: BrnPickerTitleConfig.Default, this.minuteDivider = 1, this.onCancel, @@ -139,24 +139,20 @@ class _TimePickerWidgetState extends State { } this._currStartHour = initStartTime.hour; - this._currStartMinute = initStartTime.minute; - - this._currEndHour = initEndTime.hour; - this._currEndMinute = initEndTime.minute; - - // limit the range of hour this._hourRange = _calcHourRange(); - this._minuteRange = _calcMinuteRange(); - this._currStartHour = min(max(_hourRange.first, _currStartHour), _hourRange.last); - this._currEndHour = min(_currEndHour, _hourRange.last); - // limit the range of minute + this._currStartMinute = initStartTime.minute; + this._minuteRange = _calcMinuteRange(); this._currStartMinute = min(max(_minuteRange.first, _currStartMinute), _minuteRange.last); _currStartMinute -= _currStartMinute % _minuteDivider; + this._currEndHour = initEndTime.hour; + this._currEndHour = min(_currEndHour, _hourRange.last); + + this._currEndMinute = initEndTime.minute; this._currEndMinute = min(_currEndMinute, _minuteRange.last); _currEndMinute -= _currEndMinute % _minuteDivider; @@ -351,7 +347,7 @@ class _TimePickerWidgetState extends State { alignment: Alignment.center, child: Text( "至", - style: widget.themeData!.itemTextStyle as TextStyle? ?? pickerItemTextStyle, + style: widget.themeData!.itemTextStyle.generateTextStyle(), ), ); }, diff --git a/lib/src/utils/i18n/brn_date_picker_i18n.dart b/lib/src/utils/i18n/brn_date_picker_i18n.dart index b8180a0a..0d90a097 100755 --- a/lib/src/utils/i18n/brn_date_picker_i18n.dart +++ b/lib/src/utils/i18n/brn_date_picker_i18n.dart @@ -63,7 +63,7 @@ enum DateTimePickerLocale { } /// Default value of date locale -const DateTimePickerLocale DATETIME_PICKER_LOCALE_DEFAULT = +const DateTimePickerLocale datetimePickerLocaleDefault = DateTimePickerLocale.zh_cn; const Map datePickerI18n = { @@ -76,28 +76,28 @@ class DatePickerI18n { /// Get done button text static String getLocaleDone(DateTimePickerLocale locale) { final _StringsI18n? i18n = datePickerI18n[locale] ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]; + datePickerI18n[datetimePickerLocaleDefault]; return i18n?.getDoneText() ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]!.getDoneText(); + datePickerI18n[datetimePickerLocaleDefault]!.getDoneText(); } /// Get cancel button text static String getLocaleCancel(DateTimePickerLocale locale) { final _StringsI18n? i18n = datePickerI18n[locale] ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]; + datePickerI18n[datetimePickerLocaleDefault]; return i18n?.getCancelText() ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]!.getCancelText(); + datePickerI18n[datetimePickerLocaleDefault]!.getCancelText(); } /// Get locale month array static List getLocaleMonths(DateTimePickerLocale locale) { final _StringsI18n? i18n = datePickerI18n[locale] ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]; + datePickerI18n[datetimePickerLocaleDefault]; final List? months = i18n?.getMonths(); if (months != null && months.isNotEmpty) { return months; } - return datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]!.getMonths(); + return datePickerI18n[datetimePickerLocaleDefault]!.getMonths(); } /// Get locale week array @@ -106,13 +106,13 @@ class DatePickerI18n { bool isFull = true, ]) { final _StringsI18n? i18n = datePickerI18n[locale] ?? - datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]; + datePickerI18n[datetimePickerLocaleDefault]; if (isFull) { final List? weeks = i18n?.getWeeksFull(); if (weeks != null && weeks.isNotEmpty) { return weeks; } - return datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]!.getWeeksFull(); + return datePickerI18n[datetimePickerLocaleDefault]!.getWeeksFull(); } final List? weeks = i18n?.getWeeksShort(); @@ -126,6 +126,6 @@ class DatePickerI18n { .map((item) => item.substring(0, math.min(3, item.length))) .toList(); } - return datePickerI18n[DATETIME_PICKER_LOCALE_DEFAULT]!.getWeeksShort(); + return datePickerI18n[datetimePickerLocaleDefault]!.getWeeksShort(); } } From a23e20163da02fb9c0c944a24fa2b515cf761f77 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 26 Jan 2022 11:03:55 +0800 Subject: [PATCH 21/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dlist=E6=B2=A1?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=B3=9B=E5=9E=8B=E5=8F=8Aif=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/picker/brn_mulit_select_tags_picker.dart | 8 ++++---- .../picker/multi_range_picker/brn_multi_column_list.dart | 2 +- .../multi_range_picker/brn_multi_column_picker_util.dart | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/components/picker/brn_mulit_select_tags_picker.dart b/lib/src/components/picker/brn_mulit_select_tags_picker.dart index 8f501f3c..d222640d 100644 --- a/lib/src/components/picker/brn_mulit_select_tags_picker.dart +++ b/lib/src/components/picker/brn_mulit_select_tags_picker.dart @@ -85,8 +85,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { final double itemHeight; /// 操作类型属性 - late List _selectedTags; - late List _sourceTags; + late List _selectedTags; + late List _sourceTags; @override void show() { @@ -282,8 +282,8 @@ class BrnMultiSelectTagsPicker extends CommonTagsPicker { } void _dataSetup() { - List tagItems = []; - List tagSelectItems = []; + List tagItems = []; + List tagSelectItems = []; for (BrnTagItemBean item in this.tagPickerConfig.tagItemSource) { tagItems.add(item); //选中的按钮 diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart index 946b6180..5a10b95f 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart @@ -36,7 +36,7 @@ class BrnMultiColumnListWidget extends StatefulWidget { this.maxHeight = 0, this.backgroundColor, this.selectedBackgroundColor, - this.flex = 1, + required this.flex, this.focusedIndex, this.singleListItemPick, this.onSelectEntityInterceptor, diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart index 84278352..03a0d5d7 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker_util.dart @@ -49,8 +49,8 @@ class BrnMultiColumnPickerUtil { /// !!! 在设置 isSelected = true之前进行 check。 /// 返回 true 符合条件,false 不符合条件 static bool isSelectedCountExceed(BrnPickerEntity? entity) { - if (entity == null && entity?.parent == null) return false; - return entity!.parent!.getSelectedChildCount() < + if (entity == null || entity.parent == null) return false; + return entity.parent!.getSelectedChildCount() < entity.parent!.maxSelectedCount; } } From 33ed04af205e75163188f11fb201811822dcf280 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 26 Jan 2022 11:55:02 +0800 Subject: [PATCH 22/31] fix:migrate dashed line to null safty --- .../components/line/dashed_line_example.dart | 4 +- lib/src/components/line/brn_dashed_line.dart | 98 +++++++++---------- 2 files changed, 48 insertions(+), 54 deletions(-) diff --git a/example/lib/sample/components/line/dashed_line_example.dart b/example/lib/sample/components/line/dashed_line_example.dart index f3d738c7..f5021e53 100644 --- a/example/lib/sample/components/line/dashed_line_example.dart +++ b/example/lib/sample/components/line/dashed_line_example.dart @@ -35,7 +35,7 @@ class _DashedLineExampleState extends State { axis: Axis.vertical, color: Colors.red, dashedOffset: 20, - position: BrnDashedLinePosition.DashedLineLeading, + position: BrnDashedLinePosition.leading, contentWidget: Container( margin: EdgeInsets.only(left: 60, right: 20, top: 10, bottom: 10), child: @@ -56,7 +56,7 @@ class _DashedLineExampleState extends State { axis: Axis.horizontal, color: Colors.green, dashedOffset: 20, - position: BrnDashedLinePosition.DashedLineLeading, + position: BrnDashedLinePosition.leading, contentWidget: Container( width: 200, height: 100, diff --git a/lib/src/components/line/brn_dashed_line.dart b/lib/src/components/line/brn_dashed_line.dart index 427f122e..c7a2abe4 100644 --- a/lib/src/components/line/brn_dashed_line.dart +++ b/lib/src/components/line/brn_dashed_line.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/material.dart'; @@ -13,33 +11,29 @@ import 'package:flutter/material.dart'; /// 分割线所在位置 enum BrnDashedLinePosition { /// 头部 - DashedLineTrailing, + trailing, /// 尾部 - DashedLineLeading, + leading, } -/// 虚线分割线 -class BrnDashedLine extends StatelessWidget { - /// 默认虚线方向 - static const Axis _normalAxis = Axis.horizontal; +/// 默认虚线方向 +const Axis _normalAxis = Axis.horizontal; - /// 默认虚线长度 - static const double _normalDashedLength = 8; +/// 默认虚线长度 +const double _normalDashedLength = 8; - /// 默认虚线厚度 - static const double _normalDashedThickness = 1; +/// 默认虚线厚度 +const double _normalDashedThickness = 1; - /// 默认间距 - static const double _normalDashedSpacing = 4; +/// 默认间距 +const double _normalDashedSpacing = 4; - /// 默认颜色 - static Color _normalColor = - BrnThemeConfigurator.instance.getConfig().commonConfig.dividerColorBase; +/// 默认位置,头部 +const BrnDashedLinePosition _normalPosition = BrnDashedLinePosition.leading; - /// 默认位置,头部 - static const BrnDashedLinePosition _normalPosition = - BrnDashedLinePosition.DashedLineLeading; +/// 虚线分割线 +class BrnDashedLine extends StatelessWidget { /// 虚线方向,默认值[_normalAxis] final Axis axis; @@ -54,7 +48,7 @@ class BrnDashedLine extends StatelessWidget { final double dashedSpacing; /// 颜色,默认值[_normalColor] - final Color color; + final Color? color; /// 虚线的Widget final Widget contentWidget; @@ -66,28 +60,28 @@ class BrnDashedLine extends StatelessWidget { final BrnDashedLinePosition position; BrnDashedLine({ - Key key, - @required this.contentWidget, - this.axis, - this.dashedLength, - this.dashedThickness, - this.dashedSpacing, + Key? key, + required this.contentWidget, + this.axis = _normalAxis, + this.dashedLength = _normalDashedLength, + this.dashedThickness = _normalDashedThickness, + this.dashedSpacing = _normalDashedSpacing, this.color, - this.dashedOffset, - this.position, + this.dashedOffset = 0.0, + this.position = _normalPosition, }); @override Widget build(BuildContext context) { return CustomPaint( painter: BrnDashedPainter( - axis: this.axis ?? _normalAxis, - dashedLength: this.dashedLength ?? _normalDashedLength, - dashedThickness: this.dashedThickness ?? _normalDashedThickness, - dashedSpacing: this.dashedSpacing ?? _normalDashedSpacing, - color: this.color ?? _normalColor, - dashedOffset: this.dashedOffset ?? 0, - position: this.position ?? _normalPosition), + axis: this.axis, + dashedLength: this.dashedLength , + dashedThickness: this.dashedThickness, + dashedSpacing: this.dashedSpacing , + color: this.color , + dashedOffset: this.dashedOffset, + position: this.position), child: this.contentWidget, ); } @@ -107,22 +101,22 @@ class BrnDashedPainter extends CustomPainter { final double dashedSpacing; /// 颜色 - final Color color; + final Color? color; /// 距离边缘的位置 - final double dashedOffset; + final double? dashedOffset; /// 分割线所在位置 - final BrnDashedLinePosition position; + final BrnDashedLinePosition? position; BrnDashedPainter({ - this.axis, - this.dashedLength, - this.dashedThickness, - this.dashedSpacing, + this.axis = _normalAxis, + this.dashedLength = _normalDashedLength, + this.dashedThickness = _normalDashedThickness, + this.dashedSpacing = _normalDashedSpacing, this.color, - this.dashedOffset, - this.position, + this.dashedOffset = 0.0, + this.position = _normalPosition, }); @override @@ -130,7 +124,7 @@ class BrnDashedPainter extends CustomPainter { var paint = Paint() // 创建一个画笔并配置其属性 ..strokeWidth = this.dashedThickness // 画笔的宽度 ..isAntiAlias = true // 是否抗锯齿 - ..color = this.color; // 画笔颜色 + ..color = this.color?? BrnThemeConfigurator.instance.getConfig().commonConfig.dividerColorBase; // 画笔颜色 var maxWidth = size.width; // size获取到宽度 var maxHeight = size.height; // size获取到宽度 @@ -139,12 +133,12 @@ class BrnDashedPainter extends CustomPainter { double startX = 0; final space = (this.dashedSpacing + this.dashedLength); double height = 0; - if (this.position == BrnDashedLinePosition.DashedLineLeading) { + if (this.position == BrnDashedLinePosition.leading) { // 头部 - height = dashedOffset + this.dashedThickness / 2; + height = dashedOffset! + this.dashedThickness / 2; } else { // 尾部 - height = size.height - dashedOffset - this.dashedThickness / 2; + height = size.height - dashedOffset! - this.dashedThickness / 2; } while (startX < maxWidth) { if ((maxWidth - startX) < this.dashedLength) { @@ -161,12 +155,12 @@ class BrnDashedPainter extends CustomPainter { double startY = 0; final space = (this.dashedSpacing + this.dashedLength); double width = 0; - if (this.position == BrnDashedLinePosition.DashedLineLeading) { + if (this.position == BrnDashedLinePosition.leading) { // 头部 - width = dashedOffset + this.dashedThickness / 2; + width = dashedOffset! + this.dashedThickness / 2; } else { // 尾部 - width = size.width - dashedOffset - this.dashedThickness / 2; + width = size.width - dashedOffset! - this.dashedThickness / 2; } while (startY < maxHeight) { if ((maxHeight - startY) < this.dashedLength) { From 069436d4ddac49a6c6b45294da21afa853d79eb5 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 26 Jan 2022 18:17:17 +0800 Subject: [PATCH 23/31] migrate example to null safty --- example/lib/main.dart | 2 +- .../actionsheet/actionsheet_entry_page.dart | 28 ++++---- ...ionsheet_selected_list_custom_example.dart | 16 ++--- .../actionsheet_selected_list_example.dart | 23 +++--- .../bottom_tabbar/bottom_tabbar_example.dart | 12 +--- .../components/button/big_fu_example.dart | 2 +- .../components/button/big_ghost_example.dart | 2 +- .../components/button/big_main_example.dart | 2 +- .../button/big_outline_example.dart | 2 +- .../button/bottom_button_entry_page.dart | 2 +- .../button/brn_small_outline_example.dart | 2 +- .../button/brn_text_button_panel_example.dart | 2 +- .../components/button/button_entry_page.dart | 2 +- .../button/button_panel_entry_page.dart | 2 +- .../button/button_panel_example.dart | 2 +- .../button/common_collection_example.dart | 2 +- .../button/icon_button_example.dart | 2 +- .../button/selection_collection_example.dart | 8 +-- .../components/button/small_main_example.dart | 2 +- .../calendar/calendarview_example.dart | 2 +- .../components/card/brn_shadow_example.dart | 10 +-- .../bubble/brn_expanded_bubble_example.dart | 4 +- .../card/bubble/bubble_entry_page.dart | 2 +- .../card/bubble/common_bubble_example.dart | 2 +- .../content/brn_two_rich_content_example.dart | 6 +- .../content/brn_two_text_content_example.dart | 2 +- .../keyvalue_align_content_example.dart | 14 ++-- .../keyvalue_close_content_example.dart | 8 +-- .../card/content/number_item_example.dart | 4 +- .../card/content/text_content_entry_page.dart | 2 +- .../content/text_value_arrow_example.dart | 6 +- .../card_title/brn_action_title_example.dart | 2 +- .../card_title/brn_common_title_example.dart | 2 +- .../components/card_title/title_example.dart | 2 +- .../charts/chart_entry_example.dart | 70 +++++++++---------- .../charts/doughnut_chart_example.dart | 8 +-- .../charts/line/brn_broken_line_example.dart | 42 +++++------ .../charts/line/db_data_node_model.dart | 31 ++++---- .../charts/progress_bar_chart_example.dart | 2 +- .../charts/progress_chart_entry_page.dart | 2 +- .../components/dialog/dialog_entry_page.dart | 22 +++--- .../components/empty/abnormal_entry_page.dart | 2 +- .../empty/abnormal_state_example.dart | 8 +-- .../form/all_item_style_example.dart | 2 +- .../form/form_item_entry_example.dart | 2 +- .../components/form/form_page_example.dart | 19 ++--- .../expansion_group_example.dart | 2 +- .../form/group_example/group_add_example.dart | 2 +- .../group_example/normal_group_example.dart | 2 +- .../items_example/base_title_example.dart | 2 +- .../items_example/multi_choice_example.dart | 14 ++-- .../multi_choice_protrait_example.dart | 14 ++-- .../items_example/radio_input_example.dart | 2 +- .../items_example/radio_protrait_example.dart | 2 +- .../items_example/range_input_example.dart | 2 +- .../items_example/ratio_input_example.dart | 2 +- .../select_all_title_example.dart | 2 +- .../form/items_example/star_example.dart | 2 +- .../items_example/step_input_example.dart | 2 +- .../text_block_input_example.dart | 2 +- .../items_example/text_input_example.dart | 2 +- .../text_quick_select_input_example.dart | 10 +-- .../items_example/text_select_example.dart | 2 +- .../form/items_example/title_example.dart | 2 +- .../items_example/title_select_example.dart | 4 +- .../gallery/gallery_detail_example.dart | 12 ++-- .../gallery_detail_page_theme_example.dart | 2 +- .../components/gallery/gallery_example.dart | 2 +- .../components/guide/force_guide_example.dart | 6 +- .../components/guide/guide_entry_page.dart | 2 +- .../components/guide/soft_intro_example.dart | 6 +- .../components/input/input_example.dart | 8 +-- .../components/line/dashed_line_example.dart | 7 +- .../loading/loading_widget_example.dart | 2 +- .../components/navbar/appbar_entry_page.dart | 2 +- .../navbar/nav_bar_example_page.dart | 46 ++++++------ .../noticebar/brn_notice_bar_example.dart | 2 +- .../noticebar/notice_bar_example.dart | 2 +- .../notice_bar_with_button_example.dart | 2 +- .../picker/cutomer_bottom_picker_example.dart | 2 +- .../picker/date_picker_example.dart | 2 +- .../picker/multi_picker_example.dart | 10 +-- .../components/picker/picker_entry_page.dart | 44 ++++++------ .../popup/overlay_window_example.dart | 10 +-- .../components/popup/popwindow_example.dart | 42 +++++------ .../components/rating/rating_example.dart | 2 +- .../scroll_actor_tab_example.dart | 2 +- .../selectcity/selected_city_example.dart | 10 +-- .../components/selection/filter_entity.dart | 12 ++-- .../flat_selection_five_tags_example.dart | 16 ++--- .../flat_selection_four_tags_example.dart | 14 ++-- .../flat_selection_three_tags_example.dart | 14 ++-- .../selection/selection_entry_page.dart | 20 +++--- .../selection/selection_flat_entry_page.dart | 8 +-- ...ionview_custom_floating_layer_example.dart | 16 ++--- ...view_customhandle_filter_example_page.dart | 8 +-- ...selectionview_customview_example_page.dart | 34 ++++----- ...electionview_date_filter_example_page.dart | 4 +- ...selectionview_date_range_example_page.dart | 14 ++-- .../selectionview_interceptor_example.dart | 24 +++---- ...view_limit_max_selected_count_example.dart | 10 +-- ...electionview_more_filter_example_page.dart | 6 +- ...selectionview_multi_list_example_page.dart | 8 +-- ...electionview_multi_range_example_page.dart | 10 +-- ...nview_simple_multi_check_example_page.dart | 4 +- ...nview_simple_single_list_example_page.dart | 4 +- .../sample/components/step/step_example.dart | 2 +- .../components/step/step_line_example.dart | 6 +- .../components/switch/checkbox_example.dart | 2 +- .../components/switch/radio_example.dart | 2 +- .../tabbar/brn_switch_title_example.dart | 4 +- .../components/tabbar/brn_tab_example.dart | 30 ++++---- .../tabbar/brn_tabbar_sticky_example.dart | 22 +++--- .../tabbar/sub_switch_title_example.dart | 4 +- .../components/tag/border_tag_example.dart | 2 +- .../components/tag/custom_tag_example.dart | 2 +- .../components/tag/delete_tag_example.dart | 47 ++++++++----- .../components/tag/select_tag_example.dart | 2 +- .../components/tag/state_tag_example.dart | 2 +- .../sample/components/tag/tag_example.dart | 2 +- .../components/tag/tag_row_example.dart | 2 +- .../components/toast/toast_example.dart | 2 +- example/lib/sample/home/card_data_config.dart | 28 ++++---- .../home/expandable_container_widget.dart | 57 ++++++++------- example/lib/sample/home/group_card.dart | 37 +++++----- example/lib/sample/home/home.dart | 2 +- example/lib/sample/home/list_item.dart | 14 ++-- .../lib/sample/theme/config_test_utils.dart | 2 +- 128 files changed, 592 insertions(+), 597 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 29d67303..dff77517 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:example/sample/home/home.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/actionsheet/actionsheet_entry_page.dart b/example/lib/sample/components/actionsheet/actionsheet_entry_page.dart index 315d7668..25b1c8c6 100644 --- a/example/lib/sample/components/actionsheet/actionsheet_entry_page.dart +++ b/example/lib/sample/components/actionsheet/actionsheet_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:async'; @@ -123,7 +123,7 @@ class _ActionSheetEntryPageState extends State { } void _showCommonStyle(BuildContext context) { - List actions = List(); + List actions = []; actions.add(BrnCommonActionSheetItem( '选项一(警示项)', desc: '辅助信息辅助信息辅助信息', @@ -158,7 +158,7 @@ class _ActionSheetEntryPageState extends State { } void _showCommonStylex(){ - List actions = List(); + List actions = []; // 构建标题+辅助信息的普通项 actions.add(BrnCommonActionSheetItem( '选项一(警示项)', @@ -193,7 +193,7 @@ class _ActionSheetEntryPageState extends State { } void _showCommonStyle1(BuildContext context) { - List actions = List(); + List actions = []; actions.add(BrnCommonActionSheetItem( '选项一(警示项)', actionStyle: BrnCommonActionSheetItemStyle.alert, @@ -226,7 +226,7 @@ class _ActionSheetEntryPageState extends State { } void _showCommonStyle2(BuildContext context) { - List actions = List(); + List actions = []; actions.add(BrnCommonActionSheetItem( '选项一: (010)1234567', actionStyle: BrnCommonActionSheetItemStyle.link, @@ -260,7 +260,7 @@ class _ActionSheetEntryPageState extends State { } void _showCommonCustomStyle(BuildContext context) { - List actions = List(); + List actions =[]; actions.add( BrnCommonActionSheetItem( '选项一: 自定义主标题样式', @@ -334,8 +334,8 @@ class _ActionSheetEntryPageState extends State { // 用于控制timer只加载一次 var started = false; // 计时器 - Timer periodTimer; - List actions = List(); + late Timer periodTimer; + List actions = []; actions.add(BrnCommonActionSheetItem( '倒计时:$countdown', actionStyle: BrnCommonActionSheetItemStyle.alert, @@ -393,7 +393,7 @@ class _ActionSheetEntryPageState extends State { } void _showShareSevenStyle(BuildContext context) { - List firstRowList = List(); + List firstRowList = []; firstRowList.add(BrnShareItem( BrnShareItemConstants.shareWeiXin, canClick: true, @@ -436,8 +436,8 @@ class _ActionSheetEntryPageState extends State { } void _showShareFourStyle(BuildContext context) { - List firstRowList = List(); - List secondRowList = List(); + List firstRowList = []; + List secondRowList = []; firstRowList.add(BrnShareItem( BrnShareItemConstants.shareQZone, canClick: true, @@ -490,8 +490,8 @@ class _ActionSheetEntryPageState extends State { } void _showShareThreeStyle(BuildContext context) { - List firstRowList = List(); - List secondRowList = List(); + List firstRowList = []; + List secondRowList =[]; firstRowList.add(BrnShareItem( BrnShareItemConstants.shareWeiXin, canClick: true, @@ -518,7 +518,7 @@ class _ActionSheetEntryPageState extends State { } void _showShareTwoStyle(BuildContext context) { - List firstRowList = List(); + List firstRowList = []; firstRowList.add(BrnShareItem( BrnShareItemConstants.shareWeiXin, canClick: true, diff --git a/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart b/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart index b7a0bf47..e005e45b 100644 --- a/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart +++ b/example/lib/sample/components/actionsheet/actionsheet_selected_list_custom_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -11,10 +11,10 @@ class SelectedListActionSheetCustomExamplePage extends StatefulWidget { class SelectedListActionSheetCustomExamplePageState extends State { - BrnSelectedListActionSheetController controller; + late BrnSelectedListActionSheetController controller; var _bottomActionKey = GlobalKey(); - List _data; + List? _data; @override void initState() { @@ -53,18 +53,18 @@ class SelectedListActionSheetCustomExamplePageState key: _bottomActionKey, mainButtonName: 'BrnBottomButtonPanel', mainButtonOnTap: () { - BrnToast.show('确定!sheet 的数据源长度 ${_data.length}', context); + BrnToast.show('确定!sheet 的数据源长度 ${_data!.length}', context); }, iconButtonList: [ BrnVerticalIconButton( - name: '已选(${_data.length})', + name: '已选(${_data!.length})', iconWidget: BrunoTools.getAssetImage( 'icons/grey_place_holder.png'), onTap: () { if (!controller.isHidden) { controller.dismiss(); } else { - if (_data == null || _data.length <= 0) { + if (_data == null || _data!.length <= 0) { BrnToast.show('数据为空,弹窗不展示', context); return; } @@ -72,7 +72,7 @@ class SelectedListActionSheetCustomExamplePageState context: context, isClearButtonHidden: false, isDeleteButtonHidden: true, - items: _data, + items: _data!, bottomOffset: 82, maxHeight: 400, controller: controller, @@ -102,7 +102,7 @@ class SelectedListActionSheetCustomExamplePageState cancel: '取消', confirm: '确定', onConfirm: () { setState(() {}); - _data.clear(); + _data!.clear(); }, onCancel: () {}); }) .showWithTargetKey( diff --git a/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart b/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart index efbad49b..c43d64d6 100644 --- a/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart +++ b/example/lib/sample/components/actionsheet/actionsheet_selected_list_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -10,21 +10,18 @@ class SelectedListActionSheetExamplePage extends StatefulWidget { class SelectedListActionSheetExamplePageState extends State { - BrnSelectedListActionSheetController controller; - List _data; + late BrnSelectedListActionSheetController controller; + List _data = [ + '1. 可以只指定要显示的文案,后边的 delete icon 是组件自带', + '2. delete icon 可以控制全部显示或者隐藏,但不支持某一行独立控制', + '3. 每一行的视图支持完全自定义', + '4. 如果要刷新列表,请调用 controller 调用 reloadData() 方法 ', + '5. 该例子中,点击最后一行的删除图表,可以更新当前行的文案' + ]; @override void initState() { - _data = [ - '1. 可以只指定要显示的文案,后边的 delete icon 是组件自带', - '2. delete icon 可以控制全部显示或者隐藏,但不支持某一行独立控制', - '3. 每一行的视图支持完全自定义', - '4. 如果要刷新列表,请调用 controller 调用 reloadData() 方法 ', - '5. 该例子中,点击最后一行的删除图表,可以更新当前行的文案' - ]; - controller = BrnSelectedListActionSheetController(); - super.initState(); } @@ -67,7 +64,7 @@ class SelectedListActionSheetExamplePageState if (!controller.isHidden) { controller.dismiss(); } else { - if (_data == null || _data.length <= 0) { + if ( _data.length <= 0) { BrnToast.show('数据为空,弹窗不展示', context); return; } diff --git a/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart b/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart index dc593e66..5cadf9f9 100644 --- a/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart +++ b/example/lib/sample/components/bottom_tabbar/bottom_tabbar_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -25,7 +25,7 @@ class BottomTabbarExampleState extends State with SingleTic int _selectedIndexTest3 = 0; /// 未读消息数量 - String badgeNo1; + String badgeNo1 = '100'; /// title数组 var titles = ['One', 'Two', 'Three', 'Four', 'Five', 'Six']; @@ -40,14 +40,6 @@ class BottomTabbarExampleState extends State with SingleTic Icons.star ]; - @override - void initState() { - super.initState(); - - /// 初始化某个未读消息的数量 - badgeNo1 = '100'; - } - /// 选中状态时state设置 void _onItemSelected(int index) { setState(() { diff --git a/example/lib/sample/components/button/big_fu_example.dart b/example/lib/sample/components/button/big_fu_example.dart index 95b8d02f..9ebb36ac 100644 --- a/example/lib/sample/components/button/big_fu_example.dart +++ b/example/lib/sample/components/button/big_fu_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_ghost_example.dart b/example/lib/sample/components/button/big_ghost_example.dart index 3b3d0e43..cfc433c3 100644 --- a/example/lib/sample/components/button/big_ghost_example.dart +++ b/example/lib/sample/components/button/big_ghost_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_main_example.dart b/example/lib/sample/components/button/big_main_example.dart index 250f4ce9..1eb92ddf 100644 --- a/example/lib/sample/components/button/big_main_example.dart +++ b/example/lib/sample/components/button/big_main_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/big_outline_example.dart b/example/lib/sample/components/button/big_outline_example.dart index 7adb4d96..fc901260 100644 --- a/example/lib/sample/components/button/big_outline_example.dart +++ b/example/lib/sample/components/button/big_outline_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/bottom_button_entry_page.dart b/example/lib/sample/components/button/bottom_button_entry_page.dart index ce2ef9cf..81c253ea 100644 --- a/example/lib/sample/components/button/bottom_button_entry_page.dart +++ b/example/lib/sample/components/button/bottom_button_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/common_collection_example.dart'; diff --git a/example/lib/sample/components/button/brn_small_outline_example.dart b/example/lib/sample/components/button/brn_small_outline_example.dart index 25d5fae5..6ebeb283 100644 --- a/example/lib/sample/components/button/brn_small_outline_example.dart +++ b/example/lib/sample/components/button/brn_small_outline_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/brn_text_button_panel_example.dart b/example/lib/sample/components/button/brn_text_button_panel_example.dart index 27d0ec77..cc03c07d 100644 --- a/example/lib/sample/components/button/brn_text_button_panel_example.dart +++ b/example/lib/sample/components/button/brn_text_button_panel_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/button_entry_page.dart b/example/lib/sample/components/button/button_entry_page.dart index 427d8fb4..f129d016 100644 --- a/example/lib/sample/components/button/button_entry_page.dart +++ b/example/lib/sample/components/button/button_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/big_main_example.dart'; diff --git a/example/lib/sample/components/button/button_panel_entry_page.dart b/example/lib/sample/components/button/button_panel_entry_page.dart index ad0a903d..2a1de67b 100644 --- a/example/lib/sample/components/button/button_panel_entry_page.dart +++ b/example/lib/sample/components/button/button_panel_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/button/brn_text_button_panel_example.dart'; diff --git a/example/lib/sample/components/button/button_panel_example.dart b/example/lib/sample/components/button/button_panel_example.dart index e5b139bc..026282d4 100644 --- a/example/lib/sample/components/button/button_panel_example.dart +++ b/example/lib/sample/components/button/button_panel_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/common_collection_example.dart b/example/lib/sample/components/button/common_collection_example.dart index 7591e4ea..bfa3e7a6 100644 --- a/example/lib/sample/components/button/common_collection_example.dart +++ b/example/lib/sample/components/button/common_collection_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/icon_button_example.dart b/example/lib/sample/components/button/icon_button_example.dart index bda32e1b..15e0827b 100644 --- a/example/lib/sample/components/button/icon_button_example.dart +++ b/example/lib/sample/components/button/icon_button_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/button/selection_collection_example.dart b/example/lib/sample/components/button/selection_collection_example.dart index f882204b..0ed780a3 100644 --- a/example/lib/sample/components/button/selection_collection_example.dart +++ b/example/lib/sample/components/button/selection_collection_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -9,7 +9,7 @@ class BrnSelectionBottomButtonExample extends StatefulWidget { } class _BrnSelectionBottomButtonExampleState extends State { - BrnMultipleBottomController controller; + BrnMultipleBottomController? controller; @override void initState() { @@ -55,11 +55,11 @@ class _BrnSelectionBottomButtonExampleState extends State { - int count; - - @override - void initState() { - super.initState(); - count = 0; - } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart index 5df330ba..641b72ee 100644 --- a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart +++ b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -40,7 +40,7 @@ class BrnBubbleExample2 extends StatelessWidget { maxLines: 2, text: '推荐理由:“满五唯一”“临近地铁”“首付低”,多出折行显示,文字展开的样式文式文文字展开的样式文式文。问我', onExpanded: (isExpanded){ - String str = isExpanded?"展开了":"收起了"; + String str = isExpanded!?"展开了":"收起了"; BrnToast.show("我$str", context); }, ), diff --git a/example/lib/sample/components/card/bubble/bubble_entry_page.dart b/example/lib/sample/components/card/bubble/bubble_entry_page.dart index ff6fd2d2..66346dcd 100644 --- a/example/lib/sample/components/card/bubble/bubble_entry_page.dart +++ b/example/lib/sample/components/card/bubble/bubble_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/bubble/common_bubble_example.dart'; diff --git a/example/lib/sample/components/card/bubble/common_bubble_example.dart b/example/lib/sample/components/card/bubble/common_bubble_example.dart index 5c4486b7..0468c77a 100644 --- a/example/lib/sample/components/card/bubble/common_bubble_example.dart +++ b/example/lib/sample/components/card/bubble/common_bubble_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart index 40b06a40..2fbc5f2c 100644 --- a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart +++ b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -54,11 +54,11 @@ class _BrnTwoRichContentExampleState extends State { }, clickTitle: "可点击内容", clickCallback: (value) { - BrnToast.show(value, context); + BrnToast.show(value!, context); }), BrnRichGridInfo.valueLastClickInfo('名称', '内容内容', clickTitle: "可点击内容", clickCallback: (value) { - BrnToast.show(value, context); + BrnToast.show(value!, context); }), ], ), diff --git a/example/lib/sample/components/card/content/brn_two_text_content_example.dart b/example/lib/sample/components/card/content/brn_two_text_content_example.dart index 8f1352ab..19ecbdff 100644 --- a/example/lib/sample/components/card/content/brn_two_text_content_example.dart +++ b/example/lib/sample/components/card/content/brn_two_text_content_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/card/content/keyvalue_align_content_example.dart b/example/lib/sample/components/card/content/keyvalue_align_content_example.dart index 7d8afa98..d959c039 100644 --- a/example/lib/sample/components/card/content/keyvalue_align_content_example.dart +++ b/example/lib/sample/components/card/content/keyvalue_align_content_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -11,7 +11,7 @@ class TextContentExample extends StatefulWidget { } class _TextContentExampleState extends State { - List list; + late List list; @override void initState() { @@ -25,7 +25,7 @@ class _TextContentExampleState extends State { BrnInfoModal(keyPart: "名称名称名:", valuePart: "内容内容内容内容内容"), BrnInfoModal(keyPart: "名称名称名称名称:", valuePart: "内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"), BrnInfoModal.valueLastClickInfo("名称名:", '内容内容内容内容内容', '可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }) ]; } @@ -233,7 +233,7 @@ class _TextContentExampleState extends State { keyPart: "名称名称名称名称:", valuePart: "内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"), BrnInfoModal.valueLastClickInfo("名称名:", '11111111', '22222222', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), @@ -259,7 +259,7 @@ class _TextContentExampleState extends State { keyPart: "名称名称名称名称:", valuePart: "内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"), BrnInfoModal.valueLastClickInfo("名称名:", '内容内容内容内容内容', '可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), @@ -383,7 +383,7 @@ class _TextContentExampleState extends State { BrnInfoModal(keyPart: "名称名称名:", valuePart: "内容内容内容内容内容"), BrnInfoModal.valueLastClickInfo("名称十分的长名称十分的长名称十分的长名称十分的长:", '内容内容内容内容内容', '可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), @@ -403,7 +403,7 @@ class _TextContentExampleState extends State { BrnInfoModal.valueLastClickInfo( "名称十分的长名称十分的长名称十分的长名称十分的长:", '内容内容内容内容内容', '可点击内容可点击内容可点击内容可点击内容可点击内容可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), diff --git a/example/lib/sample/components/card/content/keyvalue_close_content_example.dart b/example/lib/sample/components/card/content/keyvalue_close_content_example.dart index aa4606c9..2d6d8053 100644 --- a/example/lib/sample/components/card/content/keyvalue_close_content_example.dart +++ b/example/lib/sample/components/card/content/keyvalue_close_content_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -64,7 +64,7 @@ class _KeyTextCloseContentExampleState extends State BrnInfoModal(keyPart: "名称名称名:", valuePart: "内容内容内容内容内容"), BrnInfoModal.valueLastClickInfo("名称名:", '内容内容内容内容内容', '可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), @@ -134,12 +134,12 @@ class _KeyTextCloseContentExampleState extends State "内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内"), BrnInfoModal.valueLastClickInfo("名称十分的长名:", '内容内容内容内容内容', '可点击内容可点击内容可点击内容可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), BrnInfoModal.valueLastClickInfo( "名称十分的长名:", '内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容', '可点击内容可点击内容可点击内容可点击内容', clickCallback: (text) { - BrnToast.show(text, context); + BrnToast.show(text!, context); }), ], ), diff --git a/example/lib/sample/components/card/content/number_item_example.dart b/example/lib/sample/components/card/content/number_item_example.dart index c7e4709b..fcf2a48d 100644 --- a/example/lib/sample/components/card/content/number_item_example.dart +++ b/example/lib/sample/components/card/content/number_item_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -83,7 +83,7 @@ class _NumberItemRowExampleState extends State { lastDesc: '后', numberInfoIcon: BrnNumberInfoIcon.ARROW, iconTapCallBack: (data) { - BrnToast.show(data.title, context); + BrnToast.show(data.title!, context); }), BrnNumberInfoItemModel( title: '数字信息数字信息数字信息数字信息数字信息数字信息', diff --git a/example/lib/sample/components/card/content/text_content_entry_page.dart b/example/lib/sample/components/card/content/text_content_entry_page.dart index da1888b8..e16e0aec 100644 --- a/example/lib/sample/components/card/content/text_content_entry_page.dart +++ b/example/lib/sample/components/card/content/text_content_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/content/keyvalue_align_content_example.dart'; diff --git a/example/lib/sample/components/card/content/text_value_arrow_example.dart b/example/lib/sample/components/card/content/text_value_arrow_example.dart index 0b3b329b..e902465a 100644 --- a/example/lib/sample/components/card/content/text_value_arrow_example.dart +++ b/example/lib/sample/components/card/content/text_value_arrow_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -68,7 +68,7 @@ class _TextValueArrowContentExampleState extends State _FunnelChartExampleState(); } class _FunnelChartExampleState extends State { - double maxLayerWidth; - double minLayerWidth; - double layerMargin; - double layerHeight; - double offsetX; - double offsetY; - MarkerAlignment alignment; - FunnelShape shape; + late double maxLayerWidth; + late double minLayerWidth; + late double layerMargin; + late double layerHeight; + late double offsetX; + late double offsetY; + late MarkerAlignment alignment; + FunnelShape? shape; bool defaultStyle = false; @override @@ -361,7 +361,7 @@ class _FunnelChartExampleState extends State { padding: EdgeInsets.only(left: 20), child: Text('标签位置'), ), - FlatButton( + TextButton( onPressed: () { setState(() { alignment = MarkerAlignment.left; @@ -369,7 +369,7 @@ class _FunnelChartExampleState extends State { }, child: Text('居左'), ), - FlatButton( + TextButton( onPressed: () { setState(() { alignment = MarkerAlignment.center; @@ -377,7 +377,7 @@ class _FunnelChartExampleState extends State { }, child: Text('居中'), ), - FlatButton( + TextButton( onPressed: () { setState(() { alignment = MarkerAlignment.right; @@ -415,16 +415,16 @@ class RadarChartExample extends StatefulWidget { } class _RadarChartExampleState extends State with SingleTickerProviderStateMixin { - double radius; - int sideCount; - double angle; - double padding; + late double radius; + int? sideCount; + double? angle; + late double padding; Map> dataList1 = Map(); Map> dataList2 = Map(); - AnimationController controller; - Animation animation; + late AnimationController controller; + late Animation animation; bool defaultStyle = false; @override @@ -435,8 +435,8 @@ class _RadarChartExampleState extends State with SingleTicker padding = 4; angle = 0; for (int i = 3; i <= 8; i++) { - List data1 = List(); - List data2 = List(); + List data1 = []; + List data2 = []; for (int j = 0; j < i; j++) { data1.add(Random().nextDouble() * 10); @@ -463,18 +463,18 @@ class _RadarChartExampleState extends State with SingleTicker radius: radius, sidesCount: 5, markerMargin: padding, - rotateAngle: angle * 2 * pi / 360, - data: [dataList1[sideCount.toString()], dataList2[sideCount.toString()]], + rotateAngle: angle! * 2 * pi / 360, + data: [dataList1[sideCount.toString()]!, dataList2[sideCount.toString()]!], tagNames: ['合作共赢诚实守信', '合作共赢诚实守信', '合作共赢诚实守信', '合作共赢诚实守信', '合作共赢诚实守信'], ); } else { return BrnRadarChart( radius: radius, provider: RadarProvider(sideCount, dataList1, dataList2), - sidesCount: sideCount, + sidesCount: sideCount!, markerMargin: padding, crossedAxisLine: true, - rotateAngle: angle * 2 * pi / 360, + rotateAngle: angle! * 2 * pi / 360, animateProgress: animation.value, builder: (index) { return Text( @@ -562,7 +562,7 @@ class _RadarChartExampleState extends State with SingleTicker ), Expanded( child: Slider( - value: sideCount.toDouble(), + value: sideCount!.toDouble(), divisions: 6, onChanged: (data) { if (data.toInt() != sideCount) { @@ -579,9 +579,9 @@ class _RadarChartExampleState extends State with SingleTicker onChangeEnd: (data) { debugPrint('end:$data'); }, - min: defaultStyle ? sideCount.toDouble() : 3, - max: defaultStyle ? sideCount.toDouble() : 8, - label: '${sideCount.toStringAsFixed(0)}', + min: defaultStyle ? sideCount!.toDouble() : 3, + max: defaultStyle ? sideCount!.toDouble() : 8, + label: '${sideCount!.toStringAsFixed(0)}', activeColor: Colors.green, inactiveColor: Colors.grey, semanticFormatterCallback: (double newValue) { @@ -599,7 +599,7 @@ class _RadarChartExampleState extends State with SingleTicker ), Expanded( child: Slider( - value: angle.toDouble(), + value: angle!.toDouble(), divisions: 360, onChanged: (data) { if (data.toDouble() != angle) { @@ -618,7 +618,7 @@ class _RadarChartExampleState extends State with SingleTicker }, min: 0, max: 360, - label: '${angle.toStringAsFixed(0)}', + label: '${angle!.toStringAsFixed(0)}', activeColor: Colors.green, inactiveColor: Colors.grey, semanticFormatterCallback: (double newValue) { @@ -647,7 +647,7 @@ class RadarProvider extends BrnRadarChartDataProvider { final Map> dataList2; - final int sideCount; + final int? sideCount; RadarProvider(this.sideCount, this.dataList1, this.dataList2); @@ -688,10 +688,10 @@ class RadarProvider extends BrnRadarChartDataProvider { List getRadarValues(int radarIndex) { switch (radarIndex) { case 0: - return dataList1[sideCount.toString()]; + return dataList1[sideCount.toString()]!; case 1: - return dataList2[sideCount.toString()]; + return dataList2[sideCount.toString()]!; } - return dataList1[sideCount.toString()]; + return dataList1[sideCount.toString()]!; } } diff --git a/example/lib/sample/components/charts/doughnut_chart_example.dart b/example/lib/sample/components/charts/doughnut_chart_example.dart index e97f2e3f..b653326a 100644 --- a/example/lib/sample/components/charts/doughnut_chart_example.dart +++ b/example/lib/sample/components/charts/doughnut_chart_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -13,9 +13,9 @@ class DoughnutChartExample extends StatefulWidget { } class DoughnutChartExampleState extends State { - BrnDoughnutDataItem selectedItem; + BrnDoughnutDataItem? selectedItem; - List dataList = List(); + List dataList = []; List preinstallColors = [ Color(0xffFF862D), Color(0xff26BB7D), @@ -57,7 +57,7 @@ class DoughnutChartExampleState extends State { data: dataList, selectedItem: selectedItem, showTitleWhenSelected: true, - selectCallback: (BrnDoughnutDataItem selectedItem) { + selectCallback: (BrnDoughnutDataItem? selectedItem) { setState(() { this.selectedItem = selectedItem; }); diff --git a/example/lib/sample/components/charts/line/brn_broken_line_example.dart b/example/lib/sample/components/charts/line/brn_broken_line_example.dart index 13b8d0f4..46cce542 100644 --- a/example/lib/sample/components/charts/line/brn_broken_line_example.dart +++ b/example/lib/sample/components/charts/line/brn_broken_line_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -100,7 +100,7 @@ class _BrokenLineExampleState extends State { .map((_) => BrnPointData( pointText: _.value, x: brokenData.indexOf(_).toDouble(), - y: double.parse(_.value), + y: double.parse(_.value!), lineTouchData: BrnLineTouchData( tipWindowSize: Size(60, 40), @@ -131,17 +131,17 @@ class _BrokenLineExampleState extends State { } double _getMinValueForExample1(List brokenData) { - double minValue = double.tryParse(brokenData[0]?.value) ?? 0; + double minValue = double.tryParse(brokenData[0].value!) ?? 0; for (DBDataNodeModel point in brokenData) { - minValue = min(double.tryParse(point.value) ?? 0, minValue); + minValue = min(double.tryParse(point.value!) ?? 0, minValue); } return minValue; } double _getMaxValueForExample1(List brokenData) { - double maxValue = double.tryParse(brokenData[0]?.value) ?? 0; + double maxValue = double.tryParse(brokenData[0].value!) ?? 0; for (DBDataNodeModel point in brokenData) { - maxValue = max(double.tryParse(point.value) ?? 0, maxValue); + maxValue = max(double.tryParse(point.value!) ?? 0, maxValue); } return maxValue; } @@ -192,7 +192,7 @@ class _BrokenLineExampleState extends State { List _linesForExample2() { BrnPointsLine _pointsLine; BrnPointsLine _pointsLine1; - List pointsLineList = List(); + List pointsLineList = []; _pointsLine = BrnPointsLine( isShowPointText: true, isShowXDial: true, @@ -422,7 +422,7 @@ class _BrokenLineExampleState extends State { List _getPointsLinesForExample3() { BrnPointsLine pointsLine, _pointsLine2; - List pointsLineList = List(); + List pointsLineList = []; pointsLine = BrnPointsLine( isShowXDial: true, lineWidth: 3, @@ -488,13 +488,13 @@ class _BrokenLineExampleState extends State { ], ), ); - })), + }, tipWindowSize:Size(60, 40) )), BrnPointData( pointText: '20', y: 20, x: 3, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '20'; })), @@ -503,7 +503,7 @@ class _BrokenLineExampleState extends State { y: 67, x: 4, lineTouchData: BrnLineTouchData( - + tipWindowSize:Size(60, 40), onTouch: () { return '66'; })), @@ -663,7 +663,7 @@ class _BrokenLineExampleState extends State { y: 66, x: 8, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '66'; })), @@ -792,7 +792,7 @@ class _BrokenLineExampleState extends State { List _getPointsLinesForExample4() { BrnPointsLine pointsLine, _pointsLine2; - List pointsLineList = List(); + List pointsLineList = []; pointsLine = BrnPointsLine( isShowXDial: true, lineWidth: 3, @@ -836,7 +836,7 @@ class _BrokenLineExampleState extends State { y: 80, x: 2, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return Container( padding: EdgeInsets.only(left: 10, right: 10, top: 8, bottom: 8), @@ -864,7 +864,7 @@ class _BrokenLineExampleState extends State { y: 20, x: 3, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '20'; })), @@ -873,7 +873,7 @@ class _BrokenLineExampleState extends State { y: 67, x: 4, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '66'; })), @@ -1033,7 +1033,7 @@ class _BrokenLineExampleState extends State { y: 66, x: 8, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '66'; })), @@ -1195,7 +1195,7 @@ class _BrokenLineExampleState extends State { List _getPointsLineListWithShowPointText() { BrnPointsLine pointsLine, _pointsLine2; - List pointsLineList = List(); + List pointsLineList = []; pointsLine = BrnPointsLine( isShowXDial: true, lineWidth: 3, @@ -1249,7 +1249,7 @@ class _BrokenLineExampleState extends State { y: 80, x: 2, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return Container( padding: EdgeInsets.only(left: 10, right: 10, top: 8, bottom: 8), @@ -1287,7 +1287,7 @@ class _BrokenLineExampleState extends State { y: 67, x: 4, lineTouchData: BrnLineTouchData( - + tipWindowSize: Size(60, 40), onTouch: () { return '66'; })), @@ -1492,7 +1492,7 @@ class _BrokenLineExampleState extends State { } Widget _buildIdentificationList() { - List widgetList = List(); + List widgetList = []; for (BrnPointsLine bean in _getPointsLinesForExample3()) { Widget widget = Row(children: [ Container( diff --git a/example/lib/sample/components/charts/line/db_data_node_model.dart b/example/lib/sample/components/charts/line/db_data_node_model.dart index 93625b79..fc5928b8 100644 --- a/example/lib/sample/components/charts/line/db_data_node_model.dart +++ b/example/lib/sample/components/charts/line/db_data_node_model.dart @@ -1,36 +1,35 @@ /// @desc 看板卡片中用于描述数据指标的模型,也能用于数据块的定义,内部嵌套了一个itemList -// @dart=2.9 + class DBDataNodeModel { - String key; - String name; - String value; - String unit; - String percent; - String order; + String? key; + String? name; + String? value; + String? unit; + String? percent; + String? order; /// If tip.isNullOrEmpty == false, a question icon will be displayed on right of the label. /// A tip pop window would be displayed when icon was clicked. - String tipTitle; + String? tipTitle; - List tipList; + List? tipList; /// 1: up direction, green label, green arrow /// 0: gray label, no arrow /// -1: down direction, red label, red arrow - int trend; + int? trend; - List itemList; + List? itemList; /// section data field - String url; - DBDataNodeModel total; - + String? url; + DBDataNodeModel? total; DBDataNodeModel(); - factory DBDataNodeModel.fromJson(Map json) { - if (json == null) return null; + factory DBDataNodeModel.fromJson(Map? json) { + if (json == null) return DBDataNodeModel(); DBDataNodeModel entity = DBDataNodeModel(); entity.name = json['name'] ?? ""; entity.key = json['key'] ?? ""; diff --git a/example/lib/sample/components/charts/progress_bar_chart_example.dart b/example/lib/sample/components/charts/progress_bar_chart_example.dart index c30c8316..b0563676 100644 --- a/example/lib/sample/components/charts/progress_bar_chart_example.dart +++ b/example/lib/sample/components/charts/progress_bar_chart_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; import 'package:bruno/bruno.dart'; diff --git a/example/lib/sample/components/charts/progress_chart_entry_page.dart b/example/lib/sample/components/charts/progress_chart_entry_page.dart index db8840de..6d71c9dc 100644 --- a/example/lib/sample/components/charts/progress_chart_entry_page.dart +++ b/example/lib/sample/components/charts/progress_chart_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/dialog/dialog_entry_page.dart b/example/lib/sample/components/dialog/dialog_entry_page.dart index 189311e0..cbd2d9ca 100644 --- a/example/lib/sample/components/dialog/dialog_entry_page.dart +++ b/example/lib/sample/components/dialog/dialog_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; @@ -301,7 +301,7 @@ class DialogEntryPage extends StatelessWidget { //光标圆角弧度 cursorRadius: Radius.circular(2.0), style: TextStyle(fontSize: 14, color: Color(0xFF222222)), - maxLengthEnforced: true, + maxLengthEnforcement: MaxLengthEnforcement.enforced, onChanged: (value) {}, decoration: InputDecoration( contentPadding: EdgeInsets.all(8.0), @@ -328,7 +328,7 @@ class DialogEntryPage extends StatelessWidget { state(() {}); }, onSubmitClick: (data) { - BrnToast.show(data, context); + BrnToast.show(data!, context); }); }, )); @@ -336,7 +336,7 @@ class DialogEntryPage extends StatelessWidget { ///多选弹框 void _showMiddleMultiSelectDialog(BuildContext context) { - List data = new List(); + List data = []; data.add(new MultiSelectItem("100", "感兴趣待跟进")); data.add(new MultiSelectItem("101", "感兴趣但对本商圈没兴趣", isChecked: true)); data.add(new MultiSelectItem("102", "接通后挂断/不感兴趣", isChecked: true)); @@ -363,7 +363,7 @@ class DialogEntryPage extends StatelessWidget { void _showMiddleMultiSelectWithMessageWidgetDialog(BuildContext context) { String hintText = "感兴趣待跟进"; - List data = new List(); + List data = []; data.add(new MultiSelectItem("100", "感兴趣待跟进")); data.add(new MultiSelectItem("101", "感兴趣但对本商圈没兴趣", isChecked: true)); data.add(new MultiSelectItem("102", "接通后挂断/不感兴趣", isChecked: true)); @@ -432,7 +432,7 @@ class DialogEntryPage extends StatelessWidget { ///多选弹框 void _showMiddleMultiSelectWithMessageDialog(BuildContext context) { - List data = new List(); + List data = []; data.add(new MultiSelectItem("100", "感兴趣待跟进")); data.add(new MultiSelectItem("101", "感兴趣但对本商圈没兴趣", isChecked: true)); data.add(new MultiSelectItem("102", "接通后挂断/不感兴趣", isChecked: true)); @@ -469,7 +469,7 @@ class DialogEntryPage extends StatelessWidget { padding: const EdgeInsets.only(top: 6, left: 24, right: 24), child: BrnCSS2Text.toTextView( "这是一条增使用标签修改文字颜色的example\我是带颜色的文字," - "这是颜色标签后边的文字", linksCallback: (String text, String linkUrl) { + "这是颜色标签后边的文字", linksCallback: (String? text, String? linkUrl) { BrnToast.show('$text clicked! Url is $linkUrl', context); }), ), @@ -723,7 +723,7 @@ class DialogEntryPage extends StatelessWidget { ///对话框样式九:标准的对话框:有标题、双按钮、有警示文案和辅助信息 void _showStyle9_1Dialog(BuildContext context) { - bool status = false; + bool? status = false; BrnDialogManager.showConfirmDialog(context, title: "标题内容?", cancel: '取消', @@ -732,7 +732,7 @@ class DialogEntryPage extends StatelessWidget { return Row(children: [ Checkbox( value: status, - onChanged: (bool aaa) { + onChanged: (bool? aaa) { status = aaa; setState(() {}); }, @@ -880,8 +880,8 @@ class DialogEntryPage extends StatelessWidget { "文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文" "呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表纯本文呢表", submitText: "提交", - linksCallback: (String text, String url) { - BrnToast.show(text, context); + linksCallback: (String? text, String? url) { + BrnToast.show(text!, context); }, onSubmitClick: () { BrnToast.show("点击了纯文本弹框", context); diff --git a/example/lib/sample/components/empty/abnormal_entry_page.dart b/example/lib/sample/components/empty/abnormal_entry_page.dart index 2c39489b..3cfddc66 100644 --- a/example/lib/sample/components/empty/abnormal_entry_page.dart +++ b/example/lib/sample/components/empty/abnormal_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/empty/abnormal_state_example.dart'; diff --git a/example/lib/sample/components/empty/abnormal_state_example.dart b/example/lib/sample/components/empty/abnormal_state_example.dart index e6308d80..6cf113ca 100644 --- a/example/lib/sample/components/empty/abnormal_state_example.dart +++ b/example/lib/sample/components/empty/abnormal_state_example.dart @@ -1,10 +1,10 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class AbnomalStateExample extends StatelessWidget { - final int caseIndex; + final int? caseIndex; AbnomalStateExample({this.caseIndex}); @@ -17,8 +17,8 @@ class AbnomalStateExample extends StatelessWidget { body: _buildEmpty(caseIndex, context)); } - Widget _buildEmpty(int index, BuildContext context) { - Widget widget; + Widget? _buildEmpty(int? index, BuildContext context) { + Widget? widget; switch (index) { case 0: widget = BrnAbnormalStateWidget( diff --git a/example/lib/sample/components/form/all_item_style_example.dart b/example/lib/sample/components/form/all_item_style_example.dart index 5e02a78a..6084e42f 100644 --- a/example/lib/sample/components/form/all_item_style_example.dart +++ b/example/lib/sample/components/form/all_item_style_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/form/group_example/expansion_group_example.dart'; diff --git a/example/lib/sample/components/form/form_item_entry_example.dart b/example/lib/sample/components/form/form_item_entry_example.dart index f65383b2..d655dda2 100644 --- a/example/lib/sample/components/form/form_item_entry_example.dart +++ b/example/lib/sample/components/form/form_item_entry_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/form/all_item_style_example.dart'; diff --git a/example/lib/sample/components/form/form_page_example.dart b/example/lib/sample/components/form/form_page_example.dart index e0820de9..b55967d0 100644 --- a/example/lib/sample/components/form/form_page_example.dart +++ b/example/lib/sample/components/form/form_page_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; @@ -11,13 +11,14 @@ class FormPageExample extends StatefulWidget { } class _FormPageExampleState extends State { - List selectedOptions = List(); - String commentStr; - BrnPortraitRadioGroupOption selectedValue; + List selectedOptions = []; + String? commentStr; + late BrnPortraitRadioGroupOption selectedValue; @override void initState() { super.initState(); + selectedValue = BrnPortraitRadioGroupOption(); } @override @@ -45,10 +46,10 @@ class _FormPageExampleState extends State { '$index 不在我服务范围', '$index 其他' ], - selectedOption: selectedValue?.title, - onChanged: (BrnPortraitRadioGroupOption old, + selectedOption: selectedValue.title ?? '', + onChanged: (BrnPortraitRadioGroupOption? old, BrnPortraitRadioGroupOption newList) { - BrnToast.show(newList.title, context); + BrnToast.show(newList.title!, context); selectedValue = newList; commentStr = ''; setState(() {}); @@ -71,9 +72,9 @@ class _FormPageExampleState extends State { subTitle: 'subtitlesubtn你好 哈哈哈哈哈哈啊哈哈哈哈哈子标题哈哈哈 子标题子标题'); }), selectedOption: selectedValue, - onChanged: (BrnPortraitRadioGroupOption old, + onChanged: (BrnPortraitRadioGroupOption? old, BrnPortraitRadioGroupOption newList) { - BrnToast.show(newList.title, context); + BrnToast.show(newList.title!, context); selectedValue = newList; commentStr = ''; setState(() {}); diff --git a/example/lib/sample/components/form/group_example/expansion_group_example.dart b/example/lib/sample/components/form/group_example/expansion_group_example.dart index d4591836..9d2f2d98 100644 --- a/example/lib/sample/components/form/group_example/expansion_group_example.dart +++ b/example/lib/sample/components/form/group_example/expansion_group_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/group_example/group_add_example.dart b/example/lib/sample/components/form/group_example/group_add_example.dart index 1507f0ff..2e810ecf 100644 --- a/example/lib/sample/components/form/group_example/group_add_example.dart +++ b/example/lib/sample/components/form/group_example/group_add_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/group_example/normal_group_example.dart b/example/lib/sample/components/form/group_example/normal_group_example.dart index 705c2283..5b4b133a 100644 --- a/example/lib/sample/components/form/group_example/normal_group_example.dart +++ b/example/lib/sample/components/form/group_example/normal_group_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/base_title_example.dart b/example/lib/sample/components/form/items_example/base_title_example.dart index 03ef2f2c..b2e8b9d7 100644 --- a/example/lib/sample/components/form/items_example/base_title_example.dart +++ b/example/lib/sample/components/form/items_example/base_title_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/multi_choice_example.dart b/example/lib/sample/components/form/items_example/multi_choice_example.dart index 7930fa3e..2ba679aa 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -42,9 +42,9 @@ class MultiChoiceInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), Container( @@ -81,9 +81,9 @@ class MultiChoiceInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), Container( @@ -119,9 +119,9 @@ class MultiChoiceInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), ], diff --git a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart index 3d6667f3..f3e789b1 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -46,9 +46,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), Container( @@ -87,9 +87,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), Container( @@ -127,9 +127,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List newValue) { + onChanged: (List oldValue, List? newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); }, ), ], diff --git a/example/lib/sample/components/form/items_example/radio_input_example.dart b/example/lib/sample/components/form/items_example/radio_input_example.dart index 660138e4..e516dba3 100644 --- a/example/lib/sample/components/form/items_example/radio_input_example.dart +++ b/example/lib/sample/components/form/items_example/radio_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/radio_protrait_example.dart b/example/lib/sample/components/form/items_example/radio_protrait_example.dart index 11a29c9d..15d71f2b 100644 --- a/example/lib/sample/components/form/items_example/radio_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/radio_protrait_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/range_input_example.dart b/example/lib/sample/components/form/items_example/range_input_example.dart index e48eaa25..dc3f3bee 100644 --- a/example/lib/sample/components/form/items_example/range_input_example.dart +++ b/example/lib/sample/components/form/items_example/range_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/ratio_input_example.dart b/example/lib/sample/components/form/items_example/ratio_input_example.dart index 74027c82..d70b608a 100644 --- a/example/lib/sample/components/form/items_example/ratio_input_example.dart +++ b/example/lib/sample/components/form/items_example/ratio_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/select_all_title_example.dart b/example/lib/sample/components/form/items_example/select_all_title_example.dart index 882c4259..78507285 100644 --- a/example/lib/sample/components/form/items_example/select_all_title_example.dart +++ b/example/lib/sample/components/form/items_example/select_all_title_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/star_example.dart b/example/lib/sample/components/form/items_example/star_example.dart index 2215f140..59aa73ff 100644 --- a/example/lib/sample/components/form/items_example/star_example.dart +++ b/example/lib/sample/components/form/items_example/star_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/step_input_example.dart b/example/lib/sample/components/form/items_example/step_input_example.dart index a52ebdea..d07e7feb 100644 --- a/example/lib/sample/components/form/items_example/step_input_example.dart +++ b/example/lib/sample/components/form/items_example/step_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_block_input_example.dart b/example/lib/sample/components/form/items_example/text_block_input_example.dart index f15273f3..81685dc1 100644 --- a/example/lib/sample/components/form/items_example/text_block_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_block_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_input_example.dart b/example/lib/sample/components/form/items_example/text_input_example.dart index f55b432e..08dfe421 100644 --- a/example/lib/sample/components/form/items_example/text_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart index 2e1a9358..4666fa35 100644 --- a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -21,8 +21,8 @@ class _TextQuickSelectInputExamplePageState String selectedStr = ''; String selectedStrAllFunctionExample = ''; List options = ['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7']; - List status; - List statusAllFunctionExample; + late List status; + List? statusAllFunctionExample; _TextQuickSelectInputExamplePageState(this._title); @@ -105,8 +105,8 @@ class _TextQuickSelectInputExamplePageState subTitle: "这里是副标题", tipLabel: "标签", onBtnSelectChanged: (index) { - statusAllFunctionExample[index] = !statusAllFunctionExample[index]; - if (statusAllFunctionExample[index]) { + statusAllFunctionExample![index] = !statusAllFunctionExample![index]; + if (statusAllFunctionExample![index]) { selectedStrAllFunctionExample += '${options[index]} '; } else if (selectedStrAllFunctionExample.contains(options[index])) { selectedStrAllFunctionExample = selectedStrAllFunctionExample.replaceFirst('${options[index]} ', ''); diff --git a/example/lib/sample/components/form/items_example/text_select_example.dart b/example/lib/sample/components/form/items_example/text_select_example.dart index 7ddf1f66..44437767 100644 --- a/example/lib/sample/components/form/items_example/text_select_example.dart +++ b/example/lib/sample/components/form/items_example/text_select_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/title_example.dart b/example/lib/sample/components/form/items_example/title_example.dart index 970f43ad..8bcd8bb2 100644 --- a/example/lib/sample/components/form/items_example/title_example.dart +++ b/example/lib/sample/components/form/items_example/title_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index b42638fc..a629dd6c 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -16,7 +16,7 @@ class TitleSelectInputExamplePage extends StatefulWidget { } class TitleSelectInputState extends State { - List _list; + late List _list; TextEditingController controller = TextEditingController()..text = '123456'; @override diff --git a/example/lib/sample/components/gallery/gallery_detail_example.dart b/example/lib/sample/components/gallery/gallery_detail_example.dart index 597679d5..1219679d 100644 --- a/example/lib/sample/components/gallery/gallery_detail_example.dart +++ b/example/lib/sample/components/gallery/gallery_detail_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; enum PhotoGalleryTheme { dark, light } class GalleryDetailExamplePage extends StatefulWidget { - final String title; + final String? title; final PhotoGalleryTheme photoGalleryTheme; GalleryDetailExamplePage({this.title, this.photoGalleryTheme = PhotoGalleryTheme.dark}); @@ -18,8 +18,8 @@ class GalleryDetailExamplePage extends StatefulWidget { } class GalleryDetailExamplePageState extends State { - List allConfig; - BrnGalleryController controller; + late List allConfig; + late BrnGalleryController controller; @override void initState() { @@ -173,8 +173,8 @@ class GalleryDetailExamplePageState extends State { BrnToast.show("点击了$i $j", context); // 移除第二组的最后一个配置,跳转到 第二组的第一张图 if (allConfig.length > 1) { - if (allConfig[1].configList.length > 0) { - allConfig[1].configList.removeLast(); + if (allConfig[1].configList!.length > 0) { + allConfig[1].configList!.removeLast(); controller.refresh(1, 0); } else { allConfig.removeAt(1); diff --git a/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart b/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart index 9c908fd7..88ea69ac 100644 --- a/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart +++ b/example/lib/sample/components/gallery/gallery_detail_page_theme_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/gallery/gallery_detail_example.dart'; diff --git a/example/lib/sample/components/gallery/gallery_example.dart b/example/lib/sample/components/gallery/gallery_example.dart index cd69afb5..b61ed858 100644 --- a/example/lib/sample/components/gallery/gallery_example.dart +++ b/example/lib/sample/components/gallery/gallery_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/gallery/gallery_detail_page_theme_example.dart'; diff --git a/example/lib/sample/components/guide/force_guide_example.dart b/example/lib/sample/components/guide/force_guide_example.dart index cac44b5b..e3e6b3c5 100644 --- a/example/lib/sample/components/guide/force_guide_example.dart +++ b/example/lib/sample/components/guide/force_guide_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:async'; import 'package:bruno/bruno.dart'; @@ -6,14 +6,14 @@ import 'package:flutter/material.dart'; /// @desc 强引导example class ForceGuideExample extends StatefulWidget { - ForceGuideExample({Key key}) : super(key: key); + ForceGuideExample({Key? key}) : super(key: key); @override _ForceGuideExampleState createState() => _ForceGuideExampleState(); } class _ForceGuideExampleState extends State { - BrnGuide intro; + late BrnGuide intro; _ForceGuideExampleState() { /// init Guide diff --git a/example/lib/sample/components/guide/guide_entry_page.dart b/example/lib/sample/components/guide/guide_entry_page.dart index 1e616ab3..f15dc4b7 100644 --- a/example/lib/sample/components/guide/guide_entry_page.dart +++ b/example/lib/sample/components/guide/guide_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/guide/force_guide_example.dart'; diff --git a/example/lib/sample/components/guide/soft_intro_example.dart b/example/lib/sample/components/guide/soft_intro_example.dart index 1853fb2a..fcb0a12f 100644 --- a/example/lib/sample/components/guide/soft_intro_example.dart +++ b/example/lib/sample/components/guide/soft_intro_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:async'; @@ -7,14 +7,14 @@ import 'package:flutter/material.dart'; /// @desc 弱引导example class SoftGuideExample extends StatefulWidget { - SoftGuideExample({Key key}) : super(key: key); + SoftGuideExample({Key? key}) : super(key: key); @override _SoftGuideExampleState createState() => _SoftGuideExampleState(); } class _SoftGuideExampleState extends State { - BrnGuide intro; + late BrnGuide intro; _SoftGuideExampleState() { /// init Guide diff --git a/example/lib/sample/components/input/input_example.dart b/example/lib/sample/components/input/input_example.dart index 04ef557a..0aceb62b 100644 --- a/example/lib/sample/components/input/input_example.dart +++ b/example/lib/sample/components/input/input_example.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class TextModel { - String text; + String? text; } class BrnInputTextExample extends StatefulWidget { @@ -48,8 +48,8 @@ class _BrnInputTextExampleState extends State { minHeight: 30, minLines: 1, maxLength: 10, - bgColor: Colors.grey[200], - textString: model.text, + bgColor: Colors.grey[200]!, + textString: model.text ?? '', textInputAction: TextInputAction.newline, maxHintLines: 20, hint: 'input动态算高input动态算高input动态算高input动态算高input动态算高', diff --git a/example/lib/sample/components/line/dashed_line_example.dart b/example/lib/sample/components/line/dashed_line_example.dart index f5021e53..08cf4ff7 100644 --- a/example/lib/sample/components/line/dashed_line_example.dart +++ b/example/lib/sample/components/line/dashed_line_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -77,7 +77,10 @@ class _DashedLineExampleState extends State { color: Colors.red, child: BrnDashedLine( axis: Axis.horizontal, - dashedOffset: 10, + dashedOffset: 10, contentWidget: Container( + width: 200, + height: 100, + ), ), ), ], diff --git a/example/lib/sample/components/loading/loading_widget_example.dart b/example/lib/sample/components/loading/loading_widget_example.dart index f1d43967..53b9aa05 100644 --- a/example/lib/sample/components/loading/loading_widget_example.dart +++ b/example/lib/sample/components/loading/loading_widget_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/navbar/appbar_entry_page.dart b/example/lib/sample/components/navbar/appbar_entry_page.dart index 7a0cb152..b800a595 100644 --- a/example/lib/sample/components/navbar/appbar_entry_page.dart +++ b/example/lib/sample/components/navbar/appbar_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/navbar/nav_bar_example_page.dart b/example/lib/sample/components/navbar/nav_bar_example_page.dart index 717c46be..d0870d2a 100644 --- a/example/lib/sample/components/navbar/nav_bar_example_page.dart +++ b/example/lib/sample/components/navbar/nav_bar_example_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -14,25 +14,25 @@ class NavBarPage extends StatefulWidget { } class _NavBarPageState extends State with TickerProviderStateMixin { - TextEditingController textEditingController; + TextEditingController? textEditingController; - TextStyle selectedHeiStyle; - TextStyle unSelectedHeiStyle; - TextStyle commonHeiStyle; + TextStyle? selectedHeiStyle; + TextStyle? unSelectedHeiStyle; + TextStyle? commonHeiStyle; - TextStyle selectedBaiStyle; - TextStyle unSelectedBaiStyle; - TextStyle commonBaiStyle; + TextStyle? selectedBaiStyle; + TextStyle? unSelectedBaiStyle; + TextStyle? commonBaiStyle; int currentIndex = 0; - ValueNotifier valueNotifier; - FocusNode focusNode; + late ValueNotifier valueNotifier; + FocusNode? focusNode; - TabController tabController; + TabController? tabController; - var keyleading = GlobalKey(); + GlobalKey keyLeading = GlobalKey(); - var actionKey = GlobalKey(); + GlobalKey actionKey = GlobalKey(); @override void initState() { @@ -54,8 +54,8 @@ class _NavBarPageState extends State with TickerProviderStateMixin { commonBaiStyle = TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Color(0xFF222222)); focusNode = FocusNode(); - focusNode.addListener(() { - if (focusNode.hasFocus) { + focusNode!.addListener(() { + if (focusNode!.hasFocus) { valueNotifier.value = true; } }); @@ -71,8 +71,8 @@ class _NavBarPageState extends State with TickerProviderStateMixin { ); } - PreferredSizeWidget buildBarByIndex(BuildContext context) { - PreferredSizeWidget appBar; + PreferredSizeWidget? buildBarByIndex(BuildContext context) { + PreferredSizeWidget? appBar; switch (widget.index) { case 0: //2个文字模块切换 左右两个icon hei @@ -144,8 +144,8 @@ class _NavBarPageState extends State with TickerProviderStateMixin { return appBar; } - Widget buildContentByIndex(BuildContext context) { - Widget widget; + Widget? buildContentByIndex(BuildContext context) { + Widget? widget; switch (this.widget.index) { case 0: widget = @@ -477,7 +477,7 @@ class _NavBarPageState extends State with TickerProviderStateMixin { leading: Padding( padding: const EdgeInsets.only(right: 16), child: Row( - key: keyleading, + key: keyLeading, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( @@ -503,7 +503,7 @@ class _NavBarPageState extends State with TickerProviderStateMixin { //update 是setState方法的方法命,update() 就可以刷新输入框 BrnPopupListWindow.showPopListWindow( context, - keyleading, + keyLeading, data: ["aaaa", "bbbbb"], ); }, @@ -540,7 +540,7 @@ class _NavBarPageState extends State with TickerProviderStateMixin { leading: Padding( padding: const EdgeInsets.only(right: 16), child: Row( - key: keyleading, + key: keyLeading, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( @@ -563,7 +563,7 @@ class _NavBarPageState extends State with TickerProviderStateMixin { leadClickCallback: (controller, update) { //controller 是文本控制器,通过controller 可以拿到输入的内容 以及 对输入的内容更改 //update 是setState方法的方法命,update() 就可以刷新输入框 - BrnPopupListWindow.showPopListWindow(context, keyleading, data: ["aaaa", "bbbbb"]); + BrnPopupListWindow.showPopListWindow(context, keyLeading, data: ["aaaa", "bbbbb"]); }, //输入框 文本内容变化的监听 searchBarInputChangeCallback: (input) { diff --git a/example/lib/sample/components/noticebar/brn_notice_bar_example.dart b/example/lib/sample/components/noticebar/brn_notice_bar_example.dart index 76e44153..94eec187 100644 --- a/example/lib/sample/components/noticebar/brn_notice_bar_example.dart +++ b/example/lib/sample/components/noticebar/brn_notice_bar_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/noticebar/notice_bar_example.dart b/example/lib/sample/components/noticebar/notice_bar_example.dart index f75bf591..073ac2c4 100644 --- a/example/lib/sample/components/noticebar/notice_bar_example.dart +++ b/example/lib/sample/components/noticebar/notice_bar_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart b/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart index 91618eef..be11f666 100644 --- a/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart +++ b/example/lib/sample/components/noticebar/notice_bar_with_button_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart b/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart index 70c94902..e63e6188 100644 --- a/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart +++ b/example/lib/sample/components/picker/cutomer_bottom_picker_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/picker/date_picker_example.dart b/example/lib/sample/components/picker/date_picker_example.dart index 8fffca2a..ece9492a 100644 --- a/example/lib/sample/components/picker/date_picker_example.dart +++ b/example/lib/sample/components/picker/date_picker_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; diff --git a/example/lib/sample/components/picker/multi_picker_example.dart b/example/lib/sample/components/picker/multi_picker_example.dart index 33f33bd7..b1aa2b87 100644 --- a/example/lib/sample/components/picker/multi_picker_example.dart +++ b/example/lib/sample/components/picker/multi_picker_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; @@ -182,7 +182,7 @@ class Brn1RowDelegate implements BrnMultiDataPickerDelegate { } @override - double rowHeightForComponent(int component) { + double? rowHeightForComponent(int component) { return null; } @@ -249,7 +249,7 @@ class Brn2RowDelegate implements BrnMultiDataPickerDelegate { } @override - double rowHeightForComponent(int component) { + double? rowHeightForComponent(int component) { return null; } @@ -326,7 +326,7 @@ class Brn3RowDelegate implements BrnMultiDataPickerDelegate { } @override - double rowHeightForComponent(int component) { + double? rowHeightForComponent(int component) { return null; } @@ -386,7 +386,7 @@ class Brn2RowCustomDelegate implements BrnMultiDataPickerDelegate { } @override - double rowHeightForComponent(int component) { + double? rowHeightForComponent(int component) { return null; } diff --git a/example/lib/sample/components/picker/picker_entry_page.dart b/example/lib/sample/components/picker/picker_entry_page.dart index 5bde9125..33b907a5 100644 --- a/example/lib/sample/components/picker/picker_entry_page.dart +++ b/example/lib/sample/components/picker/picker_entry_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:convert'; @@ -13,7 +13,7 @@ import 'multi_picker_example.dart'; class PickerEntryPage extends StatelessWidget { final String _title; - List dataList = List(); + List dataList = []; PickerEntryPage(this._title); @@ -83,10 +83,10 @@ class PickerEntryPage extends StatelessWidget { onPressed: () { rootBundle.loadString('assets/list_picker.json').then((data) { List _selectionData = [] - ..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? []) + ..addAll((JsonDecoder().convert(data)["data"]['list'] as List? ?? []) .map((o) => BrnPickerEntity.fromMap(o))); - if (_selectionData != null && _selectionData.length > 0) { - _selectionData?.forEach((f) => f.configChild()); + if ( _selectionData.length > 0) { + _selectionData.forEach((f) => f.configChild()); if (dataList.length == 0) { dataList.addAll(_selectionData); } @@ -101,10 +101,10 @@ class PickerEntryPage extends StatelessWidget { onPressed: () { rootBundle.loadString('assets/list_picker.json').then((data) { List _selectionData = [] - ..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? []) + ..addAll((JsonDecoder().convert(data)["data"]['list'] as List? ?? []) .map((o) => BrnPickerEntity.fromMap(o))); - if (_selectionData != null && _selectionData.length > 0) { - _selectionData?.forEach((f) => f.configChild()); + if (_selectionData.length > 0) { + _selectionData.forEach((f) => f.configChild()); if (dataList.length == 0) { dataList.addAll(_selectionData); } @@ -155,7 +155,7 @@ class PickerEntryPage extends StatelessWidget { /// 实现限制选择数量的情况 void _showCountLimitBottomMultiSelectPicker(BuildContext context) { - List items = new List(); + List items = []; items.add(new BrnMultiSelectBottomPickerItem("100", "这里是标题1")); items.add(new BrnMultiSelectBottomPickerItem("101", "这里是标题2")); items.add(new BrnMultiSelectBottomPickerItem("102", "这里是标题3", isChecked: true)); @@ -203,7 +203,7 @@ class PickerEntryPage extends StatelessWidget { cancelDismiss: true, confirmDismiss: false, onConfirm: (context, string) { - BrnToast.show(string, context); + BrnToast.show(string ?? '', context); return; }, onCancel: (_) { @@ -215,15 +215,15 @@ class PickerEntryPage extends StatelessWidget { } void _showRangePicker(BuildContext context, List _selectionData) { - _selectionData?.forEach((f) => f.configChild()); + _selectionData.forEach((f) => f.configChild()); var selectionMenuView = BrnMultiColumnPicker( entity: _selectionData[3], defaultFocusedIndexes: [0, -1, -1], - onConfirm: (Map> result, int firstIndex, - int secondIndex, int thirdIndex) { - List pickResult = List(); + onConfirm: (Map> result, int? firstIndex, + int? secondIndex, int? thirdIndex) { + List pickResult = []; result.forEach((key, val) { - List tmp = List(); + List tmp = []; val.forEach((item) { tmp.add(item.name); }); @@ -245,7 +245,7 @@ class PickerEntryPage extends StatelessWidget { } void _showRangePicker1(BuildContext context, List _selectionData) { - _selectionData?.forEach((f) => f.configChild()); + _selectionData.forEach((f) => f.configChild()); String titleName = "测试标题"; showModalBottomSheet( context: context, @@ -255,11 +255,11 @@ class PickerEntryPage extends StatelessWidget { pickerTitleConfig: BrnPickerTitleConfig(titleContent: titleName), entity: _selectionData[3], defaultFocusedIndexes: [0, -1, -1], - onConfirm: (Map> result, int firstIndex, - int secondIndex, int thirdIndex) { - List pickResult = List(); + onConfirm: (Map> result, int? firstIndex, + int? secondIndex, int? thirdIndex) { + List pickResult = []; result.forEach((key, val) { - List tmp = List(); + List tmp = []; val.forEach((item) { tmp.add(item.name); }); @@ -293,7 +293,7 @@ class PickerEntryPage extends StatelessWidget { '可爱多池', ]; - List items = List(); + List items = []; for (int i = 0; i < tags.length; i++) { String it = tags[i]; BrnTagItemBean item = BrnTagItemBean(name: it, code: it, index: i); @@ -350,7 +350,7 @@ class PickerEntryPage extends StatelessWidget { '我是可选择的标签1', ]; - List items = List(); + List items = []; for (int i = 0; i < tags.length; i++) { String it = tags[i]; BrnTagInputItemBean item = BrnTagInputItemBean(name: it, index: i, needExpend: (i % 2 == 0)); diff --git a/example/lib/sample/components/popup/overlay_window_example.dart b/example/lib/sample/components/popup/overlay_window_example.dart index b58e0c81..458ba188 100644 --- a/example/lib/sample/components/popup/overlay_window_example.dart +++ b/example/lib/sample/components/popup/overlay_window_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -13,9 +13,9 @@ class OverlayWindowExample extends StatefulWidget { } class OverlayWindowExamplePageState extends State { - BrnOverlayController _overlayController; - var _focusNode = FocusNode(); - var _searchBarKey = GlobalKey(); + BrnOverlayController? _overlayController; + FocusNode _focusNode = FocusNode(); + GlobalKey _searchBarKey = GlobalKey(); @override void initState() { @@ -68,7 +68,7 @@ class OverlayWindowExamplePageState extends State { _overlayController?.removeOverlay(); return; } - if (_overlayController == null || _overlayController.isOverlayShowing == false) { + if (_overlayController == null || _overlayController!.isOverlayShowing == false) { _overlayController = BrnOverlayWindow.showOverlayWindow(context, _searchBarKey, content: _sugListView(), autoDismissOnTouchOutSide: true, diff --git a/example/lib/sample/components/popup/popwindow_example.dart b/example/lib/sample/components/popup/popwindow_example.dart index e5d5c1c9..a0032f43 100644 --- a/example/lib/sample/components/popup/popwindow_example.dart +++ b/example/lib/sample/components/popup/popwindow_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -13,19 +13,19 @@ class PopWindowExamplePage extends StatefulWidget { } class PopWindowExamplePageState extends State { - GlobalKey _leftKeylist0; - GlobalKey _leftKeylist1; - GlobalKey _leftKeylist2; - GlobalKey _leftKey; - GlobalKey _leftKey1; - GlobalKey _leftKey2; - GlobalKey _leftKey3; - GlobalKey _leftKey4; - GlobalKey _leftKey5; - GlobalKey _leftKey6; - GlobalKey _leftKey7; + GlobalKey? _leftKeylist0; + GlobalKey? _leftKeylist1; + GlobalKey? _leftKeylist2; + GlobalKey? _leftKey; + GlobalKey? _leftKey1; + GlobalKey? _leftKey2; + GlobalKey? _leftKey3; + GlobalKey? _leftKey4; + GlobalKey? _leftKey5; + GlobalKey? _leftKey6; + GlobalKey? _leftKey7; - BrnOverlayController overlayController; + BrnOverlayController? overlayController; @override void initState() { @@ -59,7 +59,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容", _leftKey, + BrnPopupWindow.showPopWindow(context, "提示内容", _leftKey!, hasCloseIcon: true); }, child: Text("左侧带关闭Tips"), @@ -70,7 +70,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey1, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey1, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey1!, hasCloseIcon: false); }, child: Text("左侧带无关闭Tips"), @@ -81,7 +81,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey2, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey2, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey2!, popDirection: BrnPopupDirection.top, hasCloseIcon: true); }, child: Text("左侧带关闭,箭头朝下Tips"), @@ -92,7 +92,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey3, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey3, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey3!, dismissCallback: () {}, popDirection: BrnPopupDirection.top); }, child: Text("左侧无关闭,箭头朝下Tips"), @@ -103,7 +103,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey4, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey4, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey4!, hasCloseIcon: true, dismissCallback: () {}, popDirection: BrnPopupDirection.bottom); @@ -116,7 +116,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey5, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容", _leftKey5, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容", _leftKey5!, hasCloseIcon: false, dismissCallback: () {}, popDirection: BrnPopupDirection.bottom); @@ -129,7 +129,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey6, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey6, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey6!, hasCloseIcon: true, canWrap: false, dismissCallback: () {}, @@ -143,7 +143,7 @@ class PopWindowExamplePageState extends State { child: RaisedButton( key: _leftKey7, onPressed: () { - BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey7, + BrnPopupWindow.showPopWindow(context, "提示内容提示内容提示内容提示内容提示内容提示内容", _leftKey7!, hasCloseIcon: false, dismissCallback: () {}, popDirection: BrnPopupDirection.top); diff --git a/example/lib/sample/components/rating/rating_example.dart b/example/lib/sample/components/rating/rating_example.dart index 32a6de06..61acdb71 100644 --- a/example/lib/sample/components/rating/rating_example.dart +++ b/example/lib/sample/components/rating/rating_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart index d40acf31..ffba733b 100644 --- a/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart +++ b/example/lib/sample/components/scroll_anchor/scroll_actor_tab_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; diff --git a/example/lib/sample/components/selectcity/selected_city_example.dart b/example/lib/sample/components/selectcity/selected_city_example.dart index fc6d8a7b..0f6fdfb6 100644 --- a/example/lib/sample/components/selectcity/selected_city_example.dart +++ b/example/lib/sample/components/selectcity/selected_city_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:convert'; @@ -15,8 +15,8 @@ class CitySelectRoute extends StatefulWidget { } class _CitySelectRouteState extends State { - List _cityList = List(); - List _hotCityList = List(); + List _cityList = []; + List _hotCityList = []; int _suspensionHeight = 40; int _itemHeight = 50; @@ -46,7 +46,7 @@ class _CitySelectRouteState extends State { } void _handleList(List list) { - if (list == null || list.isEmpty) return; + if (list.isEmpty) return; for (int i = 0, length = list.length; i < length; i++) { String pinyin = PinyinHelper.getPinyinE(list[i].name); String tag = pinyin.substring(0, 1).toUpperCase(); @@ -134,7 +134,7 @@ class _CitySelectRouteState extends State { flex: 1, child: AzListView( data: _cityList, - itemBuilder: (context, model) => _buildListItem(model), + itemBuilder: (context, model) => _buildListItem(model as BrnSelectCityModel), suspensionWidget: _buildSusWidget(_suspensionTag), isUseRealIndex: true, itemHeight: _itemHeight, diff --git a/example/lib/sample/components/selection/filter_entity.dart b/example/lib/sample/components/selection/filter_entity.dart index 40468f14..50d19dfb 100644 --- a/example/lib/sample/components/selection/filter_entity.dart +++ b/example/lib/sample/components/selection/filter_entity.dart @@ -1,17 +1,17 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; class BrnFilterEntity { - String key; - String name; - String defaultValue; - List children; + String? key; + late String name; + String? defaultValue; + late List children; BrnFilterEntity.fromJson(Map map) { key = map['key'] ?? ''; name = map['title'] ?? ''; defaultValue = map['defaultValue'] ?? ''; - children = []..addAll((map['children'] as List ?? []).map((o) => ItemEntity.fromJson(o))); + children = []..addAll((map['children'] as List? ?? []).map((o) => ItemEntity.fromJson(o))); } } diff --git a/example/lib/sample/components/selection/flat_selection_five_tags_example.dart b/example/lib/sample/components/selection/flat_selection_five_tags_example.dart index ff03d625..6cd63d43 100644 --- a/example/lib/sample/components/selection/flat_selection_five_tags_example.dart +++ b/example/lib/sample/components/selection/flat_selection_five_tags_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -14,11 +14,11 @@ class NewSelectionViewExamplePage23 extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - BrnSelectionEntity entity; + BrnSelectionEntity? entity; - BrnFlatSelectionController controller; + BrnFlatSelectionController? controller; - var selectionKey = GlobalKey(); + GlobalKey selectionKey = GlobalKey(); bool _isShow = true; @@ -31,7 +31,7 @@ class _SelectionViewExamplePageState extends State { - BrnSelectionEntity entity; + BrnSelectionEntity? entity; - BrnFlatSelectionController controller; + BrnFlatSelectionController? controller; var selectionKey = GlobalKey(); @@ -31,7 +31,7 @@ class _SelectionViewExamplePageState extends State @override void dispose() { - controller.dispose(); + controller!.dispose(); controller = null; super.dispose(); } @@ -111,7 +111,7 @@ class _SelectionViewExamplePageState extends State ), onTap: () { if (controller != null) { - controller.resetSelectedOptions(); + controller!.resetSelectedOptions(); } }, ), @@ -124,7 +124,7 @@ class _SelectionViewExamplePageState extends State title: "取消", onTap: () { if (controller != null) { - controller.cancelSelectedOptions(); + controller!.cancelSelectedOptions(); setState(() { _isShow = false; }); @@ -138,7 +138,7 @@ class _SelectionViewExamplePageState extends State title: "确定", onTap: () { if (controller != null) { - controller.confirmSelectedOptions(); + controller!.confirmSelectedOptions(); setState(() { _isShow = false; }); diff --git a/example/lib/sample/components/selection/flat_selection_three_tags_example.dart b/example/lib/sample/components/selection/flat_selection_three_tags_example.dart index 463095dc..73f60dbc 100644 --- a/example/lib/sample/components/selection/flat_selection_three_tags_example.dart +++ b/example/lib/sample/components/selection/flat_selection_three_tags_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -14,9 +14,9 @@ class FlatSelectionThreeTagsExample extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - BrnSelectionEntity entity; + BrnSelectionEntity? entity; - BrnFlatSelectionController controller; + BrnFlatSelectionController? controller; var selectionKey = GlobalKey(); @@ -31,7 +31,7 @@ class _SelectionViewExamplePageState extends State 0) { @@ -58,7 +58,7 @@ class FlatSelectionEntryPage extends StatelessWidget { onPressed: () { rootBundle.loadString('assets/flat_selection_filter.json').then((data) { var datas = - BrnSelectionEntityListBean.fromJson(JsonDecoder().convert(data)["data"]).list; + BrnSelectionEntityListBean.fromJson(JsonDecoder().convert(data)["data"])!.list!; void _configMaxSelectedCount(BrnSelectionEntity entity, int maxCount) { entity.maxSelectedCount = maxCount; if (entity.children != null && entity.children.length > 0) { @@ -83,7 +83,7 @@ class FlatSelectionEntryPage extends StatelessWidget { onPressed: () { rootBundle.loadString('assets/flat_selection_filter.json').then((data) { var datas = - BrnSelectionEntityListBean.fromJson(JsonDecoder().convert(data)["data"]).list; + BrnSelectionEntityListBean.fromJson(JsonDecoder().convert(data)["data"])!.list!; void _configMaxSelectedCount(BrnSelectionEntity entity, int maxCount) { entity.maxSelectedCount = maxCount; if (entity.children != null && entity.children.length > 0) { diff --git a/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart b/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart index c7d6bdee..e01167c2 100644 --- a/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart +++ b/example/lib/sample/components/selection/selectionview_custom_floating_layer_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/card/bubble/common_bubble_example.dart'; @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; class SelectionViewMoreCustomFloatLayerExamplePage extends StatefulWidget { final String _title; - final List _filterData; + final List? _filterData; SelectionViewMoreCustomFloatLayerExamplePage(this._title, this._filterData); @@ -15,9 +15,9 @@ class SelectionViewMoreCustomFloatLayerExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; - BrnSelectionViewController controller; + BrnSelectionViewController? controller; var selectionKey = GlobalKey(); @@ -46,14 +46,14 @@ class _SelectionViewExamplePageState extends State result = Map(); result['Key1'] = 'Value1'; result['Key2'] = 'Value2'; - List resultEntity = List(); - result?.forEach((userId, userName) { + List resultEntity = []; + result.forEach((userId, userName) { resultEntity.add(BrnSelectionEntity( value: userId, title: userName, isSelected: true, type: 'radio')); }); diff --git a/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart b/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart index d8df37b3..7e122c0b 100644 --- a/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_customhandle_filter_example_page.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class SelectionViewCustomHandleFilterExamplePage extends StatefulWidget { final String _title; - final List _filters; + final List? _filters; SelectionViewCustomHandleFilterExamplePage(this._title, this._filters); @@ -28,7 +28,7 @@ class _SelectionViewExamplePageState extends State[ BrnSelectionView( - originalSelectionData: widget._filters, + originalSelectionData: widget._filters!, onCustomSelectionMenuClick: (int index, BrnSelectionEntity customMenuItem, BrnSetCustomSelectionParams customHandleCallBack) { /// 用户操作一段时间之后,将自定义参数回传,触发 onSelectionChanged回调。 @@ -42,7 +42,7 @@ class _SelectionViewExamplePageState extends State filterParams, Map customParams, BrnSetCustomSelectionMenuTitle setCustomTitleFunction) { - if (menuIndex == 1 && setCustomTitleFunction != null) { + if (menuIndex == 1) { setCustomTitleFunction( menuTitle: BrunoTools.isEmpty(customParams) ? "" : customParams['CKey'] ?? "", isMenuTitleHighLight: !BrunoTools.isEmpty(customParams['CKey'])); diff --git a/example/lib/sample/components/selection/selectionview_customview_example_page.dart b/example/lib/sample/components/selection/selectionview_customview_example_page.dart index 69ac4c55..882f6d44 100644 --- a/example/lib/sample/components/selection/selectionview_customview_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_customview_example_page.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class SelectionViewCustomViewExamplePage extends StatefulWidget { final String _title; - final List _filters; + final List? _filters; SelectionViewCustomViewExamplePage(this._title, this._filters); @@ -14,11 +14,11 @@ class SelectionViewCustomViewExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List _filterData; + List? _filterData; var selectionKey = GlobalKey(); bool isCustomFilterViewShow = false; - OverlayEntry filterViewEntry; + OverlayEntry? filterViewEntry; /// 筛选组件的回调函数,用于把用户选中的参数回传给筛选组件,同意在 onSelectionChanged 回调处理。 参数在 customParams 中存储 var _customHandleCallBack; @@ -27,20 +27,20 @@ class _SelectionViewExamplePageState extends State _currentCalendarSelectedDate; + late ValueNotifier _currentCalendarSelectedDate; String _dateForamt = 'yyyy-MM-dd HH:mm:ss'; - _SelectionViewExamplePageState(List filters) { + _SelectionViewExamplePageState(List? filters) { _filterData = filters; } @override void initState() { _currentCalendarSelectedDate = - ValueNotifier(DateTimeFormatter.convertStringToDate(_dateForamt, _filterSelectedDate)); + ValueNotifier(DateTimeFormatter.convertStringToDate(_dateForamt, _filterSelectedDate!)); super.initState(); } @@ -60,14 +60,14 @@ class _SelectionViewExamplePageState extends State[ ValueListenableBuilder( valueListenable: _currentCalendarSelectedDate, - builder: (context, value, widget) { + builder: (context, dynamic value, widget) { return BrnCalendarView.single( initStartSelectedDate: _currentCalendarSelectedDate.value, initEndSelectedDate: _currentCalendarSelectedDate.value, @@ -188,7 +188,7 @@ class _SelectionViewExamplePageState extends State() - : {'date': _currentCalendarSelectedDate.value.toString() ?? ''}); + : {'date': _currentCalendarSelectedDate.value.toString()}); _filterSelectedDate = _currentCalendarSelectedDate.value?.toString(); closeCustomFilterView(); }, @@ -201,8 +201,8 @@ class _SelectionViewExamplePageState extends State { - List _filterData; + late List _filterData; _SelectionViewExamplePageState(List filters) { _filterData = filters; diff --git a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart index ec41dd0e..78beaac4 100644 --- a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class SelectionViewDateRangeExamplePage extends StatefulWidget { final String _title; - final List _filterData; + final List? _filterData; SelectionViewDateRangeExamplePage(this._title, this._filterData); @@ -14,9 +14,9 @@ class SelectionViewDateRangeExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; - BrnSelectionViewController controller; + BrnSelectionViewController? controller; @override void initState() { @@ -43,13 +43,13 @@ class _SelectionViewExamplePageState extends State filterParams, Map customParams, @@ -60,7 +60,7 @@ class _SelectionViewExamplePageState extends State _filterData; + final List? _filterData; SelectionViewCloseOrInterceptorExamplePage(this._title, this._filterData); @@ -14,9 +14,9 @@ class SelectionViewCloseOrInterceptorExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; - BrnSelectionViewController controller; + BrnSelectionViewController? controller; @override void initState() { @@ -38,7 +38,7 @@ class _SelectionViewExamplePageState extends State filterParams, Map customParams, BrnSetCustomSelectionMenuTitle setCustomTitleFunction) { BrnToast.show('选中 ${filterParams.toString()},但筛选条件被清除了', context); if (menuIndex == 1 && filterParams != null && filterParams['two_list_key'] != null) { - widget._filterData[1].clearChildSelection(); - widget._filterData[1].configRelationshipAndDefaultValue(); - controller.refreshSelectionTitle(); + widget._filterData![1].clearChildSelection(); + widget._filterData![1].configRelationshipAndDefaultValue(); + controller!.refreshSelectionTitle(); } }, onMenuClickInterceptor: (index) { diff --git a/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart b/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart index ee5cc674..142ec722 100644 --- a/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart +++ b/example/lib/sample/components/selection/selectionview_limit_max_selected_count_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -14,9 +14,9 @@ class SelectionViewLimitMaxSelectedCountExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; - BrnSelectionViewController controller; + BrnSelectionViewController? controller; @override void initState() { @@ -43,7 +43,7 @@ class _SelectionViewExamplePageState extends State _filters; + final List? _filters; SelectionViewMoreFilterExamplePage(this._title, this._filters); @@ -29,7 +29,7 @@ class _SelectionViewExamplePageState extends State[ BrnSelectionView( - originalSelectionData: widget._filters, + originalSelectionData: widget._filters!, onMoreSelectionMenuClick: (int index, BrnOpenMorePage openMore) { openMore(updateData: false); }, diff --git a/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart b/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart index fcc8b8a8..bb5937fa 100644 --- a/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_multi_list_example_page.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class SelectionViewMultiListExamplePage extends StatefulWidget { final String _title; - final List _filterData; + final List? _filterData; SelectionViewMultiListExamplePage(this._title, this._filterData); @@ -14,7 +14,7 @@ class SelectionViewMultiListExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; @override void initState() { @@ -28,7 +28,7 @@ class _SelectionViewExamplePageState extends State[ BrnSelectionView( - originalSelectionData: widget._filterData, + originalSelectionData: widget._filterData!, onSelectionChanged: (int menuIndex, Map filterParams, Map customParams, diff --git a/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart b/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart index f5acd339..6fa50866 100644 --- a/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_multi_range_example_page.dart @@ -1,11 +1,11 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class SelectionViewMultiRangeExamplePage extends StatefulWidget { final String _title; - final List _filters; + final List? _filters; SelectionViewMultiRangeExamplePage(this._title, this._filters); @@ -14,7 +14,7 @@ class SelectionViewMultiRangeExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List titles; + List? titles; @override void initState() { @@ -28,7 +28,7 @@ class _SelectionViewExamplePageState extends State[ BrnSelectionView( - originalSelectionData: widget._filters, + originalSelectionData: widget._filters!, onSelectionChanged: (int menuIndex, Map filterParams, Map customParams, @@ -39,7 +39,7 @@ class _SelectionViewExamplePageState extends State { - List items; + List? items; @override void initState() { diff --git a/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart b/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart index cf0e1c0f..3ef33f9e 100755 --- a/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_simple_single_list_example_page.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/selection/filter_entity.dart'; @@ -15,7 +15,7 @@ class SelectionViewSimpleSingleListExamplePage extends StatefulWidget { } class _SelectionViewExamplePageState extends State { - List items; + List? items; @override void initState() { diff --git a/example/lib/sample/components/step/step_example.dart b/example/lib/sample/components/step/step_example.dart index 13b1ae74..9d493417 100644 --- a/example/lib/sample/components/step/step_example.dart +++ b/example/lib/sample/components/step/step_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/step/brn_horizontal_step_example.dart'; diff --git a/example/lib/sample/components/step/step_line_example.dart b/example/lib/sample/components/step/step_line_example.dart index 4264939f..d189385c 100644 --- a/example/lib/sample/components/step/step_line_example.dart +++ b/example/lib/sample/components/step/step_line_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:math'; @@ -6,14 +6,14 @@ import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; class StepLineExample extends StatefulWidget { - const StepLineExample({Key key}) : super(key: key); + const StepLineExample({Key? key}) : super(key: key); @override _StepLineExampleState createState() => _StepLineExampleState(); } class _StepLineExampleState extends State { - int count; + int? count; @override void initState() { diff --git a/example/lib/sample/components/switch/checkbox_example.dart b/example/lib/sample/components/switch/checkbox_example.dart index ed0f0dd6..d7ad41ba 100644 --- a/example/lib/sample/components/switch/checkbox_example.dart +++ b/example/lib/sample/components/switch/checkbox_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/switch/radio_example.dart b/example/lib/sample/components/switch/radio_example.dart index eee90493..08fb1ce2 100644 --- a/example/lib/sample/components/switch/radio_example.dart +++ b/example/lib/sample/components/switch/radio_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tabbar/brn_switch_title_example.dart b/example/lib/sample/components/tabbar/brn_switch_title_example.dart index d2879f89..73658682 100644 --- a/example/lib/sample/components/tabbar/brn_switch_title_example.dart +++ b/example/lib/sample/components/tabbar/brn_switch_title_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -9,7 +9,7 @@ class BrnSwitchTitleExample extends StatefulWidget { } class _BrnSwitchTitleExampleState extends State with TickerProviderStateMixin { - TabController _controller; + late TabController _controller; @override void initState() { diff --git a/example/lib/sample/components/tabbar/brn_tab_example.dart b/example/lib/sample/components/tabbar/brn_tab_example.dart index 1f527dcd..a75c263c 100644 --- a/example/lib/sample/components/tabbar/brn_tab_example.dart +++ b/example/lib/sample/components/tabbar/brn_tab_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/list_item.dart'; @@ -12,7 +12,7 @@ class BrnTabExample extends StatefulWidget { } class _BrnTabExampleState extends State with TickerProviderStateMixin { - BrnCloseWindowController closeWindowController; + BrnCloseWindowController? closeWindowController; @override void initState() { @@ -37,7 +37,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM ), Divider(), Center( - child: OutlineButton( + child: OutlinedButton( onPressed: () { Navigator.of(context).push(new MaterialPageRoute(builder: (context) { return BrnTabbarStickyExample(); @@ -71,8 +71,8 @@ class _BrnTabExampleState extends State with TickerProviderStateM ), ), onWillPop: () { - if (closeWindowController.isShow) { - closeWindowController.closeMoreWindow(); + if (closeWindowController!.isShow) { + closeWindowController!.closeMoreWindow(); return Future.value(false); } return Future.value(true); @@ -80,7 +80,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createExpandedMoreTabbarWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一")); tabs.add(BadgeTab(text: "业务二")); tabs.add(BadgeTab(text: "业务三")); @@ -100,7 +100,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createStableTabbar4Widgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一")); tabs.add(BadgeTab(text: "业务二")); tabs.add(BadgeTab(text: "业务三")); @@ -116,7 +116,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createStableTabbarWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "特殊业务详情一", badgeText: "新")); tabs.add(BadgeTab(text: "业务二", badgeNum: 22)); tabs.add(BadgeTab(text: "业务三", badgeNum: 11)); @@ -142,7 +142,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createTabbarBadgeWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一", badgeText: "新")); tabs.add(BadgeTab(text: "业务二", badgeNum: 22)); tabs.add(BadgeTab(text: "业务三", badgeNum: 11)); @@ -163,7 +163,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createStableTabbarBadgeWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一", badgeNum: 100)); tabs.add(BadgeTab(text: "业务二", badgeNum: 22)); tabs.add(BadgeTab(text: "业务三", badgeNum: 11)); @@ -179,7 +179,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createDividerTabbarWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一", topText: "1")); tabs.add(BadgeTab(text: "业务二", topText: "2")); tabs.add(BadgeTab(text: "业务三", topText: "3")); @@ -199,7 +199,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM /// 自定义Tab宽度,如果tab宽度之和大于屏幕宽度,默认能左右滚动 /// _createCustomTabbarWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一", badgeNum: 2)); tabs.add(BadgeTab(text: "业务二")); tabs.add(BadgeTab(text: "业务三", badgeNum: 33)); @@ -215,7 +215,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createTopTabbarWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "08月09日", topText: "今天")); tabs.add(BadgeTab(text: "08月10日", topText: "明天")); tabs.add(BadgeTab(text: "08月11日", topText: "周三")); @@ -234,7 +234,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createTopTabbarCountWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "08月09日", topText: "今天")); tabs.add(BadgeTab(text: "08月10日", topText: "明天")); tabs.add(BadgeTab(text: "08月11日", topText: "周三")); @@ -251,7 +251,7 @@ class _BrnTabExampleState extends State with TickerProviderStateM } _createOriginWidgets() { - var tabs = List(); + var tabs = []; tabs.add(BadgeTab(text: "业务一", badgeText: "新")); tabs.add(BadgeTab(text: "业务二", badgeNum: 22)); tabs.add(BadgeTab(text: "业务三", badgeNum: 11)); diff --git a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart index be0d3cf6..410af360 100644 --- a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart +++ b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -10,14 +10,14 @@ class BrnTabbarStickyExample extends StatefulWidget { class _BrnTabbarStickyExampleState extends State with SingleTickerProviderStateMixin { - TabController tabController; + TabController? tabController; GlobalKey globalKey = GlobalKey(); ScrollController scrollController = ScrollController(); - BrnCloseWindowController closeWindowController; - var tabs = List(); + BrnCloseWindowController? closeWindowController; + var tabs = []; @override void initState() { @@ -31,7 +31,7 @@ class _BrnTabbarStickyExampleState extends State tabController = TabController(length: tabs.length, vsync: this); closeWindowController = BrnCloseWindowController(); scrollController.addListener(() { - closeWindowController.closeMoreWindow(); + closeWindowController!.closeMoreWindow(); }); } @@ -66,7 +66,7 @@ class _BrnTabbarStickyExampleState extends State moreWindowText: "Tabs描述", onTap: (state, index) { state.refreshBadgeState(index); - scrollController.animateTo(globalKey.currentContext.size.height, + scrollController.animateTo(globalKey.currentContext!.size!.height, duration: Duration(milliseconds: 200), curve: Curves.linear); }, onMorePop: () {}, @@ -90,8 +90,8 @@ class _BrnTabbarStickyExampleState extends State ), ), onWillPop: () { - if (closeWindowController.isShow) { - closeWindowController.closeMoreWindow(); + if (closeWindowController!.isShow) { + closeWindowController!.closeMoreWindow(); return Future.value(false); } return Future.value(true); @@ -114,7 +114,7 @@ class _BrnTabbarStickyExampleState extends State class StickyTabBarDelegate extends SliverPersistentHeaderDelegate { final BrnTabBar child; - StickyTabBarDelegate({@required this.child}); + StickyTabBarDelegate({required this.child}); @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { @@ -122,10 +122,10 @@ class StickyTabBarDelegate extends SliverPersistentHeaderDelegate { } @override - double get maxExtent => this.child.tabHeight; + double get maxExtent => this.child.tabHeight!; @override - double get minExtent => this.child.tabHeight; + double get minExtent => this.child.tabHeight!; @override bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { diff --git a/example/lib/sample/components/tabbar/sub_switch_title_example.dart b/example/lib/sample/components/tabbar/sub_switch_title_example.dart index 667b48fd..83ee38b7 100644 --- a/example/lib/sample/components/tabbar/sub_switch_title_example.dart +++ b/example/lib/sample/components/tabbar/sub_switch_title_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -10,7 +10,7 @@ class SubSwitchTitleExample extends StatefulWidget { class _SubSwitchTitleExampleState extends State with TickerProviderStateMixin { - TabController _controller; + late TabController _controller; @override void initState() { diff --git a/example/lib/sample/components/tag/border_tag_example.dart b/example/lib/sample/components/tag/border_tag_example.dart index 0ca214f4..e37b580f 100644 --- a/example/lib/sample/components/tag/border_tag_example.dart +++ b/example/lib/sample/components/tag/border_tag_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/custom_tag_example.dart b/example/lib/sample/components/tag/custom_tag_example.dart index 990a6992..8b5d425d 100644 --- a/example/lib/sample/components/tag/custom_tag_example.dart +++ b/example/lib/sample/components/tag/custom_tag_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/delete_tag_example.dart b/example/lib/sample/components/tag/delete_tag_example.dart index d58f7a42..969007a8 100644 --- a/example/lib/sample/components/tag/delete_tag_example.dart +++ b/example/lib/sample/components/tag/delete_tag_example.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -39,28 +37,37 @@ class TagViewExamplePageState extends State { } Widget _buildDeleteWidget() { - BrnDeleteTagController controller = BrnDeleteTagController( - initTags: ['这是一条很长很长很长很长很长很长很长很长很长很长的标签', '标签信息', '标签信息标签信息', '标签信息', '标签信息标签信息标签信息标签信息']); + BrnDeleteTagController controller = BrnDeleteTagController(initTags: [ + '这是一条很长很长很长很长很长很长很长很长很长很长的标签', + '标签信息', + '标签信息标签信息', + '标签信息', + '标签信息标签信息标签信息标签信息' + ]); return Container( margin: EdgeInsets.only(top: 20), color: Colors.white, child: Column( children: [ -BrnDeleteTag( - controller: controller, - onTagDelete: (tags, tag, index) { - BrnToast.show('剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', context); - }, -), -BrnDeleteTag( - controller: controller, - tagTextStyle: TextStyle(color: Colors.blue, fontSize: 20), - deleteIconSize: Size(16, 16), - onTagDelete: (tags, tag, index) { - BrnToast.show('剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', context); - }, -), + BrnDeleteTag( + controller: controller, + onTagDelete: (tags, tag, index) { + BrnToast.show( + '剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', + context); + }, + ), + BrnDeleteTag( + controller: controller, + tagTextStyle: TextStyle(color: Colors.blue, fontSize: 20), + deleteIconSize: Size(16, 16), + onTagDelete: (tags, tag, index) { + BrnToast.show( + '剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', + context); + }, + ), BrnDeleteTag( controller: controller, tagTextStyle: TextStyle(color: Colors.yellow), @@ -68,7 +75,9 @@ BrnDeleteTag( deleteIconColor: Colors.red, softWrap: false, onTagDelete: (tags, tag, index) { - BrnToast.show('剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', context); + BrnToast.show( + '剩余的标签为:${tags.toString()},删除了的标签为:$tag ,删除的标签index为$index', + context); }, ), Row( diff --git a/example/lib/sample/components/tag/select_tag_example.dart b/example/lib/sample/components/tag/select_tag_example.dart index 90573705..03122e59 100644 --- a/example/lib/sample/components/tag/select_tag_example.dart +++ b/example/lib/sample/components/tag/select_tag_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/state_tag_example.dart b/example/lib/sample/components/tag/state_tag_example.dart index 2650e082..70b3facc 100644 --- a/example/lib/sample/components/tag/state_tag_example.dart +++ b/example/lib/sample/components/tag/state_tag_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/tag/tag_example.dart b/example/lib/sample/components/tag/tag_example.dart index f47dba72..c7222e94 100644 --- a/example/lib/sample/components/tag/tag_example.dart +++ b/example/lib/sample/components/tag/tag_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/components/tag/border_tag_example.dart'; diff --git a/example/lib/sample/components/tag/tag_row_example.dart b/example/lib/sample/components/tag/tag_row_example.dart index 0148a89a..510eec30 100644 --- a/example/lib/sample/components/tag/tag_row_example.dart +++ b/example/lib/sample/components/tag/tag_row_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/components/toast/toast_example.dart b/example/lib/sample/components/toast/toast_example.dart index 39c7a348..50821aff 100644 --- a/example/lib/sample/components/toast/toast_example.dart +++ b/example/lib/sample/components/toast/toast_example.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; diff --git a/example/lib/sample/home/card_data_config.dart b/example/lib/sample/home/card_data_config.dart index 79ce55e6..aa94ddfe 100644 --- a/example/lib/sample/home/card_data_config.dart +++ b/example/lib/sample/home/card_data_config.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:convert'; @@ -49,7 +49,7 @@ import 'package:flutter/services.dart'; /// 卡片信息 class GroupInfo { /// 唯一ID - int groupId; + int? groupId; /// 组名称 String groupName; @@ -64,10 +64,10 @@ class GroupInfo { bool isSupportTheme; /// 子Widget - List children; + List? children; /// 跳转到下一个页面 - Function(BuildContext context) navigatorPage; + Function(BuildContext context)? navigatorPage; GroupInfo( {this.groupId, @@ -83,7 +83,7 @@ class GroupInfo { class CardDataConfig { /// 全部 static List getAllGroup() { - List list = List(); + List list = []; list.add(_getChartGroup()); list.add(_getDataInputGroup()); list.add(_getOperateGroup()); @@ -95,14 +95,14 @@ class CardDataConfig { /// 数据图表 static GroupInfo _getChartGroup() { - List children = List(); + List children = []; children.add(GroupInfo( groupName: "BrokenLine 折线图 ", desc: "数据折线图", navigatorPage: (BuildContext context) { rootBundle.loadString('assets/brokenline_data.json').then((data) { - var brokenData = List() - ..addAll(((JsonDecoder().convert(data) as List) ?? []) + var brokenData = [] + ..addAll(((JsonDecoder().convert(data) as List?) ?? []) .map((o) => DBDataNodeModel.fromJson(o))); Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { @@ -167,7 +167,7 @@ class CardDataConfig { /// 数据录入 static GroupInfo _getDataInputGroup() { - List children = List(); + List children = []; children.add(GroupInfo( groupName: "Form 表单项", desc: "各种表单项", @@ -215,7 +215,7 @@ class CardDataConfig { /// 操作反馈类 static GroupInfo _getOperateGroup() { - List children = List(); + List children = []; children.add(GroupInfo( groupName: "Dialog 弹窗", desc: "Dialog多种类型展示", @@ -273,7 +273,7 @@ class CardDataConfig { /// 导航类 static GroupInfo _getNavigatorGroup() { - List children = List(); + List children = []; children.add(GroupInfo( groupName: "Appbar 导航栏", desc: "Appbar 导航栏", @@ -361,7 +361,7 @@ class CardDataConfig { /// 按钮 static GroupInfo _getButtonGroup() { - List children = List(); + List children = []; children.add(GroupInfo( groupName: "NormalButton 普通按钮", desc: "主按钮、次按钮、按钮集合", @@ -428,7 +428,7 @@ class CardDataConfig { /// 内容 static GroupInfo _getContentGroup() { - List children = List(); + List children =[]; children.add(GroupInfo( groupName: "Tag 标签", desc: "标签多种样式", @@ -558,7 +558,7 @@ class CardDataConfig { /// 城市选择 static Widget _buildSingleSelectCityPage() { - List hotCityList = List(); + List hotCityList = []; hotCityList.addAll([ BrnSelectCityModel(name: "北京市"), BrnSelectCityModel(name: "广州市"), diff --git a/example/lib/sample/home/expandable_container_widget.dart b/example/lib/sample/home/expandable_container_widget.dart index 468b4af5..d8264175 100644 --- a/example/lib/sample/home/expandable_container_widget.dart +++ b/example/lib/sample/home/expandable_container_widget.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 + import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -23,21 +23,20 @@ import 'package:flutter/widgets.dart'; /// * The "Expand/collapse" section of class BrnExpandableContainerWidget extends StatefulWidget { - final Widget Function(BuildContext context) headerBuilder; + final Widget Function(BuildContext context)? headerBuilder; /// Creates a single-line [ListTile] with a trailing button that expands or collapses /// the tile to reveal or hide the [children]. The [initiallyExpanded] property must /// be non-null. const BrnExpandableContainerWidget({ - Key key, + Key? key, this.onExpansionChanged, this.headerBuilder, this.child, this.initiallyExpanded = false, this.animationDuration, this.expandableController, - }) : assert(initiallyExpanded != null), - super(key: key); + }) : super(key: key); /// A widget to display before the title. /// @@ -47,19 +46,19 @@ class BrnExpandableContainerWidget extends StatefulWidget { /// When the tile starts expanding, this function is called with the value /// true. When the tile starts collapsing, this function is called with /// the value false. - final ValueChanged onExpansionChanged; + final ValueChanged? onExpansionChanged; /// The widgets that are displayed when the tile expands. /// /// Typically [ListTile] widgets. - final Widget child; + final Widget? child; /// Specifies if the list tile is initially expanded (true) or collapsed (false, the default). final bool initiallyExpanded; - final Duration animationDuration; + final Duration? animationDuration; - final BrnExpandableContainerController expandableController; + final BrnExpandableContainerController? expandableController; @override _BrnExpansionContainerElementState createState() => _BrnExpansionContainerElementState(); @@ -69,13 +68,13 @@ class _BrnExpansionContainerElementState extends State _easeInTween = CurveTween(curve: Curves.easeIn); - BrnExpandableContainerController _expandableController; - AnimationController _animationController; - Animation _heightFactor; + BrnExpandableContainerController? _expandableController; + AnimationController? _animationController; + late Animation _heightFactor; bool _isExpanded = false; - Widget arrowIcon; + Widget? arrowIcon; @override void initState() { @@ -84,21 +83,21 @@ class _BrnExpansionContainerElementState extends State with SingleTickerProviderStateMixin { static final Animatable _easeInTween = CurveTween(curve: Curves.easeIn); static final Animatable _halfTween = Tween(begin: 0.0, end: 0.5); - BrnExpandableContainerController _controller; - Widget _arrowIcon; - Animation _iconTurns; - bool _initExpand; - AnimationController _animationController; + BrnExpandableContainerController? _controller; + Widget? _arrowIcon; + late Animation _iconTurns; + late bool _initExpand; + AnimationController? _animationController; @override void initState() { super.initState(); _controller = BrnExpandableContainerController(); _animationController = AnimationController(duration: Duration(milliseconds: 200), vsync: this); - _initExpand = widget.groupInfo.isExpand; - _iconTurns = _animationController.drive(_halfTween.chain(_easeInTween)); + _initExpand = widget.groupInfo!.isExpand; + _iconTurns = _animationController!.drive(_halfTween.chain(_easeInTween)); if (_initExpand) { _arrowIcon = Icon(Icons.keyboard_arrow_up); } else { @@ -64,7 +64,7 @@ class GroupCardState extends State with SingleTickerProviderStateMixi } else { _arrowIcon = Icon(Icons.keyboard_arrow_down); } - widget.groupInfo.isExpand = isExpand; + widget.groupInfo!.isExpand = isExpand; }, headerBuilder: (_) { return GestureDetector( @@ -78,7 +78,7 @@ class GroupCardState extends State with SingleTickerProviderStateMixi children: [ Expanded( child: Text( - widget.groupInfo.groupName, + widget.groupInfo!.groupName, style: TextStyle(color: Color(0xFF222222), fontSize: 18), )), RotationTransition( @@ -96,6 +96,9 @@ class GroupCardState extends State with SingleTickerProviderStateMixi } Widget _getContentWidget() { + if(widget.groupInfo == null || widget.groupInfo!.children == null){ + return SizedBox.shrink(); + } return ListView.builder( physics: new NeverScrollableScrollPhysics(), shrinkWrap: true, @@ -104,14 +107,14 @@ class GroupCardState extends State with SingleTickerProviderStateMixi return Container( color: Colors.white, child: ListItem( - isSupportTheme: widget.groupInfo?.children[index]?.isSupportTheme, + isSupportTheme: widget.groupInfo?.children![index].isSupportTheme ?? false, isShowLine: !(index == 0), - title: widget.groupInfo?.children[index].groupName, - describe: widget.groupInfo?.children[index].desc, + title: widget.groupInfo?.children![index].groupName ?? '', + describe: widget.groupInfo?.children![index].desc ?? '', onPressed: () { if (widget.groupInfo?.children != null && - widget.groupInfo?.children[index].navigatorPage != null) { - widget.groupInfo?.children[index].navigatorPage(context); + widget.groupInfo?.children![index].navigatorPage != null) { + widget.groupInfo?.children![index].navigatorPage!(context); } }, ), diff --git a/example/lib/sample/home/home.dart b/example/lib/sample/home/home.dart index 179aa98d..6a700325 100644 --- a/example/lib/sample/home/home.dart +++ b/example/lib/sample/home/home.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:example/sample/home/card_data_config.dart'; diff --git a/example/lib/sample/home/list_item.dart b/example/lib/sample/home/list_item.dart index 70ad5974..5947c96c 100644 --- a/example/lib/sample/home/list_item.dart +++ b/example/lib/sample/home/list_item.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'package:bruno/bruno.dart'; import 'package:flutter/material.dart'; @@ -6,26 +6,26 @@ import 'package:flutter/material.dart'; /// 列表项 class ListItem extends StatefulWidget { /// 点击事件 - final VoidCallback onPressed; + final VoidCallback? onPressed; /// 标题 final String title; - final double titleFontSize; - final Color titleColor; - final String imgPath; + final double? titleFontSize; + final Color? titleColor; + final String? imgPath; /// 描述 final String describe; final Color describeColor; /// 右侧控件 - final Widget rightWidget; + final Widget? rightWidget; final bool isSupportTheme; final bool isShowLine; /// 构造函数 ListItem({ - Key key, + Key? key, this.onPressed, this.title = "", this.titleFontSize, diff --git a/example/lib/sample/theme/config_test_utils.dart b/example/lib/sample/theme/config_test_utils.dart index 8a0d7feb..60ae7d00 100644 --- a/example/lib/sample/theme/config_test_utils.dart +++ b/example/lib/sample/theme/config_test_utils.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + import 'dart:ui'; From 3e28aa4cf47269435442fd97a00fd6d8d3d9577d Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 26 Jan 2022 19:42:34 +0800 Subject: [PATCH 24/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86e?= =?UTF-8?q?xample=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/sample/components/popup/popwindow_example.dart | 2 +- example/lib/sample/home/home.dart | 2 +- example/lib/sample/home/list_item.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/lib/sample/components/popup/popwindow_example.dart b/example/lib/sample/components/popup/popwindow_example.dart index a0032f43..ba81cdde 100644 --- a/example/lib/sample/components/popup/popwindow_example.dart +++ b/example/lib/sample/components/popup/popwindow_example.dart @@ -45,7 +45,7 @@ class PopWindowExamplePageState extends State { @override Widget build(BuildContext context) { - double top = MediaQuery.of(context).padding.top ?? 0; + double top = MediaQuery.of(context).padding.top; return Scaffold( appBar: BrnAppBar( title: widget._title, diff --git a/example/lib/sample/home/home.dart b/example/lib/sample/home/home.dart index 6a700325..cf745500 100644 --- a/example/lib/sample/home/home.dart +++ b/example/lib/sample/home/home.dart @@ -27,7 +27,7 @@ class HomePage extends StatelessWidget { padding: EdgeInsets.fromLTRB(16, 10, 16, 0), child: ListView.builder( shrinkWrap: true, - itemCount: list?.length, + itemCount: list.length, itemBuilder: (BuildContext context, int index) { return Container( padding: EdgeInsets.only(top: 10), diff --git a/example/lib/sample/home/list_item.dart b/example/lib/sample/home/list_item.dart index 5947c96c..81fd2cc2 100644 --- a/example/lib/sample/home/list_item.dart +++ b/example/lib/sample/home/list_item.dart @@ -31,7 +31,7 @@ class ListItem extends StatefulWidget { this.titleFontSize, this.titleColor, this.describe = "", - this.describeColor: Colors.grey, + this.describeColor = const Color(0xFF999999), this.rightWidget, this.imgPath, this.isSupportTheme = false, @@ -93,7 +93,7 @@ class _ListItemState extends State { Padding(padding: EdgeInsets.all(2)), Text( widget.describe, - style: TextStyle(color: widget.describeColor ?? Color(0xFF999999), fontSize: 12), + style: TextStyle(color: widget.describeColor, fontSize: 12), ), BrnLine( height: 14, From 00f8a47a63044d88e1b3f302623bdbd5b68098d5 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Thu, 27 Jan 2022 12:47:51 +0800 Subject: [PATCH 25/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Ddemo=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/sample/components/popup/popwindow_example.dart | 1 - .../lib/sample/components/tabbar/brn_tabbar_sticky_example.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/example/lib/sample/components/popup/popwindow_example.dart b/example/lib/sample/components/popup/popwindow_example.dart index ba81cdde..0645716f 100644 --- a/example/lib/sample/components/popup/popwindow_example.dart +++ b/example/lib/sample/components/popup/popwindow_example.dart @@ -45,7 +45,6 @@ class PopWindowExamplePageState extends State { @override Widget build(BuildContext context) { - double top = MediaQuery.of(context).padding.top; return Scaffold( appBar: BrnAppBar( title: widget._title, diff --git a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart index 410af360..a12d990d 100644 --- a/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart +++ b/example/lib/sample/components/tabbar/brn_tabbar_sticky_example.dart @@ -17,7 +17,7 @@ class _BrnTabbarStickyExampleState extends State ScrollController scrollController = ScrollController(); BrnCloseWindowController? closeWindowController; - var tabs = []; + List tabs = []; @override void initState() { From 8b17ba3b1ff0329a6b5c148bca1febc6af2022e4 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Thu, 27 Jan 2022 12:48:58 +0800 Subject: [PATCH 26/31] =?UTF-8?q?fix:=E8=BF=BD=E5=8A=A0=E6=9C=AA=E8=B7=9F?= =?UTF-8?q?=E8=B8=AA=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bruno.dart | 2 -- .../actionsheet/brn_selected_list_action_sheet.dart | 6 +++--- lib/src/components/appraise/brn_mulit_select_tags.dart | 2 +- lib/src/components/picker/brn_bottom_write_picker.dart | 4 ++-- .../picker/brn_select_tags_with_input_picker.dart | 2 +- lib/src/components/tag/tagview/brn_delete_tag.dart | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/bruno.dart b/lib/bruno.dart index f2a5eeb0..8ca380d3 100644 --- a/lib/bruno.dart +++ b/lib/bruno.dart @@ -1,5 +1,3 @@ -// @dart=2.9 - library bruno; // 主题 diff --git a/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart b/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart index 606aefbc..71233ee2 100644 --- a/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart +++ b/lib/src/components/actionsheet/brn_selected_list_action_sheet.dart @@ -206,7 +206,7 @@ class BrnSelectedListActionSheet { class _BrnActionSheetSelectedItemListContentWidget extends StatefulWidget { final BrnSelectedListActionSheet itemWidget; final void Function(bool isClear)? onDismiss; - final dynamic Function(int index, T entity)? itemTitleBuilder; + final dynamic Function(int index, T entity) itemTitleBuilder; final bool Function(int deleteIdx, T deleteEntity)? onItemDelete; final BrnSelectedListActionSheetController? controller; @@ -223,7 +223,7 @@ class _BrnActionSheetSelectedItemListContentWidget extends StatefulWidget { _BrnActionSheetSelectedItemListContentWidget( {required this.itemWidget, this.onDismiss, - this.itemTitleBuilder, + required this.itemTitleBuilder, this.onItemDelete, this.controller}); @@ -451,7 +451,7 @@ class _BrnActionSheetSelectedItemListState // 获取标题 Widget content = Container(color: Colors.white); if (index < widget.itemWidget.items.length) { - var item = widget.itemTitleBuilder!( + var item = widget.itemTitleBuilder( index, widget.itemWidget.items[index]); if (item is String) { content = Text( diff --git a/lib/src/components/appraise/brn_mulit_select_tags.dart b/lib/src/components/appraise/brn_mulit_select_tags.dart index bb4ab12b..495db92f 100644 --- a/lib/src/components/appraise/brn_mulit_select_tags.dart +++ b/lib/src/components/appraise/brn_mulit_select_tags.dart @@ -91,7 +91,7 @@ class _BrnMultiSelectTagsState extends State { @override Widget build(BuildContext context) { - if (widget.tagPickerBean.tagItemSource?.isNotEmpty ?? false) { + if (widget.tagPickerBean.tagItemSource.isNotEmpty) { return _buildContent(context); } else { return widget.emptyWidget ?? diff --git a/lib/src/components/picker/brn_bottom_write_picker.dart b/lib/src/components/picker/brn_bottom_write_picker.dart index 553e810f..c5a5cbaf 100644 --- a/lib/src/components/picker/brn_bottom_write_picker.dart +++ b/lib/src/components/picker/brn_bottom_write_picker.dart @@ -6,11 +6,11 @@ import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/material.dart'; ///取消输入事件回调 -typedef BrnBottomWritePickerClickCallback = Future Function( +typedef BrnBottomWritePickerClickCallback = Future? Function( String? content); ///确认输入事件回调 -typedef BrnBottomWritePickerConfirmClickCallback = Future Function( +typedef BrnBottomWritePickerConfirmClickCallback = Future? Function( BuildContext dialogContext, String? content); class BrnBottomWritePicker extends StatefulWidget { diff --git a/lib/src/components/picker/brn_select_tags_with_input_picker.dart b/lib/src/components/picker/brn_select_tags_with_input_picker.dart index 97280e81..bb39f13f 100644 --- a/lib/src/components/picker/brn_select_tags_with_input_picker.dart +++ b/lib/src/components/picker/brn_select_tags_with_input_picker.dart @@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart'; typedef SelectTagWithInputValueGetter = String Function(V data); ///提交按钮事件回调 -typedef BrnTagInputConfirmClickCallback = Future Function( +typedef BrnTagInputConfirmClickCallback = Future? Function( BuildContext dialogContext, List? selectedTags, String content); diff --git a/lib/src/components/tag/tagview/brn_delete_tag.dart b/lib/src/components/tag/tagview/brn_delete_tag.dart index 590edae5..4e22b71e 100644 --- a/lib/src/components/tag/tagview/brn_delete_tag.dart +++ b/lib/src/components/tag/tagview/brn_delete_tag.dart @@ -12,7 +12,7 @@ import 'package:flutter/widgets.dart'; /// ignore: must_be_immutable class BrnDeleteTag extends StatefulWidget { /// 初始传入的标签,当传入controller的时候,应把初始标签放入controller的构造中 - final List tags; + final List? tags; /// 标签控制器,用于主动添加和删除标签,如果使用场景只需要删除标签并进行回调可以不传控制器 final BrnDeleteTagController? controller; @@ -55,7 +55,7 @@ class BrnDeleteTag extends StatefulWidget { BrnDeleteTag( {Key? key, - required this.tags, + this.tags, this.controller, this.onTagDelete, this.verticalSpacing, From a526542c10c60d39f27ebc21448b9c28957d4cf0 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Thu, 27 Jan 2022 16:15:15 +0800 Subject: [PATCH 27/31] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=AF=E7=A9=BA=E5=8F=82=E6=95=B0=E4=B8=BA?= =?UTF-8?q?=E9=9D=9E=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/bubble/brn_expanded_bubble_example.dart | 2 +- .../card/content/brn_two_rich_content_example.dart | 4 ++-- .../sample/components/dialog/dialog_entry_page.dart | 4 ++-- .../form/items_example/multi_choice_example.dart | 4 ++-- .../items_example/multi_choice_protrait_example.dart | 12 ++++++------ .../card/content_card/brn_pair_info_rich_grid.dart | 8 ++++---- .../components/form/base/input_item_interface.dart | 2 +- lib/src/components/text/brn_expandable_text.dart | 12 +++--------- lib/src/utils/css/brn_core_funtion.dart | 2 +- 9 files changed, 22 insertions(+), 28 deletions(-) diff --git a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart index 641b72ee..46b50a47 100644 --- a/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart +++ b/example/lib/sample/components/card/bubble/brn_expanded_bubble_example.dart @@ -40,7 +40,7 @@ class BrnBubbleExample2 extends StatelessWidget { maxLines: 2, text: '推荐理由:“满五唯一”“临近地铁”“首付低”,多出折行显示,文字展开的样式文式文文字展开的样式文式文。问我', onExpanded: (isExpanded){ - String str = isExpanded!?"展开了":"收起了"; + String str = isExpanded ? "展开了" : "收起了"; BrnToast.show("我$str", context); }, ), diff --git a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart index 2fbc5f2c..36f082ef 100644 --- a/example/lib/sample/components/card/content/brn_two_rich_content_example.dart +++ b/example/lib/sample/components/card/content/brn_two_rich_content_example.dart @@ -54,11 +54,11 @@ class _BrnTwoRichContentExampleState extends State { }, clickTitle: "可点击内容", clickCallback: (value) { - BrnToast.show(value!, context); + BrnToast.show(value, context); }), BrnRichGridInfo.valueLastClickInfo('名称', '内容内容', clickTitle: "可点击内容", clickCallback: (value) { - BrnToast.show(value!, context); + BrnToast.show(value, context); }), ], ), diff --git a/example/lib/sample/components/dialog/dialog_entry_page.dart b/example/lib/sample/components/dialog/dialog_entry_page.dart index cbd2d9ca..ee418ca9 100644 --- a/example/lib/sample/components/dialog/dialog_entry_page.dart +++ b/example/lib/sample/components/dialog/dialog_entry_page.dart @@ -394,7 +394,7 @@ class DialogEntryPage extends StatelessWidget { //光标圆角弧度 cursorRadius: Radius.circular(2.0), style: TextStyle(fontSize: 14, color: Color(0xFF222222)), - maxLengthEnforced: true, + maxLengthEnforcement: MaxLengthEnforcement.enforced, onChanged: (value) {}, decoration: InputDecoration( contentPadding: EdgeInsets.all(8.0), @@ -415,7 +415,7 @@ class DialogEntryPage extends StatelessWidget { )), ), ), - onItemClick: (BuildContext contex, int index) { + onItemClick: (BuildContext context, int index) { hintText = data[index].content; state(() {}); }, diff --git a/example/lib/sample/components/form/items_example/multi_choice_example.dart b/example/lib/sample/components/form/items_example/multi_choice_example.dart index 2ba679aa..b7ea227f 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_example.dart @@ -119,9 +119,9 @@ class MultiChoiceInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List? newValue) { + onChanged: (List oldValue, List newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); }, ), ], diff --git a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart index f3e789b1..c200a947 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart @@ -46,9 +46,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List? newValue) { + onChanged: (List oldValue, List newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); }, ), Container( @@ -87,9 +87,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List? newValue) { + onChanged: (List oldValue, List newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); }, ), Container( @@ -127,9 +127,9 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { onRemoveTap: () { BrnToast.show("点击触发onRemoveTap回调", context); }, - onChanged: (List oldValue, List? newValue) { + onChanged: (List oldValue, List newValue) { BrnToast.show( - "点击触发onChanged回调${oldValue.length}_${newValue!.length}_onChanged", context); + "点击触发onChanged回调${oldValue.length}_${newValue.length}_onChanged", context); }, ), ], diff --git a/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart b/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart index 310ebe61..ca1f2666 100644 --- a/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart +++ b/lib/src/components/card/content_card/brn_pair_info_rich_grid.dart @@ -208,9 +208,9 @@ class BrnRichGridInfo { String valueTitle, { Function(String key)? keyQuestionCallback, Function(String value)? valueQuestionCallback, - String? clickTitle, + String clickTitle = '', Color? clickColor, - Function(String? clickValue)? clickCallback, + Function(String clickValue)? clickCallback, BrnPairRichInfoGridConfig? themeData, }) { themeData ??= BrnPairRichInfoGridConfig(); @@ -248,7 +248,7 @@ class BrnRichGridInfo { padding: EdgeInsets.only(left: 4), child: Container( constraints: BoxConstraints(maxWidth: 56), - child: Text(clickTitle!, + child: Text(clickTitle, maxLines: 1, overflow: TextOverflow.ellipsis, style: _getClickStyle(clickTitle, clickColor, @@ -260,7 +260,7 @@ class BrnRichGridInfo { bool isShowKeyQuestion = keyQuestionCallback != null; bool isShowValueQuestion = valueQuestionCallback != null; - bool isShowValueClick = clickTitle != null && clickTitle.isNotEmpty; + bool isShowValueClick = clickTitle.isNotEmpty; MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window); double screen = mediaQuery.size.width; diff --git a/lib/src/components/form/base/input_item_interface.dart b/lib/src/components/form/base/input_item_interface.dart index 13662ce4..757f960a 100644 --- a/lib/src/components/form/base/input_item_interface.dart +++ b/lib/src/components/form/base/input_item_interface.dart @@ -11,7 +11,7 @@ typedef OnBrnFormRadioValueChanged = void Function( typedef OnBrnFormSwitchChanged = void Function(bool oldValue, bool newValue); typedef OnBrnFormValueChanged = void Function(int oldValue, int newValue); typedef OnBrnFormMultiChoiceValueChanged = void Function( - List oldValue, List? newValue); + List oldValue, List newValue); typedef OnBrnFormBtnSelectChanged = void Function( List oldValue, List newValue); diff --git a/lib/src/components/text/brn_expandable_text.dart b/lib/src/components/text/brn_expandable_text.dart index 34ac9313..6bef4d72 100644 --- a/lib/src/components/text/brn_expandable_text.dart +++ b/lib/src/components/text/brn_expandable_text.dart @@ -2,7 +2,7 @@ import 'package:bruno/src/theme/brn_theme_configurator.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -typedef TextExpandedCallback = Function(bool?); +typedef TextExpandedCallback = Function(bool); /// 具备展开收起功能的文字面板 /// @@ -59,13 +59,7 @@ class BrnExpandableText extends StatefulWidget { } class _BrnExpandableTextState extends State { - bool? _expanded; - - @override - void initState() { - super.initState(); - _expanded = false; - } + bool _expanded = false; @override Widget build(BuildContext context) { @@ -139,7 +133,7 @@ class _BrnExpandableTextState extends State { setState(() { _expanded = true; if (null != widget.onExpanded) { - widget.onExpanded!(_expanded); + widget.onExpanded!(_expanded!); } }); }, diff --git a/lib/src/utils/css/brn_core_funtion.dart b/lib/src/utils/css/brn_core_funtion.dart index 441948e2..3aa03742 100644 --- a/lib/src/utils/css/brn_core_funtion.dart +++ b/lib/src/utils/css/brn_core_funtion.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:xml/xml_events.dart' as xml; /// 超链接的点击回调 -typedef BrnHyperLinkCallback = void Function(String? text, String? url); +typedef BrnHyperLinkCallback = void Function(String text, String? url); /// 用于将标签转为 style class BrnConvert { From 4c62a0c14a637dda22ae30949e30d35e9260a2bf Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 16 Feb 2022 16:06:19 +0800 Subject: [PATCH 28/31] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dtabar=20showmore=20?= =?UTF-8?q?overflow=20=E9=97=AE=E9=A2=98=20#98=20=E4=BB=A5=E5=8F=8A=20tabb?= =?UTF-8?q?ar=20=E6=A0=87=E7=AD=BE=E9=A2=9C=E8=89=B2=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=80=92=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialog/brn_scrollable_text_dialog.dart | 1 - .../components/tabbar/normal/brn_tab_bar.dart | 30 +++++++++---------- .../components/text/brn_expandable_text.dart | 4 +-- .../theme/base/brn_default_config_utils.dart | 4 +-- pubspec.yaml | 1 - 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/src/components/dialog/brn_scrollable_text_dialog.dart b/lib/src/components/dialog/brn_scrollable_text_dialog.dart index fba9656f..292e4a29 100644 --- a/lib/src/components/dialog/brn_scrollable_text_dialog.dart +++ b/lib/src/components/dialog/brn_scrollable_text_dialog.dart @@ -134,7 +134,6 @@ class BrnScrollableText extends StatelessWidget { if (onSubmitClick != null) { onSubmitClick!(); } - Navigator.pop(context); }, isShowOperateWidget: isShowOperateWidget, ); diff --git a/lib/src/components/tabbar/normal/brn_tab_bar.dart b/lib/src/components/tabbar/normal/brn_tab_bar.dart index dde8b4a3..d3a17121 100644 --- a/lib/src/components/tabbar/normal/brn_tab_bar.dart +++ b/lib/src/components/tabbar/normal/brn_tab_bar.dart @@ -15,7 +15,7 @@ import 'package:flutter/rendering.dart'; /// [state]:当前组件的State对象,[BrnTabBarState] /// [index]:当前组件的角标 typedef BrnTabBarOnTap = Function(BrnTabBarState state, int index); - +const double _tagDefaultSize = 75.0; /// 带小红点的Tabbar // ignore: must_be_immutable class BrnTabBar extends StatefulWidget { @@ -628,6 +628,7 @@ class BrnTabBarState extends State { // 更多弹框样式 // ignore: must_be_immutable class _TabBarOverlayWidget extends StatefulWidget { + List? tabs; String? moreWindowText; @@ -637,22 +638,22 @@ class _TabBarOverlayWidget extends StatefulWidget { BrnTabBarConfig themeData; /// tag间距 - double? spacing; + double spacing; /// 每行tag数 - int? preLineTagCount; + int preLineTagCount; /// tag高度 double? tagHeight; _TabBarOverlayWidget( {this.tabs, - this.moreWindowText, - this.brnTabbarController, - required this.themeData, - this.spacing, - this.preLineTagCount, - this.tagHeight}); + this.moreWindowText, + this.brnTabbarController, + required this.themeData, + this.spacing: 12.0, + this.preLineTagCount: 4, + this.tagHeight}); @override _TabBarOverlayWidgetState createState() => _TabBarOverlayWidgetState(); @@ -660,7 +661,7 @@ class _TabBarOverlayWidget extends StatefulWidget { class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { /// tag宽度 - double? _tagWidth; + double _tagWidth = _tagDefaultSize; double _padding = 20; @@ -724,11 +725,8 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { Widget _createMoreItems() { // 计算tag的宽度 - _tagWidth = (_parentWidth - - widget.spacing! * (widget.preLineTagCount! - 1) - - _padding * 2) / - widget.preLineTagCount!; - + _tagWidth = (_parentWidth - widget.spacing * (widget.preLineTagCount - 1) - _padding * 2) / widget.preLineTagCount; + _tagWidth = _tagWidth <= _tagDefaultSize ? _tagDefaultSize : _tagWidth; List widgets = []; List? tabList = widget.tabs; if (tabList != null && tabList.isNotEmpty) { @@ -738,7 +736,7 @@ class _TabBarOverlayWidgetState extends State<_TabBarOverlayWidget> { } } return Wrap( - spacing: widget.spacing!, + spacing: widget.spacing, runSpacing: 12, children: widgets, ); diff --git a/lib/src/components/text/brn_expandable_text.dart b/lib/src/components/text/brn_expandable_text.dart index 6bef4d72..1f59e249 100644 --- a/lib/src/components/text/brn_expandable_text.dart +++ b/lib/src/components/text/brn_expandable_text.dart @@ -74,7 +74,7 @@ class _BrnExpandableTextState extends State { ellipsis: 'EllipseText'); tp.layout(maxWidth: size.maxWidth); if (tp.didExceedMaxLines) { - if (this._expanded!) { + if (this._expanded) { return _expandedText(context, widget.text); } else { return _foldedText(context, widget.text); @@ -133,7 +133,7 @@ class _BrnExpandableTextState extends State { setState(() { _expanded = true; if (null != widget.onExpanded) { - widget.onExpanded!(_expanded!); + widget.onExpanded!(_expanded); } }); }, diff --git a/lib/src/theme/base/brn_default_config_utils.dart b/lib/src/theme/base/brn_default_config_utils.dart index cbc06626..a19e4090 100644 --- a/lib/src/theme/base/brn_default_config_utils.dart +++ b/lib/src/theme/base/brn_default_config_utils.dart @@ -596,12 +596,12 @@ class BrnDefaultConfigUtils { color: defaultCommonConfig.colorTextBase, fontSize: defaultCommonConfig.fontSizeCaption, ), - tagNormalBgColor: defaultCommonConfig.brandPrimary.withAlpha(0x14), + tagNormalBgColor: defaultCommonConfig.fillBody, tagSelectedTextStyle: BrnTextStyle( color: defaultCommonConfig.brandPrimary, fontSize: defaultCommonConfig.fontSizeCaption, ), - tagSelectedBgColor: defaultCommonConfig.fillBody, + tagSelectedBgColor: defaultCommonConfig.brandPrimary.withAlpha(0x14), tagSpacing: 12.0, preLineTagCount: 4, tagHeight: 32.0, diff --git a/pubspec.yaml b/pubspec.yaml index 778feff4..a1991422 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,6 @@ dependencies: photo_view: ^0.13.0 provider: ^6.0.1 badges: ^2.0.2 - collection: ^1.15.0 dev_dependencies: flutter_test: From dcc57319a2688dcbd6e2581619bb6b47d8b83e73 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 16 Feb 2022 16:41:25 +0800 Subject: [PATCH 29/31] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=20BrnInputIte?= =?UTF-8?q?mType=20=E5=B8=B8=E9=87=8F=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../items_example/multi_choice_example.dart | 4 +- .../multi_choice_protrait_example.dart | 4 +- .../items_example/radio_input_example.dart | 6 +- .../items_example/radio_protrait_example.dart | 4 +- .../items_example/range_input_example.dart | 14 ++-- .../items_example/ratio_input_example.dart | 6 +- .../form/items_example/star_example.dart | 4 +- .../items_example/step_input_example.dart | 4 +- .../text_block_input_example.dart | 6 +- .../items_example/text_input_example.dart | 6 +- .../text_quick_select_input_example.dart | 2 +- .../items_example/text_select_example.dart | 6 +- .../items_example/title_select_example.dart | 8 +- .../form/base/brn_form_item_type.dart | 76 +++++++++---------- .../general/brn_multi_choice_input_item.dart | 4 +- .../brn_multi_choice_portrait_input_item.dart | 4 +- .../general/brn_quick_select_input_item.dart | 4 +- .../items/general/brn_radio_input_item.dart | 6 +- .../brn_radio_portrait_input_item.dart | 4 +- .../items/general/brn_range_input_item.dart | 4 +- .../items/general/brn_ratio_input_item.dart | 4 +- .../items/general/brn_star_input_item.dart | 4 +- .../items/general/brn_step_input_item.dart | 4 +- .../general/brn_text_block_input_item.dart | 4 +- .../items/general/brn_text_input_item.dart | 4 +- .../items/general/brn_text_select_item.dart | 6 +- .../general/brn_title_select_input_item.dart | 6 +- .../brn_expandable_group_with_opreate.dart | 2 +- .../form/items/group/brn_normal_group.dart | 2 +- .../form/items/misc/brn_add_label_item.dart | 2 +- .../form/items/misc/brn_title_item.dart | 4 +- .../components/form/utils/brn_form_util.dart | 32 ++++---- 32 files changed, 125 insertions(+), 125 deletions(-) diff --git a/example/lib/sample/components/form/items_example/multi_choice_example.dart b/example/lib/sample/components/form/items_example/multi_choice_example.dart index b7ea227f..204e8f4b 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_example.dart @@ -58,7 +58,7 @@ class MultiChoiceInputExamplePage extends StatelessWidget { ), ), BrnMultiChoiceInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然", @@ -97,7 +97,7 @@ class MultiChoiceInputExamplePage extends StatelessWidget { ), ), BrnMultiChoiceInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, title: "自然到", subTitle: "这里是副标题", diff --git a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart index c200a947..e74e91aa 100644 --- a/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/multi_choice_protrait_example.dart @@ -62,7 +62,7 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { ), ), BrnMultiChoicePortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", @@ -103,7 +103,7 @@ class MultiChoicePortraitInputExamplePage extends StatelessWidget { ), ), BrnMultiChoicePortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, title: "自然到访保护期", subTitle: "这里是副标题", diff --git a/example/lib/sample/components/form/items_example/radio_input_example.dart b/example/lib/sample/components/form/items_example/radio_input_example.dart index e516dba3..f05edb6e 100644 --- a/example/lib/sample/components/form/items_example/radio_input_example.dart +++ b/example/lib/sample/components/form/items_example/radio_input_example.dart @@ -57,7 +57,7 @@ class RadioInputExamplePage extends StatelessWidget { ), ), BrnRadioInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", @@ -92,7 +92,7 @@ class RadioInputExamplePage extends StatelessWidget { ), ), BrnRadioInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, title: "自然到访保护期", subTitle: "这里是副标题", @@ -126,7 +126,7 @@ class RadioInputExamplePage extends StatelessWidget { ), ), BrnRadioInputFormItem.autoLayout( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, error: "必填项不能为空", title: "autoLayout", diff --git a/example/lib/sample/components/form/items_example/radio_protrait_example.dart b/example/lib/sample/components/form/items_example/radio_protrait_example.dart index 15d71f2b..b4c3949d 100644 --- a/example/lib/sample/components/form/items_example/radio_protrait_example.dart +++ b/example/lib/sample/components/form/items_example/radio_protrait_example.dart @@ -58,7 +58,7 @@ class RadioPortraitInputExamplePage extends StatelessWidget { ), ), BrnRadioPortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", @@ -95,7 +95,7 @@ class RadioPortraitInputExamplePage extends StatelessWidget { ), ), BrnRadioPortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, title: "自然到访保护期", subTitle: "这里是副标题", diff --git a/example/lib/sample/components/form/items_example/range_input_example.dart b/example/lib/sample/components/form/items_example/range_input_example.dart index dc3f3bee..0e207851 100644 --- a/example/lib/sample/components/form/items_example/range_input_example.dart +++ b/example/lib/sample/components/form/items_example/range_input_example.dart @@ -36,7 +36,7 @@ class RangeInputExamplePage extends StatelessWidget { maxUnit: "天", leftMaxCount: 1, rightMaxCount: 3, - inputType: BrnInputType.NUMBER, + inputType: BrnInputType.number, onTip: () { BrnToast.show("点击触发onTip回调", context); }, @@ -66,7 +66,7 @@ class RangeInputExamplePage extends StatelessWidget { BrnRangeInputFormItem( minController: TextEditingController()..text = "10", maxController: TextEditingController()..text = "100", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "保护期", @@ -79,7 +79,7 @@ class RangeInputExamplePage extends StatelessWidget { maxUnit: "天", leftMaxCount: 1, rightMaxCount: 3, - inputType: BrnInputType.NUMBER, + inputType: BrnInputType.number, onTip: () { BrnToast.show("点击触发onTip回调", context); }, @@ -109,7 +109,7 @@ class RangeInputExamplePage extends StatelessWidget { BrnRangeInputFormItem( minController: TextEditingController()..text = "10", maxController: TextEditingController()..text = "100", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, title: "保护期", subTitle: "这里是副标题", @@ -121,7 +121,7 @@ class RangeInputExamplePage extends StatelessWidget { maxUnit: "天", leftMaxCount: 2, rightMaxCount: 3, - inputType: BrnInputType.NUMBER, + inputType: BrnInputType.number, onTip: () { BrnToast.show("点击触发onTip回调", context); }, @@ -151,7 +151,7 @@ class RangeInputExamplePage extends StatelessWidget { BrnRangeInputFormItem( minController: TextEditingController()..text = "10", maxController: TextEditingController()..text = "100", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, title: "保护期", subTitle: "这里是副标题", @@ -164,7 +164,7 @@ class RangeInputExamplePage extends StatelessWidget { maxUnit: "天", leftMaxCount: 2, rightMaxCount: 3, - inputType: BrnInputType.NUMBER, + inputType: BrnInputType.number, onTip: () { BrnToast.show("点击触发onTip回调", context); }, diff --git a/example/lib/sample/components/form/items_example/ratio_input_example.dart b/example/lib/sample/components/form/items_example/ratio_input_example.dart index d70b608a..5d374d59 100644 --- a/example/lib/sample/components/form/items_example/ratio_input_example.dart +++ b/example/lib/sample/components/form/items_example/ratio_input_example.dart @@ -54,7 +54,7 @@ class RatioInputExamplePage extends StatelessWidget { ), BrnRatioInputFormItem( controller: TextEditingController()..text = "1.6", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -86,7 +86,7 @@ class RatioInputExamplePage extends StatelessWidget { ), BrnRatioInputFormItem( controller: TextEditingController()..text = "1.6", - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, isEdit: true, title: "车位比", @@ -117,7 +117,7 @@ class RatioInputExamplePage extends StatelessWidget { ), BrnRatioInputFormItem( controller: TextEditingController()..text = "1.6", - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/example/lib/sample/components/form/items_example/star_example.dart b/example/lib/sample/components/form/items_example/star_example.dart index 59aa73ff..d9f2f43f 100644 --- a/example/lib/sample/components/form/items_example/star_example.dart +++ b/example/lib/sample/components/form/items_example/star_example.dart @@ -54,7 +54,7 @@ class StarInputExamplePage extends StatelessWidget { ), ), BrnStarsFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -87,7 +87,7 @@ class StarInputExamplePage extends StatelessWidget { ), ), BrnStarsFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, isEdit: true, title: "自然到访保护期", diff --git a/example/lib/sample/components/form/items_example/step_input_example.dart b/example/lib/sample/components/form/items_example/step_input_example.dart index d07e7feb..07a92d2f 100644 --- a/example/lib/sample/components/form/items_example/step_input_example.dart +++ b/example/lib/sample/components/form/items_example/step_input_example.dart @@ -56,7 +56,7 @@ class StepInputExamplePage extends StatelessWidget { ), ), BrnStepInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -89,7 +89,7 @@ class StepInputExamplePage extends StatelessWidget { ), ), BrnStepInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, isEdit: true, title: "自然到访保护期", diff --git a/example/lib/sample/components/form/items_example/text_block_input_example.dart b/example/lib/sample/components/form/items_example/text_block_input_example.dart index 81685dc1..9d05ba9f 100644 --- a/example/lib/sample/components/form/items_example/text_block_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_block_input_example.dart @@ -57,7 +57,7 @@ class TextBlockInputExamplePage extends StatelessWidget { ), BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -90,7 +90,7 @@ class TextBlockInputExamplePage extends StatelessWidget { ), BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, title: "备注", @@ -122,7 +122,7 @@ class TextBlockInputExamplePage extends StatelessWidget { ), BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/example/lib/sample/components/form/items_example/text_input_example.dart b/example/lib/sample/components/form/items_example/text_input_example.dart index 08dfe421..2e3037d8 100644 --- a/example/lib/sample/components/form/items_example/text_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_input_example.dart @@ -56,7 +56,7 @@ class TextInputExamplePage extends StatelessWidget { ), BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -90,7 +90,7 @@ class TextInputExamplePage extends StatelessWidget { ), BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, title: "房屋总价", @@ -123,7 +123,7 @@ class TextInputExamplePage extends StatelessWidget { ), BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart index 4666fa35..28698733 100644 --- a/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart +++ b/example/lib/sample/components/form/items_example/text_quick_select_input_example.dart @@ -94,7 +94,7 @@ class _TextQuickSelectInputExamplePageState ), ), BrnTextQuickSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, btnsTxt: options, selectBtnList: statusAllFunctionExample, diff --git a/example/lib/sample/components/form/items_example/text_select_example.dart b/example/lib/sample/components/form/items_example/text_select_example.dart index 44437767..7a689bbd 100644 --- a/example/lib/sample/components/form/items_example/text_select_example.dart +++ b/example/lib/sample/components/form/items_example/text_select_example.dart @@ -53,7 +53,7 @@ class TextSelectInputExamplePage extends StatelessWidget { ), ), BrnTextSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "证件类型", @@ -83,7 +83,7 @@ class TextSelectInputExamplePage extends StatelessWidget { ), ), BrnTextSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, title: "证件类型", subTitle: "这里是副标题", @@ -112,7 +112,7 @@ class TextSelectInputExamplePage extends StatelessWidget { ), ), BrnTextSelectFormItem.autoLayout( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "证件类型", diff --git a/example/lib/sample/components/form/items_example/title_select_example.dart b/example/lib/sample/components/form/items_example/title_select_example.dart index a629dd6c..afaff9d7 100644 --- a/example/lib/sample/components/form/items_example/title_select_example.dart +++ b/example/lib/sample/components/form/items_example/title_select_example.dart @@ -83,7 +83,7 @@ class TitleSelectInputState extends State { ), BrnTitleSelectInputFormItem( controller: TextEditingController()..text = "124", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, error: "必填项不能为空", @@ -121,7 +121,7 @@ class TitleSelectInputState extends State { ), BrnTitleSelectInputFormItem( controller: TextEditingController()..text = "124", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, subTitle: "这里是副标题", @@ -158,7 +158,7 @@ class TitleSelectInputState extends State { ), BrnTitleSelectInputFormItem( controller: TextEditingController()..text = "不可编辑时+ -号可点击", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: false, @@ -197,7 +197,7 @@ class TitleSelectInputState extends State { ), BrnTitleSelectInputFormItem( controller: TextEditingController()..text = "不可编辑时+ -号可点击", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/lib/src/components/form/base/brn_form_item_type.dart b/lib/src/components/form/base/brn_form_item_type.dart index 7b03723e..08e1cf60 100644 --- a/lib/src/components/form/base/brn_form_item_type.dart +++ b/lib/src/components/form/base/brn_form_item_type.dart @@ -1,61 +1,61 @@ class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } /// 用于描述表单项的类型 class BrnInputItemType { /// appbar 类型 - static const String HEADER_NORMAL_TYPE = "header_normal_type"; + static const String headerNormalType = "header_normal_type"; /// 表单项类型 - static const String TEXT_INPUT_TYPE = "text_input_type"; - static const String TEXT_FORMAT_INPUT_TYPE = "text_format_input_type"; - static const String TEXT_ARRAY_INPUT_TYPE = "text_array_input_type"; - static const String TEXT_SELECT_INPUT_TYPE = "text_select_input_type"; - static const String TEXT_BLOCK_INPUT_TYPE = "text_block_input_type"; - static const String TEXT_INPUT_TITLE_SELECT_TYPE = + static const String textInputType = "text_input_type"; + static const String textFormatInputType = "text_format_input_type"; + static const String textArrayInputType = "text_array_input_type"; + static const String textSelectInputType = "text_select_input_type"; + static const String textBlockInputType = "text_block_input_type"; + static const String textInputTitleSelectType = "text_input_title_select_type"; - static const String TEXT_RANGE_INPUT_TYPE = "text_range_input_type"; - static const String TEXT_STEP_INPUT_TYPE = "text_step_input_type"; - static const String RADIO_INPUT_TYPE = "radio_input_type"; - static const String RADIO_PORTRAIT_INPUT_TYPE = "radio_column_input_type"; - static const String MULTI_CHOICE_INPUT_TYPE = "multi_choice_input_type"; - static const String MULTI_CHOICE_PORTRAIT_INPUT_TYPE = + static const String textRangeInputType = "text_range_input_type"; + static const String textStepInputType = "text_step_input_type"; + static const String radioInputType = "radio_input_type"; + static const String radioPortraitInputType = "radio_column_input_type"; + static const String multiChoiceInputType = "multi_choice_input_type"; + static const String multiChoicePortraitInputType = "multi_choice_column_input_type"; - static const String SWITCH_TYPE = "switch_type"; + static const String switchType = "switch_type"; - static const String STAR_INPUT_TYPE = "star_input_type"; - static const String PHOTO_PICKER_TYPE = "photo_picker_type"; - static const String EXPAND_GROUP_TYPE = "expand_group_type"; - static const String NORMAL_GROUP_TYPE = "normal_group_type"; - static const String TEXT_INPUT_RATIO_TYPE = "text_input_ratio_type"; + static const String starInputType = "star_input_type"; + static const String photoPickerType = "photo_picker_type"; + static const String expandGroupType = "expand_group_type"; + static const String normalGroupType = "normal_group_type"; + static const String textInputRatioType = "text_input_ratio_type"; - static const String TEXT_QUICK_SELECT_INPUT_TYPE = + static const String textQuickSelectInputType = "text_quick_select_input_type"; /// bottom类型 - static const String BOTTOM_BTN_TYPE = "bottom_btn_type"; + static const String bottomBtnType = "bottom_btn_type"; - static const String BTN_TYPE = "btn_type"; - static const String BTN_MULTI_TYPE = "btn_multi_type"; - static const String BTN_MULTI_STATE_TYPE = "btn_multi_state_type"; + static const String btnType = "btn_type"; + static const String btnMultiType = "btn_multi_type"; + static const String btnMultiStateType = "btn_multi_state_type"; - static const String LABEL_TITLE = "label_title"; - static const String LABEL_ADD = "label_add"; + static const String labelTitle = "label_title"; + static const String labelAdd = "label_add"; } class BrnInputType { - static const String TEXT = "text"; - static const String MULTI_LINE = "multiline"; - static const String NUMBER = "number"; - static const String DECIMAL = "decimal"; - static const String PHONE = "phone"; - static const String DATE = "datetime"; - static const String EMAIL = "emailAddress"; - static const String URL = "url"; - static const String PWD = "visiblePassword"; + static const String text = "text"; + static const String multiLine = "multiline"; + static const String number = "number"; + static const String decimal = "decimal"; + static const String phone = "phone"; + static const String date = "datetime"; + static const String email = "emailAddress"; + static const String url = "url"; + static const String pwd = "visiblePassword"; } diff --git a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart index 48707df0..1c632b54 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_input_item.dart @@ -19,7 +19,7 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.MULTI_CHOICE_INPUT_TYPE; + final String type = BrnInputItemType.multiChoiceInputType; /// 录入项标题 final String title; @@ -76,7 +76,7 @@ class BrnMultiChoiceInputFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = true, diff --git a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart index af1de928..8ed2e616 100644 --- a/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_multi_choice_portrait_input_item.dart @@ -20,7 +20,7 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.MULTI_CHOICE_PORTRAIT_INPUT_TYPE; + String type = BrnInputItemType.multiChoicePortraitInputType; /// 录入项标题 final String title; @@ -77,7 +77,7 @@ class BrnMultiChoicePortraitInputFormItem extends StatefulWidget { this.title = "", this.subTitle = "", this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, diff --git a/lib/src/components/form/items/general/brn_quick_select_input_item.dart b/lib/src/components/form/items/general/brn_quick_select_input_item.dart index bf8521a7..dd594699 100644 --- a/lib/src/components/form/items/general/brn_quick_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_quick_select_input_item.dart @@ -22,7 +22,7 @@ class BrnTextQuickSelectFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_QUICK_SELECT_INPUT_TYPE; + String type = BrnInputItemType.textQuickSelectInputType; /// 录入项标题 final String title; @@ -92,7 +92,7 @@ class BrnTextQuickSelectFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_radio_input_item.dart b/lib/src/components/form/items/general/brn_radio_input_item.dart index c23a99df..b13c7eba 100644 --- a/lib/src/components/form/items/general/brn_radio_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_input_item.dart @@ -24,7 +24,7 @@ class BrnRadioInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.RADIO_INPUT_TYPE; + final String type = BrnInputItemType.radioInputType; /// 录入项标题 final String title; @@ -90,7 +90,7 @@ class BrnRadioInputFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -118,7 +118,7 @@ class BrnRadioInputFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart index d9b1473b..3a446f72 100644 --- a/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart +++ b/lib/src/components/form/items/general/brn_radio_portrait_input_item.dart @@ -21,7 +21,7 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.RADIO_INPUT_TYPE; + String type = BrnInputItemType.radioInputType; /// 录入项标题 final String title; @@ -78,7 +78,7 @@ class BrnRadioPortraitInputFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_range_input_item.dart b/lib/src/components/form/items/general/brn_range_input_item.dart index 729cb201..00d4d1ea 100644 --- a/lib/src/components/form/items/general/brn_range_input_item.dart +++ b/lib/src/components/form/items/general/brn_range_input_item.dart @@ -20,7 +20,7 @@ class BrnRangeInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_RANGE_INPUT_TYPE; + String type = BrnInputItemType.textRangeInputType; /// 录入项标题 final String title; @@ -102,7 +102,7 @@ class BrnRangeInputFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_ratio_input_item.dart b/lib/src/components/form/items/general/brn_ratio_input_item.dart index effafcec..2a5c1293 100644 --- a/lib/src/components/form/items/general/brn_ratio_input_item.dart +++ b/lib/src/components/form/items/general/brn_ratio_input_item.dart @@ -20,7 +20,7 @@ class BrnRatioInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.TEXT_INPUT_RATIO_TYPE; + String type = BrnInputItemType.textInputRatioType; /// 录入项标题 final String title; @@ -81,7 +81,7 @@ class BrnRatioInputFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_star_input_item.dart b/lib/src/components/form/items/general/brn_star_input_item.dart index 701ba45a..b19cf5ab 100644 --- a/lib/src/components/form/items/general/brn_star_input_item.dart +++ b/lib/src/components/form/items/general/brn_star_input_item.dart @@ -22,7 +22,7 @@ class BrnStarsFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - String type = BrnInputItemType.STAR_INPUT_TYPE; + String type = BrnInputItemType.starInputType; /// 录入项标题 final String title; @@ -76,7 +76,7 @@ class BrnStarsFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_step_input_item.dart b/lib/src/components/form/items/general/brn_step_input_item.dart index 631ab199..f6c48048 100644 --- a/lib/src/components/form/items/general/brn_step_input_item.dart +++ b/lib/src/components/form/items/general/brn_step_input_item.dart @@ -21,7 +21,7 @@ class BrnStepInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.TEXT_STEP_INPUT_TYPE; + final String type = BrnInputItemType.textStepInputType; /// 录入项标题 final String title; @@ -78,7 +78,7 @@ class BrnStepInputFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, diff --git a/lib/src/components/form/items/general/brn_text_block_input_item.dart b/lib/src/components/form/items/general/brn_text_block_input_item.dart index 11cff245..7fbc70b2 100644 --- a/lib/src/components/form/items/general/brn_text_block_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_block_input_item.dart @@ -17,7 +17,7 @@ class BrnTextBlockInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.TEXT_BLOCK_INPUT_TYPE; + final String type = BrnInputItemType.textBlockInputType; /// 录入项标题 final String title; @@ -90,7 +90,7 @@ class BrnTextBlockInputFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, diff --git a/lib/src/components/form/items/general/brn_text_input_item.dart b/lib/src/components/form/items/general/brn_text_input_item.dart index 5521af36..02058a33 100644 --- a/lib/src/components/form/items/general/brn_text_input_item.dart +++ b/lib/src/components/form/items/general/brn_text_input_item.dart @@ -18,7 +18,7 @@ class BrnTextInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.TEXT_INPUT_TYPE; + final String type = BrnInputItemType.textInputType; /// 录入项标题 final String title; @@ -89,7 +89,7 @@ class BrnTextInputFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, diff --git a/lib/src/components/form/items/general/brn_text_select_item.dart b/lib/src/components/form/items/general/brn_text_select_item.dart index 2d8d3aee..1678b5c8 100644 --- a/lib/src/components/form/items/general/brn_text_select_item.dart +++ b/lib/src/components/form/items/general/brn_text_select_item.dart @@ -24,7 +24,7 @@ class BrnTextSelectFormItem extends StatefulWidget { final String? label; /// 录入项的唯一标识,主要用于录入类型页面框架中 - final String type = BrnInputItemType.TEXT_SELECT_INPUT_TYPE; + final String type = BrnInputItemType.textSelectInputType; /// 录入项类型,主要用于录入类型页面框架中 final String title; @@ -92,7 +92,7 @@ class BrnTextSelectFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -120,7 +120,7 @@ class BrnTextSelectFormItem extends StatefulWidget { this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, diff --git a/lib/src/components/form/items/general/brn_title_select_input_item.dart b/lib/src/components/form/items/general/brn_title_select_input_item.dart index fa48630e..4410cb96 100644 --- a/lib/src/components/form/items/general/brn_title_select_input_item.dart +++ b/lib/src/components/form/items/general/brn_title_select_input_item.dart @@ -24,7 +24,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.TEXT_INPUT_TITLE_SELECT_TYPE; + final String type = BrnInputItemType.textInputTitleSelectType; /// 录入项标题 final String title; @@ -98,7 +98,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, @@ -108,7 +108,7 @@ class BrnTitleSelectInputFormItem extends StatefulWidget { this.onTip, this.hint = "请输入", this.maxCount, - this.inputType = BrnInputType.TEXT, + this.inputType = BrnInputType.text, this.selectedIndex = -1, this.inputFormatters, this.onChanged, diff --git a/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart index 8d36bf0f..13a06eab 100644 --- a/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart +++ b/lib/src/components/form/items/group/brn_expandable_group_with_opreate.dart @@ -17,7 +17,7 @@ class BrnExpandFormGroup extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.NORMAL_GROUP_TYPE; + final String type = BrnInputItemType.normalGroupType; /// 录入项标题 final String title; diff --git a/lib/src/components/form/items/group/brn_normal_group.dart b/lib/src/components/form/items/group/brn_normal_group.dart index 8f2c1aa8..af71d4b8 100644 --- a/lib/src/components/form/items/group/brn_normal_group.dart +++ b/lib/src/components/form/items/group/brn_normal_group.dart @@ -18,7 +18,7 @@ class BrnNormalFormGroup extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.NORMAL_GROUP_TYPE; + final String type = BrnInputItemType.normalGroupType; /// 录入项标题 final String title; diff --git a/lib/src/components/form/items/misc/brn_add_label_item.dart b/lib/src/components/form/items/misc/brn_add_label_item.dart index 55d69e7b..731c179d 100644 --- a/lib/src/components/form/items/misc/brn_add_label_item.dart +++ b/lib/src/components/form/items/misc/brn_add_label_item.dart @@ -13,7 +13,7 @@ class BrnAddLabel extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.LABEL_ADD; + final String type = BrnInputItemType.labelAdd; /// 标题文案 final String title; diff --git a/lib/src/components/form/items/misc/brn_title_item.dart b/lib/src/components/form/items/misc/brn_title_item.dart index 0ad7d6c9..a3d77a21 100644 --- a/lib/src/components/form/items/misc/brn_title_item.dart +++ b/lib/src/components/form/items/misc/brn_title_item.dart @@ -13,7 +13,7 @@ class BrnTitleFormItem extends StatefulWidget { final String? label; /// 录入项类型,主要用于录入类型页面框架中 - final String type = BrnInputItemType.LABEL_TITLE; + final String type = BrnInputItemType.labelTitle; /// 录入项标题 final String title; @@ -58,7 +58,7 @@ class BrnTitleFormItem extends StatefulWidget { this.title = "", this.subTitle, this.tipLabel, - this.prefixIconType = BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType = BrnPrefixIconType.normal, this.error = "", this.isEdit = true, this.isRequire = false, diff --git a/lib/src/components/form/utils/brn_form_util.dart b/lib/src/components/form/utils/brn_form_util.dart index a11f269f..5ae9d8c7 100644 --- a/lib/src/components/form/utils/brn_form_util.dart +++ b/lib/src/components/form/utils/brn_form_util.dart @@ -16,7 +16,7 @@ class BrnFormUtil { static Widget buildPrefixIcon(String prefixIconType, bool isEdit, BuildContext context, VoidCallback? onAddTap, VoidCallback? onRemoveTap) { return Offstage( - offstage: prefixIconType == BrnPrefixIconType.TYPE_NORMAL, + offstage: prefixIconType == BrnPrefixIconType.normal, child: Container( padding: EdgeInsets.only(right: 6), child: GestureDetector( @@ -113,9 +113,9 @@ class BrnFormUtil { } static Widget getPrefixIcon(String type) { - if (type == BrnPrefixIconType.TYPE_ADD) { + if (type == BrnPrefixIconType.add) { return BrunoTools.getAssetImageWithBandColor(BrnAsset.iconAddFormItem); - } else if (type == BrnPrefixIconType.TYPE_REMOVE) { + } else if (type == BrnPrefixIconType.remove) { return BrunoTools.getAssetImage(BrnAsset.iconRemoveFormItem); } else { return Container(); @@ -165,7 +165,7 @@ class BrnFormUtil { /// 设置内容行padding, 包括顶部和底部padding static EdgeInsets computeEdgeInsets2(String type, bool isRequire) { - if (isRequire && type == BrnPrefixIconType.TYPE_NORMAL) { + if (isRequire && type == BrnPrefixIconType.normal) { return EdgeInsets.only(left: 10, top: 14); } @@ -187,31 +187,31 @@ class BrnFormUtil { } switch (type) { - case BrnInputType.TEXT: + case BrnInputType.text: inputType = TextInputType.text; break; - case BrnInputType.MULTI_LINE: + case BrnInputType.multiLine: inputType = TextInputType.multiline; break; - case BrnInputType.NUMBER: + case BrnInputType.number: inputType = TextInputType.number; break; - case BrnInputType.DECIMAL: + case BrnInputType.decimal: inputType = TextInputType.numberWithOptions(decimal: true); break; - case BrnInputType.PHONE: + case BrnInputType.phone: inputType = TextInputType.phone; break; - case BrnInputType.DATE: + case BrnInputType.date: inputType = TextInputType.datetime; break; - case BrnInputType.EMAIL: + case BrnInputType.email: inputType = TextInputType.emailAddress; break; - case BrnInputType.URL: + case BrnInputType.url: inputType = TextInputType.url; break; - case BrnInputType.PWD: + case BrnInputType.pwd: inputType = TextInputType.visiblePassword; break; default: @@ -228,11 +228,11 @@ class BrnFormUtil { /// 处理点击"添加/删除"按钮动作 static void notifyAddRemoveTap(BuildContext context, String prefixIconType, VoidCallback? onAddTap, VoidCallback? onRemoveTap) { - if (BrnPrefixIconType.TYPE_ADD == prefixIconType) { + if (BrnPrefixIconType.add == prefixIconType) { if (onAddTap != null) { onAddTap(); } - } else if (BrnPrefixIconType.TYPE_REMOVE == prefixIconType) { + } else if (BrnPrefixIconType.remove == prefixIconType) { if (onRemoveTap != null) { onRemoveTap(); } @@ -321,7 +321,7 @@ class BrnFormUtil { /// 标题行的左间距 static EdgeInsets titleEdgeInsets( String type, bool isRequire, BrnFormItemConfig themeData) { - if (isRequire && type == BrnPrefixIconType.TYPE_NORMAL) { + if (isRequire && type == BrnPrefixIconType.normal) { return themeData.titlePaddingSm; } return themeData.titlePaddingLg; From 6b10b9c2fae88d54114477e68d3432be975c61b3 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 16 Feb 2022 17:08:31 +0800 Subject: [PATCH 30/31] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E5=80=BC=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/appraise/appraise_example.dart | 6 +- .../calendar/calendarview_example.dart | 8 +- .../card/content/number_item_example.dart | 4 +- .../charts/chart_entry_example.dart | 4 +- .../empty/abnormal_state_example.dart | 6 +- ...selectionview_date_range_example_page.dart | 2 +- ...view_limit_max_selected_count_example.dart | 2 +- ...electionview_multi_range_example_page.dart | 2 +- lib/src/components/appraise/brn_appraise.dart | 4 +- .../appraise/brn_appraise_bottom_picker.dart | 2 +- .../appraise/brn_appraise_config.dart | 4 +- .../calendar/brn_calendar_view.dart | 48 ++++---- .../content_card/brn_enhance_number_card.dart | 8 +- .../brn_progress_bar_chart_painter.dart | 16 +-- lib/src/components/charts/funnel_chart.dart | 20 +-- lib/src/components/dialog/brn_dialog.dart | 42 +++---- .../components/empty/brn_empty_status.dart | 14 +-- .../bean/brn_multi_column_picker_entity.dart | 30 ++--- .../brn_multi_column_list.dart | 18 +-- .../brn_multi_column_picker.dart | 4 +- .../btn_multi_column_picker_item.dart | 2 +- .../date_picker/brn_date_widget.dart | 12 +- .../date_picker/brn_datetime_widget.dart | 26 ++-- .../date_picker/brn_time_widget.dart | 14 +-- .../brn_date_range_side_widget.dart | 12 +- .../bean/brn_selection_common_entity.dart | 116 +++++++++--------- .../selection/brn_flat_selection.dart | 4 +- .../selection/brn_more_selection.dart | 14 +-- .../selection/brn_selection_util.dart | 24 ++-- .../selection/brn_selection_view.dart | 4 +- .../converter/brn_selection_converter.dart | 2 +- .../widget/brn_flat_selection_item.dart | 20 +-- .../widget/brn_layer_more_selection_page.dart | 12 +- .../widget/brn_selection_list_widget.dart | 6 +- .../widget/brn_selection_menu_widget.dart | 46 +++---- .../brn_selection_more_item_widget.dart | 24 ++-- .../brn_selection_range_tag_widget.dart | 4 +- .../widget/brn_selection_range_widget.dart | 64 +++++----- .../brn_selection_single_list_widget.dart | 20 +-- 39 files changed, 335 insertions(+), 335 deletions(-) diff --git a/example/lib/sample/components/appraise/appraise_example.dart b/example/lib/sample/components/appraise/appraise_example.dart index 8c064f02..8cb7791d 100644 --- a/example/lib/sample/components/appraise/appraise_example.dart +++ b/example/lib/sample/components/appraise/appraise_example.dart @@ -67,7 +67,7 @@ class _AppraiseExampleState extends State { BrnAppraise( title: "这里是标题文字", headerType: BrnAppraiseHeaderType.center, - type: BrnAppraiseType.Star, + type: BrnAppraiseType.star, tags: tags, inputHintText: '这里是文本输入的组件', iconDescriptions: [ @@ -172,7 +172,7 @@ class _AppraiseExampleState extends State { }, ///必须传入5个字符串,没有的位置传'' - type: BrnAppraiseType.Emoji, + type: BrnAppraiseType.emoji, iconDescriptions: ['很差', '', '可以', '', '非常好'], config: BrnAppraiseConfig( indexes: [0, 2, 4], titleMaxLines: 3), @@ -206,7 +206,7 @@ class _AppraiseExampleState extends State { showToast(index, list, input, context); Navigator.pop(context); }, - type: BrnAppraiseType.Star, + type: BrnAppraiseType.star, iconDescriptions: ['很差', '不行', '可以', '好'], config: BrnAppraiseConfig( showTextInput: false, diff --git a/example/lib/sample/components/calendar/calendarview_example.dart b/example/lib/sample/components/calendar/calendarview_example.dart index 98271855..25e9f568 100644 --- a/example/lib/sample/components/calendar/calendarview_example.dart +++ b/example/lib/sample/components/calendar/calendarview_example.dart @@ -59,7 +59,7 @@ class TagViewExamplePageState extends State { Widget _calendarViewWeekNocontroll(context) { return BrnCalendarView.single( - displayMode: DisplayMode.Week, + displayMode: DisplayMode.week, showControllerBar: false, dateChange: (date) { BrnToast.show('选中的时间: $date', context); @@ -69,7 +69,7 @@ class TagViewExamplePageState extends State { Widget _calendarViewWeekNocontrollCustomWeekName(context) { return BrnCalendarView.single( - displayMode: DisplayMode.Week, + displayMode: DisplayMode.week, showControllerBar: false, weekNames: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], dateChange: (date) { @@ -80,7 +80,7 @@ class TagViewExamplePageState extends State { Widget _calendarViewWeek(context) { return BrnCalendarView.single( - displayMode: DisplayMode.Week, + displayMode: DisplayMode.week, initDisplayDate: DateTime.parse('2020-06-01'), minDate: DateTime(2020), maxDate: DateTime(2021), @@ -92,7 +92,7 @@ class TagViewExamplePageState extends State { Widget _calendarViewWeekRange(context) { return BrnCalendarView.range( - displayMode: DisplayMode.Week, + displayMode: DisplayMode.week, rangeDateChange: (rangeDate) { BrnToast.show( '开始时间: ${rangeDate.start} , 结束时间:${rangeDate.end}', context); diff --git a/example/lib/sample/components/card/content/number_item_example.dart b/example/lib/sample/components/card/content/number_item_example.dart index fcf2a48d..c70e25a0 100644 --- a/example/lib/sample/components/card/content/number_item_example.dart +++ b/example/lib/sample/components/card/content/number_item_example.dart @@ -62,7 +62,7 @@ class _NumberItemRowExampleState extends State { number: '3', preDesc: '前', lastDesc: '后', - numberInfoIcon: BrnNumberInfoIcon.ARROW, + numberInfoIcon: BrnNumberInfoIcon.arrow, iconTapCallBack: (data) {}), ], ), @@ -81,7 +81,7 @@ class _NumberItemRowExampleState extends State { number: '3', preDesc: '前', lastDesc: '后', - numberInfoIcon: BrnNumberInfoIcon.ARROW, + numberInfoIcon: BrnNumberInfoIcon.arrow, iconTapCallBack: (data) { BrnToast.show(data.title!, context); }), diff --git a/example/lib/sample/components/charts/chart_entry_example.dart b/example/lib/sample/components/charts/chart_entry_example.dart index c1fbf4ec..64dd6ea0 100644 --- a/example/lib/sample/components/charts/chart_entry_example.dart +++ b/example/lib/sample/components/charts/chart_entry_example.dart @@ -55,7 +55,7 @@ class _FunnelChartExampleState extends State { child: Column( children: [ BrnFunnelChart( - shape: FunnelShape.LeftOrRight, + shape: FunnelShape.leftOrRight, alignment: MarkerAlignment.right, maxLayerWidth: maxLayerWidth, minLayerWidth: minLayerWidth, @@ -84,7 +84,7 @@ class _FunnelChartExampleState extends State { height: 10, ), BrnFunnelChart( - shape: FunnelShape.LeftAndRight, + shape: FunnelShape.leftAndRight, alignment: alignment, maxLayerWidth: maxLayerWidth, minLayerWidth: minLayerWidth, diff --git a/example/lib/sample/components/empty/abnormal_state_example.dart b/example/lib/sample/components/empty/abnormal_state_example.dart index 6cf113ca..9ec98bd5 100644 --- a/example/lib/sample/components/empty/abnormal_state_example.dart +++ b/example/lib/sample/components/empty/abnormal_state_example.dart @@ -29,7 +29,7 @@ class AbnomalStateExample extends StatelessWidget { isCenterVertical: true, title: BrnStrings.getDateFailed, operateTexts: [BrnStrings.clickPageRetry], - operateAreaType: OperateAreaType.TextButton, + operateAreaType: OperateAreaType.textButton, action: (index) { BrnToast.show(BrnStrings.getDateFailed, context); }, @@ -71,7 +71,7 @@ class AbnomalStateExample extends StatelessWidget { ), title: "这是副标题内容这是副标题内容这是副标", content: '您的门店暂无用户', - operateAreaType: OperateAreaType.SingleButton, + operateAreaType: OperateAreaType.singleButton, operateTexts: ["切换账号"], action: (_) { BrnToast.show("第$_个按钮被点击了", context); @@ -86,7 +86,7 @@ class AbnomalStateExample extends StatelessWidget { ), title: "暂无", content: '您还没有在维护的信息哦', - operateAreaType: OperateAreaType.DoubleButton, + operateAreaType: OperateAreaType.doubleButton, operateTexts: ['去添加', '去修改'], action: (_) { BrnToast.show("第$_个按钮被点击了", context); diff --git a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart index 78beaac4..25979345 100644 --- a/example/lib/sample/components/selection/selectionview_date_range_example_page.dart +++ b/example/lib/sample/components/selection/selectionview_date_range_example_page.dart @@ -58,7 +58,7 @@ class _SelectionViewExamplePageState extends State { /// 获取评分组件 Widget _getIconWidget() { - if (widget.type == BrnAppraiseType.Emoji) { + if (widget.type == BrnAppraiseType.emoji) { return BrnAppraiseEmojiListView( indexes: widget.config.indexes, titles: widget.iconDescriptions, diff --git a/lib/src/components/appraise/brn_appraise_bottom_picker.dart b/lib/src/components/appraise/brn_appraise_bottom_picker.dart index 44f8dd24..9d6d18da 100644 --- a/lib/src/components/appraise/brn_appraise_bottom_picker.dart +++ b/lib/src/components/appraise/brn_appraise_bottom_picker.dart @@ -47,7 +47,7 @@ class BrnAppraiseBottomPicker extends StatefulWidget { Key? key, this.title = '', this.headerType = BrnAppraiseHeaderType.spaceBetween, - this.type = BrnAppraiseType.Star, + this.type = BrnAppraiseType.star, this.iconDescriptions = _defaultIconDescriptions, this.tags, this.inputHintText = '', diff --git a/lib/src/components/appraise/brn_appraise_config.dart b/lib/src/components/appraise/brn_appraise_config.dart index 866403d7..5309e308 100644 --- a/lib/src/components/appraise/brn_appraise_config.dart +++ b/lib/src/components/appraise/brn_appraise_config.dart @@ -90,8 +90,8 @@ class BrnAppraiseConfig { /// 评价组件类型 enum BrnAppraiseType { /// 表情包评价组件 - Emoji, + emoji, /// 星星评价组件 - Star, + star, } diff --git a/lib/src/components/calendar/brn_calendar_view.dart b/lib/src/components/calendar/brn_calendar_view.dart index 7fb3a339..3f5feb97 100644 --- a/lib/src/components/calendar/brn_calendar_view.dart +++ b/lib/src/components/calendar/brn_calendar_view.dart @@ -11,10 +11,10 @@ typedef CalendarDateChange = Function(DateTime date); typedef CalendarRangeDateChange = Function(DateTimeRange range); /// 展示模式,周视图模式,月视图模式 -enum DisplayMode { Week, Month } +enum DisplayMode { week, month } /// 时间选择模式,单个时间,时间范围 -enum SelectMode { SINGLE, RANGE } +enum SelectMode { single, range } const List _defaultWeekNames = ['日', '一', '二', '三', '四', '五', '六']; @@ -24,8 +24,8 @@ const List _defaultWeekNames = ['日', '一', '二', '三', '四', '五' class BrnCalendarView extends StatefulWidget { const BrnCalendarView( {Key? key, - this.selectMode = SelectMode.SINGLE, - this.displayMode = DisplayMode.Month, + this.selectMode = SelectMode.single, + this.displayMode = DisplayMode.month, this.weekNames = _defaultWeekNames, this.showControllerBar = true, this.initStartSelectedDate, @@ -37,38 +37,38 @@ class BrnCalendarView extends StatefulWidget { this.maxDate}) : assert(weekNames.length == 7), assert( - selectMode == SelectMode.SINGLE && dateChange != null || - selectMode == SelectMode.RANGE && rangeDateChange != null), + selectMode == SelectMode.single && dateChange != null || + selectMode == SelectMode.range && rangeDateChange != null), super(key: key); const BrnCalendarView.single( {Key? key, - this.displayMode = DisplayMode.Month, + this.displayMode = DisplayMode.month, this.weekNames = _defaultWeekNames, this.showControllerBar = true, this.initStartSelectedDate, this.initEndSelectedDate, this.initDisplayDate, - required CalendarDateChange this.dateChange, + required this.dateChange, this.minDate, this.maxDate}) - : this.selectMode = SelectMode.SINGLE, + : this.selectMode = SelectMode.single, this.rangeDateChange = null, assert(weekNames.length == 7), super(key: key); const BrnCalendarView.range( {Key? key, - this.displayMode = DisplayMode.Month, + this.displayMode = DisplayMode.month, this.weekNames = _defaultWeekNames, this.showControllerBar = true, this.initStartSelectedDate, this.initEndSelectedDate, this.initDisplayDate, - required CalendarRangeDateChange this.rangeDateChange, + required this.rangeDateChange, this.minDate, this.maxDate}) - : this.selectMode = SelectMode.RANGE, + : this.selectMode = SelectMode.range, this.dateChange = null, assert(weekNames.length == 7), super(key: key); @@ -132,9 +132,9 @@ class _CustomCalendarViewState extends State { _currentStartSelectedDate = widget.initStartSelectedDate; _currentEndSelectedDate = widget.initEndSelectedDate; - if (_displayMode == DisplayMode.Month) { + if (_displayMode == DisplayMode.month) { _setListOfMonthDate(_currentDate); - } else if (_displayMode == DisplayMode.Week) { + } else if (_displayMode == DisplayMode.week) { _setListOfWeekDate(_currentDate); } super.initState(); @@ -202,11 +202,11 @@ class _CustomCalendarViewState extends State { onTap: () { if (!isPreIconEnable) return; setState(() { - if (_displayMode == DisplayMode.Month) { + if (_displayMode == DisplayMode.month) { _currentDate = DateTime(_currentDate.year, _currentDate.month, 0); _setListOfMonthDate(_currentDate); - } else if (_displayMode == DisplayMode.Week) { + } else if (_displayMode == DisplayMode.week) { _currentDate = _currentDate.subtract(Duration(days: 7)); _setListOfWeekDate(_currentDate); } @@ -242,11 +242,11 @@ class _CustomCalendarViewState extends State { onTap: () { if (!isNextIconEnable) return; setState(() { - if (_displayMode == DisplayMode.Month) { + if (_displayMode == DisplayMode.month) { _currentDate = DateTime(_currentDate.year, _currentDate.month + 2, 0); _setListOfMonthDate(_currentDate); - } else if (_displayMode == DisplayMode.Week) { + } else if (_displayMode == DisplayMode.week) { _currentDate = _currentDate.add(Duration(days: 7)); _setListOfWeekDate(_currentDate); } @@ -277,7 +277,7 @@ class _CustomCalendarViewState extends State { return false; } if (dateList[0].year == _minDate.year) { - if (_displayMode == DisplayMode.Week) { + if (_displayMode == DisplayMode.week) { if (dateList[0].month < _minDate.month) { return false; } @@ -299,7 +299,7 @@ class _CustomCalendarViewState extends State { return false; } if (dateList.last.year == _maxDate.year) { - if (_displayMode == DisplayMode.Week) { + if (_displayMode == DisplayMode.week) { if (dateList.last.month > _maxDate.month) { return false; } @@ -427,12 +427,12 @@ class _CustomCalendarViewState extends State { if (date.isAfter(newMinimumDate) && date.isBefore(newMaximumDate)) { _currentDate = date; - if (_displayMode == DisplayMode.Week) { + if (_displayMode == DisplayMode.week) { _setListOfWeekDate(_currentDate); - } else if (_displayMode == DisplayMode.Month) { + } else if (_displayMode == DisplayMode.month) { _setListOfMonthDate(_currentDate); } - if (widget.selectMode == SelectMode.SINGLE) { + if (widget.selectMode == SelectMode.single) { _onSingleDateClick(date); } else { _onRangeDateClick(date); @@ -446,7 +446,7 @@ class _CustomCalendarViewState extends State { child: Text( date.day > 9 ? '${date.day}' : '0${date.day}', style: TextStyle( - color: _displayMode == DisplayMode.Month + color: _displayMode == DisplayMode.month ? (_getIsItStartAndEndDate(date) ? Colors.white : _currentDate.month == diff --git a/lib/src/components/card/content_card/brn_enhance_number_card.dart b/lib/src/components/card/content_card/brn_enhance_number_card.dart index de1624f0..1bc79a79 100644 --- a/lib/src/components/card/content_card/brn_enhance_number_card.dart +++ b/lib/src/components/card/content_card/brn_enhance_number_card.dart @@ -250,7 +250,7 @@ class BrnEnhanceNumberCard extends StatelessWidget { Widget icon = BrunoTools.getAssetSizeImage(BrnAsset.iconQuestion, 14, 14); - if (model.numberInfoIcon == BrnNumberInfoIcon.ARROW) { + if (model.numberInfoIcon == BrnNumberInfoIcon.arrow) { icon = BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 14, 14); } debugPrint('${tp.height}'); @@ -352,7 +352,7 @@ class BrnNumberInfoItemModel { BrnNumberInfoItemModel({ this.number, this.title, - this.numberInfoIcon = BrnNumberInfoIcon.QUESTION, + this.numberInfoIcon = BrnNumberInfoIcon.question, this.iconTapCallBack, this.preDesc, this.lastDesc, @@ -363,6 +363,6 @@ class BrnNumberInfoItemModel { ///可扩展 enum BrnNumberInfoIcon { - ARROW, - QUESTION, + arrow, + question, } diff --git a/lib/src/components/charts/brn_progress_bar_chart/brn_progress_bar_chart_painter.dart b/lib/src/components/charts/brn_progress_bar_chart/brn_progress_bar_chart_painter.dart index 4576437a..912efe4f 100644 --- a/lib/src/components/charts/brn_progress_bar_chart/brn_progress_bar_chart_painter.dart +++ b/lib/src/components/charts/brn_progress_bar_chart/brn_progress_bar_chart_painter.dart @@ -31,13 +31,13 @@ enum BarChartStyle { //坐标轴样式 enum AxisStyle { ///无线条 - AxisStyleNone, + axisStyleNone, ///虚线 - AxisStyleDot, + axisStyleDot, ///实线 - AxisStyleSolid, + axisStyleSolid, } /// 坐标轴项目 @@ -73,7 +73,7 @@ class ChartAxis { ChartAxis({ required this.axisItemList, this.hasMark = true, - this.axisStyle = AxisStyle.AxisStyleSolid, + this.axisStyle = AxisStyle.axisStyleSolid, }); } @@ -375,12 +375,12 @@ class BrnProgressBarChartPainter extends CustomPainter { void _drawXAxisIn(Canvas canvas, Rect xAxisRect) { if (0 == this.xAxis.axisItemList.length) return; - if (AxisStyle.AxisStyleSolid == this.xAxis.axisStyle) { + if (AxisStyle.axisStyleSolid == this.xAxis.axisStyle) { Offset xLineStart = xAxisRect.topLeft; Offset xLineEnd = xAxisRect.topRight; Paint xAxisPaint = Paint()..color = Color(0xff222222); canvas.drawLine(xLineStart, xLineEnd, xAxisPaint); - } else if (AxisStyle.AxisStyleDot == this.xAxis.axisStyle) { + } else if (AxisStyle.axisStyleDot == this.xAxis.axisStyle) { Offset xLineStart = xAxisRect.topLeft; Offset xLineEnd = xAxisRect.topRight; _drawDashLineOn(canvas, xLineStart, xLineEnd, Color(0xff222222)); @@ -455,12 +455,12 @@ class BrnProgressBarChartPainter extends CustomPainter { void _drawYAxisIn(Canvas canvas, Rect yAxisRect) { if (0 == this.yAxis.axisItemList.length) return; - if (AxisStyle.AxisStyleSolid == this.yAxis.axisStyle) { + if (AxisStyle.axisStyleSolid == this.yAxis.axisStyle) { Offset yLineStart = yAxisRect.bottomRight; Offset yLineEnd = yAxisRect.topRight; Paint yAxisPaint = Paint()..color = Color(0xff222222); canvas.drawLine(yLineStart, yLineEnd, yAxisPaint); - } else if (AxisStyle.AxisStyleDot == this.xAxis.axisStyle) { + } else if (AxisStyle.axisStyleDot == this.xAxis.axisStyle) { Offset yLineStart = yAxisRect.bottomRight; Offset yLineEnd = yAxisRect.topRight; _drawDashLineOn(canvas, yLineStart, yLineEnd, Color(0xff222222)); diff --git a/lib/src/components/charts/funnel_chart.dart b/lib/src/components/charts/funnel_chart.dart index 4a70327b..a2ac4c7d 100644 --- a/lib/src/components/charts/funnel_chart.dart +++ b/lib/src/components/charts/funnel_chart.dart @@ -11,8 +11,8 @@ import 'package:flutter/rendering.dart'; /// \____文案____/ |____文案_____/ /// ___________ + ____________ /// \__文案___/ |____文案___/ -/// 第一种,是两边都向中间缩短的漏斗[FunnelShape.LeftAndRight]。 -/// 第二种,是只有一边向中间缩短的漏斗[FunnelShape.LeftOrRight]。 +/// 第一种,是两边都向中间缩短的漏斗[FunnelShape.leftAndRight]。 +/// 第二种,是只有一边向中间缩短的漏斗[FunnelShape.leftOrRight]。 /// 通过[inputTextStyle]来控制样式。 /// 在漏斗的两层layer之间或者左右可以插入标签markers,它们可以是一些常见的Widget,如[Text],在参数[children]中提供。 /// 通过[alignment]可以控制标签的插入位置。 @@ -65,7 +65,7 @@ class BrnFunnelChart extends MultiChildRenderObjectWidget { required this.markerCount, required this.layerPainter, required MarkerBuilder builder, - this.shape = FunnelShape.LeftAndRight, + this.shape = FunnelShape.leftAndRight, this.maxLayerWidth = 200, this.minLayerWidth = 0, this.layerHeight = 40, @@ -75,7 +75,7 @@ class BrnFunnelChart extends MultiChildRenderObjectWidget { }) : assert(maxLayerWidth >= minLayerWidth), assert(layerCount - markerCount == 0 || layerCount - markerCount == 1), assert(() { - if (shape == FunnelShape.LeftOrRight && + if (shape == FunnelShape.leftOrRight && alignment == MarkerAlignment.center) { debugPrint( '当shape为FunnelShape.LeftOrRight时,alignment为MarkerAlignment.center无效'); @@ -104,7 +104,7 @@ class BrnFunnelChart extends MultiChildRenderObjectWidget { this.layerMargin = 0, this.childOffset = Offset.zero, }) : this.layerPainter = BrnDefaultFunnelLayerPainter(), - this.shape = FunnelShape.LeftAndRight, + this.shape = FunnelShape.leftAndRight, this.alignment = MarkerAlignment.right, assert(layerCount <= defaultLayerColors.length && layerCount >= 0), assert(maxLayerWidth >= minLayerWidth), @@ -577,7 +577,7 @@ class BrnFunnelRender extends RenderFunnelChart { //绘制layer文案 late double safeLeft, safeTop, safeRight, safeBottom; - if (_shape == FunnelShape.LeftAndRight) { + if (_shape == FunnelShape.leftAndRight) { safeTop = i * layerHeight + i * layerMargin; if (alignment == MarkerAlignment.right) { safeLeft = ((i + 1) * layerHeight + i * layerMargin) * @@ -647,7 +647,7 @@ class BrnFunnelRender extends RenderFunnelChart { } Path path; - if (_shape == FunnelShape.LeftAndRight || + if (_shape == FunnelShape.leftAndRight || alignment == MarkerAlignment.left) { path = Path(); //这里为什么都加了HALF_PIXEL,是因为裁剪的时候边缘会留下一定像素的误差。 @@ -662,7 +662,7 @@ class BrnFunnelRender extends RenderFunnelChart { canvas.drawPath(path, _paint); } - if (_shape == FunnelShape.LeftAndRight || + if (_shape == FunnelShape.leftAndRight || alignment == MarkerAlignment.right) { path = Path(); path.moveTo(maxLayerWidth + topLeftX + HALF_PIXEL, -HALF_PIXEL); @@ -774,10 +774,10 @@ class BrnDefaultFunnelLayerPainter extends BrnFunnelLayerPainter { ///漏斗图表的形状 enum FunnelShape { ///两边从上往下都缩小 - LeftAndRight, + leftAndRight, ///一边从上往下缩小 - LeftOrRight, + leftOrRight, } ///漏斗标签的摆放位置 diff --git a/lib/src/components/dialog/brn_dialog.dart b/lib/src/components/dialog/brn_dialog.dart index c69ff23d..2bd499bc 100644 --- a/lib/src/components/dialog/brn_dialog.dart +++ b/lib/src/components/dialog/brn_dialog.dart @@ -80,16 +80,16 @@ const Divider cDividerLine = const Divider( enum ButtonType { /// 单按钮 - Single, + single, /// 多按钮 - Multi, + multi, /// 左按钮 - Left, + left, /// 右按钮 - Right, + right, } /// 对话框的样式 @@ -448,16 +448,16 @@ class BrnDialog extends AlertDialog { color: background, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(type == ButtonType.Single || - type == ButtonType.Left || - (type == ButtonType.Multi && + bottomLeft: Radius.circular(type == ButtonType.single || + type == ButtonType.left || + (type == ButtonType.multi && actionsText != null && index == actionsText!.length - 1) ? BrnDialogUtils.getDialogRadius(dialogConfig) : 0), - bottomRight: Radius.circular(type == ButtonType.Single || - type == ButtonType.Right || - (type == ButtonType.Multi && + bottomRight: Radius.circular(type == ButtonType.single || + type == ButtonType.right || + (type == ButtonType.multi && actionsText != null && index == actionsText!.length - 1) ? BrnDialogUtils.getDialogRadius(dialogConfig) @@ -484,16 +484,16 @@ class BrnDialog extends AlertDialog { color: background, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(type == ButtonType.Single || - type == ButtonType.Left || - (type == ButtonType.Multi && + bottomLeft: Radius.circular(type == ButtonType.single || + type == ButtonType.left || + (type == ButtonType.multi && actionsText != null && index == actionsText!.length - 1) ? BrnDialogUtils.getDialogRadius(dialogConfig) : 0), - bottomRight: Radius.circular(type == ButtonType.Single || - type == ButtonType.Right || - (type == ButtonType.Multi && + bottomRight: Radius.circular(type == ButtonType.single || + type == ButtonType.right || + (type == ButtonType.multi && actionsText != null && index == actionsText!.length - 1) ? BrnDialogUtils.getDialogRadius(dialogConfig) @@ -519,7 +519,7 @@ class BrnDialog extends AlertDialog { 0, true, defaultConfig, - type: ButtonType.Single, + type: ButtonType.single, ) : actionsWidget![0]; } else if (length == 2) { @@ -531,7 +531,7 @@ class BrnDialog extends AlertDialog { child: showTextActions ? _mapTextToGesWidget( context, actionsText![0], 0, false, defaultConfig, - type: ButtonType.Left) + type: ButtonType.left) : actionsWidget![0], ), Container( @@ -542,7 +542,7 @@ class BrnDialog extends AlertDialog { child: showTextActions ? _mapTextToGesWidget( context, actionsText![1], 1, true, defaultConfig, - type: ButtonType.Right) + type: ButtonType.right) : actionsWidget![1], ) ], @@ -558,7 +558,7 @@ class BrnDialog extends AlertDialog { return showTextActions ? _mapTextToGesWidget( context, actionsText![i], i, true, defaultConfig, - type: ButtonType.Multi) + type: ButtonType.multi) : actionsWidget![i]; }, separatorBuilder: (context, i) { @@ -571,7 +571,7 @@ class BrnDialog extends AlertDialog { Widget _mapTextToGesWidget(BuildContext context, String label, int index, bool main, BrnDialogConfig dialogConfig, - {ButtonType type = ButtonType.Single}) { + {ButtonType type = ButtonType.single}) { Text text = Text(label); Widget ges = GestureDetector( child: main diff --git a/lib/src/components/empty/brn_empty_status.dart b/lib/src/components/empty/brn_empty_status.dart index 4d364d2b..2522c917 100644 --- a/lib/src/components/empty/brn_empty_status.dart +++ b/lib/src/components/empty/brn_empty_status.dart @@ -55,13 +55,13 @@ class BrnAbnormalStateUtils { /// 操作区域按钮类型 enum OperateAreaType { /// 单按钮 - SingleButton, + singleButton, /// 双按钮 - DoubleButton, + doubleButton, /// 文本按钮 - TextButton + textButton } /// 空页面操作区域按钮的点击回调 @@ -115,7 +115,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { this.img, this.title, this.content, - this.operateAreaType: OperateAreaType.TextButton, + this.operateAreaType: OperateAreaType.textButton, this.operateTexts, this.action, this.enablePageTap: false, @@ -210,7 +210,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { ///操作区按钮 _buildOperateContentWidget() { - if (OperateAreaType.SingleButton == operateAreaType) { + if (OperateAreaType.singleButton == operateAreaType) { return GestureDetector( onTap: () { if (action != null) action!(0); @@ -227,7 +227,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { style: themeData!.singleTextStyle.generateTextStyle()), ), ); - } else if (OperateAreaType.DoubleButton == operateAreaType) { + } else if (OperateAreaType.doubleButton == operateAreaType) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -269,7 +269,7 @@ class BrnAbnormalStateWidget extends StatelessWidget { ), ], ); - } else if (OperateAreaType.TextButton == operateAreaType) { + } else if (OperateAreaType.textButton == operateAreaType) { return GestureDetector( onTap: () { if (action != null) action!(0); diff --git a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart index 4ee900f6..b64f03df 100644 --- a/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart +++ b/lib/src/components/picker/multi_range_picker/bean/brn_multi_column_picker_entity.dart @@ -2,16 +2,16 @@ import 'package:bruno/src/constants/brn_constants.dart'; import 'package:bruno/src/utils/brn_tools.dart'; enum PickerFilterType { - None, //未设置 - UnLimit, // 不限类型,与其他所有类型互斥。 - Radio, //单选列表、单选项 type为radio - Checkbox, //多选列表、多选项 type为checkbox + none, //未设置 + unLimit, // 不限类型,与其他所有类型互斥。 + radio, //单选列表、单选项 type为radio + checkbox, //多选列表、多选项 type为checkbox } /// 筛选弹窗展示风格 enum PickerWindowType { - List, //列表类型,使用列表 Item 展示。 - Range, //值范围类型,使用 Tag + Range 的 Item 展示 + list, //列表类型,使用列表 Item 展示。 + range, //值范围类型,使用 Tag + Range 的 Item 展示 } class BrnPickerEntity { @@ -100,22 +100,22 @@ class BrnPickerEntity { PickerWindowType parserShowType(String showType) { if (showType == "list") { - return PickerWindowType.List; + return PickerWindowType.list; } else if (showType == "range") { - return PickerWindowType.Range; + return PickerWindowType.range; } - return PickerWindowType.List; + return PickerWindowType.list; } PickerFilterType parserFilterTypeWithType(String? type) { if (type == "unlimit") { - return PickerFilterType.UnLimit; + return PickerFilterType.unLimit; } else if (type == "radio") { - return PickerFilterType.Radio; + return PickerFilterType.radio; } else if (type == "checkbox") { - return PickerFilterType.Checkbox; + return PickerFilterType.checkbox; } - return PickerFilterType.None; + return PickerFilterType.none; } void clearChildSelection() { @@ -236,8 +236,8 @@ class BrnPickerEntity { /// 在这里简单认为 value 为空【null 或 ''】时为 unLimit. bool isUnLimit() { - return filterType == PickerFilterType.UnLimit || - (BrunoTools.isEmpty(value) && filterType == PickerFilterType.Radio); + return filterType == PickerFilterType.unLimit || + (BrunoTools.isEmpty(value) && filterType == PickerFilterType.radio); } void clearSelectedEntity() { diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart index 5a10b95f..1d6b7a55 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_list.dart @@ -131,7 +131,7 @@ class _BrnMultiColumnListWidgetState extends State { return; } - if (selectedEntity.filterType == PickerFilterType.Checkbox && + if (selectedEntity.filterType == PickerFilterType.checkbox && !selectedEntity.isSelected) { if (!BrnMultiColumnPickerUtil.isSelectedCountExceed(selectedEntity)) { BrnToast.show("您选择的数量已达上限", context); @@ -182,11 +182,11 @@ class _BrnMultiColumnListWidgetState extends State { } void _configFirstList(BrnPickerEntity selectedEntity) { - if (PickerFilterType.Radio == selectedEntity.filterType) { + if (PickerFilterType.radio == selectedEntity.filterType) { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; - } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { + } else if (PickerFilterType.checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { selectedEntity.parent!.clearChildSelection(); @@ -211,15 +211,15 @@ class _BrnMultiColumnListWidgetState extends State { void _configSecondList(BrnPickerEntity selectedEntity, int? currentListIndex) { if (currentListIndex == 1) { - if (PickerFilterType.Checkbox != selectedEntity.filterType) { + if (PickerFilterType.checkbox != selectedEntity.filterType) { selectedEntity.parent!.clearChildSelection(); } } else { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 - if (PickerFilterType.Radio == selectedEntity.filterType) { + if (PickerFilterType.radio == selectedEntity.filterType) { selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; - } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { + } else if (PickerFilterType.checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { selectedEntity.parent!.clearChildSelection(); @@ -245,15 +245,15 @@ class _BrnMultiColumnListWidgetState extends State { void _configThirdList(BrnPickerEntity selectedEntity, int? currentListIndex) { if (currentListIndex == 1) { - if (PickerFilterType.Checkbox != selectedEntity.filterType) { + if (PickerFilterType.checkbox != selectedEntity.filterType) { selectedEntity.parent!.clearChildSelection(); } } else { /// 单选,清除同一级别选中的状态,则其他的设置为未选中。 - if (PickerFilterType.Radio == selectedEntity.filterType) { + if (PickerFilterType.radio == selectedEntity.filterType) { selectedEntity.parent!.clearChildSelection(); selectedEntity.isSelected = true; - } else if (PickerFilterType.Checkbox == selectedEntity.filterType) { + } else if (PickerFilterType.checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { selectedEntity.parent!.clearChildSelection(); diff --git a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart index 80667415..e070c441 100644 --- a/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart +++ b/lib/src/components/picker/multi_range_picker/brn_multi_column_picker.dart @@ -180,7 +180,7 @@ class _BrnSelectionGroupViewState extends State { (int listIndex, int index, BrnPickerEntity entity) { _setFirstIndex(index); if (_columnCount == 1 && - widget.entity.filterType == PickerFilterType.Radio) { + widget.entity.filterType == PickerFilterType.radio) { _confirmButtonClickEvent(); } if (widget.onEntityTap != null) { @@ -472,7 +472,7 @@ class _BrnSelectionGroupViewState extends State { // 例如1级为多选,不应该默认选中2级的不限 // 否则每选中任意一个1级选项,就默认有了一个2级的不限 if (entity.isUnLimit() && - entity.parent!.filterType != PickerFilterType.Checkbox) { + entity.parent!.filterType != PickerFilterType.checkbox) { index = levelList.indexOf(entity); break; } diff --git a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart index e745625b..55dbb9be 100644 --- a/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart +++ b/lib/src/components/picker/multi_range_picker/btn_multi_column_picker_item.dart @@ -137,7 +137,7 @@ class BrnMultiRangePickerCommonItem extends StatelessWidget { int? count; if (item.parent != null) { count = item.parent!.children - .where((f) => f.filterType == PickerFilterType.Checkbox) + .where((f) => f.filterType == PickerFilterType.checkbox) .length; } return count == null ? false : count > 0; diff --git a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart index b7f6622a..1d0b2a9f 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_date_widget.dart @@ -11,7 +11,7 @@ import 'package:bruno/src/theme/brn_theme.dart'; import 'package:bruno/src/utils/i18n/brn_date_picker_i18n.dart'; import 'package:flutter/material.dart'; -enum ColumnType { Year, Month, Day } +enum ColumnType { year, month, day } /// Solar months of 31 days. const List _solarMonthsOf31Days = const [1, 3, 5, 7, 8, 10, 12]; @@ -233,8 +233,8 @@ class _BrnDateWidgetState extends State { childCount: valueRange.last - valueRange.first + 1, itemBuilder: (context, index) => _renderDatePickerItemComponent( format.contains("y") - ? ColumnType.Year - : (format.contains("M") ? ColumnType.Month : ColumnType.Day), + ? ColumnType.year + : (format.contains("M") ? ColumnType.month : ColumnType.day), index, valueRange.first + index, format), @@ -246,10 +246,10 @@ class _BrnDateWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType columnType, int index, int value, String format) { TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); - if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || - (ColumnType.Month == columnType && + if ((ColumnType.year == columnType && index == _calcSelectIndexList()[0]) || + (ColumnType.month == columnType && index == _calcSelectIndexList()[1]) || - (ColumnType.Day == columnType && index == _calcSelectIndexList()[2])) { + (ColumnType.day == columnType && index == _calcSelectIndexList()[2])) { textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( diff --git a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart index 010a35dd..b0f33a65 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_datetime_widget.dart @@ -11,7 +11,7 @@ import 'package:bruno/src/theme/brn_theme.dart'; import 'package:bruno/src/utils/i18n/brn_date_picker_i18n.dart'; import 'package:flutter/material.dart'; -enum ColumnType { Year, Month, Day, Hour, Minute, Second } +enum ColumnType { year, month, day, hour, minute, second } /// DateTimePicker widget. Can display date and time picker // ignore: must_be_immutable @@ -365,17 +365,17 @@ class _BrnDateTimeWidgetState extends State { // ignore: missing_return ColumnType? getColumnType(String format) { if (format.contains('y')) { - return ColumnType.Year; + return ColumnType.year; } else if (format.contains('M')) { - return ColumnType.Month; + return ColumnType.month; } else if (format.contains('d')) { - return ColumnType.Day; + return ColumnType.day; } else if (format.contains('H')) { - return ColumnType.Hour; + return ColumnType.hour; } else if (format.contains('m')) { - return ColumnType.Minute; + return ColumnType.minute; } else if (format.contains('s')) { - return ColumnType.Second; + return ColumnType.second; } return null; } @@ -467,14 +467,14 @@ class _BrnDateTimeWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType? columnType, int index, int value, String format) { TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); - if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || - (ColumnType.Month == columnType && + if ((ColumnType.year == columnType && index == _calcSelectIndexList()[0]) || + (ColumnType.month == columnType && index == _calcSelectIndexList()[1]) || - (ColumnType.Day == columnType && index == _calcSelectIndexList()[2]) || - (ColumnType.Hour == columnType && index == _calcSelectIndexList()[3]) || - (ColumnType.Minute == columnType && + (ColumnType.day == columnType && index == _calcSelectIndexList()[2]) || + (ColumnType.hour == columnType && index == _calcSelectIndexList()[3]) || + (ColumnType.minute == columnType && index == _calcSelectIndexList()[4]) || - (ColumnType.Second == columnType && + (ColumnType.second == columnType && index == _calcSelectIndexList()[5])) { textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } diff --git a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart index 314b6312..1e9e0491 100755 --- a/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart +++ b/lib/src/components/picker/time_picker/date_picker/brn_time_widget.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; /// TimePicker widget. -enum ColumnType { Hour, Minute, Second } +enum ColumnType { hour, minute, second } // ignore: must_be_immutable class BrnTimeWidget extends StatefulWidget { @@ -269,11 +269,11 @@ class _BrnTimeWidgetState extends State { // ignore: missing_return ColumnType? getColumnType(String format) { if (format.contains('H')) { - return ColumnType.Hour; + return ColumnType.hour; } else if (format.contains('m')) { - return ColumnType.Minute; + return ColumnType.minute; } else if (format.contains('s')) { - return ColumnType.Second; + return ColumnType.second; } return null; } @@ -290,10 +290,10 @@ class _BrnTimeWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType? columnType, int index, int value, String format) { TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); - if ((ColumnType.Hour == columnType && index == _calcSelectIndexList()[0]) || - (ColumnType.Minute == columnType && + if ((ColumnType.hour == columnType && index == _calcSelectIndexList()[0]) || + (ColumnType.minute == columnType && index == _calcSelectIndexList()[1]) || - (ColumnType.Second == columnType && + (ColumnType.second == columnType && index == _calcSelectIndexList()[2])) { textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } diff --git a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart index 97a46047..fb3a4afb 100755 --- a/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart +++ b/lib/src/components/picker/time_picker/date_range_picker/brn_date_range_side_widget.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; /// Solar months of 31 days. const List _solarMonthsOf31Days = const [1, 3, 5, 7, 8, 10, 12]; -enum ColumnType { Year, Month, Day } +enum ColumnType { year, month, day } /// one side widget of DateRangePicker // ignore: must_be_immutable @@ -237,8 +237,8 @@ class _DatePickerWidgetState extends State { childCount: valueRange.last - valueRange.first + 1, itemBuilder: (context, index) => _renderDatePickerItemComponent( format.contains("y") - ? ColumnType.Year - : (format.contains("M") ? ColumnType.Month : ColumnType.Day), + ? ColumnType.year + : (format.contains("M") ? ColumnType.month : ColumnType.day), index, valueRange.first + index, format), @@ -250,10 +250,10 @@ class _DatePickerWidgetState extends State { Widget _renderDatePickerItemComponent( ColumnType columnType, int index, int value, String format) { TextStyle textStyle = widget.themeData!.itemTextStyle.generateTextStyle(); - if ((ColumnType.Year == columnType && index == _calcSelectIndexList()[0]) || - (ColumnType.Month == columnType && + if ((ColumnType.year == columnType && index == _calcSelectIndexList()[0]) || + (ColumnType.month == columnType && index == _calcSelectIndexList()[1]) || - (ColumnType.Day == columnType && index == _calcSelectIndexList()[2])) { + (ColumnType.day == columnType && index == _calcSelectIndexList()[2])) { textStyle = widget.themeData!.itemTextSelectedStyle.generateTextStyle(); } return Container( diff --git a/lib/src/components/selection/bean/brn_selection_common_entity.dart b/lib/src/components/selection/bean/brn_selection_common_entity.dart index 79472cd7..c4c04c94 100644 --- a/lib/src/components/selection/bean/brn_selection_common_entity.dart +++ b/lib/src/components/selection/bean/brn_selection_common_entity.dart @@ -5,49 +5,49 @@ import 'package:bruno/src/utils/brn_tools.dart'; enum BrnSelectionFilterType { /// 未设置 - None, + none, /// 不限类型 - UnLimit, + unLimit, /// 单选列表、单选项 type 为 radio - Radio, + radio, /// 多选列表、多选项 type 为 checkbox - Checkbox, + checkbox, /// 一般的值范围自定义区间 type 为 range - Range, + range, /// 日期选择,普通筛选时使用 CalendarView 展示选择时间,更多情况下使用 DatePicker 选择时间 - Date, + date, /// 自定义选择日期区间, type 为 dateRange - DateRange, + dateRange, /// 自定义通过 Calendar 选择日期区间,type 为 dateRangeCalendar - DateRangeCalendar, + dateRangeCalendar, /// 标签筛选 type 为 customerTag - CustomHandle, + customHandle, /// 更多列表、多选项 无 type - More, + more, /// 去二级页面 - Layer, + layer, /// 去自定义二级页面 - CustomLayer, + customLayer, } /// 筛选弹窗展示风格 enum BrnSelectionWindowType { /// 列表类型,使用列表 Item 展示 - List, + list, /// 值范围类型,使用 Tag + Range 的 Item 展示 - Range, + range, } class BrnSelectionEntity { @@ -225,9 +225,9 @@ class BrnSelectionEntity { /// 当 default 不在普通 Item 类型中时,尝试填充 同级别 Range Item. if (children.where((_) => _.isSelected).toList().length == 0) { List rangeItems = this.children.where((_) { - return (_.filterType == BrnSelectionFilterType.Range || - _.filterType == BrnSelectionFilterType.DateRange || - _.filterType == BrnSelectionFilterType.DateRangeCalendar); + return (_.filterType == BrnSelectionFilterType.range || + _.filterType == BrnSelectionFilterType.dateRange || + _.filterType == BrnSelectionFilterType.dateRangeCalendar); }).toList(); BrnSelectionEntity? rangeEntity; if (rangeItems.isNotEmpty) { @@ -258,50 +258,50 @@ class BrnSelectionEntity { BrnSelectionWindowType parserShowType(String? showType) { if (showType == "list") { - return BrnSelectionWindowType.List; + return BrnSelectionWindowType.list; } else if (showType == "range") { - return BrnSelectionWindowType.Range; + return BrnSelectionWindowType.range; } - return BrnSelectionWindowType.List; + return BrnSelectionWindowType.list; } BrnSelectionFilterType parserFilterTypeWithType(String? type) { if (type == 'unlimit') { - return BrnSelectionFilterType.UnLimit; + return BrnSelectionFilterType.unLimit; } else if (type == "radio") { - return BrnSelectionFilterType.Radio; + return BrnSelectionFilterType.radio; } else if (type == "checkbox") { - return BrnSelectionFilterType.Checkbox; + return BrnSelectionFilterType.checkbox; } else if (type == "range") { - return BrnSelectionFilterType.Range; + return BrnSelectionFilterType.range; } else if (type == "customHandle") { - return BrnSelectionFilterType.CustomHandle; + return BrnSelectionFilterType.customHandle; } else if (type == "more") { - return BrnSelectionFilterType.More; + return BrnSelectionFilterType.more; } else if (type == 'floatinglayer') { - return BrnSelectionFilterType.Layer; + return BrnSelectionFilterType.layer; } else if (type == 'customfloatinglayer') { - return BrnSelectionFilterType.CustomLayer; + return BrnSelectionFilterType.customLayer; } else if (type == 'date') { - return BrnSelectionFilterType.Date; + return BrnSelectionFilterType.date; } else if (type == 'daterange') { - return BrnSelectionFilterType.DateRange; + return BrnSelectionFilterType.dateRange; } else if (type == 'daterangecalendar') { - return BrnSelectionFilterType.DateRangeCalendar; + return BrnSelectionFilterType.dateRangeCalendar; } - return BrnSelectionFilterType.None; + return BrnSelectionFilterType.none; } void clearChildSelection() { if (children.length > 0) { for (BrnSelectionEntity entity in children) { entity.isSelected = false; - if (entity.filterType == BrnSelectionFilterType.Date) { + if (entity.filterType == BrnSelectionFilterType.date) { entity.value = null; } - if (entity.filterType == BrnSelectionFilterType.Range || - entity.filterType == BrnSelectionFilterType.DateRange || - entity.filterType == BrnSelectionFilterType.DateRangeCalendar) { + if (entity.filterType == BrnSelectionFilterType.range || + entity.filterType == BrnSelectionFilterType.dateRange || + entity.filterType == BrnSelectionFilterType.dateRangeCalendar) { entity.customMap = Map(); } entity.clearChildSelection(); @@ -344,21 +344,21 @@ class BrnSelectionEntity { return selected .where((_) => !_.isUnLimit()) .where((_) => - (_.filterType != BrnSelectionFilterType.Range) || - (_.filterType == BrnSelectionFilterType.Range && !BrunoTools.isEmpty(_.customMap))) + (_.filterType != BrnSelectionFilterType.range) || + (_.filterType == BrnSelectionFilterType.range && !BrunoTools.isEmpty(_.customMap))) .where((_) => - (_.filterType != BrnSelectionFilterType.DateRange) || - (_.filterType == BrnSelectionFilterType.DateRange && + (_.filterType != BrnSelectionFilterType.dateRange) || + (_.filterType == BrnSelectionFilterType.dateRange && !BrunoTools.isEmpty(_.customMap))) .where((_) => - (_.filterType != BrnSelectionFilterType.DateRangeCalendar) || - (_.filterType == BrnSelectionFilterType.DateRangeCalendar && + (_.filterType != BrnSelectionFilterType.dateRangeCalendar) || + (_.filterType == BrnSelectionFilterType.dateRangeCalendar && !BrunoTools.isEmpty(_.customMap))) .toList(); } List selectedList() { - if (BrnSelectionFilterType.More == this.filterType) { + if (BrnSelectionFilterType.more == this.filterType) { return this.selectedLastColumnList(); } else { List results = []; @@ -461,13 +461,13 @@ class BrnSelectionEntity { /// 检查自己的兄弟结点是否存在 checkbox 类型。 bool hasCheckBoxBrother() { int? count = - parent?.children.where((f) => f.filterType == BrnSelectionFilterType.Checkbox).length; + parent?.children.where((f) => f.filterType == BrnSelectionFilterType.checkbox).length; return count == null ? false : count > 0; } /// 在这里简单认为 value 为空【null 或 ''】时为 unlimit. bool isUnLimit() { - return filterType == BrnSelectionFilterType.UnLimit; + return filterType == BrnSelectionFilterType.unLimit; } void clearSelectedEntity() { @@ -486,9 +486,9 @@ class BrnSelectionEntity { List currentTagListForEntity() { List list = []; children.forEach((data) { - if (data.filterType != BrnSelectionFilterType.Range && - data.filterType != BrnSelectionFilterType.DateRange && - data.filterType != BrnSelectionFilterType.DateRangeCalendar) { + if (data.filterType != BrnSelectionFilterType.range && + data.filterType != BrnSelectionFilterType.dateRange && + data.filterType != BrnSelectionFilterType.dateRangeCalendar) { list.add(data); } }); @@ -524,9 +524,9 @@ class BrnSelectionEntity { List currentRangeListForEntity() { List list = []; children.forEach((data) { - if (data.filterType == BrnSelectionFilterType.Range || - data.filterType == BrnSelectionFilterType.DateRange || - data.filterType == BrnSelectionFilterType.DateRangeCalendar) { + if (data.filterType == BrnSelectionFilterType.range || + data.filterType == BrnSelectionFilterType.dateRange || + data.filterType == BrnSelectionFilterType.dateRangeCalendar) { list.add(data); } }); @@ -534,20 +534,20 @@ class BrnSelectionEntity { } bool isValidRange() { - if (this.filterType == BrnSelectionFilterType.Range || - this.filterType == BrnSelectionFilterType.DateRange || - this.filterType == BrnSelectionFilterType.DateRangeCalendar) { + if (this.filterType == BrnSelectionFilterType.range || + this.filterType == BrnSelectionFilterType.dateRange || + this.filterType == BrnSelectionFilterType.dateRangeCalendar) { DateTime minTime = DateTime.parse(datePickerMinDatetime); DateTime maxTime = DateTime.parse(datePickerMaxDatetime); int limitMin = int.tryParse(extMap['min']?.toString() ?? "") ?? - (this.filterType == BrnSelectionFilterType.DateRange || - this.filterType == BrnSelectionFilterType.DateRangeCalendar + (this.filterType == BrnSelectionFilterType.dateRange || + this.filterType == BrnSelectionFilterType.dateRangeCalendar ? minTime.millisecondsSinceEpoch : 0); // 日期最大值没设置 默认是2121年01月01日 08:00:00 int limitMax = int.tryParse(extMap['max']?.toString() ?? "") ?? - (this.filterType == BrnSelectionFilterType.DateRange || - this.filterType == BrnSelectionFilterType.DateRangeCalendar + (this.filterType == BrnSelectionFilterType.dateRange || + this.filterType == BrnSelectionFilterType.dateRangeCalendar ? maxTime.millisecondsSinceEpoch : 9999); diff --git a/lib/src/components/selection/brn_flat_selection.dart b/lib/src/components/selection/brn_flat_selection.dart index 57ceee95..e581dde6 100644 --- a/lib/src/components/selection/brn_flat_selection.dart +++ b/lib/src/components/selection/brn_flat_selection.dart @@ -26,7 +26,7 @@ class BrnFlatSelection extends StatefulWidget { /// 每行展示tag数量 默认真是3个 final int preLineTagSize; - /// 当[BrnSelectionEntity.filterType]为[BrnSelectionFilterType.Layer] or[BrnSelectionFilterType.CustomLayer]时 + /// 当[BrnSelectionEntity.filterType]为[BrnSelectionFilterType.layer] or[BrnSelectionFilterType.customLayer]时 /// 跳转到二级页面的自定义操作 final BrnOnCustomFloatingLayerClick? onCustomFloatingLayerClick; @@ -227,7 +227,7 @@ class _BrnFlatSelectionState extends State with SingleTickerPr void _clearUIData(BrnSelectionEntity entity) { entity.isSelected = false; entity.customMap = Map(); - if (BrnSelectionFilterType.Range == entity.filterType) { + if (BrnSelectionFilterType.range == entity.filterType) { entity.title = ''; } for (BrnSelectionEntity subEntity in entity.children) { diff --git a/lib/src/components/selection/brn_more_selection.dart b/lib/src/components/selection/brn_more_selection.dart index 7d5e200e..95d90c72 100644 --- a/lib/src/components/selection/brn_more_selection.dart +++ b/lib/src/components/selection/brn_more_selection.dart @@ -221,7 +221,7 @@ class _BrnMoreSelectionPageState extends State void _clearUIData(BrnSelectionEntity entity) { entity.isSelected = false; entity.customMap = Map(); - if (BrnSelectionFilterType.Range == entity.filterType) { + if (BrnSelectionFilterType.range == entity.filterType) { entity.title = ''; } for (BrnSelectionEntity subEntity in entity.children) { @@ -240,18 +240,18 @@ class _BrnMoreSelectionPageState extends State while (tmp.isNotEmpty) { node = tmp.removeLast(); if (node.isSelected && - (node.filterType == BrnSelectionFilterType.Range || - node.filterType == BrnSelectionFilterType.DateRange || - node.filterType == BrnSelectionFilterType.DateRangeCalendar)) { + (node.filterType == BrnSelectionFilterType.range || + node.filterType == BrnSelectionFilterType.dateRange || + node.filterType == BrnSelectionFilterType.dateRangeCalendar)) { if (node.customMap != null && (BrunoTools.isEmpty(node.customMap!['min']) || BrunoTools.isEmpty(node.customMap!['max']))) { if (!node.isValidRange()) { isValid = false; - if (node.filterType == BrnSelectionFilterType.Range) { + if (node.filterType == BrnSelectionFilterType.range) { BrnToast.show('您输入的区间有误', context); - } else if (node.filterType == BrnSelectionFilterType.DateRange || - node.filterType == BrnSelectionFilterType.DateRangeCalendar) { + } else if (node.filterType == BrnSelectionFilterType.dateRange || + node.filterType == BrnSelectionFilterType.dateRangeCalendar) { BrnToast.show('您选择的区间有误', context); } return; diff --git a/lib/src/components/selection/brn_selection_util.dart b/lib/src/components/selection/brn_selection_util.dart index f4111222..69b488d8 100644 --- a/lib/src/components/selection/brn_selection_util.dart +++ b/lib/src/components/selection/brn_selection_util.dart @@ -9,17 +9,17 @@ class BrnSelectionUtil { /// 处理兄弟结点为未选中状态,将自己置为选中状态 static void processBrotherItemSelectStatus( BrnSelectionEntity selectionEntity) { - if (BrnSelectionFilterType.Checkbox == selectionEntity.filterType) { + if (BrnSelectionFilterType.checkbox == selectionEntity.filterType) { selectionEntity.isSelected = !selectionEntity.isSelected; List? allBrothers = selectionEntity.parent?.children; if (!BrunoTools.isEmpty(allBrothers)) { for (BrnSelectionEntity entity in allBrothers!) { if (entity != selectionEntity) { - if (entity.filterType == BrnSelectionFilterType.Radio) { + if (entity.filterType == BrnSelectionFilterType.radio) { entity.isSelected = false; } - if (entity.filterType == BrnSelectionFilterType.Date) { + if (entity.filterType == BrnSelectionFilterType.date) { entity.isSelected = false; entity.value = null; } @@ -27,12 +27,12 @@ class BrnSelectionUtil { } } } - if (BrnSelectionFilterType.Radio == selectionEntity.filterType) { + if (BrnSelectionFilterType.radio == selectionEntity.filterType) { selectionEntity.parent?.clearChildSelection(); selectionEntity.isSelected = true; } - if (BrnSelectionFilterType.Date == selectionEntity.filterType) { + if (BrnSelectionFilterType.date == selectionEntity.filterType) { selectionEntity.parent?.clearChildSelection(); /// 日期类型时在外部 Picker 点击确定时设置 选中状态 @@ -81,10 +81,10 @@ class BrnSelectionUtil { /// 判断列表中是否有range类型 static bool hasRangeItem(List list) { for (BrnSelectionEntity entity in list) { - if (BrnSelectionFilterType.Range == entity.filterType || - BrnSelectionFilterType.DateRange == entity.filterType || - BrnSelectionFilterType.DateRangeCalendar == entity.filterType || - BrnSelectionWindowType.Range == entity.filterShowType) { + if (BrnSelectionFilterType.range == entity.filterType || + BrnSelectionFilterType.dateRange == entity.filterType || + BrnSelectionFilterType.dateRangeCalendar == entity.filterType || + BrnSelectionWindowType.range == entity.filterShowType) { return true; } } @@ -97,9 +97,9 @@ class BrnSelectionUtil { BrnSelectionEntity? filledCustomInputItem; for (BrnSelectionEntity entity in list) { if (entity.isSelected && - (BrnSelectionFilterType.Range == entity.filterType || - BrnSelectionFilterType.DateRange == entity.filterType || - BrnSelectionFilterType.DateRangeCalendar == entity.filterType) && + (BrnSelectionFilterType.range == entity.filterType || + BrnSelectionFilterType.dateRange == entity.filterType || + BrnSelectionFilterType.dateRangeCalendar == entity.filterType) && entity.customMap != null) { filledCustomInputItem = entity; break; diff --git a/lib/src/components/selection/brn_selection_view.dart b/lib/src/components/selection/brn_selection_view.dart index dfecf3b6..6ee37f02 100644 --- a/lib/src/components/selection/brn_selection_view.dart +++ b/lib/src/components/selection/brn_selection_view.dart @@ -168,7 +168,7 @@ class BrnSelectionViewState extends State { /// 2、触发更新 UI。 /// 3、触发 _onSelectionChanged 统一回调给外部 if (widget.originalSelectionData[menuIndex].filterType == - BrnSelectionFilterType.CustomHandle && + BrnSelectionFilterType.customHandle && widget.onCustomSelectionMenuClick != null) { widget.onCustomSelectionMenuClick!(menuIndex, widget.originalSelectionData[menuIndex], (Map customParams) { @@ -182,7 +182,7 @@ class BrnSelectionViewState extends State { } /// 自定义 Menu 的时候,让外部设置选中的 value 进来统一更新 UI。 然后触发 _onSelectionChanged 统一回调给外部 - if (widget.originalSelectionData[menuIndex].filterType == BrnSelectionFilterType.More && + if (widget.originalSelectionData[menuIndex].filterType == BrnSelectionFilterType.more && widget.onMoreSelectionMenuClick != null) { widget.onMoreSelectionMenuClick!(menuIndex, ( {bool updateData = false, List? moreSelections}) { diff --git a/lib/src/components/selection/converter/brn_selection_converter.dart b/lib/src/components/selection/converter/brn_selection_converter.dart index da4f9d74..f9b3ce12 100644 --- a/lib/src/components/selection/converter/brn_selection_converter.dart +++ b/lib/src/components/selection/converter/brn_selection_converter.dart @@ -46,7 +46,7 @@ Map getSelectionParams(List? selectedResults Map params = Map(); if (selectedResults == null) return params; for (BrnSelectionEntity menuItemEntity in selectedResults) { - if (menuItemEntity.filterType == BrnSelectionFilterType.More) { + if (menuItemEntity.filterType == BrnSelectionFilterType.more) { params.addAll(getSelectionParams(menuItemEntity.children)); } else { /// 1、首先找出 自定义范围的筛选项参数。 diff --git a/lib/src/components/selection/widget/brn_flat_selection_item.dart b/lib/src/components/selection/widget/brn_flat_selection_item.dart index 70d3d4ac..3f8ffc80 100644 --- a/lib/src/components/selection/widget/brn_flat_selection_item.dart +++ b/lib/src/components/selection/widget/brn_flat_selection_item.dart @@ -28,7 +28,7 @@ class BrnFlatMoreSelection extends StatefulWidget { /// 清空已选项 一般跟重置功能搭配使用 final StreamController? clearController; - /// 当[BrnSelectionEntity.filterType]为[BrnSelectionFilterType.Layer] or[BrnSelectionFilterType.CustomLayer]时 + /// 当[BrnSelectionEntity.filterType]为[BrnSelectionFilterType.layer] or[BrnSelectionFilterType.customLayer]时 /// 跳转到二级页面的自定义操作 final BrnOnCustomFloatingLayerClick? onCustomFloatingLayerClick; @@ -60,8 +60,8 @@ class _BrnFlatMoreSelectionState extends State { @override Widget build(BuildContext context) { //弹出浮层 - if (widget.selectionEntity.filterType == BrnSelectionFilterType.Layer || - widget.selectionEntity.filterType == BrnSelectionFilterType.CustomLayer) { + if (widget.selectionEntity.filterType == BrnSelectionFilterType.layer || + widget.selectionEntity.filterType == BrnSelectionFilterType.customLayer) { return FilterLayerTypeWidget( selectionEntity: widget.selectionEntity, onCustomFloatingLayerClick: widget.onCustomFloatingLayerClick, @@ -239,12 +239,12 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { return GestureDetector( onTap: () { setState(() { - if (data.filterType == BrnSelectionFilterType.Radio) { + if (data.filterType == BrnSelectionFilterType.radio) { data.parent?.clearSelectedEntity(); data.isSelected = true; //用于发送 标签点击事件 _streamController.add(SelectEvent()); - } else if (data.filterType == BrnSelectionFilterType.Checkbox) { + } else if (data.filterType == BrnSelectionFilterType.checkbox) { if (!data.isSelected) { if (!BrnSelectionUtil.checkMaxSelectionCount(data)) { BrnToast.show('您选择的筛选条件数量已达上限', context); @@ -253,12 +253,12 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } data.parent?.children - .where((_) => _.filterType == BrnSelectionFilterType.Radio) + .where((_) => _.filterType == BrnSelectionFilterType.radio) .forEach((f) => f.isSelected = false); data.isSelected = !data.isSelected; //用于发送 标签点击事件 _streamController.add(SelectEvent()); - } else if (data.filterType == BrnSelectionFilterType.Date) { + } else if (data.filterType == BrnSelectionFilterType.date) { _showDatePicker(data); } }); @@ -289,7 +289,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } Widget _buildSingleTag(BrnSelectionEntity data) { - bool isDate = data.filterType == BrnSelectionFilterType.Date; + bool isDate = data.filterType == BrnSelectionFilterType.date; String showName; @@ -627,7 +627,7 @@ class _FilterLayerTypeWidgetState extends State { padding: const EdgeInsets.only(left: 20, right: 20, top: 6), child: GestureDetector( onTap: () { - if (widget.selectionEntity.filterType == BrnSelectionFilterType.Layer) { + if (widget.selectionEntity.filterType == BrnSelectionFilterType.layer) { Navigator.of(context) .push(PageRouteBuilder( opaque: false, @@ -640,7 +640,7 @@ class _FilterLayerTypeWidgetState extends State { .then((data) { updateContent(); }); - } else if (widget.selectionEntity.filterType == BrnSelectionFilterType.CustomLayer) { + } else if (widget.selectionEntity.filterType == BrnSelectionFilterType.customLayer) { if (widget.onCustomFloatingLayerClick != null) { int entityIndex = -1; if (widget.selectionEntity.parent != null && diff --git a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart index 68ff1b2a..f345c1cb 100644 --- a/lib/src/components/selection/widget/brn_layer_more_selection_page.dart +++ b/lib/src/components/selection/widget/brn_layer_more_selection_page.dart @@ -201,7 +201,7 @@ class _BrnLayerMoreSelectionPageState extends State if (index == _currentIndex) { return; } - if (_firstList[index].filterType == BrnSelectionFilterType.Radio) { + if (_firstList[index].filterType == BrnSelectionFilterType.radio) { setState(() { _currentIndex = index; _currentFirstEntity = _firstList[index]; @@ -217,7 +217,7 @@ class _BrnLayerMoreSelectionPageState extends State }); } else { _firstList[index].parent?.children.where((data) { - return data.filterType != BrnSelectionFilterType.Checkbox; + return data.filterType != BrnSelectionFilterType.checkbox; }).forEach((data) { data.isSelected = false; data.clearChildSelection(); @@ -336,8 +336,8 @@ class _BrnLayerMoreSelectionPageState extends State Widget _buildRightItem(int index) { bool isSingle = - (_currentFirstEntity?.children[index].filterType == BrnSelectionFilterType.Radio) || - (_currentFirstEntity?.children[index].filterType == BrnSelectionFilterType.UnLimit); + (_currentFirstEntity?.children[index].filterType == BrnSelectionFilterType.radio) || + (_currentFirstEntity?.children[index].filterType == BrnSelectionFilterType.unLimit); return GestureDetector( onTap: () { @@ -349,7 +349,7 @@ class _BrnLayerMoreSelectionPageState extends State _currentFirstEntity!.children[index].isSelected = true; } else { _currentFirstEntity!.children.where((data) { - return data.filterType != BrnSelectionFilterType.Checkbox; + return data.filterType != BrnSelectionFilterType.checkbox; }).forEach((data) { data.isSelected = false; }); @@ -461,7 +461,7 @@ class _BrnLayerMoreSelectionPageState extends State if (secondIndex == -1 && currentFirstEntity.children.isNotEmpty) { for (int i = 0, n = currentFirstEntity.children.length; i < n; i++) { if (currentFirstEntity.children[i].isUnLimit() && - currentFirstEntity.filterType == BrnSelectionFilterType.Checkbox) { + currentFirstEntity.filterType == BrnSelectionFilterType.checkbox) { currentFirstEntity.children[i].isSelected = true; break; } diff --git a/lib/src/components/selection/widget/brn_selection_list_widget.dart b/lib/src/components/selection/widget/brn_selection_list_widget.dart index 1815a41b..2a716df4 100644 --- a/lib/src/components/selection/widget/brn_selection_list_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_list_widget.dart @@ -92,7 +92,7 @@ class _BrnSelectionGroupViewState extends State { widgetList.add(_listWidget()); // TODO 判断是否添加 Bottom - if (totalLevel == 1 && widget.entity.filterType == BrnSelectionFilterType.Radio) { + if (totalLevel == 1 && widget.entity.filterType == BrnSelectionFilterType.radio) { } else { widgetList.add(_bottomWidget()); } @@ -117,7 +117,7 @@ class _BrnSelectionGroupViewState extends State { focusedIndex: _firstIndex, singleListItemSelect: (int listIndex, int index, BrnSelectionEntity entity) { _setFirstIndex(index); - if (totalLevel == 1 && widget.entity.filterType == BrnSelectionFilterType.Radio) { + if (totalLevel == 1 && widget.entity.filterType == BrnSelectionFilterType.radio) { _confirmButtonClickEvent(); } })); @@ -372,7 +372,7 @@ class _BrnSelectionGroupViewState extends State { void _resetSelectionData(BrnSelectionEntity entity) { entity.isSelected = false; entity.customMap = Map(); - if (BrnSelectionFilterType.Range == entity.filterType) { + if (BrnSelectionFilterType.range == entity.filterType) { entity.title = ''; } for (BrnSelectionEntity subEntity in entity.children) { diff --git a/lib/src/components/selection/widget/brn_selection_menu_widget.dart b/lib/src/components/selection/widget/brn_selection_menu_widget.dart index 01686e9b..b7a9d332 100644 --- a/lib/src/components/selection/widget/brn_selection_menu_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_menu_widget.dart @@ -211,15 +211,15 @@ class _BrnSelectionMenuWidgetState extends State { listViewController.hide(); } else { /// 点击不是 More、自定义类型,则直接展开。 - if (widget.data[index].filterType != BrnSelectionFilterType.More && - widget.data[index].filterType != BrnSelectionFilterType.CustomHandle) { + if (widget.data[index].filterType != BrnSelectionFilterType.more && + widget.data[index].filterType != BrnSelectionFilterType.customHandle) { /// 创建 筛选组件的的入口 OverlayEntry entry = _createEntry(widget.data[index]); Overlay.of(widget.context)?.insert(entry); listViewController.entry = entry; listViewController.show(index); - } else if (widget.data[index].filterType == BrnSelectionFilterType.CustomHandle) { + } else if (widget.data[index].filterType == BrnSelectionFilterType.customHandle) { /// 记录自定义筛选 menu 的点击状态,当点击自定义的 menu 时,menu 文案默认高亮。 listViewController.show(index); _refreshSelectionMenuTitle(index, widget.data[index]); @@ -257,11 +257,11 @@ class _BrnSelectionMenuWidgetState extends State { /// 3、只有一列筛选数据,且为多选时,使用 Tag 模式展示 bool _isRange(BrnSelectionEntity entity) { if (BrnSelectionUtil.hasRangeItem(entity.children) || - entity.filterShowType == BrnSelectionWindowType.Range) { + entity.filterShowType == BrnSelectionWindowType.range) { return true; } var totalLevel = BrnSelectionUtil.getTotalLevel(entity); - if (totalLevel == 1 && entity.filterType == BrnSelectionFilterType.Checkbox) { + if (totalLevel == 1 && entity.filterType == BrnSelectionFilterType.checkbox) { return true; } return false; @@ -339,7 +339,7 @@ class _BrnSelectionMenuWidgetState extends State { /// 筛选 Title 展示规则 String? _getSelectedResultTitle(BrnSelectionEntity entity) { /// 更多筛选不改变 title.故返回 null - if (entity.filterType == BrnSelectionFilterType.More) { + if (entity.filterType == BrnSelectionFilterType.more) { return null; } if (BrunoTools.isEmpty(entity.customTitle)) { @@ -371,10 +371,10 @@ class _BrnSelectionMenuWidgetState extends State { /// 第一列选中了一个,为【不限】类型,使用上一级别的名字展示。 if (firstColumn[0].isUnLimit()) { title = entity.title; - } else if (firstColumn[0].filterType == BrnSelectionFilterType.Range || - firstColumn[0].filterType == BrnSelectionFilterType.Date || - firstColumn[0].filterType == BrnSelectionFilterType.DateRange || - firstColumn[0].filterType == BrnSelectionFilterType.DateRangeCalendar) { + } else if (firstColumn[0].filterType == BrnSelectionFilterType.range || + firstColumn[0].filterType == BrnSelectionFilterType.date || + firstColumn[0].filterType == BrnSelectionFilterType.dateRange || + firstColumn[0].filterType == BrnSelectionFilterType.dateRangeCalendar) { title = _getDateAndRangeTitle(firstColumn, entity); } else { if (secondColumn.length == 0 || secondColumn.length > 1) { @@ -383,10 +383,10 @@ class _BrnSelectionMenuWidgetState extends State { /// 第二列选中了一个,为【不限】类型,使用上一级别的名字展示。 if (secondColumn[0].isUnLimit()) { title = firstColumn[0].title; - } else if (secondColumn[0].filterType == BrnSelectionFilterType.Range || - secondColumn[0].filterType == BrnSelectionFilterType.Date || - secondColumn[0].filterType == BrnSelectionFilterType.DateRange || - secondColumn[0].filterType == BrnSelectionFilterType.DateRangeCalendar) { + } else if (secondColumn[0].filterType == BrnSelectionFilterType.range || + secondColumn[0].filterType == BrnSelectionFilterType.date || + secondColumn[0].filterType == BrnSelectionFilterType.dateRange || + secondColumn[0].filterType == BrnSelectionFilterType.dateRangeCalendar) { title = _getDateAndRangeTitle(secondColumn, firstColumn[0]); } else { if (thirdColumn.length == 0 || thirdColumn.length > 1) { @@ -395,10 +395,10 @@ class _BrnSelectionMenuWidgetState extends State { /// 第三列选中了一个,为【不限】类型,使用上一级别的名字展示。 if (thirdColumn[0].isUnLimit()) { title = secondColumn[0].title; - } else if (thirdColumn[0].filterType == BrnSelectionFilterType.Range || - thirdColumn[0].filterType == BrnSelectionFilterType.Date || - thirdColumn[0].filterType == BrnSelectionFilterType.DateRange || - thirdColumn[0].filterType == BrnSelectionFilterType.DateRangeCalendar) { + } else if (thirdColumn[0].filterType == BrnSelectionFilterType.range || + thirdColumn[0].filterType == BrnSelectionFilterType.date || + thirdColumn[0].filterType == BrnSelectionFilterType.dateRange || + thirdColumn[0].filterType == BrnSelectionFilterType.dateRangeCalendar) { title = _getDateAndRangeTitle(thirdColumn, secondColumn[0]); } else { title = thirdColumn[0].title; @@ -416,15 +416,15 @@ class _BrnSelectionMenuWidgetState extends State { String? _getDateAndRangeTitle(List list, BrnSelectionEntity entity) { String? title = ''; if (!BrunoTools.isEmpty(list[0].customMap)) { - if (list[0].filterType == BrnSelectionFilterType.Range) { + if (list[0].filterType == BrnSelectionFilterType.range) { title = '${list[0].customMap!['min']}-${list[0].customMap!['max']}(${list[0].extMap['unit']?.toString()})'; - } else if (list[0].filterType == BrnSelectionFilterType.DateRange || - list[0].filterType == BrnSelectionFilterType.DateRangeCalendar) { + } else if (list[0].filterType == BrnSelectionFilterType.dateRange || + list[0].filterType == BrnSelectionFilterType.dateRangeCalendar) { title = _getDateRangeTitle(list); } } else { - if (list[0].filterType == BrnSelectionFilterType.Date) { + if (list[0].filterType == BrnSelectionFilterType.date) { title = _getDateTimeTitle(list); } else { title = entity.title; @@ -486,7 +486,7 @@ class _BrnSelectionMenuWidgetState extends State { } void _refreshSelectionMenuTitle(int index, BrnSelectionEntity entity) { - if (entity.filterType == BrnSelectionFilterType.More) { + if (entity.filterType == BrnSelectionFilterType.more) { if (entity.allSelectedList().length > 0) { menuItemHighlightState[index] = true; } else { diff --git a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart index 3d8ce56c..528b7d36 100644 --- a/lib/src/components/selection/widget/brn_selection_more_item_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_more_item_widget.dart @@ -48,8 +48,8 @@ class _BrnMoreSelectionWidgetState extends State { @override Widget build(BuildContext context) { //弹出浮层 - if (widget.selectionEntity.filterType == BrnSelectionFilterType.Layer || - widget.selectionEntity.filterType == BrnSelectionFilterType.CustomLayer) { + if (widget.selectionEntity.filterType == BrnSelectionFilterType.layer || + widget.selectionEntity.filterType == BrnSelectionFilterType.customLayer) { return FilterLayerTypeWidget( selectionEntity: widget.selectionEntity, onCustomFloatingLayerClick: widget.onCustomFloatingLayerClick, @@ -217,12 +217,12 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { return GestureDetector( onTap: () { setState(() { - if (data.filterType == BrnSelectionFilterType.Radio) { + if (data.filterType == BrnSelectionFilterType.radio) { data.parent?.clearSelectedEntity(); data.isSelected = true; //用于发送 标签点击事件 streamController.add(SelectEvent()); - } else if (data.filterType == BrnSelectionFilterType.Checkbox) { + } else if (data.filterType == BrnSelectionFilterType.checkbox) { if (!data.isSelected) { if (!BrnSelectionUtil.checkMaxSelectionCount(data)) { BrnToast.show('您选择的筛选条件数量已达上限', context); @@ -231,12 +231,12 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } data.parent?.children - .where((_) => _.filterType == BrnSelectionFilterType.Radio) + .where((_) => _.filterType == BrnSelectionFilterType.radio) .forEach((f) => f.isSelected = false); data.isSelected = !data.isSelected; //用于发送 标签点击事件 streamController.add(SelectEvent()); - } else if (data.filterType == BrnSelectionFilterType.Date) { + } else if (data.filterType == BrnSelectionFilterType.date) { _showDatePicker(data); } }); @@ -248,7 +248,7 @@ class __FilterCommonTypeWidgetState extends State<_FilterCommonTypeWidget> { } Widget _buildSingleTag(BrnSelectionEntity entity) { - bool isDate = entity.filterType == BrnSelectionFilterType.Date; + bool isDate = entity.filterType == BrnSelectionFilterType.date; String? showName; @@ -431,7 +431,7 @@ class __MoreRangeWidgetState extends State<_MoreRangeWidget> { /// 1:将输入框的 文本写入 customMap中 /// 2:如果最大值和最小值满足条件 则将range选中 minController.addListener(() { - if (widget.rangeEntity.filterType != BrnSelectionFilterType.Range) { + if (widget.rangeEntity.filterType != BrnSelectionFilterType.range) { return; } String minInput = minController.text; @@ -446,7 +446,7 @@ class __MoreRangeWidgetState extends State<_MoreRangeWidget> { }); maxController.addListener(() { - if (widget.rangeEntity.filterType != BrnSelectionFilterType.Range) { + if (widget.rangeEntity.filterType != BrnSelectionFilterType.range) { return; } String maxInput = maxController.text; @@ -490,7 +490,7 @@ class __MoreRangeWidgetState extends State<_MoreRangeWidget> { @override Widget build(BuildContext context) { - if (widget.rangeEntity.filterType == BrnSelectionFilterType.DateRange) { + if (widget.rangeEntity.filterType == BrnSelectionFilterType.dateRange) { return BrnSelectionDateRangeItemWidget( item: widget.rangeEntity, isNeedTitle: false, @@ -594,7 +594,7 @@ class _FilterLayerTypeWidgetState extends State { padding: const EdgeInsets.only(left: 20, right: 20, top: 6), child: GestureDetector( onTap: () { - if (widget.selectionEntity.filterType == BrnSelectionFilterType.Layer) { + if (widget.selectionEntity.filterType == BrnSelectionFilterType.layer) { Navigator.of(context) .push(PageRouteBuilder( opaque: false, @@ -607,7 +607,7 @@ class _FilterLayerTypeWidgetState extends State { .then((data) { setState(() {}); }); - } else if (widget.selectionEntity.filterType == BrnSelectionFilterType.CustomLayer) { + } else if (widget.selectionEntity.filterType == BrnSelectionFilterType.customLayer) { if (widget.onCustomFloatingLayerClick != null) { int entityIndex = -1; if (widget.selectionEntity.parent != null) { diff --git a/lib/src/components/selection/widget/brn_selection_range_tag_widget.dart b/lib/src/components/selection/widget/brn_selection_range_tag_widget.dart index 192ac8c6..52ee7fd3 100644 --- a/lib/src/components/selection/widget/brn_selection_range_tag_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_range_tag_widget.dart @@ -63,7 +63,7 @@ class _BrnSelectionRangeTagWidgetState extends State child: tagWidget, onTap: () { var selectedEntity = widget.tagFilterList[nameIndex]; - if (BrnSelectionFilterType.Checkbox == selectedEntity.filterType && + if (BrnSelectionFilterType.checkbox == selectedEntity.filterType && !selectedEntity.isSelected) { if (!BrnSelectionUtil.checkMaxSelectionCount(selectedEntity)) { BrnToast.show("您选择的筛选条件数量已达上限", context); @@ -85,7 +85,7 @@ class _BrnSelectionRangeTagWidgetState extends State bool selected = widget.tagFilterList[nameIndex].isSelected || nameIndex == widget.initFocusedIndex; String text = widget.tagFilterList[nameIndex].title; - if (widget.tagFilterList[nameIndex].filterType == BrnSelectionFilterType.Date && + if (widget.tagFilterList[nameIndex].filterType == BrnSelectionFilterType.date && !BrunoTools.isEmpty(widget.tagFilterList[nameIndex].value)) { if (int.tryParse(widget.tagFilterList[nameIndex].value ?? '') != null) { DateTime? dateTime = diff --git a/lib/src/components/selection/widget/brn_selection_range_widget.dart b/lib/src/components/selection/widget/brn_selection_range_widget.dart index 75b2e44d..a4ef0536 100644 --- a/lib/src/components/selection/widget/brn_selection_range_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_range_widget.dart @@ -197,10 +197,10 @@ class _BrnRangeSelectionGroupWidgetState extends State tagFilterList = subFilterList .where((f) => - f.filterType != BrnSelectionFilterType.Range && - f.filterType != BrnSelectionFilterType.Date && - f.filterType != BrnSelectionFilterType.DateRange && - f.filterType != BrnSelectionFilterType.DateRangeCalendar) + f.filterType != BrnSelectionFilterType.range && + f.filterType != BrnSelectionFilterType.date && + f.filterType != BrnSelectionFilterType.dateRange && + f.filterType != BrnSelectionFilterType.dateRangeCalendar) .toList(); Size maxWidthSize = Size.zero; for (BrnSelectionEntity entity in subFilterList) { @@ -258,7 +258,7 @@ class _BrnRangeSelectionGroupWidgetState extends State subFilterList) { subFilterList .where((f) => - f.filterType == BrnSelectionFilterType.Range || - f.filterType == BrnSelectionFilterType.Date || - f.filterType == BrnSelectionFilterType.DateRange || - f.filterType == BrnSelectionFilterType.DateRangeCalendar) + f.filterType == BrnSelectionFilterType.range || + f.filterType == BrnSelectionFilterType.date || + f.filterType == BrnSelectionFilterType.dateRange || + f.filterType == BrnSelectionFilterType.dateRangeCalendar) .forEach((f) { f.isSelected = false; f.customMap = Map(); @@ -544,10 +544,10 @@ class _BrnRangeSelectionGroupWidgetState extends State subFilterList) { subFilterList - .where((f) => f.filterType != BrnSelectionFilterType.Range) - .where((f) => f.filterType != BrnSelectionFilterType.Date) - .where((f) => f.filterType != BrnSelectionFilterType.DateRange) - .where((f) => f.filterType != BrnSelectionFilterType.DateRangeCalendar) + .where((f) => f.filterType != BrnSelectionFilterType.range) + .where((f) => f.filterType != BrnSelectionFilterType.date) + .where((f) => f.filterType != BrnSelectionFilterType.dateRange) + .where((f) => f.filterType != BrnSelectionFilterType.dateRangeCalendar) .forEach((f) { f.isSelected = false; f.customMap = Map(); @@ -558,9 +558,9 @@ class _BrnRangeSelectionGroupWidgetState extends State filterList) { List ranges = filterList .where((f) => - (f.filterType == BrnSelectionFilterType.Range || - f.filterType == BrnSelectionFilterType.DateRange || - f.filterType == BrnSelectionFilterType.DateRangeCalendar) && + (f.filterType == BrnSelectionFilterType.range || + f.filterType == BrnSelectionFilterType.dateRange || + f.filterType == BrnSelectionFilterType.dateRangeCalendar) && f.isSelected) .toList(); @@ -594,9 +594,9 @@ class _BrnRangeSelectionGroupWidgetState extends State subFilterList) { bool isCustomInputSelected = false; for (BrnSelectionEntity entity in subFilterList) { - if (BrnSelectionFilterType.Range == entity.filterType || - BrnSelectionFilterType.DateRange == entity.filterType || - BrnSelectionFilterType.DateRangeCalendar == entity.filterType) { + if (BrnSelectionFilterType.range == entity.filterType || + BrnSelectionFilterType.dateRange == entity.filterType || + BrnSelectionFilterType.dateRangeCalendar == entity.filterType) { isCustomInputSelected = entity.isSelected; break; } @@ -604,9 +604,9 @@ class _BrnRangeSelectionGroupWidgetState extends State - f.filterType != BrnSelectionFilterType.Range && - f.filterType != BrnSelectionFilterType.DateRange && - f.filterType != BrnSelectionFilterType.DateRangeCalendar && + f.filterType != BrnSelectionFilterType.range && + f.filterType != BrnSelectionFilterType.dateRange && + f.filterType != BrnSelectionFilterType.dateRangeCalendar && f.isSelected) .toList(); if (!isCustomInputSelected && BrunoTools.isEmpty(selectedItem)) { @@ -624,8 +624,8 @@ class _BrnRangeSelectionGroupWidgetState extends State - _.filterType == BrnSelectionFilterType.Date || - _.filterType == BrnSelectionFilterType.DateRangeCalendar) + _.filterType == BrnSelectionFilterType.date || + _.filterType == BrnSelectionFilterType.dateRangeCalendar) .toList() .length > 0; @@ -634,8 +634,8 @@ class _BrnRangeSelectionGroupWidgetState extends State - _.filterType == BrnSelectionFilterType.Date || - _.filterType == BrnSelectionFilterType.DateRangeCalendar) + _.filterType == BrnSelectionFilterType.date || + _.filterType == BrnSelectionFilterType.dateRangeCalendar) .toList() .length; if (count > 0) { diff --git a/lib/src/components/selection/widget/brn_selection_single_list_widget.dart b/lib/src/components/selection/widget/brn_selection_single_list_widget.dart index 41d3ca8c..e578d08a 100644 --- a/lib/src/components/selection/widget/brn_selection_single_list_widget.dart +++ b/lib/src/components/selection/widget/brn_selection_single_list_widget.dart @@ -35,10 +35,10 @@ class BrnSelectionSingleListWidget extends StatefulWidget { }) : super(key: key) { items = items .where((_) => - _.filterType != BrnSelectionFilterType.Range && - _.filterType != BrnSelectionFilterType.Date && - _.filterType != BrnSelectionFilterType.DateRange && - _.filterType != BrnSelectionFilterType.DateRangeCalendar) + _.filterType != BrnSelectionFilterType.range && + _.filterType != BrnSelectionFilterType.date && + _.filterType != BrnSelectionFilterType.dateRange && + _.filterType != BrnSelectionFilterType.dateRangeCalendar) .toList(); /// 当前 Items 所在的层级 @@ -81,8 +81,8 @@ class _BrnSelectionSingleListWidgetState extends State f.isSelected).length ?? 0) > 0) { @@ -163,11 +163,11 @@ class _BrnSelectionSingleListWidgetState extends State f != selectedEntity).forEach((f) { f.clearChildSelection(); f.isSelected = false; }); selectedEntity.isSelected = true; - } else if (BrnSelectionFilterType.Checkbox == selectedEntity.filterType) { + } else if (BrnSelectionFilterType.checkbox == selectedEntity.filterType) { /// 选中【不限】清除同一级别其他的状态 if (selectedEntity.isUnLimit()) { selectedEntity.parent?.children.where((f) => f != selectedEntity).forEach((f) { From 589daf15d52667ae7bbaf73c9f40a9567f2b4663 Mon Sep 17 00:00:00 2001 From: zhoujuanjuan <15143015732@163.com> Date: Wed, 16 Feb 2022 18:09:21 +0800 Subject: [PATCH 31/31] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9docs=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8Bform=E7=9B=B8=E5=85=B3=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E5=8F=8A=E6=89=80=E6=9C=89=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BrnAbnormalStateWidget.md | 2 +- .../form/BrnAddLabel/BrnAddLabel.md | 2 +- .../BrnExpandFormGroup/BrnExpandFormGroup.md | 2 +- .../BrnMultiChoiceInputFormItem.md | 8 ++-- .../BrnMultiChoicePortraitInputFormItem.md | 14 +++---- .../BrnNormalFormGroup/BrnNormalFormGroup.md | 2 +- .../BrnRadioInputFormItem.md | 19 ++++----- .../BrnRadioPortraitInputFormItem.md | 14 +++---- .../BrnRangeInputFormItem.md | 33 +++++++-------- .../BrnRatioInputFormItem.md | 6 +-- .../form/BrnStarsFormItem/BrnStarsFormItem.md | 6 +-- .../BrnStepInputFormItem.md | 5 +-- .../BrnTextBlockInputFormItem.md | 42 +++++++++---------- .../BrnTextInputFormItem.md | 14 +++---- .../BrnTextQuickSelectFormItem.md | 8 ++-- .../BrnTextSelectFormItem.md | 18 ++++---- .../form/BrnTitleFormItem/BrnTitleFormItem.md | 6 +-- .../BrnTitleSelectInputFormItem.md | 32 +++++++------- .../BrnMultiColumnPicker.md | 6 +-- .../BrnSelectionView/BrnSelectionView.md | 28 ++++++------- lib/src/theme/base/brn_base_config.dart | 1 - 21 files changed, 132 insertions(+), 136 deletions(-) diff --git a/docs/components/abnormalCard/BrnAbnormalStateWidget/BrnAbnormalStateWidget.md b/docs/components/abnormalCard/BrnAbnormalStateWidget/BrnAbnormalStateWidget.md index 2a6f2f09..3d1d6bb2 100644 --- a/docs/components/abnormalCard/BrnAbnormalStateWidget/BrnAbnormalStateWidget.md +++ b/docs/components/abnormalCard/BrnAbnormalStateWidget/BrnAbnormalStateWidget.md @@ -57,7 +57,7 @@ BrnAbnormalStateWidget({ | img | Image | 图片 | 否 | | | title | String | 标题 | 否 | | | content | String | 内容 | 否 | | -| operateAreaType | enum OperateAreaType { SingleButton, DoubleButton, TextButton } | 操作区类型。SingleButton 为【单按钮】效果 DoubleButton 为【双按钮】效果 TextButton 为【文字链】效果 | 否 | OperateAreaType.TextButton | +| operateAreaType | enum OperateAreaType { singleButton, doubleButton, textButton } | 操作区类型。SingleButton 为【单按钮】效果 DoubleButton 为【双按钮】效果 TextButton 为【文字链】效果 | 否 | OperateAreaType.TextButton | | operateTexts | List | | | | | action | BrnEmptyStatusIndexedActionClickCallback = void Function(int index)index 点击的位置 | 点击回调,在 SingleButton 类型或者 enablePageTap = true 点击空白区域时返回 0;其他根据点击的位置返回。 | 否 | | | enablePageTap | bool | 空白区域是否可点击 | 否 | false | diff --git a/docs/components/form/BrnAddLabel/BrnAddLabel.md b/docs/components/form/BrnAddLabel/BrnAddLabel.md index aedf2e7f..a15e3676 100644 --- a/docs/components/form/BrnAddLabel/BrnAddLabel.md +++ b/docs/components/form/BrnAddLabel/BrnAddLabel.md @@ -39,7 +39,7 @@ BrnAddLabel({ | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.LABEL_ADD | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.labelAdd | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | | onTap | VoidCallback | 可操作区点击回调 | 否 | 无 | | diff --git a/docs/components/form/BrnExpandFormGroup/BrnExpandFormGroup.md b/docs/components/form/BrnExpandFormGroup/BrnExpandFormGroup.md index f42833c2..a6bc1820 100644 --- a/docs/components/form/BrnExpandFormGroup/BrnExpandFormGroup.md +++ b/docs/components/form/BrnExpandFormGroup/BrnExpandFormGroup.md @@ -56,7 +56,7 @@ BrnExpandFormGroup({ | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.NORMAL_GROUP_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.normalGroupType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | diff --git a/docs/components/form/BrnMultiChoiceInputFormItem/BrnMultiChoiceInputFormItem.md b/docs/components/form/BrnMultiChoiceInputFormItem/BrnMultiChoiceInputFormItem.md index ffc86c48..e42ccd61 100644 --- a/docs/components/form/BrnMultiChoiceInputFormItem/BrnMultiChoiceInputFormItem.md +++ b/docs/components/form/BrnMultiChoiceInputFormItem/BrnMultiChoiceInputFormItem.md @@ -47,7 +47,7 @@ BrnMultiChoiceInputFormItem({ this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: true, @@ -72,11 +72,11 @@ BrnMultiChoiceInputFormItem({ | **参数名** | 参数类型 | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType
.MULTI_CHOICE_PORTRAIT_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.multiChoicePortraitInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发 onTip 回调。 | 否 | 备注中类型 3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为 null 时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL2. 展示加号图标:BrnPrefixIconType.TYPE_ADD3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示\*图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑 false:禁用 | @@ -137,7 +137,7 @@ BrnMultiChoiceInputFormItem( ```dart BrnMultiChoiceInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", diff --git a/docs/components/form/BrnMultiChoicePortraitInputFormItem/BrnMultiChoicePortraitInputFormItem.md b/docs/components/form/BrnMultiChoicePortraitInputFormItem/BrnMultiChoicePortraitInputFormItem.md index c19f9515..9bb04350 100644 --- a/docs/components/form/BrnMultiChoicePortraitInputFormItem/BrnMultiChoicePortraitInputFormItem.md +++ b/docs/components/form/BrnMultiChoicePortraitInputFormItem/BrnMultiChoicePortraitInputFormItem.md @@ -48,7 +48,7 @@ BrnMultiChoicePortraitInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -73,11 +73,11 @@ this.themeData = BrnThemeConfigurator.instance | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.MULTI_CHOICE_PORTRAIT_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.multiChoicePortraitInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE\_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE\_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | @@ -94,9 +94,9 @@ this.themeData = BrnThemeConfigurator.instance ###### BrnPrefixIconType: ```dart class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` ## 四、代码演示 @@ -138,7 +138,7 @@ BrnMultiChoicePortraitInputFormItem( ```dart BrnMultiChoicePortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", diff --git a/docs/components/form/BrnNormalFormGroup/BrnNormalFormGroup.md b/docs/components/form/BrnNormalFormGroup/BrnNormalFormGroup.md index afd9cc19..3a1d2905 100644 --- a/docs/components/form/BrnNormalFormGroup/BrnNormalFormGroup.md +++ b/docs/components/form/BrnNormalFormGroup/BrnNormalFormGroup.md @@ -60,7 +60,7 @@ BrnNormalFormGroup({ | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | String | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.NORMAL_GROUP_TYPE | 外部可用此字段判断表单类型 | +| type | String | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.normalGroupType | 外部可用此字段判断表单类型 | | title | String | 录入项标题 | 否 | 无 | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | null | 1. 若赋值为 空字符串("")时仅展示"问号"图标,2. 若赋值为非空字符串时 展示"问号图标&文案",3. 若不赋值或赋值为null时 不显示提示项 | diff --git a/docs/components/form/BrnRadioInputFormItem/BrnRadioInputFormItem.md b/docs/components/form/BrnRadioInputFormItem/BrnRadioInputFormItem.md index 83fb480e..c799bf46 100644 --- a/docs/components/form/BrnRadioInputFormItem/BrnRadioInputFormItem.md +++ b/docs/components/form/BrnRadioInputFormItem/BrnRadioInputFormItem.md @@ -51,7 +51,7 @@ BrnRadioInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -78,11 +78,10 @@ BrnRadioInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TYPE_NORMAL | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示*图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | @@ -103,10 +102,10 @@ BrnRadioInputFormItem( ```dart -class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; +class BrnPrefixIconType { + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` ## 四、代码演示 @@ -142,7 +141,7 @@ BrnRadioInputFormItem( ![](./img/BrnRadioInputFormItemDemo2.png) ```dart BrnRadioInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", @@ -173,7 +172,7 @@ BrnRadioInputFormItem( ![](./img/BrnRadioInputFormItemDemo3.png) ```dart BrnRadioInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, title: "自然到访保护期", subTitle: "这里是副标题", @@ -203,7 +202,7 @@ BrnRadioInputFormItem( ![](./img/BrnRadioInputFormItemDemo4.png) ```dart BrnRadioInputFormItem.autoLayout( - prefixIconType: BrnPrefixIconType.TYPE_REMOVE, + prefixIconType: BrnPrefixIconType.remove, isRequire: true, error: "必填项不能为空", title: "autoLayout", diff --git a/docs/components/form/BrnRadioPortraitInputFormItem/BrnRadioPortraitInputFormItem.md b/docs/components/form/BrnRadioPortraitInputFormItem/BrnRadioPortraitInputFormItem.md index b7f70a32..237dc555 100644 --- a/docs/components/form/BrnRadioPortraitInputFormItem/BrnRadioPortraitInputFormItem.md +++ b/docs/components/form/BrnRadioPortraitInputFormItem/BrnRadioPortraitInputFormItem.md @@ -46,7 +46,7 @@ BrnRadioPortraitInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -73,11 +73,11 @@ BrnRadioPortraitInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | -------------- | -------------------------- | ------------------------------------------------------------------ | ------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.RADIO_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.radioInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | 无 | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发 onTip 回调。 | 否 | 备注中类型 3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为 null 时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL2. 展示加号图标:BrnPrefixIconType.TYPE_ADD3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | 无 | | | isRequire | bool | 录入项是否为必填项(展示\*图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑 false:禁用 | @@ -96,9 +96,9 @@ BrnRadioPortraitInputFormItem( ```dart class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` @@ -138,7 +138,7 @@ BrnRadioPortraitInputFormItem( ```dart BrnRadioPortraitInputFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "自然到访保护期", diff --git a/docs/components/form/BrnRangeInputFormItem/BrnRangeInputFormItem.md b/docs/components/form/BrnRangeInputFormItem/BrnRangeInputFormItem.md index 65f5e8c0..19abd429 100644 --- a/docs/components/form/BrnRangeInputFormItem/BrnRangeInputFormItem.md +++ b/docs/components/form/BrnRangeInputFormItem/BrnRangeInputFormItem.md @@ -46,7 +46,7 @@ BrnRangeInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -82,11 +82,10 @@ BrnRangeInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TYPE_NORMAL | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标),默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | @@ -114,25 +113,25 @@ BrnRangeInputFormItem( #### BrnPrefixIconType: ``` dart -class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; +class BrnPrefixIconType { + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` #### BrnInputType ``` dart class BrnInputType { - static const String TEXT = "text"; - static const String MULTI_LINE = "multiline"; - static const String NUMBER = "number"; - static const String DECIMAL = "decimal"; - static const String PHONE = "phone"; - static const String DATE = "datetime"; - static const String EMAIL = "emailAddress"; - static const String URL = "url"; - static const String PWD = "visiblePassword"; + static const String text = "text"; + static const String multiLine = "multiline"; + static const String number = "number"; + static const String decimal = "decimal"; + static const String phone = "phone"; + static const String date = "datetime"; + static const String email = "emailAddress"; + static const String url = "url"; + static const String pwd = "visiblePassword"; } ``` ## 四、代码演示 @@ -178,7 +177,7 @@ BrnRangeInputFormItem( BrnRangeInputFormItem( minController: TextEditingController()..text = "10", maxController: TextEditingController()..text = "100", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "保护期", diff --git a/docs/components/form/BrnRatioInputFormItem/BrnRatioInputFormItem.md b/docs/components/form/BrnRatioInputFormItem/BrnRatioInputFormItem.md index c8e6d691..a6548d3f 100644 --- a/docs/components/form/BrnRatioInputFormItem/BrnRatioInputFormItem.md +++ b/docs/components/form/BrnRatioInputFormItem/BrnRatioInputFormItem.md @@ -44,7 +44,7 @@ BrnRatioInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -72,11 +72,11 @@ BrnRatioInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TEXT_INPUT_RATIO_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textInputRatioType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑,false:禁用 | diff --git a/docs/components/form/BrnStarsFormItem/BrnStarsFormItem.md b/docs/components/form/BrnStarsFormItem/BrnStarsFormItem.md index b6a280fb..d98d3e3d 100644 --- a/docs/components/form/BrnStarsFormItem/BrnStarsFormItem.md +++ b/docs/components/form/BrnStarsFormItem/BrnStarsFormItem.md @@ -41,7 +41,7 @@ BrnStarsFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -66,11 +66,11 @@ BrnStarsFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.STAR_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.starInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE\_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE\_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | diff --git a/docs/components/form/BrnStepInputFormItem/BrnStepInputFormItem.md b/docs/components/form/BrnStepInputFormItem/BrnStepInputFormItem.md index f388bbd6..b97f5f2d 100644 --- a/docs/components/form/BrnStepInputFormItem/BrnStepInputFormItem.md +++ b/docs/components/form/BrnStepInputFormItem/BrnStepInputFormItem.md @@ -42,7 +42,7 @@ BrnStepInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -69,11 +69,10 @@ BrnStepInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TYPE_NORMAL | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE\_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE\_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | diff --git a/docs/components/form/BrnTextBlockInputFormItem/BrnTextBlockInputFormItem.md b/docs/components/form/BrnTextBlockInputFormItem/BrnTextBlockInputFormItem.md index 5c764ac7..4c07ac49 100644 --- a/docs/components/form/BrnTextBlockInputFormItem/BrnTextBlockInputFormItem.md +++ b/docs/components/form/BrnTextBlockInputFormItem/BrnTextBlockInputFormItem.md @@ -43,11 +43,11 @@ group: BrnTextBlockInputFormItem( {Key key, this.label, - this.type: BrnInputItemType.TEXT_BLOCK_INPUT_TYPE, + this.type: BrnInputItemType.textBlockInputType, this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -77,11 +77,11 @@ BrnTextBlockInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TEXT_BLOCK_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textBlockInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | @@ -106,26 +106,26 @@ BrnTextBlockInputFormItem( ```dart -class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; +class BrnPrefixIconType { + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` #### BrnInputType -```dart r +```dart class BrnInputType { - static const String TEXT = "text"; - static const String MULTI_LINE = "multiline"; - static const String NUMBER = "number"; - static const String DECIMAL = "decimal"; - static const String PHONE = "phone"; - static const String DATE = "datetime"; - static const String EMAIL = "emailAddress"; - static const String URL = "url"; - static const String PWD = "visiblePassword"; + static const String text = "text"; + static const String multiLine = "multiline"; + static const String number = "number"; + static const String decimal = "decimal"; + static const String phone = "phone"; + static const String date = "datetime"; + static const String email = "emailAddress"; + static const String url = "url"; + static const String pwd = "visiblePassword"; } ``` ## 四、代码演示 @@ -160,7 +160,7 @@ BrnTextBlockInputFormItem( ```dart BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -189,7 +189,7 @@ BrnTextBlockInputFormItem( ```dart BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, title: "备注", @@ -217,7 +217,7 @@ BrnTextBlockInputFormItem( ```dart BrnTextBlockInputFormItem( controller: TextEditingController()..text = "hello", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/docs/components/form/BrnTextInputFormItem/BrnTextInputFormItem.md b/docs/components/form/BrnTextInputFormItem/BrnTextInputFormItem.md index ca77d8f8..284cc1ba 100644 --- a/docs/components/form/BrnTextInputFormItem/BrnTextInputFormItem.md +++ b/docs/components/form/BrnTextInputFormItem/BrnTextInputFormItem.md @@ -43,11 +43,11 @@ group: BrnTextInputFormItem({ Key key, this.label, - this.type: BrnInputItemType.TEXT_INPUT_TYPE, + this.type: BrnInputItemType.textInputType, this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -77,11 +77,11 @@ BrnTextInputFormItem({ | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TEXT_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | @@ -158,7 +158,7 @@ BrnTextInputFormItem( ```dart BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, error: "必填项不能为空", @@ -188,7 +188,7 @@ BrnTextInputFormItem( ```dart BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: true, title: "房屋总价", @@ -217,7 +217,7 @@ BrnTextInputFormItem( ```dart BrnTextInputFormItem( controller: TextEditingController()..text = "300", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, isPrefixIconEnabled: true, diff --git a/docs/components/form/BrnTextQuickSelectFormItem/BrnTextQuickSelectFormItem.md b/docs/components/form/BrnTextQuickSelectFormItem/BrnTextQuickSelectFormItem.md index cbc675e5..b174a09a 100644 --- a/docs/components/form/BrnTextQuickSelectFormItem/BrnTextQuickSelectFormItem.md +++ b/docs/components/form/BrnTextQuickSelectFormItem/BrnTextQuickSelectFormItem.md @@ -39,7 +39,7 @@ BrnTextQuickSelectFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -69,14 +69,14 @@ BrnTextQuickSelectFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TEXT_QUICK_SELECT_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textQuickSelectInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑false:禁用 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 BrnPrefixIconType 类 | 否 | BrnPrefixIconType.TYPE\_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL2. 展示加号图标:BrnPrefixIconType.TYPE\_ADD3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 BrnPrefixIconType 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | isBtnsScroll | bool | 快捷按钮是否可滑动 | 否 | 无 | true:可滚动false:不可滚动 | | btnsTxt | List | 按钮文案 | 否 | 无 | | | selectBtnList | List | 按钮是否默认选中 | 否 | 无 | true:选中false:未选中 | @@ -150,7 +150,7 @@ List options = ['选项1', '选项2', '选项3', '选项4']; List statusAllFunctionDemo = [false, false, false, false]; BrnTextQuickSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, btnsTxt: options, selectBtnList: statusAllFunctionDemo, diff --git a/docs/components/form/BrnTextSelectFormItem/BrnTextSelectFormItem.md b/docs/components/form/BrnTextSelectFormItem/BrnTextSelectFormItem.md index bf41b71b..3cfee756 100644 --- a/docs/components/form/BrnTextSelectFormItem/BrnTextSelectFormItem.md +++ b/docs/components/form/BrnTextSelectFormItem/BrnTextSelectFormItem.md @@ -40,7 +40,7 @@ BrnTextSelectFormItem({ this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -68,7 +68,7 @@ BrnTextSelectFormItem({ | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.TEXT_SELECT_INPUT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textSelectInputType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | @@ -92,10 +92,10 @@ BrnTextSelectFormItem({ #### BrnPrefixIconType: ```dart -class BrnPrefixIconType{ - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; +class BrnPrefixIconType { + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` ## 四、代码演示 @@ -125,7 +125,7 @@ BrnTextSelectFormItem( ![](./img/BrnTextSelectFormItemDemo2.png) ```dart BrnTextSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "证件类型", @@ -151,7 +151,7 @@ BrnTextSelectFormItem( ```dart BrnTextSelectFormItem( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, title: "证件类型", subTitle: "这里是副标题", @@ -176,7 +176,7 @@ BrnTextSelectFormItem( ```dart BrnTextSelectFormItem.autoLayout( - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, error: "必填项不能为空", title: "证件类型", diff --git a/docs/components/form/BrnTitleFormItem/BrnTitleFormItem.md b/docs/components/form/BrnTitleFormItem/BrnTitleFormItem.md index ac2f6d85..68776bf8 100644 --- a/docs/components/form/BrnTitleFormItem/BrnTitleFormItem.md +++ b/docs/components/form/BrnTitleFormItem/BrnTitleFormItem.md @@ -32,7 +32,7 @@ BrnTitleFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -53,11 +53,11 @@ BrnTitleFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.LABEL_TITLE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.labelTitle | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE\_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE\_NORMAL2. 展示加号图标:BrnPrefixIconType.TYPE\_ADD3. 展示减号图标:BrnPrefixIconType.TYPE\_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal2. 展示加号图标:BrnPrefixIconType.add3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标), 默认为 false 不必填 | 否 | false | | | isEdit | bool | 录入项 是否可编辑 | 否 | true | true:可编辑,false:禁用 | diff --git a/docs/components/form/BrnTitleSelectInputFormItem/BrnTitleSelectInputFormItem.md b/docs/components/form/BrnTitleSelectInputFormItem/BrnTitleSelectInputFormItem.md index fe8f77d6..810e1cd3 100644 --- a/docs/components/form/BrnTitleSelectInputFormItem/BrnTitleSelectInputFormItem.md +++ b/docs/components/form/BrnTitleSelectInputFormItem/BrnTitleSelectInputFormItem.md @@ -44,7 +44,7 @@ BrnTitleSelectInputFormItem( this.title: "", this.subTitle, this.tipLabel, - this.prefixIconType: BrnPrefixIconType.TYPE_NORMAL, + this.prefixIconType: BrnPrefixIconType.normal, this.error: "", this.isEdit: true, this.isRequire: false, @@ -76,11 +76,11 @@ BrnTitleSelectInputFormItem( | **参数名** | **参数类型** | **描述** | **是否必填** | **默认值** | **备注** | | --- | --- | --- | --- | --- | --- | | label | String | 录入项的唯一标识,主要用于录入类型页面框架中 | 否 | 无 | | -| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType
.TEXT_INPUT_TITLE_SELECT_TYPE | 外部可根据此字段判断表单项类型 | +| type | Stirng | 录入项类型,主要用于录入类型页面框架中 | 否 | BrnInputItemType.textInputTitleSelectType | 外部可根据此字段判断表单项类型 | | title | String | 录入项标题 | 否 | '' | | | subTitle | String | 录入项子标题 | 否 | 无 | | | tipLabel | String | 录入项提示(问号图标&文案) 用户点击时触发onTip回调。 | 否 | 备注中类型3 | 1. 设置"空字符串"时展示问号图标 2. 设置"非空字符串"时展示问号图标&文案 3. 若不赋值或赋值为null时,不显示提示项 | -| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.TYPE_NORMAL | 1. 不展示图标:BrnPrefixIconType.TYPE_NORMAL 2. 展示加号图标:BrnPrefixIconType.TYPE_ADD 3. 展示减号图标:BrnPrefixIconType.TYPE_REMOVE | +| prefixIconType | String | 录入项前缀图标样式 "添加项" "删除项" 详见 **BrnPrefixIconType** 类 | 否 | BrnPrefixIconType.normal | 1. 不展示图标:BrnPrefixIconType.normal 2. 展示加号图标:BrnPrefixIconType.add 3. 展示减号图标:BrnPrefixIconType.remove | | error | String | 录入项错误提示 | 否 | '' | | | isRequire | bool | 录入项是否为必填项(展示`*`图标) 默认为 false 不必填 | 否 | false | | | isPrefixIconEnabled | bool | 录入项不可编辑时(isEdit: false) "+"、"-"号是否可点击,true: 可点击回调false: 不可点击回调 | 否 | false | | @@ -104,9 +104,9 @@ BrnTitleSelectInputFormItem( ```dart class BrnPrefixIconType { - static const String TYPE_NORMAL = "type_normal"; - static const String TYPE_ADD = "type_add"; - static const String TYPE_REMOVE = "type_remove"; + static const String normal = "type_normal"; + static const String add = "type_add"; + static const String remove = "type_remove"; } ``` @@ -114,15 +114,15 @@ class BrnPrefixIconType { ```dart class BrnInputType { - static const String TEXT = "text"; - static const String MULTI_LINE = "multiline"; - static const String NUMBER = "number"; - static const String DECIMAL = "decimal"; - static const String PHONE = "phone"; - static const String DATE = "datetime"; - static const String EMAIL = "emailAddress"; - static const String URL = "url"; - static const String PWD = "visiblePassword"; + static const String text = "text"; + static const String multiLine = "multiline"; + static const String number = "number"; + static const String decimal = "decimal"; + static const String phone = "phone"; + static const String date = "datetime"; + static const String email = "emailAddress"; + static const String url = "url"; + static const String pwd = "visiblePassword"; } ``` @@ -174,7 +174,7 @@ _list.add('手机号'); _list.add('座机'); BrnTitleSelectInputFormItem( controller: TextEditingController()..text = "124", - prefixIconType: BrnPrefixIconType.TYPE_ADD, + prefixIconType: BrnPrefixIconType.add, isRequire: true, isEdit: false, error: "必填项不能为空", diff --git a/docs/components/picker/BrnMultiColumnPicker/BrnMultiColumnPicker.md b/docs/components/picker/BrnMultiColumnPicker/BrnMultiColumnPicker.md index 23bba47b..0781a113 100644 --- a/docs/components/picker/BrnMultiColumnPicker/BrnMultiColumnPicker.md +++ b/docs/components/picker/BrnMultiColumnPicker/BrnMultiColumnPicker.md @@ -58,9 +58,9 @@ BrnMultiColumnPicker( ```dart enum PickerFilterType { - None, //未设置 - Radio, //单选项,对应 type 为 radio - Checkbox, //多选项,对应 type 为 checkbox + none, //未设置 + radio, //单选项,对应 type 为 radio + checkbox, //多选项,对应 type 为 checkbox } ``` diff --git a/docs/components/selection/BrnSelectionView/BrnSelectionView.md b/docs/components/selection/BrnSelectionView/BrnSelectionView.md index 3ce81f6d..8e84a036 100644 --- a/docs/components/selection/BrnSelectionView/BrnSelectionView.md +++ b/docs/components/selection/BrnSelectionView/BrnSelectionView.md @@ -107,40 +107,40 @@ BrnSelectionView( ```dart enum BrnSelectionFilterType { /// 未设置 - None, + none, /// 不限类型 - UnLimit, + unLimit, /// 单选列表、单选项 type 为 radio - Radio, + radio, /// 多选列表、多选项 type 为 checkbox - Checkbox, + checkbox, /// 一般的值范围自定义区间 type 为 range - Range, + range, /// 日期选择,普通筛选时使用 CalendarView 展示选择时间,更多情况下使用 DatePicker 选择时间 - Date, + date, /// 自定义选择日期区间, type 为 dateRange - DateRange, + dateRange, /// 自定义通过 Calendar 选择日期区间,type 为 dateRangeCalendar - DateRangeCalendar, + dateRangeCalendar, /// 标签筛选 type 为 customerTag - CustomHandle, + customHandle, /// 更多列表、多选项 无 type - More, + more, /// 去二级页面 - Layer, + layer, /// 去自定义二级页面 - CustomLayer, + customLayer, } ``` @@ -165,8 +165,8 @@ enum BrnSelectionFilterType { ```dart enum SelectionWindowType { - List, //列表类型筛选弹窗,使用列表展示。 - Range, //标签类型筛选弹窗,使用 Tag + Range 的方式展示 + list, //列表类型筛选弹窗,使用列表展示。 + range, //标签类型筛选弹窗,使用 Tag + Range 的方式展示 } ``` diff --git a/lib/src/theme/base/brn_base_config.dart b/lib/src/theme/base/brn_base_config.dart index ebbcf3a7..ccb9ad60 100644 --- a/lib/src/theme/base/brn_base_config.dart +++ b/lib/src/theme/base/brn_base_config.dart @@ -1,5 +1,4 @@ import 'package:bruno/src/theme/brn_theme_configurator.dart'; -import 'package:bruno/src/theme/base/brn_default_config_utils.dart'; import 'package:bruno/src/theme/configs/brn_common_config.dart'; /// 组件配置基类