Browse Source

Start home timeline

pixelfed
Shadowfacts 3 years ago
parent
commit
24d30d36b7
Signed by: shadowfacts GPG Key ID: 94A5AB95422746E5
  1. 3
      .gitmodules
  2. 1
      SwiftSoup
  3. 18
      Tusker.xcodeproj/project.pbxproj
  4. 3
      Tusker.xcworkspace/contents.xcworkspacedata
  5. 5
      Tusker/Controllers/MastodonController.swift
  6. 39
      Tusker/Storyboards/Base.lproj/Main.storyboard
  7. 67
      Tusker/Storyboards/Statuses.storyboard
  8. 39
      Tusker/View Controllers/StatusesTableViewController.swift
  9. 29
      Tusker/Views/StatusTableViewCell.swift

3
.gitmodules

@ -1,3 +1,6 @@
[submodule "MastodonKit"]
path = MastodonKit
url = git://github.com/MastodonKit/MastodonKit.git
[submodule "SwiftSoup"]
path = SwiftSoup
url = git://github.com/scinfu/SwiftSoup.git

1
SwiftSoup

@ -0,0 +1 @@
Subproject commit f445c9067d28346e828e615e2b43cb07b20bca35

18
Tusker.xcodeproj/project.pbxproj

@ -7,6 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
D6BED16F212663DA00F02DA0 /* SwiftSoup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; };
D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; };
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDCF212518A000E1C4BB /* AppDelegate.swift */; };
D6D4DDD2212518A000E1C4BB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDD1212518A000E1C4BB /* ViewController.swift */; };
D6D4DDD5212518A000E1C4BB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6D4DDD3212518A000E1C4BB /* Main.storyboard */; };
@ -46,6 +49,7 @@
dstSubfolderSpec = 10;
files = (
D6F953E8212519A400CF0F2B /* MastodonKit.framework in Embed Frameworks */,
D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@ -53,6 +57,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSoup.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = "<group>"; };
D6D4DDCC212518A000E1C4BB /* Tusker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tusker.app; sourceTree = BUILT_PRODUCTS_DIR; };
D6D4DDCF212518A000E1C4BB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
D6D4DDD1212518A000E1C4BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@ -78,6 +84,7 @@
buildActionMask = 2147483647;
files = (
D6F953E7212519A400CF0F2B /* MastodonKit.framework in Frameworks */,
D6BED16F212663DA00F02DA0 /* SwiftSoup.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -98,9 +105,18 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D6BED1722126661300F02DA0 /* Views */ = {
isa = PBXGroup;
children = (
D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */,
);
path = Views;
sourceTree = "<group>";
};
D6D4DDC3212518A000E1C4BB = {
isa = PBXGroup;
children = (
D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */,
D6F953E6212519A400CF0F2B /* MastodonKit.framework */,
D6D4DDCE212518A000E1C4BB /* Tusker */,
D6D4DDE3212518A200E1C4BB /* TuskerTests */,
@ -125,6 +141,7 @@
D6D4DDCF212518A000E1C4BB /* AppDelegate.swift */,
D6F953F121251A2F00CF0F2B /* Controllers */,
D6F953E9212519B800CF0F2B /* View Controllers */,
D6BED1722126661300F02DA0 /* Views */,
D6F953EA212519BE00CF0F2B /* Storyboards */,
D6D4DDD6212518A200E1C4BB /* Assets.xcassets */,
D6D4DDD8212518A200E1C4BB /* LaunchScreen.storyboard */,
@ -311,6 +328,7 @@
buildActionMask = 2147483647;
files = (
D6F953F021251A2900CF0F2B /* MastodonController.swift in Sources */,
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */,
D6D4DDD2212518A000E1C4BB /* ViewController.swift in Sources */,
D6F953EC212519E700CF0F2B /* StatusesTableViewController.swift in Sources */,
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,

3
Tusker.xcworkspace/contents.xcworkspacedata

@ -7,4 +7,7 @@
<FileRef
location = "group:MastodonKit/MastodonKit.xcodeproj">
</FileRef>
<FileRef
location = "group:SwiftSoup/SwiftSoup.xcodeproj">
</FileRef>
</Workspace>

5
Tusker/Controllers/MastodonController.swift

@ -35,6 +35,11 @@ class MastodonController {
login()
}
client.run(Accounts.currentUser()) { result in
guard case let .success(account, _) = result else { fatalError() }
print(account.acct)
}
}
private func register(completion: @escaping () -> Void) {

39
Tusker/Storyboards/Base.lproj/Main.storyboard

@ -1,28 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="lT6-W8-WVA">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="hVq-Vu-bEj">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="Zb4-Yf-eZC">
<!--Statuses-->
<scene sceneID="OOu-1s-V6q">
<objects>
<viewController id="lT6-W8-WVA" customClass="ViewController" customModule="Tusker" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="bp8-bv-zit">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="yNt-Ic-ase"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xjF-Uf-9dh" userLabel="First Responder" sceneMemberID="firstResponder"/>
<viewControllerPlaceholder storyboardName="Statuses" id="7WZ-zC-GaE" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="qa8-hW-VHL"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="O8i-mP-ani" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-210" y="32"/>
<point key="canvasLocation" x="385" y="-206"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="ELt-Cr-gbC">
<objects>
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="hVq-Vu-bEj" sceneMemberID="viewController">
<toolbarItems/>
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="cjv-gb-Kie">
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="7WZ-zC-GaE" kind="relationship" relationship="viewControllers" id="q0Z-gP-JDT"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="1cN-fA-SM9" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-210.40000000000001" y="31.934032983508249"/>
</scene>
</scenes>
</document>

67
Tusker/Storyboards/Statuses.storyboard

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6nb-nb-cMm">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="CK3-h7-JHA">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
@ -17,13 +17,48 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="n0V-Nu-zEt">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="statusCell" rowHeight="72" id="n0V-Nu-zEt" customClass="StatusTableViewCell" customModule="Tusker" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="72"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="n0V-Nu-zEt" id="JcO-MN-o4M">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="71.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Display name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZFA-wR-9b4">
<rect key="frame" x="16" y="11" width="103" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="@Username" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ffn-MC-jPW">
<rect key="frame" x="127" y="11" width="94" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Content" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xX6-Gq-MFH">
<rect key="frame" x="16" y="40" width="343" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="xX6-Gq-MFH" firstAttribute="trailing" secondItem="JcO-MN-o4M" secondAttribute="trailingMargin" id="3uJ-2V-odU"/>
<constraint firstItem="Ffn-MC-jPW" firstAttribute="leading" secondItem="ZFA-wR-9b4" secondAttribute="trailing" constant="8" id="Az0-iw-JrZ"/>
<constraint firstItem="Ffn-MC-jPW" firstAttribute="top" secondItem="JcO-MN-o4M" secondAttribute="topMargin" id="I7N-O4-Q6U"/>
<constraint firstItem="ZFA-wR-9b4" firstAttribute="leading" secondItem="JcO-MN-o4M" secondAttribute="leadingMargin" id="OGD-sl-OQI"/>
<constraint firstItem="xX6-Gq-MFH" firstAttribute="bottom" secondItem="JcO-MN-o4M" secondAttribute="bottomMargin" id="Td8-7G-sJ7"/>
<constraint firstItem="ZFA-wR-9b4" firstAttribute="top" secondItem="JcO-MN-o4M" secondAttribute="topMargin" id="a0F-RV-jI0"/>
<constraint firstItem="xX6-Gq-MFH" firstAttribute="leading" secondItem="JcO-MN-o4M" secondAttribute="leadingMargin" id="oSD-4i-vYB"/>
<constraint firstItem="xX6-Gq-MFH" firstAttribute="top" secondItem="ZFA-wR-9b4" secondAttribute="bottom" constant="8" id="ufm-zI-r2q"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="contentLabel" destination="xX6-Gq-MFH" id="d7X-0B-daj"/>
<outlet property="displayNameLabel" destination="ZFA-wR-9b4" id="4Bg-aE-tVd"/>
<outlet property="usernameLabel" destination="Ffn-MC-jPW" id="dfo-KY-c7S"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
@ -31,10 +66,32 @@
<outlet property="delegate" destination="6nb-nb-cMm" id="Dio-U3-a5Z"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="SQS-FM-ReS"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5GO-2u-UCr" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-138" y="-90"/>
<point key="canvasLocation" x="800.79999999999995" y="-90.404797601199405"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="yNQ-ej-ymp">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="CK3-h7-JHA" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" systemItem="mostRecent" id="dzR-Qn-Pf3"/>
<toolbarItems/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="kM6-kS-XRr">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="6nb-nb-cMm" kind="relationship" relationship="rootViewController" id="Ga2-04-Wda"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2IM-IS-Cf8" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-138.40000000000001" y="-90.404797601199405"/>
</scene>
</scenes>
</document>

39
Tusker/View Controllers/StatusesTableViewController.swift

@ -7,12 +7,32 @@
//
import UIKit
import MastodonKit
import SwiftSoup
class StatusesTableViewController: UITableViewController {
var statuses: [Status] = [] {
didSet {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
override func viewWillAppear(_ animated: Bool) {
MastodonController.shared.client.run(Timelines.home()) { result in
guard case let .success(statuses, _) = result else { fatalError() }
self.statuses = statuses
}
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 140
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
@ -23,24 +43,27 @@ class StatusesTableViewController: UITableViewController {
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
return statuses.count
}
/*
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
guard let cell = tableView.dequeueReusableCell(withIdentifier: "statusCell", for: indexPath) as? StatusTableViewCell else {
fatalError()
}
let status = statuses[indexPath.row]
cell.updateUI(for: status)
return cell
}
*/
/*
// Override to support conditional editing of the table view.

29
Tusker/Views/StatusTableViewCell.swift

@ -0,0 +1,29 @@
//
// StatusTableViewCell.swift
// Tusker
//
// Created by Shadowfacts on 8/16/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
import MastodonKit
import SwiftSoup
class StatusTableViewCell: UITableViewCell {
@IBOutlet weak var displayNameLabel: UILabel!
@IBOutlet weak var usernameLabel: UILabel!
@IBOutlet weak var contentLabel: UILabel!
func updateUI(for status: Status) {
displayNameLabel.text = status.account.displayName
usernameLabel.text = "@\(status.account.acct)"
let doc = try! SwiftSoup.parse(status.content)
let text = (try! doc.body()?.text())!
contentLabel.text = text
}
}
Loading…
Cancel
Save