-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge remote-tracking branch 'origin/develop' into release
* origin/develop: fix: SplashViewReactor 화면 전환 issue 수정 (#702) fix: MyUserDefaults memberId, userName Type Annotation String으로 수정 (#700) fix: 로그인 버튼 클릭시 touch event cancel 현상 수정해요 (#695) fix: QA issue를 수정합니다(#696) feat: AlertService 구현 (#692) refactor: Calendar 관련 뷰 컨트롤러, 리액터 등 부가 코드 리팩토링 (#682)
Showing
81 changed files
with
2,303 additions
and
2,036 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
14th-team5-iOS/App/Sources/Presentation/Calendar/Config/CalendarImageCell+Type.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// CalendarType.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum MomoriesCalendarType { | ||
case daily | ||
case month | ||
} |
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
...ntation/Calendar/Reactive/DelegateProxy/Delegate/MemoriesCalendarPostHeaderDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// File.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/18/24. | ||
// | ||
|
||
import UIKit | ||
|
||
@objc protocol MemoriesCalendarPostHeaderDelegate: AnyObject { | ||
@objc optional func didTapProfileImageButton(_ button: UIButton, event: UIButton.Event) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...es/Presentation/Calendar/Reactive/DelegateProxy/RxMemoriesCalendarPostDelegateProxy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// RxMemoriesCalendarPostDelegate.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/18/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxCocoa | ||
import RxSwift | ||
|
||
final class RxMemoriesCalendarPostDelegateProxy: DelegateProxy<MemoriesCalendarPostHeaderView, MemoriesCalendarPostHeaderDelegate>, DelegateProxyType, MemoriesCalendarPostHeaderDelegate { | ||
|
||
public static func registerKnownImplementations() { | ||
self.register { RxMemoriesCalendarPostDelegateProxy(parentObject: $0, delegateProxy: self) } | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPostHeaderView: HasDelegate { | ||
public typealias Delegate = MemoriesCalendarPostHeaderDelegate | ||
} | ||
|
||
extension Reactive where Base: MemoriesCalendarPostHeaderView { | ||
|
||
var delegate: DelegateProxy<MemoriesCalendarPostHeaderView, MemoriesCalendarPostHeaderDelegate> { | ||
return RxMemoriesCalendarPostDelegateProxy.proxy(for: self.base) | ||
} | ||
|
||
/// 프로필 버튼을 클릭하면 빈 항목이 담긴 스트림이 흐릅니다. | ||
var didTapProfileImageButton: ControlEvent<Void> { | ||
let source = delegate.methodInvoked(#selector(MemoriesCalendarPostHeaderDelegate.didTapProfileImageButton(_:event:))) | ||
.map { _ in () } | ||
return ControlEvent(events: source) | ||
} | ||
|
||
} |
104 changes: 0 additions & 104 deletions
104
14th-team5-iOS/App/Sources/Presentation/Calendar/Reactor/CalendarImageCellReactor.swift
This file was deleted.
Oops, something went wrong.
125 changes: 0 additions & 125 deletions
125
14th-team5-iOS/App/Sources/Presentation/Calendar/Reactor/CalendarPageViewCellReactor.swift
This file was deleted.
Oops, something went wrong.
111 changes: 0 additions & 111 deletions
111
14th-team5-iOS/App/Sources/Presentation/Calendar/Reactor/CalendarPostCellReactor.swift
This file was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
...eam5-iOS/App/Sources/Presentation/Calendar/Reactor/Cell/MemoriesCalendarCellReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// | ||
// ImageCalendarCellReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 12/9/23. | ||
// | ||
|
||
import Core | ||
import DesignSystem | ||
import Domain | ||
import Foundation | ||
|
||
import ReactorKit | ||
import MacrosInterface | ||
|
||
@Reactor | ||
final public class MemoriesCalendarCellReactor { | ||
|
||
// MARK: - Typealias | ||
|
||
public typealias Action = NoAction | ||
|
||
// MARK: - Mutate | ||
|
||
public enum Mutation { | ||
case didSelect(Bool) | ||
} | ||
|
||
// MARK: - State | ||
|
||
public struct State { | ||
var date: Date | ||
var thumbnailImageUrl: String | ||
var allMemebersUploaded: Bool | ||
var isSelected: Bool | ||
} | ||
|
||
|
||
// MARK: - Properties | ||
|
||
public let type: MomoriesCalendarType | ||
public var initialState: State | ||
|
||
@Injected var provider: ServiceProviderProtocol | ||
|
||
|
||
// MARK: - Intializer | ||
|
||
init( | ||
of type: MomoriesCalendarType, | ||
with entity: MonthlyCalendarEntity, | ||
isSelected selection: Bool = false | ||
) { | ||
self.type = type | ||
self.initialState = State( | ||
date: entity.date, | ||
thumbnailImageUrl: entity.representativeThumbnailUrl, | ||
allMemebersUploaded: entity.allFamilyMemebersUploaded, | ||
isSelected: selection | ||
) | ||
} | ||
|
||
// MARK: - Transform | ||
|
||
public func transform(mutation: Observable<Mutation>) -> Observable<Mutation> { | ||
let eventMutation = provider.calendarService.event | ||
.flatMap(with: self) { | ||
switch $1 { | ||
case let .didSelect(current): | ||
let cellDate = $0.initialState.date | ||
// 셀 내 날짜와 선택한 날짜가 동일하면 | ||
if cellDate.isEqual(with: current) { | ||
// 이전에 선택된 날짜 불러오기 | ||
let previous = $0.provider.calendarService.getPreviousSelection() | ||
// 모든 가족 구성원이 게시물을 업로드하고, | ||
// 셀 내 날짜와 이전에 선택된 날짜가 동일하지 않다면 (캘린더를 스크롤하더라도 토스트가 다시 뜨지 않게) | ||
if !cellDate.isEqual(with: previous) && $0.initialState.allMemebersUploaded { | ||
// TODO: - 로직 간소화하기 | ||
let viewConfig = BBToastViewConfiguration(minWidth: 100) | ||
$0.provider.bbToastService.show( | ||
image: DesignSystemAsset.fire.image, | ||
title: "우리 가족 모두가 사진을 올린 날", | ||
viewConfig: viewConfig | ||
) | ||
} | ||
return Observable<Mutation>.just(.didSelect(true)) | ||
} else { | ||
return Observable<Mutation>.just(.didSelect(false)) | ||
} | ||
} | ||
} | ||
|
||
return Observable<Mutation>.merge(mutation, eventMutation) | ||
} | ||
|
||
|
||
// MARK: - Reduce | ||
|
||
public func reduce(state: State, mutation: Mutation) -> State { | ||
var newState = state | ||
switch mutation { | ||
case let .didSelect(bool): | ||
newState.isSelected = bool | ||
} | ||
return newState | ||
} | ||
|
||
} |
129 changes: 129 additions & 0 deletions
129
...eam5-iOS/App/Sources/Presentation/Calendar/Reactor/Cell/MemoriesCalendarPageReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// | ||
// CalendarPageViewCellReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 12/6/23. | ||
// | ||
|
||
import Core | ||
import Data | ||
import Domain | ||
import Foundation | ||
import MacrosInterface | ||
|
||
import ReactorKit | ||
|
||
@Reactor | ||
public final class MemoriesCalendarPageReactor { | ||
|
||
// MARK: - Action | ||
|
||
public enum Action { | ||
case didSelect(Date) | ||
case viewDidLoad | ||
} | ||
|
||
|
||
// MARK: - Mutation | ||
|
||
public enum Mutation { | ||
case setBannerInfo(BannerEntity) | ||
case setStatisticsSummary(FamilyMonthlyStatisticsEntity) | ||
case setMonthlyCalendar(ArrayResponseMonthlyCalendarEntity) | ||
} | ||
|
||
|
||
// MARK: - State | ||
|
||
public struct State { | ||
var yearMonth: String | ||
var bannerInfo: BannerViewModel.State? | ||
var imageCount: Int? | ||
var calendarEntity: ArrayResponseMonthlyCalendarEntity? | ||
} | ||
|
||
|
||
// MARK: - Properties | ||
|
||
public var initialState: State | ||
|
||
@Injected var provider: ServiceProviderProtocol | ||
@Injected var fetchCalendarBannerUseCase: FetchCalendarBannerUseCaseProtocol | ||
@Injected var fetchStatisticsSummaryUseCase: FetchStatisticsSummaryUseCaseProtocol | ||
@Injected var fetchMonthlyCalendarUseCase: FetchMonthlyCalendarUseCaseProtocol | ||
|
||
@Navigator var navigator: MonthlyCalendarNavigatorProtocol | ||
|
||
// MARK: - Intializer | ||
|
||
init(yearMonth: String) { | ||
self.initialState = State(yearMonth: yearMonth) | ||
} | ||
|
||
|
||
// MARK: - Mutate | ||
|
||
public func mutate(action: Action) -> Observable<Mutation> { | ||
switch action { | ||
case .viewDidLoad: | ||
let yearMonth = initialState.yearMonth | ||
return Observable<Mutation>.merge( | ||
setCalendarBannrInfo(yearMonth: yearMonth), | ||
setStatisticsSummary(yearMonth: yearMonth), | ||
setMonthlyCalendar(yearMonth: yearMonth) | ||
) | ||
|
||
case let .didSelect(date): | ||
navigator.toDailyCalendar(selection: date) | ||
return Observable<Mutation>.empty() | ||
} | ||
} | ||
|
||
|
||
// MARK: - Reduce | ||
|
||
public func reduce(state: State, mutation: Mutation) -> State { | ||
var newState = state | ||
switch mutation { | ||
case let .setBannerInfo(banner): | ||
let bannerState = BannerViewModel.State( | ||
familyTopPercentage: banner.familyTopPercentage, | ||
allFamilyMemberUploadedDays: banner.allFammilyMembersUploadedDays, | ||
bannerImage: banner.bannerImage, | ||
bannerString: banner.bannerString, | ||
bannerColor: banner.bannerColor | ||
) | ||
newState.bannerInfo = bannerState | ||
|
||
case let .setStatisticsSummary(statistics): | ||
newState.imageCount = statistics.totalImageCnt | ||
|
||
case let .setMonthlyCalendar(arrayCalendarResponse): | ||
newState.calendarEntity = arrayCalendarResponse | ||
} | ||
return newState | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
private extension MemoriesCalendarPageReactor { | ||
|
||
func setCalendarBannrInfo(yearMonth: String) -> Observable<Mutation> { | ||
return fetchCalendarBannerUseCase.execute(yearMonth: yearMonth) | ||
.flatMap { Observable<Mutation>.just(.setBannerInfo($0)) } | ||
} | ||
|
||
func setStatisticsSummary(yearMonth: String) -> Observable<Mutation> { | ||
return fetchStatisticsSummaryUseCase.execute(yearMonth: yearMonth) | ||
.flatMap { Observable<Mutation>.just(.setStatisticsSummary($0)) } | ||
} | ||
|
||
func setMonthlyCalendar(yearMonth: String) -> Observable<Mutation> { | ||
return fetchMonthlyCalendarUseCase.execute(yearMonth: yearMonth) | ||
.flatMap { Observable<Mutation>.just(.setMonthlyCalendar($0)) } | ||
} | ||
|
||
} |
126 changes: 126 additions & 0 deletions
126
...-iOS/App/Sources/Presentation/Calendar/Reactor/Cell/MemoriesCalendarPostCellReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// | ||
// CalendarPostCellReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 5/7/24. | ||
// | ||
|
||
import Core | ||
import Domain | ||
import Foundation | ||
import MacrosInterface | ||
|
||
import ReactorKit | ||
|
||
@Reactor | ||
public final class MemoriesCalendarPostCellReactor { | ||
|
||
// MARK: - Action | ||
|
||
public enum Action { | ||
case viewDidLoad | ||
case didTapProfileImageButton | ||
} | ||
|
||
// MARK: - Mutation | ||
|
||
public enum Mutation { | ||
case setMemberName(String) | ||
case setProfileImageUrl(URL) | ||
case setContentDatasource([DisplayEditItemModel]) | ||
} | ||
|
||
// MARK: - State | ||
|
||
public struct State { | ||
var dailyPost: DailyCalendarEntity | ||
var memberName: String? | ||
var profileImageUrl: URL? | ||
var contentDatasource: [DisplayEditSectionModel]? | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public var initialState: State | ||
|
||
@Injected var fetchUserNameUseCase: FetchUserNameUseCaseProtocol | ||
@Injected var fetchProfileImageUrlUseCase: FetchProfileImageUrlUseCaseProtocol | ||
@Injected var checkIsVaildMemberUseCase: CheckIsVaildMemberUseCaseProtocol | ||
@Injected var provider: ServiceProviderProtocol | ||
|
||
@Navigator var navigator: DailyCalendarNavigatorProtocol | ||
|
||
|
||
// MARK: - Intializer | ||
|
||
public init(postEntity entity: DailyCalendarEntity) { | ||
self.initialState = State(dailyPost: entity) | ||
} | ||
|
||
// MARK: - Mutate | ||
|
||
public func mutate(action: Action) -> Observable<Mutation> { | ||
switch action { | ||
case .viewDidLoad: | ||
let memberId = initialState.dailyPost.authorId | ||
return Observable<Mutation>.concat( | ||
setMemberName(memberId: memberId), | ||
setProfileImageUrl(memberId: memberId), | ||
setContentDatasource(post: initialState.dailyPost) | ||
) | ||
|
||
case .didTapProfileImageButton: | ||
let memberId = initialState.dailyPost.authorId | ||
if checkIsVaildMemberUseCase.execute(memberId: memberId) { | ||
navigator.toProfile(memberId: memberId) | ||
} | ||
return Observable<Mutation>.empty() | ||
} | ||
} | ||
|
||
// MARK: - Reduce | ||
|
||
public func reduce(state: State, mutation: Mutation) -> State { | ||
var newState = state | ||
switch mutation { | ||
case let .setMemberName(name): | ||
newState.memberName = name | ||
|
||
case let .setProfileImageUrl(url): | ||
newState.profileImageUrl = url | ||
|
||
case let .setContentDatasource(section): | ||
newState.contentDatasource = [.displayKeyword(section)] | ||
} | ||
return newState | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
private extension MemoriesCalendarPostCellReactor { | ||
|
||
func setMemberName(memberId: String) -> Observable<Mutation> { | ||
let memberName = fetchUserNameUseCase.execute(memberId: memberId) | ||
return Observable<Mutation>.just(.setMemberName(memberName)) | ||
} | ||
|
||
func setProfileImageUrl(memberId: String) -> Observable<Mutation> { | ||
let imageUrl = fetchProfileImageUrlUseCase.execute(memberId: memberId) | ||
if let url = imageUrl { | ||
return Observable<Mutation>.just(.setProfileImageUrl(url)) | ||
} | ||
return Observable<Mutation>.empty() | ||
} | ||
|
||
func setContentDatasource(post: DailyCalendarEntity) -> Observable<Mutation> { | ||
var sectionItem: [DisplayEditItemModel] = [] | ||
post.postContent?.forEach { | ||
sectionItem.append(.fetchDisplayItem(.init(title: String($0), radius: 10, font: .head2Bold))) | ||
} | ||
return Observable<Mutation>.just(.setContentDatasource(sectionItem)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...am5-iOS/App/Sources/Presentation/Calendar/Reactor/MemoriesCalendarPostHeaderReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// MemoriesCalendarPostHeaderReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/17/24. | ||
// | ||
|
||
import Core | ||
import Domain | ||
import Foundation | ||
|
||
import ReactorKit | ||
|
||
final public class MemoriesCalendarPostHeaderReactor: Reactor { | ||
|
||
public typealias Action = NoAction | ||
|
||
// MARK: - Mutate | ||
|
||
public enum Mutation { } | ||
|
||
// MARK: - State | ||
|
||
public struct State { | ||
var memberName: String? | ||
var profileImageUrl: URL? | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public let initialState: State | ||
|
||
// MARK: - Intializer | ||
|
||
public init() { self.initialState = State() } | ||
|
||
|
||
// MARK: - Mutate | ||
|
||
public func mutate(action: Action) -> Observable<Mutation> { | ||
return .empty() | ||
} | ||
|
||
|
||
// MARK: - Reduce | ||
|
||
public func reduce(state: State, mutation: Mutation) -> State { | ||
return state | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...eam5-iOS/App/Sources/Presentation/Calendar/Reactor/MemoriesCalendarPostImageReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// MemoriesCalendarPostImageReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/17/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import ReactorKit | ||
|
||
final public class MemoriesCalendarPostImageReactor: Reactor { | ||
|
||
public typealias Action = NoAction | ||
|
||
// MARK: - State | ||
|
||
public struct State { } | ||
|
||
// MARK: - Properties | ||
|
||
public let initialState: State | ||
|
||
// MARK: - Intializer | ||
|
||
public init() { self.initialState = State() } | ||
|
||
} | ||
|
64 changes: 64 additions & 0 deletions
64
...eam5-iOS/App/Sources/Presentation/Calendar/Reactor/MemoriesCalendarTitleViewReactor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// MemoriesCalendarTitleViewReactor.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/16/24. | ||
// | ||
|
||
import ReactorKit | ||
import MacrosInterface | ||
|
||
@Reactor | ||
final public class MemoriesCalendarTitleViewReactor { | ||
|
||
// MARK: - Action | ||
|
||
public enum Action { | ||
case didTapTipButton | ||
} | ||
|
||
// MARK: - Mutation | ||
|
||
public enum Mutation { | ||
case setTooltipHidden(hidden: Bool) | ||
} | ||
|
||
// MARK: - State | ||
|
||
public struct State { | ||
@Pulse var hiddenTooltipView: Bool = true | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public var initialState: State = State() | ||
|
||
// MARK: - Intializer | ||
|
||
public init() { | ||
self.initialState = State() | ||
} | ||
|
||
|
||
// MARK: - Mutate | ||
|
||
public func mutate(action: Action) -> Observable<Mutation> { | ||
switch action { | ||
case .didTapTipButton: | ||
return Observable<Mutation>.just(.setTooltipHidden(hidden: !currentState.hiddenTooltipView)) | ||
} | ||
} | ||
|
||
|
||
// MARK: - Reduce | ||
|
||
public func reduce(state: State, mutation: Mutation) -> State { | ||
var newState = state | ||
switch mutation { | ||
case let .setTooltipHidden(hidden): | ||
newState.hiddenTooltipView = hidden | ||
} | ||
return newState | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
14th-team5-iOS/App/Sources/Presentation/Calendar/Strings/CalenderStrings.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
263 changes: 0 additions & 263 deletions
263
14th-team5-iOS/App/Sources/Presentation/Calendar/View/Cell/CalendarCell.swift
This file was deleted.
Oops, something went wrong.
268 changes: 0 additions & 268 deletions
268
14th-team5-iOS/App/Sources/Presentation/Calendar/View/Cell/CalendarPostCell.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
226 changes: 226 additions & 0 deletions
226
...-team5-iOS/App/Sources/Presentation/Calendar/View/Cell/MemoriesCalendarPageViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
// | ||
// CalendarPageViewCell.swift | ||
// App | ||
// | ||
// Created by 김건우 on 12/6/23. | ||
// | ||
|
||
import Core | ||
import DesignSystem | ||
import Domain | ||
import SwiftUI | ||
import UIKit | ||
|
||
import FSCalendar | ||
import ReactorKit | ||
import RxCocoa | ||
import RxSwift | ||
import SnapKit | ||
import Then | ||
|
||
final class MemoriesCalendarPageViewCell: BaseCollectionViewCell<MemoriesCalendarPageReactor> { | ||
|
||
// MARK: - Id | ||
|
||
static var id: String = "CalendarCell" | ||
|
||
|
||
// MARK: - Views | ||
|
||
private lazy var titleView = makeMemoriesCalendarTitleView() | ||
private lazy var bannerViewController = BannerHostingViewController(reactor: reactor) | ||
private let calendarView: FSCalendar = FSCalendar() | ||
|
||
|
||
// MARK: - Properties | ||
|
||
private let infoImage: UIImage = DesignSystemAsset.infoCircleFill.image | ||
.withRenderingMode(.alwaysTemplate) | ||
|
||
|
||
// MARK: - Helpers | ||
|
||
override func bind(reactor: MemoriesCalendarPageReactor) { | ||
super.bind(reactor: reactor) | ||
|
||
bindInput(reactor: reactor) | ||
bindOutput(reactor: reactor) | ||
} | ||
|
||
private func bindInput(reactor: MemoriesCalendarPageReactor) { | ||
Observable.just(()) | ||
.map { Reactor.Action.viewDidLoad } | ||
.bind(to: reactor.action) | ||
.disposed(by: disposeBag) | ||
|
||
calendarView.rx.didSelect | ||
.map { Reactor.Action.didSelect($0) } | ||
.bind(to: reactor.action) | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
private func bindOutput(reactor: MemoriesCalendarPageReactor) { | ||
|
||
let yearMonth = reactor.state.map { $0.yearMonth } | ||
.map { $0.toDate(with: .dashYyyyMM) } | ||
.asDriver(onErrorJustReturn: .distantPast) | ||
|
||
yearMonth | ||
.drive(with: self, onNext: { $0.titleView.setTitle($1.toFormatString(with: "yyyy년 M월")) }) | ||
.disposed(by: disposeBag) | ||
|
||
yearMonth | ||
.drive(calendarView.rx.currentPage) | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.compactMap { $0.imageCount } | ||
.distinctUntilChanged() | ||
.bind(with: self) { $0.titleView.setMemoryCount($1) } | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.compactMap { $0.bannerInfo } | ||
.distinctUntilChanged(\.familyTopPercentage) | ||
.bind(with: self) { $0.bannerViewController.updateState($1) } | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.map { $0.calendarEntity } | ||
.withUnretained(self) | ||
.subscribe { $0.0.calendarView.reloadData() } | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
override func setupUI() { | ||
super.setupUI() | ||
contentView.addSubviews(bannerViewController.view, calendarView, titleView) | ||
} | ||
|
||
override func setupAutoLayout() { | ||
super.setupAutoLayout() | ||
|
||
titleView.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(24) | ||
$0.horizontalEdges.equalToSuperview().inset(24) | ||
$0.height.equalTo(24) | ||
} | ||
|
||
bannerViewController.view.snp.makeConstraints { | ||
$0.top.equalTo(titleView.snp.bottom).offset(22) | ||
$0.horizontalEdges.equalToSuperview().inset(20) | ||
$0.bottom.equalTo(calendarView.snp.top).offset(-28) | ||
} | ||
|
||
calendarView.snp.makeConstraints { | ||
$0.bottom.equalToSuperview().offset(UIScreen.isPhoneSE ? -8 : -30) | ||
$0.horizontalEdges.equalToSuperview().inset(0.5) | ||
$0.height.equalTo(contentView.snp.width).multipliedBy(0.98) | ||
} | ||
} | ||
|
||
override func setupAttributes() { | ||
super.setupAttributes() | ||
|
||
calendarView.do { | ||
$0.headerHeight = 0 | ||
$0.weekdayHeight = 40 | ||
|
||
$0.today = nil | ||
$0.scrollEnabled = false | ||
$0.placeholderType = .fillSixRows | ||
$0.adjustsBoundingRectWhenChangingMonths = true | ||
|
||
$0.appearance.selectionColor = UIColor.clear | ||
$0.appearance.titleFont = UIFont.style(.body1Regular) | ||
$0.appearance.titleDefaultColor = UIColor.bibbiWhite | ||
$0.appearance.titleSelectionColor = UIColor.bibbiWhite | ||
$0.appearance.weekdayFont = UIFont.style(.caption) | ||
$0.appearance.weekdayTextColor = UIColor.gray300 | ||
$0.appearance.caseOptions = .weekdayUsesSingleUpperCase | ||
$0.appearance.titlePlaceholderColor = UIColor.gray700 | ||
|
||
$0.backgroundColor = UIColor.clear | ||
|
||
$0.locale = Locale(identifier: "ko_kr") | ||
$0.register(MemoriesCalendarCell.self, forCellReuseIdentifier: MemoriesCalendarCell.id) | ||
$0.register(MemoriesCalendarPlaceholderCell.self, forCellReuseIdentifier: MemoriesCalendarPlaceholderCell.id) | ||
|
||
$0.delegate = self | ||
$0.dataSource = self | ||
} | ||
|
||
} | ||
} | ||
|
||
// MARK: - Extensions | ||
|
||
extension MemoriesCalendarPageViewCell: FSCalendarDelegate { | ||
|
||
func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool { | ||
let currentMonth = date.month | ||
let visibleMonth = calendar.currentPage.month | ||
|
||
if let cell = calendar.cell(for: date, at: monthPosition) as? MemoriesCalendarCell { | ||
if visibleMonth == currentMonth && cell.hasThumbnailImage { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPageViewCell: FSCalendarDataSource { | ||
|
||
func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell { | ||
let currentMonth = date.month | ||
let visibleMonth = calendar.currentPage.month | ||
|
||
if visibleMonth == currentMonth { | ||
let cell = calendar.dequeueReusableCell( | ||
withIdentifier: MemoriesCalendarCell.id, | ||
for: date, | ||
at: position | ||
) as! MemoriesCalendarCell | ||
|
||
guard | ||
let entity = reactor?.currentState | ||
.calendarEntity?.results | ||
.first(where: { $0.date == date }) | ||
else { | ||
let entity = MonthlyCalendarEntity( | ||
date: date, | ||
representativePostId: "", | ||
representativeThumbnailUrl: "", | ||
allFamilyMemebersUploaded: false | ||
) | ||
cell.reactor = MemoriesCalendarCellReactor( | ||
of: .month, | ||
with: entity | ||
) | ||
return cell | ||
} | ||
|
||
cell.reactor = MemoriesCalendarCellReactor( | ||
of: .month, | ||
with: entity | ||
) | ||
return cell | ||
|
||
} else { | ||
let cell = calendar.dequeueReusableCell( | ||
withIdentifier: MemoriesCalendarPlaceholderCell.id, | ||
for: date, | ||
at: position | ||
) as! MemoriesCalendarPlaceholderCell | ||
return cell | ||
} | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPageViewCell { | ||
|
||
private func makeMemoriesCalendarTitleView() -> MemoriesCalendarPageTitleView { | ||
MemoriesCalendarPageTitleView(reactor: .init()) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
208 changes: 208 additions & 0 deletions
208
14th-team5-iOS/App/Sources/Presentation/Calendar/View/Cell/MemoriesCalendarPostCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
// | ||
// CalendarPostCell.swift | ||
// App | ||
// | ||
// Created by 김건우 on 5/7/24. | ||
// | ||
|
||
import Core | ||
import Domain | ||
import UIKit | ||
|
||
import SnapKit | ||
import Then | ||
import RxSwift | ||
import RxCocoa | ||
import RxDataSources | ||
import Kingfisher | ||
|
||
final class MemoriesCalendarPostCell: BaseCollectionViewCell<MemoriesCalendarPostCellReactor> { | ||
|
||
// MARK: - Typealias | ||
|
||
typealias RxDataSource = RxCollectionViewSectionedReloadDataSource<DisplayEditSectionModel> | ||
|
||
|
||
// MARK: - Id | ||
|
||
static let id = "CalendarPostCell" | ||
|
||
|
||
// MARK: - Views | ||
|
||
private lazy var headerView = makeMemoriesCalendarPostHeaderView() | ||
private lazy var postImageView = makeMemoriesCalendarPostImageView() | ||
private lazy var collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) | ||
|
||
|
||
// MARK: - Properties | ||
|
||
private lazy var datasource = prepareContentDatasource() | ||
|
||
|
||
// MARK: - LifeCycles | ||
|
||
override func prepareForReuse() { | ||
super.prepareForReuse() | ||
headerView.prepareForReuse() | ||
postImageView.prepareForReuse() | ||
} | ||
|
||
|
||
// MARK: - Helpers | ||
|
||
override func bind(reactor: MemoriesCalendarPostCellReactor) { | ||
super.bind(reactor: reactor) | ||
bindInput(reactor: reactor) | ||
bindOutput(reactor: reactor) | ||
} | ||
|
||
private func bindInput(reactor: MemoriesCalendarPostCellReactor) { | ||
Observable.just(()) | ||
.map { Reactor.Action.viewDidLoad } | ||
.bind(to: reactor.action) | ||
.disposed(by: disposeBag) | ||
|
||
headerView.rx.didTapProfileImageButton | ||
.throttle(RxInterval._300milliseconds, scheduler: RxScheduler.main) | ||
.map { Reactor.Action.didTapProfileImageButton } | ||
.bind(to: reactor.action) | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
private func bindOutput(reactor: MemoriesCalendarPostCellReactor) { | ||
let dailyPost = reactor.state.map { $0.dailyPost } | ||
.asDriver(onErrorDriveWith: .empty()) | ||
|
||
dailyPost | ||
.distinctUntilChanged() | ||
.compactMap { $0.missionContent } | ||
.drive(with: self, onNext: { $0.postImageView.setMissionText(text: $1) }) | ||
.disposed(by: disposeBag) | ||
|
||
dailyPost | ||
.distinctUntilChanged() | ||
.drive(with: self, onNext: { $0.postImageView.setPostImage(imageUrl: $1.postImageUrl) }) | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.map { $0.memberName } | ||
.distinctUntilChanged() | ||
.bind(with: self) { $0.headerView.setMemberName(text: $1) } | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.map { $0.profileImageUrl } | ||
.distinctUntilChanged() | ||
.compactMap { $0 } | ||
.bind(with: self) { $0.headerView.setProfileImage(imageUrl: $1) } | ||
.disposed(by: disposeBag) | ||
|
||
reactor.state.compactMap { $0.contentDatasource } | ||
.bind(to: collectionView.rx.items(dataSource: datasource)) | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
override func setupUI() { | ||
super.setupUI() | ||
|
||
contentView.addSubviews(headerView, postImageView, collectionView) | ||
} | ||
|
||
override func setupAutoLayout() { | ||
super.setupAutoLayout() | ||
|
||
headerView.snp.makeConstraints { | ||
$0.top.equalTo(self.snp.top).offset(8) | ||
$0.horizontalEdges.equalToSuperview().inset(16) | ||
$0.height.equalTo(34) | ||
} | ||
|
||
collectionView.snp.makeConstraints { | ||
$0.height.equalTo(41) | ||
$0.bottom.equalTo(postImageView.snp.bottom).offset(-20) | ||
$0.horizontalEdges.equalToSuperview() | ||
} | ||
|
||
postImageView.snp.makeConstraints { | ||
$0.horizontalEdges.equalToSuperview() | ||
$0.height.equalTo(postImageView.snp.width) | ||
$0.horizontalEdges.equalToSuperview().inset(1) | ||
$0.top.equalTo(headerView.snp.bottom).offset(8) | ||
} | ||
} | ||
|
||
override func setupAttributes() { | ||
super.setupAttributes() | ||
|
||
collectionView.do { | ||
$0.backgroundColor = .clear | ||
$0.isScrollEnabled = false | ||
$0.showsVerticalScrollIndicator = false | ||
$0.showsHorizontalScrollIndicator = false | ||
$0.collectionViewLayout = UICollectionViewFlowLayout() | ||
$0.register(DisplayEditCollectionViewCell.self, forCellWithReuseIdentifier: DisplayEditCollectionViewCell.id) | ||
$0.delegate = self | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
extension MemoriesCalendarPostCell { | ||
|
||
private func prepareContentDatasource() -> RxDataSource { | ||
return RxDataSource { datasources, collectionView, indexPath, sectionItem in | ||
switch sectionItem { | ||
case let .fetchDisplayItem(reactor): | ||
guard let cell = collectionView.dequeueReusableCell( | ||
withReuseIdentifier: DisplayEditCollectionViewCell.id, | ||
for: indexPath | ||
) as? DisplayEditCollectionViewCell else { | ||
return UICollectionViewCell() | ||
} | ||
cell.reactor = reactor | ||
return cell | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPostCell { | ||
|
||
func makeMemoriesCalendarPostHeaderView() -> MemoriesCalendarPostHeaderView { | ||
return MemoriesCalendarPostHeaderView(reactor: MemoriesCalendarPostHeaderReactor()) | ||
} | ||
|
||
func makeMemoriesCalendarPostImageView() -> MemoriesCalendarPostImageView { | ||
return MemoriesCalendarPostImageView(reactor: MemoriesCalendarPostImageReactor()) | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPostCell: UICollectionViewDelegateFlowLayout { | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
return CGSize(width: 28, height: 41) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { | ||
return 2 | ||
} | ||
|
||
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { | ||
guard let count = reactor?.currentState.dailyPost.postContent?.count else { | ||
return .zero | ||
} | ||
|
||
let totalCellWidth = 28 * count | ||
let totalSpacingWidth = 2 * (count - 1) | ||
|
||
let leftInset = (collectionView.frame.width - CGFloat(totalCellWidth + totalSpacingWidth)) / 2 | ||
let rightInset = leftInset | ||
|
||
return UIEdgeInsets(top: 0, left: leftInset, bottom: 0, right: rightInset) | ||
} | ||
|
||
} |
125 changes: 125 additions & 0 deletions
125
14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPageTitleView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// | ||
// MemoriesCalendarPageHeaderView.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/16/24. | ||
// | ||
|
||
import Core | ||
import DesignSystem | ||
import UIKit | ||
|
||
import SnapKit | ||
import Then | ||
|
||
final public class MemoriesCalendarPageTitleView: BaseView<MemoriesCalendarTitleViewReactor> { | ||
|
||
// MARK: - Views | ||
|
||
private let labelStack: UIStackView = UIStackView() | ||
private let titleLabel: BBLabel = BBLabel(.head2Bold, textAlignment: .center, textColor: .gray200) | ||
private let memoryCountLabel: BBLabel = BBLabel(.body1Regular, textColor: .gray200) | ||
private let tipButton: UIButton = UIButton(type: .system) | ||
|
||
private let toolTipView: BBToolTipView = BBToolTipView() | ||
|
||
// MARK: - Properties | ||
|
||
private let tipImage: UIImage = DesignSystemAsset.infoCircleFill.image.withRenderingMode(.alwaysTemplate) | ||
|
||
|
||
// MARK: - Helpers | ||
|
||
public override func bind(reactor: Reactor) { | ||
super.bind(reactor: reactor) | ||
|
||
bindInput(reactor: reactor) | ||
bindOutput(reactor: reactor) | ||
} | ||
|
||
private func bindInput(reactor: Reactor) { | ||
tipButton.rx.tap | ||
.throttle(RxInterval._300milliseconds, scheduler: RxScheduler.main) | ||
.map { Reactor.Action.didTapTipButton } | ||
.bind(to: reactor.action) | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
private func bindOutput(reactor: Reactor) { | ||
reactor.pulse(\.$hiddenTooltipView) | ||
.bind(with: self) { | ||
$1 ? $0.toolTipView.hidePopover() | ||
: $0.toolTipView.showPopover() | ||
} | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
|
||
public override func setupUI() { | ||
super.setupUI() | ||
|
||
self.addSubviews(labelStack, memoryCountLabel, toolTipView) | ||
labelStack.addArrangedSubviews(titleLabel, tipButton) | ||
} | ||
|
||
public override func setupAutoLayout() { | ||
super.setupAutoLayout() | ||
|
||
labelStack.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(0) | ||
$0.leading.equalToSuperview().offset(0) | ||
} | ||
|
||
memoryCountLabel.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(0) | ||
$0.trailing.equalToSuperview().offset(0) | ||
} | ||
|
||
tipButton.snp.makeConstraints { | ||
$0.size.equalTo(20) | ||
} | ||
|
||
toolTipView.snp.makeConstraints { | ||
$0.top.equalTo(tipButton.snp.bottom).offset(4) | ||
$0.leading.equalToSuperview().offset(57.5) | ||
} | ||
} | ||
|
||
public override func setupAttributes() { | ||
super.setupAttributes() | ||
|
||
self.clipsToBounds = false | ||
|
||
tipButton.do { | ||
$0.setImage(tipImage, for: .normal) | ||
$0.tintColor = .gray300 | ||
} | ||
|
||
labelStack.do { | ||
$0.axis = .horizontal | ||
$0.spacing = 10 | ||
$0.alignment = .fill | ||
$0.distribution = .fill | ||
} | ||
|
||
toolTipView.hidePopover() | ||
toolTipView.toolTipType = .monthlyCalendar | ||
// toolTipView.anchorPoint = CGPoint(x: 0.3, y: 0) | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
public extension MemoriesCalendarPageTitleView { | ||
|
||
func setTitle(_ title: String) { | ||
self.titleLabel.text = title | ||
} | ||
|
||
func setMemoryCount(_ count: Int) { | ||
self.memoryCountLabel.text = "\(count)개의 추억" | ||
} | ||
|
||
} |
131 changes: 131 additions & 0 deletions
131
14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPostHeaderView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// | ||
// MemoriesCalendarPostHeaderView.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/17/24. | ||
// | ||
|
||
import Core | ||
import UIKit | ||
|
||
import Then | ||
import SnapKit | ||
import Kingfisher | ||
|
||
final class MemoriesCalendarPostHeaderView: BaseView<MemoriesCalendarPostHeaderReactor> { | ||
|
||
// MARK: - Views | ||
|
||
private let profileStack: UIStackView = UIStackView() | ||
private let profileBackgroundView: UIView = UIView() | ||
private let profileImageButton: UIButton = UIButton(type: .custom) | ||
private let firstNameLetter: BBLabel = BBLabel(.caption, textColor: .bibbiWhite) | ||
private let memberNameLabel: BBLabel = BBLabel(.caption, textColor: .gray200) | ||
|
||
// MARK: - Properteis | ||
|
||
weak var delegate: (any MemoriesCalendarPostHeaderDelegate)? | ||
|
||
|
||
// MARK: - Helpers | ||
|
||
public override func bind(reactor: Reactor) { | ||
super.bind(reactor: reactor) | ||
} | ||
|
||
public override func setupUI() { | ||
super.setupUI() | ||
|
||
addSubview(profileStack) | ||
profileBackgroundView.addSubviews(firstNameLetter, profileImageButton) | ||
profileStack.addArrangedSubviews(profileBackgroundView, memberNameLabel) | ||
} | ||
|
||
public override func setupAutoLayout() { | ||
super.setupAutoLayout() | ||
|
||
profileStack.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
} | ||
|
||
profileBackgroundView.snp.makeConstraints { | ||
$0.size.equalTo(34) | ||
} | ||
|
||
profileImageButton.snp.makeConstraints { | ||
$0.size.equalTo(34) | ||
} | ||
|
||
firstNameLetter.snp.makeConstraints { | ||
$0.center.equalToSuperview() | ||
} | ||
} | ||
|
||
public override func setupAttributes() { | ||
super.setupAttributes() | ||
|
||
profileStack.do { | ||
$0.spacing = 12 | ||
$0.axis = .horizontal | ||
} | ||
|
||
profileBackgroundView.do { | ||
$0.layer.masksToBounds = true | ||
$0.layer.cornerRadius = 34 / 2 | ||
$0.backgroundColor = UIColor.gray800 | ||
$0.isUserInteractionEnabled = true | ||
} | ||
|
||
profileImageButton.do { | ||
$0.contentMode = .scaleAspectFill | ||
$0.layer.masksToBounds = true | ||
$0.layer.cornerRadius = 34 / 2 | ||
$0.adjustsImageWhenHighlighted = false | ||
$0.addTarget(self, action: #selector(didTapProfileImageButton(_:event:)), for: .touchUpInside) | ||
} | ||
|
||
memberNameLabel.do { | ||
$0.text = "알 수 없음" | ||
} | ||
|
||
firstNameLetter.do { | ||
$0.text = "알" | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
extension MemoriesCalendarPostHeaderView { | ||
|
||
@objc func didTapProfileImageButton(_ button: UIButton, event: UIControl.Event) { | ||
delegate?.didTapProfileImageButton?(button, event: event) | ||
} | ||
|
||
} | ||
|
||
extension MemoriesCalendarPostHeaderView { | ||
|
||
func prepareForReuse() { | ||
profileImageButton.setImage(nil, for: .normal) | ||
firstNameLetter.text = "알" | ||
memberNameLabel.text = "알 수 없음" | ||
} | ||
|
||
func setMemberName(text: String?) { | ||
memberNameLabel.text = text | ||
firstNameLetter.text = text?[0] | ||
} | ||
|
||
func setProfileImage(imageUrl url: URL) { | ||
KingfisherManager.shared.retrieveImage(with: url) { result in | ||
if case let .success(imageResult) = result { | ||
self.profileImageButton.setBackgroundImage(imageResult.image, for: .normal) // extension으로 빼기 | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
79 changes: 79 additions & 0 deletions
79
14th-team5-iOS/App/Sources/Presentation/Calendar/View/MemoriesCalendarPostImageView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// MemoriesCalendarPostImageView.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/17/24. | ||
// | ||
|
||
import Core | ||
import UIKit | ||
|
||
import Then | ||
import SnapKit | ||
|
||
final class MemoriesCalendarPostImageView: BaseView<MemoriesCalendarPostImageReactor> { | ||
|
||
// MARK: - Views | ||
|
||
private let imageView: UIImageView = UIImageView() | ||
private let missionText: MissionTextView = MissionTextView() | ||
|
||
// MARK: - Helpers | ||
|
||
public override func setupUI() { | ||
super.setupUI() | ||
|
||
addSubviews(imageView, missionText) | ||
} | ||
|
||
public override func setupAutoLayout() { | ||
super.setupAutoLayout() | ||
|
||
imageView.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
} | ||
|
||
missionText.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(16) | ||
$0.horizontalEdges.equalToSuperview().inset(32) | ||
$0.height.equalTo(41) | ||
} | ||
} | ||
|
||
public override func setupAttributes() { | ||
super.setupAttributes() | ||
|
||
imageView.do { | ||
$0.clipsToBounds = true | ||
$0.backgroundColor = UIColor.gray100 | ||
$0.contentMode = .scaleAspectFill | ||
$0.layer.cornerRadius = 48 | ||
} | ||
|
||
missionText.do { | ||
$0.isHidden = true | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - Extensions | ||
|
||
extension MemoriesCalendarPostImageView { | ||
|
||
func prepareForReuse() { | ||
imageView.image = nil | ||
missionText.setHidden(hidden: true) | ||
} | ||
|
||
func setPostImage(imageUrl url: String) { | ||
imageView.kf.setImage(with: URL(string: url)!) | ||
} | ||
|
||
func setMissionText(text: String?) { | ||
missionText.setHidden(hidden: false) | ||
missionText.setMissionText(text: text) | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...m5-iOS/App/Sources/Presentation/Calendar/ViewController/BannerHostingViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// BannerViewController.swift | ||
// App | ||
// | ||
// Created by 김건우 on 10/16/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import Then | ||
|
||
final class BannerHostingViewController: UIHostingController<BannerView> { | ||
|
||
private let _viewModel: BannerViewModel | ||
|
||
init(reactor: MemoriesCalendarPageReactor?) { | ||
self._viewModel = BannerViewModel(reactor: reactor, state: .init()) | ||
super.init(rootView: BannerView(viewModel: _viewModel)) | ||
|
||
self.view.backgroundColor = UIColor.clear | ||
} | ||
|
||
@MainActor @preconcurrency required dynamic init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
var viewModel: BannerViewModel { | ||
get { _viewModel } | ||
set { } | ||
} | ||
|
||
func updateState(_ state: BannerViewModel.State) { | ||
viewModel.updateState(state: state) | ||
} | ||
|
||
} |
Oops, something went wrong.