diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index 62db31fa1..94ffd7844 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -757,6 +757,8 @@ EC1CA89A24C9C9A200DE9EBF /* SetupBiometricsCoordinatorType.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA89224C9C9A200DE9EBF /* SetupBiometricsCoordinatorType.swift */; }; EC1CA89B24C9C9A200DE9EBF /* SetupBiometricsViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA89324C9C9A200DE9EBF /* SetupBiometricsViewState.swift */; }; EC1CA89C24C9C9A200DE9EBF /* SetupBiometricsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA89424C9C9A200DE9EBF /* SetupBiometricsViewModel.swift */; }; + EC1CA8C824D3160100DE9EBF /* Row.m in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA8C724D3160100DE9EBF /* Row.m */; }; + EC1CA8CB24D3168F00DE9EBF /* Section.m in Sources */ = {isa = PBXBuildFile; fileRef = EC1CA8CA24D3168F00DE9EBF /* Section.m */; }; EC2B4EF124A1EEBD005EB739 /* DataProtectionHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2B4EF024A1EEBD005EB739 /* DataProtectionHelper.swift */; }; EC2B4EF224A1EF34005EB739 /* DataProtectionHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2B4EF024A1EEBD005EB739 /* DataProtectionHelper.swift */; }; EC3B066924AC6ADE000DF9BF /* CrossSigningService.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3B066424AC6ADD000DF9BF /* CrossSigningService.swift */; }; @@ -1879,6 +1881,10 @@ EC1CA8BB24D1B4BF00DE9EBF /* SiriIntents-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "SiriIntents-Debug.xcconfig"; sourceTree = ""; }; EC1CA8BC24D1B4CF00DE9EBF /* NSE-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "NSE-Debug.xcconfig"; sourceTree = ""; }; EC1CA8BD24D1B4CF00DE9EBF /* NSE-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "NSE-Release.xcconfig"; sourceTree = ""; }; + EC1CA8C624D3160100DE9EBF /* Row.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Row.h; sourceTree = ""; }; + EC1CA8C724D3160100DE9EBF /* Row.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Row.m; sourceTree = ""; }; + EC1CA8C924D3168F00DE9EBF /* Section.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Section.h; sourceTree = ""; }; + EC1CA8CA24D3168F00DE9EBF /* Section.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Section.m; sourceTree = ""; }; EC2B4EF024A1EEBD005EB739 /* DataProtectionHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataProtectionHelper.swift; sourceTree = ""; }; EC3B066424AC6ADD000DF9BF /* CrossSigningService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrossSigningService.swift; sourceTree = ""; }; EC3B066624AC6ADD000DF9BF /* CrossSigningSetupBannerCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CrossSigningSetupBannerCell.xib; sourceTree = ""; }; @@ -3192,6 +3198,7 @@ B1B5567720EE6C4C00210D55 /* Settings */ = { isa = PBXGroup; children = ( + EC1CA8C524D315EA00DE9EBF /* Models */, B1B5567F20EE6C4C00210D55 /* SettingsViewController.h */, B1B5567E20EE6C4C00210D55 /* SettingsViewController.m */, B1B5578120EF564900210D55 /* Views */, @@ -4607,6 +4614,17 @@ path = SetupBiometrics; sourceTree = ""; }; + EC1CA8C524D315EA00DE9EBF /* Models */ = { + isa = PBXGroup; + children = ( + EC1CA8C624D3160100DE9EBF /* Row.h */, + EC1CA8C724D3160100DE9EBF /* Row.m */, + EC1CA8C924D3168F00DE9EBF /* Section.h */, + EC1CA8CA24D3168F00DE9EBF /* Section.m */, + ); + path = Models; + sourceTree = ""; + }; EC3B066324AC6ADD000DF9BF /* CrossSigning */ = { isa = PBXGroup; children = ( @@ -6035,6 +6053,7 @@ B1A6C10D23882D1D002882FD /* SlidingModalPresentationController.swift in Sources */, 32A6001D22C661100042C1D9 /* EditHistoryCoordinatorType.swift in Sources */, F083BDFA1E7009ED00A9B29C /* RoomPreviewData.m in Sources */, + EC1CA8CB24D3168F00DE9EBF /* Section.m in Sources */, B1B557B420EF5AEF00210D55 /* EventDetailsView.m in Sources */, EC85D751247C0E8F002C44C9 /* UNUserNotificationCenter.swift in Sources */, B1BEE73823DF44A60003A4CB /* UserVerificationSessionsStatusViewAction.swift in Sources */, @@ -6061,6 +6080,7 @@ EC711B7624A63B37008F830C /* SecretsSetupRecoveryKeyViewState.swift in Sources */, 32FDC1CD2386CD390084717A /* RiotSettingIntegrationProvisioning.swift in Sources */, B1BEE73523DF44A60003A4CB /* UserVerificationSessionsStatusViewModel.swift in Sources */, + EC1CA8C824D3160100DE9EBF /* Row.m in Sources */, B1B5572020EE6C4D00210D55 /* ContactsTableViewController.m in Sources */, EC85D7142477DCD7002C44C9 /* KeyVerificationScanConfirmationViewState.swift in Sources */, EC711B9124A63B37008F830C /* SecretsRecoveryWithKeyCoordinatorType.swift in Sources */, diff --git a/Riot/Modules/Settings/Models/Row.h b/Riot/Modules/Settings/Models/Row.h new file mode 100644 index 000000000..c39c314f1 --- /dev/null +++ b/Riot/Modules/Settings/Models/Row.h @@ -0,0 +1,32 @@ +// +// Copyright 2020 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +/// Row object for tableviews +@interface Row: NSObject + +@property (nonatomic, assign) NSInteger tag; + ++ (instancetype)rowWithTag:(NSInteger)tag; + +- (instancetype)initWithTag:(NSInteger)tag; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Riot/Modules/Settings/Models/Row.m b/Riot/Modules/Settings/Models/Row.m new file mode 100644 index 000000000..a4dc62f0e --- /dev/null +++ b/Riot/Modules/Settings/Models/Row.m @@ -0,0 +1,35 @@ +// +// Copyright 2020 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "Row.h" + +@implementation Row + ++ (instancetype)rowWithTag:(NSInteger)tag +{ + return [[self alloc] initWithTag:tag]; +} + +- (instancetype)initWithTag:(NSInteger)tag +{ + self = [super init]; + if (self) { + self.tag = tag; + } + return self; +} + +@end diff --git a/Riot/Modules/Settings/Models/Section.h b/Riot/Modules/Settings/Models/Section.h new file mode 100644 index 000000000..e566b8fa5 --- /dev/null +++ b/Riot/Modules/Settings/Models/Section.h @@ -0,0 +1,39 @@ +// +// Copyright 2020 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class Row; + +/// Section object for tableviews +@interface Section: NSObject + +@property (nonatomic, assign) NSInteger tag; +@property (nonatomic, strong) NSMutableArray *rows; +@property (nonatomic, copy) NSString *headerTitle; + ++ (instancetype)sectionWithTag:(NSInteger)tag; +- (instancetype)initWithTag:(NSInteger)tag; + +- (void)addRow:(Row *)row; +- (void)addRowWithTag:(NSInteger)tag; +- (NSInteger)indexOfRowForTag:(NSInteger)tag; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Riot/Modules/Settings/Models/Section.m b/Riot/Modules/Settings/Models/Section.m new file mode 100644 index 000000000..e6f4a6b1a --- /dev/null +++ b/Riot/Modules/Settings/Models/Section.m @@ -0,0 +1,54 @@ +// +// Copyright 2020 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "Section.h" +#import "Row.h" + +@implementation Section + ++ (instancetype)sectionWithTag:(NSInteger)tag +{ + return [[self alloc] initWithTag:tag]; +} + +- (instancetype)initWithTag:(NSInteger)tag +{ + self = [super init]; + if (self) { + self.tag = tag; + _rows = [NSMutableArray arrayWithCapacity:10]; + } + return self; +} + +- (void)addRow:(Row *)row +{ + [_rows addObject:row]; +} + +- (void)addRowWithTag:(NSInteger)tag +{ + [_rows addObject:[Row rowWithTag:tag]]; +} + +- (NSInteger)indexOfRowForTag:(NSInteger)tag +{ + return [_rows indexOfObjectPassingTest:^BOOL(Row * _Nonnull row, NSUInteger idx, BOOL * _Nonnull stop) { + return row.tag == tag; + }]; +} + +@end diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 045116125..769ab6e8f 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -42,6 +42,9 @@ #import "GroupsDataSource.h" #import "GroupTableViewCellWithSwitch.h" +#import "Row.h" +#import "Section.h" + #import "GBDeviceInfo_iOS.h" #import "Riot-Swift.h" @@ -157,81 +160,6 @@ enum typedef void (^blockSettingsViewController_onReadyToDestroy)(void); -#pragma mark - Row - -@interface Row: NSObject - -@property (nonatomic, assign) NSInteger tag; - -@end - -@implementation Row - -+ (instancetype)rowWithTag:(NSInteger)tag -{ - return [[self alloc] initWithTag:tag]; -} - -- (instancetype)initWithTag:(NSInteger)tag -{ - self = [super init]; - if (self) { - self.tag = tag; - } - return self; -} - -@end - -#pragma mark - Section - -@interface Section: NSObject - -@property (nonatomic, assign) NSInteger tag; -@property (nonatomic, strong) NSMutableArray *rows; -@property (nonatomic, copy) NSString *headerTitle; - -- (void)addRow:(Row *)row; -- (void)addRowWithTag:(NSInteger)tag; - -@end - -@implementation Section - -+ (instancetype)sectionWithTag:(NSInteger)tag -{ - return [[self alloc] initWithTag:tag]; -} - -- (instancetype)initWithTag:(NSInteger)tag -{ - self = [super init]; - if (self) { - self.tag = tag; - _rows = [NSMutableArray arrayWithCapacity:10]; - } - return self; -} - -- (void)addRow:(Row *)row -{ - [_rows addObject:row]; -} - -- (void)addRowWithTag:(NSInteger)tag -{ - [_rows addObject:[Row rowWithTag:tag]]; -} - -- (NSInteger)indexOfRowForTag:(NSInteger)tag -{ - return [_rows indexOfObjectPassingTest:^BOOL(Row * _Nonnull row, NSUInteger idx, BOOL * _Nonnull stop) { - return row.tag == tag; - }]; -} - -@end - #pragma mark - SettingsViewController @interface SettingsViewController ()