diff --git a/README.md b/README.md index e1f84bb..e34d124 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,20 @@ ## dep -![flutter_screenutil](https://img.shields.io/badge/flutter__screenutil-%203.2.0-brightgreen) +![flutter_screenutil](https://img.shields.io/badge/flutter__screenutil-3.2.0-brightgreen) ## Getting Started +### 安装ansu_ui + +#### Android + +Change the minimum Android sdk version to 21 (or higher) in your `android/app/build.gradle` file. + +```gradle +minSdkVersion 21 +``` + ## 贡献 ### 组件命名 diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3932aa9..5a4d759 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" - minSdkVersion 16 + minSdkVersion 21 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..e8efba1 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#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 592ceee..399e934 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# 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_button.dart b/example/lib/example_button.dart index f9abfa7..1687eb2 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -10,7 +10,6 @@ class ExampleButton extends StatefulWidget { } class _ExampleButtonState extends State { - TextEditingController _EditingController = TextEditingController(); @override Widget build(BuildContext context) { return ASScaffold( @@ -70,11 +69,6 @@ class _ExampleButtonState extends State { padding: EdgeInsets.symmetric(horizontal: 100.w), child: ASLongButton.solid(title: 'null', onPressed: () {}), ), - ASNumericButton( - initValue: 1, - suffix: '个', - onChange: (value) {}, - ), Row( children: [ ASButton.order( diff --git a/example/lib/example_numeric_button.dart b/example/lib/example_numeric_button.dart new file mode 100644 index 0000000..4dc034e --- /dev/null +++ b/example/lib/example_numeric_button.dart @@ -0,0 +1,43 @@ +import 'package:ansu_ui/ansu_ui.dart'; +import 'package:flutter/material.dart'; + +class ExampleNumericButton extends StatefulWidget { + ExampleNumericButton({Key key}) : super(key: key); + + @override + _ExampleNumericButtonState createState() => _ExampleNumericButtonState(); +} + +class _ExampleNumericButtonState extends State { + _showSnack(BuildContext context, String title) { + Scaffold.of(context).showSnackBar( + SnackBar(content: Text(title)), + ); + } + + @override + Widget build(BuildContext context) { + return ASScaffold( + title: '数量选择器', + body: Builder( + builder: (context) { + return ListView( + children: [ + ASNumericButton( + initValue: 0, + maxValue: 10, + onChange: (value) {}, + reachMax: (value) { + _showSnack(context, 'reach max'); + }, + reachMin: (value) { + _showSnack(context, 'reach min'); + }, + ) + ], + ); + }, + ), + ); + } +} diff --git a/example/lib/example_scaffold.dart b/example/lib/example_scaffold.dart index ee5dd38..9554bb9 100644 --- a/example/lib/example_scaffold.dart +++ b/example/lib/example_scaffold.dart @@ -26,7 +26,7 @@ class _ExampleScaffoldState extends State @override Widget build(BuildContext context) { return ASScaffold( - title: '标题 SCaffold', + title: '标题 Scaffold', appBarBottom: ASTabBar( items: tabs, isScrollable: true, diff --git a/example/lib/example_tab_bar.dart b/example/lib/example_tab_bar.dart new file mode 100644 index 0000000..6df6cab --- /dev/null +++ b/example/lib/example_tab_bar.dart @@ -0,0 +1,58 @@ +import 'package:ansu_ui/ansu_ui.dart'; +import 'package:flutter/material.dart'; + +class ExampleTabBar extends StatefulWidget { + ExampleTabBar({Key key}) : super(key: key); + + @override + _ExampleTabBarState createState() => _ExampleTabBarState(); +} + +class _ExampleTabBarState extends State + with TickerProviderStateMixin { + TabController _tabController1; + TabController _tabController2; + TabController _tabController3; + @override + void initState() { + super.initState(); + _tabController1 = TabController(length: 3, vsync: this); + _tabController2 = TabController(length: 5, vsync: this); + _tabController3 = TabController(length: 10, vsync: this); + } + + @override + void dispose() { + _tabController1?.dispose(); + _tabController2?.dispose(); + _tabController3?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ASScaffold( + title: 'TabBar', + appBarBottom: PreferredSize( + child: Column( + children: [ + ASTabBar( + items: ['全部', 'Part1', 'Part2'], + controller: _tabController1, + ), + ASTabBar( + items: List.generate(5, (index) => 'Tab $index'), + controller: _tabController2, + ), + ASTabBar( + isScrollable: true, + items: List.generate(10, (index) => 'Tab $index'), + controller: _tabController3, + ), + ], + ), + preferredSize: Size.fromHeight(46 * 3.0), + ), + ); + } +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 3735365..d858a30 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,8 +3,12 @@ import 'package:example/example_bottom_button.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'example_numeric_button.dart'; import 'example_scaffold.dart'; import 'example_button.dart'; +import 'example_tab_bar.dart'; +import 'example_numeric_button.dart'; +import 'example_tab_bar.dart'; void main() { runApp(MyApp()); @@ -42,10 +46,21 @@ class _MyHomePageState extends State { return ASScaffold( title: '安速组件', body: ListView( + padding: EdgeInsets.all(16.w), children: [ - ASButton.info(title:'Button',onPressed: () => Get.to(ExampleButton())), - ASButton.info(title:'Scaffold', onPressed:() => Get.to(ExampleScaffold())), - ASButton.info(title: 'BottomBottun',onPressed: () => Get.to(ExampleBottomButton()),), + ASButton.info( + title: '按钮 Button', onPressed: () => Get.to(ExampleButton())), + ASButton.info( + title: 'Scaffold', onPressed: () => Get.to(ExampleScaffold())), + ASButton.info( + title: 'Tabbar', onPressed: () => Get.to(ExampleTabBar())), + ASButton.info( + title: '数量选择器NumericButton', + onPressed: () => Get.to(ExampleNumericButton())), + ASButton.info( + title: '底部按钮 BottomButton', + onPressed: () => Get.to(ExampleBottomButton()), + ) ], ), ); diff --git a/lib/ansu_ui.dart b/lib/ansu_ui.dart index 83ccb89..99e75b5 100644 --- a/lib/ansu_ui.dart +++ b/lib/ansu_ui.dart @@ -8,6 +8,7 @@ export 'scaffold/as_scaffold.dart'; export 'styles/as_colors.dart'; export 'bar/as_tabbar.dart'; export 'drawer/as_drawer.dart'; + export 'utils/screen_adapter.dart'; //`BOTTOM` is external lib diff --git a/lib/buttons/as_numeric_button.dart b/lib/buttons/as_numeric_button.dart index 6088dc0..e20565c 100644 --- a/lib/buttons/as_numeric_button.dart +++ b/lib/buttons/as_numeric_button.dart @@ -95,6 +95,12 @@ class _ASNumericButtonState extends State { _controller = TextEditingController(text: widget.initValue.toString()); } + @override + void dispose() { + _controller?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Row( @@ -125,9 +131,11 @@ class _ASNumericButtonState extends State { alignment: Alignment.center, child: IntrinsicWidth( child: TextField( + keyboardType: TextInputType.number, controller: _controller, onChanged: (text) { setState(() {}); + //TODO input check }, focusNode: _focusNode, style: TextStyle(