diff --git a/example/lib/example_dialog.dart b/example/lib/example_dialog.dart index 799ea5c..f4748c8 100644 --- a/example/lib/example_dialog.dart +++ b/example/lib/example_dialog.dart @@ -1,6 +1,7 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; class ExampleDialog extends StatefulWidget { @override @@ -42,12 +43,13 @@ class _ExampleDialogState extends State { )); }), ListTile( - title: 'BOTTOM DIALOG'.text, + title: 'BOTTOM DIALOG'.text.make(), onTap: () { showASBottomDialog( context, items: [ - ASBottomDialogItem(title: 'TEST'.text, onPressed: () {}), + ASBottomDialogItem( + title: 'TEST'.text.make(), onPressed: () {}), ], ); }, diff --git a/example/lib/example_pop_up_menu.dart b/example/lib/example_pop_up_menu.dart index 302ff6c..0a1684c 100644 --- a/example/lib/example_pop_up_menu.dart +++ b/example/lib/example_pop_up_menu.dart @@ -1,5 +1,6 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; class ExamplePopUpMenu extends StatefulWidget { ExamplePopUpMenu({Key key}) : super(key: key); @@ -17,20 +18,20 @@ class _ExamplePopUpMenuState extends State { children: [ SizedBox(height: 500), ListTile( - title: 'PopUpMenu'.text, + title: 'PopUpMenu'.text.make(), trailing: Builder( builder: (context) { return TextButton( - child: 'test'.text, + child: 'test'.text.make(), onPressed: () { showASPopUpMenu( context: context, initValue: 3, items: [ - PopupMenuItem(child: 'test'.text, value: 1), - PopupMenuItem(child: 'test'.text, value: 2), - PopupMenuItem(child: 'test'.text, value: 3), - PopupMenuItem(child: 'test'.text, value: 4), + PopupMenuItem(child: 'test'.text.make(), value: 1), + PopupMenuItem(child: 'test'.text.make(), value: 2), + PopupMenuItem(child: 'test'.text.make(), value: 3), + PopupMenuItem(child: 'test'.text.make(), value: 4), ], ).then((value) {}); }, diff --git a/example/lib/example_tag.dart b/example/lib/example_tag.dart index 382eba1..c1fd374 100644 --- a/example/lib/example_tag.dart +++ b/example/lib/example_tag.dart @@ -2,6 +2,7 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; import 'codeviewer/code_segments.dart'; import 'common/code_view.dart'; @@ -80,7 +81,7 @@ class _ExampaleTagState extends State { title: Text('ASCheckedTag'), trailing: ASCheckTag( checked: _checked, - text: 'TAG'.text, + text: 'TAG'.text.make(), ), ), // END diff --git a/example/pubspec.lock b/example/pubspec.lock index 44e7304..1460db0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + animator: + dependency: transitive + description: + name: animator + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.2" ansu_ui: dependency: "direct main" description: @@ -22,6 +29,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.4.2" + auto_size_text: + dependency: transitive + description: + name: auto_size_text + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" bot_toast: dependency: transitive description: @@ -226,6 +240,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.8.0-nullsafety.2" + states_rebuilder: + dependency: transitive + description: + name: states_rebuilder + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.0" string_scanner: dependency: transitive description: @@ -254,6 +275,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.3" + velocity_x: + dependency: transitive + description: + name: velocity_x + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" sdks: dart: ">=2.10.0 <2.11.0" flutter: ">=1.17.0 <2.0.0" diff --git a/lib/ansu_ui.dart b/lib/ansu_ui.dart index 011f86c..8eab789 100644 --- a/lib/ansu_ui.dart +++ b/lib/ansu_ui.dart @@ -68,5 +68,5 @@ export 'extension/list_extension.dart'; export 'extension/widget_extension.dart'; export 'extension/string_extension.dart'; export 'extension/text_style_extension.dart'; -export 'extension/text_extension.dart'; export 'extension/image_extension.dart'; +export 'package:velocity_x/velocity_x.dart'; diff --git a/lib/badge/as_badge.dart b/lib/badge/as_badge.dart index 8fbe244..472e688 100644 --- a/lib/badge/as_badge.dart +++ b/lib/badge/as_badge.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:ansu_ui/extension/string_extension.dart'; -import 'package:ansu_ui/extension/text_extension.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ansu_ui/extension/num_extension.dart'; +import 'package:velocity_x/velocity_x.dart'; class ASBadge extends StatelessWidget { final Widget child; @@ -37,7 +36,7 @@ class ASBadge extends StatelessWidget { borderRadius: 8.radius, ), height: 16.w, - child: tag.text.white.size(10), + child: tag.text.white.size(10).make(), ), ), ], diff --git a/lib/bar/as_tabbar.dart b/lib/bar/as_tabbar.dart index 2ee388d..4418ce2 100644 --- a/lib/bar/as_tabbar.dart +++ b/lib/bar/as_tabbar.dart @@ -3,7 +3,7 @@ import 'package:ansu_ui/bar/as_tab_indicator.dart'; import 'package:ansu_ui/bar/as_tabbar_item.dart'; import 'package:flutter/material.dart'; import 'package:ansu_ui/styles/as_colors.dart'; -import 'package:ansu_ui/extension/string_extension.dart'; +import 'package:velocity_x/velocity_x.dart'; /// ## 安速Tabbar /// @@ -69,14 +69,14 @@ class _ASTabBarState extends State { ? widget.tabItems.map((e) { return Tab( child: ASBadge( - child: e.title.text, + child: e.title.text.make(), tag: e.tag, ), ); }).toList() : widget.items .map((e) => Tab( - child: e.text, + child: e.text.make(), )) .toList(), labelStyle: TextStyle( diff --git a/lib/dialog/as_bottom_dialog.dart b/lib/dialog/as_bottom_dialog.dart index 6e57bde..4ae4ff2 100644 --- a/lib/dialog/as_bottom_dialog.dart +++ b/lib/dialog/as_bottom_dialog.dart @@ -2,9 +2,8 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/buttons/as_material_button.dart'; import 'package:flutter/material.dart'; import 'package:ansu_ui/styles/as_colors.dart'; -import 'package:ansu_ui/extension/string_extension.dart'; -import 'package:ansu_ui/extension/text_extension.dart'; import 'package:ansu_ui/extension/num_extension.dart'; +import 'package:velocity_x/velocity_x.dart'; ///ASDialog /// @@ -26,7 +25,7 @@ class _ASBottomDialogState extends State { onPressed: () { Navigator.pop(context); }, - child: '取消'.text.bold.black.size(18), + child: '取消'.text.black.size(18).make(), ); } diff --git a/lib/extension/string_extension.dart b/lib/extension/string_extension.dart index bc8b325..d3409cc 100644 --- a/lib/extension/string_extension.dart +++ b/lib/extension/string_extension.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:ansu_ui/toast/as_toast.dart'; extension PhoneExt on String { @@ -32,8 +31,6 @@ extension PhoneExt on String { return '${_parsePhone[0]}****${_parsePhone[2]}'; } - Text get text => Text(this); - get toast { ASToast.show(this); } diff --git a/lib/extension/text_extension.dart b/lib/extension/text_extension.dart deleted file mode 100644 index a56dcdf..0000000 --- a/lib/extension/text_extension.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:ansu_ui/extension/text_style_extension.dart'; - -extension TextExtension on Text { - Text get bold => Text( - this.data, - style: this.style?.bold ?? TextStyle().bold, - ); - - Text size(double size) { - return Text( - this.data, - style: this.style?.size(size) ?? TextStyle().size(size), - ); - } - - Text color(Color color) { - return Text( - this.data, - style: this.style?.colorX(color) ?? TextStyle().colorX(color), - ); - } - - Text height(double height) => Text( - this.data, - style: this.style?.heightX(height) ?? TextStyle().heightX(height), - ); - - Text get white => - Text(this.data, style: this.style?.white ?? TextStyle().white); - - Text get black => - Text(this.data, style: this.style?.black ?? TextStyle().black); - - Text get black65 => - Text(this.data, style: this.style?.black65 ?? TextStyle().black65); - - Text lines(int maxLines) { - return Text( - this.data, - maxLines: maxLines, - ); - } - - Text over(TextOverflow textOverflow) { - return Text( - this.data, - overflow: textOverflow, - ); - } - - Text get light => Text( - this.data, - style: this.style?.light ?? TextStyle().light, - ); - - Text copyWith({ - FontWeight fontWeight, - Color color, - double fontSize, - }) { - return Text(this.data, - style: this.style.copyWith( - fontWeight: fontWeight, - color: color, - fontSize: fontSize, - )); - } -} diff --git a/lib/pickers/as_two_date_picker.dart b/lib/pickers/as_two_date_picker.dart index 5b6a0bf..45b79cc 100644 --- a/lib/pickers/as_two_date_picker.dart +++ b/lib/pickers/as_two_date_picker.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ansu_ui/styles/as_colors.dart'; -import 'package:ansu_ui/extension/string_extension.dart'; import 'package:ansu_ui/extension/widget_extension.dart'; -import 'package:ansu_ui/extension/text_extension.dart'; import 'package:ansu_ui/extension/num_extension.dart'; import 'package:ansu_ui/extension/text_style_extension.dart'; import 'package:ansu_ui/pickers/as_date_range_picker_part.dart'; import 'package:ansu_ui/buttons/as_longbutton.dart'; +import 'package:velocity_x/velocity_x.dart'; class AS2DatePicker extends StatefulWidget { final bool isAnHour; @@ -50,9 +49,7 @@ class _AS2DatePickerState extends State { }, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, height: 70.w, - child: title.text.black - .size(16) - .copyWith(fontWeight: sameDay ? FontWeight.bold : FontWeight.normal), + child: title.text.black.size(16.sp).bold.make(), ); } @@ -79,7 +76,7 @@ class _AS2DatePickerState extends State { children: [ 30.wb, AnimatedDefaultTextStyle( - child: title.text, + child: title.text.make(), style: TextStyle().size(16).copyWith( color: selected ? kSecondaryColor : kTextColor, ), diff --git a/lib/utils/camera_view.dart b/lib/utils/camera_view.dart index 2daa804..2684c58 100644 --- a/lib/utils/camera_view.dart +++ b/lib/utils/camera_view.dart @@ -5,13 +5,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ansu_ui/styles/as_colors.dart'; import 'package:ansu_ui/scaffold/as_scaffold.dart'; -import 'package:ansu_ui/extension/string_extension.dart'; -import 'package:ansu_ui/extension/text_extension.dart'; import 'package:ansu_ui/utils/photo_viewer.dart'; import 'package:ansu_ui/utils/camera_util.dart'; import 'package:ansu_ui/extension/list_extension.dart'; import 'package:ansu_ui/divider/as_divider.dart'; +import 'package:velocity_x/velocity_x.dart'; + class CameraView extends StatefulWidget { final File file; final String title; @@ -24,7 +24,7 @@ class CameraView extends StatefulWidget { class _CameraViewState extends State { _buildButton({String title, Color color = kTextColor, onPressed}) { return MaterialButton( - child: title.text.bold.size(18).copyWith(color: color), + child: title.text.bold.size(18).color(color).make(), onPressed: onPressed, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, height: 48.w, diff --git a/pubspec.lock b/pubspec.lock index 0d92dea..0c504c5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + animator: + dependency: transitive + description: + name: animator + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.2" async: dependency: transitive description: @@ -8,6 +15,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.5.0-nullsafety.1" + auto_size_text: + dependency: transitive + description: + name: auto_size_text + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" boolean_selector: dependency: transitive description: @@ -116,6 +130,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.1" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.16.1" lpinyin: dependency: "direct main" description: @@ -177,6 +198,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0-nullsafety.1" + states_rebuilder: + dependency: transitive + description: + name: states_rebuilder + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.0" stream_channel: dependency: transitive description: @@ -219,6 +247,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.3" + velocity_x: + dependency: "direct main" + description: + name: velocity_x + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" sdks: dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.17.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2580d73..366216b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,8 @@ dependencies: lpinyin: ^1.1.0 image_picker: ^0.6.7+15 bot_toast: ^3.0.5 - + velocity_x: + dev_dependencies: flutter_test: sdk: flutter