-
Notifications
You must be signed in to change notification settings - Fork 10
Basic iOS widget. r=francisco #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b292116
7d5c374
f8b4302
75f7f65
d06d0db
c82d164
f3fbf56
631c753
c8be57c
3d93deb
eb8ef78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,3 +44,6 @@ android/keystores/debug.keystore | |
|
|
||
| # Carthage | ||
| ios/Carthage/ | ||
|
|
||
| #Cocoapods | ||
| ios/Pods/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| github "hkellaway/Gloss" "0.7.4" | ||
| github "stephencelis/SQLite.swift" "0.10.1" | ||
| github "mozilla-magnet/magnet-scanner-ios" "0.1.2" |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Yeo-Tx-QDY"> | ||
| <dependencies> | ||
| <deployment identifier="iOS"/> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> | ||
| </dependencies> | ||
| <scenes> | ||
| <!--Magnet Widget Table View Controller--> | ||
| <scene sceneID="sxy-ih-aCc"> | ||
| <objects> | ||
| <tableViewController id="Yeo-Tx-QDY" customClass="MagnetWidgetTableViewController" customModule="MagnetWidget" customModuleProvider="target" sceneMemberID="viewController"> | ||
| <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="yza-9t-0U8"> | ||
| <rect key="frame" x="0.0" y="0.0" width="320" height="200"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
| <prototypes> | ||
| <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="MagnetCell" id="ypu-i4-M1Z" customClass="MagnetWidgetTableViewCell" customModule="MagnetWidget" customModuleProvider="target"> | ||
| <rect key="frame" x="0.0" y="28" width="320" height="44"/> | ||
| <autoresizingMask key="autoresizingMask"/> | ||
| <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ypu-i4-M1Z" id="owG-n7-DVW"> | ||
| <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/> | ||
| <autoresizingMask key="autoresizingMask"/> | ||
| <subviews> | ||
| <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8pn-Lq-5W0" userLabel="titleLabel"> | ||
| <rect key="frame" x="17" y="0.0" width="295" height="21"/> | ||
| <fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
| <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | ||
| <nil key="highlightedColor"/> | ||
| </label> | ||
| <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kXk-pr-mab" userLabel="urlLabel"> | ||
| <rect key="frame" x="17" y="22" width="295" height="21"/> | ||
| <fontDescription key="fontDescription" type="system" pointSize="12"/> | ||
| <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> | ||
| <nil key="highlightedColor"/> | ||
| </label> | ||
| </subviews> | ||
| </tableViewCellContentView> | ||
| <connections> | ||
| <outlet property="titleLabel" destination="8pn-Lq-5W0" id="qXt-n7-bWK"/> | ||
| <outlet property="urlLabel" destination="kXk-pr-mab" id="DUC-RS-E5c"/> | ||
| </connections> | ||
| </tableViewCell> | ||
| </prototypes> | ||
| <connections> | ||
| <outlet property="dataSource" destination="Yeo-Tx-QDY" id="hmd-hj-k2T"/> | ||
| <outlet property="delegate" destination="Yeo-Tx-QDY" id="OP7-eP-am5"/> | ||
| </connections> | ||
| </tableView> | ||
| <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
| <size key="freeformSize" width="320" height="200"/> | ||
| <connections> | ||
| <outlet property="table" destination="yza-9t-0U8" id="0UB-0n-2ug"/> | ||
| </connections> | ||
| </tableViewController> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="BSQ-af-ra7" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
| </objects> | ||
| <point key="canvasLocation" x="558" y="431"/> | ||
| </scene> | ||
| </scenes> | ||
| </document> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleDisplayName</key> | ||
| <string>Magnet</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>XPC!</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| <key>NSExtension</key> | ||
| <dict> | ||
| <key>NSExtensionMainStoryboard</key> | ||
| <string>MainInterface</string> | ||
| <key>NSExtensionPointIdentifier</key> | ||
| <string>com.apple.widget-extension</string> | ||
| </dict> | ||
| </dict> | ||
| </plist> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import Foundation | ||
| import SwiftSerializer | ||
|
|
||
| class MagnetObject: Serializable { | ||
| var url: String; | ||
|
|
||
| init(url: String) { | ||
| self.url = url; | ||
| } | ||
| } | ||
|
|
||
| class MagnetRequest: Serializable { | ||
| var objects: Array<MagnetObject>; | ||
|
|
||
| init(objects: Array<MagnetObject>) { | ||
| self.objects = objects; | ||
| } | ||
| } | ||
|
|
||
| class MagnetMetadataClient: NSObject { | ||
| let metadataServerUrl: NSURL = NSURL(string: "https://tengam.org/api/v1/metadata")!; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool ;) |
||
| var onMetadata: (([String:AnyObject]) -> Void)!; | ||
|
|
||
| init(onMetadata: ([String:AnyObject]) -> Void) { | ||
| super.init(); | ||
| self.onMetadata = onMetadata; | ||
| } | ||
|
|
||
| func requestMetadata(url: String) { | ||
| let request = NSMutableURLRequest(URL: metadataServerUrl); | ||
| request.HTTPMethod = "POST"; | ||
| request.setValue("application/json", forHTTPHeaderField: "Content-Type"); | ||
|
|
||
| // Serialize request body. | ||
| let magnetUrl = MagnetObject(url: url); | ||
| var magnetObjects = [MagnetObject](); | ||
| magnetObjects.append(magnetUrl); | ||
| debugPrint("url", magnetUrl.toJsonString()!); | ||
|
|
||
| let body = MagnetRequest(objects: magnetObjects); | ||
| debugPrint("request", body.toJsonString()!); | ||
|
|
||
| request.HTTPBody = body.toJson(); | ||
|
|
||
| let config = NSURLSessionConfiguration.defaultSessionConfiguration(); | ||
| let session = NSURLSession(configuration: config); | ||
| let task = session.dataTaskWithRequest(request, completionHandler: { | ||
| (data, response, error) in | ||
| guard error == nil else { | ||
| print("Error: metadata server error", error); | ||
| return; | ||
| } | ||
| guard let responseData = data else { | ||
| print("Error: did not receive data from metadata server"); | ||
| return; | ||
| } | ||
| do { | ||
| guard let metadata = | ||
| try NSJSONSerialization.JSONObjectWithData(responseData, options: .AllowFragments) | ||
| as? [[String:AnyObject]] else { | ||
| print("Error: JSON parse error. Crap"); | ||
| return; | ||
| } | ||
| self.onMetadata(metadata[0]); | ||
|
|
||
| } catch { | ||
| print("Error: JSON parse error"); | ||
| } | ||
| }); | ||
| task.resume(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import Foundation | ||
| import MagnetScannerIOS | ||
|
|
||
| class MagnetScanner: NSObject { | ||
| var scanner: MagnetScannerIOS.MagnetScanner!; | ||
| var callback: ((Dictionary<String, AnyObject>) -> Void)! | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to save an instance of the callback? |
||
|
|
||
| init(callback: (Dictionary<String, AnyObject>) -> Void) { | ||
| super.init(); | ||
| scanner = MagnetScannerIOS.MagnetScanner(callback: callback); | ||
| } | ||
|
|
||
| func start() { | ||
| scanner.start(); | ||
| } | ||
|
|
||
| func stop() { | ||
| scanner.stop(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // Generated by Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31) | ||
| #pragma clang diagnostic push | ||
|
|
||
| #if defined(__has_include) && __has_include(<swift/objc-prologue.h>) | ||
| # include <swift/objc-prologue.h> | ||
| #endif | ||
|
|
||
| #pragma clang diagnostic ignored "-Wauto-import" | ||
| #include <objc/NSObject.h> | ||
| #include <stdint.h> | ||
| #include <stddef.h> | ||
| #include <stdbool.h> | ||
|
|
||
| #if !defined(SWIFT_TYPEDEFS) | ||
| # define SWIFT_TYPEDEFS 1 | ||
| # if defined(__has_include) && __has_include(<uchar.h>) | ||
| # include <uchar.h> | ||
| # elif !defined(__cplusplus) || __cplusplus < 201103L | ||
| typedef uint_least16_t char16_t; | ||
| typedef uint_least32_t char32_t; | ||
| # endif | ||
| typedef float swift_float2 __attribute__((__ext_vector_type__(2))); | ||
| typedef float swift_float3 __attribute__((__ext_vector_type__(3))); | ||
| typedef float swift_float4 __attribute__((__ext_vector_type__(4))); | ||
| typedef double swift_double2 __attribute__((__ext_vector_type__(2))); | ||
| typedef double swift_double3 __attribute__((__ext_vector_type__(3))); | ||
| typedef double swift_double4 __attribute__((__ext_vector_type__(4))); | ||
| typedef int swift_int2 __attribute__((__ext_vector_type__(2))); | ||
| typedef int swift_int3 __attribute__((__ext_vector_type__(3))); | ||
| typedef int swift_int4 __attribute__((__ext_vector_type__(4))); | ||
| #endif | ||
|
|
||
| #if !defined(SWIFT_PASTE) | ||
| # define SWIFT_PASTE_HELPER(x, y) x##y | ||
| # define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) | ||
| #endif | ||
| #if !defined(SWIFT_METATYPE) | ||
| # define SWIFT_METATYPE(X) Class | ||
| #endif | ||
|
|
||
| #if defined(__has_attribute) && __has_attribute(objc_runtime_name) | ||
| # define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X))) | ||
| #else | ||
| # define SWIFT_RUNTIME_NAME(X) | ||
| #endif | ||
| #if defined(__has_attribute) && __has_attribute(swift_name) | ||
| # define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X))) | ||
| #else | ||
| # define SWIFT_COMPILE_NAME(X) | ||
| #endif | ||
| #if !defined(SWIFT_CLASS_EXTRA) | ||
| # define SWIFT_CLASS_EXTRA | ||
| #endif | ||
| #if !defined(SWIFT_PROTOCOL_EXTRA) | ||
| # define SWIFT_PROTOCOL_EXTRA | ||
| #endif | ||
| #if !defined(SWIFT_ENUM_EXTRA) | ||
| # define SWIFT_ENUM_EXTRA | ||
| #endif | ||
| #if !defined(SWIFT_CLASS) | ||
| # if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted) | ||
| # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA | ||
| # define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA | ||
| # else | ||
| # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA | ||
| # define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA | ||
| # endif | ||
| #endif | ||
|
|
||
| #if !defined(SWIFT_PROTOCOL) | ||
| # define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA | ||
| # define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA | ||
| #endif | ||
|
|
||
| #if !defined(SWIFT_EXTENSION) | ||
| # define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__) | ||
| #endif | ||
|
|
||
| #if !defined(OBJC_DESIGNATED_INITIALIZER) | ||
| # if defined(__has_attribute) && __has_attribute(objc_designated_initializer) | ||
| # define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) | ||
| # else | ||
| # define OBJC_DESIGNATED_INITIALIZER | ||
| # endif | ||
| #endif | ||
| #if !defined(SWIFT_ENUM) | ||
| # define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type | ||
| # if defined(__has_feature) && __has_feature(generalized_swift_name) | ||
| # define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_EXTRA _name : _type | ||
| # else | ||
| # define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) SWIFT_ENUM(_type, _name) | ||
| # endif | ||
| #endif | ||
| #if defined(__has_feature) && __has_feature(modules) | ||
| #endif | ||
|
|
||
| #pragma clang diagnostic ignored "-Wproperty-attribute-mismatch" | ||
| #pragma clang diagnostic ignored "-Wduplicate-method-arg" | ||
| #pragma clang diagnostic pop |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #import <UIKit/UIKit.h> | ||
|
|
||
| //! Project version number for MagnetScannerIOS. | ||
| FOUNDATION_EXPORT double MagnetScannerIOSVersionNumber; | ||
|
|
||
| //! Project version string for MagnetScannerIOS. | ||
| FOUNDATION_EXPORT const unsigned char MagnetScannerIOSVersionString[]; | ||
|
|
||
| // In this header, you should import all the public headers of your framework using statements like #import <MagnetScannerIOS/PublicHeader.h> | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| framework module MagnetScannerIOS { | ||
| umbrella header "MagnetScannerIOS.h" | ||
|
|
||
| export * | ||
| module * { export * } | ||
| } | ||
|
|
||
| module MagnetScannerIOS.Swift { | ||
| header "MagnetScannerIOS-Swift.h" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // | ||
| // Use this file to import your target's public headers that you would like to expose to Swift. | ||
| // | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import UIKit | ||
|
|
||
| class MagnetWidgetTableViewCell: UITableViewCell { | ||
| @IBOutlet weak var titleLabel: UILabel! | ||
| @IBOutlet weak var urlLabel: UILabel! | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change it to 'Project Magnet'