Added Settings viewcontroller.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2017-07-05 16:21:14 +02:00
Родитель 4b7f79218e
Коммит b0245ac951
7 изменённых файлов: 215 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,7 @@
2CA1CCA71F026222002FE6A2 /* ContactsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA1CCA61F026222002FE6A2 /* ContactsTableViewController.m */; };
2CA1CCAA1F02D1A4002FE6A2 /* NCAPIController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA1CCA91F02D1A4002FE6A2 /* NCAPIController.m */; };
2CA1CCAC1F067F35002FE6A2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CA1CCAB1F067F35002FE6A2 /* Images.xcassets */; };
2CA1CCB51F0D0D5E002FE6A2 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA1CCB41F0D0D5E002FE6A2 /* SettingsViewController.m */; };
DB6A892B5CEBD4812F7C52EF /* libPods-VideoCalls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6267808DF11BEB859C0BE9F1 /* libPods-VideoCalls.a */; };
/* End PBXBuildFile section */
@ -60,6 +61,8 @@
2CA1CCA81F02D1A4002FE6A2 /* NCAPIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCAPIController.h; sourceTree = "<group>"; };
2CA1CCA91F02D1A4002FE6A2 /* NCAPIController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCAPIController.m; sourceTree = "<group>"; };
2CA1CCAB1F067F35002FE6A2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
2CA1CCB31F0D0D5E002FE6A2 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
2CA1CCB41F0D0D5E002FE6A2 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = "<group>"; };
6267808DF11BEB859C0BE9F1 /* libPods-VideoCalls.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VideoCalls.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8BD08DF13BF3479DEEECFEB1 /* Pods-VideoCalls.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoCalls.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VideoCalls/Pods-VideoCalls.debug.xcconfig"; sourceTree = "<group>"; };
E8DF4DF89BBD55A5ED6488CB /* Pods-VideoCalls.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoCalls.release.xcconfig"; path = "Pods/Target Support Files/Pods-VideoCalls/Pods-VideoCalls.release.xcconfig"; sourceTree = "<group>"; };
@ -104,7 +107,6 @@
2C05747F1EDD9E8E00D9E7F2 /* VideoCalls */ = {
isa = PBXGroup;
children = (
2CA1CCAB1F067F35002FE6A2 /* Images.xcassets */,
2C0574831EDD9E8E00D9E7F2 /* AppDelegate.h */,
2C0574841EDD9E8E00D9E7F2 /* AppDelegate.m */,
2C90E5D01EE80C870093D85A /* AuthenticationViewController.h */,
@ -113,6 +115,7 @@
2CA1CCA31F025F64002FE6A2 /* CallsTableViewController.m */,
2CA1CCA51F026222002FE6A2 /* ContactsTableViewController.h */,
2CA1CCA61F026222002FE6A2 /* ContactsTableViewController.m */,
2CA1CCAB1F067F35002FE6A2 /* Images.xcassets */,
2C0574941EDD9E8E00D9E7F2 /* Info.plist */,
2C0574911EDD9E8E00D9E7F2 /* LaunchScreen.storyboard */,
2C0574A11EDDA2E300D9E7F2 /* LoginViewController.h */,
@ -125,6 +128,8 @@
2CA1CC901F014354002FE6A2 /* NCConnectionController.m */,
2CA1CC931F014EF9002FE6A2 /* NCSettingsController.h */,
2CA1CC941F014EF9002FE6A2 /* NCSettingsController.m */,
2CA1CCB31F0D0D5E002FE6A2 /* SettingsViewController.h */,
2CA1CCB41F0D0D5E002FE6A2 /* SettingsViewController.m */,
2C0574801EDD9E8E00D9E7F2 /* Supporting Files */,
);
path = VideoCalls;
@ -309,6 +314,7 @@
2C90E5D31EE80C870093D85A /* AuthenticationViewController.m in Sources */,
2C0574A41EDDA2E300D9E7F2 /* LoginViewController.m in Sources */,
2CA1CC911F014354002FE6A2 /* NCConnectionController.m in Sources */,
2CA1CCB51F0D0D5E002FE6A2 /* SettingsViewController.m in Sources */,
2CA1CC951F014EF9002FE6A2 /* NCSettingsController.m in Sources */,
2CA1CC9A1F0161EA002FE6A2 /* UICKeyChainStore.m in Sources */,
);

Просмотреть файл

