Skip to content

Commit c8660ee

Browse files
committed
Initial import
1 parent e24a096 commit c8660ee

File tree

156 files changed

+12995
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+12995
-1
lines changed

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Xcode
2+
#
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
20+
# CocoaPods
21+
#
22+
# We recommend against adding the Pods directory to your .gitignore. However
23+
# you should judge for yourself, the pros and cons are mentioned at:
24+
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25+
#
26+
# Pods/

Client.xcodeproj/project.pbxproj

+1,048
Large diffs are not rendered by default.

Client.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client/Application/AppDelegate.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import UIKit
6+
7+
@UIApplicationMain
8+
class AppDelegate: UIResponder, UIApplicationDelegate
9+
{
10+
var window: UIWindow!
11+
12+
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
13+
let tabBarViewController = TabBarViewController(nibName: "TabBarViewController", bundle: nil)
14+
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
15+
self.window.rootViewController = tabBarViewController
16+
self.window.backgroundColor = UIColor.whiteColor()
17+
self.window.makeKeyAndVisible()
18+
return true
19+
}
20+
}

Client/Application/LaunchScreen.xib

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
5+
</dependencies>
6+
<objects>
7+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
8+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
9+
<view contentMode="scaleToFill" id="iN0-l3-epB">
10+
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
11+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
12+
<subviews>
13+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="iPhone6-4.7" translatesAutoresizingMaskIntoConstraints="NO" id="0jH-Ya-j0m">
14+
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
15+
</imageView>
16+
</subviews>
17+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
18+
<constraints>
19+
<constraint firstItem="0jH-Ya-j0m" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="4VC-rR-S6f"/>
20+
<constraint firstAttribute="trailing" secondItem="0jH-Ya-j0m" secondAttribute="trailing" id="Ggl-Ru-uHL"/>
21+
<constraint firstItem="0jH-Ya-j0m" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="it2-zM-naU"/>
22+
<constraint firstAttribute="bottom" secondItem="0jH-Ya-j0m" secondAttribute="bottom" id="x1B-H7-cYF"/>
23+
</constraints>
24+
<nil key="simulatedStatusBarMetrics"/>
25+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
26+
<point key="canvasLocation" x="404" y="445"/>
27+
</view>
28+
</objects>
29+
<resources>
30+
<image name="iPhone6-4.7" width="750" height="1334"/>
31+
</resources>
32+
</document>
189 KB
Binary file not shown.
203 KB
Binary file not shown.
188 KB
Binary file not shown.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "29x29",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "29x29",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "40x40",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "40x40",
21+
"scale" : "3x"
22+
},
23+
{
24+
"size" : "60x60",
25+
"idiom" : "iphone",
26+
"filename" : "AppIcon-60@2x.png",
27+
"scale" : "2x"
28+
},
29+
{
30+
"size" : "60x60",
31+
"idiom" : "iphone",
32+
"filename" : "AppIcon-60@3x.png",
33+
"scale" : "3x"
34+
},
35+
{
36+
"idiom" : "ipad",
37+
"size" : "29x29",
38+
"scale" : "1x"
39+
},
40+
{
41+
"idiom" : "ipad",
42+
"size" : "29x29",
43+
"scale" : "2x"
44+
},
45+
{
46+
"idiom" : "ipad",
47+
"size" : "40x40",
48+
"scale" : "1x"
49+
},
50+
{
51+
"idiom" : "ipad",
52+
"size" : "40x40",
53+
"scale" : "2x"
54+
},
55+
{
56+
"idiom" : "ipad",
57+
"size" : "76x76",
58+
"scale" : "1x"
59+
},
60+
{
61+
"idiom" : "ipad",
62+
"size" : "76x76",
63+
"scale" : "2x"
64+
}
65+
],
66+
"info" : {
67+
"version" : 1,
68+
"author" : "xcode"
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"images" : [
3+
{
4+
"orientation" : "portrait",
5+
"idiom" : "iphone",
6+
"extent" : "full-screen",
7+
"minimum-system-version" : "7.0",
8+
"scale" : "2x"
9+
},
10+
{
11+
"orientation" : "portrait",
12+
"idiom" : "iphone",
13+
"extent" : "full-screen",
14+
"minimum-system-version" : "7.0",
15+
"subtype" : "retina4",
16+
"scale" : "2x"
17+
},
18+
{
19+
"orientation" : "portrait",
20+
"idiom" : "ipad",
21+
"extent" : "full-screen",
22+
"minimum-system-version" : "7.0",
23+
"scale" : "1x"
24+
},
25+
{
26+
"orientation" : "landscape",
27+
"idiom" : "ipad",
28+
"extent" : "full-screen",
29+
"minimum-system-version" : "7.0",
30+
"scale" : "1x"
31+
},
32+
{
33+
"orientation" : "portrait",
34+
"idiom" : "ipad",
35+
"extent" : "full-screen",
36+
"minimum-system-version" : "7.0",
37+
"scale" : "2x"
38+
},
39+
{
40+
"orientation" : "landscape",
41+
"idiom" : "ipad",
42+
"extent" : "full-screen",
43+
"minimum-system-version" : "7.0",
44+
"scale" : "2x"
45+
}
46+
],
47+
"info" : {
48+
"version" : 1,
49+
"author" : "xcode"
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "iPhone6-4.7.png"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "leaf.png"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading

Client/Client.entitlements

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.application-groups</key>
6+
<array>
7+
<string>group.Client</string>
8+
</array>
9+
<key>keychain-access-groups</key>
10+
<array>
11+
<string>$(AppIdentifierPrefix)org.mozilla.Client</string>
12+
</array>
13+
</dict>
14+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import UIKit
6+
import Alamofire
7+
8+
func createMockFavicon(icon: UIImage) -> UIImage {
9+
let size = CGSize(width: 30, height: 30)
10+
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
11+
var context = UIGraphicsGetCurrentContext()
12+
icon.drawInRect(CGRectInset(CGRect(origin: CGPointZero, size: size), 1.0, 1.0))
13+
CGContextSetStrokeColorWithColor(context, UIColor.grayColor().CGColor)
14+
CGContextSetLineWidth(context, 0.5);
15+
CGContextStrokeEllipseInRect(context, CGRectInset(CGRect(origin: CGPointZero, size: size), 1.0, 1.0))
16+
let image = UIGraphicsGetImageFromCurrentImageContext()
17+
UIGraphicsEndImageContext()
18+
return image
19+
}
20+
21+
class BookmarksViewController: UITableViewController
22+
{
23+
var bookmarksResponse: BookmarksResponse?
24+
25+
override func viewDidLoad()
26+
{
27+
super.viewDidLoad()
28+
29+
tableView.sectionFooterHeight = 0
30+
//tableView.separatorStyle = UITableViewCellSeparatorStyle.None
31+
32+
refreshControl = UIRefreshControl()
33+
refreshControl?.addTarget(self, action: "refresh", forControlEvents: UIControlEvents.ValueChanged)
34+
}
35+
36+
func reloadData() {
37+
Alamofire.request(.GET, "https://syncapi-dev.sateh.com/1.0/bookmarks/recent")
38+
.authenticate(user: "sarentz+syncapi@mozilla.com", password: "q1w2e3r4")
39+
.responseJSON { (request, response, data, error) in
40+
self.bookmarksResponse = parseBookmarksResponse(data)
41+
dispatch_async(dispatch_get_main_queue()) {
42+
self.refreshControl?.endRefreshing()
43+
self.tableView.reloadData()
44+
}
45+
}
46+
}
47+
48+
func refresh() {
49+
reloadData()
50+
}
51+
52+
override func viewDidAppear(animated: Bool) {
53+
reloadData()
54+
}
55+
56+
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
57+
return 1
58+
}
59+
60+
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
61+
if let r = bookmarksResponse {
62+
return r.bookmarks.count
63+
} else {
64+
return 0
65+
}
66+
}
67+
68+
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
69+
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: nil)
70+
71+
if let image = (UIImage(named: "leaf.png")) {
72+
cell.imageView.image = createMockFavicon(image)
73+
}
74+
75+
let bookmark = bookmarksResponse?.bookmarks[indexPath.row]
76+
77+
cell.textLabel.text = bookmark?.title
78+
cell.textLabel.font = UIFont(name: "FiraSans-SemiBold", size: 13)
79+
cell.textLabel.textColor = UIColor.darkGrayColor()
80+
cell.indentationWidth = 20
81+
82+
return cell
83+
}
84+
85+
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
86+
return 42
87+
}
88+
89+
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
90+
return 0
91+
}
92+
93+
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
94+
let objects = UINib(nibName: "TabsViewControllerHeader", bundle: nil).instantiateWithOwner(nil, options: nil)
95+
let view = objects[0] as? UIView
96+
97+
if let label = view?.viewWithTag(1) as? UILabel {
98+
label.text = "Recent Bookmarks"
99+
}
100+
101+
return view
102+
}
103+
104+
// func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
105+
// let objects = UINib(nibName: "TabsViewControllerHeader", bundle: nil).instantiateWithOwner(nil, options: nil)
106+
// if let view = objects[0] as? UIView {
107+
// if let label = view.viewWithTag(1) as? UILabel {
108+
// // TODO: More button
109+
// }
110+
// }
111+
// return view
112+
// }
113+
114+
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
115+
tableView.deselectRowAtIndexPath(indexPath, animated: false)
116+
//let bookmark = bookmarksResponse?.bookmarks[indexPath.row]
117+
//UIApplication.sharedApplication().openURL(NSURL(string: bookmark?.url!)!)
118+
}
119+
}

0 commit comments

Comments
 (0)