feat: 引入共享会话状态与未登录占位组件

This commit is contained in:
AndyChen1024
2026-09-09 22:15:46 +08:00
parent c80fb31eb1
commit c41c04ff23
4 changed files with 72 additions and 0 deletions

View File

@@ -4,10 +4,12 @@ import com.mingyuan.android_client.core.data.repository.FakeCheckinRepository
import com.mingyuan.android_client.core.data.repository.FakeHomeRepository
import com.mingyuan.android_client.core.data.repository.FakePlanRepository
import com.mingyuan.android_client.core.data.repository.FakeProfileRepository
import com.mingyuan.android_client.core.data.repository.FakeSessionRepository
import com.mingyuan.android_client.core.domain.repository.CheckinRepository
import com.mingyuan.android_client.core.domain.repository.HomeRepository
import com.mingyuan.android_client.core.domain.repository.PlanRepository
import com.mingyuan.android_client.core.domain.repository.ProfileRepository
import com.mingyuan.android_client.core.domain.repository.SessionRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
@@ -33,4 +35,8 @@ abstract class DataModule {
@Binds
@Singleton
abstract fun bindProfileRepository(impl: FakeProfileRepository): ProfileRepository
@Binds
@Singleton
abstract fun bindSessionRepository(impl: FakeSessionRepository): SessionRepository
}

View File

@@ -0,0 +1,25 @@
package com.mingyuan.android_client.core.data.repository
import com.mingyuan.android_client.core.domain.repository.SessionRepository
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class FakeSessionRepository @Inject constructor() : SessionRepository {
private val _isLoggedIn = MutableStateFlow(true)
override val isLoggedIn: Flow<Boolean> = _isLoggedIn
override suspend fun login() {
delay(300)
_isLoggedIn.value = true
}
override suspend fun logout() {
delay(300)
_isLoggedIn.value = false
}
}