@ -8,6 +8,62 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Settings-->
<scene sceneID="3cs-hc-79B">
<objects>
<tableViewController id="mBz-0e-fOH" customClass="SettingsViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="Ht6-iM-DHG">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="IZY-pD-QFP">
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="IZY-pD-QFP" id="b4T-B8-WHs">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="mBz-0e-fOH" id="qQL-It-EGb"/>
<outlet property="delegate" destination="mBz-0e-fOH" id="xg2-8U-OKe"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Settings" id="JFt-ZI-oe6">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="Nvt-Pr-NcO">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<action selector="cancelButtonPressed:" destination="mBz-0e-fOH" id="vb2-8J-9Lp"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zFr-fx-9m5" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3473" y="-943"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="54W-NR-WAb">
<objects>
<navigationController id="tcx-5H-OG9" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="pba-Gu-M55">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<textAttributes key="titleTextAttributes">
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textShadowColor" white="0.26000000000000001" alpha="1" colorSpace="calibratedWhite"/>
</textAttributes>
</navigationBar>
<connections>
<segue destination="mBz-0e-fOH" kind="relationship" relationship="rootViewController" id="Nu3-Tl-roi"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nAq-Ig-1az" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2654" y="-943"/>
</scene>
<!--Root View Controller-->
<scene sceneID="XxO-ic-LNg">
<objects>
@ -35,6 +91,9 @@
<navigationItem key="navigationItem" title="Root View Controller" id="3e2-3x-z0c">
<barButtonItem key="leftBarButtonItem" image="settings" id="jaA-0s-oKf">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<segue destination="tcx-5H-OG9" kind="presentation" id="IGh-Q2-lrk"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="add" id="0Gy-30-3im">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>

Просмотреть файл

@ -46,6 +46,13 @@
serverUrl = [serverUrl substringToIndex:[serverUrl length] - 1];
}
// Remove stored cookies
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [storage cookies])
{
[storage deleteCookie:cookie];
}
[[NCAPIController sharedInstance] setNCServer:serverUrl];
[[NCAPIController sharedInstance] getRoomsWithCompletionBlock:^(NSMutableArray *rooms, NSError *error, NSInteger errorCode) {
if (errorCode == 401) {

Просмотреть файл

@ -23,5 +23,6 @@ extern NSString * const kNCTokenKey;
@property (nonatomic, copy) NSString *ncToken;
+ (instancetype)sharedInstance;
- (void)cleanAllStoredValues;
@end

Просмотреть файл

@ -8,6 +8,8 @@
#import "NCSettingsController.h"
#import "NCAPIController.h"
@implementation NCSettingsController
NSString * const kNCServerKey = @"ncServer";
@ -40,4 +42,16 @@ NSString * const kNCTokenKey = @"ncToken";
_ncToken = [UICKeyChainStore stringForKey:kNCTokenKey];
}
- (void)cleanAllStoredValues
{
_ncServer = nil;
_ncUser = nil;
_ncToken = nil;
[UICKeyChainStore removeAllItems];
#warning TODO - Restore NCAPIController in a diferent way
[[NCAPIController sharedInstance] setAuthHeaderWithUser:NULL andToken:NULL];
}
@end

Просмотреть файл

@ -0,0 +1,13 @@
//
// SettingsViewController.h
// VideoCalls
//
// Created by Ivan Sein on 05.07.17.
// Copyright © 2017 struktur AG. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SettingsViewController : UITableViewController
@end

Просмотреть файл

@ -0,0 +1,114 @@
//
// SettingsViewController.m
// VideoCalls
//
// Created by Ivan Sein on 05.07.17.
// Copyright © 2017 struktur AG. All rights reserved.
//
#import "SettingsViewController.h"
#import "NCSettingsController.h"
typedef enum SettingsSection {
kSettingsSectionServer = 0,
kSettingsSectionUser,
kSettingsSectionLogout
} SettingsSection;
@interface SettingsViewController ()
{
NSString *_server;
NSString *_user;
NSArray *_settingsSections;
}
@end
@implementation SettingsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.00 green:0.51 blue:0.79 alpha:1.0]; //#0082C9
self.tabBarController.tabBar.tintColor = [UIColor colorWithRed:0.00 green:0.51 blue:0.79 alpha:1.0]; //#0082C9
_server = [[NCSettingsController sharedInstance] ncServer];
_user = [[NCSettingsController sharedInstance] ncUser];
_settingsSections = @[@"Server", @"User", @"Logout"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)cancelButtonPressed:(id)sender {
[self dismissViewControllerAnimated:true completion:nil];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [_settingsSections count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [_settingsSections objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
static NSString *ServerCellIdentifier = @"ServerCellIdentifier";
static NSString *UserCellIdentifier = @"UserCellIdentifier";
static NSString *LogoutCellIdentifier = @"LogoutCellIdentifier";
switch (indexPath.section) {
case kSettingsSectionServer:
{
cell = [tableView dequeueReusableCellWithIdentifier:ServerCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ServerCellIdentifier];
cell.textLabel.text = _server;
}
}
break;
case kSettingsSectionUser:
{
cell = [tableView dequeueReusableCellWithIdentifier:UserCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserCellIdentifier];
cell.textLabel.text = _user;
}
}
break;
case kSettingsSectionLogout:
{
cell = [tableView dequeueReusableCellWithIdentifier:LogoutCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LogoutCellIdentifier];
cell.textLabel.text = @"Sign off";
}
}
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == kSettingsSectionLogout) {
[[NCSettingsController sharedInstance] cleanAllStoredValues];
[self dismissViewControllerAnimated:true completion:nil];
}
}
@end