mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00

- Implemented theme colors. - Implemented the content length options. - Implemented the font size options. - Implemented the compact / comfortable options. - Improved the logic for the rounded corners on cards.
82 lines
2.4 KiB
Swift
82 lines
2.4 KiB
Swift
//
|
|
// FeedDetailStoryView.swift
|
|
// NewsBlur
|
|
//
|
|
// Created by David Sinclair on 2023-02-01.
|
|
// Copyright © 2023 NewsBlur. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Story view within the feed detail, only used in grid layout.
|
|
struct StoryView: View {
|
|
let cache: StoryCache
|
|
|
|
let story: Story
|
|
|
|
let interaction: FeedDetailInteraction
|
|
|
|
var body: some View {
|
|
VStack {
|
|
ZStack {
|
|
Color.themed([0xFFFDEF, 0xEEECCD, 0x303A40, 0x303030])
|
|
|
|
HStack {
|
|
Text(story.title)
|
|
.padding()
|
|
|
|
Spacer()
|
|
|
|
if let image = previewImage {
|
|
gridPreview(image: image)
|
|
}
|
|
|
|
Text(story.dateString)
|
|
.padding()
|
|
}
|
|
}
|
|
.font(.custom("WhitneySSm-Medium", size: 14, relativeTo: .body))
|
|
.foregroundColor(Color.themed([0x686868, 0xA0A0A0]))
|
|
.frame(height: 50)
|
|
.clipShape(RoundedRectangle(cornerRadius: 10))
|
|
.onTapGesture {
|
|
interaction.storyHidden(story)
|
|
}
|
|
|
|
StoryPagesView()
|
|
}
|
|
}
|
|
|
|
var previewImage: UIImage? {
|
|
guard cache.settings.preview != .none, let image = cache.appDelegate.cachedImage(forStoryHash: story.hash), image.isKind(of: UIImage.self) else {
|
|
return nil
|
|
}
|
|
|
|
return image
|
|
}
|
|
|
|
@ViewBuilder
|
|
func gridPreview(image: UIImage) -> some View {
|
|
Image(uiImage: image)
|
|
.resizable()
|
|
.scaledToFill()
|
|
.frame(width: 200, height: 50)
|
|
.clipped()
|
|
}
|
|
}
|
|
|
|
struct StoryPagesView: UIViewControllerRepresentable {
|
|
typealias UIViewControllerType = StoryPagesViewController
|
|
|
|
let appDelegate = NewsBlurAppDelegate.shared!
|
|
|
|
func makeUIViewController(context: Context) -> StoryPagesViewController {
|
|
appDelegate.detailViewController.prepareStoriesForGridView()
|
|
|
|
return appDelegate.storyPagesViewController
|
|
}
|
|
|
|
func updateUIViewController(_ storyPagesViewController: StoryPagesViewController, context: Context) {
|
|
storyPagesViewController.updatePage(withActiveStory: appDelegate.storiesCollection.locationOfActiveStory(), updateFeedDetail: false)
|
|
}
|
|
}
|