Skip to content

Commit 1678d8f

Browse files
committed
fix conflict
1 parent adeec19 commit 1678d8f

File tree

9 files changed

+189
-412
lines changed

9 files changed

+189
-412
lines changed

iOSDesignPatternSamples.xcodeproj/project.pbxproj

+133-177
Large diffs are not rendered by default.

iOSDesignPatternSamples/Resources/Base.lproj/Main.storyboard

+12-12
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
</subviews>
4343
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
4444
<constraints>
45-
<constraint firstItem="pvz-qk-lgd" firstAttribute="trailing" secondItem="hXN-GY-eDF" secondAttribute="trailing" id="3cd-vM-eQa"/>
46-
<constraint firstItem="hXN-GY-eDF" firstAttribute="leading" secondItem="pvz-qk-lgd" secondAttribute="leading" id="64o-gN-lPo"/>
47-
<constraint firstItem="pvz-qk-lgd" firstAttribute="bottom" secondItem="hXN-GY-eDF" secondAttribute="bottom" id="8wA-YL-go0"/>
48-
<constraint firstItem="hXN-GY-eDF" firstAttribute="top" secondItem="pvz-qk-lgd" secondAttribute="top" id="Obu-xQ-QgL"/>
45+
<constraint firstItem="pPO-zw-ZSW" firstAttribute="trailing" secondItem="hXN-GY-eDF" secondAttribute="trailing" id="3cd-vM-eQa"/>
46+
<constraint firstItem="hXN-GY-eDF" firstAttribute="leading" secondItem="pPO-zw-ZSW" secondAttribute="leading" id="64o-gN-lPo"/>
47+
<constraint firstItem="pPO-zw-ZSW" firstAttribute="bottom" secondItem="hXN-GY-eDF" secondAttribute="bottom" id="8wA-YL-go0"/>
48+
<constraint firstItem="hXN-GY-eDF" firstAttribute="top" secondItem="pPO-zw-ZSW" secondAttribute="top" id="Obu-xQ-QgL"/>
4949
</constraints>
50-
<viewLayoutGuide key="safeArea" id="pvz-qk-lgd"/>
50+
<viewLayoutGuide key="safeArea" id="pPO-zw-ZSW"/>
5151
</view>
5252
<navigationItem key="navigationItem" id="cVF-Oh-r4H"/>
5353
<connections>
@@ -118,15 +118,15 @@
118118
</subviews>
119119
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
120120
<constraints>
121-
<constraint firstItem="ZKg-MR-Ccd" firstAttribute="top" secondItem="OBv-xB-n9y" secondAttribute="top" id="0HA-zC-ahq"/>
122-
<constraint firstItem="OBv-xB-n9y" firstAttribute="bottom" secondItem="7NS-lN-HF0" secondAttribute="bottom" id="5jV-Up-2nz"/>
123-
<constraint firstItem="OBv-xB-n9y" firstAttribute="trailing" secondItem="ZKg-MR-Ccd" secondAttribute="trailing" id="6dG-KY-xf8"/>
124-
<constraint firstItem="7NS-lN-HF0" firstAttribute="leading" secondItem="OBv-xB-n9y" secondAttribute="leading" id="XN4-ka-rwu"/>
121+
<constraint firstItem="ZKg-MR-Ccd" firstAttribute="top" secondItem="nRh-Zl-98i" secondAttribute="top" id="0HA-zC-ahq"/>
122+
<constraint firstItem="nRh-Zl-98i" firstAttribute="bottom" secondItem="7NS-lN-HF0" secondAttribute="bottom" id="5jV-Up-2nz"/>
123+
<constraint firstItem="nRh-Zl-98i" firstAttribute="trailing" secondItem="ZKg-MR-Ccd" secondAttribute="trailing" id="6dG-KY-xf8"/>
124+
<constraint firstItem="7NS-lN-HF0" firstAttribute="leading" secondItem="nRh-Zl-98i" secondAttribute="leading" id="XN4-ka-rwu"/>
125125
<constraint firstItem="7NS-lN-HF0" firstAttribute="top" secondItem="ZKg-MR-Ccd" secondAttribute="bottom" id="ixB-sU-4S2"/>
126-
<constraint firstItem="OBv-xB-n9y" firstAttribute="trailing" secondItem="7NS-lN-HF0" secondAttribute="trailing" id="mYh-fj-l3a"/>
127-
<constraint firstItem="ZKg-MR-Ccd" firstAttribute="leading" secondItem="OBv-xB-n9y" secondAttribute="leading" id="nbZ-e7-ZtR"/>
126+
<constraint firstItem="nRh-Zl-98i" firstAttribute="trailing" secondItem="7NS-lN-HF0" secondAttribute="trailing" id="mYh-fj-l3a"/>
127+
<constraint firstItem="ZKg-MR-Ccd" firstAttribute="leading" secondItem="nRh-Zl-98i" secondAttribute="leading" id="nbZ-e7-ZtR"/>
128128
</constraints>
129-
<viewLayoutGuide key="safeArea" id="OBv-xB-n9y"/>
129+
<viewLayoutGuide key="safeArea" id="nRh-Zl-98i"/>
130130
</view>
131131
<navigationItem key="navigationItem" id="qil-DS-Lhy"/>
132132
<connections>

