From 6bb4128f5c6a17269981fddabcfcc7a972d6c8ae Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:45:00 +0900 Subject: [PATCH 01/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20GithubEntity=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/github/GithubInformationEntity.kt | 10 ++++++++++ .../domain/entity/github/GithubListEntity.kt | 14 ++++++++++++++ .../domain/entity/github/GithubOAuthCheckEntity.kt | 5 +++++ .../domain/entity/github/GithubOAuthEntity.kt | 5 +++++ 4 files changed, 34 insertions(+) create mode 100644 domain/src/main/java/com/xquare/domain/entity/github/GithubInformationEntity.kt create mode 100644 domain/src/main/java/com/xquare/domain/entity/github/GithubListEntity.kt create mode 100644 domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthCheckEntity.kt create mode 100644 domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthEntity.kt diff --git a/domain/src/main/java/com/xquare/domain/entity/github/GithubInformationEntity.kt b/domain/src/main/java/com/xquare/domain/entity/github/GithubInformationEntity.kt new file mode 100644 index 00000000..343ca13e --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/entity/github/GithubInformationEntity.kt @@ -0,0 +1,10 @@ +package com.xquare.domain.entity.github + +data class GithubInformationEntity( + val user_id: String, + val name: String, + val username: String, + val profile_file_name: String, + val contributions: Int, + val ranking: Int, +) diff --git a/domain/src/main/java/com/xquare/domain/entity/github/GithubListEntity.kt b/domain/src/main/java/com/xquare/domain/entity/github/GithubListEntity.kt new file mode 100644 index 00000000..1e977631 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/entity/github/GithubListEntity.kt @@ -0,0 +1,14 @@ +package com.xquare.domain.entity.github + +data class GithubListEntity( + val users: List +){ + data class GithubUserListEntity( + val user_id: String, + val name: String, + val username: String, + val profile_file_name: String, + val contributions: Int, + val ranking: Int, + ) +} diff --git a/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthCheckEntity.kt b/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthCheckEntity.kt new file mode 100644 index 00000000..beb99991 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthCheckEntity.kt @@ -0,0 +1,5 @@ +package com.xquare.domain.entity.github + +data class GithubOAuthCheckEntity( + val is_connected: Boolean +) \ No newline at end of file diff --git a/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthEntity.kt b/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthEntity.kt new file mode 100644 index 00000000..65c80078 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/entity/github/GithubOAuthEntity.kt @@ -0,0 +1,5 @@ +package com.xquare.domain.entity.github + +data class GithubOAuthEntity( + val code: String, +) From a802175807ec3fc36c703502acd575e583c26c24 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:46:20 +0900 Subject: [PATCH 02/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Reposi?= =?UTF-8?q?tory=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/GithubRepository.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 domain/src/main/java/com/xquare/domain/repository/GithubRepository.kt diff --git a/domain/src/main/java/com/xquare/domain/repository/GithubRepository.kt b/domain/src/main/java/com/xquare/domain/repository/GithubRepository.kt new file mode 100644 index 00000000..13a412b9 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/repository/GithubRepository.kt @@ -0,0 +1,18 @@ +package com.xquare.domain.repository + +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.entity.github.GithubOAuthEntity +import kotlinx.coroutines.flow.Flow + +interface GithubRepository { + + suspend fun fetchGithubOAuth(code: String) + + suspend fun fetchGithubInformation(): GithubInformationEntity + + suspend fun fetchGithubList(): GithubListEntity + + suspend fun fetchGithubOAuthCheck(): GithubOAuthCheckEntity +} \ No newline at end of file From a30dfb60a05fe0501ba6097e9608631879f6cfe2 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:46:48 +0900 Subject: [PATCH 03/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20UseCas?= =?UTF-8?q?e=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/FetchGithubInformationUseCase.kt | 16 ++++++++++++++++ .../usecase/github/FetchGithubListUseCase.kt | 15 +++++++++++++++ .../github/FetchGithubOAuthCheckUseCase.kt | 16 ++++++++++++++++ .../usecase/github/FetchGithubOAuthUseCase.kt | 16 ++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubInformationUseCase.kt create mode 100644 domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubListUseCase.kt create mode 100644 domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthCheckUseCase.kt create mode 100644 domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubInformationUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubInformationUseCase.kt new file mode 100644 index 00000000..21d84100 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubInformationUseCase.kt @@ -0,0 +1,16 @@ +package com.xquare.domain.usecase.github + +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.repository.GithubRepository +import com.xquare.domain.usecase.UseCase +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class FetchGithubInformationUseCase @Inject constructor( + private val githubRepository: GithubRepository +): UseCase() { + + override suspend fun execute(data: Unit): GithubInformationEntity = + githubRepository.fetchGithubInformation() + +} \ No newline at end of file diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubListUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubListUseCase.kt new file mode 100644 index 00000000..65a0682b --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubListUseCase.kt @@ -0,0 +1,15 @@ +package com.xquare.domain.usecase.github + +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.domain.repository.GithubRepository +import com.xquare.domain.usecase.UseCase +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class FetchGithubListUseCase @Inject constructor( + private val githubRepository: GithubRepository +): UseCase() { + + override suspend fun execute(data: Unit): GithubListEntity = + githubRepository.fetchGithubList() +} \ No newline at end of file diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthCheckUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthCheckUseCase.kt new file mode 100644 index 00000000..d0919540 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthCheckUseCase.kt @@ -0,0 +1,16 @@ +package com.xquare.domain.usecase.github + +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.repository.GithubRepository +import com.xquare.domain.usecase.UseCase +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class FetchGithubOAuthCheckUseCase @Inject constructor( + private val githubRepository: GithubRepository +) : UseCase() { + + override suspend fun execute(data: Unit): GithubOAuthCheckEntity = + githubRepository.fetchGithubOAuthCheck() + +} diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt new file mode 100644 index 00000000..b0fa8d68 --- /dev/null +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt @@ -0,0 +1,16 @@ +package com.xquare.domain.usecase.github + +import com.xquare.domain.entity.github.GithubOAuthEntity +import com.xquare.domain.repository.GithubRepository +import com.xquare.domain.usecase.UseCase +import javax.inject.Inject + +class FetchGithubOAuthUseCase @Inject constructor( + + private val githubRepository: GithubRepository +) : UseCase() { + + override suspend fun execute(data: GithubOAuthEntity) = + githubRepository.fetchGithubOAuth(code = data.code) + +} From c4cedd17dc220ad14fc46d61265ae05da53e0712 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:49:36 +0900 Subject: [PATCH 04/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Api=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- di/src/main/java/com/xquare/di/NetworkModule.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/di/src/main/java/com/xquare/di/NetworkModule.kt b/di/src/main/java/com/xquare/di/NetworkModule.kt index 5d8a2ca1..178311f8 100644 --- a/di/src/main/java/com/xquare/di/NetworkModule.kt +++ b/di/src/main/java/com/xquare/di/NetworkModule.kt @@ -108,4 +108,10 @@ object NetworkModule { retrofit: Retrofit ): ReportsApi = retrofit.create(ReportsApi::class.java) + + @Provides + fun provideGithubApi( + retrofit: Retrofit + ): GithubApi = + retrofit.create((GithubApi::class.java)) } \ No newline at end of file From e7d1060cf6b600c5e701709dba332c2fa9649df2 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:50:19 +0900 Subject: [PATCH 05/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20GithubRemoteDat?= =?UTF-8?q?aSource=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/di/RemoteDataSourceModule.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/di/src/main/java/com/xquare/di/RemoteDataSourceModule.kt b/di/src/main/java/com/xquare/di/RemoteDataSourceModule.kt index fb7edfad..fa3ba828 100644 --- a/di/src/main/java/com/xquare/di/RemoteDataSourceModule.kt +++ b/di/src/main/java/com/xquare/di/RemoteDataSourceModule.kt @@ -1,6 +1,30 @@ package com.xquare.di import com.xquare.data.remote.datasource.* +import com.xquare.data.remote.datasource.alarm.AlarmRemoteDataSource +import com.xquare.data.remote.datasource.alarm.AlarmRemoteDataSourceImpl +import com.xquare.data.remote.datasource.attachment.AttachmentRemoteDataSource +import com.xquare.data.remote.datasource.attachment.AttachmentRemoteDataSourceImpl +import com.xquare.data.remote.datasource.auth.AuthRemoteDataSource +import com.xquare.data.remote.datasource.auth.AuthRemoteDataSourceImpl +import com.xquare.data.remote.datasource.github.GithubRemoteDataSource +import com.xquare.data.remote.datasource.github.GithubRemoteDataSourceImpl +import com.xquare.data.remote.datasource.meal.MealRemoteDataSource +import com.xquare.data.remote.datasource.meal.MealRemoteDataSourceImpl +import com.xquare.data.remote.datasource.pick.PickRemoteDataSource +import com.xquare.data.remote.datasource.pick.PickRemoteDataSourceImpl +import com.xquare.data.remote.datasource.point.PointRemoteDataSource +import com.xquare.data.remote.datasource.point.PointRemoteDataSourceImpl +import com.xquare.data.remote.datasource.report.ReportRemoteDataSource +import com.xquare.data.remote.datasource.report.ReportRemoteDataSourceImpl +import com.xquare.data.remote.datasource.schedules.SchedulesRemoteDataSource +import com.xquare.data.remote.datasource.schedules.SchedulesRemoteDataSourceImpl +import com.xquare.data.remote.datasource.timetable.TimetablesRemoteDataSource +import com.xquare.data.remote.datasource.timetable.TimetablesRemoteDataSourceImpl +import com.xquare.data.remote.datasource.user.UserRemoteDataSource +import com.xquare.data.remote.datasource.user.UserRemoteDataSourceImpl +import com.xquare.data.remote.datasource.user.UserSimpleRemoteDataSource +import com.xquare.data.remote.datasource.user.UserSimpleRemoteDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -64,4 +88,9 @@ abstract class RemoteDataSourceModule { abstract fun bindReportsRemoteDataSource( reportRemoteDataSourceImpl: ReportRemoteDataSourceImpl ): ReportRemoteDataSource + + @Binds + abstract fun bindGithubRemoteDataSource( + githubRemoteDataSourceImpl: GithubRemoteDataSourceImpl + ): GithubRemoteDataSource } \ No newline at end of file From 4409e2669badc9bf254bd31b34aa5333b1c6b5e7 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:50:44 +0900 Subject: [PATCH 06/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Repository=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- di/src/main/java/com/xquare/di/RepositoryModule.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/di/src/main/java/com/xquare/di/RepositoryModule.kt b/di/src/main/java/com/xquare/di/RepositoryModule.kt index 8486f337..cf0b6f6a 100644 --- a/di/src/main/java/com/xquare/di/RepositoryModule.kt +++ b/di/src/main/java/com/xquare/di/RepositoryModule.kt @@ -1,6 +1,7 @@ package com.xquare.di import com.xquare.data.repository.AuthRepositoryImpl +import com.xquare.data.repository.GithubRepositoryImpl import com.xquare.data.repository.PointRepositoryImpl import com.xquare.data.repository.WebViewRepositoryImpl import com.xquare.data.repository.attachment.AttachmentRepositoryImpl @@ -12,6 +13,7 @@ import com.xquare.data.repository.pick.PickRepositoryImpl import com.xquare.data.repository.reports.ReportRepositoryImpl import com.xquare.data.repository.user.UserRepositoryImpl import com.xquare.domain.repository.AuthRepository +import com.xquare.domain.repository.GithubRepository import com.xquare.domain.repository.PointRepository import com.xquare.domain.repository.WebViewRepository import com.xquare.domain.repository.attachment.AttachmentRepository @@ -85,4 +87,9 @@ abstract class RepositoryModule { abstract fun bindReportsRepository( reportRepositoryImpl: ReportRepositoryImpl, ): ReportRepository + + @Binds + abstract fun bindGithubRepository( + githubRepositoryImpl: GithubRepositoryImpl + ): GithubRepository } \ No newline at end of file From 1a68fb76fa9ede85c33d340f3b7c430f2db9e1dd Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:51:15 +0900 Subject: [PATCH 07/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20GithubRepositor?= =?UTF-8?q?yImpl=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/GithubRepositoryImpl.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 data/src/main/java/com/xquare/data/repository/GithubRepositoryImpl.kt diff --git a/data/src/main/java/com/xquare/data/repository/GithubRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/GithubRepositoryImpl.kt new file mode 100644 index 00000000..93cf4203 --- /dev/null +++ b/data/src/main/java/com/xquare/data/repository/GithubRepositoryImpl.kt @@ -0,0 +1,25 @@ +package com.xquare.data.repository + +import com.xquare.data.remote.datasource.github.GithubRemoteDataSource +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.repository.GithubRepository +import javax.inject.Inject + +class GithubRepositoryImpl @Inject constructor( + private val githubRemoteDataSource: GithubRemoteDataSource, +): GithubRepository { + + override suspend fun fetchGithubOAuth(code: String) = + githubRemoteDataSource.fetchGithubOAuth(code) + + override suspend fun fetchGithubInformation(): GithubInformationEntity = + githubRemoteDataSource.fetchGithubInformation() + + override suspend fun fetchGithubList(): GithubListEntity = + githubRemoteDataSource.fetchGithubList() + + override suspend fun fetchGithubOAuthCheck(): GithubOAuthCheckEntity = + githubRemoteDataSource.fetchGithubOAuthCheck() +} \ No newline at end of file From a779e3f4e442ac5bd1dad311882152fbc4cdfdb1 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:52:04 +0900 Subject: [PATCH 08/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/data/remote/api/GithubApi.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 data/src/main/java/com/xquare/data/remote/api/GithubApi.kt diff --git a/data/src/main/java/com/xquare/data/remote/api/GithubApi.kt b/data/src/main/java/com/xquare/data/remote/api/GithubApi.kt new file mode 100644 index 00000000..7455d6af --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/api/GithubApi.kt @@ -0,0 +1,31 @@ +package com.xquare.data.remote.api + +import com.xquare.data.remote.response.github.GithubInformationResponse +import com.xquare.data.remote.response.github.GithubListResponse +import com.xquare.data.remote.response.github.GithubOAuthCheckResponse +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.PATCH +import retrofit2.http.POST +import retrofit2.http.Query + +interface GithubApi { + + @POST("gits") + suspend fun githubOAuth( + @Query("code") code: String + ) + + @PATCH("gits") + suspend fun githubUpdateRanking() + + @GET("gits") + suspend fun githubInformation(): GithubInformationResponse + + @GET("gits/all") + suspend fun githubList(): GithubListResponse + + @GET("gits/exist") + suspend fun githubOAuthCheck(): GithubOAuthCheckResponse + +} \ No newline at end of file From 859b3cc2b126f1429d8498a0faead017b453ff00 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:52:52 +0900 Subject: [PATCH 09/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Respon?= =?UTF-8?q?se=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/GithubInformationResponse.kt | 23 +++++++++++++ .../response/github/GithubListResponse.kt | 32 +++++++++++++++++++ .../github/GithubOAuthCheckResponse.kt | 13 ++++++++ 3 files changed, 68 insertions(+) create mode 100644 data/src/main/java/com/xquare/data/remote/response/github/GithubInformationResponse.kt create mode 100644 data/src/main/java/com/xquare/data/remote/response/github/GithubListResponse.kt create mode 100644 data/src/main/java/com/xquare/data/remote/response/github/GithubOAuthCheckResponse.kt diff --git a/data/src/main/java/com/xquare/data/remote/response/github/GithubInformationResponse.kt b/data/src/main/java/com/xquare/data/remote/response/github/GithubInformationResponse.kt new file mode 100644 index 00000000..3cbe47a7 --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/response/github/GithubInformationResponse.kt @@ -0,0 +1,23 @@ +package com.xquare.data.remote.response.github + +import com.google.gson.annotations.SerializedName +import com.xquare.domain.entity.github.GithubInformationEntity + +data class GithubInformationResponse( + @SerializedName("user_id") val user_id: String, + @SerializedName("name") val name: String, + @SerializedName("username") val username: String, + @SerializedName("profile_file_name") val profile_file_name: String, + @SerializedName("contributions") val contributions: Int, + @SerializedName("ranking") val ranking: Int, +) + +fun GithubInformationResponse.toEntity(): GithubInformationEntity = + GithubInformationEntity( + user_id = user_id, + name = name, + username = username, + profile_file_name = profile_file_name, + contributions = contributions, + ranking = ranking + ) diff --git a/data/src/main/java/com/xquare/data/remote/response/github/GithubListResponse.kt b/data/src/main/java/com/xquare/data/remote/response/github/GithubListResponse.kt new file mode 100644 index 00000000..d8e69cf2 --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/response/github/GithubListResponse.kt @@ -0,0 +1,32 @@ +package com.xquare.data.remote.response.github + +import com.google.gson.annotations.SerializedName +import com.xquare.domain.entity.github.GithubListEntity + +data class GithubListResponse( + @SerializedName("users") val users: List, +){ + data class GithubUserListResponse( + @SerializedName("user_id") val user_id: String, + @SerializedName("name") val name: String, + @SerializedName("username") val username: String, + @SerializedName("profile_file_name") val profile_file_name: String, + @SerializedName("contributions") val contributions: Int, + @SerializedName("ranking") val ranking: Int, + ) +} + +fun GithubListResponse.toEntity() = + GithubListEntity( + users = users.map { it.toEntity() } + ) + +fun GithubListResponse.GithubUserListResponse.toEntity() = + GithubListEntity.GithubUserListEntity( + user_id = user_id, + name = name, + username = username, + profile_file_name = profile_file_name, + contributions = contributions, + ranking = ranking + ) \ No newline at end of file diff --git a/data/src/main/java/com/xquare/data/remote/response/github/GithubOAuthCheckResponse.kt b/data/src/main/java/com/xquare/data/remote/response/github/GithubOAuthCheckResponse.kt new file mode 100644 index 00000000..0fcf1787 --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/response/github/GithubOAuthCheckResponse.kt @@ -0,0 +1,13 @@ +package com.xquare.data.remote.response.github + +import com.google.gson.annotations.SerializedName +import com.xquare.domain.entity.github.GithubOAuthCheckEntity + +data class GithubOAuthCheckResponse( + @SerializedName("is_connected") val is_connected: Boolean, +) + +fun GithubOAuthCheckResponse.toEntity(): GithubOAuthCheckEntity = + GithubOAuthCheckEntity( + is_connected = is_connected + ) \ No newline at end of file From f3e707735c218d730913a5bf6e1c156c0348e1e9 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:53:16 +0900 Subject: [PATCH 10/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20GithubRemoteDat?= =?UTF-8?q?aSource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/GithubRemoteDataSource.kt | 18 ++++++++++++ .../github/GithubRemoteDataSourceImpl.kt | 29 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSource.kt create mode 100644 data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSourceImpl.kt diff --git a/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSource.kt new file mode 100644 index 00000000..e0315bfa --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSource.kt @@ -0,0 +1,18 @@ +package com.xquare.data.remote.datasource.github + +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.entity.github.GithubOAuthEntity +import kotlinx.coroutines.flow.Flow + +interface GithubRemoteDataSource { + + suspend fun fetchGithubOAuth(code: String) + + suspend fun fetchGithubInformation(): GithubInformationEntity + + suspend fun fetchGithubOAuthCheck(): GithubOAuthCheckEntity + + suspend fun fetchGithubList(): GithubListEntity +} \ No newline at end of file diff --git a/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSourceImpl.kt new file mode 100644 index 00000000..48a5e69d --- /dev/null +++ b/data/src/main/java/com/xquare/data/remote/datasource/github/GithubRemoteDataSourceImpl.kt @@ -0,0 +1,29 @@ +package com.xquare.data.remote.datasource.github + +import com.xquare.data.remote.api.GithubApi +import com.xquare.data.remote.response.github.toEntity +import com.xquare.data.sendHttpRequest +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.entity.github.GithubOAuthEntity +import javax.inject.Inject + +class GithubRemoteDataSourceImpl @Inject constructor( + private val githubApi: GithubApi +): GithubRemoteDataSource { + + + override suspend fun fetchGithubOAuth(code: String) = + sendHttpRequest(httpRequest = { githubApi.githubOAuth(code) }) + + override suspend fun fetchGithubInformation(): GithubInformationEntity = + sendHttpRequest(httpRequest = { githubApi.githubInformation().toEntity() }) + + override suspend fun fetchGithubOAuthCheck(): GithubOAuthCheckEntity = + sendHttpRequest(httpRequest = { githubApi.githubOAuthCheck().toEntity() }) + + override suspend fun fetchGithubList(): GithubListEntity = + sendHttpRequest(httpRequest = { githubApi.githubList().toEntity() }) + +} \ No newline at end of file From b55e41ec0164d201ceeff420375799e6a8e60e8b Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:54:00 +0900 Subject: [PATCH 11/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Deep=20Link=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e80356c0..39519d7a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,9 +1,9 @@ + package="com.xquare.xquare_android"> - + @@ -17,24 +17,36 @@ android:supportsRtl="true" android:hardwareAccelerated="true"> - + - - + + + android:name="com.xquare.xquare_android.MainActivity" + android:exported="true" + android:label="@string/app_name" + android:screenOrientation="portrait" + android:theme="@style/Theme.XquareAndroid"> + + + + + + + + + From ab9341fbbcb04c42ce717befd1cecf035afe1be9 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:54:37 +0900 Subject: [PATCH 12/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20naviga?= =?UTF-8?q?te=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xquare/xquare_android/feature/all/AllScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/xquare/xquare_android/feature/all/AllScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/all/AllScreen.kt index a7105601..2658015b 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/all/AllScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/all/AllScreen.kt @@ -44,7 +44,7 @@ import com.xquare.xquare_android.util.DevicePaddings @Composable fun AllScreen(navController: NavController) { - val schoolMenuList = listOf("오늘의 자습감독 선생님")//"동아리 지원하기", "오늘의 자습감독 선생님", "랭킹") + val schoolMenuList = listOf("오늘의 자습감독 선생님", "랭킹")//"동아리 지원하기", "오늘의 자습감독 선생님", "랭킹") val dormitoryMenuList = listOf("봉사 지원하기", "청소판 확인하기") val userMenuList = listOf("업데이트 사항") @@ -92,6 +92,7 @@ fun AllScreen(navController: NavController) { ColumnMenuItem(title) { when(index) { 0 -> navController.navigate(AppNavigationItem.TodayTeacher.route) + 1 -> navController.navigate(AppNavigationItem.Github.route) } } } From 056b8f2407711e310e97377c091b58f585ad8631 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:55:02 +0900 Subject: [PATCH 13/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/github/GithubScreen.kt | 50 ++++++++++++++----- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt index 006b5626..562668aa 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt @@ -1,6 +1,5 @@ package com.xquare.xquare_android.feature.github -import androidx.annotation.ChecksSdkIntAtLeast import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border @@ -17,20 +16,25 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Icon -import androidx.compose.material.ListItem import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import com.semicolon.design.Body1 import com.semicolon.design.Body2 @@ -41,25 +45,50 @@ import com.semicolon.design.color.primary.gray.gray700 import com.semicolon.design.color.primary.gray.gray900 import com.semicolon.design.color.primary.purple.purple200 import com.semicolon.design.color.primary.white.white +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity import com.xquare.xquare_android.R import com.xquare.xquare_android.component.CenterAppBar import com.xquare.xquare_android.theme.Bronze import com.xquare.xquare_android.theme.Gold import com.xquare.xquare_android.theme.Silver import com.xquare.xquare_android.util.DevicePaddings -import okhttp3.internal.notify +import com.xquare.xquare_android.util.makeToast @Composable fun GithubScreen( navController: NavController, ) { + val context = LocalContext.current + val viewModel: GithubViewModel = hiltViewModel() + var information: GithubInformationEntity? by remember { mutableStateOf(null) } + var githubList: GithubListEntity? by remember { mutableStateOf(null) } - Github(onBack = { navController.popBackStack() }) + LaunchedEffect(Unit){ + viewModel.fetchInformation() + viewModel.eventFlow.collect(){ + when(it){ + is GithubViewModel.Event.InformationSuccess -> { + information = it.data + } + is GithubViewModel.Event.Failure -> { + makeToast(context, "Github 정보를 불러오기에 실패했습니다.") + } + + } + } + } + Github( + githubInformation = information, + githubList = githubList, + onBack = { navController.popBackStack() }) } @Composable fun Github( + githubList: GithubListEntity?, + githubInformation: GithubInformationEntity?, onBack: () -> Unit, ) { Scaffold( @@ -101,7 +130,7 @@ fun Github( id = "@yeon0821", commit = "1,828커밋", color = Silver, - centerPadding = 16.dp, + centerPadding = 15.dp, tint = Silver ) GithubItem( @@ -112,7 +141,7 @@ fun Github( id = "@junjaㅈboy", commit = "18,181커밋", color = Gold, - centerPadding = 24.dp, + centerPadding = 30.dp, tint = Gold ) GithubItem( @@ -123,7 +152,7 @@ fun Github( id = "@Tmdhoon2", commit = "1,818커밋", color = Bronze, - centerPadding = 8.dp, + centerPadding = 1.dp, tint = Bronze ) } @@ -237,8 +266,3 @@ private fun RowScope.GithubItem( } } -@Preview(showBackground = true) -@Composable -private fun GithubPreview() { - Github {} -} From b31e8eb0d3fdbfa918aaf2cf9fa034ebad55d65e Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:55:20 +0900 Subject: [PATCH 14/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20ViewMo?= =?UTF-8?q?del?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/github/GithubViewModel.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt new file mode 100644 index 00000000..e6013c10 --- /dev/null +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt @@ -0,0 +1,40 @@ +package com.xquare.xquare_android.feature.github + +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.entity.github.GithubOAuthEntity +import com.xquare.domain.usecase.github.FetchGithubInformationUseCase +import com.xquare.domain.usecase.github.FetchGithubListUseCase +import com.xquare.domain.usecase.github.FetchGithubOAuthCheckUseCase +import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase +import com.xquare.xquare_android.base.BaseViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class GithubViewModel @Inject constructor( + private val fetchGithubInformationUseCase: FetchGithubInformationUseCase, + private val fetchGithubListUseCase: FetchGithubListUseCase, +) : BaseViewModel() { + + + fun fetchInformation() = + execute( + job = { fetchGithubInformationUseCase.execute(Unit) }, + onSuccess = { emitEvent(Event.InformationSuccess(it)) }, + onFailure = { emitEvent(Event.Failure) } + ) + + + + sealed class Event { + + + data class InformationSuccess(val data: GithubInformationEntity) : Event() + + + object Failure : Event() + + + } +} \ No newline at end of file From c55fd349eb5f2ed11d4643a76b4791c44eea1c3a Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:55:37 +0900 Subject: [PATCH 15/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20OAuth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/profile/ProfileScreen.kt | 113 ++++++++++++------ .../feature/profile/ProfileViewModel.kt | 23 ++++ 2 files changed, 100 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index 12094e86..bdd8ce1a 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -2,6 +2,7 @@ package com.xquare.xquare_android.feature.profile import android.app.Activity import android.content.Intent +import android.net.Uri import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.Image @@ -29,11 +30,17 @@ import com.semicolon.design.Body1 import com.semicolon.design.Body2 import com.semicolon.design.Body3 import com.semicolon.design.color.primary.gray.* +import com.semicolon.design.color.primary.purple.purple200 +import com.semicolon.design.color.primary.purple.purple300 +import com.semicolon.design.color.primary.purple.purple50 import com.semicolon.design.color.primary.white.white +import com.xquare.domain.entity.github.GithubOAuthCheckEntity +import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.entity.profile.ProfileEntity import com.xquare.xquare_android.R import com.xquare.xquare_android.component.CenterAppBar import com.xquare.xquare_android.component.modal.ConfirmModal +import com.xquare.xquare_android.getCode import com.xquare.xquare_android.navigation.AppNavigationItem import com.xquare.xquare_android.util.DevicePaddings import com.xquare.xquare_android.util.makeToast @@ -53,21 +60,36 @@ fun ProfileScreen(navController: NavController) { is ProfileViewModel.Event.Success -> { profile = it.data } + is ProfileViewModel.Event.Failure -> { makeToast(context, "프로필을 불러오지 못했습니다") } + is ProfileViewModel.Event.UploadFileSuccess -> { viewModel.fixProfileImage(it.data[0]) } + is ProfileViewModel.Event.UploadFileFailure -> { makeToast(context, "이미지를 불러오지 못했습니다") } + is ProfileViewModel.Event.ImageChangeSuccess -> { viewModel.fetchProfile() } + is ProfileViewModel.Event.ImageChangeFailure -> { makeToast(context, "이미지를 변경하지 못했습니다") } + + is ProfileViewModel.Event.OAuthCheckSuccess -> { + viewModel.fetchOAuthCheck() + makeToast(context, "Github 계정연동에 성공하셨습니다.") + } + + is ProfileViewModel.Event.OAuthSuccess -> { + navController.navigate(AppNavigationItem.Profile.route) + } + is ProfileViewModel.Event.LogoutSuccess -> { navController.navigate(AppNavigationItem.Onboard.route) { popUpTo(0) { @@ -84,13 +106,15 @@ fun ProfileScreen(navController: NavController) { sendImage = { viewModel.uploadFile(it) }, - viewModel = viewModel + viewModel = viewModel, ) } + @Composable private fun Profile( profile: ProfileEntity?, onBackPress: () -> Unit, +// onOAuthClick: (GithubOAuthEntity) -> Unit, sendImage: (File) -> Unit, viewModel: ProfileViewModel, ) { @@ -98,7 +122,7 @@ private fun Profile( var galleryState by remember { mutableStateOf(false) } var logoutDialogState by remember { mutableStateOf(false) } val gitMenuList = listOf("계정 연동") -// var gitState by remember { mutableStateOf(false) } + var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf( GithubOAuthCheckEntity(is_connected = false)) } val accountMenuList = listOf("로그아웃") val openWebViewGallery = rememberLauncherForActivityResult( @@ -186,7 +210,8 @@ private fun Profile( } ) Spacer(Modifier.size(30.dp)) - Row(Modifier.padding(horizontal = 16.dp) + Row( + Modifier.padding(horizontal = 16.dp) ) { Body1(text = "이름", color = gray900) Spacer(modifier = Modifier.weight(1f)) @@ -194,11 +219,12 @@ private fun Profile( } Spacer(Modifier.size(20.dp)) - Row(Modifier.padding(horizontal = 16.dp)){ + Row(Modifier.padding(horizontal = 16.dp)) { Body1(text = "생년월일", color = gray900) Spacer(modifier = Modifier.weight(1f)) Body1( - text = profile?.birthday?.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")) ?: "", + text = profile?.birthday?.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")) + ?: "", fontWeight = FontWeight.Medium ) } @@ -235,11 +261,33 @@ private fun Profile( logoutDialogState = false } } + Spacer(Modifier.size(4.dp)) + Column(Modifier.padding(horizontal = 16.dp)) { + Body1( + text = "계정 연동", + fontWeight = FontWeight.Medium + ) + Spacer(Modifier.size(4.dp)) + gitMenuList.forEachIndexed { index, text -> + ButtonColumnMenu( + text = "Github 연동", + onClick = + { + val intent = Intent( + Intent.ACTION_VIEW, + Uri.parse("https://github.com/login/oauth/authorize?client_id=7ba1da5afd9b182e9793") + ) + context.startActivity(intent) + }, + is_connected = gitState!!.is_connected, + ) + } + } + Spacer(Modifier.size(4.dp)) Column(Modifier.padding(horizontal = 16.dp)) { Body1( text = "계정 설정", - fontWeight = FontWeight.Bold, - + fontWeight = FontWeight.Medium, ) Spacer(Modifier.size(4.dp)) Body3(text = "기기내 계정에서 로그아웃 할 수 있어요.", color = gray700) @@ -251,27 +299,13 @@ private fun Profile( } } } - /* - Column { - Body1( - text = "계정 연동", - fontWeight = FontWeight.Bold, - modifier = Modifier - .padding(start = 4.dp) - ) - gitMenuList.forEachIndexed { index, text -> - ButtonColumnMenu(text = text) { - when(index) { - 0 -> TODO() - } - } - } - } - */ } + } } } + + @Composable private fun ColumnMenu(text: String, onClick: () -> Unit) { Box( @@ -294,23 +328,24 @@ private fun ColumnMenu(text: String, onClick: () -> Unit) { ) } } -/* + @Composable private fun ButtonColumnMenu( -text: String, -onClick: () -> Unit, -gitState: Boolean, + text: String, + onClick: (GithubOAuthEntity) -> Unit, + is_connected: Boolean, ) { - //val textColor = if (gitState) white else purple200 - //val buttonColor = if (gitState) purple300 else purple50 + val textColor = if (is_connected) purple200 else white + val buttonColor = if (is_connected) purple50 else purple300 + val intent:Intent = Intent() Box( modifier = Modifier - .padding(start = 12.dp, end = 16.dp, top = 12.dp) + .padding(top = 12.dp, bottom = 12.dp) .clickable( interactionSource = MutableInteractionSource(), indication = null, enabled = true - ) { onClick() } + ) { onClick(GithubOAuthEntity(getCode(intent).toString())) } .fillMaxWidth() .height(52.dp) .background(gray50, RoundedCornerShape(12.dp)), @@ -331,13 +366,19 @@ gitState: Boolean, modifier = Modifier .size(80.dp, 38.dp) .clip(RoundedCornerShape(8.dp)) - .background(purple300), + .clickable { + onClick(GithubOAuthEntity(getCode(intent).toString())) + } + .background(buttonColor), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center - ){ - Text(text = "연동하기", color = white) + + ) { + if (is_connected){ + Text(text = "연동됨", color = textColor) + } + else Text(text = "연동하기", color = textColor ) } } } } -*/ \ No newline at end of file diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt index dbe59bb3..ffb8ddb8 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt @@ -1,10 +1,13 @@ package com.xquare.xquare_android.feature.profile import android.util.Log +import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.entity.profile.ProfileEntity import com.xquare.domain.usecase.attachment.UploadFileUseCase import com.xquare.domain.usecase.auth.LogoutUseCase +import com.xquare.domain.usecase.github.FetchGithubOAuthCheckUseCase +import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase import com.xquare.domain.usecase.user.FetchProfileUseCase import com.xquare.domain.usecase.user.FixProfileImageUseCase import com.xquare.xquare_android.base.BaseViewModel @@ -18,6 +21,8 @@ class ProfileViewModel @Inject constructor( private val fixProfileImageUseCase: FixProfileImageUseCase, private val uploadFileUseCase: UploadFileUseCase, private val logoutUseCase: LogoutUseCase, + private val fetchGithubOAuthUseCase: FetchGithubOAuthUseCase, + private val fetchGithubOAuthCheckUseCase: FetchGithubOAuthCheckUseCase, ) : BaseViewModel() { fun fetchProfile() = @@ -46,6 +51,14 @@ class ProfileViewModel @Inject constructor( ) } + fun fetchOAuth(githubOAuthEntity: GithubOAuthEntity) = + execute( + job = { fetchGithubOAuthUseCase.execute(githubOAuthEntity) }, + onSuccess = { emitEvent(Event.OAuthSuccess(githubOAuthEntity)) }, + onFailure = { emitEvent(Event.Failure)} + ) + + fun logout() = execute( job = { logoutUseCase.execute(Unit) }, @@ -53,12 +66,22 @@ class ProfileViewModel @Inject constructor( onFailure = { } ) + fun fetchOAuthCheck() = + execute( + job = { fetchGithubOAuthCheckUseCase.execute(Unit) }, + onSuccess = { emitEvent(Event.OAuthCheckSuccess) }, + onFailure = { emitEvent(Event.Failure) } + ) + sealed class Event { object LogoutSuccess : Event() data class Success(val data: ProfileEntity) : Event() object Failure : Event() + object OAuthCheckSuccess : Event() + data class OAuthSuccess(val data: GithubOAuthEntity) : Event() + data class UploadFileSuccess(val data: List) : Event() object UploadFileFailure : Event() From 3f41df42a60cb3648d092ddc6620f8b15036ccf4 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:56:45 +0900 Subject: [PATCH 16/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20URL=20Scheme=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/xquare_android/MainActivity.kt | 21 ++++++++++++++++++- .../xquare_android/XquareApplication.kt | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index 3b1372e3..510190a8 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -2,6 +2,8 @@ package com.xquare.xquare_android import android.content.Context import android.content.ContextWrapper +import android.content.Intent +import android.net.Uri import android.os.Build import android.os.Bundle import android.util.Log @@ -32,6 +34,7 @@ import com.xquare.xquare_android.feature.alarm.AlarmScreen import com.xquare.xquare_android.feature.all.AllScreen import com.xquare.xquare_android.feature.allmeal.AllMealScreen import com.xquare.xquare_android.feature.bug.BugReportScreen +import com.xquare.xquare_android.feature.github.GithubScreen import com.xquare.xquare_android.feature.home.HomeScreen import com.xquare.xquare_android.feature.imagedetail.ImageDetailScreen import com.xquare.xquare_android.feature.onboard.OnboardScreen @@ -54,6 +57,7 @@ import dagger.hilt.android.AndroidEntryPoint import java.io.File import java.net.URLDecoder import java.nio.charset.StandardCharsets +import kotlin.math.log @AndroidEntryPoint @@ -65,6 +69,7 @@ class MainActivity : ComponentActivity() { DevicePaddings.navigationBarHeightDp = getNavigationBarHeightDp() super.onCreate(savedInstanceState) saveDeviceToken(this) + getCode(intent) setContent { Thread.setDefaultUncaughtExceptionHandler( @@ -141,6 +146,9 @@ fun BaseApp() { ReleaseScreen(navController) } + composable(AppNavigationItem.Github.route){ + GithubScreen(navController) + } composable(AppNavigationItem.WriteSchedule.route) { val schedulesData = it.arguments?.get("schedulesData").toString() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -289,4 +297,15 @@ fun Context.getActivity(): ComponentActivity? = when (this) { is ComponentActivity -> this is ContextWrapper -> baseContext.getActivity() else -> null -} \ No newline at end of file +} + +fun getCode(intent: Intent): String? { + val data: Uri? = intent.data + val action: String? = intent.action + Log.d("TAG", "getCode: ${data?.getQueryParameter("code")}") + + if (action == Intent.ACTION_VIEW) { + data?.getQueryParameter("code") + } + return null +} diff --git a/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt b/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt index a823931d..c09424a2 100644 --- a/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt +++ b/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt @@ -2,6 +2,7 @@ package com.xquare.xquare_android import android.app.Application import android.content.Context +import android.content.Intent import android.util.Log import com.google.firebase.FirebaseApp import com.google.firebase.messaging.FirebaseMessaging @@ -21,5 +22,6 @@ class XquareApplication : Application() { sharedPrefs.edit().clear().apply() saveDeviceToken(this) clearCache(this) + getCode(intent = Intent()) } } From bd4eb1c6930678c0772e727a457074f011fa8650 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:57:05 +0900 Subject: [PATCH 17/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20Naviga?= =?UTF-8?q?tionItem=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/xquare_android/navigation/AppNavigationItem.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/xquare/xquare_android/navigation/AppNavigationItem.kt b/app/src/main/java/com/xquare/xquare_android/navigation/AppNavigationItem.kt index 54b05599..d33ba842 100644 --- a/app/src/main/java/com/xquare/xquare_android/navigation/AppNavigationItem.kt +++ b/app/src/main/java/com/xquare/xquare_android/navigation/AppNavigationItem.kt @@ -40,6 +40,8 @@ sealed class AppNavigationItem(val route: String) { object ReleaseNote: AppNavigationItem("ReleaseNote") + object Github: AppNavigationItem("Github") + object WriteSchedule : AppNavigationItem("writeSchedule/{schedulesData}") { fun createRoute(schedulesData: SchedulesEntity.SchedulesDataEntity?): String { return if (schedulesData == null) "writeSchedule/null" else "writeSchedule/${ From c9b917581402caf26d1a04f1c168a1d55ac107f0 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Thu, 7 Sep 2023 22:59:08 +0900 Subject: [PATCH 18/29] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20package=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/{ => alarm}/AlarmRemoteDataSource.kt | 2 +- .../{ => alarm}/AlarmRemoteDataSourceImpl.kt | 5 ++--- .../{ => attachment}/AttachmentRemoteDataSource.kt | 2 +- .../AttachmentRemoteDataSourceImpl.kt | 13 +------------ .../datasource/{ => auth}/AuthRemoteDataSource.kt | 2 +- .../{ => auth}/AuthRemoteDataSourceImpl.kt | 2 +- .../datasource/{ => meal}/MealRemoteDataSource.kt | 2 +- .../{ => meal}/MealRemoteDataSourceImpl.kt | 3 +-- .../datasource/{ => pick}/PickRemoteDataSource.kt | 2 +- .../{ => pick}/PickRemoteDataSourceImpl.kt | 3 +-- .../datasource/{ => point}/PointRemoteDataSource.kt | 2 +- .../{ => point}/PointRemoteDataSourceImpl.kt | 3 +-- .../{ => report}/ReportRemoteDataSource.kt | 2 +- .../{ => report}/ReportRemoteDataSourceImpl.kt | 4 ++-- .../{ => schedules}/SchedulesRemoteDataSource.kt | 2 +- .../SchedulesRemoteDataSourceImpl.kt | 2 +- .../{ => timetable}/TimetablesRemoteDataSource.kt | 2 +- .../TimetablesRemoteDataSourceImpl.kt | 2 +- .../datasource/{ => user}/UserRemoteDataSource.kt | 2 +- .../{ => user}/UserRemoteDataSourceImpl.kt | 2 +- .../{ => user}/UserSimpleRemoteDataSource.kt | 2 +- .../{ => user}/UserSimpleRemoteDataSourceImpl.kt | 2 +- .../xquare/data/repository/AuthRepositoryImpl.kt | 2 +- .../xquare/data/repository/PointRepositoryImpl.kt | 3 +-- .../xquare/data/repository/WebViewRepositoryImpl.kt | 2 +- .../attachment/AttachmentRepositoryImpl.kt | 2 +- .../data/repository/meal/MealRepositoryImpl.kt | 6 +----- .../repository/notification/AlarmRepositoryImpl.kt | 6 +----- .../data/repository/pick/PickRepositoryImpl.kt | 4 +--- .../data/repository/reports/ReportRepositoryImpl.kt | 2 +- .../repository/schedules/SchedulesRepositoryImpl.kt | 4 +--- .../timetables/TimetablesRepositoryImpl.kt | 2 +- .../data/repository/user/UserRepositoryImpl.kt | 5 ++--- 33 files changed, 36 insertions(+), 65 deletions(-) rename data/src/main/java/com/xquare/data/remote/datasource/{ => alarm}/AlarmRemoteDataSource.kt (89%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => alarm}/AlarmRemoteDataSourceImpl.kt (84%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => attachment}/AttachmentRemoteDataSource.kt (75%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => attachment}/AttachmentRemoteDataSourceImpl.kt (71%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => auth}/AuthRemoteDataSource.kt (88%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => auth}/AuthRemoteDataSourceImpl.kt (97%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => meal}/MealRemoteDataSource.kt (86%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => meal}/MealRemoteDataSourceImpl.kt (91%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => pick}/PickRemoteDataSource.kt (92%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => pick}/PickRemoteDataSourceImpl.kt (94%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => point}/PointRemoteDataSource.kt (85%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => point}/PointRemoteDataSourceImpl.kt (89%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => report}/ReportRemoteDataSource.kt (82%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => report}/ReportRemoteDataSourceImpl.kt (90%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => schedules}/SchedulesRemoteDataSource.kt (89%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => schedules}/SchedulesRemoteDataSourceImpl.kt (96%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => timetable}/TimetablesRemoteDataSource.kt (84%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => timetable}/TimetablesRemoteDataSourceImpl.kt (94%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => user}/UserRemoteDataSource.kt (74%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => user}/UserRemoteDataSourceImpl.kt (91%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => user}/UserSimpleRemoteDataSource.kt (83%) rename data/src/main/java/com/xquare/data/remote/datasource/{ => user}/UserSimpleRemoteDataSourceImpl.kt (93%) diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSource.kt similarity index 89% rename from data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSource.kt index 68a49684..0b208236 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.alarm import com.xquare.domain.entity.notification.ActivateAlarmEntity import com.xquare.domain.entity.notification.AlarmCategoriesEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSourceImpl.kt similarity index 84% rename from data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSourceImpl.kt index 13d1877e..460e107c 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AlarmRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/alarm/AlarmRemoteDataSourceImpl.kt @@ -1,10 +1,9 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.alarm import com.xquare.data.remote.api.NotificationApi -import com.xquare.data.remote.request.notification.toRequest +import com.xquare.data.remote.datasource.alarm.AlarmRemoteDataSource import com.xquare.data.remote.response.notification.toEntity import com.xquare.data.sendHttpRequest -import com.xquare.domain.entity.notification.ActivateAlarmEntity import com.xquare.domain.entity.notification.AlarmCategoriesEntity import com.xquare.domain.entity.notification.AlarmEntity import javax.inject.Inject diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSource.kt similarity index 75% rename from data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSource.kt index e6f5bfec..94760ca2 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.attachment import com.xquare.domain.entity.attachment.FileEntity import java.io.File diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSourceImpl.kt similarity index 71% rename from data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSourceImpl.kt index a3bb963b..5bffe2bb 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AttachmentRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/attachment/AttachmentRemoteDataSourceImpl.kt @@ -1,24 +1,13 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.attachment -import android.content.Context -import android.database.Cursor -import android.net.Uri -import android.provider.MediaStore import android.util.Log import com.xquare.data.remote.api.AttachmentApi -import com.xquare.data.remote.request.FileRequest import com.xquare.data.remote.response.attachment.toEntity import com.xquare.data.sendHttpRequest import com.xquare.domain.entity.attachment.FileEntity -import okhttp3.MediaType -import okhttp3.MediaType.Companion.get -import okhttp3.MediaType.Companion.parse import okhttp3.MediaType.Companion.toMediaType -import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody -import okhttp3.RequestBody import okhttp3.RequestBody.Companion.asRequestBody -import okhttp3.RequestBody.Companion.toRequestBody import java.io.File import javax.inject.Inject diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSource.kt similarity index 88% rename from data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSource.kt index d1514175..d154ddcb 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.auth import com.xquare.domain.entity.auth.SignInEntity import com.xquare.domain.entity.auth.SignUpEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSourceImpl.kt similarity index 97% rename from data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSourceImpl.kt index b142552d..82d1340a 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/AuthRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/auth/AuthRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.auth import com.xquare.data.remote.api.AuthApi import com.xquare.data.remote.api.ProfileApi diff --git a/data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSource.kt similarity index 86% rename from data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSource.kt index 9df14588..4cf26527 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.meal import com.xquare.domain.entity.meal.AllMealEntity import com.xquare.domain.entity.meal.MealEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSourceImpl.kt similarity index 91% rename from data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSourceImpl.kt index 17703fa7..1f542689 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/MealRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/meal/MealRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.meal import com.xquare.data.remote.api.MealApi import com.xquare.data.remote.response.meal.toEntity @@ -6,7 +6,6 @@ import com.xquare.data.sendHttpRequest import com.xquare.domain.entity.meal.AllMealEntity import com.xquare.domain.entity.meal.MealEntity import org.threeten.bp.LocalDate -import java.time.LocalDateTime import javax.inject.Inject class MealRemoteDataSourceImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSource.kt similarity index 92% rename from data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSource.kt index 3320a4a0..78d2e671 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.pick import com.xquare.domain.entity.pick.ClassPositionEntity import com.xquare.domain.entity.pick.PassDataEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSourceImpl.kt similarity index 94% rename from data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSourceImpl.kt index 6b5f00e9..8aa5cd69 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/PickRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/pick/PickRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.pick import com.xquare.data.remote.api.PickApi import com.xquare.data.remote.response.pick.toEntity @@ -7,7 +7,6 @@ import com.xquare.domain.entity.pick.ClassPositionEntity import com.xquare.domain.entity.pick.PassDataEntity import com.xquare.domain.entity.pick.PassTimeEntity import com.xquare.domain.entity.pick.TodaySelfStudyTeacherEntity -import kotlinx.coroutines.flow.Flow import javax.inject.Inject class PickRemoteDataSourceImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSource.kt similarity index 85% rename from data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSource.kt index 46b26c1e..7233f52b 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.point import com.xquare.domain.entity.point.PointHistoriesEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSourceImpl.kt similarity index 89% rename from data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSourceImpl.kt index 1530503e..774d81d8 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/PointRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/point/PointRemoteDataSourceImpl.kt @@ -1,10 +1,9 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.point import com.xquare.data.remote.api.PointApi import com.xquare.data.remote.response.point.toEntity import com.xquare.data.sendHttpRequest import com.xquare.domain.entity.point.PointHistoriesEntity -import com.xquare.domain.entity.point.PointSummaryEntity import javax.inject.Inject class PointRemoteDataSourceImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSource.kt similarity index 82% rename from data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSource.kt index b9e9eade..30bfd389 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.report import com.xquare.domain.entity.reports.BugEntity import com.xquare.domain.entity.reports.ReleaseEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSourceImpl.kt similarity index 90% rename from data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSourceImpl.kt index 64a7de0d..ca98b7c2 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/ReportRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/report/ReportRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.report import com.xquare.data.remote.api.ReportsApi import com.xquare.data.remote.request.reports.toRequest @@ -10,7 +10,7 @@ import javax.inject.Inject class ReportRemoteDataSourceImpl @Inject constructor( private val reportsApi: ReportsApi -): ReportRemoteDataSource{ +): ReportRemoteDataSource { override suspend fun uploadBug(bugEntity: BugEntity) = sendHttpRequest(httpRequest = { reportsApi.uploadBug(bugEntity.toRequest()) }) diff --git a/data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSource.kt similarity index 89% rename from data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSource.kt index f0757869..583d047c 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.schedules import com.xquare.domain.entity.schedules.SchedulesEntity import com.xquare.domain.entity.schedules.CreateSchedulesEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSourceImpl.kt similarity index 96% rename from data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSourceImpl.kt index 5a2fffc0..2cbc63ff 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/SchedulesRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/schedules/SchedulesRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.schedules import com.xquare.data.remote.api.SchedulesApi import com.xquare.data.remote.request.schedules.toRequest diff --git a/data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSource.kt similarity index 84% rename from data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSource.kt index 8af6f2fd..4c30dc0d 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.timetable import com.xquare.domain.entity.timetables.DayTimetableEntity import com.xquare.domain.entity.timetables.TimetableEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSourceImpl.kt similarity index 94% rename from data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSourceImpl.kt index 3875fc16..258a7229 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/TimetablesRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/timetable/TimetablesRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.timetable import android.os.Build import androidx.annotation.RequiresApi diff --git a/data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSource.kt similarity index 74% rename from data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSource.kt index 039f61a6..0a11ae73 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.user import com.xquare.domain.entity.profile.ProfileEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSourceImpl.kt similarity index 91% rename from data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSourceImpl.kt index 2ca67811..efdcfff7 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/UserRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/user/UserRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.user import com.xquare.data.remote.api.ProfileApi import com.xquare.data.remote.response.profile.toEntity diff --git a/data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSource.kt b/data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSource.kt similarity index 83% rename from data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSource.kt rename to data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSource.kt index 17b560f0..a108784a 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSource.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSource.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.user import com.xquare.domain.entity.user.HomeUserEntity import kotlinx.coroutines.flow.Flow diff --git a/data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSourceImpl.kt b/data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSourceImpl.kt similarity index 93% rename from data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSourceImpl.kt rename to data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSourceImpl.kt index c1b8106f..b5fce82b 100644 --- a/data/src/main/java/com/xquare/data/remote/datasource/UserSimpleRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/xquare/data/remote/datasource/user/UserSimpleRemoteDataSourceImpl.kt @@ -1,4 +1,4 @@ -package com.xquare.data.remote.datasource +package com.xquare.data.remote.datasource.user import com.xquare.data.remote.api.UserApi import com.xquare.data.remote.request.user.ProfileImageRequest diff --git a/data/src/main/java/com/xquare/data/repository/AuthRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/AuthRepositoryImpl.kt index 748fc026..ee9c5954 100644 --- a/data/src/main/java/com/xquare/data/repository/AuthRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/AuthRepositoryImpl.kt @@ -2,7 +2,7 @@ package com.xquare.data.repository import com.xquare.data.local.datasource.AuthLocalDataSource import com.xquare.data.local.preference.AuthPreference -import com.xquare.data.remote.datasource.AuthRemoteDataSource +import com.xquare.data.remote.datasource.auth.AuthRemoteDataSource import com.xquare.domain.AppCookieManager import com.xquare.domain.entity.auth.SignInEntity import com.xquare.domain.entity.auth.SignUpEntity diff --git a/data/src/main/java/com/xquare/data/repository/PointRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/PointRepositoryImpl.kt index 648733a0..ecf95528 100644 --- a/data/src/main/java/com/xquare/data/repository/PointRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/PointRepositoryImpl.kt @@ -1,9 +1,8 @@ package com.xquare.data.repository -import com.xquare.data.fetchDataWithOfflineCache import com.xquare.data.fetchPointWithOfflineCache import com.xquare.data.local.datasource.PointLocalDataSource -import com.xquare.data.remote.datasource.PointRemoteDataSource +import com.xquare.data.remote.datasource.point.PointRemoteDataSource import com.xquare.domain.entity.point.PointHistoriesEntity import com.xquare.domain.repository.PointRepository import kotlinx.coroutines.flow.Flow diff --git a/data/src/main/java/com/xquare/data/repository/WebViewRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/WebViewRepositoryImpl.kt index 400ea779..a3f23173 100644 --- a/data/src/main/java/com/xquare/data/repository/WebViewRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/WebViewRepositoryImpl.kt @@ -1,7 +1,7 @@ package com.xquare.data.repository import com.xquare.data.local.datasource.AuthLocalDataSource -import com.xquare.data.remote.datasource.AuthRemoteDataSource +import com.xquare.data.remote.datasource.auth.AuthRemoteDataSource import com.xquare.domain.repository.WebViewRepository import javax.inject.Inject diff --git a/data/src/main/java/com/xquare/data/repository/attachment/AttachmentRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/attachment/AttachmentRepositoryImpl.kt index 0b97e7e3..eeb62c4f 100644 --- a/data/src/main/java/com/xquare/data/repository/attachment/AttachmentRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/attachment/AttachmentRepositoryImpl.kt @@ -1,6 +1,6 @@ package com.xquare.data.repository.attachment -import com.xquare.data.remote.datasource.AttachmentRemoteDataSource +import com.xquare.data.remote.datasource.attachment.AttachmentRemoteDataSource import com.xquare.domain.entity.attachment.FileEntity import com.xquare.domain.repository.attachment.AttachmentRepository import java.io.File diff --git a/data/src/main/java/com/xquare/data/repository/meal/MealRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/meal/MealRepositoryImpl.kt index e964781c..6eee5a4f 100644 --- a/data/src/main/java/com/xquare/data/repository/meal/MealRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/meal/MealRepositoryImpl.kt @@ -2,16 +2,12 @@ package com.xquare.data.repository.meal import com.xquare.data.fetchDataWithOfflineCache import com.xquare.data.local.datasource.MealLocalDataSource -import com.xquare.data.remote.datasource.MealRemoteDataSource +import com.xquare.data.remote.datasource.meal.MealRemoteDataSource import com.xquare.data.today import com.xquare.domain.entity.meal.AllMealEntity import com.xquare.domain.entity.meal.MealEntity import com.xquare.domain.repository.meal.MealRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import org.threeten.bp.LocalDate -import org.threeten.bp.LocalDateTime -import org.threeten.bp.format.DateTimeFormatter import javax.inject.Inject class MealRepositoryImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/repository/notification/AlarmRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/notification/AlarmRepositoryImpl.kt index 53d12edc..6707524f 100644 --- a/data/src/main/java/com/xquare/data/repository/notification/AlarmRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/notification/AlarmRepositoryImpl.kt @@ -1,13 +1,9 @@ package com.xquare.data.repository.notification -import com.xquare.data.fetchDataWithOfflineCache -import com.xquare.data.local.datasource.AlarmLocalDataSource -import com.xquare.data.remote.datasource.AlarmRemoteDataSource -import com.xquare.domain.entity.notification.ActivateAlarmEntity +import com.xquare.data.remote.datasource.alarm.AlarmRemoteDataSource import com.xquare.domain.entity.notification.AlarmCategoriesEntity import com.xquare.domain.entity.notification.AlarmEntity import com.xquare.domain.repository.notification.AlarmRepository -import kotlinx.coroutines.flow.Flow import javax.inject.Inject class AlarmRepositoryImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/repository/pick/PickRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/pick/PickRepositoryImpl.kt index 03ef7c07..c8fb022e 100644 --- a/data/src/main/java/com/xquare/data/repository/pick/PickRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/pick/PickRepositoryImpl.kt @@ -1,14 +1,12 @@ package com.xquare.data.repository.pick -import com.xquare.data.fetchDataWithOfflineCache -import com.xquare.data.remote.datasource.PickRemoteDataSource +import com.xquare.data.remote.datasource.pick.PickRemoteDataSource import com.xquare.data.today import com.xquare.domain.entity.pick.ClassPositionEntity import com.xquare.domain.entity.pick.PassDataEntity import com.xquare.domain.entity.pick.PassTimeEntity import com.xquare.domain.entity.pick.TodaySelfStudyTeacherEntity import com.xquare.domain.repository.pick.PickRepository -import kotlinx.coroutines.flow.Flow import javax.inject.Inject class PickRepositoryImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/repository/reports/ReportRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/reports/ReportRepositoryImpl.kt index 27a42ff8..5993f639 100644 --- a/data/src/main/java/com/xquare/data/repository/reports/ReportRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/reports/ReportRepositoryImpl.kt @@ -1,6 +1,6 @@ package com.xquare.data.repository.reports -import com.xquare.data.remote.datasource.ReportRemoteDataSource +import com.xquare.data.remote.datasource.report.ReportRemoteDataSource import com.xquare.domain.entity.reports.BugEntity import com.xquare.domain.entity.reports.ReleaseEntity import com.xquare.domain.repository.reports.ReportRepository diff --git a/data/src/main/java/com/xquare/data/repository/schedules/SchedulesRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/schedules/SchedulesRepositoryImpl.kt index fafccf00..b0018bdf 100644 --- a/data/src/main/java/com/xquare/data/repository/schedules/SchedulesRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/schedules/SchedulesRepositoryImpl.kt @@ -1,13 +1,11 @@ package com.xquare.data.repository.schedules -import com.xquare.data.fetchDataWithOfflineCache -import com.xquare.data.remote.datasource.SchedulesRemoteDataSource +import com.xquare.data.remote.datasource.schedules.SchedulesRemoteDataSource import com.xquare.data.today import com.xquare.domain.entity.schedules.SchedulesEntity import com.xquare.domain.entity.schedules.CreateSchedulesEntity import com.xquare.domain.entity.schedules.FixSchedulesEntity import com.xquare.domain.repository.schedules.SchedulesRepository -import kotlinx.coroutines.flow.Flow import javax.inject.Inject class SchedulesRepositoryImpl @Inject constructor( diff --git a/data/src/main/java/com/xquare/data/repository/timetables/TimetablesRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/timetables/TimetablesRepositoryImpl.kt index 6c36ff91..11614210 100644 --- a/data/src/main/java/com/xquare/data/repository/timetables/TimetablesRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/timetables/TimetablesRepositoryImpl.kt @@ -2,7 +2,7 @@ package com.xquare.data.repository.timetables import com.xquare.data.fetchDataWithOfflineCache import com.xquare.data.local.datasource.TimetableLocalDataSource -import com.xquare.data.remote.datasource.TimetablesRemoteDataSource +import com.xquare.data.remote.datasource.timetable.TimetablesRemoteDataSource import com.xquare.domain.entity.timetables.TimetableEntity import com.xquare.domain.repository.timetables.TimetablesRepository import kotlinx.coroutines.flow.Flow diff --git a/data/src/main/java/com/xquare/data/repository/user/UserRepositoryImpl.kt b/data/src/main/java/com/xquare/data/repository/user/UserRepositoryImpl.kt index 0f1edf25..37c75a87 100644 --- a/data/src/main/java/com/xquare/data/repository/user/UserRepositoryImpl.kt +++ b/data/src/main/java/com/xquare/data/repository/user/UserRepositoryImpl.kt @@ -2,10 +2,9 @@ package com.xquare.data.repository.user import com.xquare.data.fetchDataWithOfflineCache import com.xquare.data.local.datasource.HomeUserLocalDataSource -import com.xquare.data.local.entity.homeUser.toRoomEntity -import com.xquare.data.remote.datasource.UserRemoteDataSource +import com.xquare.data.remote.datasource.user.UserRemoteDataSource import com.xquare.domain.entity.profile.ProfileEntity -import com.xquare.data.remote.datasource.UserSimpleRemoteDataSource +import com.xquare.data.remote.datasource.user.UserSimpleRemoteDataSource import com.xquare.domain.entity.user.HomeUserEntity import com.xquare.domain.repository.user.UserRepository import kotlinx.coroutines.flow.Flow From b072f4f08f7ba304c925a78b9adb776f13923276 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Mon, 18 Sep 2023 21:39:52 +0900 Subject: [PATCH 19/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/github/GithubDetail.kt | 196 ++++++++++++++++ .../feature/github/GithubScreen.kt | 219 ++++++------------ .../feature/github/GithubViewModel.kt | 20 +- build.gradle | 8 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 295 insertions(+), 150 deletions(-) create mode 100644 app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt new file mode 100644 index 00000000..6ef235ea --- /dev/null +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt @@ -0,0 +1,196 @@ +package com.xquare.xquare_android.feature.github + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Icon +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.painter.ColorPainter +import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import coil.compose.rememberAsyncImagePainter +import com.semicolon.design.Body1 +import com.semicolon.design.Body2 +import com.semicolon.design.Body3 +import com.semicolon.design.Subtitle4 +import com.semicolon.design.color.primary.gray.gray200 +import com.semicolon.design.color.primary.gray.gray50 +import com.semicolon.design.color.primary.gray.gray700 +import com.semicolon.design.color.primary.gray.gray900 +import com.semicolon.design.color.primary.purple.purple200 +import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity +import com.xquare.xquare_android.R +import java.text.DecimalFormat + +fun formatNumberWithComma(number: Int): String { + val decimalFormat = DecimalFormat("#,###") + return decimalFormat.format(number) +} + +@Composable +fun GithubRankingItem( + githubInformation: GithubInformationEntity?, + borderState: Boolean, +) { + val borderColor = if (borderState) purple200 else gray50 + Row( + modifier = Modifier + .fillMaxWidth() + .height(74.dp) + .background(color = gray50, shape = RoundedCornerShape(12.dp)) + .border(width = 1.dp, color = borderColor, shape = RoundedCornerShape(12.dp)) + .padding(start = 15.dp, end = 20.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Image( + painter = rememberAsyncImagePainter( + model = githubInformation?.profile_file_name, + placeholder = ColorPainter(gray200), + error = painterResource(id = R.drawable.ic_profile_default) + ), + contentDescription = null, + modifier = Modifier + .size(50.dp) + .clip(RoundedCornerShape(30.dp)), + ) + Spacer(Modifier.size(10.dp)) + Column { + Body2(text = "${githubInformation?.ranking}위 : ${githubInformation?.name}", fontWeight = FontWeight.Medium, color = gray900) + Body3(text = "@${githubInformation?.username}", fontWeight = FontWeight.Normal, color = gray700) + } + Spacer(Modifier.weight(1f)) + Box( + modifier = Modifier + .width(80.dp) + .height(40.dp) + .padding(bottom = 5.dp) + ) { + Body1( + text = "${githubInformation?.contributions?.let { formatNumberWithComma(it) }} 커밋", + fontWeight = FontWeight.Medium, + color = gray900, + modifier = Modifier.align(Alignment.Center) + ) + } + } +} + +@Composable +fun GithubItem( + githubList: GithubListEntity.GithubUserListEntity, + modifier: Modifier = Modifier, + crown: Painter, + color: Color, + centerPadding: Dp, + tint: Color, + image: Dp +) { + + Column( + modifier = modifier + .background(gray50, RoundedCornerShape(12.dp)) + .border(width = 1.dp, color = color, shape = RoundedCornerShape(12.dp)), + horizontalAlignment = Alignment.CenterHorizontally + ) { + + Column( + Modifier.padding(top = 10.dp, bottom = 10.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Box { + Icon( + painter = crown, + contentDescription = null, + modifier = Modifier.align(Alignment.TopCenter), + tint = tint + ) + Image( + painter = rememberAsyncImagePainter( + model = githubList.profile_file_name, + placeholder = ColorPainter(gray200), + error = painterResource(id = R.drawable.ic_profile_default) + ), + contentScale = ContentScale.Crop, + contentDescription = null, + modifier = Modifier + .padding(top = (15.5).dp) + .size(image) + .clip(RoundedCornerShape(30.dp)), + ) + } + Spacer(Modifier.height(centerPadding)) + Subtitle4(text = githubList.name, color = gray900, fontWeight = FontWeight.SemiBold) + Body3(text = " @${githubList.username}", color = gray700, fontWeight = FontWeight.Normal) + Body3(text = "${formatNumberWithComma(githubList.contributions)} 커밋", color = gray900, fontWeight = FontWeight.Medium) + } + } +} + +@Composable +fun GithubAllRankingItem( + githubList: GithubListEntity.GithubUserListEntity, + borderState: Boolean, +) { + val borderColor = if (borderState) purple200 else gray50 + Row( + modifier = Modifier + .fillMaxWidth() + .height(74.dp) + .background(color = gray50, shape = RoundedCornerShape(12.dp)) + .border(width = 1.dp, color = borderColor, shape = RoundedCornerShape(12.dp)) + .padding(start = 15.dp, end = 20.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Image( + painter = rememberAsyncImagePainter( + model = githubList.profile_file_name, + error = painterResource(id = R.drawable.ic_profile_default) + ), + contentScale = ContentScale.Crop, + contentDescription = null, + modifier = Modifier + .size(50.dp) + .clip(RoundedCornerShape(30.dp)), + ) + Spacer(Modifier.size(10.dp)) + Column { + Body2(text = "${githubList.ranking}위 : ${githubList.name}", fontWeight = FontWeight.Medium, color = gray900) + Body3(text = "@${githubList.username}", fontWeight = FontWeight.Normal, color = gray700) + } + Spacer(Modifier.weight(1f)) + Box( + modifier = Modifier + .width(80.dp) + .height(40.dp) + .padding(bottom = 5.dp) + ) { + Body1( + text = "${formatNumberWithComma(githubList.contributions)} 커밋", + fontWeight = FontWeight.Medium, + color = gray900, + modifier = Modifier + .align(Alignment.Center) + ) + } + } + Spacer(Modifier.size(12.dp)) +} diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt index 562668aa..8869ea79 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer @@ -14,6 +15,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Icon import androidx.compose.material.Scaffold @@ -27,19 +29,25 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.painter.ColorPainter import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController +import coil.compose.rememberAsyncImagePainter +import com.google.accompanist.pager.ExperimentalPagerApi +import com.google.accompanist.pager.HorizontalPager +import com.google.accompanist.pager.VerticalPager +import com.google.accompanist.pager.rememberPagerState import com.semicolon.design.Body1 import com.semicolon.design.Body2 import com.semicolon.design.Body3 import com.semicolon.design.Subtitle4 +import com.semicolon.design.color.primary.gray.gray200 import com.semicolon.design.color.primary.gray.gray50 import com.semicolon.design.color.primary.gray.gray700 import com.semicolon.design.color.primary.gray.gray900 @@ -64,20 +72,31 @@ fun GithubScreen( var information: GithubInformationEntity? by remember { mutableStateOf(null) } var githubList: GithubListEntity? by remember { mutableStateOf(null) } - LaunchedEffect(Unit){ + + LaunchedEffect(Unit) { viewModel.fetchInformation() - viewModel.eventFlow.collect(){ - when(it){ + viewModel.fetchUserList() + viewModel.eventFlow.collect() { + when (it) { is GithubViewModel.Event.InformationSuccess -> { information = it.data } - is GithubViewModel.Event.Failure -> { - makeToast(context, "Github 정보를 불러오기에 실패했습니다.") + + is GithubViewModel.Event.GithubInformationFailure -> { + makeToast(context, "내 정보를 불러오기에 실패했습니다.") + } + + is GithubViewModel.Event.GithubUserListFailure -> { + makeToast(context, "Github List를 불러오는데 실패했습니다.") } + is GithubViewModel.Event.UserListSuccess -> { + githubList = it.list + } } } } + Github( githubInformation = information, githubList = githubList, @@ -85,12 +104,15 @@ fun GithubScreen( } +@OptIn(ExperimentalPagerApi::class) @Composable fun Github( githubList: GithubListEntity?, githubInformation: GithubInformationEntity?, onBack: () -> Unit, ) { + val lazyListState = rememberLazyListState() + Scaffold( modifier = Modifier .background(white) @@ -115,154 +137,65 @@ fun Github( ), ) { Spacer(modifier = Modifier.size(20.dp)) - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp), - verticalAlignment = Alignment.Bottom, - horizontalArrangement = Arrangement.spacedBy(12.dp), - ) { - GithubItem( - modifier = Modifier.weight(1f), - crown = painterResource(id = R.drawable.ic_github_crown), - profile = painterResource(id = R.drawable.ic_profile_default), - name = "김연우", - id = "@yeon0821", - commit = "1,828커밋", - color = Silver, - centerPadding = 15.dp, - tint = Silver - ) - GithubItem( - modifier = Modifier.weight(1f), - crown = painterResource(id = R.drawable.ic_github_crown), - profile = painterResource(id = R.drawable.ic_profile_default), - name = "박준수", - id = "@junjaㅈboy", - commit = "18,181커밋", - color = Gold, - centerPadding = 30.dp, - tint = Gold - ) - GithubItem( - modifier = Modifier.weight(1f), - crown = painterResource(id = R.drawable.ic_github_crown), - profile = painterResource(id = R.drawable.ic_profile_default), - name = "정승훈", - id = "@Tmdhoon2", - commit = "1,818커밋", - color = Bronze, - centerPadding = 1.dp, - tint = Bronze - ) + githubList?.run { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + verticalAlignment = Alignment.Bottom, + horizontalArrangement = Arrangement.spacedBy(12.dp), + ) { + GithubItem( + modifier = Modifier.weight(1f), + githubList = githubList.users[1], + crown = painterResource(id = R.drawable.ic_github_crown), + color = Silver, + centerPadding = 10.dp, + tint = Silver, + image = 34.dp + ) + GithubItem( + modifier = Modifier.weight(1f), + githubList = githubList.users[0], + crown = painterResource(id = R.drawable.ic_github_crown), + color = Gold, + centerPadding = 25.dp, + tint = Gold, + image = 44.dp + ) + GithubItem( + modifier = Modifier.weight(1f), + githubList = githubList.users[2], + crown = painterResource(id = R.drawable.ic_github_crown), + color = Bronze, + centerPadding = 8.dp, + tint = Bronze, + image = 34.dp + ) + } } Spacer(Modifier.size(17.dp)) Body1(text = "나의 순위", color = gray900, fontWeight = FontWeight.Bold) Spacer(Modifier.size(16.dp)) GithubRankingItem( - ranking = "2위", - profile = painterResource(id = R.drawable.ic_profile_default), - name = "김연우", - id = "@yeon0821", - commit = "1,828 커밋", + githubInformation = githubInformation, borderState = true ) Spacer(Modifier.size(16.dp)) Body1(text = "전체 순위", color = gray900, fontWeight = FontWeight.Bold) Spacer(Modifier.size(16.dp)) - LazyColumn() { - //TODO(준수님이 해주시겠죠?) - } - } - } -} - -@Composable -private fun GithubRankingItem( - ranking: String, - profile: Painter, - name: String, - id: String, - commit: String, - borderState: Boolean, -) { - val borderColor = if (borderState) purple200 else gray50 - Row( - modifier = Modifier - .fillMaxWidth() - .height(74.dp) - .background(color = gray50, shape = RoundedCornerShape(12.dp)) - .border(width = 1.dp, color = borderColor, shape = RoundedCornerShape(12.dp)) - .padding(start = 25.dp, end = 20.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Body2(text = ranking, fontWeight = FontWeight.Normal, color = gray900) - Spacer(Modifier.size(15.dp)) - Image( - painter = profile, - contentDescription = null, - modifier = Modifier - .size(50.dp) - .clip(RoundedCornerShape(30.dp)), - ) - Spacer(Modifier.size(10.dp)) - Column { - Body2(text = name, fontWeight = FontWeight.Medium, color = gray900) - Body3(text = id, fontWeight = FontWeight.Normal, color = gray700) - } - Body1( - text = commit, - fontWeight = FontWeight.SemiBold, - color = gray900, - modifier = Modifier.padding(start = 25.dp) - ) - } -} - -@Composable -private fun RowScope.GithubItem( - modifier: Modifier = Modifier, - crown: Painter, - profile: Painter, - name: String, - id: String, - commit: String, - color: Color, - centerPadding: Dp, - tint: Color -) { - Column( - modifier = modifier - .background(gray50, RoundedCornerShape(12.dp)) - .border(width = 1.dp, color = color, shape = RoundedCornerShape(12.dp)), - horizontalAlignment = Alignment.CenterHorizontally - ) { - - Column( - Modifier.padding(top = 10.dp, bottom = 10.dp), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Box { - Icon( - painter = crown, - contentDescription = null, - modifier = Modifier.align(Alignment.TopCenter), - tint = tint - ) - Image( - painter = profile, - contentDescription = null, - modifier = Modifier - .padding(top = (15.5).dp) - .size(44.dp) - .clip(RoundedCornerShape(30.dp)), - ) + githubList?.run { + LazyColumn( + state = lazyListState + ) { + items(githubList.users.count()) { + GithubAllRankingItem( + githubList = githubList.users[it], + borderState = false + ) + } + } } - Spacer(Modifier.height(centerPadding)) - Subtitle4(text = name, color = gray900, fontWeight = FontWeight.SemiBold) - Body3(text = id, color = gray700, fontWeight = FontWeight.Normal) - Body3(text = commit, color = gray900, fontWeight = FontWeight.Normal) } } } - diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt index e6013c10..43f1c33d 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubViewModel.kt @@ -1,6 +1,7 @@ package com.xquare.xquare_android.feature.github import com.xquare.domain.entity.github.GithubInformationEntity +import com.xquare.domain.entity.github.GithubListEntity import com.xquare.domain.entity.github.GithubOAuthCheckEntity import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.usecase.github.FetchGithubInformationUseCase @@ -15,6 +16,8 @@ import javax.inject.Inject class GithubViewModel @Inject constructor( private val fetchGithubInformationUseCase: FetchGithubInformationUseCase, private val fetchGithubListUseCase: FetchGithubListUseCase, + + ) : BaseViewModel() { @@ -22,9 +25,18 @@ class GithubViewModel @Inject constructor( execute( job = { fetchGithubInformationUseCase.execute(Unit) }, onSuccess = { emitEvent(Event.InformationSuccess(it)) }, - onFailure = { emitEvent(Event.Failure) } + onFailure = { emitEvent(Event.GithubInformationFailure) } + ) + + + fun fetchUserList() = + execute( + job = { fetchGithubListUseCase.execute(Unit)}, + onSuccess = { emitEvent(Event.UserListSuccess(it))}, + onFailure = { emitEvent(Event.GithubUserListFailure)} ) +// fun fetch sealed class Event { @@ -33,7 +45,11 @@ class GithubViewModel @Inject constructor( data class InformationSuccess(val data: GithubInformationEntity) : Event() - object Failure : Event() + data class UserListSuccess(val list: GithubListEntity): Event() + + object GithubInformationFailure : Event() + + object GithubUserListFailure: Event() } diff --git a/build.gradle b/build.gradle index b26719a0..5dbff658 100644 --- a/build.gradle +++ b/build.gradle @@ -5,16 +5,16 @@ buildscript { hilt_version = '2.40.1' } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" classpath 'com.google.gms:google-services:4.3.15' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false - id 'org.jetbrains.kotlin.android' version '1.5.21' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false + id 'org.jetbrains.kotlin.android' version '1.6.21' apply false } task clean(type: Delete) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 278d419f..e85ecd86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat May 07 03:01:39 KST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From a5bed1cf7a60d6826209a5450b837bd9f37b5843 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Tue, 19 Sep 2023 19:42:11 +0900 Subject: [PATCH 20/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/xquare_android/MainActivity.kt | 25 +++++++------ .../xquare_android/XquareApplication.kt | 2 - .../feature/profile/ProfileScreen.kt | 37 ++++++++++--------- .../feature/profile/ProfileViewModel.kt | 17 ++++++++- 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index 510190a8..c6304965 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -62,6 +62,17 @@ import kotlin.math.log @AndroidEntryPoint class MainActivity : ComponentActivity() { + + private fun getCode(intent: Intent): String? { + val data: Uri? = intent.data + val action: String? = intent.action + Log.d("TAG", "getCode: ${data?.getQueryParameter("code")}") + + return if (action == Intent.ACTION_VIEW) { + data?.getQueryParameter("code") + } else { null } + } + @RequiresApi(Build.VERSION_CODES.O) override fun onCreate(savedInstanceState: Bundle?) { setStatusBarTransparent() @@ -69,8 +80,6 @@ class MainActivity : ComponentActivity() { DevicePaddings.navigationBarHeightDp = getNavigationBarHeightDp() super.onCreate(savedInstanceState) saveDeviceToken(this) - getCode(intent) - setContent { Thread.setDefaultUncaughtExceptionHandler( XquareExceptionHandler( @@ -79,6 +88,7 @@ class MainActivity : ComponentActivity() { ) BaseApp() } + getCode(intent) } } @@ -299,13 +309,6 @@ fun Context.getActivity(): ComponentActivity? = when (this) { else -> null } -fun getCode(intent: Intent): String? { - val data: Uri? = intent.data - val action: String? = intent.action - Log.d("TAG", "getCode: ${data?.getQueryParameter("code")}") - if (action == Intent.ACTION_VIEW) { - data?.getQueryParameter("code") - } - return null -} + + diff --git a/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt b/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt index c09424a2..422ac1b5 100644 --- a/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt +++ b/app/src/main/java/com/xquare/xquare_android/XquareApplication.kt @@ -16,12 +16,10 @@ class XquareApplication : Application() { super.onCreate() AndroidThreeTen.init(this) FirebaseApp.initializeApp(this) - val sharedPrefs = getSharedPreferences("token", Context.MODE_PRIVATE) // 데이터 모두 삭제 sharedPrefs.edit().clear().apply() saveDeviceToken(this) clearCache(this) - getCode(intent = Intent()) } } diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index bdd8ce1a..dad541e0 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -3,6 +3,7 @@ package com.xquare.xquare_android.feature.profile import android.app.Activity import android.content.Intent import android.net.Uri +import android.util.Log import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.Image @@ -40,7 +41,6 @@ import com.xquare.domain.entity.profile.ProfileEntity import com.xquare.xquare_android.R import com.xquare.xquare_android.component.CenterAppBar import com.xquare.xquare_android.component.modal.ConfirmModal -import com.xquare.xquare_android.getCode import com.xquare.xquare_android.navigation.AppNavigationItem import com.xquare.xquare_android.util.DevicePaddings import com.xquare.xquare_android.util.makeToast @@ -53,8 +53,12 @@ fun ProfileScreen(navController: NavController) { val context = LocalContext.current val viewModel: ProfileViewModel = hiltViewModel() var profile: ProfileEntity? by remember { mutableStateOf(null) } + var githubOAuth: GithubOAuthEntity? by remember { mutableStateOf(null) } + LaunchedEffect(Unit) { viewModel.fetchProfile() + viewModel.fetchOAuthCheck() + githubOAuth?.let { viewModel.fetchOAuth(it) } viewModel.eventFlow.collect { when (it) { is ProfileViewModel.Event.Success -> { @@ -81,9 +85,8 @@ fun ProfileScreen(navController: NavController) { makeToast(context, "이미지를 변경하지 못했습니다") } - is ProfileViewModel.Event.OAuthCheckSuccess -> { - viewModel.fetchOAuthCheck() - makeToast(context, "Github 계정연동에 성공하셨습니다.") + is ProfileViewModel.Event.OAuthConnected -> { + makeToast(context, "Github 계정연동 되어있습니다.") } is ProfileViewModel.Event.OAuthSuccess -> { @@ -97,6 +100,10 @@ fun ProfileScreen(navController: NavController) { } } } + + ProfileViewModel.Event.OAuthNotConnected -> { + makeToast(context, "Github 계정연동에 되어있지않습니다.") + } } } } @@ -114,7 +121,6 @@ fun ProfileScreen(navController: NavController) { private fun Profile( profile: ProfileEntity?, onBackPress: () -> Unit, -// onOAuthClick: (GithubOAuthEntity) -> Unit, sendImage: (File) -> Unit, viewModel: ProfileViewModel, ) { @@ -122,8 +128,9 @@ private fun Profile( var galleryState by remember { mutableStateOf(false) } var logoutDialogState by remember { mutableStateOf(false) } val gitMenuList = listOf("계정 연동") - var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf( GithubOAuthCheckEntity(is_connected = false)) } + var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf(GithubOAuthCheckEntity(false)) } val accountMenuList = listOf("로그아웃") + var isButtonClickable by remember { mutableStateOf(true) } val openWebViewGallery = rememberLauncherForActivityResult( ActivityResultContracts.StartActivityForResult() @@ -135,6 +142,8 @@ private fun Profile( } galleryState = false } + + val openGalleryLauncher = Intent(Intent.ACTION_PICK).apply { this.type = "image/*" @@ -271,8 +280,7 @@ private fun Profile( gitMenuList.forEachIndexed { index, text -> ButtonColumnMenu( text = "Github 연동", - onClick = - { + onClick = { val intent = Intent( Intent.ACTION_VIEW, Uri.parse("https://github.com/login/oauth/authorize?client_id=7ba1da5afd9b182e9793") @@ -332,12 +340,11 @@ private fun ColumnMenu(text: String, onClick: () -> Unit) { @Composable private fun ButtonColumnMenu( text: String, - onClick: (GithubOAuthEntity) -> Unit, + onClick: () -> Unit, is_connected: Boolean, ) { val textColor = if (is_connected) purple200 else white val buttonColor = if (is_connected) purple50 else purple300 - val intent:Intent = Intent() Box( modifier = Modifier .padding(top = 12.dp, bottom = 12.dp) @@ -345,7 +352,7 @@ private fun ButtonColumnMenu( interactionSource = MutableInteractionSource(), indication = null, enabled = true - ) { onClick(GithubOAuthEntity(getCode(intent).toString())) } + ) { onClick() } .fillMaxWidth() .height(52.dp) .background(gray50, RoundedCornerShape(12.dp)), @@ -366,18 +373,14 @@ private fun ButtonColumnMenu( modifier = Modifier .size(80.dp, 38.dp) .clip(RoundedCornerShape(8.dp)) - .clickable { - onClick(GithubOAuthEntity(getCode(intent).toString())) - } .background(buttonColor), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center ) { - if (is_connected){ + if (is_connected) { Text(text = "연동됨", color = textColor) - } - else Text(text = "연동하기", color = textColor ) + } else Text(text = "연동하기", color = textColor) } } } diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt index ffb8ddb8..773bf922 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt @@ -1,6 +1,7 @@ package com.xquare.xquare_android.feature.profile import android.util.Log +import androidx.compose.runtime.Composable import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.entity.profile.ProfileEntity @@ -69,7 +70,17 @@ class ProfileViewModel @Inject constructor( fun fetchOAuthCheck() = execute( job = { fetchGithubOAuthCheckUseCase.execute(Unit) }, - onSuccess = { emitEvent(Event.OAuthCheckSuccess) }, + onSuccess = { + val success = it.is_connected + Log.d("TAG", "fetchOAuthCheck: $success") + emitEvent( + if (success) { + Event.OAuthConnected + } else { + Event.OAuthNotConnected + }, + ) + }, onFailure = { emitEvent(Event.Failure) } ) @@ -79,7 +90,9 @@ class ProfileViewModel @Inject constructor( data class Success(val data: ProfileEntity) : Event() object Failure : Event() - object OAuthCheckSuccess : Event() + object OAuthConnected : Event() + + object OAuthNotConnected: Event() data class OAuthSuccess(val data: GithubOAuthEntity) : Event() data class UploadFileSuccess(val data: List) : Event() From 014d1dc7f8d33abd9ea3808b9c29fc1dc5824296 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Wed, 20 Sep 2023 21:25:59 +0900 Subject: [PATCH 21/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20MainActivityVie?= =?UTF-8?q?wModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/xquare_android/MainActivity.kt | 13 +++++++++ .../xquare_android/MainActivityVIewModel.kt | 28 +++++++++++++++++++ .../feature/profile/ProfileScreen.kt | 5 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index c6304965..81073372 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -20,6 +20,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.lifecycle.ViewModelProvider import androidx.navigation.NavController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable @@ -28,6 +29,7 @@ import com.google.firebase.FirebaseApp import com.google.firebase.messaging.FirebaseMessaging import com.google.gson.Gson import com.semicolon.design.color.primary.white.white +import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.entity.schedules.SchedulesEntity import com.xquare.xquare_android.component.BottomNavigation import com.xquare.xquare_android.feature.alarm.AlarmScreen @@ -54,6 +56,7 @@ import com.xquare.xquare_android.navigation.AppNavigationItem import com.xquare.xquare_android.navigation.BottomNavigationItem import com.xquare.xquare_android.util.* import dagger.hilt.android.AndroidEntryPoint +import org.openjdk.tools.javac.Main import java.io.File import java.net.URLDecoder import java.nio.charset.StandardCharsets @@ -63,6 +66,13 @@ import kotlin.math.log @AndroidEntryPoint class MainActivity : ComponentActivity() { + private val mainActivityVIewModel: MainActivityVIewModel by lazy { + ViewModelProvider(this)[MainActivityVIewModel::class.java] + } + + + private val githubOAuthEntity: GithubOAuthEntity = GithubOAuthEntity(getCode(intent).toString()) + private fun getCode(intent: Intent): String? { val data: Uri? = intent.data val action: String? = intent.action @@ -73,6 +83,7 @@ class MainActivity : ComponentActivity() { } else { null } } + @RequiresApi(Build.VERSION_CODES.O) override fun onCreate(savedInstanceState: Bundle?) { setStatusBarTransparent() @@ -80,6 +91,8 @@ class MainActivity : ComponentActivity() { DevicePaddings.navigationBarHeightDp = getNavigationBarHeightDp() super.onCreate(savedInstanceState) saveDeviceToken(this) + + setContent { Thread.setDefaultUncaughtExceptionHandler( XquareExceptionHandler( diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt new file mode 100644 index 00000000..1d6e2342 --- /dev/null +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt @@ -0,0 +1,28 @@ +package com.xquare.xquare_android + +import com.xquare.domain.entity.github.GithubOAuthEntity +import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase +import com.xquare.xquare_android.base.BaseViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class MainActivityVIewModel @Inject constructor( + private val fetchGithubOAuthUseCase: FetchGithubOAuthUseCase +): BaseViewModel() { + + fun fetchGithubOAuth(githubOAuthEntity: GithubOAuthEntity) = + execute( + job = {fetchGithubOAuthUseCase.execute(githubOAuthEntity)}, + onSuccess = { emitEvent(Event.OAuthSuccess)}, + onFailure = { emitEvent(Event.OAuthFailure)} + ) + + + sealed class Event { + + object OAuthSuccess : Event() + + object OAuthFailure : Event() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index dad541e0..3851f423 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -90,7 +90,8 @@ fun ProfileScreen(navController: NavController) { } is ProfileViewModel.Event.OAuthSuccess -> { - navController.navigate(AppNavigationItem.Profile.route) + makeToast(context, "Github OAuth에 연동하셨습니다") + viewModel.fetchOAuth(it.data) } is ProfileViewModel.Event.LogoutSuccess -> { @@ -128,7 +129,7 @@ private fun Profile( var galleryState by remember { mutableStateOf(false) } var logoutDialogState by remember { mutableStateOf(false) } val gitMenuList = listOf("계정 연동") - var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf(GithubOAuthCheckEntity(false)) } + var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf(GithubOAuthCheckEntity(true)) } val accountMenuList = listOf("로그아웃") var isButtonClickable by remember { mutableStateOf(true) } val openWebViewGallery = From 54993bdf0fc8d8964094e4748542f3b80b03d8d5 Mon Sep 17 00:00:00 2001 From: Kim Yeon woo Date: Wed, 20 Sep 2023 22:02:12 +0900 Subject: [PATCH 22/29] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/xquare/xquare_android/MainActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index 81073372..faaa4f13 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -71,7 +71,6 @@ class MainActivity : ComponentActivity() { } - private val githubOAuthEntity: GithubOAuthEntity = GithubOAuthEntity(getCode(intent).toString()) private fun getCode(intent: Intent): String? { val data: Uri? = intent.data From 81cb1847b496692b01b141095b62d9d0e2a71ba1 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 09:02:42 +0900 Subject: [PATCH 23/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 30 +++++---- .../com/xquare/xquare_android/MainActivity.kt | 65 ++++++++++++------- .../xquare_android/MainActivityVIewModel.kt | 28 -------- .../xquare_android/MainActivityViewModel.kt | 37 +++++++++++ 4 files changed, 96 insertions(+), 64 deletions(-) delete mode 100644 app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt create mode 100644 app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 8ab37b43..ef229177 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,17 +1,23 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index faaa4f13..316cc19b 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -7,20 +7,19 @@ import android.net.Uri import android.os.Build import android.os.Bundle import android.util.Log +import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.viewModels import androidx.annotation.RequiresApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.padding import androidx.compose.material.Scaffold import androidx.compose.material.rememberScaffoldState import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue +import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import androidx.lifecycle.ViewModelProvider import androidx.navigation.NavController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable @@ -54,32 +53,34 @@ import com.xquare.xquare_android.feature.today_teacher.TodayTeacherScreen import com.xquare.xquare_android.feature.webview.CommonWebViewScreen import com.xquare.xquare_android.navigation.AppNavigationItem import com.xquare.xquare_android.navigation.BottomNavigationItem -import com.xquare.xquare_android.util.* +import com.xquare.xquare_android.util.DevicePaddings +import com.xquare.xquare_android.util.XquareExceptionHandler +import com.xquare.xquare_android.util.getNavigationBarHeightDp +import com.xquare.xquare_android.util.getStatusBarHeightDp +import com.xquare.xquare_android.util.setStatusBarTransparent import dagger.hilt.android.AndroidEntryPoint -import org.openjdk.tools.javac.Main import java.io.File import java.net.URLDecoder import java.nio.charset.StandardCharsets -import kotlin.math.log @AndroidEntryPoint class MainActivity : ComponentActivity() { - private val mainActivityVIewModel: MainActivityVIewModel by lazy { - ViewModelProvider(this)[MainActivityVIewModel::class.java] - } - + private val mainActivityVIewModel: MainActivityViewModel by viewModels() - private fun getCode(intent: Intent): String? { - val data: Uri? = intent.data + private fun uploadGithubOauthCodeIfExists(intent: Intent) { + val data: Uri = intent.data ?: return val action: String? = intent.action - Log.d("TAG", "getCode: ${data?.getQueryParameter("code")}") + Log.d("TAG", "getCode: ${data.getQueryParameter("code")}") - return if (action == Intent.ACTION_VIEW) { - data?.getQueryParameter("code") - } else { null } + if (action == Intent.ACTION_VIEW) { + val code = data.getQueryParameter("code") ?: return + mainActivityVIewModel.registerGithubUser( + GithubOAuthEntity(code = code) + ) + } } @@ -90,9 +91,25 @@ class MainActivity : ComponentActivity() { DevicePaddings.navigationBarHeightDp = getNavigationBarHeightDp() super.onCreate(savedInstanceState) saveDeviceToken(this) + setContent { + LaunchedEffect(Unit) { + mainActivityVIewModel.eventFlow.collect { event -> + when (event) { + MainActivityViewModel.Event.OAuthFailure -> Toast.makeText( + this@MainActivity, + "깃허브 연동에 실패하였습니다.", + Toast.LENGTH_SHORT + ).show() + MainActivityViewModel.Event.OAuthSuccess ->Toast.makeText( + this@MainActivity, + "깃허브 연동에 성공하였습니다.", + Toast.LENGTH_SHORT + ).show() - setContent { + } + } + } Thread.setDefaultUncaughtExceptionHandler( XquareExceptionHandler( context = this, @@ -100,7 +117,7 @@ class MainActivity : ComponentActivity() { ) BaseApp() } - getCode(intent) + uploadGithubOauthCodeIfExists(intent) } } @@ -158,17 +175,17 @@ fun BaseApp() { composable(AppNavigationItem.Pass.route) { PassScreen(navController) } - composable(AppNavigationItem.TodayTeacher.route){ + composable(AppNavigationItem.TodayTeacher.route) { TodayTeacherScreen(navController) } composable(AppNavigationItem.Setting.route) { SettingScreen(navController) } - composable(AppNavigationItem.ReleaseNote.route){ + composable(AppNavigationItem.ReleaseNote.route) { ReleaseScreen(navController) - + } - composable(AppNavigationItem.Github.route){ + composable(AppNavigationItem.Github.route) { GithubScreen(navController) } composable(AppNavigationItem.WriteSchedule.route) { @@ -285,7 +302,7 @@ fun saveDeviceToken(context: Context) { Log.d("TAG", "saveDeviceToken: $token") val pref = context.getSharedPreferences("token", Context.MODE_PRIVATE) val editor = pref.edit() - editor.putString("token",token).apply() + editor.putString("token", token).apply() editor.commit() Log.d("TAG", "Save Token Successfully") diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt deleted file mode 100644 index 1d6e2342..00000000 --- a/app/src/main/java/com/xquare/xquare_android/MainActivityVIewModel.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.xquare.xquare_android - -import com.xquare.domain.entity.github.GithubOAuthEntity -import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase -import com.xquare.xquare_android.base.BaseViewModel -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class MainActivityVIewModel @Inject constructor( - private val fetchGithubOAuthUseCase: FetchGithubOAuthUseCase -): BaseViewModel() { - - fun fetchGithubOAuth(githubOAuthEntity: GithubOAuthEntity) = - execute( - job = {fetchGithubOAuthUseCase.execute(githubOAuthEntity)}, - onSuccess = { emitEvent(Event.OAuthSuccess)}, - onFailure = { emitEvent(Event.OAuthFailure)} - ) - - - sealed class Event { - - object OAuthSuccess : Event() - - object OAuthFailure : Event() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt new file mode 100644 index 00000000..7d333a57 --- /dev/null +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt @@ -0,0 +1,37 @@ +package com.xquare.xquare_android + +import com.xquare.domain.entity.github.GithubOAuthEntity +import com.xquare.domain.usecase.github.FetchGithubOAuthCheckUseCase +import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase +import com.xquare.xquare_android.base.BaseViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.runBlocking +import javax.inject.Inject + +@HiltViewModel +class MainActivityViewModel @Inject constructor( + private val fetchGithubOAuthUseCase: FetchGithubOAuthUseCase, + private val fetchGithubOAuthCheckUseCase: FetchGithubOAuthCheckUseCase +) : BaseViewModel() { + + fun registerGithubUser(githubOAuthEntity: GithubOAuthEntity) { + execute( + job = { + val connected = runBlocking(Dispatchers.IO) { + fetchGithubOAuthCheckUseCase.execute(Unit).is_connected + } + if (!connected) { + fetchGithubOAuthUseCase.execute(githubOAuthEntity) + } + }, + onSuccess = { emitEvent(Event.OAuthSuccess) }, + onFailure = { emitEvent(Event.OAuthFailure) } + ) + } + + sealed class Event { + object OAuthSuccess : Event() + object OAuthFailure : Event() + } +} \ No newline at end of file From 297f81acea885bc2244cba7e4d522194f0f8bc79 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 10:43:02 +0900 Subject: [PATCH 24/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Github=20oauth?= =?UTF-8?q?=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 2 +- .../feature/profile/ProfileScreen.kt | 40 ++++++++++++------- .../feature/profile/ProfileViewModel.kt | 18 ++------- .../usecase/github/FetchGithubOAuthUseCase.kt | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index ef229177..b47414d0 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -15,7 +15,7 @@ - + diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index 3851f423..b34ec017 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -3,18 +3,30 @@ package com.xquare.xquare_android.feature.profile import android.app.Activity import android.content.Intent import android.net.Uri -import android.util.Log import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Scaffold import androidx.compose.material.Text -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -30,13 +42,14 @@ import coil.compose.rememberAsyncImagePainter import com.semicolon.design.Body1 import com.semicolon.design.Body2 import com.semicolon.design.Body3 -import com.semicolon.design.color.primary.gray.* +import com.semicolon.design.color.primary.gray.gray200 +import com.semicolon.design.color.primary.gray.gray50 +import com.semicolon.design.color.primary.gray.gray700 +import com.semicolon.design.color.primary.gray.gray900 import com.semicolon.design.color.primary.purple.purple200 import com.semicolon.design.color.primary.purple.purple300 import com.semicolon.design.color.primary.purple.purple50 import com.semicolon.design.color.primary.white.white -import com.xquare.domain.entity.github.GithubOAuthCheckEntity -import com.xquare.domain.entity.github.GithubOAuthEntity import com.xquare.domain.entity.profile.ProfileEntity import com.xquare.xquare_android.R import com.xquare.xquare_android.component.CenterAppBar @@ -53,12 +66,11 @@ fun ProfileScreen(navController: NavController) { val context = LocalContext.current val viewModel: ProfileViewModel = hiltViewModel() var profile: ProfileEntity? by remember { mutableStateOf(null) } - var githubOAuth: GithubOAuthEntity? by remember { mutableStateOf(null) } + var githubConnected by remember { mutableStateOf(false) } LaunchedEffect(Unit) { viewModel.fetchProfile() viewModel.fetchOAuthCheck() - githubOAuth?.let { viewModel.fetchOAuth(it) } viewModel.eventFlow.collect { when (it) { is ProfileViewModel.Event.Success -> { @@ -86,12 +98,11 @@ fun ProfileScreen(navController: NavController) { } is ProfileViewModel.Event.OAuthConnected -> { - makeToast(context, "Github 계정연동 되어있습니다.") + githubConnected = true } - is ProfileViewModel.Event.OAuthSuccess -> { - makeToast(context, "Github OAuth에 연동하셨습니다") - viewModel.fetchOAuth(it.data) + is ProfileViewModel.Event.OAuthNotConnected -> { + githubConnected = false } is ProfileViewModel.Event.LogoutSuccess -> { @@ -114,6 +125,7 @@ fun ProfileScreen(navController: NavController) { sendImage = { viewModel.uploadFile(it) }, + githubConnected = githubConnected, viewModel = viewModel, ) } @@ -123,13 +135,13 @@ private fun Profile( profile: ProfileEntity?, onBackPress: () -> Unit, sendImage: (File) -> Unit, + githubConnected: Boolean, viewModel: ProfileViewModel, ) { val context = LocalContext.current var galleryState by remember { mutableStateOf(false) } var logoutDialogState by remember { mutableStateOf(false) } val gitMenuList = listOf("계정 연동") - var gitState: GithubOAuthCheckEntity? by remember { mutableStateOf(GithubOAuthCheckEntity(true)) } val accountMenuList = listOf("로그아웃") var isButtonClickable by remember { mutableStateOf(true) } val openWebViewGallery = @@ -288,7 +300,7 @@ private fun Profile( ) context.startActivity(intent) }, - is_connected = gitState!!.is_connected, + is_connected = githubConnected, ) } } diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt index 773bf922..8f48a4f8 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileViewModel.kt @@ -1,9 +1,7 @@ package com.xquare.xquare_android.feature.profile import android.util.Log -import androidx.compose.runtime.Composable import com.xquare.domain.entity.github.GithubOAuthEntity - import com.xquare.domain.entity.profile.ProfileEntity import com.xquare.domain.usecase.attachment.UploadFileUseCase import com.xquare.domain.usecase.auth.LogoutUseCase @@ -52,19 +50,11 @@ class ProfileViewModel @Inject constructor( ) } - fun fetchOAuth(githubOAuthEntity: GithubOAuthEntity) = - execute( - job = { fetchGithubOAuthUseCase.execute(githubOAuthEntity) }, - onSuccess = { emitEvent(Event.OAuthSuccess(githubOAuthEntity)) }, - onFailure = { emitEvent(Event.Failure)} - ) - - fun logout() = execute( job = { logoutUseCase.execute(Unit) }, onSuccess = { emitEvent(Event.LogoutSuccess) }, - onFailure = { } + onFailure = { } ) fun fetchOAuthCheck() = @@ -77,7 +67,7 @@ class ProfileViewModel @Inject constructor( if (success) { Event.OAuthConnected } else { - Event.OAuthNotConnected + Event.OAuthNotConnected }, ) }, @@ -92,9 +82,7 @@ class ProfileViewModel @Inject constructor( object OAuthConnected : Event() - object OAuthNotConnected: Event() - data class OAuthSuccess(val data: GithubOAuthEntity) : Event() - + object OAuthNotConnected : Event() data class UploadFileSuccess(val data: List) : Event() object UploadFileFailure : Event() diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt index b0fa8d68..a103abf3 100644 --- a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt @@ -11,6 +11,6 @@ class FetchGithubOAuthUseCase @Inject constructor( ) : UseCase() { override suspend fun execute(data: GithubOAuthEntity) = - githubRepository.fetchGithubOAuth(code = data.code) + githubRepository.fetchGithubOAuth(code = data.code).also { println("CODECODE ${data.code}") } } From 4b2ef07d844c5b7f89d267121715eb10f4473df6 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 10:59:33 +0900 Subject: [PATCH 25/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20returning=20log?= =?UTF-8?q?ic=20after=20github=20authentication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + .../com/xquare/xquare_android/MainActivity.kt | 13 ++++++---- .../xquare_android/MainActivityViewModel.kt | 4 +-- .../feature/github/GithubScreen.kt | 25 ------------------- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 39519d7a..6cad6e04 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,6 +29,7 @@ android:name="com.xquare.xquare_android.MainActivity" android:exported="true" android:label="@string/app_name" + android:launchMode="singleInstance" android:screenOrientation="portrait" android:theme="@style/Theme.XquareAndroid"> diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index 316cc19b..c5a47f54 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -71,14 +71,14 @@ class MainActivity : ComponentActivity() { private fun uploadGithubOauthCodeIfExists(intent: Intent) { - val data: Uri = intent.data ?: return + val data: Uri? = intent.data val action: String? = intent.action - Log.d("TAG", "getCode: ${data.getQueryParameter("code")}") if (action == Intent.ACTION_VIEW) { - val code = data.getQueryParameter("code") ?: return + val code = data!!.getQueryParameter("code") + Log.d("TAG", "getCode: ${data.getQueryParameter("code")}") mainActivityVIewModel.registerGithubUser( - GithubOAuthEntity(code = code) + GithubOAuthEntity(code = code!!) ) } } @@ -106,7 +106,6 @@ class MainActivity : ComponentActivity() { "깃허브 연동에 성공하였습니다.", Toast.LENGTH_SHORT ).show() - } } } @@ -117,6 +116,10 @@ class MainActivity : ComponentActivity() { ) BaseApp() } + } + + override fun onResume() { + super.onResume() uploadGithubOauthCodeIfExists(intent) } } diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt index 7d333a57..eb5bdfeb 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt @@ -20,8 +20,8 @@ class MainActivityViewModel @Inject constructor( job = { val connected = runBlocking(Dispatchers.IO) { fetchGithubOAuthCheckUseCase.execute(Unit).is_connected - } - if (!connected) { + }.also { println("CONNCONN $it") } + if (connected) { fetchGithubOAuthUseCase.execute(githubOAuthEntity) } }, diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt index 8869ea79..bad61413 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubScreen.kt @@ -1,23 +1,15 @@ package com.xquare.xquare_android.feature.github -import androidx.compose.foundation.Image import androidx.compose.foundation.background -import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Icon import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -27,31 +19,15 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.painter.ColorPainter -import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController -import coil.compose.rememberAsyncImagePainter import com.google.accompanist.pager.ExperimentalPagerApi -import com.google.accompanist.pager.HorizontalPager -import com.google.accompanist.pager.VerticalPager -import com.google.accompanist.pager.rememberPagerState import com.semicolon.design.Body1 -import com.semicolon.design.Body2 -import com.semicolon.design.Body3 -import com.semicolon.design.Subtitle4 -import com.semicolon.design.color.primary.gray.gray200 -import com.semicolon.design.color.primary.gray.gray50 -import com.semicolon.design.color.primary.gray.gray700 import com.semicolon.design.color.primary.gray.gray900 -import com.semicolon.design.color.primary.purple.purple200 import com.semicolon.design.color.primary.white.white import com.xquare.domain.entity.github.GithubInformationEntity import com.xquare.domain.entity.github.GithubListEntity @@ -104,7 +80,6 @@ fun GithubScreen( } -@OptIn(ExperimentalPagerApi::class) @Composable fun Github( githubList: GithubListEntity?, From 2a649649c600f091fd53005da8255fd022d642aa Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 11:53:22 +0900 Subject: [PATCH 26/29] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/git_toolbox_prj.xml | 15 +++++++++++++++ app/src/main/AndroidManifest.xml | 3 +-- .../com/xquare/xquare_android/MainActivity.kt | 10 +++++----- .../xquare_android/MainActivityViewModel.kt | 16 ++++++++++------ .../xquare/xquare_android/base/BaseViewModel.kt | 3 ++- 5 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 .idea/git_toolbox_prj.xml diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml new file mode 100644 index 00000000..02b915b8 --- /dev/null +++ b/.idea/git_toolbox_prj.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6cad6e04..6465e273 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,7 +29,7 @@ android:name="com.xquare.xquare_android.MainActivity" android:exported="true" android:label="@string/app_name" - android:launchMode="singleInstance" + android:launchMode="standard" android:screenOrientation="portrait" android:theme="@style/Theme.XquareAndroid"> @@ -40,7 +40,6 @@ - diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt index c5a47f54..df6792b8 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivity.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivity.kt @@ -67,17 +67,17 @@ import java.nio.charset.StandardCharsets @AndroidEntryPoint class MainActivity : ComponentActivity() { - private val mainActivityVIewModel: MainActivityViewModel by viewModels() + private val mainActivityViewModel: MainActivityViewModel by viewModels() private fun uploadGithubOauthCodeIfExists(intent: Intent) { - val data: Uri? = intent.data - val action: String? = intent.action + val action: String? = intent.action.also { println("ACTACT $it") } if (action == Intent.ACTION_VIEW) { + val data: Uri? = intent.data val code = data!!.getQueryParameter("code") Log.d("TAG", "getCode: ${data.getQueryParameter("code")}") - mainActivityVIewModel.registerGithubUser( + mainActivityViewModel.registerGithubUser( GithubOAuthEntity(code = code!!) ) } @@ -93,7 +93,7 @@ class MainActivity : ComponentActivity() { saveDeviceToken(this) setContent { LaunchedEffect(Unit) { - mainActivityVIewModel.eventFlow.collect { event -> + mainActivityViewModel.eventFlow.collect { event -> when (event) { MainActivityViewModel.Event.OAuthFailure -> Toast.makeText( this@MainActivity, diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt index eb5bdfeb..ebea25c7 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt @@ -6,6 +6,7 @@ import com.xquare.domain.usecase.github.FetchGithubOAuthUseCase import com.xquare.xquare_android.base.BaseViewModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import javax.inject.Inject @@ -16,17 +17,20 @@ class MainActivityViewModel @Inject constructor( ) : BaseViewModel() { fun registerGithubUser(githubOAuthEntity: GithubOAuthEntity) { + println("CALLEDCALLED") execute( job = { - val connected = runBlocking(Dispatchers.IO) { - fetchGithubOAuthCheckUseCase.execute(Unit).is_connected - }.also { println("CONNCONN $it") } - if (connected) { + val connected = fetchGithubOAuthCheckUseCase.execute(Unit).is_connected + + println("LOGLOGLOG $connected") + if (!connected) { fetchGithubOAuthUseCase.execute(githubOAuthEntity) } }, - onSuccess = { emitEvent(Event.OAuthSuccess) }, - onFailure = { emitEvent(Event.OAuthFailure) } + onSuccess = { emitEvent(Event.OAuthSuccess) + println("SUCCESSSUCCESS")}, + onFailure = { emitEvent(Event.OAuthFailure) + println("FAILFAIL")} ) } diff --git a/app/src/main/java/com/xquare/xquare_android/base/BaseViewModel.kt b/app/src/main/java/com/xquare/xquare_android/base/BaseViewModel.kt index 695795e5..5b42a861 100644 --- a/app/src/main/java/com/xquare/xquare_android/base/BaseViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/base/BaseViewModel.kt @@ -3,6 +3,7 @@ package com.xquare.xquare_android.base import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.xquare.domain.exception.NeedLoginException +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch abstract class BaseViewModel : ViewModel() { @@ -18,7 +19,7 @@ abstract class BaseViewModel : ViewModel() { job: suspend () -> V, onSuccess: suspend (value: V) -> Unit, onFailure: suspend (t: Throwable) -> Unit - ) = viewModelScope.launch { + ) = viewModelScope.launch(Dispatchers.IO) { kotlin.runCatching { job() } .onSuccess { onSuccess(it) } .onFailure { From ad3e9dacf424178537c07af79bbcb98ff6530838 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 11:54:04 +0900 Subject: [PATCH 27/29] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xquare/xquare_android/MainActivityViewModel.kt | 8 ++------ .../domain/usecase/github/FetchGithubOAuthUseCase.kt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt index ebea25c7..50bcbb3f 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt @@ -17,20 +17,16 @@ class MainActivityViewModel @Inject constructor( ) : BaseViewModel() { fun registerGithubUser(githubOAuthEntity: GithubOAuthEntity) { - println("CALLEDCALLED") execute( job = { val connected = fetchGithubOAuthCheckUseCase.execute(Unit).is_connected - println("LOGLOGLOG $connected") if (!connected) { fetchGithubOAuthUseCase.execute(githubOAuthEntity) } }, - onSuccess = { emitEvent(Event.OAuthSuccess) - println("SUCCESSSUCCESS")}, - onFailure = { emitEvent(Event.OAuthFailure) - println("FAILFAIL")} + onSuccess = { emitEvent(Event.OAuthSuccess) }, + onFailure = { emitEvent(Event.OAuthFailure) } ) } diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt index a103abf3..b0fa8d68 100644 --- a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt @@ -11,6 +11,6 @@ class FetchGithubOAuthUseCase @Inject constructor( ) : UseCase() { override suspend fun execute(data: GithubOAuthEntity) = - githubRepository.fetchGithubOAuth(code = data.code).also { println("CODECODE ${data.code}") } + githubRepository.fetchGithubOAuth(code = data.code) } From 13e2c71d72c750592e434af64b6e1284d470d8d0 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 11:54:04 +0900 Subject: [PATCH 28/29] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xquare/xquare_android/MainActivityViewModel.kt | 8 ++------ .../xquare_android/feature/profile/ProfileScreen.kt | 12 +++++++----- .../domain/usecase/github/FetchGithubOAuthUseCase.kt | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt index ebea25c7..50bcbb3f 100644 --- a/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt +++ b/app/src/main/java/com/xquare/xquare_android/MainActivityViewModel.kt @@ -17,20 +17,16 @@ class MainActivityViewModel @Inject constructor( ) : BaseViewModel() { fun registerGithubUser(githubOAuthEntity: GithubOAuthEntity) { - println("CALLEDCALLED") execute( job = { val connected = fetchGithubOAuthCheckUseCase.execute(Unit).is_connected - println("LOGLOGLOG $connected") if (!connected) { fetchGithubOAuthUseCase.execute(githubOAuthEntity) } }, - onSuccess = { emitEvent(Event.OAuthSuccess) - println("SUCCESSSUCCESS")}, - onFailure = { emitEvent(Event.OAuthFailure) - println("FAILFAIL")} + onSuccess = { emitEvent(Event.OAuthSuccess) }, + onFailure = { emitEvent(Event.OAuthFailure) } ) } diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index b34ec017..4f16eda9 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -294,11 +294,13 @@ private fun Profile( ButtonColumnMenu( text = "Github 연동", onClick = { - val intent = Intent( - Intent.ACTION_VIEW, - Uri.parse("https://github.com/login/oauth/authorize?client_id=7ba1da5afd9b182e9793") - ) - context.startActivity(intent) + if (!githubConnected) { + val intent = Intent( + Intent.ACTION_VIEW, + Uri.parse("https://github.com/login/oauth/authorize?client_id=7ba1da5afd9b182e9793") + ) + context.startActivity(intent) + } }, is_connected = githubConnected, ) diff --git a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt index a103abf3..b0fa8d68 100644 --- a/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt +++ b/domain/src/main/java/com/xquare/domain/usecase/github/FetchGithubOAuthUseCase.kt @@ -11,6 +11,6 @@ class FetchGithubOAuthUseCase @Inject constructor( ) : UseCase() { override suspend fun execute(data: GithubOAuthEntity) = - githubRepository.fetchGithubOAuth(code = data.code).also { println("CODECODE ${data.code}") } + githubRepository.fetchGithubOAuth(code = data.code) } From 368b067aeba6c80ac503a4305ab88014cede0456 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Thu, 21 Sep 2023 23:19:21 +0900 Subject: [PATCH 29/29] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EC=A0=84=20=EB=B2=84=ED=8A=BC=20=EB=B9=84=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/github/GithubDetail.kt | 1 + .../feature/profile/ProfileScreen.kt | 50 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt index 6ef235ea..8210bd79 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/github/GithubDetail.kt @@ -67,6 +67,7 @@ fun GithubRankingItem( placeholder = ColorPainter(gray200), error = painterResource(id = R.drawable.ic_profile_default) ), + contentScale = ContentScale.Crop, contentDescription = null, modifier = Modifier .size(50.dp) diff --git a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt index 4f16eda9..87aff9b2 100644 --- a/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt +++ b/app/src/main/java/com/xquare/xquare_android/feature/profile/ProfileScreen.kt @@ -47,7 +47,6 @@ import com.semicolon.design.color.primary.gray.gray50 import com.semicolon.design.color.primary.gray.gray700 import com.semicolon.design.color.primary.gray.gray900 import com.semicolon.design.color.primary.purple.purple200 -import com.semicolon.design.color.primary.purple.purple300 import com.semicolon.design.color.primary.purple.purple50 import com.semicolon.design.color.primary.white.white import com.xquare.domain.entity.profile.ProfileEntity @@ -66,7 +65,7 @@ fun ProfileScreen(navController: NavController) { val context = LocalContext.current val viewModel: ProfileViewModel = hiltViewModel() var profile: ProfileEntity? by remember { mutableStateOf(null) } - var githubConnected by remember { mutableStateOf(false) } + var githubConnected by remember { mutableStateOf(null) } LaunchedEffect(Unit) { viewModel.fetchProfile() @@ -135,7 +134,7 @@ private fun Profile( profile: ProfileEntity?, onBackPress: () -> Unit, sendImage: (File) -> Unit, - githubConnected: Boolean, + githubConnected: Boolean?, viewModel: ProfileViewModel, ) { val context = LocalContext.current @@ -143,7 +142,6 @@ private fun Profile( var logoutDialogState by remember { mutableStateOf(false) } val gitMenuList = listOf("계정 연동") val accountMenuList = listOf("로그아웃") - var isButtonClickable by remember { mutableStateOf(true) } val openWebViewGallery = rememberLauncherForActivityResult( ActivityResultContracts.StartActivityForResult() @@ -290,11 +288,11 @@ private fun Profile( fontWeight = FontWeight.Medium ) Spacer(Modifier.size(4.dp)) - gitMenuList.forEachIndexed { index, text -> + gitMenuList.forEachIndexed { _, _ -> ButtonColumnMenu( text = "Github 연동", onClick = { - if (!githubConnected) { + if (githubConnected == false) { val intent = Intent( Intent.ACTION_VIEW, Uri.parse("https://github.com/login/oauth/authorize?client_id=7ba1da5afd9b182e9793") @@ -302,7 +300,7 @@ private fun Profile( context.startActivity(intent) } }, - is_connected = githubConnected, + isConnected = githubConnected, ) } } @@ -356,10 +354,16 @@ private fun ColumnMenu(text: String, onClick: () -> Unit) { private fun ButtonColumnMenu( text: String, onClick: () -> Unit, - is_connected: Boolean, + isConnected: Boolean?, ) { - val textColor = if (is_connected) purple200 else white - val buttonColor = if (is_connected) purple50 else purple300 + val textColor = when (isConnected){ + true -> purple200 + else -> white + } + val buttonColor = when(isConnected) { + true -> purple50 + else -> white + } Box( modifier = Modifier .padding(top = 12.dp, bottom = 12.dp) @@ -384,18 +388,22 @@ private fun ButtonColumnMenu( .padding(end = 12.dp), horizontalArrangement = Arrangement.End ) { - Row( - modifier = Modifier - .size(80.dp, 38.dp) - .clip(RoundedCornerShape(8.dp)) - .background(buttonColor), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center + isConnected?.let { + Row( + modifier = Modifier + .size(80.dp, 38.dp) + .clip(RoundedCornerShape(8.dp)) + .background(buttonColor), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center - ) { - if (is_connected) { - Text(text = "연동됨", color = textColor) - } else Text(text = "연동하기", color = textColor) + ) { + if (isConnected) { + Text(text = "연동됨", color = textColor) + } else { + Text(text = "연동하기", color = textColor) + } + } } } }