Skip to content

Commit

Permalink
接入FlutterBoost简化Native与Flutter交互
Browse files Browse the repository at this point in the history
fmtjava committed Dec 27, 2021
1 parent d5eecff commit 196b7a5
Showing 5 changed files with 147 additions and 138 deletions.
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions app/src/main/java/com/fmt/github/data/http/Retrofit.kt
Original file line number Diff line number Diff line change
@@ -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()
20 changes: 13 additions & 7 deletions app/src/main/res/layout/layout_repos.xml
Original file line number Diff line number Diff line change
@@ -97,44 +97,50 @@

<TextView
android:id="@+id/tv_start_num"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_8"
android:layout_marginStart="@dimen/dp_58"
android:layout_marginTop="@dimen/dp_5"
android:drawableStart="@mipmap/icon_start"
android:drawablePadding="@dimen/dp_5"
android:text="@{String.valueOf(item.stargazers_count)}"
android:textColor="@color/repos_common_text_color"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toRightOf="@id/iv_head"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_fork_num"
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />

<TextView
android:id="@+id/tv_fork_num"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_5"
android:drawableStart="@mipmap/icon_fork"
android:drawablePadding="@dimen/dp_5"
android:text="@{String.valueOf(item.forks)}"
android:textColor="@color/repos_common_text_color"
android:textSize="@dimen/sp_12"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/tv_start_num"
app:layout_constraintRight_toLeftOf="@id/tv_author"
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />

<TextView
android:id="@+id/tv_author"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_5"
android:drawableStart="@mipmap/icon_author"
android:drawablePadding="@dimen/dp_5"
android:text="@{item.owner.login}"
android:textColor="@color/repos_common_text_color"
android:textSize="@dimen/sp_12"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/tv_fork_num"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />


54 changes: 28 additions & 26 deletions flutter_module/lib/widget/follow_page_item.dart
Original file line number Diff line number Diff line change
@@ -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,
}),
),
);
}
194 changes: 98 additions & 96 deletions flutter_module/lib/widget/trend_page_item.dart
Original file line number Diff line number Diff line change
@@ -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: <Widget>[
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: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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: <Widget>[
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: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.star_border,
color: DColor.desTextColor,
size: 20,
),
Text(
trendModel.starCount,
style: TextStyle(color: DColor.desTextColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.device_hub,
color: DColor.desTextColor,
size: 20,
),
Text(
trendModel.forkCount,
style: TextStyle(color: DColor.desTextColor),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.remove_red_eye,
color: DColor.desTextColor,
size: 20,
),
Text(
trendModel.meta,
style: TextStyle(color: DColor.desTextColor),
)
],
)
],
),
)
],
),
)
],
),
))
],
))
],
),
),
),
),

0 comments on commit 196b7a5

Please sign in to comment.