Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed Jun 6, 2015
0 parents commit f46e2ec
Show file tree
Hide file tree
Showing 57 changed files with 2,235 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
Binary file added Assets/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Bohr.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = "Bohr"
s.version = "1.0.0"
s.summary = "Settings screen composing framework"
s.homepage = "https://github.com/Dromaguirre/Bohr"
s.author = { "David Roman" => "[email protected]" }
s.license = { :type => 'MIT', :file => 'LICENSE' }

s.platform = :ios, '8.0'
s.ios.deployment_target = '8.0'

s.source = { :git => "https://github.com/Dromaguirre/Bohr.git", :tag => s.version.to_s }
s.source_files = 'Bohr/*.{h,m}'
s.frameworks = 'Foundation', 'UIKit'
s.requires_arc = true
end
620 changes: 620 additions & 0 deletions Bohr.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75C7ADFE1B1AB3280050C8AA"
BuildableName = "Bohr.framework"
BlueprintName = "Bohr"
ReferencedContainer = "container:Bohr.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75C7ADFE1B1AB3280050C8AA"
BuildableName = "Bohr.framework"
BlueprintName = "Bohr"
ReferencedContainer = "container:Bohr.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75C7ADFE1B1AB3280050C8AA"
BuildableName = "Bohr.framework"
BlueprintName = "Bohr"
ReferencedContainer = "container:Bohr.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
15 changes: 15 additions & 0 deletions Bohr/BOButtonTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BOButtonTableViewCell.h
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOTableViewCell.h"

@interface BOButtonTableViewCell : BOTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title didTriggerBlock:(void (^)(void))didTriggerBlock;

@end
37 changes: 37 additions & 0 deletions Bohr/BOButtonTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// BOButtonTableViewCell.m
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOButtonTableViewCell.h"

#import "BOTableViewCell+Subclass.h"

@interface BOButtonTableViewCell ()

@property (nonatomic, copy) void(^didTriggerBlock)(void);

@end

@implementation BOButtonTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title didTriggerBlock:(void (^)(void))didTriggerBlock {
BOButtonTableViewCell *cell = [super cellWithTitle:title setting:nil];
cell.didTriggerBlock = didTriggerBlock;
return cell;
}

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
self.textLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];
if (self.didTriggerBlock) self.didTriggerBlock();
}

@end
15 changes: 15 additions & 0 deletions Bohr/BOChoiceTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BOChoiceTableViewCell.h
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOTableViewCell.h"

@interface BOChoiceTableViewCell : BOTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title setting:(BOSetting *)setting options:(NSArray *)options;

@end
47 changes: 47 additions & 0 deletions Bohr/BOChoiceTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// BOChoiceTableViewCell.m
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOChoiceTableViewCell.h"

#import "BOTableViewCell+Subclass.h"

@interface BOChoiceTableViewCell ()

@property (nonatomic, strong) NSArray *options;

@end

@implementation BOChoiceTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title setting:(BOSetting *)setting options:(NSArray *)options {
BOChoiceTableViewCell *cell = [super cellWithTitle:title setting:setting];
cell.options = options;
return cell;
}

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];

NSInteger currentOption = [self.setting.value integerValue];

if (currentOption < self.options.count-1) {
self.setting.value = @(currentOption+1);
} else {
self.setting.value = @0;
}
}

- (void)settingValueDidChange {
self.detailTextLabel.text = self.options[[self.setting.value integerValue]];
}

@end
15 changes: 15 additions & 0 deletions Bohr/BODisclosureTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BODisclosureTableViewCell.h
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOTableViewCell.h"

@interface BODisclosureTableViewCell : BOTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title destinationViewController:(UIViewController *)destinationViewController;

@end
37 changes: 37 additions & 0 deletions Bohr/BODisclosureTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// BODisclosureTableViewCell.m
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BODisclosureTableViewCell.h"

#import "BOTableViewCell+Subclass.h"

@interface BODisclosureTableViewCell ()

@property (nonatomic, strong) UIViewController *destinationViewController;

@end

@implementation BODisclosureTableViewCell

+ (instancetype)cellWithTitle:(NSString *)title destinationViewController:(UIViewController *)destinationViewController {
BODisclosureTableViewCell *cell = [super cellWithTitle:title setting:nil];
cell.destinationViewController = destinationViewController;
return cell;
}

- (void)setup {
self.selectionStyle = UITableViewCellSelectionStyleDefault;
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
[super wasSelectedFromViewController:viewController];
[viewController.navigationController pushViewController:self.destinationViewController animated:YES];
}

@end
17 changes: 17 additions & 0 deletions Bohr/BOSetting+Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// BOSetting+Private.h
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOSetting.h"

@interface BOSetting ()

typedef void(^BOSettingValueDidChangeBlock)(void);

@property (nonatomic, copy) BOSettingValueDidChangeBlock valueDidChangeBlock;

@end
18 changes: 18 additions & 0 deletions Bohr/BOSetting.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// BOSetting.h
// BOSettings
//
// Created by David Román Aguirre on 31/5/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface BOSetting : NSObject

@property (nonatomic, readonly) NSString *key;
@property (nonatomic, assign) id value;

+ (instancetype)settingWithDefaultValue:(id)defaultValue forKey:(NSString *)key;

@end
46 changes: 46 additions & 0 deletions Bohr/BOSetting.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// BOSetting.m
// BOSettings
//
// Created by David Román Aguirre on 31/5/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOSetting+Private.h"

@implementation BOSetting

+ (instancetype)settingWithDefaultValue:(id)defaultValue forKey:(NSString *)key {
return [[self alloc] initWithDefaultValue:defaultValue forKey:key];
}

- (instancetype)initWithDefaultValue:(id)defaultValue forKey:(NSString *)key {
if (self = [super init]) {
_key = key;
[[NSUserDefaults standardUserDefaults] registerDefaults:@{self.key: defaultValue}];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:self.key options:NSKeyValueObservingOptionNew context:nil];
}

return self;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
self.value = change[@"new"];
if (self.valueDidChangeBlock) self.valueDidChangeBlock();
}

- (id)value {
return [[NSUserDefaults standardUserDefaults] objectForKey:self.key];
}

- (void)setValue:(id)value {
if (self.value != value) {
[[NSUserDefaults standardUserDefaults] setObject:value forKey:self.key];
}
}

- (void)dealloc {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:self.key];
}

@end
15 changes: 15 additions & 0 deletions Bohr/BOSwitchTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BOSwitchTableViewCell.h
// Bohr
//
// Created by David Román Aguirre on 4/6/15.
// Copyright (c) 2015 David Roman. All rights reserved.
//

#import "BOTableViewCell.h"

@interface BOSwitchTableViewCell : BOTableViewCell

@property (nonatomic, strong) UISwitch *toggleSwitch;

@end
Loading

0 comments on commit f46e2ec

Please sign in to comment.