- Cleanup.
This commit is contained in:
David Sinclair 2022-11-10 19:22:03 -07:00
parent c3a21924b6
commit 14247ac926
5 changed files with 4 additions and 215 deletions

View file

@ -1,129 +0,0 @@
//
// GridDetailViewController.swift
// NewsBlur
//
// Created by David Sinclair on 2022-08-19.
// Copyright © 2022 NewsBlur. All rights reserved.
//
import UIKit
/// A view controller to manage the Grid layout.
class GridDetailViewController: UIViewController {
/// Returns the shared app delegate.
var appDelegate: NewsBlurAppDelegate {
return NewsBlurAppDelegate.shared()
}
@IBOutlet var collectionView: UICollectionView!
enum SectionLayoutKind: Int, CaseIterable {
/// Feed cells before the story.
case feedBeforeStory
/// The selected story.
case selectedStory
/// Feed cells after the story.
case feedAfterStory
}
var feedColumns: Int {
guard let pref = UserDefaults.standard.string(forKey: "grid_columns"), let columns = Int(pref) else {
return 4
}
return columns
}
var dataSource: UICollectionViewDiffableDataSource<SectionLayoutKind, Int>! = nil
override func viewDidLoad() {
super.viewDidLoad()
collectionView.collectionViewLayout = createLayout()
configureDataSource()
}
@objc func reload() {
configureDataSource()
}
}
extension GridDetailViewController {
func createLayout() -> UICollectionViewLayout {
let layout = UICollectionViewCompositionalLayout { (sectionIndex: Int,
layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in
guard let sectionLayoutKind = SectionLayoutKind(rawValue: sectionIndex) else {
return nil
}
let isStory = sectionLayoutKind == .selectedStory
let columns = isStory ? 1 : self.feedColumns
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalHeight(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
let groupHeight = isStory ?
NSCollectionLayoutDimension.absolute(1000) :
NSCollectionLayoutDimension.fractionalWidth(0.4)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: groupHeight)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: columns)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 0, trailing: 10)
return section
}
return layout
}
}
extension GridDetailViewController {
func configureDataSource() {
let feedCellRegistration = UICollectionView.CellRegistration<GridFeedCell, Int> { (cell, indexPath, identifier) in
cell.contentView.backgroundColor = UIColor.red
cell.contentView.layer.borderColor = UIColor.black.cgColor
cell.contentView.layer.borderWidth = 1
// cell.contentView.layer.cornerRadius = SectionLayoutKind(rawValue: indexPath.section)! == .feed ? 8 : 0
//TODO: 🚧
}
let storyCellRegistration = UICollectionView.CellRegistration<StoryPagesCollectionCell, Int> { (cell, indexPath, identifier) in
//TODO: 🚧
cell.contentView.backgroundColor = UIColor.blue
}
dataSource = UICollectionViewDiffableDataSource<SectionLayoutKind, Int>(collectionView: collectionView) {
(collectionView: UICollectionView, indexPath: IndexPath, identifier: Int) -> UICollectionViewCell? in
return SectionLayoutKind(rawValue: indexPath.section)! == .selectedStory ?
collectionView.dequeueConfiguredReusableCell(using: storyCellRegistration, for: indexPath, item: identifier) : collectionView.dequeueConfiguredReusableCell(using: feedCellRegistration, for: indexPath, item: identifier)
}
var snapshot = NSDiffableDataSourceSnapshot<SectionLayoutKind, Int>()
if let activeFeed = appDelegate.storiesCollection.activeFeedStories {
let numberOfStories = activeFeed.count
let selectedIndex = min(numberOfStories - 1, 8)
snapshot.appendSections(SectionLayoutKind.allCases)
snapshot.appendItems(Array(0..<selectedIndex - 1), toSection: .feedBeforeStory)
snapshot.appendItems([selectedIndex], toSection: .selectedStory)
snapshot.appendItems(Array(selectedIndex + 1..<numberOfStories), toSection: .feedAfterStory)
}
dataSource.apply(snapshot, animatingDifferences: false)
}
}
extension GridDetailViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
collectionView.deselectItem(at: indexPath, animated: true)
}
}

