Skip to content

Commit

Permalink
new ParkDataModel and add getParkList method at it
Browse files Browse the repository at this point in the history
refine APIManager, add method convertToQueries
new ParkTableViewCell and set its layout
setup TableView in ViewController and connect with API
implement load more in ViewController
refine load more user experience
  • Loading branch information
YutaLin committed Jul 6, 2017
1 parent c7d4fa2 commit 7952510
Show file tree
Hide file tree
Showing 13 changed files with 378 additions and 17 deletions.
37 changes: 35 additions & 2 deletions TaipeiPark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
objects = {

/* Begin PBXBuildFile section */
5572C52F1F0E994A00F71BDE /* ParkTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5572C52D1F0E994A00F71BDE /* ParkTableViewCell.m */; };
5572C5301F0E994A00F71BDE /* ParkTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5572C52E1F0E994A00F71BDE /* ParkTableViewCell.xib */; };
55A49E4B1F0E80170090C28C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A49E4A1F0E80170090C28C /* main.m */; };
55A49E4E1F0E80170090C28C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A49E4D1F0E80170090C28C /* AppDelegate.m */; };
55A49E511F0E80170090C28C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A49E501F0E80170090C28C /* ViewController.m */; };
55A49E541F0E80170090C28C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55A49E521F0E80170090C28C /* Main.storyboard */; };
55A49E561F0E80170090C28C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55A49E551F0E80170090C28C /* Assets.xcassets */; };
55A49E591F0E80170090C28C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55A49E571F0E80170090C28C /* LaunchScreen.storyboard */; };
55A49E631F0E80450090C28C /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A49E621F0E80450090C28C /* APIManager.m */; };
55A49E681F0E86520090C28C /* ParkDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A49E671F0E86520090C28C /* ParkDataModel.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
5572C52C1F0E994A00F71BDE /* ParkTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ParkTableViewCell.h; path = Cell/ParkTableViewCell.h; sourceTree = "<group>"; };
5572C52D1F0E994A00F71BDE /* ParkTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ParkTableViewCell.m; path = Cell/ParkTableViewCell.m; sourceTree = "<group>"; };
5572C52E1F0E994A00F71BDE /* ParkTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ParkTableViewCell.xib; path = Cell/ParkTableViewCell.xib; sourceTree = "<group>"; };
55A49E461F0E80170090C28C /* TaipeiPark.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TaipeiPark.app; sourceTree = BUILT_PRODUCTS_DIR; };
55A49E4A1F0E80170090C28C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
55A49E4C1F0E80170090C28C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand All @@ -29,6 +35,8 @@
55A49E5A1F0E80170090C28C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
55A49E611F0E80450090C28C /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APIManager.h; path = Manager/APIManager.h; sourceTree = "<group>"; };
55A49E621F0E80450090C28C /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = APIManager.m; path = Manager/APIManager.m; sourceTree = "<group>"; };
55A49E661F0E86520090C28C /* ParkDataModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ParkDataModel.h; path = Model/ParkDataModel.h; sourceTree = "<group>"; };
55A49E671F0E86520090C28C /* ParkDataModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ParkDataModel.m; path = Model/ParkDataModel.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -42,6 +50,25 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5572C52A1F0E992700F71BDE /* ViewController */ = {
isa = PBXGroup;
children = (
55A49E4F1F0E80170090C28C /* ViewController.h */,
55A49E501F0E80170090C28C /* ViewController.m */,
);
name = ViewController;
sourceTree = "<group>";
};
5572C52B1F0E993200F71BDE /* Cell */ = {
isa = PBXGroup;
children = (
5572C52C1F0E994A00F71BDE /* ParkTableViewCell.h */,
5572C52D1F0E994A00F71BDE /* ParkTableViewCell.m */,
5572C52E1F0E994A00F71BDE /* ParkTableViewCell.xib */,
);
name = Cell;
sourceTree = "<group>";
};
55A49E3D1F0E80170090C28C = {
isa = PBXGroup;
children = (
Expand All @@ -61,12 +88,12 @@
55A49E481F0E80170090C28C /* TaipeiPark */ = {
isa = PBXGroup;
children = (
5572C52B1F0E993200F71BDE /* Cell */,
5572C52A1F0E992700F71BDE /* ViewController */,
55A49E651F0E85CB0090C28C /* Model */,
55A49E601F0E80270090C28C /* Manager */,
55A49E4C1F0E80170090C28C /* AppDelegate.h */,
55A49E4D1F0E80170090C28C /* AppDelegate.m */,
55A49E4F1F0E80170090C28C /* ViewController.h */,
55A49E501F0E80170090C28C /* ViewController.m */,
55A49E521F0E80170090C28C /* Main.storyboard */,
55A49E551F0E80170090C28C /* Assets.xcassets */,
55A49E571F0E80170090C28C /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -96,6 +123,8 @@
55A49E651F0E85CB0090C28C /* Model */ = {
isa = PBXGroup;
children = (
55A49E661F0E86520090C28C /* ParkDataModel.h */,
55A49E671F0E86520090C28C /* ParkDataModel.m */,
);
name = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,6 +191,7 @@
55A49E591F0E80170090C28C /* LaunchScreen.storyboard in Resources */,
55A49E561F0E80170090C28C /* Assets.xcassets in Resources */,
55A49E541F0E80170090C28C /* Main.storyboard in Resources */,
5572C5301F0E994A00F71BDE /* ParkTableViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -175,7 +205,9 @@
55A49E631F0E80450090C28C /* APIManager.m in Sources */,
55A49E511F0E80170090C28C /* ViewController.m in Sources */,
55A49E4E1F0E80170090C28C /* AppDelegate.m in Sources */,
55A49E681F0E86520090C28C /* ParkDataModel.m in Sources */,
55A49E4B1F0E80170090C28C /* main.m in Sources */,
5572C52F1F0E994A00F71BDE /* ParkTableViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -334,6 +366,7 @@
55A49E5F1F0E80170090C28C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
27 changes: 23 additions & 4 deletions TaipeiPark/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="l7y-QF-X7N">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="l7y-QF-X7N" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="25T-8i-y6d"/>
<constraint firstAttribute="trailing" secondItem="l7y-QF-X7N" secondAttribute="trailing" id="AT1-I6-mqi"/>
<constraint firstItem="l7y-QF-X7N" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="a91-i7-glu"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="l7y-QF-X7N" secondAttribute="bottom" id="vr0-px-c5t"/>
</constraints>
</view>
<connections>
<outlet property="parkListTableView" destination="l7y-QF-X7N" id="6m5-5n-JVS"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down
17 changes: 17 additions & 0 deletions TaipeiPark/Cell/ParkTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ParkTableViewCell.h
// TaipeiPark
//
// Created by linyuta on 07/07/2017.
// Copyright © 2017 TaipeiData. All rights reserved.
//

#import <UIKit/UIKit.h>

@class ParkDataModel;

@interface ParkTableViewCell : UITableViewCell

@property (strong, nonatomic) ParkDataModel *parkData;

@end
40 changes: 40 additions & 0 deletions TaipeiPark/Cell/ParkTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// ParkTableViewCell.m
// TaipeiPark
//
// Created by linyuta on 07/07/2017.
// Copyright © 2017 TaipeiData. All rights reserved.
//

#import "ParkTableViewCell.h"
#import "ParkDataModel.h"

@interface ParkTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *parkNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *parkImageNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *parkIntroductionLabel;


@end

@implementation ParkTableViewCell

- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

- (void)setParkData:(ParkDataModel *)parkData {
self.parkNameLabel.text = parkData.name;
self.parkImageNameLabel.text = parkData.imageURLString;
self.parkIntroductionLabel.text = parkData.introduction;
}

@end
66 changes: 66 additions & 0 deletions TaipeiPark/Cell/ParkTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ParkTableViewCell" rowHeight="136" id="KGk-i7-Jjw" customClass="ParkTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="136"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="136"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kQx-AI-Dk1">
<rect key="frame" x="8" y="8" width="42" height="77"/>
<color key="backgroundColor" red="0.30588235289999999" green="0.72156862749999995" blue="0.3411764706" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FmA-s6-qxI">
<rect key="frame" x="8" y="116" width="304" height="17"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7YF-pN-fMw">
<rect key="frame" x="8" y="85" width="304" height="21"/>
<color key="backgroundColor" red="0.93333333330000001" green="0.59607843140000005" blue="0.10980392160000001" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="FmA-s6-qxI" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="0N8-eb-8uw"/>
<constraint firstItem="kQx-AI-Dk1" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="BSO-88-Acc"/>
<constraint firstAttribute="bottom" secondItem="FmA-s6-qxI" secondAttribute="bottom" constant="2.5" id="FSo-KE-hv9"/>
<constraint firstItem="7YF-pN-fMw" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="OBP-1c-mk9"/>
<constraint firstItem="kQx-AI-Dk1" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="dQ5-cg-nHm"/>
<constraint firstItem="FmA-s6-qxI" firstAttribute="top" secondItem="7YF-pN-fMw" secondAttribute="bottom" constant="10" id="gCa-js-cpZ"/>
<constraint firstAttribute="trailingMargin" secondItem="7YF-pN-fMw" secondAttribute="trailing" id="gG1-fX-3Xu"/>
<constraint firstItem="7YF-pN-fMw" firstAttribute="top" secondItem="kQx-AI-Dk1" secondAttribute="bottom" id="thg-Dw-Ggx"/>
<constraint firstAttribute="trailingMargin" secondItem="FmA-s6-qxI" secondAttribute="trailing" id="uLL-Fw-9EL"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.98039215690000003" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="parkImageNameLabel" destination="7YF-pN-fMw" id="JKk-KJ-u1a"/>
<outlet property="parkIntroductionLabel" destination="FmA-s6-qxI" id="jsq-0e-RfF"/>
<outlet property="parkNameLabel" destination="kQx-AI-Dk1" id="zNx-eL-xHZ"/>
</connections>
<point key="canvasLocation" x="110" y="-8"/>
</tableViewCell>
</objects>
</document>
5 changes: 5 additions & 0 deletions TaipeiPark/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
1 change: 1 addition & 0 deletions TaipeiPark/Manager/APIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@interface APIManager : NSObject

+ (id)shared;
- (void)postWithParameters:(NSDictionary *)parameters completion:(void (^)(BOOL finished, id data))completion failure:(void (^)(NSError *error))failure;

@end
Loading

0 comments on commit 7952510

Please sign in to comment.