Adds social media follow buttons to Settings

This commit is contained in:
Riley Testut
2024-02-14 15:50:09 -06:00
committed by Magesh K
parent f85dcdcd4a
commit 1c02da8806
10 changed files with 220 additions and 13 deletions

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "github.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "threads_icon.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "mastodon.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "twitter.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -15,18 +15,90 @@
<objects>
<tableViewController id="aMk-Xp-UL8" customClass="SettingsViewController" customModule="SideStore" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" indicatorStyle="white" dataMode="static" style="grouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="MuO-1I-cKW">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="1614"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" name="SettingsBackground"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="separatorColor" white="1" alpha="0.25" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<label key="tableFooterView" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SideStore 1.0" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="bUR-rp-Nw2">
<rect key="frame" x="0.0" y="1347" width="375" height="25"/>
<stackView key="tableFooterView" opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalCentering" alignment="center" spacing="15" id="48g-cT-stR">
<rect key="frame" x="0.0" y="1270" width="375" height="125"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="0.69999999999999996" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="900" text="Follow AltStore for updates" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XFa-MY-7cV">
<rect key="frame" x="84.5" y="0.0" width="206" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="0.69999999999999996" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="hru-pm-ZI3">
<rect key="frame" x="88.5" y="46" width="198" height="34.5"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="fill" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="B8Q-e7-beR" userLabel="Mastodon">
<rect key="frame" x="0.0" y="0.0" width="34.5" height="34.5"/>
<constraints>
<constraint firstAttribute="width" secondItem="B8Q-e7-beR" secondAttribute="height" id="gaj-Mb-oSa"/>
<constraint firstAttribute="width" constant="34.5" id="kjw-36-Rjk"/>
</constraints>
<state key="normal" title=""/>
<buttonConfiguration key="configuration" style="plain" title=" ">
<backgroundConfiguration key="background" image="Mastodon" imageContentMode="scaleAspectFit"/>
</buttonConfiguration>
<connections>
<action selector="followAltStoreMastodon" destination="aMk-Xp-UL8" eventType="primaryActionTriggered" id="nKQ-bR-E96"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="fill" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AWk-yE-9LI" userLabel="Threads">
<rect key="frame" x="54.5" y="0.0" width="34.5" height="34.5"/>
<constraints>
<constraint firstAttribute="width" constant="34.5" id="3o9-57-KDr"/>
<constraint firstAttribute="width" secondItem="AWk-yE-9LI" secondAttribute="height" id="QuX-po-kv7"/>
</constraints>
<state key="normal" title=""/>
<buttonConfiguration key="configuration" style="plain">
<backgroundConfiguration key="background" image="Threads" imageContentMode="scaleAspectFit"/>
</buttonConfiguration>
<connections>
<action selector="followAltStoreThreads" destination="aMk-Xp-UL8" eventType="primaryActionTriggered" id="0f0-KK-7lE"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="fill" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uYZ-Vu-RzK" userLabel="Twitter">
<rect key="frame" x="109" y="0.0" width="34.5" height="34.5"/>
<constraints>
<constraint firstAttribute="width" constant="34.5" id="LKG-L3-APj"/>
<constraint firstAttribute="width" secondItem="uYZ-Vu-RzK" secondAttribute="height" id="UyA-cy-ol3"/>
</constraints>
<state key="normal" title=""/>
<buttonConfiguration key="configuration" style="plain">
<backgroundConfiguration key="background" image="Twitter" imageContentMode="scaleAspectFit"/>
</buttonConfiguration>
<connections>
<action selector="followAltStoreTwitter" destination="aMk-Xp-UL8" eventType="primaryActionTriggered" id="m1Q-xB-VTe"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="fill" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oqj-4S-I9l" userLabel="GitHub">
<rect key="frame" x="163.5" y="0.0" width="34.5" height="34.5"/>
<constraints>
<constraint firstAttribute="width" constant="34.5" id="BEp-uf-a6X"/>
<constraint firstAttribute="width" secondItem="oqj-4S-I9l" secondAttribute="height" id="ye3-ez-e16"/>
</constraints>
<state key="normal" title=""/>
<buttonConfiguration key="configuration" style="plain">
<backgroundConfiguration key="background" image="GitHub" imageContentMode="scaleAspectFit"/>
</buttonConfiguration>
<connections>
<action selector="followAltStoreGitHub" destination="aMk-Xp-UL8" eventType="primaryActionTriggered" id="vo1-Er-hjQ"/>
</connections>
</button>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="900" text="Version 2.0" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5u7-mb-jJj">
<rect key="frame" x="151.5" y="108" width="72.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="0.69999999999999996" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<sections>
<tableViewSection headerTitle="" id="flW-d4-bco">
<cells>
@@ -918,6 +990,7 @@
</connections>
</tableView>
<navigationItem key="navigationItem" title="Settings" id="Ddg-UQ-KJ8"/>
<size key="freeformSize" width="375" height="1614"/>
<connections>
<outlet property="accountEmailLabel" destination="0uP-Cd-tNX" id="14b-aL-yE3"/>
<outlet property="accountNameLabel" destination="CnN-M1-AYK" id="Ldc-Py-Bix"/>
@@ -927,7 +1000,11 @@
<outlet property="noIdleTimeoutSwitch" destination="iQA-wm-5ag" id="jHC-js-q0Y"/>
<outlet property="disableResponseCachingSwitch" destination="e30-w4-5fk" id="Duy-Yb-eo1"/>
<outlet property="enforceThreeAppLimitSwitch" destination="Oie-te-KSQ" id="jKn-t1-gyk"/>
<outlet property="versionLabel" destination="bUR-rp-Nw2" id="85I-5R-hqz"/>
<outlet property="githubButton" destination="oqj-4S-I9l" id="sxB-LE-gA2"/>
<outlet property="mastodonButton" destination="B8Q-e7-beR" id="Kbe-Og-rsg"/>
<outlet property="threadsButton" destination="AWk-yE-9LI" id="SOc-ei-4gK"/>
<outlet property="twitterButton" destination="uYZ-Vu-RzK" id="anA-jh-w4z"/>
<outlet property="versionLabel" destination="5u7-mb-jJj" id="zvU-TQ-lO6"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SI0-mJ-Wad" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -1283,7 +1360,7 @@ Settings by i cons from the Noun Project</string>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
</accessibility>
<state key="normal" title="Button"/>
<state key="normal" title=""/>
<buttonConfiguration key="configuration" style="plain" title=" "/>
</button>
</subviews>
@@ -1403,6 +1480,8 @@ Settings by i cons from the Noun Project</string>
</scene>
</scenes>
<resources>
<image name="GitHub" width="130" height="130"/>
<image name="Mastodon" width="130" height="130"/>
<image name="Next" width="18" height="18"/>
<image name="Settings" width="20" height="20"/>
<image name="ladybug" catalog="system" width="128" height="122"/>

