mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-09-01 23:53:48 +00:00
Use Nuke where relevant
This commit is contained in:
parent
4be33b4f67
commit
e569bb1d74
11 changed files with 75 additions and 60 deletions
|
@ -18,6 +18,15 @@
|
||||||
"revision" : "32a99b537d1c6f3529a08257c28a5feb70c0c5af"
|
"revision" : "32a99b537d1c6f3529a08257c28a5feb70c0c5af"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "nuke",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/kean/Nuke",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "1e7395a8931ad19659fd1e10137a862b9c1e2a38",
|
||||||
|
"version" : "11.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swiftui-shimmer",
|
"identity" : "swiftui-shimmer",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|
|
@ -2,6 +2,9 @@ import SwiftUI
|
||||||
import Models
|
import Models
|
||||||
import DesignSystem
|
import DesignSystem
|
||||||
import Env
|
import Env
|
||||||
|
import Shimmer
|
||||||
|
import Nuke
|
||||||
|
import NukeUI
|
||||||
|
|
||||||
struct AccountDetailHeaderView: View {
|
struct AccountDetailHeaderView: View {
|
||||||
@EnvironmentObject private var theme: Theme
|
@EnvironmentObject private var theme: Theme
|
||||||
|
@ -29,20 +32,21 @@ struct AccountDetailHeaderView: View {
|
||||||
private var headerImageView: some View {
|
private var headerImageView: some View {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
ZStack(alignment: .bottomTrailing) {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
AsyncImage(
|
LazyImage(url: account.header) { state in
|
||||||
url: account.header,
|
if let image = state.image {
|
||||||
content: { image in
|
image
|
||||||
image.resizable()
|
.resizingMode(.aspectFill)
|
||||||
.aspectRatio(contentMode: .fill)
|
} else if state.isLoading {
|
||||||
|
Color.gray
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
.frame(width: proxy.frame(in: .local).width)
|
.shimmering()
|
||||||
.clipped()
|
} else {
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
Color.gray
|
Color.gray
|
||||||
.frame(height: bannerHeight)
|
.frame(height: bannerHeight)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
.frame(height: bannerHeight)
|
||||||
|
|
||||||
if relationship?.followedBy == true {
|
if relationship?.followedBy == true {
|
||||||
Text("Follows You")
|
Text("Follows You")
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
|
|
|
@ -16,14 +16,16 @@ let package = Package(
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(name: "Models", path: "../Models"),
|
.package(name: "Models", path: "../Models"),
|
||||||
.package(name: "Env", path: "../Env"),
|
.package(name: "Env", path: "../Env"),
|
||||||
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0")],
|
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0"),
|
||||||
|
.package(url: "https://github.com/kean/Nuke", from: "11.5.0")],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "DesignSystem",
|
name: "DesignSystem",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Models", package: "Models"),
|
.product(name: "Models", package: "Models"),
|
||||||
.product(name: "Env", package: "Env"),
|
.product(name: "Env", package: "Env"),
|
||||||
.product(name: "Shimmer", package: "SwiftUI-Shimmer")
|
.product(name: "Shimmer", package: "SwiftUI-Shimmer"),
|
||||||
|
.product(name: "NukeUI", package: "Nuke")
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Shimmer
|
import Shimmer
|
||||||
|
import NukeUI
|
||||||
|
import Nuke
|
||||||
|
|
||||||
public struct AvatarView: View {
|
public struct AvatarView: View {
|
||||||
public enum Size {
|
public enum Size {
|
||||||
|
@ -41,22 +43,20 @@ public struct AvatarView: View {
|
||||||
.fill(.gray)
|
.fill(.gray)
|
||||||
.frame(maxWidth: size.size.width, maxHeight: size.size.height)
|
.frame(maxWidth: size.size.width, maxHeight: size.size.height)
|
||||||
} else {
|
} else {
|
||||||
AsyncImage(url: url) { phase in
|
LazyImage(url: url) { state in
|
||||||
switch phase {
|
if let image = state.image {
|
||||||
case .empty:
|
image
|
||||||
|
.resizingMode(.aspectFit)
|
||||||
|
} else if state.isLoading {
|
||||||
placeholderView
|
placeholderView
|
||||||
.shimmering()
|
.shimmering()
|
||||||
case let .success(image):
|
} else {
|
||||||
image.resizable()
|
|
||||||
.aspectRatio(contentMode: .fit)
|
|
||||||
.cornerRadius(size.cornerRadius)
|
|
||||||
.frame(maxWidth: size.size.width, maxHeight: size.size.height)
|
|
||||||
case .failure:
|
|
||||||
placeholderView
|
|
||||||
@unknown default:
|
|
||||||
placeholderView
|
placeholderView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.processors([ImageProcessors.Resize(size: size.size),
|
||||||
|
ImageProcessors.RoundedCorners(radius: size.cornerRadius)])
|
||||||
|
.frame(width: size.size.width, height: size.size.height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ let package = Package(
|
||||||
.package(name: "Models", path: "../Models"),
|
.package(name: "Models", path: "../Models"),
|
||||||
.package(name: "Env", path: "../Env"),
|
.package(name: "Env", path: "../Env"),
|
||||||
.package(name: "Status", path: "../Status"),
|
.package(name: "Status", path: "../Status"),
|
||||||
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0")
|
.package(name: "DesignSystem", path: "../DesignSystem"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
@ -30,7 +30,7 @@ let package = Package(
|
||||||
.product(name: "Models", package: "Models"),
|
.product(name: "Models", package: "Models"),
|
||||||
.product(name: "Env", package: "Env"),
|
.product(name: "Env", package: "Env"),
|
||||||
.product(name: "Status", package: "Status"),
|
.product(name: "Status", package: "Status"),
|
||||||
.product(name: "Shimmer", package: "SwiftUI-Shimmer")
|
.product(name: "DesignSystem", package: "DesignSystem")
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Nuke
|
||||||
|
import NukeUI
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension Account {
|
extension Account {
|
||||||
public var displayNameWithEmojis: some View {
|
public var displayNameWithEmojis: some View {
|
||||||
let splittedDisplayName = displayName.split(separator: ":")
|
let splittedDisplayName = displayName.split(separator: ":")
|
||||||
return HStack(spacing: 0) {
|
return HStack(spacing: 0) {
|
||||||
ForEach(splittedDisplayName, id: \.self) { part in
|
ForEach(splittedDisplayName, id: \.self) { part in
|
||||||
if let emoji = emojis.first(where: { $0.shortcode == part }) {
|
if let emoji = emojis.first(where: { $0.shortcode == part }) {
|
||||||
AsyncImage(
|
LazyImage(url: emoji.url) { state in
|
||||||
url: emoji.url,
|
if let image = state.image {
|
||||||
content: { image in
|
image
|
||||||
image.resizable()
|
.resizingMode(.aspectFit)
|
||||||
.aspectRatio(contentMode: .fit)
|
} else if state.isLoading {
|
||||||
.frame(maxWidth: 20, maxHeight: 20)
|
ProgressView()
|
||||||
},
|
} else {
|
||||||
placeholder: {
|
|
||||||
ProgressView()
|
ProgressView()
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
.processors([ImageProcessors.Resize(size: .init(width: 20, height: 20))])
|
||||||
|
.frame(width: 20, height: 20)
|
||||||
} else {
|
} else {
|
||||||
Text(part)
|
Text(part)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ let package = Package(
|
||||||
.package(name: "Models", path: "../Models"),
|
.package(name: "Models", path: "../Models"),
|
||||||
.package(name: "Env", path: "../Env"),
|
.package(name: "Env", path: "../Env"),
|
||||||
.package(name: "Status", path: "../Status"),
|
.package(name: "Status", path: "../Status"),
|
||||||
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0")
|
.package(name: "DesignSystem", path: "../DesignSystem"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
@ -28,7 +28,7 @@ let package = Package(
|
||||||
.product(name: "Models", package: "Models"),
|
.product(name: "Models", package: "Models"),
|
||||||
.product(name: "Env", package: "Env"),
|
.product(name: "Env", package: "Env"),
|
||||||
.product(name: "Status", package: "Status"),
|
.product(name: "Status", package: "Status"),
|
||||||
.product(name: "Shimmer", package: "SwiftUI-Shimmer")
|
.product(name: "DesignSystem", package: "DesignSystem")
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,6 @@ let package = Package(
|
||||||
.package(name: "Network", path: "../Network"),
|
.package(name: "Network", path: "../Network"),
|
||||||
.package(name: "Env", path: "../Env"),
|
.package(name: "Env", path: "../Env"),
|
||||||
.package(name: "DesignSystem", path: "../DesignSystem"),
|
.package(name: "DesignSystem", path: "../DesignSystem"),
|
||||||
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0"),
|
|
||||||
.package(url: "https://github.com/Dimillian/TextView", branch: "main")
|
.package(url: "https://github.com/Dimillian/TextView", branch: "main")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
|
@ -29,7 +28,6 @@ let package = Package(
|
||||||
.product(name: "Network", package: "Network"),
|
.product(name: "Network", package: "Network"),
|
||||||
.product(name: "Env", package: "Env"),
|
.product(name: "Env", package: "Env"),
|
||||||
.product(name: "DesignSystem", package: "DesignSystem"),
|
.product(name: "DesignSystem", package: "DesignSystem"),
|
||||||
.product(name: "Shimmer", package: "SwiftUI-Shimmer"),
|
|
||||||
.product(name: "TextView", package: "TextView")
|
.product(name: "TextView", package: "TextView")
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Models
|
import Models
|
||||||
import Shimmer
|
import Shimmer
|
||||||
|
import Nuke
|
||||||
|
import NukeUI
|
||||||
|
|
||||||
public struct StatusCardView: View {
|
public struct StatusCardView: View {
|
||||||
@Environment(\.openURL) private var openURL
|
@Environment(\.openURL) private var openURL
|
||||||
|
@ -14,21 +16,18 @@ public struct StatusCardView: View {
|
||||||
if let title = card.title {
|
if let title = card.title {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
if let imageURL = card.image {
|
if let imageURL = card.image {
|
||||||
AsyncImage(
|
LazyImage(url: imageURL) { state in
|
||||||
url: imageURL,
|
if let image = state.image {
|
||||||
content: { image in
|
image
|
||||||
image.resizable()
|
.resizingMode(.aspectFill)
|
||||||
.aspectRatio(contentMode: .fill)
|
} else if state.isLoading {
|
||||||
.frame(maxHeight: 200)
|
|
||||||
.clipped()
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.fill(Color.gray)
|
.fill(Color.gray)
|
||||||
.frame(height: 200)
|
.frame(height: 200)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
.frame(height: 200)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
HStack {
|
HStack {
|
||||||
|
|
|
@ -2,6 +2,8 @@ import SwiftUI
|
||||||
import Models
|
import Models
|
||||||
import Env
|
import Env
|
||||||
import Shimmer
|
import Shimmer
|
||||||
|
import Nuke
|
||||||
|
import NukeUI
|
||||||
|
|
||||||
public struct StatusMediaPreviewView: View {
|
public struct StatusMediaPreviewView: View {
|
||||||
@EnvironmentObject private var quickLook: QuickLook
|
@EnvironmentObject private var quickLook: QuickLook
|
||||||
|
@ -89,24 +91,21 @@ public struct StatusMediaPreviewView: View {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
switch type {
|
switch type {
|
||||||
case .image:
|
case .image:
|
||||||
AsyncImage(
|
LazyImage(url: attachement.url) { state in
|
||||||
url: attachement.url,
|
if let image = state.image {
|
||||||
content: { image in
|
|
||||||
image
|
image
|
||||||
.resizable()
|
.resizingMode(.aspectFill)
|
||||||
.aspectRatio(contentMode: attachements.count == 1 ? .fit : .fill)
|
|
||||||
.frame(height: imageMaxHeight)
|
|
||||||
.frame(width: proxy.frame(in: .local).width)
|
|
||||||
.cornerRadius(4)
|
.cornerRadius(4)
|
||||||
},
|
} else if state.isLoading {
|
||||||
placeholder: {
|
|
||||||
RoundedRectangle(cornerRadius: 4)
|
RoundedRectangle(cornerRadius: 4)
|
||||||
.fill(Color.gray)
|
.fill(Color.gray)
|
||||||
.frame(maxHeight: imageMaxHeight)
|
.frame(maxHeight: imageMaxHeight)
|
||||||
.frame(width: proxy.frame(in: .local).width)
|
.frame(width: proxy.frame(in: .local).width)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
.frame(width: proxy.frame(in: .local).width)
|
||||||
|
.frame(height: imageMaxHeight)
|
||||||
case .gifv:
|
case .gifv:
|
||||||
VideoPlayerView(viewModel: .init(url: attachement.url))
|
VideoPlayerView(viewModel: .init(url: attachement.url))
|
||||||
.frame(width: proxy.frame(in: .local).width)
|
.frame(width: proxy.frame(in: .local).width)
|
||||||
|
|
|
@ -18,7 +18,7 @@ let package = Package(
|
||||||
.package(name: "Models", path: "../Models"),
|
.package(name: "Models", path: "../Models"),
|
||||||
.package(name: "Env", path: "../Env"),
|
.package(name: "Env", path: "../Env"),
|
||||||
.package(name: "Status", path: "../Status"),
|
.package(name: "Status", path: "../Status"),
|
||||||
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", exact: "1.1.0")
|
.package(name: "DesignSystem", path: "../DesignSystem"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
@ -28,7 +28,7 @@ let package = Package(
|
||||||
.product(name: "Models", package: "Models"),
|
.product(name: "Models", package: "Models"),
|
||||||
.product(name: "Env", package: "Env"),
|
.product(name: "Env", package: "Env"),
|
||||||
.product(name: "Status", package: "Status"),
|
.product(name: "Status", package: "Status"),
|
||||||
.product(name: "Shimmer", package: "SwiftUI-Shimmer")
|
.product(name: "DesignSystem", package: "DesignSystem")
|
||||||
]),
|
]),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "TimelineTests",
|
name: "TimelineTests",
|
||||||
|
|
Loading…
Reference in a new issue