-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: altstore news + copy dl links + disregard some errors
- Loading branch information
1 parent
7aa3c4f
commit 95acb5d
Showing
10 changed files
with
305 additions
and
4 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
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
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
63 changes: 63 additions & 0 deletions
63
iOS/Views/Sources/SourceAppViews/News/CardContextMenuView.swift
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,63 @@ | ||
// | ||
// CardContextMenuView.swift | ||
// feather | ||
// | ||
// Created by samara on 4.02.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CardContextMenuView: View { | ||
let news: NewsData | ||
|
||
var formattedDate: String { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd" | ||
if let date = dateFormatter.date(from: news.date) { | ||
return date.formatted(.relative(presentation: .named)) | ||
} | ||
return news.date | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 12) { | ||
AsyncImage(url: URL(string: news.imageURL ?? "")) { image in | ||
image.resizable() | ||
.aspectRatio(contentMode: .fill) | ||
} placeholder: { | ||
Color.gray | ||
} | ||
.frame(width: 280, height: 160) | ||
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous)) | ||
.overlay( | ||
LinearGradient( | ||
gradient: Gradient(colors: [.clear, .black.opacity(0.2)]), | ||
startPoint: .top, | ||
endPoint: .bottom | ||
) | ||
) | ||
|
||
VStack(alignment: .leading, spacing: 8) { | ||
Text(news.title) | ||
.font(.title3) | ||
.fontWeight(.bold) | ||
.lineLimit(2) | ||
|
||
if let caption = news.caption { | ||
Text(caption) | ||
.font(.subheadline) | ||
.foregroundColor(.secondary) | ||
.lineLimit(2) | ||
} | ||
|
||
Text(formattedDate) | ||
.font(.caption) | ||
.foregroundColor(.secondary) | ||
} | ||
} | ||
.frame(width: 280) | ||
.padding() | ||
.background(Color(uiColor: .systemBackground)) | ||
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) | ||
} | ||
} |
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,85 @@ | ||
// | ||
// NewsCardView.swift | ||
// feather | ||
// | ||
// Created by samara on 3.02.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct NewsCardView: View { | ||
let news: NewsData | ||
|
||
var body: some View { | ||
ZStack(alignment: .bottomLeading) { | ||
if (news.imageURL != nil) { | ||
AsyncImage(url: URL(string: news.imageURL!)) { image in | ||
Color.clear.overlay( | ||
image | ||
.resizable() | ||
.aspectRatio(contentMode: .fill) | ||
) | ||
} placeholder: { | ||
Color.black.opacity(0.2) | ||
} | ||
|
||
LinearGradient( | ||
gradient: Gradient(colors: [.clear, .black.opacity(0.7)]), | ||
startPoint: .top, | ||
endPoint: .bottom | ||
) | ||
} | ||
VariableBlurView() | ||
.opacity(0.97) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.rotationEffect(.degrees(180)) | ||
.padding(.top, 95) | ||
|
||
VStack { | ||
Spacer() | ||
Text(news.title) | ||
.font(.headline) | ||
.fontWeight(.bold) | ||
.foregroundColor(.white) | ||
.lineLimit(2) | ||
.padding() | ||
} | ||
} | ||
.frame(width: 250, height: 150) | ||
.background(Color(uiColor: UIColor(hex: news.tintColor ?? "000000"))) | ||
.clipShape( | ||
RoundedRectangle(cornerRadius: 12, style: .continuous) | ||
) | ||
.overlay( | ||
RoundedRectangle(cornerRadius: 12, style: .continuous) | ||
.stroke(Color.white.opacity(0.15), lineWidth: 2) | ||
) | ||
.compactContentMenuPreview(news: news) | ||
} | ||
} | ||
|
||
extension View { | ||
func compactContentMenuPreview(news: NewsData) -> some View { | ||
if #available(iOS 16.0, *) { | ||
return self.contextMenu { | ||
if (news.url != nil) { | ||
Button(action: { | ||
UIApplication.shared.open(news.url!) | ||
}) { | ||
Label("Open URL", systemImage: "arrow.up.right") | ||
} | ||
} else { | ||
Button(action: { | ||
UIApplication.shared.open(URL(string: "https://github.com/khcrysalis/feather")!) | ||
}) { | ||
Label("Give us a star!", systemImage: "star") | ||
} | ||
} | ||
} preview: { | ||
CardContextMenuView(news: news) | ||
} | ||
} else { | ||
return self | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
iOS/Views/Sources/SourceAppViews/News/NewsCardsScrollView.swift
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,28 @@ | ||
// | ||
// NewsCardsScrollView.swift | ||
// feather | ||
// | ||
// Created by samara on 3.02.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct NewsCardsScrollView: View { | ||
@State private var newsData: [NewsData] | ||
|
||
init(newsData: [NewsData]) { | ||
_newsData = State(initialValue: newsData) | ||
} | ||
|
||
var body: some View { | ||
ScrollView(.horizontal, showsIndicators: false) { | ||
HStack(spacing: 10) { | ||
ForEach(newsData.reversed(), id: \.self) { new in | ||
NewsCardView(news: new) | ||
} | ||
} | ||
.padding() | ||
} | ||
.frame(maxWidth: .infinity) | ||
} | ||
} |
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
Oops, something went wrong.