From 196b7a54cdc98480c07b71d0e68480bd2242541e Mon Sep 17 00:00:00 2001 From: fmtjava <2694746499@qq.com> Date: Mon, 27 Dec 2021 17:25:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5FlutterBoost=E7=AE=80?= =?UTF-8?q?=E5=8C=96Native=E4=B8=8EFlutter=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 13 +- .../java/com/fmt/github/data/http/Retrofit.kt | 4 +- app/src/main/res/layout/layout_repos.xml | 20 +- .../lib/widget/follow_page_item.dart | 54 ++--- .../lib/widget/trend_page_item.dart | 194 +++++++++--------- 5 files changed, 147 insertions(+), 138 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 220063f..f956d1e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,19 +20,18 @@ aspectjx { exclude 'module-info', 'kotlinx.coroutines', 'androidx.paging', 'com.lxj.xpopup', 'com.just.agentweb' } -//kapt { -// generateStubs = true -//} - android { compileSdkVersion 29 defaultConfig { applicationId "com.fmt.github" minSdkVersion 21 targetSdkVersion 29 - versionCode 13 - versionName "2.8" + versionCode 14 + versionName "3.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + ndk { + abiFilters 'arm64-v8a' + } } signingConfigs { release { @@ -134,7 +133,7 @@ dependencies { //okhttp + retrofit(2.6.0以后支持协程) implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2") implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.retrofit2:converter-gson:2.9.0' + implementation 'com.squareup.retrofit2:converter-moshi:2.9.0' //协程 + room implementation "androidx.room:room-runtime:2.3.0" diff --git a/app/src/main/java/com/fmt/github/data/http/Retrofit.kt b/app/src/main/java/com/fmt/github/data/http/Retrofit.kt index 0c7894f..07c0eb2 100644 --- a/app/src/main/java/com/fmt/github/data/http/Retrofit.kt +++ b/app/src/main/java/com/fmt/github/data/http/Retrofit.kt @@ -9,7 +9,7 @@ import com.fmt.github.user.api.UserApi import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory +import retrofit2.converter.moshi.MoshiConverterFactory import java.util.concurrent.TimeUnit private const val BASE_URL = "https://api.github.com/" @@ -35,7 +35,7 @@ val okHttpClient = OkHttpClient.Builder() }.build() val retrofit: Retrofit = Retrofit.Builder() - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(MoshiConverterFactory.create()) .client(okHttpClient) .baseUrl(BASE_URL) .build() diff --git a/app/src/main/res/layout/layout_repos.xml b/app/src/main/res/layout/layout_repos.xml index 3398468..cbc276a 100644 --- a/app/src/main/res/layout/layout_repos.xml +++ b/app/src/main/res/layout/layout_repos.xml @@ -97,44 +97,50 @@ diff --git a/flutter_module/lib/widget/follow_page_item.dart b/flutter_module/lib/widget/follow_page_item.dart index 5b2516a..c7e5651 100644 --- a/flutter_module/lib/widget/follow_page_item.dart +++ b/flutter_module/lib/widget/follow_page_item.dart @@ -14,35 +14,37 @@ class FollowPageItem extends StatelessWidget { Widget build(BuildContext context) { return Card( margin: EdgeInsets.fromLTRB(8, 8, 8, 4), - child: InkWell( - child: Padding( - padding: EdgeInsets.all(15), - child: Row( - children: [ - ClipOval( - child: CachedNetworkImage( - imageUrl: followModel.avatarUrl, - height: 40, - width: 40, - fit: BoxFit.cover), - ), - Padding( - padding: EdgeInsets.only(left: 10), - child: Text( - followModel.login, - style: TextStyle( - color: DColor.themeColor, - fontSize: 18, - fontWeight: FontWeight.bold), + child: Material( + child: InkWell( + child: Padding( + padding: EdgeInsets.all(15), + child: Row( + children: [ + ClipOval( + child: CachedNetworkImage( + imageUrl: followModel.avatarUrl, + height: 40, + width: 40, + fit: BoxFit.cover), ), - ) - ], + Padding( + padding: EdgeInsets.only(left: 10), + child: Text( + followModel.login, + style: TextStyle( + color: DColor.themeColor, + fontSize: 18, + fontWeight: FontWeight.bold), + ), + ) + ], + ), ), + onTap: () => NavigationUtil.push(USER_INFO_PAGE, arguments: { + "user_name": followModel.login, + "user_avatar": followModel.avatarUrl, + }), ), - onTap: ()=>NavigationUtil.push(USER_INFO_PAGE, arguments: { - "user_name": followModel.login, - "user_avatar": followModel.avatarUrl, - }), ), ); } diff --git a/flutter_module/lib/widget/trend_page_item.dart b/flutter_module/lib/widget/trend_page_item.dart index 8bad002..4e0a940 100644 --- a/flutter_module/lib/widget/trend_page_item.dart +++ b/flutter_module/lib/widget/trend_page_item.dart @@ -14,111 +14,113 @@ class TrendPageItem extends StatelessWidget { Widget build(BuildContext context) { return Card( margin: EdgeInsets.fromLTRB(8, 8, 8, 4), - child: InkWell( - onTap: () => NavigationUtil.push(REPOS_DETAIL_PAGE, arguments: { - "web_url": trendModel.url, - "owner": trendModel.name, - "repo": trendModel.reposName - }), - child: Padding( - padding: EdgeInsets.all(8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ClipOval( - child: CachedNetworkImage( - imageUrl: trendModel.contributorsUrl, - height: 40, - width: 40, - fit: BoxFit.cover), - ), - Expanded( - child: Padding( - padding: EdgeInsets.only(left: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - trendModel.reposName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: DColor.themeColor, - fontSize: 16, - fontWeight: FontWeight.bold), - )), - Container( - margin: EdgeInsets.only(left: 10), - child: Text( - trendModel.language, - style: TextStyle( - color: DColor.desTextColor, fontSize: 12), - ), - ) - ], - ), - Text( - trendModel.description, - style: - TextStyle(color: DColor.desTextColor, fontSize: 14), - ), - Padding( - padding: EdgeInsets.only(top: 4), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: Material( + child: InkWell( + onTap: () => NavigationUtil.push(REPOS_DETAIL_PAGE, arguments: { + "web_url": trendModel.url, + "owner": trendModel.name, + "repo": trendModel.reposName + }), + child: Padding( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipOval( + child: CachedNetworkImage( + imageUrl: trendModel.contributorsUrl, + height: 40, + width: 40, + fit: BoxFit.cover), + ), + Expanded( + child: Padding( + padding: EdgeInsets.only(left: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Icon( - Icons.star_border, - color: DColor.desTextColor, - size: 20, - ), - Text( - trendModel.starCount, - style: TextStyle(color: DColor.desTextColor), + Expanded( + child: Text( + trendModel.reposName, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: DColor.themeColor, + fontSize: 16, + fontWeight: FontWeight.bold), + )), + Container( + margin: EdgeInsets.only(left: 10), + child: Text( + trendModel.language, + style: TextStyle( + color: DColor.desTextColor, fontSize: 12), + ), ) ], ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.device_hub, - color: DColor.desTextColor, - size: 20, - ), - Text( - trendModel.forkCount, - style: TextStyle(color: DColor.desTextColor), - ) - ], + Text( + trendModel.description, + style: + TextStyle(color: DColor.desTextColor, fontSize: 14), ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.remove_red_eye, - color: DColor.desTextColor, - size: 20, - ), - Text( - trendModel.meta, - style: TextStyle(color: DColor.desTextColor), - ) - ], + Padding( + padding: EdgeInsets.only(top: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.star_border, + color: DColor.desTextColor, + size: 20, + ), + Text( + trendModel.starCount, + style: TextStyle(color: DColor.desTextColor), + ) + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.device_hub, + color: DColor.desTextColor, + size: 20, + ), + Text( + trendModel.forkCount, + style: TextStyle(color: DColor.desTextColor), + ) + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.remove_red_eye, + color: DColor.desTextColor, + size: 20, + ), + Text( + trendModel.meta, + style: TextStyle(color: DColor.desTextColor), + ) + ], + ) + ], + ), ) ], ), - ) - ], - ), - )) - ], + )) + ], + ), ), ), ),