Skip to content

Commit 4b9cc9a

Browse files
committed
feat: 사용자의 앨범 불러오기 (#27)
1 parent 7a06e63 commit 4b9cc9a

File tree

7 files changed

+192
-3
lines changed

7 files changed

+192
-3
lines changed

iOS/issue-tracker.xcodeproj/project.pbxproj

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
10D55EDF2670D46E007587C4 /* AdditionalTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 10D55EDD2670D46E007587C4 /* AdditionalTableViewCell.xib */; };
2424
10D55EE12670D512007587C4 /* AdditionalTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D55EE02670D512007587C4 /* AdditionalTableViewDataSource.swift */; };
2525
10D55EE32670D717007587C4 /* AdditionalTableDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D55EE22670D717007587C4 /* AdditionalTableDelegate.swift */; };
26+
10ED3B802671C21600FCBF2E /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10ED3B7F2671C21600FCBF2E /* PhotoViewController.swift */; };
27+
10ED3B842671C31500FCBF2E /* PhotoDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10ED3B832671C31500FCBF2E /* PhotoDataSource.swift */; };
28+
10ED3B862671C34200FCBF2E /* PhotoManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10ED3B852671C34200FCBF2E /* PhotoManager.swift */; };
29+
10ED3B8C2671C41B00FCBF2E /* PhotoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10ED3B8B2671C41B00FCBF2E /* PhotoCell.swift */; };
2630
BCCEBE1E1668EC814AFFBE24 /* Pods_issue_tracker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 906455FA7C42AB9BB530CE77 /* Pods_issue_tracker.framework */; };
2731
/* End PBXBuildFile section */
2832

