Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Develop #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "ishkawa/APIKit" "release/4.1.0"
github "daltoniam/Starscream" >= 3.0.6
github "ishkawa/APIKit" "5.0.0"
github "daltoniam/Starscream" >= 3.1.0
4 changes: 2 additions & 2 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Alamofire/Alamofire" ~> 4.2.0
github "AliSoftware/OHHTTPStubs" "5.2.3-swift3"
github "Alamofire/Alamofire" ~> 4.8.0
github "AliSoftware/OHHTTPStubs" ~> 8.0.0
9 changes: 4 additions & 5 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
github "Alamofire/Alamofire" "4.8.0"
github "AliSoftware/OHHTTPStubs" "5.2.3-swift3"
github "antitypical/Result" "4.0.0"
github "daltoniam/Starscream" "3.0.6"
github "ishkawa/APIKit" "22f56c457b54888ddd7a0bed27b77d0ee3eb8b78"
github "Alamofire/Alamofire" "4.8.2"
github "AliSoftware/OHHTTPStubs" "8.0.0"
github "daltoniam/Starscream" "3.1.0"
github "ishkawa/APIKit" "5.0.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Alamofire
Submodule Alamofire updated 187 files
2 changes: 1 addition & 1 deletion Carthage/Checkouts/OHHTTPStubs
Submodule OHHTTPStubs updated 101 files
5 changes: 3 additions & 2 deletions Example-OSX/Example-OSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -314,7 +315,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "Example-OSX";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -332,7 +333,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "Example-OSX";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
10 changes: 5 additions & 5 deletions Example-OSX/Example-OSX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
override func awakeFromNib() {
super.awakeFromNib()
_ = TypetalkAPI.setDeveloperSettings(
clientId: "Your ClientID",
clientSecret: "Your SecretID",
scopes: [Scope.my, Scope.topicRead], // e.g. typetalkkit://auth/success
redirectURI: "Your custome scheme")
clientId: "Your_ClientID",
clientSecret: "Your_SecretID",
scopes: [Scope.my, Scope.topicRead],
redirectURI: "Your_custome_scheme") // e.g. typetalkkit://auth/success

_ = TypetalkAPI.restoreTokenFromAccountStore()
}
Expand All @@ -32,7 +32,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

// MARK - handleURL

func handleGetURLEvent(_ event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
@objc func handleGetURLEvent(_ event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
if let ev = event,
let url_str = ev.forKeyword(AEKeyword(keyDirectObject))?.stringValue,
let url = URL(string: url_str), TypetalkAPI.isRedirectURL(url) {
Expand Down
8 changes: 4 additions & 4 deletions Example-OSX/Example-OSX/MessageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ class MessageViewController: NSViewController, NSTableViewDelegate, NSTableViewD
}

func tableView(_ tableView: NSTableView, viewFor viewForTableColumn: NSTableColumn?, row: Int) -> NSView? {
let cell = tableView.make(withIdentifier: "MessageCell", owner: nil) as! MessageCell
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "MessageCell"), owner: nil) as! MessageCell
cell.model = messages!.posts[row]
return cell
}

func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
/*func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
let font = NSFont(name: "Helvetica", size: 13)!
let attr: [String:AnyObject] = [NSFontAttributeName: font]
let attr: [String:AnyObject] = [NSAttributedString.Key.font.rawValue: font]
let mes = messages!.posts[row].message

let size = (mes as NSString).size(withAttributes: attr)

return max(size.height + 32, 56)
}
}*/
}
4 changes: 2 additions & 2 deletions Example-OSX/Example-OSX/TopicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TopicViewController: NSViewController, NSTableViewDelegate, NSTableViewDat
if topics.count <= sender.selectedRow { return }

let topic = topics[sender.selectedRow]
let controller = self.parent?.childViewControllers[1] as! MessageViewController
let controller = self.parent?.children[1] as! MessageViewController
controller.detailItem = topic
}

Expand All @@ -128,7 +128,7 @@ class TopicViewController: NSViewController, NSTableViewDelegate, NSTableViewDat
}

