Skip to content

Commit

Permalink
Merge pull request #100 from APP-iOS5th/Feature/LetterBoxDetailLetter…
Browse files Browse the repository at this point in the history
…View

Feature/letter box detail letter view
  • Loading branch information
uunwon authored Sep 3, 2024
2 parents 14beb2f + 27e003b commit 14f5abe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import SwiftUI

struct LetterBoxDetailLetterView: View {
@EnvironmentObject var viewModel: LetterViewModel
@EnvironmentObject var letterBoxDetailViewModel: LetterBoxDetailViewModel

@State private var showDetailLetter = false

var letterType: LetterType
Expand Down Expand Up @@ -59,6 +61,7 @@ struct LetterBoxDetailLetterView: View {
}
}
.onAppear {
letterBoxDetailViewModel.fetchLetterBoxDetailLetters(letterType: letterType)
viewModel.offset = 0
viewModel.showDeleteButton = false
}
Expand Down
1 change: 1 addition & 0 deletions Kabinett/Presentation/View/LetterBox/LetterBoxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct LetterBoxView: View {
}
}
}
.padding(.bottom, 65)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Kabinett/Presentation/View/LetterBox/LetterCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct LetterCell: View {

GeometryReader { geometry in
ZStack {
ForEach(0..<totalPageCount, id: \.self) { index in
ForEach(0..<max(totalPageCount, 1), id: \.self) { index in
if index == selectedIndex || index == selectedIndex + 1 {
createPageView(index: index, geometry: geometry)
.offset(x: CGFloat(index - selectedIndex) * 10, y: CGFloat(index - selectedIndex) * 10)
Expand Down Expand Up @@ -60,12 +60,13 @@ struct LetterCell: View {

@ViewBuilder
private func createPageView(index: Int, geometry: GeometryProxy) -> some View {
if index < letter.content.count {

if letter.content.isEmpty || index < letter.content.count {
ContentRectangleView(
stationeryImageUrlString: letter.stationeryImageUrlString,
fromUserName: letter.fromUserName,
toUserName: letter.toUserName,
letterContent: letter.content[index].isEmpty ? " " : letter.content[index],
letterContent: letter.content.isEmpty ? " " : letter.content[index].isEmpty ? " " : letter.content[index],
fontString: letter.fontString ?? "SFDisplay",
date: letter.date,
currentPageIndex: index,
Expand Down
1 change: 1 addition & 0 deletions Kabinett/Presentation/View/LetterBox/SearchBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct SearchBarView: View {
.tint(.black)
TextField("Search", text: $searchText)
.focused($textFieldFocused)
.textInputAutocapitalization(.never)
.onAppear {
textFieldFocused = isTextFieldFocused
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LetterBoxDetailViewModel: ObservableObject {
if findKeyword.isEmpty { return }

Task { @MainActor in
let result = await letterBoxUseCase.searchBy(findKeyword: findKeyword, letterType: letterType)
let result = await letterBoxUseCase.searchBy(findKeyword: findKeyword.lowercased(), letterType: letterType)
switch result {
case .success(let resultLettersOfSearchKeyword):
self.letterBoxDetailLetters = resultLettersOfSearchKeyword ?? []
Expand All @@ -45,6 +45,10 @@ class LetterBoxDetailViewModel: ObservableObject {
}

func fetchSearchByDate(letterType: LetterType, startDate: Date, endDate: Date) {
let calendar = Calendar.current
let startDate = calendar.startOfDay(for: startDate)
let endDate = calendar.date(byAdding: .day, value: 1, to: calendar.startOfDay(for: endDate)) ?? endDate

Task { @MainActor in
let result = await letterBoxUseCase.searchBy(letterType: letterType, startDate: startDate, endDate: endDate)
switch result {
Expand Down

0 comments on commit 14f5abe

Please sign in to comment.