Skip to content

Commit b23a83b

Browse files
committed
增加 history 对接
1 parent 8006dc2 commit b23a83b

File tree

3 files changed

+39
-2
lines changed
  • app/src/main/java/com/shuyu/gsygithubappcompose
  • data/src/main/java/com/shuyu/gsygithubappcompose/data/repository/mapper
  • feature/home/src/main/java/com/shuyu/gsygithubappcompose/feature/home

3 files changed

+39
-2
lines changed

app/src/main/java/com/shuyu/gsygithubappcompose/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import com.shuyu.gsygithubappcompose.feature.info.InfoScreen
3131
import dagger.hilt.android.AndroidEntryPoint
3232
import com.shuyu.gsygithubappcompose.core.common.manager.LanguageManager
3333
import com.shuyu.gsygithubappcompose.core.ui.util.ProvideLocalizedResources
34+
import com.shuyu.gsygithubappcompose.feature.history.HistoryScreen
3435
import jakarta.inject.Inject
3536

3637

@@ -145,6 +146,10 @@ class MainActivity : ComponentActivity() {
145146
composable("info") {
146147
InfoScreen()
147148
}
149+
150+
composable("history") {
151+
HistoryScreen()
152+
}
148153
}
149154
}
150155
}

data/src/main/java/com/shuyu/gsygithubappcompose/data/repository/mapper/DataMappers.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ fun Organization.toUser(): User {
713713
login = login,
714714
id = id,
715715
nodeId = nodeId,
716-
avatarUrl = avatarUrl ?:"",
716+
avatarUrl = avatarUrl ?: "",
717717
gravatarId = null,
718718
url = url,
719719
htmlUrl = null,
@@ -776,5 +776,28 @@ fun RepositoryDetailModel.toHistoryEntity(): HistoryEntity {
776776
}
777777

778778
fun HistoryEntity.toRepositoryModel(): Repository {
779-
return Gson().fromJson(data, Repository::class.java)
779+
val detail = Gson().fromJson(data, RepositoryDetailModel::class.java)
780+
return detail.toRepository()
781+
}
782+
783+
fun RepositoryDetailModel.toRepository(): Repository {
784+
return Repository(
785+
id = id.hashCode().toLong(),
786+
name = name,
787+
fullName = nameWithOwner,
788+
description = shortDescriptionHTML,
789+
owner = User.toMiniUserModel(
790+
id = 0, login = owner, avatarUrl = ownerAvatarUrl ?: ""
791+
),
792+
private = false,
793+
htmlUrl = "https://github.com/$nameWithOwner",
794+
language = languages?.firstOrNull(),
795+
stargazersCount = stargazersCount,
796+
watchersCount = watchersCount,
797+
forksCount = forkCount,
798+
openIssuesCount = issuesOpen,
799+
createdAt = createdAt,
800+
updatedAt = pushedAt ?: "",
801+
pushedAt = pushedAt
802+
)
780803
}

feature/home/src/main/java/com/shuyu/gsygithubappcompose/feature/home/HomeScreen.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ fun HomeScreen(
199199
"check_update" -> {
200200
homeViewModel.checkUpdate(versionName, true)
201201
}
202+
"history" -> {
203+
navigator.navigate("history")
204+
}
202205
}
203206
coroutineScope.launch {
204207
drawerState.close()
@@ -305,6 +308,12 @@ fun DrawerContent(
305308

306309
// Menu Items
307310
Column(modifier = Modifier.weight(1f)) {
311+
Text(
312+
text = stringResource(id = R.string.history),
313+
modifier = Modifier
314+
.fillMaxWidth()
315+
.clickable { onItemSelected("history") }
316+
.padding(16.dp))
308317
Text(
309318
text = stringResource(id = R.string.menu_feedback),
310319
modifier = Modifier

0 commit comments

Comments
 (0)