Skip to content

Commit

Permalink
~ Replace matched geo effect with transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
boscojwho committed Aug 22, 2024
1 parent 9893637 commit 2ba9e4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
3 changes: 3 additions & 0 deletions PyTerm/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
},
"Package" : {

},
"Packages saved in Newest/Latest appear here." : {

},
"Pick a Pip Installation" : {

Expand Down
36 changes: 21 additions & 15 deletions PyTerm/PyPIFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ struct PyPIFeedView: View {
) {
Group {
if let items = viewModel.feed?.items {
ForEach(Array(items.enumerated()), id: \.element.hashValue) {
offset,
item in
itemView(item, offset: offset)
.matchedGeometryEffect(
id: offset,
in: feedNamespace,
properties: .position
if items.isEmpty {
GroupBox {
ContentUnavailableView(
"Saved Packages",
systemImage: "star",
description: Text("Packages saved in Newest/Latest appear here.")
)
}
} else {
ForEach(Array(items.enumerated()), id: \.element.hashValue) {
offset,
item in
itemView(item, offset: offset)
}
}
} else {
ForEach(0..<30) { offset in
Expand All @@ -88,11 +93,6 @@ struct PyPIFeedView: View {
}
.padding(6)
.redacted(reason: .placeholder)
.matchedGeometryEffect(
id: offset,
in: feedNamespace,
properties: .position
)
}
}
}
Expand Down Expand Up @@ -186,6 +186,12 @@ struct PyPIFeedView: View {
.fontWeight(.bold)
}
.padding(6)
.transition(
.asymmetric(
insertion: .push(from: .top).combined(with: .opacity),
removal: .scale.combined(with: .opacity)
)
)
.textSelection(.enabled)
.alert(
"Are you sure?",
Expand Down Expand Up @@ -230,14 +236,14 @@ struct PyPIFeedView: View {

private func itemTitle(_ item: RSSFeedItem) -> String {
switch feedType {
case .newestPackages:
case .newestPackages, .savedPackages:
if let title = item.title {
let packageName = title.split(separator: " ", maxSplits: 1).first
return String(packageName ?? "")
} else {
return ""
}
case .latestUpdates, .savedPackages:
case .latestUpdates:
return item.title ?? ""
}
}
Expand Down

0 comments on commit 2ba9e4d

Please sign in to comment.