Skip to content

Commit

Permalink
[Refactor/#91] 로그인 뷰 관련 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-seonwoo committed Nov 8, 2024
1 parent aa1c872 commit 641be9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
//

import SwiftUI
import AuthenticationServices

import DSKit
import Domain

public struct LoginView: View {
@ObservedObject var viewModel: LoginViewModel

public init(viewModel: LoginViewModel) {
init(viewModel: LoginViewModel) {
self.viewModel = viewModel
}

Expand All @@ -23,15 +23,13 @@ public struct LoginView: View {
.ignoresSafeArea()
VStack(spacing: 10) {
//TODO: 이미지 타입 문제거 같은데 지금 해결하기엔 싱싱미역
// SwipeView(imageNames: [.onboardingFirst, .onboardingSecond, .onboardingThird])
// .padding(.bottom, 75)
LoginButton(loginProvider: .kakao, viewModel: viewModel)
LoginButton(loginProvider: .apple, viewModel: viewModel)
SwipeView(swipeImages: [DSKitAsset.onboardingFirst.swiftUIImage, DSKitAsset.onboardingSecond.swiftUIImage, DSKitAsset.onboardingThird.swiftUIImage])
.padding(.bottom, 75)
LoginButton(loginProvider: OAuthProviderType.kakao, viewModel: viewModel)
LoginButton(loginProvider: OAuthProviderType.apple, viewModel: viewModel)
}
}
.frame(maxHeight: .infinity)
.padding(.vertical, 22)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,25 @@
//

import SwiftUI
import AuthenticationServices

import DSKit

enum SignInProvider {
case apple
case kakao

var signInLogoImage: String {
switch self {
case .apple:
return "appleLogo"
case .kakao:
return "kakaoLogo"
}
}
}
import Domain

struct LoginButton: View {
let loginProvider: SignInProvider
var loginProvider: OAuthProviderType = .apple
@ObservedObject var viewModel: LoginViewModel
var signInLogoImage = DSKitAsset.appleLogo.swiftUIImage

var body: some View {
Button(action: {
if loginProvider == .apple {
viewModel.handleAppleLogin()
} else if loginProvider == .kakao {
viewModel.handleKakaoLogin()
}
viewModel.handleLoginButton(provider: loginProvider)
}) {
RoundedRectangle(cornerRadius: 6.3)
.frame(width:336, height: 51)
.foregroundColor(loginProvider == .apple ? DSKitAsset.whiteBtn.swiftUIColor : DSKitAsset.yelloBtn.swiftUIColor)
.overlay(
HStack {
Image(loginProvider.signInLogoImage)
Image(uiImage: loginProvider == .apple ? DSKitAsset.appleLogo.image : DSKitAsset.kakaoLogo.image)
.resizable()
.frame(width: 24, height: 24)
.padding(.leading, 14)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import SwiftUI
import DSKit

struct SwipeView: View {
var imageNames: [ImageResource]
var swipeImages: [Image]
private let timer = Timer.publish(every: 3.0, on: .main, in: .common).autoconnect()

@State private var selectedImageIndex: Int = 0

var body: some View {
VStack {
TabView(selection: $selectedImageIndex) {
ForEach(0..<imageNames.count, id: \.self) { index in
Image(imageNames[index])
ForEach(0..<swipeImages.count, id: \.self) { index in
swipeImages[index]
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: .infinity, maxHeight: .infinity)
Expand All @@ -29,7 +29,7 @@ struct SwipeView: View {
.padding(.bottom, 30)
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
HStack {
ForEach(0..<imageNames.count, id: \.self) { index in
ForEach(0..<swipeImages.count, id: \.self) { index in
Rectangle()
.fill(selectedImageIndex == index ? Color(.white) : Color(DSKitAsset.gray2.swiftUIColor))
.frame(width: 8, height: 8)
Expand All @@ -42,7 +42,7 @@ struct SwipeView: View {
.frame(maxWidth: .infinity)
.onReceive(timer) { _ in
withAnimation(.default) {
selectedImageIndex = (selectedImageIndex + 1) % imageNames.count
selectedImageIndex = (selectedImageIndex + 1) % swipeImages.count
}
}
}
Expand Down

0 comments on commit 641be9e

Please sign in to comment.