diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ea6c6bc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "ansu_ui", + "request": "launch", + "type": "dart" + }, + { + "name": "example", + "cwd": "example", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index e8efba1..592ceee 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 399e934..592ceee 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1,2 +1 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile deleted file mode 100644 index 1e8c3c9..0000000 --- a/example/ios/Podfile +++ /dev/null @@ -1,41 +0,0 @@ -# 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 flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/example/lib/example_tag.dart b/example/lib/example_tag.dart new file mode 100644 index 0000000..37a3fda --- /dev/null +++ b/example/lib/example_tag.dart @@ -0,0 +1,27 @@ +import 'package:ansu_ui/scaffold/as_scaffold.dart'; +import 'package:ansu_ui/tag/as_tag.dart'; +import 'package:flutter/material.dart'; + +class ExampleTag extends StatefulWidget { + ExampleTag({Key key}) : super(key: key); + + @override + _ExampaleTagState createState() => _ExampaleTagState(); +} + +class _ExampaleTagState extends State { + @override + Widget build(BuildContext context) { + return ASScaffold(title: 'Tag', + body: Column( + children: [ + Row( + children: [ + ASTag.dangerousItem('带电'), + ], + ), + ], + ) + ); + } +} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index aa0844a..e2b209f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:example/example_bottom_button.dart'; +import 'package:example/example_tag.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; @@ -76,7 +77,8 @@ class _MyHomePageState extends State { ASButton.info( title: '底部按钮 BottomButton', onPressed: () => Get.to(ExampleBottomButton()), - ) + ), + ASButton.info(title: '标签 TAG',onPressed: () => Get.to(ExampleTag()),), ], ), ); diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart new file mode 100644 index 0000000..747db1d --- /dev/null +++ b/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/lib/tag/as_tag.dart b/lib/tag/as_tag.dart new file mode 100644 index 0000000..7e00c05 --- /dev/null +++ b/lib/tag/as_tag.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ASTag extends StatefulWidget { + ///宽度 + final double width; + + ///高度 + final double height; + + ///背景色 + final Color bgColor; + + ///标签内容 + final String text; + + ///标签文字颜色 + final Color textColor; + + ///标签文字风格 + final TextStyle textStyle; + + ///是否有边框 + final bool outline; + + ///边框颜色 + final Color outlineColor; + + ///圆角 + final double radius; + ASTag( + {Key key, + this.width, + this.height, + this.bgColor, + this.text, + this.textColor, + this.textStyle, + this.outline = false, + this.outlineColor, + this.radius}) + : super(key: key); + + ASTag.dangerousItem(this.text, + {Key key, + this.width, + this.height, + this.textStyle, + this.outlineColor, + this.radius}) + : bgColor = Color(0xFFF69A2D), + textColor = Color(0xFFFFFFFF), + outline = false, + super(key: key); + + @override + _ASTagState createState() => _ASTagState(); +} + +class _ASTagState extends State { + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.center, + width: widget.width ?? 36.w, + height: widget.height ?? 18.w, + decoration: BoxDecoration( + color: widget.bgColor ?? Color(0xFFF69A2D), + border: widget.outline + ? Border.all( + color: widget.outlineColor ?? Color(0xFFE50112), + ) + : Border.fromBorderSide(BorderSide.none), + borderRadius: BorderRadius.circular(widget.radius ?? 9.w)), + child: Text( + widget.text, + style: widget.textStyle ?? + TextStyle( + color: widget.textColor, + fontSize: 10.sp, + ), + ), + ); + } +} diff --git a/test/ansu_ui_test.dart b/test/ansu_ui_test.dart new file mode 100644 index 0000000..aae6e6c --- /dev/null +++ b/test/ansu_ui_test.dart @@ -0,0 +1,13 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:ansu_ui/ansu_ui.dart'; + +void main() { + test('adds one to input values', () { + final calculator = Calculator(); + expect(calculator.addOne(2), 3); + expect(calculator.addOne(-7), -6); + expect(calculator.addOne(0), 1); + expect(() => calculator.addOne(null), throwsNoSuchMethodError); + }); +}