mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Supports viewing all NewsItems and StoreApps for a source
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SafariServices
|
||||
|
||||
import AltStoreCore
|
||||
import Roxas
|
||||
@@ -304,6 +305,33 @@ private extension SourceDetailContentViewController
|
||||
}
|
||||
}
|
||||
|
||||
private extension SourceDetailContentViewController
|
||||
{
|
||||
@objc func viewAllNews()
|
||||
{
|
||||
self.performSegue(withIdentifier: "showAllNews", sender: nil)
|
||||
}
|
||||
|
||||
@objc func viewAllApps()
|
||||
{
|
||||
self.performSegue(withIdentifier: "showAllApps", sender: nil)
|
||||
}
|
||||
|
||||
@IBSegueAction
|
||||
func makeNewsViewController(_ coder: NSCoder) -> UIViewController?
|
||||
{
|
||||
let newsViewController = NewsViewController(source: self.source, coder: coder)
|
||||
return newsViewController
|
||||
}
|
||||
|
||||
@IBSegueAction
|
||||
func makeBrowseViewController(_ coder: NSCoder) -> UIViewController?
|
||||
{
|
||||
let browseViewController = BrowseViewController(source: self.source, coder: coder)
|
||||
return browseViewController
|
||||
}
|
||||
}
|
||||
|
||||
extension SourceDetailContentViewController
|
||||
{
|
||||
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView
|
||||
@@ -318,6 +346,9 @@ extension SourceDetailContentViewController
|
||||
let buttonView = supplementaryView as! ButtonCollectionReusableView
|
||||
buttonView.button.setTitle(NSLocalizedString("View All", comment: ""), for: .normal)
|
||||
|
||||
buttonView.button.removeTarget(self, action: nil, for: .primaryActionTriggered)
|
||||
buttonView.button.addTarget(self, action: #selector(SourceDetailContentViewController.viewAllNews), for: .primaryActionTriggered)
|
||||
|
||||
case (.featuredApps, .title):
|
||||
let titleView = supplementaryView as! TitleCollectionReusableView
|
||||
titleView.label.text = NSLocalizedString("Featured Apps", comment: "")
|
||||
@@ -326,6 +357,9 @@ extension SourceDetailContentViewController
|
||||
let buttonView = supplementaryView as! ButtonCollectionReusableView
|
||||
buttonView.button.setTitle(NSLocalizedString("View All Apps", comment: ""), for: .normal)
|
||||
|
||||
buttonView.button.removeTarget(self, action: nil, for: .primaryActionTriggered)
|
||||
buttonView.button.addTarget(self, action: #selector(SourceDetailContentViewController.viewAllApps), for: .primaryActionTriggered)
|
||||
|
||||
case (.about, _):
|
||||
let titleView = supplementaryView as! TitleCollectionReusableView
|
||||
titleView.label.text = NSLocalizedString("About", comment: "")
|
||||
@@ -333,6 +367,34 @@ extension SourceDetailContentViewController
|
||||
|
||||
return supplementaryView
|
||||
}
|
||||
|
||||
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
|
||||
{
|
||||
let section = Section(rawValue: indexPath.section)!
|
||||
let item = self.dataSource.item(at: indexPath)
|
||||
|
||||
switch (section, item)
|
||||
{
|
||||
case (.news, let newsItem as NewsItem):
|
||||
if let externalURL = newsItem.externalURL
|
||||
{
|
||||
let safariViewController = SFSafariViewController(url: externalURL)
|
||||
safariViewController.preferredControlTintColor = newsItem.tintColor
|
||||
self.present(safariViewController, animated: true, completion: nil)
|
||||
}
|
||||
else if let storeApp = newsItem.storeApp
|
||||
{
|
||||
let appViewController = AppViewController.makeAppViewController(app: storeApp)
|
||||
self.navigationController?.pushViewController(appViewController, animated: true)
|
||||
}
|
||||
|
||||
case (.featuredApps, let storeApp as StoreApp):
|
||||
let appViewController = AppViewController.makeAppViewController(app: storeApp)
|
||||
self.navigationController?.pushViewController(appViewController, animated: true)
|
||||
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SourceDetailContentViewController: ScrollableContentViewController
|
||||
|
||||
@@ -138,6 +138,32 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="810" y="-13"/>
|
||||
</scene>
|
||||
<!--All Apps-->
|
||||
<scene sceneID="d8a-U8-CPc">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="ih5-9R-QX7" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<collectionViewController storyboardIdentifier="browseViewController" id="Nhf-Gw-Ukx" customClass="BrowseViewController" customModule="AltStore" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="oBI-6P-Lm3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="393" height="783"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="50" minimumInteritemSpacing="10" id="pSh-Xl-aNg">
|
||||
<size key="itemSize" width="375" height="400"/>
|
||||
<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="8" maxX="0.0" maxY="20"/>
|
||||
</collectionViewFlowLayout>
|
||||
<cells/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="Nhf-Gw-Ukx" id="JPE-wa-fZ5"/>
|
||||
<outlet property="delegate" destination="Nhf-Gw-Ukx" id="rW6-a2-seQ"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
<navigationItem key="navigationItem" title="All Apps" id="rUb-ON-AON"/>
|
||||
</collectionViewController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3404" y="-13"/>
|
||||
</scene>
|
||||
<!--Source Detail View Controller-->
|
||||
<scene sceneID="xbN-Mz-TtU">
|
||||
<objects>
|
||||
@@ -192,10 +218,40 @@
|
||||
<outlet property="delegate" destination="MSh-hM-32I" id="8SG-5v-iF2"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
<connections>
|
||||
<segue destination="MVH-oB-c8m" kind="show" identifier="showAllNews" destinationCreationSelector="makeNewsViewController:" id="txA-ay-P7p"/>
|
||||
<segue destination="Nhf-Gw-Ukx" kind="show" identifier="showAllApps" destinationCreationSelector="makeBrowseViewController:" id="On0-GP-kaE"/>
|
||||
</connections>
|
||||
</collectionViewController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2509" y="-13"/>
|
||||
</scene>
|
||||
<!--All News-->
|
||||
<scene sceneID="avV-5f-uNE">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="7f5-vn-JrS" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<collectionViewController storyboardIdentifier="newsViewController" id="MVH-oB-c8m" customClass="NewsViewController" customModule="AltStore" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" id="p9p-rr-fbF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="393" height="783"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="40" minimumInteritemSpacing="40" id="3cD-ax-3h6">
|
||||
<size key="itemSize" width="375" height="300"/>
|
||||
<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="40" maxX="0.0" maxY="13"/>
|
||||
</collectionViewFlowLayout>
|
||||
<cells/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="MVH-oB-c8m" id="tji-Ko-dBy"/>
|
||||
<outlet property="delegate" destination="MVH-oB-c8m" id="fcy-SK-PkD"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
<navigationItem key="navigationItem" title="All News" id="FGB-cd-Vkd"/>
|
||||
</collectionViewController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3404" y="-711"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
|
||||
Reference in New Issue
Block a user