@@ -46,6 +50,10 @@
4650
10D55EDD2670D46E007587C4 /* AdditionalTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdditionalTableViewCell.xib; sourceTree = "<group>"; };
4751
10D55EE02670D512007587C4 /* AdditionalTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalTableViewDataSource.swift; sourceTree = "<group>"; };
4852
10D55EE22670D717007587C4 /* AdditionalTableDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalTableDelegate.swift; sourceTree = "<group>"; };
53+
10ED3B7F2671C21600FCBF2E /* PhotoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
54+
10ED3B832671C31500FCBF2E /* PhotoDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoDataSource.swift; sourceTree = "<group>"; };
55+
10ED3B852671C34200FCBF2E /* PhotoManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoManager.swift; sourceTree = "<group>"; };
56+
10ED3B8B2671C41B00FCBF2E /* PhotoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoCell.swift; sourceTree = "<group>"; };
4957
26D189FC7EF28507BC1CCEF4 /* Pods-issue-tracker.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-issue-tracker.debug.xcconfig"; path = "Target Support Files/Pods-issue-tracker/Pods-issue-tracker.debug.xcconfig"; sourceTree = "<group>"; };
5058
3CB31D25B54D61EBD8942312 /* Pods-issue-tracker.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-issue-tracker.release.xcconfig"; path = "Target Support Files/Pods-issue-tracker/Pods-issue-tracker.release.xcconfig"; sourceTree = "<group>"; };
5159
906455FA7C42AB9BB530CE77 /* Pods_issue_tracker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_issue_tracker.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -120,8 +128,10 @@
120128
10CE4DA2266EFB5700FBD593 /* Assets.xcassets */,
121129
10CE4DA4266EFB5700FBD593 /* LaunchScreen.storyboard */,
122130
10CE4DA7266EFB5700FBD593 /* Info.plist */,
123-
10D4258026709CB000AE119C /* IssueList */,
124131
10BCA8A3266F38D700DBBA61 /* Login */,
132+
10ED3B7E2671C1F600FCBF2E /* Photo */,
133+
10ED3B7D2671AFA000FCBF2E /* NewIssue */,
134+
10D4258026709CB000AE119C /* IssueList */,
125135
);
126136
path = "issue-tracker";
127137
sourceTree = "<group>";
@@ -130,7 +140,6 @@
130140
isa = PBXGroup;
131141
children = (
132142
10D4258126709CC200AE119C /* IssueListViewController.swift */,
133-
10BDE6B42670C324007B38AF /* IssueEditViewController.swift */,
134143
1085274B2670C149006121B8 /* View */,
135144
10D55EE02670D512007587C4 /* AdditionalTableViewDataSource.swift */,
136145
10D55EE22670D717007587C4 /* AdditionalTableDelegate.swift */,
@@ -146,6 +155,25 @@
146155
path = Extension;
147156
sourceTree = "<group>";
148157
};
158+
10ED3B7D2671AFA000FCBF2E /* NewIssue */ = {
159+
isa = PBXGroup;
160+
children = (
161+
10BDE6B42670C324007B38AF /* IssueEditViewController.swift */,
162+
);
163+
path = NewIssue;
164+
sourceTree = "<group>";
165+
};
166+
10ED3B7E2671C1F600FCBF2E /* Photo */ = {
167+
isa = PBXGroup;
168+
children = (
169+
10ED3B7F2671C21600FCBF2E /* PhotoViewController.swift */,
170+
10ED3B832671C31500FCBF2E /* PhotoDataSource.swift */,
171+
10ED3B852671C34200FCBF2E /* PhotoManager.swift */,
172+
10ED3B8B2671C41B00FCBF2E /* PhotoCell.swift */,
173+
);
174+
path = Photo;
175+
sourceTree = "<group>";
176+
};
149177
7322197006E01F85C16AF0AA /* Pods */ = {
150178
isa = PBXGroup;
151179
children = (
@@ -280,10 +308,14 @@
280308
buildActionMask = 2147483647;
281309
files = (
282310
10BCA8A5266F38E800DBBA61 /* LoginViewController.swift in Sources */,
311+
10ED3B842671C31500FCBF2E /* PhotoDataSource.swift in Sources */,
283312
10D55EE12670D512007587C4 /* AdditionalTableViewDataSource.swift in Sources */,
313+
10ED3B862671C34200FCBF2E /* PhotoManager.swift in Sources */,
314+
10ED3B8C2671C41B00FCBF2E /* PhotoCell.swift in Sources */,
284315
10CE4D9E266EFB5700FBD593 /* ViewController.swift in Sources */,
285316
10D4258226709CC200AE119C /* IssueListViewController.swift in Sources */,
286317
10BDE6B92670C62A007B38AF /* IdentityProtocol.swift in Sources */,
318+
10ED3B802671C21600FCBF2E /* PhotoViewController.swift in Sources */,
287319
10CE4D9A266EFB5700FBD593 /* AppDelegate.swift in Sources */,
288320
10CE4D9C266EFB5700FBD593 /* SceneDelegate.swift in Sources */,
289321
10D55EE32670D717007587C4 /* AdditionalTableDelegate.swift in Sources */,

iOS/issue-tracker/Base.lproj/Main.storyboard

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
66
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
77
<capability name="System colors in document resources" minToolsVersion="11.0"/>
8+
<capability name="collection view cell content view" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
910
</dependencies>
1011
<customFonts key="customFonts">
@@ -194,6 +195,66 @@
194195
</objects>
195196
<point key="canvasLocation" x="1900.0000000000002" y="130.58035714285714"/>
196197
</scene>
198+
<!--Photo View Controller-->
199+
<scene sceneID="Qhn-EN-AA6">
200+
<objects>
201+
<viewController storyboardIdentifier="PhotoViewController" id="3i5-Tr-59N" customClass="PhotoViewController" customModule="issue_tracker" customModuleProvider="target" sceneMemberID="viewController">
202+
<view key="view" contentMode="scaleToFill" id="0uT-yf-zTm">
203+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
204+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
205+
<subviews>
206+
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="jN3-VD-35R">
207+
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
208+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
209+
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="OHb-jT-NpV">
210+
<size key="itemSize" width="128" height="128"/>
211+
<size key="headerReferenceSize" width="0.0" height="0.0"/>
212+
<size key="footerReferenceSize" width="0.0" height="0.0"/>
213+
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
214+
</collectionViewFlowLayout>
215+
<cells>
216+
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="PhotoCell" id="MVx-rW-jh6" customClass="PhotoCell" customModule="issue_tracker" customModuleProvider="target">
217+
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
218+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
219+
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="CGq-6B-cGF">
220+
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
221+
<autoresizingMask key="autoresizingMask"/>
222+
<subviews>
223+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Lyh-m7-fez">
224+
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
225+
</imageView>
226+
</subviews>
227+
<constraints>
228+
<constraint firstAttribute="trailing" secondItem="Lyh-m7-fez" secondAttribute="trailing" id="Js3-GB-4Ze"/>
229+
<constraint firstAttribute="bottom" secondItem="Lyh-m7-fez" secondAttribute="bottom" id="bhZ-a7-DYP"/>
230+
<constraint firstItem="Lyh-m7-fez" firstAttribute="top" secondItem="CGq-6B-cGF" secondAttribute="top" id="g0M-kj-wFK"/>
231+
<constraint firstItem="Lyh-m7-fez" firstAttribute="leading" secondItem="CGq-6B-cGF" secondAttribute="leading" id="rFc-8Q-OTB"/>
232+
</constraints>
233+
</collectionViewCellContentView>
234+
<connections>
235+
<outlet property="photo" destination="Lyh-m7-fez" id="3dg-Me-A3I"/>
236+
</connections>
237+
</collectionViewCell>
238+
</cells>
239+
</collectionView>
240+
</subviews>
241+
<viewLayoutGuide key="safeArea" id="Ncf-vT-f03"/>
242+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
243+
<constraints>
244+
<constraint firstItem="jN3-VD-35R" firstAttribute="leading" secondItem="Ncf-vT-f03" secondAttribute="leading" id="8Oo-Wj-q91"/>
245+
<constraint firstItem="Ncf-vT-f03" firstAttribute="trailing" secondItem="jN3-VD-35R" secondAttribute="trailing" id="HAH-bg-FYy"/>
246+
<constraint firstItem="Ncf-vT-f03" firstAttribute="bottom" secondItem="jN3-VD-35R" secondAttribute="bottom" id="k0r-7B-UU9"/>
247+
<constraint firstItem="jN3-VD-35R" firstAttribute="top" secondItem="Ncf-vT-f03" secondAttribute="top" id="xHd-rb-LO0"/>
248+
</constraints>
249+
</view>
250+
<connections>
251+
<outlet property="album" destination="jN3-VD-35R" id="nM8-Rh-O8y"/>
252+
</connections>
253+
</viewController>
254+
<placeholder placeholderIdentifier="IBFirstResponder" id="G5K-mW-iKV" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
255+
</objects>
256+
<point key="canvasLocation" x="2746" y="131"/>
257+
</scene>
197258
</scenes>
198259
<resources>
199260
<systemColor name="labelColor">

iOS/issue-tracker/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>NSPhotoLibraryUsageDescription</key>
6+
<string>Can I use your photo album?</string>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>$(DEVELOPMENT_LANGUAGE)</string>
79
<key>CFBundleExecutable</key>

iOS/issue-tracker/IssueList/IssueEditViewController.swift renamed to iOS/issue-tracker/NewIssue/IssueEditViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class IssueEditViewController: UIViewController {
2727
}
2828

2929
private func registerNib(){
30-
additionalInfoTable.register(UINib(nibName: AdditionalTableViewCell.nibName, bundle: nil),
30+
additionalInfoTable.register(UINib(nibName: AdditionalTableViewCell.nibName, bundle: Bundle.main),
3131
forCellReuseIdentifier: AdditionalTableViewCell.reuseIdentifier)
3232

3333
}
@@ -39,7 +39,10 @@ class IssueEditViewController: UIViewController {
3939

4040
@objc
4141
func insertPhoto(){
42+
let photoSelectViewController = PhotoViewController
43+
.instantiate(name: "Main", bundle: Bundle.main)
4244

45+
self.present(photoSelectViewController, animated: true)
4346
}
4447
}
4548
extension IssueEditViewController: UITextViewDelegate {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// PhotoCell.swift
3+
// issue-tracker
4+
//
5+
// Created by 박혜원 on 2021/06/10.
6+
//
7+
8+
import UIKit
9+
10+
class PhotoCell: UICollectionViewCell, ReuseIdentity {
11+
12+
@IBOutlet weak var photo: UIImageView!
13+
14+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// PhotoDataSource.swift
3+
// issue-tracker
4+
//
5+
// Created by 박혜원 on 2021/06/10.
6+
//
7+
8+
import UIKit
9+
import Photos
10+
11+
class PhotoDataSource: NSObject, UICollectionViewDataSource {
12+
13+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
14+
return PhotoManager.shared.allPhotos.count
15+
}
16+
17+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
18+
19+
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PhotoCell.reuseIdentifier,
20+
for: indexPath) as? PhotoCell
21+
else {
22+
return UICollectionViewCell()
23+
}
24+
25+
let asset: PHAsset = PhotoManager.shared.allPhotos.object(at: indexPath.item)
26+
let imageManager = PHCachingImageManager()
27+
imageManager.requestImage(for: asset,
28+
targetSize: CGSize(width: 128, height: 128),
29+
contentMode: .aspectFill,
30+
options: nil,
31+
resultHandler: { image, _ in
32+
cell.photo.image = image
33+
})
34+
return cell
35+
}
36+
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// PhotoManager.swift
3+
// issue-tracker
4+
//
5+
// Created by 박혜원 on 2021/06/10.
6+
//
7+
8+
import Foundation
9+
import Photos
10+
11+
class PhotoManager {
12+
13+
var allPhotos: PHFetchResult<PHAsset>
14+
static var shared = PhotoManager()
15+
16+
private init(){
17+
allPhotos = PHFetchResult<PHAsset>()
18+
}
19+
20+
func requestPhotos() {
21+
PHPhotoLibrary.requestAuthorization { (status) in
22+
switch status {
23+
case .authorized:
24+
self.allPhotos = PHAsset.fetchAssets(with: nil)
25+
default:
26+
break
27+
}
28+
}
29+
}
30+
31+
func authorization() {
32+
let status = PHPhotoLibrary.authorizationStatus()
33+
switch status {
34+
case .authorized:
35+
self.allPhotos = PHAsset.fetchAssets(with: nil)
36+
default:
37+
break
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)