iOSDesignPatternSamples/Sources/UI/Favorite/FavoriteViewController.swift

+5-10
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,23 @@ protocol FavoriteView: class {
1616

1717
final class FavoriteViewController: UIViewController, FavoriteView {
1818
@IBOutlet weak var tableView: UITableView!
19-
19+
2020
private(set) lazy var presenter: FavoritePresenter = FavoriteViewPresenter(view: self)
2121
private lazy var dataSource: FavoriteViewDataSource = .init(presenter: self.presenter)
22-
22+
2323
override func viewDidLoad() {
2424
super.viewDidLoad()
2525

2626
title = "On Memory Favorite"
27-
27+
2828
dataSource.configure(with: tableView)
2929
}
30-
31-
<<<<<<< HEAD
30+
3231
func showRepository(with repository: Repository) {
3332
let vc = RepositoryViewController(repository: repository, favoritePresenter: presenter)
34-
=======
35-
private func showRepository(with repository: Repository) {
36-
let vc = RepositoryViewController(repository: repository, favoriteModel: favoriteModel)
37-
>>>>>>> mvc
3833
navigationController?.pushViewController(vc, animated: true)
3934
}
40-
35+
4136
func reloadData() {
4237
tableView?.reloadData()
4338
}

iOSDesignPatternSamples/Sources/UI/Repository/RepositoryViewController.swift

+5-13
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,27 @@ final class RepositoryViewController: SFSafariViewController, RepositoryView {
2222
action: #selector(RepositoryViewController.favoriteButtonTap(_:)))
2323
}()
2424
private let presenter: RepositoryPresenter
25-
26-
<<<<<<< HEAD
25+
2726
init(repository: Repository,
2827
favoritePresenter: FavoritePresenter,
2928
entersReaderIfAvailable: Bool = true) {
3029
self.presenter = RepositoryViewPresenter(repository: repository,
3130
favoritePresenter: favoritePresenter)
32-
super.init(url: repository.url, entersReaderIfAvailable: entersReaderIfAvailable)
33-
=======
34-
init(repository: Repository, favoriteModel: FavoriteModel) {
35-
self.repository = repository
36-
self.favoriteModel = favoriteModel
37-
3831
super.init(url: repository.url, configuration: .init())
39-
>>>>>>> mvc
4032
hidesBottomBarWhenPushed = true
4133
self.presenter.view = self
4234
}
43-
35+
4436
override func viewDidLoad() {
4537
super.viewDidLoad()
46-
38+
4739
navigationItem.rightBarButtonItem = favoriteButtonItem
4840
}
49-
41+
5042
@objc private func favoriteButtonTap(_ sender: UIBarButtonItem) {
5143
presenter.favoriteButtonTap()
5244
}
53-
45+
5446
func updateFavoriteButtonTitle(_ title: String) {
5547
favoriteButtonItem.title = title
5648
}

iOSDesignPatternSamples/Sources/UI/Repository/RepositoryViewPresenter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import GithubKit
1111

1212
protocol RepositoryPresenter: class {
1313
init(repository: Repository, favoritePresenter: FavoritePresenter)
14-
weak var view: RepositoryView? { get set }
14+
var view: RepositoryView? { get set }
1515
var favoriteButtonTitle: String { get }
1616
func favoriteButtonTap()
1717
}

iOSDesignPatternSamples/Sources/UI/Search/SearchViewController.swift

+15-108
Original file line numberDiff line numberDiff line change
@@ -28,72 +28,11 @@ final class SearchViewController: UIViewController, SearchView {
2828
searchBar.delegate = self
2929
return searchBar
3030
}()
31-
32-
<<<<<<< HEAD
31+
3332
fileprivate let loadingView = LoadingView.makeFromNib()
34-
33+
3534
var favoritePresenter: FavoritePresenter?
36-
=======
37-
private var query: String = "" {
38-
didSet {
39-
if query != oldValue {
40-
users.removeAll()
41-
pageInfo = nil
42-
totalCount = 0
43-
}
44-
task?.cancel()
45-
task = nil
46-
fetchUsers()
47-
}
48-
}
49-
private var task: URLSessionTask? = nil
50-
private var pageInfo: PageInfo? = nil
51-
private var totalCount: Int = 0 {
52-
didSet {
53-
totalCountLabel.text = "\(users.count) / \(totalCount)"
54-
}
55-
}
56-
private var users: [User] = [] {
57-
didSet {
58-
totalCountLabel.text = "\(users.count) / \(totalCount)"
59-
tableView.reloadData()
60-
}
61-
}
62-
private let debounce: (_ action: @escaping () -> ()) -> () = {
63-
var lastFireTime: DispatchTime = .now()
64-
let delay: DispatchTimeInterval = .milliseconds(500)
65-
return { [delay] action in
66-
let deadline: DispatchTime = .now() + delay
67-
lastFireTime = .now()
68-
DispatchQueue.global().asyncAfter(deadline: deadline) { [delay] in
69-
let now: DispatchTime = .now()
70-
let when: DispatchTime = lastFireTime + delay
71-
if now < when { return }
72-
lastFireTime = .now()
73-
DispatchQueue.main.async {
74-
action()
75-
}
76-
}
77-
}
78-
}()
79-
private var isFetchingUsers = false {
80-
didSet {
81-
tableView.reloadData()
82-
}
83-
}
84-
private var pool = Notice.ObserverPool()
85-
86-
private let loadingView = LoadingView.makeFromNib()
87-
88-
private var isReachedBottom: Bool = false {
89-
didSet {
90-
if isReachedBottom && isReachedBottom != oldValue {
91-
fetchUsers()
92-
}
93-
}
94-
}
95-
>>>>>>> mvc
96-
35+
9736
private lazy var presenter: SearchPresenter = SearchViewPresenter(view: self)
9837
private lazy var dataSource: SearchViewDataSource = .init(presenter: self.presenter)
9938

@@ -102,32 +41,27 @@ final class SearchViewController: UIViewController, SearchView {
10241

10342
navigationItem.titleView = searchBar
10443
searchBar.placeholder = "Input user name"
105-
44+
10645
dataSource.configure(with: tableView)
10746
}
108-
47+
10948
override func viewWillAppear(_ animated: Bool) {
11049
super.viewWillAppear(animated)
11150
presenter.viewWillAppear()
11251
}
113-
52+
11453
override func viewWillDisappear(_ animated: Bool) {
11554
super.viewWillDisappear(animated)
11655
if searchBar.isFirstResponder {
11756
searchBar.resignFirstResponder()
11857
}
119-
<<<<<<< HEAD
12058
presenter.viewWillDisappear()
121-
=======
122-
pool = Notice.ObserverPool()
123-
>>>>>>> mvc
12459
}
125-
60+
12661
func reloadData() {
12762
tableView.reloadData()
12863
}
129-
130-
<<<<<<< HEAD
64+
13165
func keyboardWillShow(with keyboardInfo: UIKeyboardInfo) {
13266
view.layoutIfNeeded()
13367
let extra = tabBarController?.tabBar.bounds.height ?? 0
@@ -137,29 +71,8 @@ final class SearchViewController: UIViewController, SearchView {
13771
options: keyboardInfo.animationCurve,
13872
animations: { self.view.layoutIfNeeded() },
13973
completion: nil)
140-
=======
141-
private func observeKeyboard() {
142-
NotificationCenter.default.nok.observe(name: .keyboardWillShow) { [weak self] in
143-
self?.view.layoutIfNeeded()
144-
let extra = self?.tabBarController?.tabBar.bounds.height ?? 0
145-
self?.tableViewBottomConstraint.constant = $0.frame.size.height - extra
146-
UIView.animate(withDuration: $0.animationDuration, delay: 0, options: $0.animationCurve, animations: {
147-
self?.view.layoutIfNeeded()
148-
}, completion: nil)
149-
}
150-
.invalidated(by: pool)
151-
152-
NotificationCenter.default.nok.observe(name: .keyboardWillHide) { [weak self] in
153-
self?.view.layoutIfNeeded()
154-
self?.tableViewBottomConstraint.constant = 0
155-
UIView.animate(withDuration: $0.animationDuration, delay: 0, options: $0.animationCurve, animations: {
156-
self?.view.layoutIfNeeded()
157-
}, completion: nil)
158-
}
159-
.invalidated(by: pool)
160-
>>>>>>> mvc
16174
}
162-
75+
16376
func keyboardWillHide(with keyboardInfo: UIKeyboardInfo) {
16477
view.layoutIfNeeded()
16578
tableViewBottomConstraint.constant = 0
@@ -169,23 +82,17 @@ final class SearchViewController: UIViewController, SearchView {
16982
animations: { self.view.layoutIfNeeded() },
17083
completion: nil)
17184
}
172-
173-
<<<<<<< HEAD
85+
17486
func showUserRepository(with user: User) {
17587
guard let presenter = favoritePresenter else { return }
17688
let vc = UserRepositoryViewController(user: user, favoritePresenter: presenter)
177-
=======
178-
private func showUserRepository(with user: User) {
179-
guard let favoriteModel = favoriteModel else { return }
180-
let vc = UserRepositoryViewController(user: user, favoriteModel: favoriteModel)
181-
>>>>>>> mvc
18289
navigationController?.pushViewController(vc, animated: true)
18390
}
184-
91+
18592
func updateTotalCountLabel(_ countText: String) {
18693
totalCountLabel.text = countText
18794
}
188-
95+
18996
func updateLoadingView(with view: UIView, isLoading: Bool) {
19097
loadingView.removeFromSuperview()
19198
loadingView.isLoading = isLoading
@@ -205,16 +112,16 @@ extension SearchViewController: UISearchBarDelegate {
205112
searchBar.resignFirstResponder()
206113
searchBar.showsCancelButton = false
207114
}
208-
115+
209116
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
210117
searchBar.resignFirstResponder()
211118
searchBar.showsCancelButton = false
212119
}
213-
120+
214121
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
215122
searchBar.showsCancelButton = true
216123
}
217-
124+
218125
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
219126
presenter.search(queryIfNeeded: searchText)
220127
}

iOSDesignPatternSamples/Sources/UI/Search/SearchViewPresenter.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ final class SearchViewPresenter: SearchPresenter {
8888
}
8989
}
9090
}
91-
private var pool = NoticeObserverPool()
91+
private var pool = Notice.ObserverPool()
9292

9393
var numberOfUsers: Int {
9494
return users.count
@@ -142,19 +142,19 @@ final class SearchViewPresenter: SearchPresenter {
142142
}
143143

144144
func viewWillAppear() {
145-
UIKeyboardWillShow.observe { [weak self] in
145+
NotificationCenter.default.nok.observe(name: .keyboardWillShow) { [weak self] in
146146
self?.view?.keyboardWillShow(with: $0)
147147
}
148-
.disposed(by: pool)
149-
150-
UIKeyboardWillHide.observe { [weak self] in
148+
.invalidated(by: pool)
149+
150+
NotificationCenter.default.nok.observe(name: .keyboardWillHide) { [weak self] in
151151
self?.view?.keyboardWillHide(with: $0)
152152
}
153-
.disposed(by: pool)
153+
.invalidated(by: pool)
154154
}
155155

156156
func viewWillDisappear() {
157-
pool = NoticeObserverPool()
157+
pool = Notice.ObserverPool()
158158
}
159159

160160
func showLoadingView(on view: UIView) {

0 commit comments

Comments
 (0)