Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from gkd-kit:main #19

Merged
merged 4 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
targetSdk = libs.versions.android.targetSdk.get().toInt()

applicationId = "li.songe.gkd"
versionCode = 9
versionName = "1.4.1"
versionCode = 11
versionName = "1.5.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/li/songe/gkd/ui/HomePageVm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import li.songe.gkd.util.LoadStatus
import li.songe.gkd.util.checkUpdate
import li.songe.gkd.util.client
import li.songe.gkd.util.dbFolder
import li.songe.gkd.util.initFolder
import li.songe.gkd.util.json
import li.songe.gkd.util.launchTry
import li.songe.gkd.util.storeFlow
Expand Down Expand Up @@ -86,6 +87,12 @@ class HomePageVm @Inject constructor() : ViewModel() {
}
}
}

viewModelScope.launchTry(Dispatchers.IO) {
// 在某些机型由于未知原因创建失败
// 在此保证每次重新打开APP都能重新检测创建
initFolder()
}
}

val uploadStatusFlow = MutableStateFlow<LoadStatus<GithubPoliciesAsset>?>(null)
Expand All @@ -105,10 +112,10 @@ class HomePageVm @Inject constructor() : ViewModel() {
onUpload { bytesSentTotal, contentLength ->
if (uploadStatusFlow.value is LoadStatus.Loading) {
uploadStatusFlow.value =
LoadStatus.Loading(bytesSentTotal / contentLength.toFloat())
LoadStatus.Loading(bytesSentTotal / contentLength.toFloat())
}
}
}
}
if (response.headers["X_RPC_OK"] == "true") {
val policiesAsset = response.body<GithubPoliciesAsset>()
uploadStatusFlow.value = LoadStatus.Success(policiesAsset)
Expand Down
21 changes: 16 additions & 5 deletions app/src/main/java/li/songe/gkd/util/ProfileTransitions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@ import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.navigation.NavBackStackEntry
import com.blankj.utilcode.util.ScreenUtils
import com.ramcosta.composedestinations.spec.DestinationStyle

object ProfileTransitions : DestinationStyle.Animated {
private const val durationMillis = 400
override fun AnimatedContentTransitionScope<NavBackStackEntry>.enterTransition(): EnterTransition? {
return slideInHorizontally(tween()) { it }
return slideInHorizontally(
initialOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis)
)
}

override fun AnimatedContentTransitionScope<NavBackStackEntry>.exitTransition(): ExitTransition? {
return slideOutHorizontally(tween()) { -it } + fadeOut(tween())
return slideOutHorizontally(
targetOffsetX = { -ScreenUtils.getScreenWidth() / 2 },
animationSpec = tween(durationMillis)
)
}

override fun AnimatedContentTransitionScope<NavBackStackEntry>.popEnterTransition(): EnterTransition? {
return slideInHorizontally(tween()) { -it }
return slideInHorizontally(
initialOffsetX = { -ScreenUtils.getScreenWidth() / 2 },
animationSpec = tween(durationMillis)
)
}

override fun AnimatedContentTransitionScope<NavBackStackEntry>.popExitTransition(): ExitTransition? {
return slideOutHorizontally(tween()) { it }
return slideOutHorizontally(
targetOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis)
)
}
}