inapp: implement shop properly

This commit is contained in:
Gautier Pelloux-Prayer 2016-08-30 15:28:17 +02:00
parent 8f770bf3a3
commit 108d5cdda5
4 changed files with 70 additions and 42 deletions

View file

@ -1,17 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="NO">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ShopView">
<connections>
<outlet property="accountBuyButton" destination="0bU-UW-3nR" id="GOQ-1M-4kI"/>
<outlet property="accountProductDescription" destination="Ubj-Hn-QQP" id="itS-zY-QnV"/>
<outlet property="accountProductPrice" destination="Hhk-KZ-LpO" id="rao-hi-s4Y"/>
<outlet property="accountProductTitle" destination="8CD-Y8-Ad3" id="29E-MO-OgE"/>
<outlet property="portraitView" destination="HJH-1o-RXN" id="Hoa-uk-q9s"/>
<outlet property="view" destination="HJH-1o-RXN" id="OKD-FI-yhX"/>
</connections>
@ -56,53 +52,28 @@
</label>
</subviews>
</view>
<view clipsSubviews="YES" multipleTouchEnabled="YES" tag="6" contentMode="scaleToFill" id="er6-WR-NP1">
<rect key="frame" x="0.0" y="66" width="320" height="535"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Product description" lineBreakMode="wordWrap" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ubj-Hn-QQP" userLabel="productDescription">
<rect key="frame" x="16" y="35" width="177" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="0bU-UW-3nR" userLabel="purchaseButton">
<rect key="frame" x="248" y="31" width="72" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Buy"/>
<connections>
<action selector="onPurchaseButtonClick:" destination="-1" eventType="touchUpInside" id="ZX7-nC-4Mi"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Product title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" highlighted="YES" adjustsFontSizeToFit="NO" id="8CD-Y8-Ad3" userLabel="productTitle">
<rect key="frame" x="16" y="11" width="245" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.5 €" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Hhk-KZ-LpO">
<rect key="frame" x="203" y="35" width="55" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="AXe-My-OHb" customClass="ShowTableView">
<rect key="frame" x="0.0" y="66" width="320" height="348"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="Pl4-ib-dZC" id="Cny-je-KR9"/>
<outlet property="delegate" destination="Pl4-ib-dZC" id="kzc-F5-3JS"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<point key="canvasLocation" x="235.5" y="318.5"/>
<point key="canvasLocation" x="235" y="318"/>
</view>
<tapGestureRecognizer id="l7c-wq-pii" userLabel="onLinkTap">
<connections>
<action selector="onLinkTap:" destination="-1" id="Ay5-Uz-RDo"/>
</connections>
</tapGestureRecognizer>
<tableViewController id="Pl4-ib-dZC"/>
</objects>
<resources>
<image name="color_E.png" width="2" height="2"/>

13
Classes/ShopTableView.h Normal file
View file

@ -0,0 +1,13 @@
//
// ShopTableView.h
// linphone
//
// Created by Gautier Pelloux-Prayer on 30/08/16.
//
//
#import <UIKit/UIKit.h>
@interface ShopTableView : UITableViewController
@end

38
Classes/ShopTableView.m Normal file
View file

@ -0,0 +1,38 @@
//
// ShopTableView.m
// linphone
//
// Created by Gautier Pelloux-Prayer on 30/08/16.
//
//
#import "ShopTableView.h"
@implementation ShopTableView
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return LinphoneManager.instance.iapManager.productsAvailable.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] init];
cell.textLabel.text = LinphoneManager.instance.iapManager.productsAvailable[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
[LinphoneManager.instance.iapManager purchaseWithID:cell.textLabel.text];
}
@end

View file

@ -595,6 +595,7 @@
63B8D6A21BCBF43100C12B09 /* UIChatCreateCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B8D6A01BCBF43100C12B09 /* UIChatCreateCell.m */; };
63BB26A31D006F4B00DA1F83 /* libbv16.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 637835A41CFD971D00599382 /* libbv16.a */; };
63BC49E21BA2CDFC004EC273 /* UICallPausedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BC49E11BA2CDFC004EC273 /* UICallPausedCell.m */; };
63BE7A781D75BDF6000990EF /* ShopTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BE7A771D75BDF6000990EF /* ShopTableView.m */; };
63C441C31BBC23ED0053DC5E /* UIAssistantTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C441C21BBC23ED0053DC5E /* UIAssistantTextField.m */; };
63CAACDB1C91D10200216F8D /* NotificationTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 63CAACD51C91D0D100216F8D /* NotificationTester.m */; };
63CD4B4F1A5AAC8C00B84282 /* DTAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63CD4B4E1A5AAC8C00B84282 /* DTAlertView.m */; };
@ -1545,6 +1546,8 @@
63B8D6A01BCBF43100C12B09 /* UIChatCreateCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIChatCreateCell.m; sourceTree = "<group>"; };
63BC49E01BA2CDFC004EC273 /* UICallPausedCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICallPausedCell.h; sourceTree = "<group>"; };
63BC49E11BA2CDFC004EC273 /* UICallPausedCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICallPausedCell.m; sourceTree = "<group>"; };
63BE7A761D75BDF6000990EF /* ShopTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopTableView.h; sourceTree = "<group>"; };
63BE7A771D75BDF6000990EF /* ShopTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopTableView.m; sourceTree = "<group>"; };
63C441C11BBC23ED0053DC5E /* UIAssistantTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAssistantTextField.h; sourceTree = "<group>"; };
63C441C21BBC23ED0053DC5E /* UIAssistantTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIAssistantTextField.m; sourceTree = "<group>"; };
63CAACD41C91D0D100216F8D /* NotificationTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationTester.h; sourceTree = "<group>"; };
@ -2042,6 +2045,8 @@
D35E759C159460B50066B1C1 /* SettingsView.h */,
D35E759D159460B50066B1C1 /* SettingsView.m */,
636316D61A1DEC650009B839 /* SettingsView.xib */,
63BE7A761D75BDF6000990EF /* ShopTableView.h */,
63BE7A771D75BDF6000990EF /* ShopTableView.m */,
570742601D5A09B8004B9C84 /* ShopView.h */,
5707425F1D5A09B8004B9C84 /* ShopView.m */,
570742561D5A0691004B9C84 /* ShopView.xib */,
@ -3876,6 +3881,7 @@
D35498211587716B000081D8 /* StatusBarView.m in Sources */,
D3A55FBC15877E5E003FD403 /* UIContactCell.m in Sources */,
6341807C1BBC103100F71761 /* ChatConversationCreateTableView.m in Sources */,
63BE7A781D75BDF6000990EF /* ShopTableView.m in Sources */,
D326483815887D5200930C67 /* OrderedDictionary.m in Sources */,
D32648441588F6FC00930C67 /* UIToggleButton.m in Sources */,
D36FB2D51589EF7C0036F6F2 /* UIPauseButton.m in Sources */,