diff --git a/android/app/build.gradle b/android/app/build.gradle index 603b4502..03806468 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -25,8 +25,15 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + + android { - compileSdkVersion 27 + compileSdkVersion 28 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -38,21 +45,28 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.ali.fluttergo" + applicationId "com.alibaba.fluttergo" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - buildTypes { + signingConfigs { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] } } + buildTypes { + release { + signingConfig signingConfigs.release + } + } + } flutter { @@ -62,8 +76,8 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' //firebase implementation 'com.google.firebase:firebase-core:16.0.8' //Crashlytics SDK diff --git a/android/app/google-services.json b/android/app/google-services.json index 5da02053..06bce26c 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -1,42 +1,35 @@ { "project_info": { - "project_number": "1002138254102", - //"firebase_url": "https://ali-flutter-go.firebaseio.com", - "project_id": "ali-flutter-go", - "storage_bucket": "ali-flutter-go.appspot.com" + "project_number": "611157827052", + "firebase_url": "https://alibaba-flutter-go.firebaseio.com", + "project_id": "alibaba-flutter-go", + "storage_bucket": "alibaba-flutter-go.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:1002138254102:android:00e8533fa0274183", + "mobilesdk_app_id": "1:611157827052:android:c6129e5eff2f125d", "android_client_info": { - "package_name": "com.ali.fluttergo" + "package_name": "com.alibaba.fluttergo" } }, "oauth_client": [ { - "client_id": "1002138254102-2r4hs0mm1avp4p1qielecihnbugan693.apps.googleusercontent.com", + "client_id": "611157827052-iiuevj8qu56alpqh47v37j9sd4e40di7.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyDFdL3GSwVDfejIq44pyOpiEBZ32dTGMVA" + "current_key": "AIzaSyA9chxDIuds7gmPQTJPpDpoXyN9rDTdvhU" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { - "client_id": "1002138254102-2r4hs0mm1avp4p1qielecihnbugan693.apps.googleusercontent.com", + "client_id": "611157827052-iiuevj8qu56alpqh47v37j9sd4e40di7.apps.googleusercontent.com", "client_type": 3 - }, - { - "client_id": "1002138254102-qo9jp8c3lc69p9lclu0rtp5dmt1kulv7.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.ali.fluttergo" - } } ] } @@ -44,4 +37,4 @@ } ], "configuration_version": "1" -} \ No newline at end of file +} diff --git a/android/app/release/output.json b/android/app/release/output.json new file mode 100644 index 00000000..16e1b0c5 --- /dev/null +++ b/android/app/release/output.json @@ -0,0 +1 @@ +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"0.0.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 6c60789b..615dd053 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.alibaba.fluttergo"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 97b1e4ee..80c74332 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.alibaba.fluttergo"> + android:src="@drawable/splash" /> diff --git a/android/app/src/main/res/mipmap-xhdpi/splash.png b/android/app/src/main/res/mipmap-xhdpi/splash.png deleted file mode 100644 index d42caece..00000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/splash.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/spalsh.png b/android/app/src/main/res/mipmap-xxxhdpi/spalsh.png new file mode 100644 index 00000000..dc63fc0e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/spalsh.png differ diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index 6c60789b..615dd053 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.alibaba.fluttergo"> diff --git a/android/build.gradle b/android/build.gradle index 906cf5c2..01a308ee 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.0' repositories { google() jcenter() @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.3.0' //firebase classpath 'com.google.gms:google-services:4.2.0' //Crashlytics SDK diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f68..678cd624 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/android/key.properties b/android/key.properties new file mode 100644 index 00000000..0be86790 --- /dev/null +++ b/android/key.properties @@ -0,0 +1,4 @@ +storePassword=fluttergo123 +keyPassword=fluttergo123 +keyAlias=key +storeFile=/Users/xj.deng/key.jks \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 53919b45..1301f46b 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -243,7 +243,8 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = RDJKXT446D; + DevelopmentTeam = 4WLT68XRNA; + ProvisioningStyle = Manual; }; }; }; @@ -252,6 +253,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -350,8 +352,8 @@ files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", + "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( @@ -359,7 +361,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -509,8 +511,9 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = RDJKXT446D; + DEVELOPMENT_TEAM = 4WLT68XRNA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -522,8 +525,9 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.ali.fluttergo; + PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "FlutterGO-alibaba-develop"; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -534,8 +538,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = RDJKXT446D; + DEVELOPMENT_TEAM = 4WLT68XRNA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -547,8 +553,9 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.ali.fluttergo; + PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = FlutterGO_alibaba_distribution_ad_hoc; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ba1a9822..04305270 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -42,7 +42,7 @@ CLIENT_ID - 1002138254102-qo9jp8c3lc69p9lclu0rtp5dmt1kulv7.apps.googleusercontent.com + 611157827052-0n777p43lrtr2dpo7gco5o3lffu7a7r4.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.1002138254102-qo9jp8c3lc69p9lclu0rtp5dmt1kulv7 + com.googleusercontent.apps.611157827052-0n777p43lrtr2dpo7gco5o3lffu7a7r4 API_KEY - AIzaSyD01jR14RevQibnzkg4tBUbFzc7UjKESFQ + AIzaSyDztt5Q9D7plAc8VqNtHumAci6BaoOiTg4 GCM_SENDER_ID - 1002138254102 + 611157827052 PLIST_VERSION 1 BUNDLE_ID - com.ali.fluttergo + com.alibaba.fluttergo PROJECT_ID - ali-flutter-go + alibaba-flutter-go STORAGE_BUCKET - ali-flutter-go.appspot.com + alibaba-flutter-go.appspot.com IS_ADS_ENABLED IS_ANALYTICS_ENABLED @@ -29,8 +29,8 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:1002138254102:ios:00e8533fa0274183 + 1:611157827052:ios:c6129e5eff2f125d DATABASE_URL - https://ali-flutter-go.firebaseio.com + https://alibaba-flutter-go.firebaseio.com \ No newline at end of file diff --git a/ios/Runner/Images.xcassets/LaunchImage-2.launchimage/Contents.json b/ios/Runner/Images.xcassets/LaunchImage-2.launchimage/Contents.json index 5a296668..a0ad363c 100644 --- a/ios/Runner/Images.xcassets/LaunchImage-2.launchimage/Contents.json +++ b/ios/Runner/Images.xcassets/LaunchImage-2.launchimage/Contents.json @@ -3,43 +3,30 @@ { "orientation" : "portrait", "idiom" : "ipad", - "minimum-system-version" : "7.0", "extent" : "full-screen", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", "minimum-system-version" : "7.0", - "extent" : "full-screen", "scale" : "1x" }, { "orientation" : "landscape", "idiom" : "ipad", - "minimum-system-version" : "7.0", "extent" : "full-screen", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "minimum-system-version" : "7.0", - "subtype" : "retina4", - "scale" : "2x" + "scale" : "1x" }, { "orientation" : "portrait", "idiom" : "ipad", - "minimum-system-version" : "7.0", "extent" : "full-screen", - "scale" : "1x" + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" } ], "info" : { diff --git a/lib/blocs/search_api.dart b/lib/blocs/bak/search_api.dart similarity index 100% rename from lib/blocs/search_api.dart rename to lib/blocs/bak/search_api.dart diff --git a/lib/blocs/search_bloc.dart b/lib/blocs/bak/search_bloc.dart similarity index 100% rename from lib/blocs/search_bloc.dart rename to lib/blocs/bak/search_bloc.dart diff --git a/lib/blocs/search_event.dart b/lib/blocs/bak/search_event.dart similarity index 100% rename from lib/blocs/search_event.dart rename to lib/blocs/bak/search_event.dart diff --git a/lib/blocs/bak/search_result.dart b/lib/blocs/bak/search_result.dart new file mode 100644 index 00000000..8001e49a --- /dev/null +++ b/lib/blocs/bak/search_result.dart @@ -0,0 +1,14 @@ +/** + * Created with Android Studio. + * User: 一晟 + * Date: 2019/4/28 + * Time: 7:11 PM + * email: zhu.yan@alibaba-inc.com + * tartget: + */ +class SearchResult { + String title; + String source; + + SearchResult({this.title, this.source}); +} \ No newline at end of file diff --git a/lib/blocs/search_state.dart b/lib/blocs/bak/search_state.dart similarity index 100% rename from lib/blocs/search_state.dart rename to lib/blocs/bak/search_state.dart diff --git a/lib/blocs/search_widget.dart b/lib/blocs/bak/search_widget.dart similarity index 100% rename from lib/blocs/search_widget.dart rename to lib/blocs/bak/search_widget.dart diff --git a/lib/blocs/industry_api.dart b/lib/blocs/industry_api.dart index de3ed457..fc8b2967 100644 --- a/lib/blocs/industry_api.dart +++ b/lib/blocs/industry_api.dart @@ -14,47 +14,45 @@ import './industry_model.dart'; import './search_result.dart'; var dio = new Dio(); -class Api2 { - /// 关键字提示(起点) - Future> suggestion(String query) async { -// http.Response response = await http.get( -// "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query"); - var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {}); - //var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query"); - print('1=====>${query}'); - print('2=====>${response.data}'); - //var data = Suggestion.fromJson(json.decode(response.body)); - //var data = Suggestion.fromJson(json.decode(response.data)); - var data = Suggestion.fromJson(json.decode(response.data)); - List suggestion = []; - data.suggestions.forEach((k) { - //print('=====>${k.value}'); - suggestion.add(k.value); - }); - - return Future.delayed(Duration(seconds:2), () { - return suggestion; - }); - //return suggestion; - } -} +//class Api2 { +// /// 关键字提示(起点) +// Future> suggestion(String query) async { +//// http.Response response = await http.get( +//// "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query"); +// var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {}); +// //var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query"); +// print('1=====>${query}'); +// print('2=====>${response.data}'); +// //var data = Suggestion.fromJson(json.decode(response.body)); +// //var data = Suggestion.fromJson(json.decode(response.data)); +// var data = Suggestion.fromJson(json.decode(response.data)); +// List suggestion = []; +// data.suggestions.forEach((k) { +// //print('=====>${k.value}'); +// suggestion.add(k.value); +// }); +// +// return Future.delayed(Duration(seconds:2), () { +// return suggestion; +// }); +// //return suggestion; +// } +//} class Api { /// 关键字提示(起点) Future> suggestion(String query) async { // http.Response response = await http.get( // "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query"); /// var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {}); - var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query"); + var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter"); var document = parse(response.data); var app = document.querySelectorAll('.res-title a'); - print('1=====>${query}'); - print('2=====>${response.data}'); - print('3=====>${app}'); - //var data = Suggestion.fromJson(json.decode(response.body)); - //var data = Suggestion.fromJson(json.decode(response.data)); + ///print('1=====>${query}'); + ///print('2=====>${response.data}'); + ////print('3=====>${app}'); List res = []; app.forEach((f) { - print('f==>${f}'); + ///print('f==>${f}'); res.add( SearchResult( title: f.text, diff --git a/lib/blocs/industry_bloc.dart b/lib/blocs/industry_bloc.dart index fd1addb6..3bcd464c 100644 --- a/lib/blocs/industry_bloc.dart +++ b/lib/blocs/industry_bloc.dart @@ -15,19 +15,27 @@ import './industry_state.dart'; class SuggestionBloc extends Bloc { @override SuggestionState get initialState => SuggestionUninitialized(); - @override Stream mapEventToState(SuggestionEvent event)async* { //Stream mapEventToState(SuggestionState currentState, SuggestionEvent event,) async* { if (event is SuggestionFetch) { - print('event==>${event.query}'); + //print('event==>${event}'); try { yield SuggestionLoading(); final res = await api.suggestion(event.query); + print('res====>${res}'); yield SuggestionLoaded(res: res); } catch (_) { yield SuggestionError(); } } + if (event is SuggestionClearFetch) { + //print('event==>${event}'); + try { + yield SuggestionUninitialized(); + } catch (_) { + yield SuggestionError(); + } + } } } diff --git a/lib/blocs/industry_event.dart b/lib/blocs/industry_event.dart index c7aad05e..641720b2 100644 --- a/lib/blocs/industry_event.dart +++ b/lib/blocs/industry_event.dart @@ -14,4 +14,13 @@ class SuggestionFetch extends SuggestionEvent { @override String toString() => 'SuggestionFetch:获取关键字提示事件'; +} + +class SuggestionClearFetch extends SuggestionEvent { + final String query; + + SuggestionClearFetch({this.query}); + + @override + String toString() => 'SuggestionClearFetch:清空界面'; } \ No newline at end of file diff --git a/lib/blocs/industry_main.dart b/lib/blocs/industry_main.dart index 88dd6d55..22dfbc0a 100644 --- a/lib/blocs/industry_main.dart +++ b/lib/blocs/industry_main.dart @@ -6,52 +6,40 @@ * email: zhu.yan@alibaba-inc.com */ import 'package:flutter/material.dart'; -//import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import './industry_bloc.dart'; import './industry_event.dart'; import './industry_state.dart'; -//class Industry extends StatelessWidget { -// @override -// Widget build(BuildContext context) { -// return MaterialApp( -// title: '关键字提示', -// home: Scaffold( -// appBar: AppBar( -// title: Text('关键字提示'), -// ), -// body: AppHome(), -// ), -// ); -// } -//} +final SuggestionBloc suggestion = SuggestionBloc(); class IndustryPage extends StatefulWidget { + final Function itemTitle; + IndustryPage({Key key,this.itemTitle}) : super(key: key); + @override _IndustryState createState() => _IndustryState(); } class _IndustryState extends State { - final SuggestionBloc _suggestion = SuggestionBloc(); - @override Widget build(BuildContext context) { return Material( child: Column( children: [ - TextField( - autofocus: true, - textAlign: TextAlign.center, - onSubmitted: (text) { - _suggestion.dispatch(SuggestionFetch(query: text)); - }, - ), +// TextField( +// autofocus: true, +// textAlign: TextAlign.center, +// onSubmitted: (text) { +// print('onSubmitted:${text}'); +// suggestion.dispatch(SuggestionFetch(query: text)); +// }, +// ), Expanded( child: BlocBuilder( - bloc: _suggestion, + bloc: suggestion, builder: (BuildContext context, SuggestionState state) { - print('-------${state}'); + print('BlocBuilder----${state}'); if (state is SuggestionUninitialized) { return Center( child: Text('暂无内容'), @@ -65,34 +53,15 @@ class _IndustryState extends State { child: Text('出现错误'), ); } else if (state is SuggestionLoaded) { -// return ListView.builder( -// itemBuilder: (BuildContext context, int index) { -// //return ListTile(title: Text(state.res[index])); -// return null; -// }, -// itemCount: state.res.length, -// ); - return ListView.builder( - itemBuilder: (BuildContext context, int index) { - return ListTile( - dense: true, - leading: Icon( - Icons.bookmark_border, - size: 32, - ), - title: Text( - state.res[index].title, - overflow: TextOverflow.ellipsis, - ), - subtitle: Text(state.res[index].source), - onTap: () { - // 在这里对选中的结果进行解析,因为我目前是用golang实现的,所以就没贴代码了。 - print(state.res[index].source); - }, - ); - }, - itemCount: state.res.length, - ); + if (state.res.length == 0) { + return Center( + child: Text('没有适合的结果,更换查询条件试试'), + ); + }else { + if (widget.itemTitle is Function) { + return widget.itemTitle(state); + } + } } }, ), @@ -104,7 +73,7 @@ class _IndustryState extends State { @override void dispose() { - _suggestion.dispose(); + //suggestion.dispose();//添加这个第二次进入会失灵 super.dispose(); } } \ No newline at end of file diff --git a/lib/blocs/industry_state.dart b/lib/blocs/industry_state.dart index c3061318..b129830c 100644 --- a/lib/blocs/industry_state.dart +++ b/lib/blocs/industry_state.dart @@ -31,4 +31,4 @@ class SuggestionLoaded extends SuggestionState { @override String toString() => 'SuggestionLoaded:加载完毕'; -} \ No newline at end of file +} diff --git a/lib/components/home_banner.dart b/lib/components/home_banner.dart index 5dd335fd..36345cbe 100644 --- a/lib/components/home_banner.dart +++ b/lib/components/home_banner.dart @@ -42,6 +42,18 @@ class _BannerState extends State { timer.cancel(); } + /// pagination 的计数器 + Widget _numberIndicator(BuildContext context, int index, int itemCount) { + return Container( + decoration: BoxDecoration( + color: Colors.black45, borderRadius: BorderRadius.circular(20.0)), + margin: EdgeInsets.only(top: 10.0, right: 5.0), + padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 2.0), + child: Text("${++index}/$itemCount", + style: TextStyle( color: Colors.white70, fontSize: 12.0, fontWeight:FontWeight.bold )), + ); + } + @override Widget build(BuildContext context) { return Container( @@ -54,6 +66,11 @@ class _BannerState extends State { onPageChanged: _onPageChanged, children: _buildItems(),), _buildIndicator(), // 下面的小点 + Positioned(//方法二 + top: 0.0, + right: 0.0, + child: _numberIndicator(context,virtualIndex,widget.bannerStories.length), + ) ]), ); } diff --git a/lib/main.dart b/lib/main.dart index f83e2133..5c6a8c1f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,7 +6,7 @@ import 'routers/application.dart'; import 'package:flutter_go/utils/provider.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; -import 'package:flutter_go/views/first_page/home.dart'; +import 'package:flutter_go/views/home.dart'; import 'package:flutter_go/model/search_history.dart'; import 'package:flutter_go/utils/analytics.dart' as Analytics; //import 'views/welcome_page/index.dart'; @@ -53,6 +53,7 @@ class MyApp extends StatelessWidget { home: new Scaffold( body: showWelcomePage() ), + debugShowCheckedModeBanner: false, onGenerateRoute: Application.router.generator, navigatorObservers: [Analytics.observer], ); diff --git a/lib/routers/router_handler.dart b/lib/routers/router_handler.dart index 01519cd5..6105301c 100644 --- a/lib/routers/router_handler.dart +++ b/lib/routers/router_handler.dart @@ -5,7 +5,7 @@ import 'package:flutter_go/components/category.dart'; import '../widgets/404.dart'; import 'package:flutter_go/components/full_screen_code_dialog.dart'; import 'package:flutter_go/views/web_page/web_view_page.dart'; -import 'package:flutter_go/views/first_page/home.dart'; +import 'package:flutter_go/views/home.dart'; // app的首页 var homeHandler = new Handler( diff --git a/lib/views/first_page/first_page.dart b/lib/views/first_page/first_page.dart index e121390f..1fded132 100644 --- a/lib/views/first_page/first_page.dart +++ b/lib/views/first_page/first_page.dart @@ -40,8 +40,8 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 _unKnow.then((bool value) { new Future.delayed(const Duration(seconds: 1),(){ - if (!value) { - key.currentState.showAlertDialog(context); + if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { + key.currentState.showAlertDialog(context); } }); }); @@ -80,8 +80,8 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin return result; } + /// 每个item的样式 Widget makeCard(index,item){ - var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; @@ -92,18 +92,18 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin return Column( children: [ - Stack( - //alignment: const FractionalOffset(0.9, 0.1),//方法一 - children: [ - Pagination(), - Positioned(//方法二 - top: 10.0, - left: 0.0, - child: DisclaimerMsg(key:key,pWidget:this) - ), - ]), - SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), - SizedBox(height: 10), + Stack( + //alignment: const FractionalOffset(0.9, 0.1),//方法一 + children: [ + Pagination(), + Positioned(//方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key:key,pWidget:this) + ), + ]), + SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), + SizedBox(height: 10), ], ); diff --git a/lib/views/first_page/main_page.dart b/lib/views/first_page/main_page.dart index 53613754..43383a85 100644 --- a/lib/views/first_page/main_page.dart +++ b/lib/views/first_page/main_page.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -//import 'package:flutter_wanandroid/common/component_index.dart'; -//import 'package:flutter_wanandroid/ui/pages/main_left_page.dart'; -//import 'package:flutter_wanandroid/ui/pages/page_index.dart'; - +import 'package:flutter/cupertino.dart'; +import './first_page.dart'; +import './sub_page.dart'; import './main_app_bar.dart'; +import './search_page.dart'; class _Page { final String labelId; @@ -12,10 +12,10 @@ class _Page { } final List<_Page> _allPages = <_Page>[ - _Page('titleHome'), - _Page('titleHome'), - _Page('titleHome'), - _Page('titleHome'), + _Page('项目1'), + _Page('项目2'), + _Page('项目3'), + _Page('项目4'), ]; class MainPage extends StatelessWidget { @@ -40,10 +40,7 @@ class MainPage extends StatelessWidget { IconButton( icon: Icon(Icons.search), onPressed: () { - /// NavigatorUtil.pushPage(context, SearchPage(), - ///pageName: "SearchPage"); - // NavigatorUtil.pushPage(context, TestPage()); - // NavigatorUtil.pushPage(context, DemoApp()); + pushPage(context, SearchPage(), pageName: "SearchPage"); }) ], ), @@ -55,12 +52,18 @@ class MainPage extends StatelessWidget { } } +void pushPage(BuildContext context, Widget page, {String pageName}) { + if (context == null || page == null) return; + Navigator.push(context, CupertinoPageRoute(builder: (ctx) => page)); +} + class TabLayout extends StatelessWidget { @override Widget build(BuildContext context) { return TabBar( isScrollable: true, - labelPadding: EdgeInsets.all(12.0), + //labelPadding: EdgeInsets.all(12.0), + labelPadding: EdgeInsets.only(top: 12.0,left: 12.0,right:12.0), indicatorSize: TabBarIndicatorSize.label, tabs: _allPages .map((_Page page) => @@ -73,38 +76,29 @@ class TabLayout extends StatelessWidget { class TabBarViewLayout extends StatelessWidget { Widget buildTabView(BuildContext context, _Page page) { String labelId = page.labelId; -// switch (labelId) { -// case Ids.titleHome: -// //return HomePage(labelId: labelId); -// return ReposPage(labelId: labelId); -// break; -// case Ids.titleRepos: -// return ReposPage(labelId: labelId); -// break; -// case Ids.titleEvents: -// return EventsPage(labelId: labelId); -// break; -// case Ids.titleSystem: -// return SystemPage(labelId: labelId); -// break; -// default: -// return Container(); -// break; -// } - return Container( - child: new ClipOval( - child: Image.network( - 'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658', - scale: 5.0, - ), - ) - ); + switch (labelId) { + case '项目1': + return FirstPage(); + break; + case '项目2': + return SubPage(); + break; + case '项目3': + return SubPage(); + break; + case '项目4': + return SubPage(); + break; + default: + return Container(); + break; + } } @override Widget build(BuildContext context) { print("TabBarViewLayout build......."); - return TabBarView( + return TabBarView( children: _allPages.map((_Page page) { return buildTabView(context, page); }).toList()); diff --git a/lib/views/first_page/search_page.dart b/lib/views/first_page/search_page.dart new file mode 100644 index 00000000..130b550a --- /dev/null +++ b/lib/views/first_page/search_page.dart @@ -0,0 +1,189 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter/cupertino.dart'; +import 'dart:ui'; +import 'dart:async'; +import 'package:flutter_go/blocs/industry_main.dart' as Industry; +import 'package:flutter_go/blocs/industry_event.dart'; +import 'package:flutter_go/routers/application.dart'; +import 'package:flutter_go/routers/routers.dart'; + +final _industryPage = Industry.IndustryPage(itemTitle: (state){ + return ListView.builder( + itemBuilder: (BuildContext context, int index) { + return ListTile( + dense: true, + leading: Icon( + Icons.bookmark_border, + size: 32, + ), + title: Text( + state.res[index].title, + overflow: TextOverflow.ellipsis, + ), + subtitle: Text(state.res[index].source), + onTap: () { + // 在这里对选中的结果进行解析,因为我目前是用golang实现的,所以就没贴代码了。 + print(state.res[index].source); + final itemTitle = state.res[index].title; + final itemUrl = state.res[index].source; + Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); + }, + ); + }, + itemCount: state.res.length, + ); +}); + +final suggestion = Industry.suggestion; +final searchBarPage = SearchBarPage(); + +class SearchPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + /// print('suggestion::${Industry.suggestion}'); + return Scaffold( + appBar: PreferredSize( + preferredSize: Size(double.infinity, 52), // 44 is the height + child: AppBar(title: searchBarPage) + ), + //body: ProgressView(), + body: _industryPage, + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.search), + onPressed: () { + //print('searchBarPage=====>${controller.text}'); + //print('searchBarPage=====>${that.getResultsDebounced}'); + if(that is _SearchBarPageState && that.getResultsDebounced is Function && controller.text is String ) { + that.getResultsDebounced(controller.text); + } + }, + ), + ); + } +} + +/// 加载loading +class ProgressView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Center( + child: SizedBox( + width: 24.0, + height: 24.0, + child: CircularProgressIndicator( + strokeWidth: 2.0, + ), + ), + ); + } +} + +class SearchBarPage extends StatefulWidget{ + @override + State createState() => _SearchBarPageState(); +} + + +final TextEditingController controller = TextEditingController(); +var that; +class _SearchBarPageState extends State { + @override + void initState() { + super.initState(); + that = this; + } + + Timer _resultsTimer; + bool _loading = false; + String oldKey; + /// 防抖函数 + Future getResultsDebounced(String text) async { + if(oldKey == text){ + print('请求内容重复'); + return; + } + if (text == '' || !mounted) { + return; + } + _loading = true; + if (_resultsTimer != null && _resultsTimer.isActive) { + _resultsTimer.cancel(); + } + _resultsTimer = new Timer(new Duration(milliseconds: 400), () async { + _loading = true; + if(mounted){ + suggestion.dispatch(SuggestionFetch(query: text)); + } + oldKey = text; + }); + } + + + void onSearchTextChanged(String text){ + print('onSearchTextChanged:${text}'); + //suggestion.dispatch(SuggestionFetch(query: text)); + getResultsDebounced(text); + } + + @override + void dispose() { + print('dispose'); + suggestion.dispatch(SuggestionClearFetch()); + controller.dispose(); + super.dispose(); + } + + + Widget build(BuildContext context) { + return Container( + color: Theme.of(context).primaryColor, + //color: Colors.amber, + child: Padding( + //padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top,), + padding: EdgeInsets.all(0.0), + child: Container( + //height: 162.0, + child: Padding( + padding: const EdgeInsets.all(6.0), + child: Card( + child: Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 5.0,), + Icon(Icons.search, color: Colors.grey,size: 18.0,), + Expanded( + child: Container( + alignment: Alignment.center, + child: TextField( + controller: controller, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(top: 0.0), + hintText: '搜索全局flutter知识库', + hintStyle:TextStyle(fontSize: 12.0), + border: InputBorder.none + ), + onChanged: onSearchTextChanged, + ), + ), + ), + IconButton( + icon: Icon(Icons.cancel), + color: Colors.grey, + iconSize: 18.0, + onPressed: () { + controller.clear(); + // onSearchTextChanged(''); + }, + ), + ], + ), + ) + ) + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/views/first_page/sub_page.dart b/lib/views/first_page/sub_page.dart new file mode 100644 index 00000000..387b55bf --- /dev/null +++ b/lib/views/first_page/sub_page.dart @@ -0,0 +1,125 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'package:flutter_go/components/list_view_item.dart'; +import 'package:flutter_go/components/list_refresh.dart' as listComp; +import 'package:flutter_go/components/pagination.dart'; +import 'package:flutter_go/views/first_page/first_page_item.dart'; +import 'package:flutter_go/components/disclaimer_msg.dart'; +import 'package:flutter_go/utils/net_utils.dart'; + +// ValueKey key; + +class SubPage extends StatefulWidget { + @override + SubPageState createState() => SubPageState(); +} + +class SubPageState extends State with AutomaticKeepAliveClientMixin{ + Future _prefs = SharedPreferences.getInstance(); + Future _unKnow; + GlobalKey key; + + @override + bool get wantKeepAlive => true; + + + @override + void initState() { + super.initState(); + if (key == null) { + key = GlobalKey(); + // key = const Key('__RIKEY1__'); + //获取sharePre + _unKnow = _prefs.then((SharedPreferences prefs) { + return (prefs.getBool('disclaimer::Boolean') ?? false); + }); + + /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 + _unKnow.then((bool value) { + new Future.delayed(const Duration(seconds: 1),(){ + if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { + key.currentState.showAlertDialog(context); + } + }); + }); + } + } + + + Future getIndexListData([Map params]) async { + const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; + var pageIndex = (params is Map) ? params['pageIndex'] : 0; + final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'}; + var responseList = []; + var pageTotal = 0; + + try{ + var response = await NetUtils.get(juejin_flutter, params: _param); + responseList = response['d']['entrylist']; + pageTotal = response['d']['total']; + if (!(pageTotal is int) || pageTotal <= 0) { + pageTotal = 0; + } + }catch(e){ + + } + pageIndex += 1; + List resultList = new List(); + for (int i = 0; i < responseList.length; i++) { + try { + FirstPageItem cellData = new FirstPageItem.fromJson(responseList[i]); + resultList.add(cellData); + } catch (e) { + // No specified type, handles all + } + } + Map result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex}; + return result; + } + + Widget makeCard(index,item){ + + var myTitle = '${item.title}'; + var myUsername = '${'👲'}: ${item.username} '; + var codeUrl = '${item.detailUrl}'; + return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); + } + + headerView(){ + return + Column( + children: [ + Stack( + //alignment: const FractionalOffset(0.9, 0.1),//方法一 + children: [ + Pagination(), + Positioned(//方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key:key,pWidget:this) + ), + ]), + SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), + SizedBox(height: 10), + ], + ); + + } + + @override + Widget build(BuildContext context) { + super.build(context); + return new Column( + children: [ + new Expanded( + child: listComp.ListRefresh(getIndexListData,makeCard) + ) + ] + ); + } +} + + diff --git a/lib/views/first_page/home.dart b/lib/views/home.dart similarity index 93% rename from lib/views/first_page/home.dart rename to lib/views/home.dart index c2185cd3..63b22aeb 100644 --- a/lib/views/first_page/home.dart +++ b/lib/views/home.dart @@ -22,10 +22,7 @@ import 'package:flutter_go/components/search_input.dart'; import 'package:flutter_go/model/search_history.dart'; import 'package:flutter_go/resources/widget_name_to_icon.dart'; -import 'package:flutter_go/blocs/industry_main.dart'; -//import 'package:flutter_go/blocs/search_widget.dart'; - -import 'main_page.dart'; +import './first_page/main_page.dart'; @@ -99,12 +96,14 @@ class _MyHomePageState extends State }); searchHistoryList .add(SearchHistory(name: targetName, targetRouter: targetRouter)); - print("searchHistoryList ${searchHistoryList.toString()}"); + print("searchHistoryList1 ${searchHistoryList.toString()}"); + print("searchHistoryList2 ${targetRouter}"); + print("searchHistoryList3 ${widgetPoint.name}"); Application.router.navigateTo(context, "$targetRouter"); } Widget buildSearchInput(BuildContext context) { - return new SearchInput((value) async { + return new SearchInput((value) async { if (value != '') { List list = await widgetControl.search(value); @@ -114,7 +113,7 @@ class _MyHomePageState extends State icon: WidgetName2Icon.icons[item.name] ?? null, text: 'widget', onTap: () { - onWidgetTap(item, context); + onWidgetTap(item, context); }, )) .toList(); @@ -140,8 +139,6 @@ class _MyHomePageState extends State appBar: renderAppBar(context,widget), body: new TabBarView(controller: controller, children: [ //new FirstPage(), - //new IndustryPage(), - //new SearchWidget(), MainPage(), WidgetPage(db), CollectionPage(), diff --git a/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart b/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart index fa2f6d26..5e5d9eaf 100644 --- a/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart +++ b/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart @@ -20,8 +20,8 @@ class _FlexibleSpaceBarFullDefault extends State { @override Widget build(BuildContext context) { return FlexibleSpaceBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -30,8 +30,7 @@ class FlexibleSpaceBarLessDefault extends StatelessWidget { final widget; final parent; - const FlexibleSpaceBarLessDefault([this.widget, this.parent]) - : super(); + const FlexibleSpaceBarLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { @@ -39,7 +38,8 @@ class FlexibleSpaceBarLessDefault extends StatelessWidget { height: 300.0, child: Scaffold( body: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( expandedHeight: 150.0, @@ -55,6 +55,13 @@ class FlexibleSpaceBarLessDefault extends StatelessWidget { background: Image.network( "https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350", fit: BoxFit.cover, + + /// 色彩叠加 UI可以理解为两个色彩涂层,在图片混合一个色层 + // color: Colors.redAccent, //混合的颜色 + // colorBlendMode: BlendMode.darken, //混合方式 + + ///图片重复填充容器 + // repeat: ImageRepeat.repeat, )), ), ]; @@ -63,6 +70,6 @@ class FlexibleSpaceBarLessDefault extends StatelessWidget { child: Text("向上提拉 ⬆ 查看效果..."), ), ), - ) - ); -}} \ No newline at end of file + )); + } +} diff --git a/lib/widgets/components/Grid/GridView/demo.dart b/lib/widgets/components/Grid/GridView/demo.dart index a7bbeb16..6246c433 100644 --- a/lib/widgets/components/Grid/GridView/demo.dart +++ b/lib/widgets/components/Grid/GridView/demo.dart @@ -13,7 +13,6 @@ class GridTileDemo extends StatefulWidget { class _Demo extends State { - Widget build(BuildContext context) { return Container( height: 400, @@ -55,3 +54,34 @@ class _Demo extends State { ); } } + + +class GridViewDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + height: 200, + color: Color(0xffc91b3a), + child: GridView( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + ///列数 + crossAxisCount: 3, + ///列间距 + mainAxisSpacing: 10.0, + ///横轴距离 + crossAxisSpacing: 4.0, + ///缩放比例 + childAspectRatio: 1.3,), + padding: const EdgeInsets.only(left: 10,right: 10,top: 10), + children: [ + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), + ],), + ); + } + +} \ No newline at end of file diff --git a/lib/widgets/components/Grid/GridView/index.dart b/lib/widgets/components/Grid/GridView/index.dart index 0f8beb0d..d00925e9 100644 --- a/lib/widgets/components/Grid/GridView/index.dart +++ b/lib/widgets/components/Grid/GridView/index.dart @@ -49,6 +49,13 @@ const String _Text0 = """ - GridView.extent """; +const Text1=""" +### +> SliverGridDelegateWithFixedCrossAxisCount + +gridDelegate: SliverGridDelegateWithFixedCrossAxisCount,实现网格 +"""; + class Demo extends StatefulWidget { @@ -68,8 +75,10 @@ class _DemoState extends State { _Text0, GridTileDemo(), SizedBox( - height: 100.0, - ) + height: 10.0, + ), + Text1, + GridViewDemo(), ], docUrl: 'https://docs.flutter.io/flutter/material/GridView-class.html', ); diff --git a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart index bf4bf0fd..86da89f3 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -19,8 +19,10 @@ class DecoratedBoxCreate extends StatelessWidget { decoration: BoxDecoration( color: const Color(0xff7c94b6), //设置图片内容 - image: DecorationImage( - fit: BoxFit.cover, + image: DecorationImage( + ///fix:BoxFit.contain: 保持图片的比例,最大程度填充容器 BoxFit.fill:容器被图片完全填充,不在意图片比例,只填充整个容器 + ///fix:BoxFit.fitWidth:图片以宽被完全填充 BoxFit.fix:fixHigth:图片以高度完全填充 + fit: BoxFit.cover, //图片填充整个容器,按比例放大,多余部分被裁切 image: ExactAssetImage('assets/images/food01.jpeg')), //外宽边框,可以不设置 border: Border.all( @@ -44,7 +46,7 @@ class DecoratedBoxCreateTwo extends StatelessWidget { decoration: BoxDecoration( color: const Color(0xff7c94b6), //设置图片内容 - image: DecorationImage( + image: DecorationImage( fit: BoxFit.cover, image: ExactAssetImage('assets/images/food01.jpeg')), //根据传入的不同大小,呈现图片效弧度不同, @@ -65,7 +67,7 @@ class DecoratedBoxCreateShape extends StatelessWidget { position: DecorationPosition.background, decoration: BoxDecoration( color: const Color(0xff7c94b6), - image: DecorationImage( + image: DecorationImage( fit: BoxFit.cover, image: ExactAssetImage('assets/images/food01.jpeg')), border: Border.all( @@ -77,3 +79,27 @@ class DecoratedBoxCreateShape extends StatelessWidget { ); } } + +class DecoratedBoxCreateShapes extends StatelessWidget { + DecoratedBoxCreateShapes({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + position: DecorationPosition.background, + decoration: BoxDecoration( + gradient: const LinearGradient( + //渐变效果 线性渐变 + colors: [Colors.red, Colors.yellowAccent, Colors.lightGreenAccent]), +// color: const Color(0xff7c94b6), + border: Border.all( + color: Colors.blue.shade50, + width: 5.0, + ), + shape: BoxShape.circle, + ), + ); + } +} diff --git a/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart b/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart index 66ab7701..a824d9bc 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart @@ -1,7 +1,7 @@ ///Author: xiaojia.dxj -///Date: 2019-01-08 15:56:49 +///Date: 2019-01-08 15:56:49 ///Last Modified by: xiaojia.dxj -///Last Modified time: 2019-01-08 15:56:49 +///Last Modified time: 2019-01-08 15:56:49 ///email: xiaojia.dxj@alibaba-inc.com import 'package:flutter/material.dart'; @@ -46,7 +46,7 @@ class _DemoState extends State { } Column _decoratedBoxCreate() { - return Column( + return Column( children: [ Container( height: 100.0, @@ -68,6 +68,14 @@ class _DemoState extends State { height: 100.0, width: 100.0, child: DecoratedBoxCreateShape(), + ), + SizedBox( + height: 10.0, + ), + Container( + height: 100.0, + width: 100.0, + child: DecoratedBoxCreateShapes(), ) ], ); diff --git a/lib/widgets/elements/Frame/Layout/Row/demo.dart b/lib/widgets/elements/Frame/Layout/Row/demo.dart index 2c372d83..7e26823b 100644 --- a/lib/widgets/elements/Frame/Layout/Row/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Row/demo.dart @@ -1,4 +1,5 @@ - /// Author: xiaojia.dxj + import 'package:flutter/material.dart'; +/// Author: xiaojia.dxj /// Date: 2018/11/22 /// Email: xiaojia.dxj@alibaba-inc.com /// LastUpdateTime: 2018/11/22 @@ -92,3 +93,34 @@ class RowLayoutCreate extends StatelessWidget { ); } } + +class RowExpanded extends StatelessWidget{ + @override + Widget build(BuildContext context) { + + return Row( + children: [ + ////填充数据 + Expanded(child: new RaisedButton( + onPressed: (){ + }, + color: Color(0xfffce4ec), + child:new Text('flutter',style: TextStyle(color: Colors.white),) + ),), + Expanded(child: new RaisedButton( + onPressed: (){ + }, + color: Color(0xfff8bbd0), + child:new Text('Expanded',style: TextStyle(color: Colors.white),) + ),), + Expanded(child: new RaisedButton( + onPressed: (){ + }, + color: Color(0xfff48fb1), + child:new Text('flutter',style: TextStyle(color: Colors.white),) + ),), + ], + ); + } + +} diff --git a/lib/widgets/elements/Frame/Layout/Row/index.dart b/lib/widgets/elements/Frame/Layout/Row/index.dart index fa8e7b34..4ebb6f8f 100644 --- a/lib/widgets/elements/Frame/Layout/Row/index.dart +++ b/lib/widgets/elements/Frame/Layout/Row/index.dart @@ -60,6 +60,8 @@ class _DemoState extends State { return Column( children: [ RowLayoutCreate(), + SizedBox(height: 10.0,), + RowExpanded(), Row( children: [ Expanded( diff --git a/pubspec.lock b/pubspec.lock index a62c6a84..9e9bcdd5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,105 +5,91 @@ packages: dependency: transitive description: name: args - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.5.1" async: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - bloc: - dependency: "direct main" - description: - name: bloc - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.12.0" + version: "2.2.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.4" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.2" city_pickers: dependency: "direct main" description: name: city_pickers - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.1.16" + version: "0.0.4" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.14.11" cookie_jar: dependency: transitive description: name: cookie_jar - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.0.8" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.2" dio: dependency: "direct main" description: name: dio - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.17" event_bus: dependency: "direct main" description: name: event_bus - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" firebase_analytics: dependency: "direct main" description: name: firebase_analytics - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1+3" + version: "1.2.0+1" firebase_core: dependency: "direct main" description: name: firebase_core - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.3.4" fluro: dependency: "direct main" description: name: fluro - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.4.0" flutter: @@ -111,18 +97,11 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_bloc: - dependency: "direct main" - description: - name: flutter_bloc - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.11.1" flutter_markdown: dependency: "direct main" description: name: flutter_markdown - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.2.0" flutter_test: @@ -134,91 +113,77 @@ packages: dependency: "direct main" description: name: flutter_webview_plugin - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.3.4" - html: - dependency: "direct main" - description: - name: html - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.14.0+2" image_picker: dependency: "direct main" description: name: image_picker - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.4.12+1" + version: "0.6.0+1" intl: dependency: "direct main" description: name: intl - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.15.7" lpinyin: dependency: transitive description: name: lpinyin - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.7" markdown: dependency: transitive description: name: markdown - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.3" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.3+1" + version: "0.12.5" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.6" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.6.2" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" quiver: dependency: transitive description: name: quiver - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" - rxdart: - dependency: transitive - description: - name: rxdart - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.21.0" + version: "2.0.3" shared_preferences: dependency: "direct main" description: name: shared_preferences - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.4.3" sky_engine: @@ -230,79 +195,79 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.5.4" + version: "1.5.5" sqflite: dependency: "direct main" description: name: sqflite - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.2+1" + version: "1.1.5" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.9.3" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.0.4" synchronized: dependency: transitive description: name: synchronized - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.2" + version: "0.2.5" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.6" url_launcher: dependency: "direct main" description: name: url_launcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "4.2.0+3" + version: "5.0.2" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.0.8" sdks: - dart: ">=2.1.0 <3.0.0" - flutter: ">=0.5.6 <2.0.0" + dart: ">=2.2.0 <3.0.0" + flutter: ">=1.2.1 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ec8cb834..4e6e268e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,23 +21,20 @@ dependencies: cupertino_icons: ^0.1.2 event_bus: ^1.0.1 fluro: ^1.3.4 - image_picker: ^0.4.10 - sqflite: ^0.12.1 + image_picker: ^0.6.0+1 + sqflite: ^1.1.5 flutter_markdown: ^0.2.0 - url_launcher: ^4.0.1 + url_launcher: ^5.0.2 # 本地存储、收藏功能 shared_preferences: ^0.4.3 dio: ^1.0.6 - flutter_webview_plugin: ^0.3.0+2 + flutter_webview_plugin: ^0.3.4 # 日期格式化 intl: 0.15.7 - city_pickers: ^0.1.0 - firebase_analytics: ^2.0.2+1 + city_pickers: ^0.0.1 + firebase_analytics: ^1.1.0 #firebase_auth: ^0.8.3 #auth - firebase_core: ^0.3.0 # add dependency for Firebase Core - flutter_bloc: ^0.11.1 - bloc: ^0.12.0 - html: ^0.14.0+2 + firebase_core: ^0.3.4 # add dependency for Firebase Core dev_dependencies: flutter_test: