mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 13:13:33 +01:00
cleanup
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - NetworkImageView
|
||||
|
||||
struct NetworkImageView: View {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
init(url: URL?) {
|
||||
|
||||
self.imageDownloader = .init(url: url)
|
||||
}
|
||||
|
||||
|
||||
// MARK: View
|
||||
|
||||
var body: some View {
|
||||
|
||||
if let image = self.imageDownloader.image {
|
||||
|
||||
return AnyView(
|
||||
Image(uiImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
return AnyView(
|
||||
Circle()
|
||||
.colorMultiply(Color(UIColor.placeholderText))
|
||||
.onAppear {
|
||||
|
||||
self.imageDownloader.fetchImage()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@ObservedObject
|
||||
private var imageDownloader: ImageDownloader
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
//
|
||||
// Demo
|
||||
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
// MARK: - UIImage
|
||||
|
||||
extension UIImage {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
convenience init(
|
||||
color: UIColor,
|
||||
size: CGSize = CGSize(width: 1, height: 1),
|
||||
cornerRadius: CGFloat = 0
|
||||
) {
|
||||
let rect = CGRect(origin: .zero, size: size)
|
||||
let scale = UIScreen.main.scale
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, scale)
|
||||
defer {
|
||||
UIGraphicsEndImageContext()
|
||||
}
|
||||
let context = UIGraphicsGetCurrentContext()!
|
||||
|
||||
if cornerRadius > 0 {
|
||||
UIBezierPath(
|
||||
roundedRect: rect,
|
||||
cornerRadius: cornerRadius
|
||||
)
|
||||
.addClip()
|
||||
}
|
||||
color.setFill()
|
||||
context.fill(rect)
|
||||
|
||||
self.init(
|
||||
cgImage: UIGraphicsGetImageFromCurrentImageContext()!.cgImage!,
|
||||
scale: scale,
|
||||
orientation: .up
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user