-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
์ฌ๋ฌ๊ฐ์ง ์ถ๊ฐ ๋ฐ ๊ฐ์ ๐
- Loading branch information
Showing
49 changed files
with
1,421 additions
and
433 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ImageSaver.swift | ||
// Core | ||
// | ||
// Created by Young Bin on 2023/09/10. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Photos | ||
|
||
public class ImageSaver: NSObject { | ||
private var completion: ((Error?) -> Void)? | ||
|
||
public func save(_ image: UIImage, completion: @escaping (Error?) -> Void) { | ||
UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveError), nil) | ||
self.completion = completion | ||
} | ||
|
||
@objc private func saveError( | ||
_ image: UIImage, | ||
didFinishSavingWithError error: Error?, | ||
contextInfo: UnsafeRawPointer | ||
) { | ||
DispatchQueue.main.async { | ||
if let error { | ||
self.completion?(error) | ||
} else { | ||
self.completion?(nil) | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// ReverseMask.swift | ||
// Core | ||
// | ||
// Created by Young Bin on 2023/09/10. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public extension View { | ||
@inlinable func reverseMask<Mask: View>( | ||
alignment: Alignment = .center, | ||
@ViewBuilder _ mask: () -> Mask | ||
) -> some View { | ||
self.mask( | ||
ZStack(alignment: .center) { | ||
Rectangle() | ||
|
||
mask() | ||
.blendMode(.destinationOut) | ||
} | ||
.compositingGroup() | ||
) | ||
} | ||
} |
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,88 @@ | ||
// | ||
// ScreenShooter.swift | ||
// Core | ||
// | ||
// Created by Young Bin on 2023/09/12. | ||
// Copyright ยฉ 2023 team.humanwave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct Screenshotter<Content: View>: UIViewControllerRepresentable { | ||
@Binding var isTakingScreenshot: Bool | ||
var onScreenshotTaken: (UIImage?) -> Void | ||
let content: () -> Content | ||
|
||
public init( | ||
isTakingScreenshot: Binding<Bool>, | ||
@ViewBuilder content: @escaping () -> Content, | ||
onScreenshotTaken: @escaping (UIImage?) -> Void | ||
) { | ||
self._isTakingScreenshot = isTakingScreenshot | ||
self.content = content | ||
self.onScreenshotTaken = onScreenshotTaken | ||
} | ||
|
||
public func makeUIViewController(context: Context) -> UIViewController { | ||
let viewController = UIViewController() | ||
let hostingController = UIHostingController(rootView: content()) | ||
|
||
viewController.addChild(hostingController) | ||
viewController.view.addSubview(hostingController.view) | ||
hostingController.view.frame = viewController.view.bounds | ||
hostingController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
|
||
context.coordinator.hostingController = hostingController // coordinator์ hostingController๋ฅผ ์ ์ฅํฉ๋๋ค. | ||
return viewController | ||
} | ||
|
||
public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { | ||
context.coordinator.hostingController?.rootView = content() // rootView๋ฅผ ์ ๋ฐ์ดํธ ํฉ๋๋ค. | ||
|
||
if isTakingScreenshot { | ||
DispatchQueue.main.async { | ||
let screenshot = self.takeScreenshot(of: uiViewController.view) | ||
self.onScreenshotTaken(screenshot) | ||
self.isTakingScreenshot = false | ||
} | ||
} | ||
} | ||
|
||
public func makeCoordinator() -> Coordinator { | ||
return Coordinator() | ||
} | ||
|
||
public class Coordinator { | ||
var hostingController: UIHostingController<Content>? | ||
} | ||
|
||
func takeScreenshot(of view: UIView) -> UIImage? { | ||
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0) | ||
defer { UIGraphicsEndImageContext() } | ||
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true) | ||
let snapshotImage = UIGraphicsGetImageFromCurrentImageContext() | ||
return snapshotImage | ||
} | ||
} | ||
|
||
// ์์ง ์ธ ๋ฐ๋ ์์ | ||
public extension View { | ||
func capture() -> UIImage? { | ||
let targetSize = UIScreen.main.bounds.size | ||
return capture(targetSize: targetSize) | ||
} | ||
|
||
func capture(targetSize: CGSize) -> UIImage? { | ||
let controller = UIHostingController(rootView: self) | ||
let view = controller.view | ||
|
||
view?.bounds = CGRect(origin: .zero, size: targetSize) | ||
view?.backgroundColor = .clear | ||
view?.layoutIfNeeded() // Force layout | ||
|
||
let renderer = UIGraphicsImageRenderer(size: targetSize) | ||
return renderer.image { _ in | ||
view?.drawHierarchy(in: controller.view.bounds, afterScreenUpdates: true) | ||
} | ||
} | ||
} |
68 changes: 0 additions & 68 deletions
68
Projects/Core/Sources/Utility/UI/WebView/WebViewWarmUper.swift
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Projects/DSKit/Resources/Image.xcassets/mypage_empty.imageset/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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "mypage_empty.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+2.52 KB
Projects/DSKit/Resources/Image.xcassets/mypage_empty.imageset/mypage_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.97 KB
Projects/DSKit/Resources/Image.xcassets/mypage_empty.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.41 KB
Projects/DSKit/Resources/Image.xcassets/mypage_empty.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.