Skip to content

Commit d89a53d

Browse files
committed
feat: abillity to visit website inside of repositories
1 parent b3fa85b commit d89a53d

File tree

5 files changed

+100
-85
lines changed

5 files changed

+100
-85
lines changed

Shared/Data/CoreData/Models/SourcesModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public struct SourcesData: Codable, Hashable {
1616

1717
public var sourceURL: URL?
1818
public var iconURL: URL?
19+
public var website: String?
1920
public var news: [NewsData]?
2021
public var apps: [StoreAppsData]
2122

feather.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iOS/Views/Sources/SourceAppViews/News/CardContextMenuView.swift

Lines changed: 76 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -23,90 +23,92 @@ struct CardContextMenuView: View {
2323

2424
var body: some View {
2525
NavigationView {
26-
VStack(spacing: 12) {
27-
if (news.imageURL != nil) {
28-
AsyncImage(url: URL(string: news.imageURL ?? "")) { image in
29-
Color.clear.overlay(
30-
image
31-
.resizable()
32-
.aspectRatio(contentMode: .fill)
26+
ScrollView {
27+
VStack(spacing: 12) {
28+
if (news.imageURL != nil) {
29+
AsyncImage(url: URL(string: news.imageURL ?? "")) { image in
30+
Color.clear.overlay(
31+
image
32+
.resizable()
33+
.aspectRatio(contentMode: .fill)
34+
)
35+
.transition(.opacity.animation(.easeInOut(duration: 0.3)))
36+
} placeholder: {
37+
Color.black
38+
.opacity(0.2)
39+
.overlay(
40+
ProgressView()
41+
.progressViewStyle(.circular)
42+
.tint(.white)
43+
)
44+
}
45+
.background(Color(uiColor: UIColor(hex: news.tintColor ?? "000000")))
46+
.clipShape(
47+
RoundedRectangle(cornerRadius: 12, style: .continuous)
3348
)
34-
.transition(.opacity.animation(.easeInOut(duration: 0.3)))
35-
} placeholder: {
36-
Color.black
37-
.opacity(0.2)
38-
.overlay(
39-
ProgressView()
40-
.progressViewStyle(.circular)
41-
.tint(.white)
49+
.overlay(
50+
LinearGradient(
51+
gradient: Gradient(colors: [.clear, .black.opacity(0.2)]),
52+
startPoint: .top,
53+
endPoint: .bottom
4254
)
43-
}
44-
.background(Color(uiColor: UIColor(hex: news.tintColor ?? "000000")))
45-
.clipShape(
46-
RoundedRectangle(cornerRadius: 12, style: .continuous)
47-
)
48-
.overlay(
49-
LinearGradient(
50-
gradient: Gradient(colors: [.clear, .black.opacity(0.2)]),
51-
startPoint: .top,
52-
endPoint: .bottom
5355
)
54-
)
55-
.overlay(
56-
RoundedRectangle(cornerRadius: 12, style: .continuous)
57-
.stroke(Color.white.opacity(0.15), lineWidth: 2)
58-
)
59-
.frame(height: 250)
60-
}
61-
62-
VStack(alignment: .leading, spacing: 16) {
63-
if let title = news.title {
64-
Text(title)
65-
.font(.title)
66-
.fontWeight(.bold)
67-
.lineLimit(2)
68-
.foregroundStyle(.primary)
69-
.multilineTextAlignment(.leading)
70-
}
71-
72-
if let caption = news.caption {
73-
Text(caption)
74-
.font(.headline)
75-
.foregroundColor(.secondary)
76-
.multilineTextAlignment(.leading)
56+
.overlay(
57+
RoundedRectangle(cornerRadius: 12, style: .continuous)
58+
.stroke(Color.white.opacity(0.15), lineWidth: 2)
59+
)
60+
.frame(height: 250)
7761
}
7862

79-
if (news.url != nil) {
80-
Button(action: {
81-
UIApplication.shared.open(news.url!)
82-
}) {
83-
Label("Open URL", systemImage: "arrow.up.right")
84-
.frame(maxWidth: .infinity)
63+
VStack(alignment: .leading, spacing: 16) {
64+
if let title = news.title {
65+
Text(title)
66+
.font(.title)
67+
.fontWeight(.bold)
68+
.lineLimit(2)
69+
.foregroundStyle(.primary)
70+
.multilineTextAlignment(.leading)
71+
}
72+
73+
if let caption = news.caption {
74+
Text(caption)
75+
.font(.headline)
76+
.foregroundColor(.secondary)
77+
.multilineTextAlignment(.leading)
8578
}
86-
.padding()
87-
.foregroundColor(.accentColor)
88-
.background(Color(uiColor: .secondarySystemBackground))
89-
.cornerRadius(10)
79+
80+
if (news.url != nil) {
81+
Button(action: {
82+
UIApplication.shared.open(news.url!)
83+
}) {
84+
Label("Open URL", systemImage: "arrow.up.right")
85+
.frame(maxWidth: .infinity)
86+
}
87+
.padding()
88+
.foregroundColor(.accentColor)
89+
.background(Color(uiColor: .secondarySystemBackground))
90+
.cornerRadius(10)
91+
}
92+
93+
Text(formattedDate)
94+
.font(.caption)
95+
.foregroundColor(.secondary)
9096
}
97+
.frame(maxWidth: .infinity)
9198

92-
Text(formattedDate)
93-
.font(.caption)
94-
.foregroundColor(.secondary)
99+
Spacer()
95100
}
96-
.frame(maxWidth: .infinity)
97-
98-
Spacer()
101+
.frame(
102+
minWidth: 0,
103+
maxWidth: .infinity,
104+
minHeight: 0,
105+
maxHeight: .infinity,
106+
alignment: .topLeading
107+
)
108+
.padding()
109+
.background(Color(uiColor: .systemBackground))
110+
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
99111
}
100-
.frame(
101-
minWidth: 0,
102-
maxWidth: .infinity,
103-
minHeight: 0,
104-
maxHeight: .infinity,
105-
alignment: .topLeading
106-
)
107-
.padding()
108-
.background(Color(uiColor: .systemBackground))
109-
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
110112
.toolbar {
111113
ToolbarItem(placement: .topBarLeading) {
112114
Button(action: {

iOS/Views/Sources/SourceAppViews/SourceAppViewController.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class SourceAppViewController: UITableViewController {
2525
var filteredApps: [StoreAppsData] = []
2626

2727
var name: String? { didSet { self.title = name } }
28-
2928
var uri: [URL]!
3029

3130

@@ -182,6 +181,7 @@ class SourceAppViewController: UITableViewController {
182181
var allApps: [StoreAppsData] = []
183182
var newsData: [NewsData] = []
184183

184+
var website = ""
185185
var tintColor = ""
186186

187187
for uri in urls {
@@ -194,6 +194,7 @@ class SourceAppViewController: UITableViewController {
194194
allApps.append(contentsOf: sourceData.apps)
195195
newsData.append(contentsOf: sourceData.news ?? [])
196196
tintColor = sourceData.tintColor ?? ""
197+
website = sourceData.website ?? ""
197198
}
198199
case .failure(let error):
199200
Debug.shared.log(message: "Error fetching data from \(uri): \(error.localizedDescription)")
@@ -220,8 +221,27 @@ class SourceAppViewController: UITableViewController {
220221
self?.applyFilter()
221222
}
222223

224+
if self?.uri.count == 1 {
225+
let children = [
226+
UIAction(title: "Visit Website", image: UIImage(systemName: "globe")) { _ in
227+
UIApplication.shared.open(URL(string: website)!, options: [:], completionHandler: nil)
228+
}
229+
]
230+
231+
let menu = UIMenu(children: children)
232+
233+
if #available(iOS 16.0, *) {
234+
if (website != "") {
235+
self?.navigationItem.titleMenuProvider = { _ in
236+
menu
237+
}
238+
}
239+
}
240+
}
241+
223242
UIView.transition(with: self!.tableView, duration: 0.3, options: .transitionCrossDissolve, animations: {
224243
self!.activityIndicator.stopAnimating()
244+
225245
self?.navigationItem.titleView = nil
226246
if self?.highlightAppName == nil {
227247
self?.updateFilterMenu()

0 commit comments

Comments
 (0)