-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] #516 - Create writePostView and photo import function
- writePostView in Community tab - photo import (5 limit) - view custom in progress
- Loading branch information
1 parent
e572b1a
commit 83fdfb9
Showing
7 changed files
with
177 additions
and
3 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
38 changes: 38 additions & 0 deletions
38
HappyAnding/HappyAnding/Assets.xcassets/Colors/CharcoalGray.colorset/Contents.json
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,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0x40", | ||
"green" : "0x40", | ||
"red" : "0x40" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0x40", | ||
"green" : "0x40", | ||
"red" : "0x40" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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
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
56 changes: 56 additions & 0 deletions
56
HappyAnding/HappyAnding/Views/CommunityViews/PhotoPicker.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,56 @@ | ||
// | ||
// PhotoPicker.swift | ||
// HappyAnding | ||
// | ||
// Created by HanGyeongjun on 3/30/24. | ||
// | ||
|
||
import SwiftUI | ||
import PhotosUI | ||
|
||
struct PhotoPicker: UIViewControllerRepresentable { | ||
@Binding var selectedImages: [UIImage] | ||
@Environment(\.presentationMode) var presentationMode | ||
|
||
func makeUIViewController(context: Context) -> PHPickerViewController { | ||
var config = PHPickerConfiguration(photoLibrary: .shared()) | ||
config.selectionLimit = 5 | ||
config.filter = .images | ||
let picker = PHPickerViewController(configuration: config) | ||
picker.delegate = context.coordinator | ||
return picker | ||
} | ||
|
||
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {} | ||
|
||
func makeCoordinator() -> Coordinator { | ||
Coordinator(self) | ||
} | ||
|
||
class Coordinator: NSObject, PHPickerViewControllerDelegate { | ||
var parent: PhotoPicker | ||
|
||
init(_ parent: PhotoPicker) { | ||
self.parent = parent | ||
} | ||
|
||
//이미지 배열 생성. 최대 5개, 앞쪽에 추가 | ||
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { | ||
picker.dismiss(animated: true) | ||
|
||
for result in results.reversed() { | ||
guard result.itemProvider.canLoadObject(ofClass: UIImage.self) else { continue } | ||
result.itemProvider.loadObject(ofClass: UIImage.self) { (image, error) in | ||
DispatchQueue.main.async { | ||
if let image = image as? UIImage { | ||
self.parent.selectedImages.insert(image, at: 0) | ||
if self.parent.selectedImages.count > 5 { | ||
self.parent.selectedImages.removeLast() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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