-
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.
Merge pull request #6 from juandahurt/image
feat: add image view
- Loading branch information
Showing
6 changed files
with
62 additions
and
25 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
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,19 @@ | ||
// | ||
// ImageExample.swift | ||
// PuraceDemo | ||
// | ||
// Created by Juan Hurtado on 23/05/22. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import Purace | ||
|
||
struct ImageExample: View { | ||
var body: some View { | ||
Text("`PraceImageView(url: ...)`") | ||
PuraceImageView(url: URL(string: "https://www.biografiasyvidas.com/biografia/c/fotos/caldas_francisco_jose_2.jpg")) | ||
.frame(width: 150, height: 150) | ||
Spacer() | ||
} | ||
} |
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,34 @@ | ||
// | ||
// PuraceImageView.swift | ||
// | ||
// | ||
// Created by Juan Hurtado on 23/05/22. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import Kingfisher | ||
|
||
public struct PuraceImageView: View { | ||
let url: URL? | ||
|
||
public init(url: URL?) { | ||
self.url = url | ||
} | ||
|
||
public var body: some View { | ||
KFImage.url(url) | ||
.resizable() | ||
.fade(duration: 0.2) | ||
.placeholder { _ in | ||
GeometryReader { reader in | ||
ZStack { | ||
PuraceCircularLoaderView() | ||
.foregroundColor(PuraceStyle.Color.G3) | ||
.frame(width: reader.size.width * 0.1, height: reader.size.width * 0.1) | ||
.position(x: reader.size.width / 2, y: reader.size.height / 2) | ||
} | ||
} | ||
} | ||
} | ||
} |
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