refactor code, and update user home scene

This commit is contained in:
ylzheng
2015-09-25 09:17:46 +08:00
parent 85978bcc8c
commit 99edb3f34b
17 changed files with 195 additions and 58 deletions
+131 -12
View File
@@ -138,32 +138,146 @@
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rID-rz-Ikg">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="cafeloisl" translatesAutoresizingMaskIntoConstraints="NO" id="yIh-xg-eKG">
<rect key="frame" x="0.0" y="0.0" width="600" height="230"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="profile" translatesAutoresizingMaskIntoConstraints="NO" id="yIh-xg-eKG">
<rect key="frame" x="0.0" y="0.0" width="600" height="200"/>
<constraints>
<constraint firstAttribute="height" constant="230" id="lVM-Oo-ZsF"/>
<constraint firstAttribute="height" constant="200" id="lVM-Oo-ZsF"/>
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Java" translatesAutoresizingMaskIntoConstraints="NO" id="G5f-iX-fst">
<rect key="frame" x="284" y="192" width="32" height="32"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="MenuBackground" translatesAutoresizingMaskIntoConstraints="NO" id="Lbq-HZ-5wb">
<rect key="frame" x="270" y="83" width="60" height="60"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="9DG-Uh-cYa"/>
<constraint firstAttribute="height" constant="60" id="UTr-2j-yNW"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="15"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" red="0.86909019990000003" green="0.87904130650000001" blue="0.8443919781" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fzw-w9-kdk">
<rect key="frame" x="148" y="200" width="100" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vyf-L7-jNr">
<rect key="frame" x="35" y="0.0" width="30" height="30"/>
<state key="normal" title="分享">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" red="0.85977454730000002" green="0.85977454730000002" blue="0.85977454730000002" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="bottomBorderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="bottomBorderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JE5-AB-F9o">
<rect key="frame" x="250" y="200" width="100" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J9I-re-993">
<rect key="frame" x="35" y="0.0" width="30" height="30"/>
<state key="normal" title="喜欢">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="Yf3-aH-gNj"/>
<constraint firstAttribute="height" constant="30" id="y6e-TR-mAW"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="bottomBorderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MqB-lq-Lgm">
<rect key="frame" x="351" y="200" width="100" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lm0-dM-xa3">
<rect key="frame" x="35" y="0.0" width="30" height="30"/>
<state key="normal" title="收藏">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="bottomBorderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<constraints>
<constraint firstAttribute="centerX" secondItem="G5f-iX-fst" secondAttribute="centerX" id="2tM-K1-H0j"/>
<constraint firstAttribute="centerX" secondItem="yIh-xg-eKG" secondAttribute="centerX" id="2Hf-Nw-YU2"/>
<constraint firstAttribute="width" secondItem="yIh-xg-eKG" secondAttribute="width" id="7Ni-RC-xNJ"/>
<constraint firstAttribute="height" constant="600" id="7nl-um-KpN"/>
<constraint firstAttribute="bottom" secondItem="yIh-xg-eKG" secondAttribute="bottom" constant="370" id="9L0-St-z8R"/>
<constraint firstItem="G5f-iX-fst" firstAttribute="top" secondItem="yIh-xg-eKG" secondAttribute="bottom" constant="-38" id="FEw-2z-cSV"/>
<constraint firstItem="Lbq-HZ-5wb" firstAttribute="top" secondItem="rID-rz-Ikg" secondAttribute="top" constant="83" id="8fD-AM-3HN"/>
<constraint firstAttribute="bottom" secondItem="yIh-xg-eKG" secondAttribute="bottom" constant="400" id="9L0-St-z8R"/>
<constraint firstItem="MqB-lq-Lgm" firstAttribute="width" secondItem="JE5-AB-F9o" secondAttribute="width" id="9fz-UV-Lcj"/>
<constraint firstAttribute="centerX" secondItem="JE5-AB-F9o" secondAttribute="centerX" constant="25" id="Jy5-Mr-CgN"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="top" secondItem="fzw-w9-kdk" secondAttribute="top" id="Koe-Vf-AuM"/>
<constraint firstItem="yIh-xg-eKG" firstAttribute="leading" secondItem="rID-rz-Ikg" secondAttribute="leading" id="LBg-us-noG"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="leading" secondItem="fzw-w9-kdk" secondAttribute="trailing" constant="2" id="Nbo-HI-8Pb"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="top" secondItem="MqB-lq-Lgm" secondAttribute="top" id="Q0Y-wa-ekJ"/>
<constraint firstAttribute="width" constant="600" id="QFx-AC-Ggk"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="leading" secondItem="fzw-w9-kdk" secondAttribute="trailing" constant="2" id="QmL-GB-16L"/>
<constraint firstItem="MqB-lq-Lgm" firstAttribute="leading" secondItem="JE5-AB-F9o" secondAttribute="trailing" constant="1" id="TON-xO-KQq"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="bottom" secondItem="MqB-lq-Lgm" secondAttribute="bottom" id="Yn8-L8-Pq1"/>
<constraint firstItem="MqB-lq-Lgm" firstAttribute="leading" secondItem="JE5-AB-F9o" secondAttribute="trailing" constant="1" id="ZHF-Wg-9Jo"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="bottom" secondItem="fzw-w9-kdk" secondAttribute="bottom" id="dzS-Z0-nsW"/>
<constraint firstAttribute="trailing" secondItem="yIh-xg-eKG" secondAttribute="trailing" id="fAq-oH-fX3"/>
<constraint firstItem="G5f-iX-fst" firstAttribute="centerX" secondItem="yIh-xg-eKG" secondAttribute="centerX" id="o9W-vM-hzo"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="width" secondItem="fzw-w9-kdk" secondAttribute="width" id="gsJ-21-9GR"/>
<constraint firstAttribute="centerX" secondItem="JE5-AB-F9o" secondAttribute="centerX" id="jFX-iW-OOh"/>
<constraint firstAttribute="centerX" secondItem="Lbq-HZ-5wb" secondAttribute="centerX" id="nVv-t1-POA"/>
<constraint firstItem="yIh-xg-eKG" firstAttribute="top" secondItem="rID-rz-Ikg" secondAttribute="top" id="v4L-cf-1kL"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="leading" secondItem="fzw-w9-kdk" secondAttribute="trailing" constant="2" id="vHY-Ot-foO"/>
<constraint firstItem="JE5-AB-F9o" firstAttribute="top" secondItem="Lbq-HZ-5wb" secondAttribute="bottom" constant="57" id="ypM-TM-2dP"/>
<constraint firstItem="MqB-lq-Lgm" firstAttribute="leading" secondItem="JE5-AB-F9o" secondAttribute="trailing" constant="1" id="ypm-S9-WMZ"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="Jy5-Mr-CgN"/>
</mask>
</variation>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="rID-rz-Ikg" firstAttribute="width" secondItem="x3M-rz-jsn" secondAttribute="width" id="GGr-N2-UJ6"/>
<constraint firstItem="rID-rz-Ikg" firstAttribute="leading" secondItem="x3M-rz-jsn" secondAttribute="leading" id="Rqq-36-ESv"/>
<constraint firstItem="rID-rz-Ikg" firstAttribute="top" secondItem="x3M-rz-jsn" secondAttribute="top" id="vOv-ia-Rrs"/>
</constraints>
@@ -171,6 +285,11 @@
<navigationItem key="navigationItem" title="个人中心" id="aqp-9i-WAE">
<barButtonItem key="rightBarButtonItem" id="8hk-iR-75v"/>
</navigationItem>
<connections>
<outlet property="likeUIView" destination="JE5-AB-F9o" id="XUM-YT-7cD"/>
<outlet property="markUIView" destination="MqB-lq-Lgm" id="hQZ-L7-H3U"/>
<outlet property="shareUIView" destination="fzw-w9-kdk" id="3t4-qK-9lF"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="JVC-mx-K4x" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
@@ -559,7 +678,7 @@
<!--首页Navigation-->
<scene sceneID="w2o-3B-jX7">
<objects>
<navigationController storyboardIdentifier="NavigationStoriesTableViewController" title="首页Navigation" automaticallyAdjustsScrollViewInsets="NO" id="9YB-h9-56i" sceneMemberID="viewController">
<navigationController storyboardIdentifier="NavigationStoriesTableViewController" title="首页Navigation" automaticallyAdjustsScrollViewInsets="NO" modalTransitionStyle="crossDissolve" id="9YB-h9-56i" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="信息流" image="Home" id="ryG-68-tYE"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="wKr-iH-tOr">
@@ -1005,11 +1124,11 @@
<image name="Back" width="32" height="32"/>
<image name="Camera" width="100" height="100"/>
<image name="Home" width="32" height="32"/>
<image name="Java" width="32" height="32"/>
<image name="Lightning" width="32" height="32"/>
<image name="Like" width="32" height="32"/>
<image name="LikeEmpty" width="32" height="32"/>
<image name="Menu" width="22" height="22"/>
<image name="MenuBackground" width="520" height="768"/>
<image name="Plus" width="32" height="32"/>
<image name="Python" width="32" height="32"/>
<image name="UploadCloud" width="32" height="32"/>
@@ -1017,8 +1136,8 @@
<image name="Visible" width="32" height="32"/>
<image name="action-comment" width="26" height="23"/>
<image name="action-share" width="19" height="27"/>
<image name="cafeloisl" width="640" height="640"/>
<image name="icon-close" width="19" height="20"/>
<image name="profile" width="146" height="220"/>
<image name="royaloak" width="640" height="640"/>
</resources>
</document>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 B

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 816 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