View file

@ -1,15 +0,0 @@
//
// GridFeedCell.swift
// NewsBlur
//
// Created by David Sinclair on 2022-08-19.
// Copyright © 2022 NewsBlur. All rights reserved.
//
import UIKit
/// Collection view cell for a feed detail title.
class GridFeedCell: UICollectionViewCell {
static let reuseIdentifier = "GridFeedCell"
}

View file

@ -20,7 +20,6 @@ class Storyboards {
/// Main storyboard identifiers.
enum Main: String {
case feedDetail = "FeedDetailViewController"
case gridDetail = "GridDetailViewController"
case horizontalPages = "HorizontalPageViewController"
case verticalPages = "VerticalPageViewController"
// case storyDetail = "StoryDetailViewController" // loading from XIB currently

View file

@ -80,8 +80,6 @@
177551D5238E228A00E27818 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 177551D4238E228A00E27818 /* NotificationCenter.framework */; platformFilter = ios; };
177551DB238E228A00E27818 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 177551D9238E228A00E27818 /* MainInterface.storyboard */; };
177551DF238E228A00E27818 /* Old NewsBlur Latest.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 177551D3238E228A00E27818 /* Old NewsBlur Latest.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
177D017828B056C600F2F2DB /* GridDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 177D017728B056C600F2F2DB /* GridDetailViewController.swift */; };
177D017B28B05D2500F2F2DB /* GridFeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 177D017A28B05D2500F2F2DB /* GridFeedCell.swift */; };
177D017D28B05D9500F2F2DB /* StoryPagesCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 177D017C28B05D9500F2F2DB /* StoryPagesCollectionCell.swift */; };
17813FB723AC6E450057FB16 /* WidgetErrorTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 17CE3F0523AC529B003152EF /* WidgetErrorTableViewCell.xib */; };
1787083024F8B3A50000C82B /* StoryDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1787082F24F8B3A50000C82B /* StoryDetailViewController.swift */; };
@ -826,8 +824,6 @@
177551DA238E228A00E27818 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
177551DC238E228A00E27818 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
177551E3238E26BF00E27818 /* Widget Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Widget Extension.entitlements"; sourceTree = "<group>"; };
177D017728B056C600F2F2DB /* GridDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridDetailViewController.swift; sourceTree = "<group>"; };
177D017A28B05D2500F2F2DB /* GridFeedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridFeedCell.swift; sourceTree = "<group>"; };
177D017C28B05D9500F2F2DB /* StoryPagesCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryPagesCollectionCell.swift; sourceTree = "<group>"; };
1787082F24F8B3A50000C82B /* StoryDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryDetailViewController.swift; sourceTree = "<group>"; };
17876B9A1C9911D40055DD15 /* g_icn_folder_rss_sm.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = g_icn_folder_rss_sm.png; sourceTree = "<group>"; };
@ -1697,7 +1693,6 @@
431B857315A131C300DCE497 /* Feeds */,
431B857215A131B200DCE497 /* Feed-Detail */,
431B857415A1324200DCE497 /* Story */,
177D017928B05CBF00F2F2DB /* Grid */,
431B857115A1317000DCE497 /* FTUX */,
431B857015A1315F00DCE497 /* Social */,
FF3FA8871BB26595001F7C32 /* Activities */,
@ -1809,15 +1804,6 @@
path = "Old Widget Extension";
sourceTree = "<group>";
};
177D017928B05CBF00F2F2DB /* Grid */ = {
isa = PBXGroup;
children = (
177D017728B056C600F2F2DB /* GridDetailViewController.swift */,
177D017A28B05D2500F2F2DB /* GridFeedCell.swift */,
);
name = Grid;
sourceTree = "<group>";
};
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
@ -3781,7 +3767,6 @@
17432C831C53438D003F8FD6 /* FeedChooserViewController.m in Sources */,
010EDEFA1B2386B7003B79DE /* OnePasswordExtension.m in Sources */,
43ABBCAA15B53A1400EA3111 /* InteractionCell.m in Sources */,
177D017828B056C600F2F2DB /* GridDetailViewController.swift in Sources */,
FF8D1ECF1BAA311000725D8A /* SBJson4StreamTokeniser.m in Sources */,
FF8D1ED81BAA33BA00725D8A /* NSObject+SBJSON.m in Sources */,
172AD274251D9F40000BB264 /* Storyboards.swift in Sources */,
@ -3810,7 +3795,6 @@
176A5C7A24F8BD1B009E8DF9 /* DetailViewController.swift in Sources */,
17432C7F1C533FBC003F8FD6 /* MenuViewController.m in Sources */,
FFF8B3AF1F847505001AB95E /* NBDashboardNavigationBar.m in Sources */,
177D017B28B05D2500F2F2DB /* GridFeedCell.swift in Sources */,
17E635AF1C548C580075338E /* FeedChooserItem.m in Sources */,
FF6A233216448E0700E15989 /* StoryPagesObjCViewController.m in Sources */,
FF67D3B2168924C40057A7DA /* TrainerViewController.m in Sources */,
@ -3973,7 +3957,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4019,7 +4002,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4078,7 +4060,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4128,7 +4109,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4180,7 +4160,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Old Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4227,7 +4206,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Old Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4270,7 +4248,6 @@
GCC_VERSION = "";
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "NewsBlur-iPhone-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@ -4320,7 +4297,6 @@
GCC_VERSION = "";
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "NewsBlur-iPhone-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@ -4383,8 +4359,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/**";
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MACOSX_DEPLOYMENT_TARGET = 10.15;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 11.1;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
@ -4436,8 +4412,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/**";
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MACOSX_DEPLOYMENT_TARGET = 10.15;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 11.1;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
@ -4481,7 +4457,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -4521,7 +4496,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",

View file

@ -303,46 +303,6 @@
</objects>
<point key="canvasLocation" x="-546" y="1835"/>
</scene>
<!--Grid Detail View Controller-->
<scene sceneID="OXZ-eV-qQz">
<objects>
<viewController storyboardIdentifier="GridDetailViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="QmF-fv-1Bp" customClass="GridDetailViewController" customModule="NewsBlur" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="JQ6-ZA-aZb">
<rect key="frame" x="0.0" y="0.0" width="1194" height="834"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="vaf-JJ-7oP">
<rect key="frame" x="0.0" y="0.0" width="1194" height="834"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Fmx-jr-pAt">
<size key="itemSize" width="128" height="128"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet property="delegate" destination="QmF-fv-1Bp" id="UAX-33-p9U"/>
</connections>
</collectionView>
</subviews>
<viewLayoutGuide key="safeArea" id="pwo-OK-kJk"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="vaf-JJ-7oP" firstAttribute="top" secondItem="JQ6-ZA-aZb" secondAttribute="top" id="7F9-cE-mjz"/>
<constraint firstAttribute="trailing" secondItem="vaf-JJ-7oP" secondAttribute="trailing" id="Dp9-b5-7mR"/>
<constraint firstAttribute="bottom" secondItem="vaf-JJ-7oP" secondAttribute="bottom" id="jin-ea-ii1"/>
<constraint firstItem="vaf-JJ-7oP" firstAttribute="leading" secondItem="JQ6-ZA-aZb" secondAttribute="leading" id="uJn-0H-m3i"/>
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="vaf-JJ-7oP" id="BkE-3h-foS"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5kV-BU-lYP" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="181" y="2678"/>
</scene>
<!--Horizontal Page View Controller-->
<scene sceneID="Dnt-lB-G3h">
<objects>