Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]#13- 온보딩, 로그인 뷰 구현 #40

Merged
merged 6 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions SOPT-Stamp-iOS/Projects/Core/Sources/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,39 @@ public struct I18N {
public static let verify = "확인"
}

public struct Navi {
public static let post = "공지"
}

public struct Search {
public static let placeholder = "검색어 입력"
public static let cancel = "취소"
public static let countUnit = " 건"
public static let enterSearch = "검색어를 입력해 주세요."
public static let noSearchData = "등록된 게시물이 없습니다"
}

public struct Onboarding {
public static let title1 = "A부터 Z까지 SOPT 즐기기"
public static let caption1 = "동아리 활동을 더욱 재미있게\n즐기는 방법을 알려드려요!"
public static let title2 = "랭킹으로 다같이 참여하기"
public static let caption2 = "미션을 달성하고 랭킹이 올라가는\n재미를 느껴보세요!"
public static let title3 = "완료된 미션으로 추억 감상하기"
public static let caption3 = "완료된 미션을 확인하며\n추억을 감상할 수 있어요"
public static let start = "시작하기"
}

public struct SignIn {
public static let id = "ID"
public static let enterID = "이메일을 입력해주세요."
public static let password = "Password"
public static let enterPW = "비밀번호를 입력해주세요."
public static let checkAccount = "정보를 다시 확인해 주세요."
public static let findAccount = "계정 찾기"
public static let signIn = "로그인"
public static let signUp = "회원가입"
}