+21
View File
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "profile.jpg"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

+16 -45
View File
@@ -16,7 +16,6 @@ import JWT
struct LibrxService {
private static let baseURL = "http://uat.librme.com"
// private static let baseURL = "http://localhost:3000"
private static let defaultThumail = "http://7pn5d3.com1.z0.glb.clouddn.com/9050353.png"
@@ -64,12 +63,7 @@ struct LibrxService {
static func loadExplore(response: ([Explore]) -> ()) {
let urlString = baseURL + ResourcePath.Explore.description
let token:String = LocalStore.accessToken()!
var headers:[String: String] = [
"Authorization": "Bear \(token)"
]
let headers: [String:String] = buildHttpRequestHeader()
Alamofire.request(.GET, urlString, headers: headers).response{
@@ -84,21 +78,14 @@ struct LibrxService {
response(explores)
}
}
static func postsForTop(page: Int, keyword: String? = nil, response: ([Post]) -> ()) {
let urlString = baseURL + ResourcePath.Top.description
var token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
var headers:[String: String] = [
"Authorization": "Bear \(token)"
]
let headers: [String:String] = buildHttpRequestHeader()
loadPostsByUrl(urlString, headers: headers, response: response)
@@ -108,12 +95,7 @@ struct LibrxService {
static func postsForIndex(page: Int, keyword: String? = nil, response: ([Post]) -> ()){
let urlString = baseURL + ResourcePath.Posts.description
var token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
var headers: [String:String] = [
"Authorization": "Bear \(token)"
]
let headers: [String:String] = buildHttpRequestHeader()
loadPostsByUrl(urlString, headers: headers, response: response)
@@ -172,19 +154,11 @@ struct LibrxService {
}
}
static func likePost(postId: Int) {
let urlString = baseURL + ResourcePath.LikePost(postId: postId).description
var token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
var headers:[String: String] = [
"Authorization": "Bear \(token)"
]
toggleLikeOfPost(postId, urlString: urlString)
@@ -193,20 +167,14 @@ struct LibrxService {
static func unlikePost(postId: Int) {
let urlString = baseURL + ResourcePath.UnLikePost(postId: postId).description
toggleLikeOfPost(postId, urlString: urlString)
toggleLikeOfPost(postId, urlString: urlString)
}
static func toggleLikeOfPost(postId: Int, urlString: String) {
let urlString = baseURL + ResourcePath.UnLikePost(postId: postId).description
var token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
var headers:[String: String] = [
"Authorization": "Bear \(token)"
]
let headers: [String:String] = buildHttpRequestHeader()
Alamofire.request(.GET, urlString, headers: headers)
@@ -222,14 +190,9 @@ struct LibrxService {
static func createPost(post: Post, response: (Post) -> ()){
let urlString = baseURL + ResourcePath.Posts.description
let headers: [String:String] = buildHttpRequestHeader()
var token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
var headers: [String:String] = [
"Authorization": "Bear \(token)"
]
var parameters: [String: AnyObject] = [
let parameters: [String: AnyObject] = [
"url": post.url,
"type": post.type,
"description": ""
@@ -245,6 +208,14 @@ struct LibrxService {
}
static func buildHttpRequestHeader() -> ([String: String]) {
let token = (LocalStore.accessToken() != nil) ? LocalStore.accessToken()! : ""
let headers: [String:String] = [
"Authorization": "Bear \(token)"
]
return headers
}
}
+20 -1
View File
@@ -10,9 +10,28 @@ import UIKit
class ProfileViewController: UIViewController {
@IBOutlet weak var shareUIView: UIView!
@IBOutlet weak var likeUIView: UIView!
@IBOutlet weak var markUIView: UIView!
private var screenSize: CGRect!
private var screenWidth: CGFloat!
private var screenHeight: CGFloat!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1)
}
screenSize = UIScreen.mainScreen().bounds
screenWidth = screenSize.width
screenHeight = screenSize.height
self.shareUIView.frame.size.width = screenWidth / 3
self.likeUIView.frame.size.width = screenWidth / 3
self.markUIView.frame.size.width = screenWidth / 3
}
}
+7
View File
@@ -32,6 +32,9 @@ class WebViewController: UIViewController, UIWebViewDelegate, UIScrollViewDelega
navigationController?.navigationBar.hidden=false
navigationController?.navigationBar.backgroundColor = UIColor.clearColor()
navigationController?.navigationBar.tintColor = UIColor.clearColor()
navigationController?.navigationBar.backItem?.hidesBackButton = true
self.title = self.post.title
}
@@ -58,6 +61,10 @@ class WebViewController: UIViewController, UIWebViewDelegate, UIScrollViewDelega
self.presentViewController(alert, animated: true, completion: nil)
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent;
}
@IBAction func backButtonDidTouch(sender: AnyObject) {
webView.goBack()
}