diff --git a/OneTimePasswordExample.xcodeproj/project.pbxproj b/OneTimePasswordExample.xcodeproj/project.pbxproj index 83174b4..635e20d 100644 --- a/OneTimePasswordExample.xcodeproj/project.pbxproj +++ b/OneTimePasswordExample.xcodeproj/project.pbxproj @@ -14,6 +14,9 @@ 08C8E27826BBA377006D4608 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08C8E27726BBA377006D4608 /* Assets.xcassets */; }; 08C8E27B26BBA377006D4608 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08C8E27926BBA377006D4608 /* LaunchScreen.storyboard */; }; 08C8E27E26BBA377006D4608 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08C8E27D26BBA377006D4608 /* main.m */; }; + 4F8B41252703520D00CF6A1A /* SettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F8B41242703520D00CF6A1A /* SettingController.m */; }; + 4F8B41292705F8CF00CF6A1A /* SettingsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */; }; + 4F8B412D2709A50E00CF6A1A /* SettingTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */; }; 9A376FD397E03D93D3D80530 /* libPods-OneTimePasswordExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C08B5529218DAFE111F19B53 /* libPods-OneTimePasswordExample.a */; }; /* End PBXBuildFile section */ @@ -30,6 +33,11 @@ 08C8E27A26BBA377006D4608 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 08C8E27C26BBA377006D4608 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 08C8E27D26BBA377006D4608 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 4F8B41242703520D00CF6A1A /* SettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingController.m; sourceTree = ""; }; + 4F8B4126270484D900CF6A1A /* SettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingController.h; sourceTree = ""; }; + 4F8B41272705F8A900CF6A1A /* SettingsTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsTableViewCell.h; sourceTree = ""; }; + 4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsTableViewCell.m; sourceTree = ""; }; + 4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingTableViewCell.xib; sourceTree = ""; }; 62EA47A9FA5474BBDDECC144 /* Pods-OneTimePasswordExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneTimePasswordExample.debug.xcconfig"; path = "Target Support Files/Pods-OneTimePasswordExample/Pods-OneTimePasswordExample.debug.xcconfig"; sourceTree = ""; }; C08B5529218DAFE111F19B53 /* libPods-OneTimePasswordExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneTimePasswordExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C0CF9A46AE07C0F1865C69D3 /* Pods-OneTimePasswordExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneTimePasswordExample.release.xcconfig"; path = "Target Support Files/Pods-OneTimePasswordExample/Pods-OneTimePasswordExample.release.xcconfig"; sourceTree = ""; }; @@ -68,13 +76,18 @@ 08C8E26A26BBA376006D4608 /* OneTimePasswordExample */ = { isa = PBXGroup; children = ( + 4F8B41272705F8A900CF6A1A /* SettingsTableViewCell.h */, + 4F8B41282705F8CF00CF6A1A /* SettingsTableViewCell.m */, 08C8E26B26BBA376006D4608 /* AppDelegate.h */, 08C8E26C26BBA376006D4608 /* AppDelegate.m */, 08C8E26E26BBA376006D4608 /* SceneDelegate.h */, 08C8E26F26BBA376006D4608 /* SceneDelegate.m */, 08C8E27126BBA376006D4608 /* ViewController.h */, 08C8E27226BBA376006D4608 /* ViewController.m */, + 4F8B41242703520D00CF6A1A /* SettingController.m */, + 4F8B4126270484D900CF6A1A /* SettingController.h */, 08C8E27426BBA376006D4608 /* Main.storyboard */, + 4F8B412C2709A50E00CF6A1A /* SettingTableViewCell.xib */, 08C8E27726BBA377006D4608 /* Assets.xcassets */, 08C8E27926BBA377006D4608 /* LaunchScreen.storyboard */, 08C8E27C26BBA377006D4608 /* Info.plist */, @@ -159,6 +172,7 @@ files = ( 08C8E27B26BBA377006D4608 /* LaunchScreen.storyboard in Resources */, 08C8E27826BBA377006D4608 /* Assets.xcassets in Resources */, + 4F8B412D2709A50E00CF6A1A /* SettingTableViewCell.xib in Resources */, 08C8E27626BBA376006D4608 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -197,6 +211,8 @@ files = ( 08C8E27326BBA376006D4608 /* ViewController.m in Sources */, 08C8E26D26BBA376006D4608 /* AppDelegate.m in Sources */, + 4F8B41292705F8CF00CF6A1A /* SettingsTableViewCell.m in Sources */, + 4F8B41252703520D00CF6A1A /* SettingController.m in Sources */, 08C8E27E26BBA377006D4608 /* main.m in Sources */, 08C8E27026BBA376006D4608 /* SceneDelegate.m in Sources */, ); diff --git a/OneTimePasswordExample/Base.lproj/Main.storyboard b/OneTimePasswordExample/Base.lproj/Main.storyboard index 5baab28..9455976 100644 --- a/OneTimePasswordExample/Base.lproj/Main.storyboard +++ b/OneTimePasswordExample/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -29,16 +30,27 @@ + + + + @@ -48,7 +60,56 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OneTimePasswordExample/SettingController.h b/OneTimePasswordExample/SettingController.h new file mode 100644 index 0000000..2e0ebdf --- /dev/null +++ b/OneTimePasswordExample/SettingController.h @@ -0,0 +1,16 @@ +// +// SettingController.h +// OneTimePasswordExample +// +// Created by Mai Nakagami on 2021/09/29. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SettingController : UITableViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/OneTimePasswordExample/SettingController.m b/OneTimePasswordExample/SettingController.m new file mode 100644 index 0000000..aa89580 --- /dev/null +++ b/OneTimePasswordExample/SettingController.m @@ -0,0 +1,140 @@ +// +// SettingController.m +// OneTimePasswordExample +// +// Created by Mai Nakagami on 2021/09/28. +// + +#import "SettingController.h" +#import "SettingsTableViewCell.h" + +#pragma mark - Settings item + +typedef NS_ENUM(UInt8, SettingsItem) { + SettingsItem1, + SettingsItem2, + SettingsItme3, +}; + +extern SettingsItem SettingsItemUnknown; + + +#pragma mark - Settings table view controller + +@interface SettingController () + +@property (nonatomic) SettingsItem settingsItem; + +@property (nonatomic) UIPickerView *pickerView; + +@property (nonatomic) NSArray *test1Patterns; +@property (nonatomic) NSArray *test2Patterns; +@property (nonatomic) NSArray *test3Patterns; + +@property (nonatomic) NSString *test1; +@property (nonatomic) NSString *test2; +@property (nonatomic) NSString *test3; + +@end + +@implementation SettingController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.center = self.view.center; + self.pickerView.dataSource = self; + self.pickerView.delegate = self; + [self.view addSubview: self.pickerView]; + + self.test1Patterns = @[@"1", @"2", @"3"]; + self.test2Patterns = @[@"4", @"5", @"6"]; + self.test3Patterns = @[@"7", @"8", @"9"]; + + self.test1 = self.test1Patterns[0]; + self.test2 = self.test2Patterns[0]; + self.test3 = self.test3Patterns[0]; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return 3; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + SettingsTableViewCell *cell = (SettingsTableViewCell *)[tableView dequeueReusableCellWithIdentifier: @"SettingsTableViewCell" forIndexPath:indexPath]; + + switch (indexPath.row) { + case 0: + cell.titleLabel.text = @"TEST1"; + cell.valueLabel.text = self.test1; + break; + case 1: + cell.titleLabel.text = @"TEST2"; + cell.valueLabel.text = self.test2; + break; + case 2: + cell.titleLabel.text = @"TEST3"; + cell.valueLabel.text = self.test3; + break; + } + + return cell; +} + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self.pickerView selectRow:0 inComponent:0 animated:true]; + [self.pickerView reloadAllComponents]; + self.settingsItem = indexPath.row; +} + +#pragma mark - Picker view data source + +- (NSInteger)numberOfComponentsInPickerView:(nonnull UIPickerView *)pickerView { + return 1; +} + +- (NSInteger)pickerView:(nonnull UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { + return 3; +} + +#pragma mark - Picker view delegate + +- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + switch (self.settingsItem) { + case SettingsItem1: + return self.test1Patterns[row]; + case SettingsItem2: + return self.test2Patterns[row]; + case SettingsItme3: + return self.test3Patterns[row]; + } + + return @""; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + switch (self.settingsItem) { + case SettingsItem1: + self.test1 = self.test1Patterns[row]; + break; + case SettingsItem2: + self.test2 = self.test2Patterns[row]; + break; + case SettingsItme3: + self.test3 = self.test3Patterns[row]; + break; + } + + [self.tableView reloadData]; +} + +@end diff --git a/OneTimePasswordExample/SettingTableViewCell.storyboard b/OneTimePasswordExample/SettingTableViewCell.storyboard new file mode 100644 index 0000000..dd79351 --- /dev/null +++ b/OneTimePasswordExample/SettingTableViewCell.storyboard @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OneTimePasswordExample/SettingTableViewCell.xib b/OneTimePasswordExample/SettingTableViewCell.xib new file mode 100644 index 0000000..631227f --- /dev/null +++ b/OneTimePasswordExample/SettingTableViewCell.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OneTimePasswordExample/SettingsTableViewCell.h b/OneTimePasswordExample/SettingsTableViewCell.h new file mode 100644 index 0000000..84946b0 --- /dev/null +++ b/OneTimePasswordExample/SettingsTableViewCell.h @@ -0,0 +1,19 @@ +// +// SettingTableViewCell.h +// OneTimePasswordExample +// +// Created by MaiNakagami on 2021/09/30. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SettingsTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; +@property (weak, nonatomic) IBOutlet UILabel *valueLabel; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OneTimePasswordExample/SettingsTableViewCell.m b/OneTimePasswordExample/SettingsTableViewCell.m new file mode 100644 index 0000000..40b44d4 --- /dev/null +++ b/OneTimePasswordExample/SettingsTableViewCell.m @@ -0,0 +1,23 @@ +// +// SettingTableViewCell.m +// OneTimePasswordExample +// +// Created by MaiNakagami on 2021/09/30. +// + +#import "SettingsTableViewCell.h" + +@implementation SettingsTableViewCell + +- (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 +} + +@end