Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#41-postDetailUI
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonsu0-0 authored Jan 13, 2024
2 parents b59a385 + 1b5c0f4 commit eb8fae3
Show file tree
Hide file tree
Showing 44 changed files with 1,694 additions and 323 deletions.
96 changes: 92 additions & 4 deletions DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DontBe-iOS/DontBe-iOS/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
UINavigationBar.appearance().titleTextAttributes = [
NSAttributedString.Key.font: UIFont.font(.body1),
NSAttributedString.Key.foregroundColor: UIColor.donBlack
]
]

KakaoSDK.initSDK(appKey: Bundle.main.object(forInfoDictionaryKey: Config.Keys.Plist.nativeAppKey) as? String ?? "")
return true
Expand Down
16 changes: 14 additions & 2 deletions DontBe-iOS/DontBe-iOS/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
self.window?.makeKeyAndVisible()

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2.0) {
let navigationController = UINavigationController(rootViewController: LoginViewController(viewModel: LoginViewModel()))
// let navigationController = UINavigationController(rootViewController: LoginViewController(viewModel: LoginViewModel()))
// let navigationController = UINavigationController(rootViewController: DontBeTabBarController())
self.window?.rootViewController = navigationController
if loadUserData()?.isSocialLogined == true && loadUserData()?.isJoinedApp == true && loadUserData()?.isOnboardingFinished == true {
let navigationController = UINavigationController(rootViewController: DontBeTabBarController())
self.window?.rootViewController = navigationController
} else if loadUserData()?.isJoinedApp == false {
let navigationController = UINavigationController(rootViewController: LoginViewController(viewModel: LoginViewModel()))
self.window?.rootViewController = navigationController
} else if loadUserData()?.isOnboardingFinished == false {
let navigationController = UINavigationController(rootViewController: OnboardingViewController())
self.window?.rootViewController = navigationController
} else {
let navigationController = UINavigationController(rootViewController: LoginViewController(viewModel: LoginViewModel()))
self.window?.rootViewController = navigationController
}
self.window?.makeKeyAndVisible()
}
}
Expand Down
40 changes: 38 additions & 2 deletions DontBe-iOS/DontBe-iOS/Global/Extension/UILabel+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,55 @@
import UIKit

