Skip to content

Commit f42da57

Browse files
Merge pull request #339 from BCSDLab/fix/postlostitem
refactor: 분실물 작성 화면 UI 개선
2 parents 251611d + 6d2b7bd commit f42da57

23 files changed

Lines changed: 579 additions & 246 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ extension UIApplication {
4343
height = statusBarManager?.statusBarFrame.height ?? 0
4444
return height
4545
}
46+
47+
static func bottomSafeAreaHeight() -> CGFloat {
48+
let height: CGFloat
49+
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
50+
height = windowScene?.windows.first?.safeAreaInsets.bottom ?? 0
51+
return height
52+
}
4653
}

Koin/Core/Extensions/UIViewController+Navigate.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@ extension UIViewController {
1313
loginViewController.title = "로그인"
1414
navigationController?.pushViewController(loginViewController, animated: true)
1515
}
16+
17+
func replaceTopViewController(_ viewController: UIViewController, animated: Bool) {
18+
if var viewControllers = navigationController?.viewControllers {
19+
let _ = viewControllers.removeLast()
20+
viewControllers.append(viewController)
21+
navigationController?.setViewControllers(viewControllers, animated: animated)
22+
}
23+
}
1624
}

Koin/Data/Repository/DefaultNoticeListRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class DefaultNoticeListRepository: NoticeListRepository {
2828
service.deleteLostItem(id: id)
2929
}
3030

