flip_the_switch 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +146 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +14 -0
- data/Classes/FlipTheSwitch/FlipTheSwitch.h +9 -0
- data/Classes/FlipTheSwitch/FlipTheSwitch.m +88 -0
- data/Example/.gitignore +2 -0
- data/Example/Colors-iOS/AppDelegateiOS.h +3 -0
- data/Example/Colors-iOS/AppDelegateiOS.m +4 -0
- data/Example/Colors-iOS/Base.lproj/Main_iPhone.storyboard +76 -0
- data/Example/Colors-iOS/Colors-iOS-Info.plist +49 -0
- data/Example/Colors-iOS/Colors-iOS-Prefix.pch +16 -0
- data/Example/Colors-iOS/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/Example/Colors-iOS/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/Example/Colors-iOS/ViewControlleriOS.h +2 -0
- data/Example/Colors-iOS/ViewControlleriOS.m +78 -0
- data/Example/Colors-iOS/main.m +8 -0
- data/Example/Colors.xcodeproj/project.pbxproj +358 -0
- data/Example/Colors.xcodeproj/xcshareddata/xcschemes/Colors-iOS.xcscheme +77 -0
- data/Example/Podfile +4 -0
- data/Example/Rakefile +23 -0
- data/Example/features.yml +2 -0
- data/FlipTheSwitch.podspec +16 -0
- data/Gemfile +17 -0
- data/Guardfile.example +15 -0
- data/LICENSE +21 -0
- data/README.md +104 -0
- data/Rakefile +35 -0
- data/Tests/FlipTheSwitchSpec-Mac/Features.plist +8 -0
- data/Tests/FlipTheSwitchSpec-Mac/FlipTheSwitchSpec-Mac-Info.plist +22 -0
- data/Tests/FlipTheSwitchSpec-Mac/FlipTheSwitchSpec-Mac-Prefix.pch +13 -0
- data/Tests/FlipTheSwitchSpec-iOS/Features.plist +8 -0
- data/Tests/FlipTheSwitchSpec-iOS/FlipTheSwitchSpec-iOS-Info.plist +22 -0
- data/Tests/FlipTheSwitchSpec-iOS/FlipTheSwitchSpec-iOS-Prefix.pch +14 -0
- data/Tests/FlipTheSwitchSpec.xcodeproj/project.pbxproj +605 -0
- data/Tests/FlipTheSwitchSpec.xcodeproj/xcshareddata/xcschemes/FlipTheSwitchSpec-Mac.xcscheme +75 -0
- data/Tests/FlipTheSwitchSpec.xcodeproj/xcshareddata/xcschemes/FlipTheSwitchSpec-iOS.xcscheme +75 -0
- data/Tests/Podfile +15 -0
- data/Tests/Rakefile +22 -0
- data/Tests/Spec/Classes/FlipTheSwitch/FlipTheSwitchSpec.m +88 -0
- data/Tests/Spec/Helpers/GcovTestObserver.h +4 -0
- data/Tests/Spec/Helpers/GcovTestObserver.m +12 -0
- data/bin/flip-the-switch +4 -0
- data/flip_the_switch.gemspec +17 -0
- data/lib/flip_the_switch/cli.rb +61 -0
- data/lib/flip_the_switch/errors.rb +12 -0
- data/lib/flip_the_switch/generator/base.rb +13 -0
- data/lib/flip_the_switch/generator/category.rb +71 -0
- data/lib/flip_the_switch/generator/header.h.erb +11 -0
- data/lib/flip_the_switch/generator/implementation.m.erb +26 -0
- data/lib/flip_the_switch/generator/plist.rb +17 -0
- data/lib/flip_the_switch/generator.rb +3 -0
- data/lib/flip_the_switch/reader/yaml.rb +39 -0
- data/lib/flip_the_switch/reader.rb +1 -0
- data/lib/flip_the_switch.rb +3 -0
- data/spec/flip_the_switch/cli_spec.rb +81 -0
- data/spec/flip_the_switch/generator/category_spec.rb +44 -0
- data/spec/flip_the_switch/generator/plist_spec.rb +19 -0
- data/spec/flip_the_switch/reader/yaml_spec.rb +43 -0
- data/spec/resources/ExpectedFeatures.plist +10 -0
- data/spec/resources/expected_header.h +16 -0
- data/spec/resources/expected_implementation.m +46 -0
- data/spec/resources/invalid_layout/features.yml +4 -0
- data/spec/resources/invalid_type/features.yml +7 -0
- data/spec/resources/real/features.yml +2 -0
- data/spec/spec_helper.rb +15 -0
- metadata +166 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 619f1abd162d81a6bbad84209c1cea55f2b27aa4
|
4
|
+
data.tar.gz: 5fe65dd5282fa538e9d7fae127bed002ad3b5b01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2e7f90c45df40258f8ff75ccae108e4ca54d57f382458b617453d8871eac376846172f232ab1a0a5c2d5832a3cb24d55c4bfa85bc5bb5da26082832f3981b4b
|
7
|
+
data.tar.gz: 6d7949f226ffec6785cadf0c6008ec653b9d0f28ec266c61db17eb92815ae79e941927dfa11cd98c9ad14eaf91f3e62c312cf7fe34cade0db96a209a7ef2391a
|
data/.gitignore
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
#########################
|
2
|
+
# .gitignore file for Xcode4 / OS X Source projects
|
3
|
+
#
|
4
|
+
# Version 2.0
|
5
|
+
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
|
6
|
+
#
|
7
|
+
# 2013 updates:
|
8
|
+
# - fixed the broken "save personal Schemes"
|
9
|
+
#
|
10
|
+
# NB: if you are storing "built" products, this WILL NOT WORK,
|
11
|
+
# and you should use a different .gitignore (or none at all)
|
12
|
+
# This file is for SOURCE projects, where there are many extra
|
13
|
+
# files that we want to exclude
|
14
|
+
#
|
15
|
+
#########################
|
16
|
+
|
17
|
+
#####
|
18
|
+
# Guard
|
19
|
+
Guardfile
|
20
|
+
|
21
|
+
#####
|
22
|
+
# Coveralls
|
23
|
+
.coveralls.yml
|
24
|
+
|
25
|
+
#####
|
26
|
+
# Cocoapods
|
27
|
+
Pods/
|
28
|
+
|
29
|
+
#####
|
30
|
+
# Gems
|
31
|
+
*.gem
|
32
|
+
|
33
|
+
#####
|
34
|
+
# OS X temporary files that should never be committed
|
35
|
+
|
36
|
+
.DS_Store
|
37
|
+
*.swp
|
38
|
+
*.lock
|
39
|
+
profile
|
40
|
+
|
41
|
+
|
42
|
+
####
|
43
|
+
# Xcode temporary files that should never be committed
|
44
|
+
#
|
45
|
+
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...
|
46
|
+
|
47
|
+
*~.nib
|
48
|
+
|
49
|
+
|
50
|
+
####
|
51
|
+
# Xcode build files -
|
52
|
+
#
|
53
|
+
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"
|
54
|
+
|
55
|
+
DerivedData/
|
56
|
+
|
57
|
+
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"
|
58
|
+
|
59
|
+
build/
|
60
|
+
|
61
|
+
|
62
|
+
#####
|
63
|
+
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
|
64
|
+
#
|
65
|
+
# This is complicated:
|
66
|
+
#
|
67
|
+
# SOMETIMES you need to put this file in version control.
|
68
|
+
# Apple designed it poorly - if you use "custom executables", they are
|
69
|
+
# saved in this file.
|
70
|
+
# 99% of projects do NOT use those, so they do NOT want to version control this file.
|
71
|
+
# ..but if you're in the 1%, comment out the line "*.pbxuser"
|
72
|
+
|
73
|
+
*.pbxuser
|
74
|
+
*.mode1v3
|
75
|
+
*.mode2v3
|
76
|
+
*.perspectivev3
|
77
|
+
# NB: also, whitelist the default ones, some projects need to use these
|
78
|
+
!default.pbxuser
|
79
|
+
!default.mode1v3
|
80
|
+
!default.mode2v3
|
81
|
+
!default.perspectivev3
|
82
|
+
|
83
|
+
|
84
|
+
####
|
85
|
+
# Xcode 4 - semi-personal settings
|
86
|
+
#
|
87
|
+
#
|
88
|
+
# OPTION 1: ---------------------------------
|
89
|
+
# throw away ALL personal settings (including custom schemes!
|
90
|
+
# - unless they are "shared")
|
91
|
+
#
|
92
|
+
# NB: this is exclusive with OPTION 2 below
|
93
|
+
xcuserdata
|
94
|
+
|
95
|
+
# OPTION 2: ---------------------------------
|
96
|
+
# get rid of ALL personal settings, but KEEP SOME OF THEM
|
97
|
+
# - NB: you must manually uncomment the bits you want to keep
|
98
|
+
#
|
99
|
+
# NB: this is exclusive with OPTION 1 above
|
100
|
+
#
|
101
|
+
#xcuserdata/**/*
|
102
|
+
|
103
|
+
# (requires option 2 above): Personal Schemes
|
104
|
+
#
|
105
|
+
#!xcuserdata/**/xcschemes/*
|
106
|
+
|
107
|
+
####
|
108
|
+
# XCode 4 workspaces - more detailed
|
109
|
+
#
|
110
|
+
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
|
111
|
+
#
|
112
|
+
# Workspace layout is quite spammy. For reference:
|
113
|
+
#
|
114
|
+
# /(root)/
|
115
|
+
# /(project-name).xcodeproj/
|
116
|
+
# project.pbxproj
|
117
|
+
# /project.xcworkspace/
|
118
|
+
# contents.xcworkspacedata
|
119
|
+
# /xcuserdata/
|
120
|
+
# /(your name)/xcuserdatad/
|
121
|
+
# UserInterfaceState.xcuserstate
|
122
|
+
# /xcsshareddata/
|
123
|
+
# /xcschemes/
|
124
|
+
# (shared scheme name).xcscheme
|
125
|
+
# /xcuserdata/
|
126
|
+
# /(your name)/xcuserdatad/
|
127
|
+
# (private scheme).xcscheme
|
128
|
+
# xcschememanagement.plist
|
129
|
+
#
|
130
|
+
#
|
131
|
+
*.xcworkspace
|
132
|
+
|
133
|
+
####
|
134
|
+
# Xcode 4 - Deprecated classes
|
135
|
+
#
|
136
|
+
# Allegedly, if you manually "deprecate" your classes, they get moved here.
|
137
|
+
#
|
138
|
+
# We're using source-control, so this is a "feature" that we do not want!
|
139
|
+
|
140
|
+
*.moved-aside
|
141
|
+
|
142
|
+
|
143
|
+
####
|
144
|
+
# UNKNOWN: recommended by others, but I can't discover what these files are
|
145
|
+
#
|
146
|
+
# ...none. Everything is now explained.
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --drb --format documentation
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: objective-c
|
2
|
+
before_install:
|
3
|
+
- brew update
|
4
|
+
- brew upgrade xctool
|
5
|
+
- sudo easy_install cpp-coveralls
|
6
|
+
- gem install bundler
|
7
|
+
- bundle install
|
8
|
+
script: bundle exec rake ci
|
9
|
+
after_success: bundle exec rake coverage
|
10
|
+
addons:
|
11
|
+
code_climate:
|
12
|
+
repo_token:
|
13
|
+
secure: OX7DsiC54CWoPd2c2LQ2zI9TNUNGwkXRRPDb1i0pPLHW3YhRnxfLC79R3wXSYHwWfQY4VYDvNL3Kn44XltyZfptPcksSYJFdU2bmA1ppoyEO72CuCAVlFlcbmBfqdLclP4h5pXJdP+euW0QPvl6JpEnIKz+77vVnkLj6jotSL+g=
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# 0.3.0 / 2014-07-02
|
2
|
+
|
3
|
+
* [FEATURE] #15 Auto-create category for features
|
4
|
+
* [FEATURE] #13 Auto-create plist file for features
|
5
|
+
* [FEATURE] #10 Create gem
|
6
|
+
|
7
|
+
# 0.2.0 / 2014-06-06
|
8
|
+
|
9
|
+
* [FEATURE] #9 Allow setting initial feature settings via plist file
|
10
|
+
|
11
|
+
# 0.1.0 / 2014-06-06
|
12
|
+
|
13
|
+
* [FEATURE] #1 Allow in-app feature setting & unsetting
|
14
|
+
* [FEATURE] #2 Persist through app close
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@interface FlipTheSwitch : NSObject
|
2
|
+
- (instancetype)init __attribute__((unavailable("init not available ")));
|
3
|
+
+ (instancetype)sharedInstance;
|
4
|
+
|
5
|
+
- (BOOL)isFeatureEnabled:(NSString *)feature;
|
6
|
+
- (void)enableFeature:(NSString *)feature;
|
7
|
+
- (void)disableFeature:(NSString *)feature;
|
8
|
+
- (void)setFeature:(NSString *)feature enabled:(BOOL)enabled;
|
9
|
+
@end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#import "FlipTheSwitch.h"
|
2
|
+
|
3
|
+
@interface FlipTheSwitch ()
|
4
|
+
@property (nonatomic, readonly) NSUserDefaults *userDefaults;
|
5
|
+
@property (nonatomic, readonly) NSBundle *bundle;
|
6
|
+
@end
|
7
|
+
|
8
|
+
@implementation FlipTheSwitch {
|
9
|
+
NSDictionary *_plistEnabledFeatures;
|
10
|
+
}
|
11
|
+
|
12
|
+
#pragma mark - Singleton
|
13
|
+
|
14
|
+
+ (instancetype)sharedInstance
|
15
|
+
{
|
16
|
+
static FlipTheSwitch *sharedInstance;
|
17
|
+
static dispatch_once_t once;
|
18
|
+
dispatch_once(&once, ^{
|
19
|
+
sharedInstance = [[self alloc] initWithUserDefaults:[NSUserDefaults standardUserDefaults]
|
20
|
+
bundle:[NSBundle mainBundle]];
|
21
|
+
});
|
22
|
+
return sharedInstance;
|
23
|
+
}
|
24
|
+
|
25
|
+
#pragma mark - Initialization
|
26
|
+
|
27
|
+
- (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults
|
28
|
+
bundle:(NSBundle *)bundle
|
29
|
+
{
|
30
|
+
self = [super init];
|
31
|
+
if (self) {
|
32
|
+
NSParameterAssert(userDefaults);
|
33
|
+
NSParameterAssert(bundle);
|
34
|
+
_userDefaults = userDefaults;
|
35
|
+
_bundle = bundle;
|
36
|
+
}
|
37
|
+
return self;
|
38
|
+
}
|
39
|
+
|
40
|
+
#pragma mark - Public
|
41
|
+
|
42
|
+
- (BOOL)isFeatureEnabled:(NSString *)feature
|
43
|
+
{
|
44
|
+
NSNumber *userEnabledFeature = [self.userDefaults objectForKey:[self userKeyForFeature:feature]];
|
45
|
+
if (userEnabledFeature) {
|
46
|
+
return [userEnabledFeature boolValue];
|
47
|
+
} else {
|
48
|
+
return [[[self plistEnabledFeatures] objectForKey:feature] boolValue];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
- (void)enableFeature:(NSString *)feature
|
53
|
+
{
|
54
|
+
[self setFeature:feature enabled:YES];
|
55
|
+
}
|
56
|
+
|
57
|
+
- (void)disableFeature:(NSString *)feature
|
58
|
+
{
|
59
|
+
[self setFeature:feature enabled:NO];
|
60
|
+
}
|
61
|
+
|
62
|
+
- (void)setFeature:(NSString *)feature enabled:(BOOL)enabled
|
63
|
+
{
|
64
|
+
[self.userDefaults setBool:enabled forKey:[self userKeyForFeature:feature]];
|
65
|
+
[self.userDefaults synchronize];
|
66
|
+
}
|
67
|
+
|
68
|
+
#pragma mark - Private
|
69
|
+
|
70
|
+
- (NSString *)userKeyForFeature:(NSString *)feature
|
71
|
+
{
|
72
|
+
return [NSString stringWithFormat:@"FTS_FEATURE_%@", feature];
|
73
|
+
}
|
74
|
+
|
75
|
+
- (NSDictionary *)plistEnabledFeatures
|
76
|
+
{
|
77
|
+
if (!_plistEnabledFeatures) {
|
78
|
+
_plistEnabledFeatures = [[NSDictionary alloc] initWithContentsOfFile:[self featurePlistPath]];
|
79
|
+
}
|
80
|
+
return _plistEnabledFeatures;
|
81
|
+
}
|
82
|
+
|
83
|
+
- (NSString *)featurePlistPath
|
84
|
+
{
|
85
|
+
return [self.bundle pathForResource:@"Features" ofType:@"plist"];
|
86
|
+
}
|
87
|
+
|
88
|
+
@end
|
data/Example/.gitignore
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
|
3
|
+
<dependencies>
|
4
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
|
5
|
+
</dependencies>
|
6
|
+
<scenes>
|
7
|
+
<!--View ControlleriOS-->
|
8
|
+
<scene sceneID="ufC-wZ-h7g">
|
9
|
+
<objects>
|
10
|
+
<viewController id="vXZ-lx-hvc" customClass="ViewControlleriOS" sceneMemberID="viewController">
|
11
|
+
<layoutGuides>
|
12
|
+
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
|
13
|
+
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
|
14
|
+
</layoutGuides>
|
15
|
+
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
|
16
|
+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
17
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
18
|
+
<subviews>
|
19
|
+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="n3c-1r-4pm">
|
20
|
+
<rect key="frame" x="0.0" y="0.0" width="320" height="259"/>
|
21
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
22
|
+
<subviews>
|
23
|
+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hmn-zk-CNu">
|
24
|
+
<rect key="frame" x="88" y="161" width="145" height="30"/>
|
25
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
26
|
+
<state key="normal" title="Change the top color">
|
27
|
+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
28
|
+
</state>
|
29
|
+
<connections>
|
30
|
+
<action selector="topColorChangeButtonTapped" destination="vXZ-lx-hvc" eventType="touchUpInside" id="UDv-XR-9Cr"/>
|
31
|
+
</connections>
|
32
|
+
</button>
|
33
|
+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="The top part of the screen is green" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6sQ-se-sag">
|
34
|
+
<rect key="frame" x="0.0" y="119" width="320" height="21"/>
|
35
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
36
|
+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
37
|
+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
38
|
+
<nil key="highlightedColor"/>
|
39
|
+
</label>
|
40
|
+
</subviews>
|
41
|
+
<color key="backgroundColor" red="0.0" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
42
|
+
</view>
|
43
|
+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7pg-AU-squ">
|
44
|
+
<rect key="frame" x="0.0" y="267" width="320" height="301"/>
|
45
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
46
|
+
<subviews>
|
47
|
+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="The bottom part of the screen is yellow" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l8T-13-b9l">
|
48
|
+
<rect key="frame" x="0.0" y="140" width="320" height="21"/>
|
49
|
+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
50
|
+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
51
|
+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
52
|
+
<nil key="highlightedColor"/>
|
53
|
+
</label>
|
54
|
+
</subviews>
|
55
|
+
<color key="backgroundColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
56
|
+
</view>
|
57
|
+
</subviews>
|
58
|
+
</view>
|
59
|
+
<connections>
|
60
|
+
<outlet property="bottomColorInfoTextView" destination="l8T-13-b9l" id="DVQ-Pv-h5e"/>
|
61
|
+
<outlet property="bottomColorView" destination="7pg-AU-squ" id="V4I-KX-4e3"/>
|
62
|
+
<outlet property="topColorChangeButton" destination="hmn-zk-CNu" id="u6i-up-Bry"/>
|
63
|
+
<outlet property="topColorInfoTextView" destination="6sQ-se-sag" id="ury-Jl-zil"/>
|
64
|
+
<outlet property="topColorView" destination="n3c-1r-4pm" id="zTf-UX-aoz"/>
|
65
|
+
</connections>
|
66
|
+
</viewController>
|
67
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
|
68
|
+
</objects>
|
69
|
+
</scene>
|
70
|
+
</scenes>
|
71
|
+
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
72
|
+
<simulatedStatusBarMetrics key="statusBar"/>
|
73
|
+
<simulatedOrientationMetrics key="orientation"/>
|
74
|
+
<simulatedScreenMetrics key="destination" type="retina4"/>
|
75
|
+
</simulatedMetricsContainer>
|
76
|
+
</document>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>en</string>
|
7
|
+
<key>CFBundleDisplayName</key>
|
8
|
+
<string>${PRODUCT_NAME}</string>
|
9
|
+
<key>CFBundleExecutable</key>
|
10
|
+
<string>${EXECUTABLE_NAME}</string>
|
11
|
+
<key>CFBundleIdentifier</key>
|
12
|
+
<string>com.github.${PRODUCT_NAME:rfc1034identifier}</string>
|
13
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
14
|
+
<string>6.0</string>
|
15
|
+
<key>CFBundleName</key>
|
16
|
+
<string>${PRODUCT_NAME}</string>
|
17
|
+
<key>CFBundlePackageType</key>
|
18
|
+
<string>APPL</string>
|
19
|
+
<key>CFBundleShortVersionString</key>
|
20
|
+
<string>1.0</string>
|
21
|
+
<key>CFBundleSignature</key>
|
22
|
+
<string>????</string>
|
23
|
+
<key>CFBundleVersion</key>
|
24
|
+
<string>1.0</string>
|
25
|
+
<key>LSRequiresIPhoneOS</key>
|
26
|
+
<true/>
|
27
|
+
<key>UIMainStoryboardFile</key>
|
28
|
+
<string>Main_iPhone</string>
|
29
|
+
<key>UIMainStoryboardFile~ipad</key>
|
30
|
+
<string>Main_iPad</string>
|
31
|
+
<key>UIRequiredDeviceCapabilities</key>
|
32
|
+
<array>
|
33
|
+
<string>armv7</string>
|
34
|
+
</array>
|
35
|
+
<key>UISupportedInterfaceOrientations</key>
|
36
|
+
<array>
|
37
|
+
<string>UIInterfaceOrientationPortrait</string>
|
38
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
39
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
40
|
+
</array>
|
41
|
+
<key>UISupportedInterfaceOrientations~ipad</key>
|
42
|
+
<array>
|
43
|
+
<string>UIInterfaceOrientationPortrait</string>
|
44
|
+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
45
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
46
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
47
|
+
</array>
|
48
|
+
</dict>
|
49
|
+
</plist>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// Prefix header
|
3
|
+
//
|
4
|
+
// The contents of this file are implicitly included at the beginning of every source file.
|
5
|
+
//
|
6
|
+
|
7
|
+
#import <Availability.h>
|
8
|
+
|
9
|
+
#ifndef __IPHONE_5_0
|
10
|
+
#warning "This project uses features only available in iOS SDK 5.0 and later."
|
11
|
+
#endif
|
12
|
+
|
13
|
+
#ifdef __OBJC__
|
14
|
+
#import <Foundation/Foundation.h>
|
15
|
+
#import <UIKit/UIKit.h>
|
16
|
+
#endif
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
"images" : [
|
3
|
+
{
|
4
|
+
"idiom" : "iphone",
|
5
|
+
"size" : "29x29",
|
6
|
+
"scale" : "2x"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"idiom" : "iphone",
|
10
|
+
"size" : "40x40",
|
11
|
+
"scale" : "2x"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"idiom" : "iphone",
|
15
|
+
"size" : "60x60",
|
16
|
+
"scale" : "2x"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"idiom" : "ipad",
|
20
|
+
"size" : "29x29",
|
21
|
+
"scale" : "1x"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"idiom" : "ipad",
|
25
|
+
"size" : "29x29",
|
26
|
+
"scale" : "2x"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"idiom" : "ipad",
|
30
|
+
"size" : "40x40",
|
31
|
+
"scale" : "1x"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"idiom" : "ipad",
|
35
|
+
"size" : "40x40",
|
36
|
+
"scale" : "2x"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"idiom" : "ipad",
|
40
|
+
"size" : "76x76",
|
41
|
+
"scale" : "1x"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"idiom" : "ipad",
|
45
|
+
"size" : "76x76",
|
46
|
+
"scale" : "2x"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"info" : {
|
50
|
+
"version" : 1,
|
51
|
+
"author" : "xcode"
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
"images" : [
|
3
|
+
{
|
4
|
+
"orientation" : "portrait",
|
5
|
+
"idiom" : "iphone",
|
6
|
+
"extent" : "full-screen",
|
7
|
+
"minimum-system-version" : "7.0",
|
8
|
+
"scale" : "2x"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"orientation" : "portrait",
|
12
|
+
"idiom" : "iphone",
|
13
|
+
"subtype" : "retina4",
|
14
|
+
"extent" : "full-screen",
|
15
|
+
"minimum-system-version" : "7.0",
|
16
|
+
"scale" : "2x"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"orientation" : "portrait",
|
20
|
+
"idiom" : "ipad",
|
21
|
+
"extent" : "full-screen",
|
22
|
+
"minimum-system-version" : "7.0",
|
23
|
+
"scale" : "1x"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"orientation" : "landscape",
|
27
|
+
"idiom" : "ipad",
|
28
|
+
"extent" : "full-screen",
|
29
|
+
"minimum-system-version" : "7.0",
|
30
|
+
"scale" : "1x"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"orientation" : "portrait",
|
34
|
+
"idiom" : "ipad",
|
35
|
+
"extent" : "full-screen",
|
36
|
+
"minimum-system-version" : "7.0",
|
37
|
+
"scale" : "2x"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"orientation" : "landscape",
|
41
|
+
"idiom" : "ipad",
|
42
|
+
"extent" : "full-screen",
|
43
|
+
"minimum-system-version" : "7.0",
|
44
|
+
"scale" : "2x"
|
45
|
+
}
|
46
|
+
],
|
47
|
+
"info" : {
|
48
|
+
"version" : 1,
|
49
|
+
"author" : "xcode"
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#import "ViewControlleriOS.h"
|
2
|
+
|
3
|
+
#import "FlipTheSwitch+Features.h"
|
4
|
+
|
5
|
+
@interface ViewControlleriOS ()
|
6
|
+
@property (nonatomic, weak) IBOutlet UIView *topColorView;
|
7
|
+
@property (nonatomic, weak) IBOutlet UILabel *topColorInfoTextView;
|
8
|
+
@property (nonatomic, weak) IBOutlet UIButton *topColorChangeButton;
|
9
|
+
@property (nonatomic, weak) IBOutlet UIView *bottomColorView;
|
10
|
+
@property (nonatomic, weak) IBOutlet UILabel *bottomColorInfoTextView;
|
11
|
+
@end
|
12
|
+
|
13
|
+
@implementation ViewControlleriOS
|
14
|
+
|
15
|
+
#pragma mark - UIViewController Lifecycle
|
16
|
+
|
17
|
+
- (void)viewDidLoad
|
18
|
+
{
|
19
|
+
[super viewDidLoad];
|
20
|
+
[self setupView];
|
21
|
+
}
|
22
|
+
|
23
|
+
#pragma mark - Actions
|
24
|
+
|
25
|
+
- (IBAction)topColorChangeButtonTapped
|
26
|
+
{
|
27
|
+
[self toggleRedFeature];
|
28
|
+
}
|
29
|
+
|
30
|
+
#pragma mark - Private
|
31
|
+
|
32
|
+
- (void)setupView
|
33
|
+
{
|
34
|
+
[self setupTopView];
|
35
|
+
[self setupBottomView];
|
36
|
+
}
|
37
|
+
|
38
|
+
- (void)setupTopView
|
39
|
+
{
|
40
|
+
NSString *topColorName;
|
41
|
+
UIColor *topColor;
|
42
|
+
if ([FlipTheSwitch isRedColorEnabled]) {
|
43
|
+
topColorName = @"Red";
|
44
|
+
topColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
45
|
+
} else {
|
46
|
+
topColorName = @"Green";
|
47
|
+
topColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:1];
|
48
|
+
}
|
49
|
+
self.topColorInfoTextView.text = [NSString stringWithFormat:@"The top part of the screen is %@", topColorName];
|
50
|
+
self.topColorView.backgroundColor = topColor;
|
51
|
+
}
|
52
|
+
|
53
|
+
- (void)setupBottomView
|
54
|
+
{
|
55
|
+
NSString *bottomColorName;
|
56
|
+
UIColor *bottomColor;
|
57
|
+
if ([FlipTheSwitch isPurpleColorEnabled]) {
|
58
|
+
bottomColorName = @"Purple";
|
59
|
+
bottomColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:1];
|
60
|
+
} else {
|
61
|
+
bottomColorName = @"Yellow";
|
62
|
+
bottomColor = [UIColor colorWithRed:1 green:1 blue:0 alpha:1];
|
63
|
+
}
|
64
|
+
self.bottomColorInfoTextView.text = [NSString stringWithFormat:@"The bottom part of the screen is %@", bottomColorName];
|
65
|
+
self.bottomColorView.backgroundColor = bottomColor;
|
66
|
+
}
|
67
|
+
|
68
|
+
- (void)toggleRedFeature
|
69
|
+
{
|
70
|
+
if ([FlipTheSwitch isRedColorEnabled]) {
|
71
|
+
[FlipTheSwitch disableRedColor];
|
72
|
+
} else {
|
73
|
+
[FlipTheSwitch enableRedColor];
|
74
|
+
}
|
75
|
+
[self setupView];
|
76
|
+
}
|
77
|
+
|
78
|
+
@end
|