From 108d5cdda5779273115016cee4eb05e011ddcc04 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 30 Aug 2016 15:28:17 +0200 Subject: [PATCH] inapp: implement shop properly --- Classes/Base.lproj/ShopView.xib | 55 +++++++----------------------- Classes/ShopTableView.h | 13 +++++++ Classes/ShopTableView.m | 38 +++++++++++++++++++++ linphone.xcodeproj/project.pbxproj | 6 ++++ 4 files changed, 70 insertions(+), 42 deletions(-) create mode 100644 Classes/ShopTableView.h create mode 100644 Classes/ShopTableView.m diff --git a/Classes/Base.lproj/ShopView.xib b/Classes/Base.lproj/ShopView.xib index 87ddbee2a..a8b271af3 100644 --- a/Classes/Base.lproj/ShopView.xib +++ b/Classes/Base.lproj/ShopView.xib @@ -1,17 +1,13 @@ - + - + - - - - @@ -56,53 +52,28 @@ - - - - - - - - - - + + + + + + + + + - + + diff --git a/Classes/ShopTableView.h b/Classes/ShopTableView.h new file mode 100644 index 000000000..3ec63fa5d --- /dev/null +++ b/Classes/ShopTableView.h @@ -0,0 +1,13 @@ +// +// ShopTableView.h +// linphone +// +// Created by Gautier Pelloux-Prayer on 30/08/16. +// +// + +#import + +@interface ShopTableView : UITableViewController + +@end diff --git a/Classes/ShopTableView.m b/Classes/ShopTableView.m new file mode 100644 index 000000000..112399aa7 --- /dev/null +++ b/Classes/ShopTableView.m @@ -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 diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 95727d86d..d2f6bbc55 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -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 = ""; }; 63BC49E01BA2CDFC004EC273 /* UICallPausedCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICallPausedCell.h; sourceTree = ""; }; 63BC49E11BA2CDFC004EC273 /* UICallPausedCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICallPausedCell.m; sourceTree = ""; }; + 63BE7A761D75BDF6000990EF /* ShopTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopTableView.h; sourceTree = ""; }; + 63BE7A771D75BDF6000990EF /* ShopTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopTableView.m; sourceTree = ""; }; 63C441C11BBC23ED0053DC5E /* UIAssistantTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIAssistantTextField.h; sourceTree = ""; }; 63C441C21BBC23ED0053DC5E /* UIAssistantTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIAssistantTextField.m; sourceTree = ""; }; 63CAACD41C91D0D100216F8D /* NotificationTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationTester.h; sourceTree = ""; }; @@ -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 */,