From 8ff402236aa742ea7eb2afadc7fc39a6a2971fc2 Mon Sep 17 00:00:00 2001 From: hhhello Date: Fri, 4 Oct 2024 01:48:51 +0900 Subject: [PATCH] S: Add NeisProperties, I: Add Sheet --- .../global/config/Properties.kt | 5 -- .../global/config/PropertiesConfig.kt | 15 ----- .../global/config/RetrofitConfig.kt | 29 --------- .../global/config/WebSecurityConfig.kt | 2 + .../JwtAuthenticationFilter.kt | 2 +- .../{config => jwt}/JwtExceptionFilter.kt | 2 +- .../global/{config => jwt}/JwtUserDetails.kt | 2 +- .../{config => jwt}/JwtUserDetailsService.kt | 2 +- .../infra/neis/NeisMealHelper.kt | 5 +- .../infra/neis/NeisProperties.kt | 9 +++ .../infra/neis/NeisScheduleHelper.kt | 11 ++-- .../Graduating.xcodeproj/project.pbxproj | 25 +++++++ .../xcshareddata/swiftpm/Package.resolved | 65 ++++++++++++++++++- .../Feature/Main/Profile/ProfileView.swift | 24 ++++++- .../Graduating/Feature/Util/ViewExt.swift | 50 ++++++++++++++ 15 files changed, 182 insertions(+), 66 deletions(-) delete mode 100644 Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/Properties.kt delete mode 100644 Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/PropertiesConfig.kt delete mode 100644 Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/RetrofitConfig.kt rename Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/{config => jwt}/JwtAuthenticationFilter.kt (95%) rename Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/{config => jwt}/JwtExceptionFilter.kt (93%) rename Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/{config => jwt}/JwtUserDetails.kt (91%) rename Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/{config => jwt}/JwtUserDetailsService.kt (88%) create mode 100644 Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisProperties.kt create mode 100644 Graduating-iOS/Graduating/Feature/Util/ViewExt.swift diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/Properties.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/Properties.kt deleted file mode 100644 index 8abfbe5..0000000 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/Properties.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config - -data class Properties( - val neisApiKey: String, -) \ No newline at end of file diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/PropertiesConfig.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/PropertiesConfig.kt deleted file mode 100644 index d74b365..0000000 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/PropertiesConfig.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config - -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration - -@Configuration -class PropertiesConfig( - @Value("\${secret.neis.apikey}") val neisApiKey: String, -) { - @Bean - fun propertyConfig() = Properties( - neisApiKey = neisApiKey - ) -} \ No newline at end of file diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/RetrofitConfig.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/RetrofitConfig.kt deleted file mode 100644 index f210884..0000000 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/RetrofitConfig.kt +++ /dev/null @@ -1,29 +0,0 @@ -//package com.bestswlkh0310.graduating.graduatingserver.global.config -// -//import com.bestswlkh0310.graduating.graduatingserver.infra.neis.NeisApi -//import okhttp3.OkHttpClient -//import org.springframework.context.annotation.Bean -//import org.springframework.context.annotation.Configuration -//import retrofit2.Retrofit -//import retrofit2.converter.gson.GsonConverterFactory -//import java.util.concurrent.TimeUnit -// -//@Configuration -//class RetrofitConfig { -// -// val okhttpClient = OkHttpClient.Builder() -// .connectTimeout(1, TimeUnit.MINUTES) -// .readTimeout(30, TimeUnit.SECONDS) -// .writeTimeout(15, TimeUnit.SECONDS) -// .build() -// -// val retrofit: Retrofit by lazy { -// Retrofit.Builder() -// .baseUrl("https://open.neis.go.kr/") -// .client(okhttpClient) -// .addConverterFactory(GsonConverterFactory.create()) -// .build() -// } -// -// @Bean fun neisRepository() = retrofit.create(NeisApi::class.java) -//} \ No newline at end of file diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/WebSecurityConfig.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/WebSecurityConfig.kt index c829d43..686041f 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/WebSecurityConfig.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/WebSecurityConfig.kt @@ -2,6 +2,8 @@ package com.bestswlkh0310.graduating.graduatingserver.global.config import com.bestswlkh0310.graduating.graduatingserver.global.exception.ErrorResponseSender import com.bestswlkh0310.graduating.graduatingserver.global.exception.HttpExceptionFilter +import com.bestswlkh0310.graduating.graduatingserver.global.jwt.JwtAuthenticationFilter +import com.bestswlkh0310.graduating.graduatingserver.global.jwt.JwtExceptionFilter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.HttpStatus diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtAuthenticationFilter.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtAuthenticationFilter.kt similarity index 95% rename from Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtAuthenticationFilter.kt rename to Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtAuthenticationFilter.kt index e70795a..f408d72 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtAuthenticationFilter.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtAuthenticationFilter.kt @@ -1,4 +1,4 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config +package com.bestswlkh0310.graduating.graduatingserver.global.jwt import com.bestswlkh0310.graduating.graduatingserver.global.TokenExtractor import com.bestswlkh0310.graduating.graduatingserver.infra.token.JwtClient diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtExceptionFilter.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtExceptionFilter.kt similarity index 93% rename from Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtExceptionFilter.kt rename to Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtExceptionFilter.kt index 531d16d..8d1f4b2 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtExceptionFilter.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtExceptionFilter.kt @@ -1,4 +1,4 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config +package com.bestswlkh0310.graduating.graduatingserver.global.jwt import com.bestswlkh0310.graduating.graduatingserver.global.exception.CustomException import com.bestswlkh0310.graduating.graduatingserver.global.exception.ErrorResponseSender diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetails.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetails.kt similarity index 91% rename from Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetails.kt rename to Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetails.kt index d3ba628..ab8f079 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetails.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetails.kt @@ -1,4 +1,4 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config +package com.bestswlkh0310.graduating.graduatingserver.global.jwt import com.bestswlkh0310.graduating.graduatingserver.core.user.User diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetailsService.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetailsService.kt similarity index 88% rename from Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetailsService.kt rename to Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetailsService.kt index 3d4280e..c9a7993 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/config/JwtUserDetailsService.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/global/jwt/JwtUserDetailsService.kt @@ -1,4 +1,4 @@ -package com.bestswlkh0310.graduating.graduatingserver.global.config +package com.bestswlkh0310.graduating.graduatingserver.global.jwt import com.bestswlkh0310.graduating.graduatingserver.core.user.UserRepository import com.bestswlkh0310.graduating.graduatingserver.core.user.getByUsername diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisMealHelper.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisMealHelper.kt index 68c0c60..a39388d 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisMealHelper.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisMealHelper.kt @@ -1,7 +1,6 @@ package com.bestswlkh0310.graduating.graduatingserver.infra.neis import com.bestswlkh0310.graduating.graduatingserver.common.parse -import com.bestswlkh0310.graduating.graduatingserver.global.config.Properties import com.bestswlkh0310.graduating.graduatingserver.core.meal.MealEntity import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolEntity import com.bestswlkh0310.graduating.graduatingserver.core.meal.MealRepository @@ -14,7 +13,7 @@ import java.time.LocalDateTime @Component class NeisMealHelper( private val schoolRepository: SchoolRepository, - private val properties: Properties, + private val neisProperties: NeisProperties, private val mealRepository: MealRepository, @Qualifier("neis") private val restClient: RestClient @@ -28,7 +27,7 @@ class NeisMealHelper( .uri { uriBuilder -> uriBuilder .path("hub/mealServiceDietInfo") - .queryParam("KEY", properties.neisApiKey) + .queryParam("KEY", neisProperties.apiKey) .queryParam("Type", "json") .queryParam("ATPT_OFCDC_SC_CODE", school.officeCode) .queryParam("SD_SCHUL_CODE", school.code) diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisProperties.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisProperties.kt new file mode 100644 index 0000000..64fd989 --- /dev/null +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisProperties.kt @@ -0,0 +1,9 @@ +package com.bestswlkh0310.graduating.graduatingserver.infra.neis + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.boot.context.properties.bind.ConstructorBinding + +@ConfigurationProperties(prefix = "neis") +class NeisProperties @ConstructorBinding constructor( + val apiKey: String, +) \ No newline at end of file diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisScheduleHelper.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisScheduleHelper.kt index 9a24316..4bfee05 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisScheduleHelper.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/infra/neis/NeisScheduleHelper.kt @@ -1,6 +1,5 @@ package com.bestswlkh0310.graduating.graduatingserver.infra.neis -import com.bestswlkh0310.graduating.graduatingserver.global.config.Properties import com.bestswlkh0310.graduating.graduatingserver.core.graduating.GraduatingEntity import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolEntity import com.bestswlkh0310.graduating.graduatingserver.core.school.SchoolType @@ -24,13 +23,13 @@ class NeisScheduleHelper( private val graduatingRepository: GraduatingRepository, @Qualifier("neis") private val restClient: RestClient, - private val properties: Properties + private val neisProperties: NeisProperties ) { fun importCsv(filePath: String) { val file = File(filePath) val parser = CSVParser.parse(file, StandardCharsets.UTF_8, CSVFormat.DEFAULT.withFirstRecordAsHeader()) - + parser.mapNotNull { record -> val v = record.toList() try { @@ -63,10 +62,10 @@ class NeisScheduleHelper( val result = arrayListOf() try { val response = restClient.get() - .uri { uriBuilder -> + .uri { uriBuilder -> uriBuilder .path("hub/SchoolSchedule") - .queryParam("KEY", properties.neisApiKey) + .queryParam("KEY", neisProperties.apiKey) .queryParam("Type", "json") .queryParam("ATPT_OFCDC_SC_CODE", school.officeCode) .queryParam("SD_SCHUL_CODE", school.code) @@ -77,7 +76,7 @@ class NeisScheduleHelper( .retrieve() .toEntity(NeisSchedulesRes::class.java) .body - + var includeGraduating = false response?.SchoolSchedule?.let { res -> res.mapNotNull { it?.row } diff --git a/Graduating-iOS/Graduating.xcodeproj/project.pbxproj b/Graduating-iOS/Graduating.xcodeproj/project.pbxproj index e1c787c..e427ebe 100644 --- a/Graduating-iOS/Graduating.xcodeproj/project.pbxproj +++ b/Graduating-iOS/Graduating.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 25064D392CAEFEFF00181796 /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = 25064D382CAEFEFF00181796 /* GoogleSignIn */; }; + 25064D3B2CAEFEFF00181796 /* GoogleSignInSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 25064D3A2CAEFEFF00181796 /* GoogleSignInSwift */; }; 250EAE242C7DE05500D9FF5E /* CombineMoya in Frameworks */ = {isa = PBXBuildFile; productRef = 250EAE232C7DE05500D9FF5E /* CombineMoya */; }; 250EAE262C7DE05500D9FF5E /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 250EAE252C7DE05500D9FF5E /* Moya */; }; 250FD0852C74AF100070503B /* CombineMoya in Frameworks */ = {isa = PBXBuildFile; productRef = 250FD0842C74AF100070503B /* CombineMoya */; }; @@ -176,7 +178,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 25064D3B2CAEFEFF00181796 /* GoogleSignInSwift in Frameworks */, 250FD0852C74AF100070503B /* CombineMoya in Frameworks */, + 25064D392CAEFEFF00181796 /* GoogleSignIn in Frameworks */, 25C962D42C7B07C500EB872E /* libData.a in Frameworks */, 25C962D12C7B07C000EB872E /* libModel.a in Frameworks */, 253DC2B22C7EBEAC0047C401 /* MyDesignSystem in Frameworks */, @@ -292,6 +296,8 @@ 250FD0862C74AF100070503B /* Moya */, 25C4CCF42C74B30600DB83B3 /* Then */, 253DC2B12C7EBEAC0047C401 /* MyDesignSystem */, + 25064D382CAEFEFF00181796 /* GoogleSignIn */, + 25064D3A2CAEFEFF00181796 /* GoogleSignInSwift */, ); productName = Graduating; productReference = 2560F1732C746C16007009E2 /* Graduating.app */; @@ -440,6 +446,7 @@ 250FD0832C74AF100070503B /* XCRemoteSwiftPackageReference "Moya" */, 25C4CCF32C74B30600DB83B3 /* XCRemoteSwiftPackageReference "Then" */, 253DC2B02C7EBEAC0047C401 /* XCRemoteSwiftPackageReference "my-ios-kit" */, + 25064D372CAEFEFF00181796 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */, ); productRefGroup = 2560F1742C746C16007009E2 /* Products */; projectDirPath = ""; @@ -981,6 +988,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 25064D372CAEFEFF00181796 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/google/GoogleSignIn-iOS"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 8.0.0; + }; + }; 250FD0832C74AF100070503B /* XCRemoteSwiftPackageReference "Moya" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Moya/Moya"; @@ -1016,6 +1031,16 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 25064D382CAEFEFF00181796 /* GoogleSignIn */ = { + isa = XCSwiftPackageProductDependency; + package = 25064D372CAEFEFF00181796 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */; + productName = GoogleSignIn; + }; + 25064D3A2CAEFEFF00181796 /* GoogleSignInSwift */ = { + isa = XCSwiftPackageProductDependency; + package = 25064D372CAEFEFF00181796 /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */; + productName = GoogleSignInSwift; + }; 250EAE232C7DE05500D9FF5E /* CombineMoya */ = { isa = XCSwiftPackageProductDependency; package = 250FD0832C74AF100070503B /* XCRemoteSwiftPackageReference "Moya" */; diff --git a/Graduating-iOS/Graduating.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Graduating-iOS/Graduating.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9419ea2..7665438 100644 --- a/Graduating-iOS/Graduating.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Graduating-iOS/Graduating.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "809835623b93457091506cc3575358d02b8eb0375bfc0e2b7f06996cf058430c", + "originHash" : "e3c1180a8e38a74c7306c05087a0cb19db9d112d93d960a6d4f87d4ab491fe93", "pins" : [ { "identity" : "alamofire", @@ -10,6 +10,60 @@ "version" : "5.9.1" } }, + { + "identity" : "app-check", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/app-check.git", + "state" : { + "revision" : "21fe1af9be463a359aaf8d96789ef73fc3760d09", + "version" : "11.0.1" + } + }, + { + "identity" : "appauth-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/openid/AppAuth-iOS.git", + "state" : { + "revision" : "c89ed571ae140f8eb1142735e6e23d7bb8c34cb2", + "version" : "1.7.5" + } + }, + { + "identity" : "googlesignin-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleSignIn-iOS", + "state" : { + "revision" : "65fb3f1aa6ffbfdc79c4e22178a55cd91561f5e9", + "version" : "8.0.0" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "53156c7ec267db846e6b64c9f4c4e31ba4cf75eb", + "version" : "8.0.2" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", + "version" : "3.5.0" + } + }, + { + "identity" : "gtmappauth", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GTMAppAuth.git", + "state" : { + "revision" : "5d7d66f647400952b1758b230e019b07c0b4b22a", + "version" : "4.1.1" + } + }, { "identity" : "moya", "kind" : "remoteSourceControl", @@ -37,6 +91,15 @@ "version" : "12.3.0" } }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", + "version" : "2.4.0" + } + }, { "identity" : "reactiveswift", "kind" : "remoteSourceControl", diff --git a/Graduating-iOS/Graduating/Feature/Main/Profile/ProfileView.swift b/Graduating-iOS/Graduating/Feature/Main/Profile/ProfileView.swift index fce620e..bb9f583 100644 --- a/Graduating-iOS/Graduating/Feature/Main/Profile/ProfileView.swift +++ b/Graduating-iOS/Graduating/Feature/Main/Profile/ProfileView.swift @@ -5,6 +5,7 @@ struct ProfileView: View { @EnvironmentObject private var router: Router @Environment(\.openURL) private var openURL + @State private var isSheetPresent: Bool = false var body: some View { MyTopAppBar.default( @@ -14,9 +15,13 @@ struct ProfileView: View { VStack(spacing: 0) { VStack(spacing: 8) { MyAvatar(nil, type: .larger) - Text("이름") - .foreground(Colors.Label.alternative) - .myFont(.bodyR) + Button { + isSheetPresent = true + } label: { + Text("로그인 하기") + .foreground(Colors.Label.alternative) + .myFont(.bodyR) + } } .padding(.top, 16) HStack(spacing: 12) { @@ -48,5 +53,18 @@ struct ProfileView: View { .padding(insets) // .background(Colors.Background.normal) } + .sheet(isPresented: $isSheetPresent) { + VStack(spacing: 10) { + AppleSignInButton { + + } + GoogleSignInButton { + + } + } + .padding(20) + .background(Colors.Background.normal) + .adjustedHeightSheet() + } } } diff --git a/Graduating-iOS/Graduating/Feature/Util/ViewExt.swift b/Graduating-iOS/Graduating/Feature/Util/ViewExt.swift new file mode 100644 index 0000000..5dd8588 --- /dev/null +++ b/Graduating-iOS/Graduating/Feature/Util/ViewExt.swift @@ -0,0 +1,50 @@ +// +// ViewExt.swift +// Graduating +// +// Created by hhhello0507 on 10/4/24. +// + +import SwiftUI + +public extension View { + @ViewBuilder + func onReadSize(_ perform: @escaping (CGSize) -> Void) -> some View { + self.customBackground { + GeometryReader { geometryProxy in + Color.clear + .preference(key: SizePreferenceKey.self, value: geometryProxy.size) + } + } + .onPreferenceChange(SizePreferenceKey.self, perform: perform) + } + + @ViewBuilder + func customBackground(alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View { + self.background(alignment: alignment, content: content) + } +} + +struct SizePreferenceKey: PreferenceKey { + static var defaultValue: CGSize = .zero + static func reduce(value: inout CGSize, nextValue: () -> CGSize) { } +} + +struct AdjustedHeightSheetViewModifier: ViewModifier { + + @State private var size: CGSize = .zero + + func body(content: Content) -> some View { + content + .onReadSize { + self.size = $0 + } + .presentationDetents([.height(size.height)]) + } +} + +public extension View { + func adjustedHeightSheet() -> some View { + self.modifier(AdjustedHeightSheetViewModifier()) + } +}