From 0f373649af9d69cd3fc6bd58560a9ff62d644937 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 24 Nov 2020 15:27:09 +0800 Subject: [PATCH 1/2] add camera support --- README.md | 13 +++++- example/android/app/build.gradle | 2 +- example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 1 + example/ios/Podfile | 41 +++++++++++++++++ example/lib/example_button.dart | 6 --- example/lib/example_numeric_button.dart | 43 ++++++++++++++++++ example/lib/example_scaffold.dart | 2 +- example/lib/example_tab_bar.dart | 58 +++++++++++++++++++++++++ example/lib/main.dart | 14 +++++- example/pubspec.lock | 9 +++- lib/buttons/as_numeric_button.dart | 8 ++++ pubspec.lock | 9 +++- pubspec.yaml | 1 + 14 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 example/ios/Podfile create mode 100644 example/lib/example_numeric_button.dart create mode 100644 example/lib/example_tab_bar.dart diff --git a/README.md b/README.md index e1f84bb..be7d75c 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,21 @@ ## 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) +![camera](https://img.shields.io/badge/camera-0.5.8+11-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 34a8f20..3a2d4bf 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -9,7 +9,6 @@ class ExampleButton extends StatefulWidget { } class _ExampleButtonState extends State { - TextEditingController _EditingController = TextEditingController(); @override Widget build(BuildContext context) { return ASScaffold( @@ -45,11 +44,6 @@ class _ExampleButtonState extends State { padding: EdgeInsets.symmetric(horizontal: 100.w), child: ASLongButton.solid(title: 'null', onpressed: () {}), ), - ASNumericButton( - initValue: 1, - suffix: '个', - onChange: (value) {}, - ), ], ), ); 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 072a3d7..97d6da7 100644 --- a/example/lib/example_scaffold.dart +++ b/example/lib/example_scaffold.dart @@ -27,7 +27,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 e4431e8..a4a80bc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -4,6 +4,8 @@ import 'package:get/get.dart'; import 'example_scaffold.dart'; import 'example_button.dart'; +import 'example_tab_bar.dart'; +import 'example_numeric_button.dart'; void main() { runApp(MyApp()); @@ -41,9 +43,17 @@ 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: '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())), ], ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index d1a090b..35c3b8c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -22,6 +22,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.1" + camera: + dependency: transitive + description: + name: camera + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.8+11" characters: dependency: transitive description: @@ -172,4 +179,4 @@ packages: version: "2.1.0-nullsafety.3" sdks: dart: ">=2.10.0 <2.11.0" - flutter: ">=1.17.0" + flutter: ">=1.17.0 <2.0.0" 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( diff --git a/pubspec.lock b/pubspec.lock index 708b7b9..b1bd10c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,6 +15,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.1" + camera: + dependency: "direct main" + description: + name: camera + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.8+11" characters: dependency: transitive description: @@ -151,4 +158,4 @@ packages: version: "2.1.0-nullsafety.3" sdks: dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.17.0" + flutter: ">=1.17.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8e6c041..af967de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter flutter_screenutil: ^3.2.0 + camera: ^0.5.8+11 dev_dependencies: flutter_test: From ebe4c5187d036e35bf56145c23deb058e4b0768c Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 24 Nov 2020 15:44:24 +0800 Subject: [PATCH 2/2] remove camera --- README.md | 1 - example/lib/main.dart | 15 ++++++++++++--- example/pubspec.lock | 9 +-------- lib/ansu_ui.dart | 1 + pubspec.lock | 9 +-------- pubspec.yaml | 1 - 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index be7d75c..e34d124 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ## dep ![flutter_screenutil](https://img.shields.io/badge/flutter__screenutil-3.2.0-brightgreen) -![camera](https://img.shields.io/badge/camera-0.5.8+11-brightgreen) ## Getting Started diff --git a/example/lib/main.dart b/example/lib/main.dart index 42ee619..32e1c68 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,10 +2,12 @@ import 'package:ansu_ui/ansu_ui.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()); @@ -45,9 +47,16 @@ class _MyHomePageState extends State { 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: '按钮 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())), + ], ), ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 35c3b8c..d1a090b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -22,13 +22,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.1" - camera: - dependency: transitive - description: - name: camera - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.5.8+11" characters: dependency: transitive description: @@ -179,4 +172,4 @@ packages: version: "2.1.0-nullsafety.3" sdks: dart: ">=2.10.0 <2.11.0" - flutter: ">=1.17.0 <2.0.0" + flutter: ">=1.17.0" 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/pubspec.lock b/pubspec.lock index b1bd10c..708b7b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,13 +15,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.0-nullsafety.1" - camera: - dependency: "direct main" - description: - name: camera - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.5.8+11" characters: dependency: transitive description: @@ -158,4 +151,4 @@ packages: version: "2.1.0-nullsafety.3" sdks: dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.17.0 <2.0.0" + flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index af967de..8e6c041 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,6 @@ dependencies: flutter: sdk: flutter flutter_screenutil: ^3.2.0 - camera: ^0.5.8+11 dev_dependencies: flutter_test: