Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions ReadLog/ReadLog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
E622526B2AFB7AE600D33EC3 /* omyu pretty.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E622526A2AFB7AE600D33EC3 /* omyu pretty.ttf */; };
E622526E2AFB7CB300D33EC3 /* Color+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E622526D2AFB7CB300D33EC3 /* Color+Extension.swift */; };
E62252702AFB7E7000D33EC3 /* TextStyle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E622526F2AFB7E7000D33EC3 /* TextStyle+Extension.swift */; };
E6B184D12B142C6600776177 /* BookShelfView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6B184D02B142C6600776177 /* BookShelfView.swift */; };
E6B184D32B142FD400776177 /* BookShelfCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6B184D22B142FD400776177 /* BookShelfCell.swift */; };
E6C73D5B2B02F82E00A3C9C9 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6C73D5A2B02F82E00A3C9C9 /* UINavigationController+Extension.swift */; };
E6E4BF532B01B70300FEEE10 /* AddNoteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6E4BF522B01B70300FEEE10 /* AddNoteView.swift */; };
E6E4BF562B01BF4000FEEE10 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6E4BF552B01BF4000FEEE10 /* Header.swift */; };
Expand Down Expand Up @@ -64,6 +66,8 @@
E622526C2AFB7B0400D33EC3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
E622526D2AFB7CB300D33EC3 /* Color+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Extension.swift"; sourceTree = "<group>"; };
E622526F2AFB7E7000D33EC3 /* TextStyle+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TextStyle+Extension.swift"; sourceTree = "<group>"; };
E6B184D02B142C6600776177 /* BookShelfView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookShelfView.swift; sourceTree = "<group>"; };
E6B184D22B142FD400776177 /* BookShelfCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookShelfCell.swift; sourceTree = "<group>"; };
E6C73D5A2B02F82E00A3C9C9 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = "<group>"; };
E6E4BF522B01B70300FEEE10 /* AddNoteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNoteView.swift; sourceTree = "<group>"; };
E6E4BF552B01BF4000FEEE10 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -147,6 +151,15 @@
path = Fonts;
sourceTree = "<group>";
};
E6B184CF2B142C5C00776177 /* BookShelf */ = {
isa = PBXGroup;
children = (
E6B184D02B142C6600776177 /* BookShelfView.swift */,
E6B184D22B142FD400776177 /* BookShelfCell.swift */,
);
path = BookShelf;
sourceTree = "<group>";
};
E6E4BF542B01BD9B00FEEE10 /* AddNote */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -209,8 +222,8 @@
E6E68EE82AF1DDF400172557 /* Presenter */ = {
isa = PBXGroup;
children = (
E6B184CF2B142C5C00776177 /* BookShelf */,
E6F5AD282B134BEC00A605D4 /* URLImage */,
E6035B882B0CF07F00C34007 /* BookShelf */,
E6035B852B0CEF4200C34007 /* ReadingBook */,
9DC96E9D2B0C57B500034878 /* BookDetail */,
E618517D2B0B9CFC0067811C /* BookInfo */,
Expand Down Expand Up @@ -386,6 +399,7 @@
E60DDA9F2B0AF95500F25BB2 /* BookProfileContainer.swift in Sources */,
E6F5AD1E2B0FCAFC00A605D4 /* ISBNScannerView.swift in Sources */,
E60DDA992B0A8D1400F25BB2 /* BookSearchView.swift in Sources */,
E6B184D12B142C6600776177 /* BookShelfView.swift in Sources */,
E60DDA9B2B0A8F2400F25BB2 /* SearchBar.swift in Sources */,
E6E4BF5B2B01CE1100FEEE10 /* NoteLabel.swift in Sources */,
E6E4BF592B01C88500FEEE10 /* Note.swift in Sources */,
Expand All @@ -396,6 +410,7 @@
9DA3579C2B009AD1004EC3C1 /* viewBookMemo.swift in Sources */,
DB633C1B2B02FC8F004CEC27 /* Model.xcdatamodeld in Sources */,
DB18172D2B062ED600A55F80 /* Persistence.swift in Sources */,
E6B184D32B142FD400776177 /* BookShelfCell.swift in Sources */,
E6F5AD2A2B134C0200A605D4 /* URLImage.swift in Sources */,
E6F5AD252B112AEE00A605D4 /* BookInfoData_Temporal.swift in Sources */,
E61851832B0B9EA80067811C /* APIKEY.swift in Sources */,
Expand Down Expand Up @@ -548,11 +563,13 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ReadLog/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "책의 내용을 스캔하기 위해서 카메라 사용 허용이 필요합니다.";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -584,11 +601,13 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ReadLog/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "책의 내용을 스캔하기 위해서 카메라 사용 허용이 필요합니다.";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
1 change: 1 addition & 0 deletions ReadLog/ReadLog/Presenter/AddNote/AddNoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct AddNoteView: View {
}
.padding(.horizontal, 32)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.toolbar(.hidden)
.fullScreenCover(isPresented: $showScannerSheet, content: {
scannerView
Expand Down
81 changes: 81 additions & 0 deletions ReadLog/ReadLog/Presenter/BookShelf/BookShelfCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// BookShelfCell.swift
// ReadLog
//
// Created by sanghyo on 11/27/23.
//

import SwiftUI

struct BookShelfCell: View {
var renderedBook: [BookExample?]

var body: some View {
VStack(spacing: 5) {
bookRow(renderedBook).padding(.horizontal, 20)
horizontalLine
}
.listRowSeparator(.hidden)
.listRowBackground(Color.backgroundColor)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(.bottom, 5)
}
}

private extension BookShelfCell {
@ViewBuilder
func bookRow(_ bookList: [BookExample?]) -> some View {
HStack(alignment: .center) {
bookCell(bookList[0])
Spacer()
bookCell(bookList[1])
Spacer()
bookCell(bookList[2])
}
}

@ViewBuilder
func bookCell(_ book: BookExample?) -> some View {
if let book = book {
Image(book.imageName)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 80)
.shadow(radius: 4, y: 4)
.onTapGesture {
// move to detail page
}
} else {
Spacer()
.frame(width: 80)
}
}

var horizontalLine: some View {
Rectangle()
.foregroundStyle(Color.white)
.frame(height: 6)
.shadow(radius: 4, y: 4)
}

}

struct BookExample: Identifiable {
let id: Int
let imageName: String

static var mock: [BookExample?] {
return [
BookExample(id: 0, imageName: "bookExample"),
BookExample(id: 1, imageName: "bookExample"),
BookExample(id: 3, imageName: "bookExample"),
BookExample(id: 4, imageName: "bookExample"),
nil,

]
}
}

#Preview {
BookShelfCell(renderedBook: BookExample.mock)
}
53 changes: 51 additions & 2 deletions ReadLog/ReadLog/Presenter/BookShelf/BookShelfView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,63 @@
// BookShelfView.swift
// ReadLog
//
// Created by sanghyo on 11/21/23.
// Created by sanghyo on 11/27/23.
//

import SwiftUI

struct BookShelfView: View {
private var bookList: [BookExample] = BookExample.mock.compactMap { $0 }
private let bookCountInRow: Int = 3
private var interpolatedBookList: [BookExample?] {
get {
interpolateBookList(bookList)
}
}

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
NavigationStack {
ZStack {
Color.backgroundColor
.ignoresSafeArea()
VStack(spacing: 40) {
header
List {
ForEach(0..<interpolatedBookList.count/bookCountInRow, id: \.self) {idx in
BookShelfCell(renderedBook: dataForRow(idx: idx))
}
}
.listStyle(.plain)
}
}
}

.toolbar(.hidden)
}
}

private extension BookShelfView {

var header: some View {
HStack {
Spacer()
Text("읽은 책 목록")
.display(Color.black)
Spacer()
}
.tint(.black)
.padding(EdgeInsets(top: 16, leading: 0, bottom: 8, trailing: 0))
}

func interpolateBookList(_ bookList: [BookExample]) -> [BookExample?] {
let bookCount = bookList.count
let addBookCount = (bookCountInRow - bookCount % bookCountInRow) % bookCountInRow
let nilArray: [BookExample?] = Array<BookExample?>(repeating: nil, count: addBookCount)
return bookList + nilArray
}

func dataForRow(idx: Int) -> [BookExample?] {
Array(interpolatedBookList[idx*bookCountInRow..<idx*bookCountInRow+3])
}
}

Expand Down