func tableView(_ tableView: NSTableView, viewFor viewForTableColumn: NSTableColumn?, row: Int) -> NSView? {
let cell = tableView.make(withIdentifier: "TopicCell", owner: nil) as! NSTableCellView
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "TopicCell"), owner: nil) as! NSTableCellView
cell.textField?.stringValue = topics[row].topic.name
return cell
}
Expand Down
5 changes: 3 additions & 2 deletions Example-iOS/Example-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -330,7 +331,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "Example-iOS";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -347,7 +348,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "Example-iOS";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
10 changes: 5 additions & 5 deletions Example-iOS/Example-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
//navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
Expand All @@ -24,18 +24,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
_ = TypetalkAPI.setDeveloperSettings(
clientId: "Your ClientID",
clientSecret: "Your SecretID",
scopes: [Scope.my, Scope.topicRead], // e.g. typetalkkit://auth/success
redirectURI: "Your custome scheme")
scopes: [Scope.my, Scope.topicRead],
redirectURI: "Your custome scheme") // e.g. typetalkkit://auth/success

_ = TypetalkAPI.restoreTokenFromAccountStore()

return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if TypetalkAPI.isRedirectURL(url) {
if #available(iOS 9.0, *) {
if let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?, sourceApplication == "com.apple.mobilesafari" {
if let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?, sourceApplication == "com.apple.mobilesafari" {
return TypetalkAPI.authorizationDone(URL: url)
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions Example-iOS/Example-iOS/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DetailViewController: UITableViewController {
super.viewDidLoad()

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension

self.title = detailItem?.topic.name
getMessages()
Expand All @@ -28,7 +28,7 @@ class DetailViewController: UITableViewController {
case .connected : print("connected")
case .disconnected(let err) : print("disconnected: \(String(describing: err))")
case .postMessage(let res) :
self.append(newPost: res.post!)
self.append(newPost: res.post)
DispatchQueue.main.async { () -> Void in
weakTableView?.reloadData()
}
Expand All @@ -44,7 +44,7 @@ class DetailViewController: UITableViewController {
TypetalkAPI.send(GetMessages(topicId: topicid)) { result -> Void in
switch result {
case .success(let ms):
self.posts = ms.posts!
self.posts = ms.posts
self.tableView.reloadData()
case .failure(let error):
print(error)
Expand Down
39 changes: 37 additions & 2 deletions Example-iOS/Example-iOS/MasterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,45 @@ class MasterViewController: UITableViewController {
fetchData()
}

fileprivate func fetchData() {
func fetchData() {
fetchSpace()
}

func fetchSpace() {
if TypetalkAPI.isSignedIn {
TypetalkAPI.send(GetSpaces()) { result in
switch result {
case .success(let ss):
guard let mySpace = ss.mySpaces.last else { return }
self.fetchTopic(spaceKey: mySpace.space.key)
case .failure(let error):
print(error)
_ = TypetalkAPI.requestRefreshToken { (err) -> Void in
if err == nil {
self.fetchData()
} else {
TypetalkAPI.authorize { (error) -> Void in
if (error == nil) {
self.fetchData()
}
}
}
}
}
}
} else {
TypetalkAPI.authorize { (error) -> Void in
if (error == nil) {
self.fetchData()
}
}
}
}

fileprivate func fetchTopic(spaceKey: String) {

if TypetalkAPI.isSignedIn {
TypetalkAPI.send(GetTopics()) { result in
TypetalkAPI.send(GetTopics(spaceKey: spaceKey)) { result in
switch result {
case .success(let ts):
self.topics = ts.topics
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TypetalkKit is an unofficial web API client for Typetalk.
The following code gets user's topics and prints these.

```swift
TypetalkAPI.sendRequest(GetTopics()) { result in
TypetalkAPI.sendRequest(GetTopics(spaceKey: spaceKey)) { result in
switch result {
case .Success(let ts):
for i in ts {
Expand Down
33 changes: 15 additions & 18 deletions TypetalkKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -999,19 +999,19 @@
};
8D9D18471A77D54200E3BCCF = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
8D9D18511A77D54200E3BCCF = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
8DBA516719C5B47300BD88A3 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0900;
LastSwiftMigration = "";
};
8DBA517219C5B47400BD88A3 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
};
};
Expand All @@ -1020,6 +1020,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 8DBA515E19C5B47300BD88A3;
Expand Down Expand Up @@ -1464,7 +1465,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1477,7 +1478,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -1506,7 +1507,7 @@
PRODUCT_NAME = TypetalkKit;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1532,7 +1533,7 @@
PRODUCT_NAME = TypetalkKit;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -1557,7 +1558,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1578,7 +1579,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -1709,8 +1710,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TypetalkKit;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1733,8 +1733,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TypetalkKit;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1754,8 +1753,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1771,8 +1769,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.blogspot.safx-dev.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down