public struct SignUp {
public static let signUp = "회원가입"
public static let nickname = "닉네임"
Expand Down Expand Up @@ -47,6 +80,8 @@ public struct I18N {
public static let mission = "미션"
public static let missionComplete = "미션 완료"
public static let editComplte = "수정 완료"

public static let deleteTitle = "달성한 미션을 삭제하시겠습니까?"

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// SignInRepository.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Combine

import Domain
import Network

public class SignInRepository {

private let networkService: AuthService
private let cancelBag = Set<AnyCancellable>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CancelBag으로 통일하면 좋을 것 같아요~!


public init(service: AuthService) {
self.networkService = service
}
}

extension SignInRepository: SignInRepositoryInterface {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SignInTransform.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Foundation

import Domain
import Network

extension SignInEntity {

public func toDomain() -> SignInModel {
return SignInModel.init()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// OnboardingDataModel.swift
// Domain
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import UIKit

public struct OnboardingDataModel {
public var image: UIImage
public var title, caption: String

public init(image: UIImage, title: String, caption: String) {
self.image = image
self.title = title
self.caption = caption
}
}
16 changes: 16 additions & 0 deletions SOPT-Stamp-iOS/Projects/Domain/Sources/Model/SignInModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SignInModel.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Foundation

public struct SignInModel {

public init() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SignInRepositoryInterface.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Combine

public protocol SignInRepositoryInterface {

}
27 changes: 27 additions & 0 deletions SOPT-Stamp-iOS/Projects/Domain/Sources/UseCase/SignInUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// SignInUseCase.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Combine

public protocol SignInUseCase {

}

public class DefaultSignInUseCase {

private let repository: SignInRepositoryInterface
private var cancelBag = Set<AnyCancellable>()

public init(repository: SignInRepositoryInterface) {
self.repository = repository
}
}

extension DefaultSignInUseCase: SignInUseCase {

}
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ extension CustomTextFieldView {
textField.backgroundColor = .clear
textField.textColor = .black
textField.font = UIFont.caption1
textField.returnKeyType = .done

alertlabel.font = UIFont.caption3
alertlabel.textColor = SoptampColor.error300.color
Expand Down Expand Up @@ -477,6 +478,11 @@ extension CustomTextFieldView: UITextFieldDelegate {
self.setTextFieldViewState(.editing)
}
}

public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

textField.resignFirstResponder()
return true
}
}

// MARK: - CustomTextFieldViewAlertDelegate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SignInEntity.swift
// Presentation
//
// Created by devxsby on 2022/12/01.
// Copyright © 2022 SOPT-Stamp-iOS. All rights reserved.
//

import Foundation

public struct SignInEntity {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Core
public protocol ModuleFactoryInterface {
func makeSplashVC() -> SplashVC
func makeOnboardingVC() -> OnboardingVC
func makeSignInVC() -> SignInVC
func makeSignUpVC() -> SignUpVC
func makeSignUpCompleteVC() -> SignUpCompleteVC
func makeMissionListVC(sceneType: MissionListSceneType) -> MissionListVC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,67 @@ import UIKit

import DSKit

import Domain

import Core

import SnapKit
import Then

public class OnboardingVC: UIViewController {

// MARK: - Properties

private var onboardingData: [OnboardingDataModel] = []

private var currentPage: Int = 0 {
didSet {
pageControl.currentPage = currentPage
startButton.setEnabled(currentPage == 2)
}
}

public var factory: ModuleFactoryInterface!

// MARK: - UI Components

private lazy var onboardingCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.isScrollEnabled = true
collectionView.isPagingEnabled = true
collectionView.showsHorizontalScrollIndicator = false
return collectionView
}()

private lazy var pageControl = UIPageControl().then {
$0.pageIndicatorTintColor = DSKitAsset.Colors.purple200.color
$0.currentPageIndicatorTintColor = DSKitAsset.Colors.purple300.color
$0.numberOfPages = 3
$0.isUserInteractionEnabled = false
}

private lazy var startButton = CustomButton(title: I18N.Onboarding.start).setEnabled(false).then {
$0.addTarget(self, action: #selector(startButtonDidTap), for: .touchUpInside)
}

// MARK: - View Life Cycle

public override func viewDidLoad() {
super.viewDidLoad()
self.setUI()
self.setLayout()
self.setCollectionViewCell()
self.setOnboardingData()
}

// MARK: - @objc Function

@objc
private func startButtonDidTap() {
let vc = self.factory.makeSignInVC()
self.navigationController?.pushViewController(vc, animated: true)
}
}

Expand All @@ -39,8 +83,87 @@ extension OnboardingVC {
}

private func setLayout() {
view.addSubviews(onboardingCollectionView, pageControl, startButton)

onboardingCollectionView.snp.makeConstraints { make in
make.top.equalTo(view.safeAreaLayoutGuide).offset(40.adjustedH)
make.leading.trailing.equalTo(view.safeAreaLayoutGuide)
make.height.equalTo(450.adjusted)
}

pageControl.snp.makeConstraints { make in
make.top.equalTo(onboardingCollectionView.snp.bottom).offset(14.adjustedH)
make.centerX.equalToSuperview()
}

startButton.snp.makeConstraints { make in
make.top.equalTo(pageControl.snp.bottom).offset(50.adjustedH)
make.leading.trailing.equalTo(view.safeAreaInsets).inset(20)
make.height.equalTo(56)
}
}
}

// MARK: - Methods

extension OnboardingVC {

private func setCollectionViewCell() {
onboardingCollectionView.delegate = self
onboardingCollectionView.dataSource = self

onboardingCollectionView.register(OnboardingCVC.self, forCellWithReuseIdentifier: OnboardingCVC.className)
}

private func setOnboardingData() {
onboardingData.append(contentsOf: [
OnboardingDataModel(image: DSKitAsset.Assets.splashImg1.image,
title: I18N.Onboarding.title1,
caption: I18N.Onboarding.caption1),
OnboardingDataModel(image: DSKitAsset.Assets.splashImg2.image,
title: I18N.Onboarding.title2,
caption: I18N.Onboarding.caption2),
OnboardingDataModel(image: DSKitAsset.Assets.splashImg3.image,
title: I18N.Onboarding.title3,
caption: I18N.Onboarding.caption3)
])
}
}

// MARK: - CollectionView Delegate, DataSource

extension OnboardingVC: UICollectionViewDelegate, UICollectionViewDataSource {

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return onboardingData.count
}

public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = onboardingCollectionView.dequeueReusableCell(withReuseIdentifier: OnboardingCVC.className, for: indexPath) as? OnboardingCVC else { return UICollectionViewCell() }
cell.setOnboardingSlides(onboardingData[indexPath.row])
return cell
}

public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
let page = Int(targetContentOffset.pointee.x / self.view.frame.width)
self.currentPage = page
}
}

// MARK: - CollectionView DelegateFlowLayout

extension OnboardingVC: UICollectionViewDelegateFlowLayout {

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let length = self.view.frame.size.width
return CGSize(width: length, height: 450.adjustedH)
}

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
}
Loading