Skip to content

Commit

Permalink
Merge pull request #349 from MaeumGaGym/feature/#348-baseText
Browse files Browse the repository at this point in the history
MERGE :: [#348] base 파일 주석 변경
  • Loading branch information
Eunho0922 authored Jun 26, 2024
2 parents 85c6d65 + 76e5d38 commit 66df422
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 65 deletions.
5 changes: 0 additions & 5 deletions Projects/Core/Sources/Base/BaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,4 @@ open class BaseButton: UIButton {
// 버튼의 titleText를 설정하는 함수입니다.
self.setTitle(text, for: .normal)
}

// open func setFont(font: UIFont) {
// // 버튼의 titleLabel font를 설정하는 함수입니다.
// self.titleLabel?.font = font
// }
}
40 changes: 31 additions & 9 deletions Projects/Core/Sources/Base/BaseLabel.swift
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
import UIKit

import RxSwift
import RxCocoa

import Then
import SnapKit

/// MG의 BaseLabel은 UILabel을 확장한 기본 라벨 클래스
open class BaseLabel: UILabel {

/// disposeBag은 RxSwift의 메모리 관리를 위한 객체
public let disposeBag = DisposeBag()

/// 기본 초기화 함수.
/// - Parameter frame: 라벨의 프레임.
public override init(frame: CGRect) {
super.init(frame: frame)

attribute()
layout()
}

/// Interface Builder를 통해 생성될 때 호출되는 초기화 함수입니다.
/// Interface Builder 사용을 지원하지 않습니다.
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

/// 라벨의 기본 속성을 설정하는 함수입니다.
/// 여기서 폰트, 색상 등의 기본적인 속성을 설정할 수 있습니다.
open func attribute() {
// 부가적인 것을 여기에 넣습니다.
// Attributes configuration
}

/// 라벨의 레이아웃을 구성하는 함수입니다.
/// SnapKit 라이브러리를 사용하여 레이아웃을 정의합니다.
open func layout() {
// 서브뷰를 구성하고 SnapKit을 사용해서 layout을 하는 함수입니다.
// Layout configuration using SnapKit
}

/// 라벨에 사용할 폰트를 설정합니다.
/// - Parameter font: 설정할 폰트
public func setPretendardFont(font: UIFont) {
// PretendardFont를 받습니다.
self.font = font
}

public func setColor(textColor: UIColor? = nil, backgroudColor: UIColor? = nil) {
// DSKit의 color를 받아줍니다.
/// 라벨의 텍스트와 배경 색상을 설정합니다.
/// - Parameters:
/// - textColor: 텍스트 색상
/// - backgroudColor: 배경 색상
public func setColor(
textColor: UIColor? = nil,
backgroudColor: UIColor? = nil
) {
if let textColor = textColor {
self.textColor = textColor
}
Expand All @@ -44,8 +60,14 @@ open class BaseLabel: UILabel {
}
}

public func setTextAlignmentAndNumberOfLines(alignment: NSTextAlignment? = nil, numberOfLines: Int? = nil) {
// numberOfLines와 Alignment를 받아줍니다.
/// 라벨의 텍스트 정렬과 줄 수를 설정합니다.
/// - Parameters:
/// - alignment: 텍스트 정렬
/// - numberOfLines: 텍스트 줄 수
public func setTextAlignmentAndNumberOfLines(
alignment: NSTextAlignment? = nil,
numberOfLines: Int? = nil
) {
if let alignment = alignment {
self.textAlignment = alignment
}
Expand Down
16 changes: 7 additions & 9 deletions Projects/Core/Sources/Base/BaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SnapKit
import RxSwift
import RxCocoa

/// BaseView는 UIView를 확장하여 범용적으로 사용할 수 있는 기본 뷰 클래스입니다.
open class BaseView: UIView {
public let disposeBag = DisposeBag()

Expand All @@ -19,15 +20,12 @@ open class BaseView: UIView {
fatalError("init(coder:) has not been implemented")
}

open func attribute() {
// 부가적인 것을 여기에 넣습니다.
}
/// 뷰의 기본 속성을 설정하는 함수입니다.
open func attribute() { }

open func layout() {
// 서브뷰를 구성하고 SnapKit을 사용해서 layout을 하는 함수입니다.
}
/// 이 함수에서는 각 서브뷰의 위치와 크기를 결정합니다.
open func layout() { }

open func bind() {
// 서브뷰를 구성하고 SnapKit을 사용해서 layout을 하는 함수입니다.
}
/// 이 함수에서는 RxCocoa를 활용하여 이벤트 처리 및 데이터 스트림을 관리합니다.
open func bind() { }
}
85 changes: 43 additions & 42 deletions Projects/Core/Sources/Base/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,48 @@ import RxCocoa

import SnapKit

/// BaseViewController는 UIViewController를 제네릭으로 확장하여 다양한 유형의 ViewModel을 지원합니다.
open class BaseViewController<T>: UIViewController {
/// ViewModel을 저장하는 변수, 제네릭 타입 T를 사용합니다.
public var viewModel: T

/// RxSwift의 메모리 관리를 위해 사용하는 DisposeBag 인스턴스.
public var disposeBag = DisposeBag()

/// RxFlow를 사용하여 흐름을 제어하는 PublishRelay.
public var steps = PublishRelay<Step>()

/// 화면 너비의 비율을 계산하는 프로퍼티.
public var width: CGFloat {
return view.frame.width / 430.0
}

/// 화면 높이의 비율을 계산하는 프로퍼티.
public var height: CGFloat {
return view.frame.height / 932.0
}

/// 기기 화면의 경계를 나타내는 상수.
let bounds = UIScreen.main.bounds

/// ViewController의 초기화 함수, ViewModel을 인자로 받습니다.
public init(_ viewModel: T) {
self.viewModel = viewModel
super .init(nibName: nil, bundle: nil)
super.init(nibName: nil, bundle: nil)
}

/// Interface Builder를 통해 생성될 때 호출되는 초기화 함수입니다.
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

/// View의 하위 뷰가 레이아웃될 때 호출됩니다.
open override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

configureNavigationBar()
}

/// View가 메모리에 로드된 후 호출됩니다.
open override func viewDidLoad() {
super.viewDidLoad()
bindActions()
Expand All @@ -44,63 +57,51 @@ open class BaseViewController<T>: UIViewController {
attribute()
}

/// 뷰의 기본 속성을 설정합니다.
open func attribute() {
view.backgroundColor = .white
}

open func layout() {
// 서브뷰를 구성하고 SnapKit을 사용해서 layout을 하는 함수입니다.
}
/// 서브뷰를 구성하고 SnapKit을 사용해서 레이아웃을 구성하는 함수입니다.
open func layout() { }

open func bindViewModel() {
// RxSwift를 사용하여 UI 바인딩을 설정을 하는 함수입니다.
}
/// ViewModel과의 바인딩을 설정하는 함수입니다.
open func bindViewModel() { }

open func configureNavigationBar() {
// 내비게이션 바의 모양과 동작을 사용자 지정하고 네비게이션 관련 코드를 설정하는 함수입니다.
}
/// 네비게이션 바를 사용자 정의하고 설정하는 함수입니다.
open func configureNavigationBar() { }

open func permissionControlHandling() {
// 권한 관련으로 핸들링 하는 작업입니다. (ex 카메라의 접근 해도 될까요?)
}
/// 권한 처리를 하는 함수입니다. 예를 들어 카메라 접근 권한 요청 등을 처리합니다.
open func permissionControlHandling() { }

/// 키보드 이벤트를 처리하는 함수입니다.
open func setupKeyboardHandling() { }

open func setupKeyboardHandling() {
// 키보드 인벤트처리를 하는 함수입니다.
}
/// 액션 바인딩을 설정하는 함수입니다. RxSwift를 사용하여 UI 이벤트를 처리합니다.
open func bindActions() { }

open func bindActions() {
// RxSwift를 사용하여 UI 요소들의 액션과 관련하여 반응형 동작을 설정하는 함수 입니다.
}
/// 테이블 뷰를 설정하고 초기화하는 함수입니다.
open func configureTableView() { }

open func configureTableView() {
// 테이블 뷰를 설정하고 초기화하기 위한 함수입니다.
}

open func configureCollectionView() {
// 컬렉션 뷰를 설정하고 초기화하기 위한 함수 입니다.
}
/// 컬렉션 뷰를 설정하고 초기화하는 함수입니다.
open func configureCollectionView() { }

open func showActivityIndicator() {
// 네트워크 요청 등 작업 진행 중에 인디케이터를 화면에 표시하는 함수입니다.
}
/// 네트워크 요청 등 작업 진행 중 화면에 인디케이터를 표시하는 함수입니다.
open func showActivityIndicator() { }

open func hideActivityIndicator() {
// 작업이 완료되었을 때 인디케이터를 화면에서 숨기는 함수입니다.
}
/// 작업 완료 후 화면에서 인디케이터를 숨기는 함수입니다.
open func hideActivityIndicator() { }

open func handleError(_ error: Error) {
// 발생한 오류에 대한 처리를 수행하는 함수입니다.
}
/// 오류 발생 시 처리를 수행하는 함수입니다.
open func handleError(_ error: Error) { }

open func showEmptyStateView() {
// 데이터가 없을 때 빈 상태를 표시하는 뷰를 보여주는 함수입니다.
}
/// 데이터가 없을 때 빈 상태의 뷰를 보여주는 함수입니다.
open func showEmptyStateView() { }

open func hideEmptyStateView() {
// 빈 상태 뷰를 숨기는 함수이며 데이터가 로드되어서 빈 상태가 아닌 경우 다시 호출됩니다
}
/// 빈 상태 뷰를 숨기는 함수입니다.
open func hideEmptyStateView() { }

/// 화면을 터치했을 때 키보드를 숨기는 이벤트를 처리합니다.
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
Expand Down

0 comments on commit 66df422

Please sign in to comment.