Skip to content

Commit

Permalink
refactor(signin): Repositoryをdata.apiからdomainにお引越し
Browse files Browse the repository at this point in the history
  • Loading branch information
mikanIchinose committed Nov 9, 2024
1 parent daea673 commit 0fd0463
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion feature/signin/data/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ dependencies {
implementation(platform(libs.google.firebase.bom))
implementation(libs.google.firebase.auth)

implementation(projects.feature.signin.data.api)
implementation(projects.feature.signin.domain)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.github.mikan.githubstarviewer.feature.signin.data.di

import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.data.impl.AuthRepositoryImpl
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
interface SignInDataModule {
internal interface SignInDataModule {
@Binds
fun bindSignInDataRepository(
repository: AuthRepositoryImpl
): AuthRepository
fun bindSignInDataRepository(impl: AuthRepositoryImpl): AuthRepository
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package com.github.mikan.githubstarviewer.feature.signin.data.impl

import android.app.Activity
import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.OAuthCredential
import com.google.firebase.auth.OAuthProvider
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.tasks.await
import javax.inject.Inject
import javax.inject.Singleton

class AuthRepositoryImpl @Inject constructor(
@Singleton
internal class AuthRepositoryImpl @Inject constructor(
private val auth: FirebaseAuth,
private val oathProvider: OAuthProvider
private val oathProvider: OAuthProvider,
) : AuthRepository {
override var accessToken: String? = null

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.mikan.githubstarviewer.feature.signin.data.api
package com.github.mikan.githubstarviewer.feature.signin.domain.repository

import android.app.Activity
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mikan.githubstarviewer.feature.signin.domain.usecase

import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import javax.inject.Inject

class GetAccessTokenUseCase @Inject constructor(
private val authRepository: AuthRepository
private val authRepository: AuthRepository,
) {
operator fun invoke() =
authRepository.accessToken
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mikan.githubstarviewer.feature.signin.domain.usecase

import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import javax.inject.Inject

class IsSignedInUseCase @Inject constructor(
private val authRepository: AuthRepository
private val authRepository: AuthRepository,
) {
operator fun invoke() =
authRepository.isSignedIn()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.mikan.githubstarviewer.feature.signin.domain.usecase

import android.app.Activity
import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapConcat
Expand All @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.map
import javax.inject.Inject

class SignInWithGithubUseCase @Inject constructor(
private val authRepository: AuthRepository
private val authRepository: AuthRepository,
) {
@OptIn(ExperimentalCoroutinesApi::class)
operator fun invoke(activity: Activity): Flow<String> = flowOf(Unit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mikan.githubstarviewer.feature.signin.domain.usecase

import com.github.mikan.githubstarviewer.feature.signin.data.api.AuthRepository
import com.github.mikan.githubstarviewer.feature.signin.domain.repository.AuthRepository
import javax.inject.Inject

class SignOutUseCase @Inject constructor(
private val authRepository: AuthRepository
private val authRepository: AuthRepository,
) {
operator fun invoke() =
authRepository.signOut()
Expand Down

0 comments on commit 0fd0463

Please sign in to comment.