View File

@@ -99,6 +99,11 @@ final class SettingsViewController: UITableViewController
@IBOutlet private var enforceThreeAppLimitSwitch: UISwitch!
@IBOutlet private var disableResponseCachingSwitch: UISwitch!
@IBOutlet private var mastodonButton: UIButton!
@IBOutlet private var threadsButton: UIButton!
@IBOutlet private var twitterButton: UIButton!
@IBOutlet private var githubButton: UIButton!
@IBOutlet private var versionLabel: UILabel!
override var preferredStatusBarStyle: UIStatusBarStyle {
@@ -142,7 +147,7 @@ final class SettingsViewController: UITableViewController
let localizedVersion = installedApp.version
#endif
self.versionLabel.text = NSLocalizedString(String(format: "AltStore %@", localizedVersion), comment: "AltStore Version")
self.versionLabel.text = NSLocalizedString(String(format: "Version %@", localizedVersion), comment: "AltStore Version")
}
else if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
{
@@ -159,9 +164,11 @@ final class SettingsViewController: UITableViewController
versionString += " - \(!pair_test)"
}
}
self.versionLabel.text = NSLocalizedString(String(format: "Version %@", version), comment: "AltStore Version")
}
else
{
self.versionLabel.text = nil
versionString += "SideStore\t"
}
versionString += "\n\(Bundle.Info.appbundleIdentifier)"
@@ -176,10 +183,26 @@ final class SettingsViewController: UITableViewController
self.update()
if #available(iOS 15, *), let appearance = self.tabBarController?.tabBar.standardAppearance
if #available(iOS 15, *)
{
appearance.stackedLayoutAppearance.normal.badgeBackgroundColor = .altPrimary
self.navigationController?.tabBarItem.scrollEdgeAppearance = appearance
if let appearance = self.tabBarController?.tabBar.standardAppearance
{
appearance.stackedLayoutAppearance.normal.badgeBackgroundColor = .altPrimary
self.navigationController?.tabBarItem.scrollEdgeAppearance = appearance
}
// We can only configure the contentMode for a button's background image from Interface Builder.
// This works, but it means buttons don't visually highlight because there's no foreground image.
// As a workaround, we manually set the foreground image + contentMode here.
for button in [self.mastodonButton!, self.threadsButton!, self.twitterButton!, self.githubButton!]
{
// Get the assigned image from Interface Builder.
let image = button.configuration?.background.image
button.configuration = nil
button.setImage(image, for: .normal)
button.imageView?.contentMode = .scaleAspectFit
}
}
}
@@ -497,6 +520,51 @@ private extension SettingsViewController
}
}
}
func openMastodon(username: String)
{
// Rely on universal links to open app.
let components = username.split(separator: "@")
guard components.count == 2 else { return }
let server = String(components[1])
let username = "@" + String(components[0])
guard let serverURL = URL(string: "https://" + server) else { return }
let mastodonURL = serverURL.appendingPathComponent(username)
UIApplication.shared.open(mastodonURL, options: [:])
}
func openThreads(username: String)
{
// Rely on universal links to open app.
let safariURL = URL(string: "https://www.threads.net/@" + username)!
UIApplication.shared.open(safariURL, options: [:])
}
@IBAction func followAltStoreMastodon()
{
self.openMastodon(username: "@altstore@fosstodon.org")
}
@IBAction func followAltStoreThreads()
{
self.openThreads(username: "altstoreio")
}
@IBAction func followAltStoreTwitter()
{
self.openTwitter(username: "altstoreio")
}
@IBAction func followAltStoreGitHub()
{
let safariURL = URL(string: "https://github.com/altstoreio")!
UIApplication.shared.open(safariURL, options: [:])
}
}
private extension SettingsViewController