extension UILabel {
func setTextWithLineHeight(text: String?, lineHeight: CGFloat){
func setTextWithLineHeight(text: String?, lineHeight: CGFloat, alignment: NSTextAlignment){
if let text = text {
let style = NSMutableParagraphStyle()
style.maximumLineHeight = lineHeight
style.minimumLineHeight = lineHeight

let attributes: [NSAttributedString.Key: Any] = [
.paragraphStyle: style,
]

let attrString = NSAttributedString(string: text,
attributes: attributes)
self.attributedText = attrString
self.textAlignment = alignment
}
}

/// 특정 텍스트만 폰트를 다르게 주는 함수
func asFont(targetString: String, font: UIFont) {
let fullText = text ?? ""
let attributedString = NSMutableAttributedString(string: fullText)
let range = (fullText as NSString).range(of: targetString)
attributedString.addAttribute(.font, value: font, range: range)
attributedText = attributedString
}

func setTextWithLineHeightAndFont(text: String?, lineHeight: CGFloat, targetString: String, font: UIFont) {
if let text = text {
let style = NSMutableParagraphStyle()
style.maximumLineHeight = lineHeight
style.minimumLineHeight = lineHeight

let attributes: [NSAttributedString.Key: Any] = [
.paragraphStyle: style,
.font: UIFont.font(.body4)
]

let attrString = NSMutableAttributedString(string: text, attributes: attributes)

// 특정 문자열에 대해서만 폰트 변경
let range = (text as NSString).range(of: targetString)
attrString.addAttribute(.font, value: font, range: range)

self.attributedText = attrString
}
}

class func lineNumber(label: UILabel, labelWidth: CGFloat) -> Int {
let boundingRect = label.text?.boundingRect(with: .zero, options: [.usesFontLeading], attributes: [.font: label.font as Any], context: nil)
return Int((boundingRect?.width ?? 0) / labelWidth + 1)
}
}
17 changes: 9 additions & 8 deletions DontBe-iOS/DontBe-iOS/Global/Extension/UITextView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@ import UIKit
import SnapKit

extension UITextView {
func addPlaceholder(_ placeholder: String) {
func addPlaceholder(_ placeholder: String, padding: UIEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)) {
let placeholderLabel = UILabel()
placeholderLabel.text = placeholder
placeholderLabel.textColor = .donGray8
placeholderLabel.textAlignment = .left
placeholderLabel.font = self.font

placeholderLabel.numberOfLines = 0

self.addSubview(placeholderLabel)

placeholderLabel.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.edges.equalToSuperview().inset(padding)
}

NotificationCenter.default.addObserver(self, selector: #selector(textViewTextDidChange), name: UITextView.textDidChangeNotification, object: nil)

updatePlaceholderVisibility(placeholderLabel)
}

@objc private func textViewTextDidChange() {
for subview in self.subviews {
if let placeholderLabel = subview as? UILabel, placeholderLabel.textColor == .donGray8 {
updatePlaceholderVisibility(placeholderLabel)
}
}
}

private func updatePlaceholderVisibility(_ placeholderLabel: UILabel) {
placeholderLabel.isHidden = !self.text.isEmpty
}
Expand Down
8 changes: 7 additions & 1 deletion DontBe-iOS/DontBe-iOS/Global/Literals/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ enum ImageLiterals {
static var icnHomeSelected: UIImage { .load(name: "icn_home_selected") }
static var icnWriting: UIImage { .load(name: "icn_writing") }
static var icnWritingSelected: UIImage { .load(name: "icn_writing_selected") }
static var icnNotification: UIImage { .load(name: "icn_notification") }
static var icnNotificationRead: UIImage { .load(name: "icn_notification").withRenderingMode(.alwaysOriginal) }
static var icnNotificationUnread: UIImage { .load(name: "icn_notification_unread").withRenderingMode(.alwaysOriginal) }
static var icnNotificationSelected: UIImage { .load(name: "icn_notification_selected") }
static var icnMyPage: UIImage { .load(name: "icn_mypage") }
static var icnMyPageSelected: UIImage { .load(name: "icn_mypage_selected") }
Expand Down Expand Up @@ -74,6 +75,11 @@ enum ImageLiterals {
static var icnCheck: UIImage { .load(name: "icn_check") }
}

enum Notification {
static var imgNotice: UIImage { .load(name: "img_notice") }
static var imgEmpty: UIImage { .load(name: "img_empty") }
}

enum MyPage {
static var icnMenu: UIImage { .load(name: "icn_menu") }
static var icnEditProfile: UIImage { .load(name: "icn_editprofile") }
Expand Down
21 changes: 20 additions & 1 deletion DontBe-iOS/DontBe-iOS/Global/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,44 @@ enum StringLiterals {

enum Onboarding {
static let placeHolder = "한문장으로 소개를 남겨주세요!"
static let information = "설정한 사진, 닉네임, 한줄소개는 설정에서 변경 가능해요!"
static let information = "설정한 사진, 닉네임, 한줄소개는 설정에서 변경 가능해요!\n작성한 한 줄 소개는 작성한 게시글로 업로드 돼요."
}

enum Button {
static let skip = "건너뛰기"
static let next = "다음으로"
static let start = "시작하기"
static let later = "한 줄 소개 나중에 작성하기"
static let finish = "완료하기"
static let editFinish = "수정완료"
}

enum Toast {
static let uploading = "게시 중..."
static let uploaded = "게시 완료!"
}

enum Notification {
static let alarm = "알림"
static let likeContent = "님이 회원님의 글을 좋아합니다."
static let writeComment = "님이 답글을 작성했습니다."
static let likeComment = "님이 회원님의 답글을 좋아합니다."
static let welcome = "님, 이제 다시 글을 작성할 수 있어요! 오랜만에 인사를 남겨주세요!"
static let transparency = "님, 투명해져서 당분간 글을 작성할 수 없어요."
static let violation = "님 커뮤니티 활동 정책 위반으로 더이상 돈비를 이용할 수 없어요. 자세한 내용은 문의사항으로 남겨주세요."
static let emphasizeViolation = "님 커뮤니티 활동 정책 위반으로 더이상 돈비를 이용할 수 없어요."
static let contentTransparency = "님, 작성하신 게시글로 인해 점점 투명해지고 있어요."
static let commentTransparency = "님, 작성하신 답글로 인해 점점 투명해지고 있어요."
static let emptyTitle = "아직 받은 알림이 없어요."
static let emptyDescription = "새로운 소식이 도착하면 알려드릴게요."
}

enum MyPage {
static let MyPageNavigationTitle = "마이"
static let MyPageEditNavigationTitle = "프로필 편집"
static let MyPageAccountInfoNavigationTitle = "계정 정보"
static let myPageEditIntroduction = "한줄 소개"
static let myPageEditIntroductionPlease = "한 줄로 자신을 소개해주세요."
}

enum TransparencyInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "img_empty.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "image_notice_management.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property 1=badge.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UITableViewCell.swift
// DontBe-iOS
//
// Created by 변희주 on 1/12/24.
//

import UIKit

public protocol UITableViewCellRegisterable where Self: UITableViewCell {
static func register(tableView: UITableView)
static func dequeueReusableCell(tableView: UITableView, indexPath: IndexPath) -> Self
static var reuseIdentifier: String { get }
}

extension UITableViewCellRegisterable {
public static func register(tableView: UITableView) {
tableView.register(self, forCellReuseIdentifier: self.reuseIdentifier)
}

public static func dequeueReusableCell(tableView: UITableView, indexPath: IndexPath) -> Self {
guard let cell = tableView.dequeueReusableCell(withIdentifier: self.reuseIdentifier, for: indexPath) as? Self else { fatalError()}
return cell
}

public static var reuseIdentifier: String {
return String(describing: self)
}
}
25 changes: 24 additions & 1 deletion DontBe-iOS/DontBe-iOS/Presentation/Helpers/UserInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@

import Foundation

struct UserInfo {
struct UserInfo: Codable {
let isSocialLogined: Bool
let isJoinedApp: Bool
let isNotFirstUser: Bool
let isOnboardingFinished: Bool
let userNickname: String
}

// 구조체를 UserDefault에 저장하는 함수
func saveUserData(_ userData: UserInfo) {
let encoder = JSONEncoder()
if let encodedData = try? encoder.encode(userData) {
UserDefaults.standard.set(encodedData, forKey: "saveUserInfo")
}
}

// UserDefault에서 구조체를 가져오는 함수
func loadUserData() -> UserInfo? {
if let encodedData = UserDefaults.standard.data(forKey: "saveUserInfo") {
let decoder = JSONDecoder()
if let userData = try? decoder.decode(UserInfo.self, from: encodedData) {
return userData
}
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class JoinAgreementViewController: UIViewController {

extension JoinAgreementViewController {
private func setUI() {
self.view.backgroundColor = .donWhite
self.view.backgroundColor = .donGray1
self.navigationItem.title = StringLiterals.Join.joinNavigationTitle
}

Expand Down Expand Up @@ -163,6 +163,7 @@ extension JoinAgreementViewController {
output.pushViewController
.sink { _ in
let viewController = JoinProfileViewController(viewModel: JoinProfileViewModel())
self.navigationBackButton.removeFromSuperview()
self.navigationController?.pushViewController(viewController, animated: true)
}
.store(in: self.cancelBag)
Expand Down
Loading

0 comments on commit eb8fae3

Please sign in to comment.