feat: 引入共享会话状态与未登录占位组件
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user