-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add BanchanListViewModel, UICollectionViewDiffableDataSource
섹션별로 업데이트를 하기위해 UICollectionViewDiffableDataSource를 도입하였습니다. 이에 따른 NSDiffableDataSourceSnapshot을 적용해 주었고 가독성을 높이기 위해 typealias를 통하여 재정의 해주었습니다. DataSource에 정보를 주기 위한 BanchanListViewModel을 정의해주었습니다. issue: #13
- Loading branch information
Showing
12 changed files
with
183 additions
and
25 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
Binary file added
BIN
+39.3 KB
...codeproj/project.xcworkspace/xcuserdata/jibook.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
...eDish/SideDish.xcodeproj/xcuserdata/jibook.xcuserdatad/xcschemes/xcschememanagement.plist
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>SideDish.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
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
26 changes: 26 additions & 0 deletions
26
iOS/SideDish/SideDish/Presentaion/BanchanList/View/BanchanCollectionView.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,26 @@ | ||
// | ||
// BanchanCollectionView.swift | ||
// SideDish | ||
// | ||
// Created by 지북 on 2021/04/21. | ||
// | ||
|
||
import UIKit | ||
|
||
class BanchanCollectionView: UICollectionView { | ||
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { | ||
super.init(frame: frame, collectionViewLayout: layout) | ||
configure() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
configure() | ||
} | ||
|
||
private func configure() { | ||
self.register(BanchanCustomCell.nib, forCellWithReuseIdentifier: BanchanCustomCell.identifer) | ||
self.register(BanchanCustomCellHeader.nib, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: BanchanCustomCellHeader.identifier) | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
31 changes: 31 additions & 0 deletions
31
iOS/SideDish/SideDish/Presentaion/BanchanList/ViewModel/BanchanListViewModel.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,31 @@ | ||
// | ||
// BanchanListViewModel.swift | ||
// SideDish | ||
// | ||
// Created by 지북 on 2021/04/20. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
class BanchanListViewModel { | ||
enum Section: String, CaseIterable { | ||
case soup = "정성이 담긴 뜨끈뜨끈 국물요리" | ||
case side = "식탁을 풍성하게 하는 정갈한 밑반찬" | ||
case main = "모두가 좋아하는 든든한 메인요리" | ||
} | ||
|
||
var menu: Dictionary<Section, [Banchan]> | ||
|
||
init() { | ||
self.menu = [:] | ||
} | ||
|
||
func sectionCount() -> Int { | ||
return Section.allCases.count | ||
} | ||
|
||
func getBanchans(section: Section) -> [Banchan]? { | ||
return menu[section] | ||
} | ||
} |