31-
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse> {
31+
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse> {
3232
service.postLostItem(request: request)
3333
}
3434

Koin/Data/Service/NoticeListService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protocol NoticeListService {
2121
func downloadNoticeAttachment(downloadUrl: String, fileName: String) -> AnyPublisher<URL?, ErrorResponse>
2222
func manageRecentSearchedWord(name: String, date: Date, actionType: Int)
2323
func fetchRecentSearchedWord() -> [RecentSearchedWordInfo]
24-
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse>
24+
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse>
2525
func fetchLostItemList(requestModel: FetchNoticeArticlesRequest) -> AnyPublisher<NoticeListDto, Error>
2626
func fetchLostItem(id: Int, retry: Bool) -> AnyPublisher<LostArticleDetailDto, ErrorResponse>
2727
func deleteLostItem(id: Int) -> AnyPublisher<Void, ErrorResponse>
@@ -67,9 +67,9 @@ final class DefaultNoticeService: NoticeListService {
6767
.eraseToAnyPublisher()
6868
}
6969

70-
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse> {
70+
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse> {
7171
return networkService.requestWithResponse(api: NoticeListAPI.postLostItem(request))
72-
.catch { [weak self] error -> AnyPublisher<LostArticleDetailDto, ErrorResponse> in
72+
.catch { [weak self] error -> AnyPublisher<LostItemDataDto, ErrorResponse> in
7373
guard let self = self else { return Fail(error: error).eraseToAnyPublisher() }
7474
if error.code == "401" {
7575
return self.networkService.refreshToken()

Koin/Domain/Model/LostItem/LostItemListData.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ struct LostItemListData {
1919
var isReported: Bool
2020
var isFound: Bool
2121
}
22+
23+
extension LostItemListData {
24+
25+
init(from data: LostItemData) {
26+
self.id = data.id
27+
self.type = data.type
28+
self.category = data.category
29+
self.foundPlace = data.foundPlace
30+
self.foundDate = data.foundDate
31+
self.content = data.content
32+
self.author = data.author
33+
self.registeredAt = data.registeredAt
34+
self.isReported = false
35+
self.isFound = data.isFound
36+
}
37+
}

Koin/Domain/Repository/NoticeListRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protocol NoticeListRepository {
2121
func downloadNoticeAttachment(downloadUrl: String, fileName: String) -> AnyPublisher<URL?, ErrorResponse>
2222
func manageRecentSearchedWord(name: String, date: Date, actionType: Int)
2323
func fetchRecentSearchedWord() -> [RecentSearchedWordInfo]
24-
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse>
24+
func postLostItem(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse>
2525
func fetchLostItem(id: Int) -> AnyPublisher<LostArticleDetailDto, ErrorResponse>
2626
func deleteLostItem(id: Int) -> AnyPublisher<Void, ErrorResponse>
2727
func reportLostItemArticle(id: Int, request: ReportLostItemRequest) -> AnyPublisher<Void, ErrorResponse>

Koin/Domain/UseCase/NoticeList/PostLostItemUseCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Combine
99

1010
protocol PostLostItemUseCase {
11-
func execute(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse>
11+
func execute(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse>
1212
}
1313

1414
final class DefaultPostLostItemUseCase: PostLostItemUseCase {
@@ -19,7 +19,7 @@ final class DefaultPostLostItemUseCase: PostLostItemUseCase {
1919
self.noticeListRepository = noticeListRepository
2020
}
2121

22-
func execute(request: [PostLostItemRequest]) -> AnyPublisher<LostArticleDetailDto, ErrorResponse> {
22+
func execute(request: [PostLostItemRequest]) -> AnyPublisher<LostItemDataDto, ErrorResponse> {
2323
noticeListRepository.postLostItem(request: request)
2424
}
2525
}

Koin/Presentation/LostItem/EditLostItem/SubViews/EditLostItemImagesView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ final class EditLostItemImagesView: UIView {
3939
layout.scrollDirection = .horizontal
4040
let collectionView = LostItemImageCollectionView(frame: .zero, collectionViewLayout: layout)
4141
collectionView.backgroundColor = UIColor.appColor(.neutral100)
42+
collectionView.layer.cornerRadius = 8
4243
return collectionView
4344
}()
4445
private let addPictureButton = UIButton().then {
@@ -78,7 +79,7 @@ final class EditLostItemImagesView: UIView {
7879
self?.pictureCountLabel.text = "\(urls.count)/10"
7980
}.store(in: &subscriptions)
8081

81-
imageUploadCollectionView.shouldDismissDropDownPublisher.sink { [weak self] in
82+
imageUploadCollectionView.shouldDismissDropDownKeyBoardPublisher.sink { [weak self] in
8283
self?.dismissDropDownPublisher.send()
8384
self?.endEditing(true)
8485
}.store(in: &subscriptions)

Koin/Presentation/LostItem/LostItemData/Subviews/LostItemDataContentView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ final class LostItemDataContentView: UIView {
7777
required init?(coder: NSCoder) {
7878
fatalError("init(coder:) has not been implemented")
7979
}
80-
81-
80+
8281
func configure(images: [Image], content: String?, isCouncil: Bool) {
8382
imageCollectionView.configure(images: images)
8483
imageCollectionView.isHidden = images.isEmpty

Koin/Presentation/LostItem/LostItemList/LostItemListViewController.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,40 @@ extension LostItemListViewController {
182182

183183
private func presentPostTypeModal() {
184184
let onFoundButtonTapped = { [weak self] in
185-
self?.dismissView()
185+
guard let self else { return }
186+
dismissView()
186187
let viewController = PostLostItemViewController(viewModel: PostLostItemViewModel(type: .found))
187-
self?.navigationController?.pushViewController(viewController, animated: true)
188+
viewController.delegate = self
189+
navigationController?.pushViewController(viewController, animated: true)
188190
}
189191
let onLostButtonTapped = { [weak self] in
190-
self?.dismissView()
192+
guard let self else { return }
193+
dismissView()
191194
let viewController = PostLostItemViewController(viewModel: PostLostItemViewModel(type: .lost))
192-
self?.navigationController?.pushViewController(viewController, animated: true)
195+
viewController.delegate = self
196+
navigationController?.pushViewController(viewController, animated: true)
193197
}
194198
let postOptionViewController = LostItemPostOptionController(
195199
onFoundButtonTapped: onFoundButtonTapped,
196200
onLostButtonTapped: onLostButtonTapped
197201
)
198-
let bottomSheetViewController = BottomSheetViewController(contentViewController: postOptionViewController, defaultHeight: 225, cornerRadius: 32)
202+
let bottomSheetViewController = BottomSheetViewController(
203+
contentViewController: postOptionViewController,
204+
defaultHeight: 191 + UIApplication.bottomSafeAreaHeight(),
205+
cornerRadius: 32
206+
)
199207
bottomSheetViewController.modalTransitionStyle = .crossDissolve
200208
navigationController?.present(bottomSheetViewController, animated: true)
201209
}
202210
}
203211

212+
extension LostItemListViewController: PostLostItemViewControllerDelegate {
213+
214+
func appendData(_ newData: LostItemData) {
215+
lostItemListTableView.appendAtFirst(LostItemListData(from: newData))
216+
}
217+
}
218+
204219
extension LostItemListViewController: LostItemDataViewControllerDelegate {
205220

206221
func updateState(foundDataId id: Int) {
@@ -239,7 +254,10 @@ extension LostItemListViewController {
239254
self?.inputSubject.send(.updateFilter(filter: filter))
240255
}
241256
)
242-
let bottomSheetViewController = BottomSheetViewController(contentViewController: filterViewController, defaultHeight: UIApplication.hasHomeButton() ? 661 - 35 : 661, cornerRadius: 32)
257+
let bottomSheetViewController = BottomSheetViewController(
258+
contentViewController: filterViewController,
259+
defaultHeight: 627 + UIApplication.bottomSafeAreaHeight(),
260+
cornerRadius: 32)
243261
bottomSheetViewController.modalTransitionStyle = .crossDissolve
244262
navigationController?.present(bottomSheetViewController, animated: true)
245263
}

0 commit comments

Comments
 (0)