├── .gitignore ├── Chrysalis.plist ├── Global.h ├── Global.x ├── LICENSE ├── Makefile ├── README.md ├── Screenshots ├── darkmode.png └── regular.png ├── TBCSAppSwitcherCollectionViewCell.h ├── TBCSAppSwitcherCollectionViewCell.x ├── TBCSAppSwitcherManager.h ├── TBCSAppSwitcherManager.x ├── TBCSAppSwitcherViewController.h ├── TBCSAppSwitcherViewController.x ├── TBCSDisplayItem.h ├── TBCSDisplayItem.x ├── TBCSPreferencesManager.h ├── TBCSPreferencesManager.m ├── TBCSTutorialViewController.h ├── TBCSTutorialViewController.x ├── TBCSWindow.h ├── TBCSWindow.x ├── Tweak.xm ├── control └── prefs ├── Makefile ├── Resources ├── About.plist ├── Advanced.plist ├── Info.plist ├── Root.plist ├── advanced.png ├── advanced@2x.png ├── advanced@3x.png ├── darkmode.png ├── darkmode@2x.png ├── darkmode@3x.png ├── enable.png ├── enable@2x.png ├── enable@3x.png ├── fonts │ ├── Billy.ttf │ └── Nexa.otf ├── footerLogo.png ├── footerLogo@2x.png ├── footerLogo@3x.png ├── headerImage-568h@2x.png ├── headerImage.png ├── headerImage@2x.png ├── headerImage@3x.png ├── headerLogo.png ├── headerLogo@2x.png ├── headerLogo@3x.png ├── home-dark.png ├── home-dark@2x.png ├── home-dark@3x.png ├── home-light.png ├── home-light@2x.png ├── home-light@3x.png ├── home.png ├── home@2x.png ├── home@3x.png ├── icon.png ├── icon@2x.png ├── icon@3x.png ├── kill.png ├── kill@2x.png ├── kill@3x.png ├── makers.png ├── makers@2x.png ├── makers@3x.png ├── name.png ├── name@2x.png ├── name@3x.png ├── position.png ├── position@2x.png ├── position@3x.png ├── preview.png ├── preview@2x.png ├── preview@3x.png ├── support.png ├── support@2x.png ├── support@3x.png ├── x.png ├── x@2x.png └── x@3x.png ├── TBCSAboutCreatorView.h ├── TBCSAboutCreatorView.m ├── TBCSAboutHeaderView.h ├── TBCSAboutHeaderView.m ├── TBCSAboutListController.h ├── TBCSAboutListController.m ├── TBCSAdvancedBackgroundGradientView.h ├── TBCSAdvancedBackgroundGradientView.m ├── TBCSAdvancedListController.h ├── TBCSAdvancedListController.x ├── TBCSRootListController.h ├── TBCSRootListController.m └── entry.plist /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .theos 3 | debs 4 | -------------------------------------------------------------------------------- /Chrysalis.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /Global.h: -------------------------------------------------------------------------------- 1 | extern NSBundle *bundle; 2 | -------------------------------------------------------------------------------- /Global.x: -------------------------------------------------------------------------------- 1 | NSBundle *bundle; 2 | 3 | %ctor { 4 | bundle = [[NSBundle bundleWithPath:@"/Library/PreferenceBundles/ChrysalisPrefs.bundle"] retain]; 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | TWEAK_NAME = Chrysalis 4 | Chrysalis_FILES = Tweak.xm $(wildcard *.x) $(wildcard *.m) 5 | Chrysalis_PRIVATE_FRAMEWORKS = FrontBoard 6 | Chrysalis_EXTRA_FRAMEWORKS = Cephei 7 | Chrysalis_CFLAGS = -include Global.h 8 | 9 | include $(THEOS_MAKE_PATH)/tweak.mk 10 | 11 | after-install:: 12 | ifeq ($(RESPRING),0) 13 | install.exec "killall Preferences" 14 | else 15 | install.exec spring 16 | endif 17 | 18 | SUBPROJECTS += prefs 19 | include $(THEOS_MAKE_PATH)/aggregate.mk 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chrysalis 2 | Ben, CPDigitalDarkroom, kirb, and veerklempt. 3 | 4 | This is our project for Tweak Battles #3. Chrysalis has been submitted and will be out on BigBoss next week. This package depends on [Cephei](https://github.com/hbang/libcephei). 5 | 6 | Chrysalis was designed from a vision of a better 3D Touch app switcher, and to bring a convenient app switching gesture to older devices. There has never been an easier way to switch your apps efficiently before Chrysalis. Simply force press on the left edge of the screen, and Chrysalis will create an elegant new experience for you. Drag your finger to the app you would like to switch to and let go. That’s it! 7 | 8 | Built from the ground up with lots of love, to not just be an immersive experience, but it was also built for a good cause. We made this tweak as part of the [Tweak Battles competition](http://www.tweakbattles.com/), where almost $1,000 was raised for charity. 9 | 10 | We hope you enjoy the convenience of Chrysalis, as much as we did making it. 11 | 12 | We've put a ton of work into this tweak and we hope you love it! 13 | 14 | # Functionality 15 | 16 | Chrysalis is a 3d-touch based app switcher. It's also completely gesture based. From the left of your screen, press firmly (or slide if you aren't on a 3d touch supported device) and the app switcher will show, where you can slide your finger and let go on an app, which will open it. The app switcher also has customization such as a dark mode. 17 | 18 | # Screenshots 19 | 20 | | Regular | Dark Mode | 21 | |-------------------------------------------------------------------------------------------- |--------------------------------------------------------------------------------------------- | 22 | | ![](https://raw.githubusercontent.com/benrosen78/chrysalis/master/Screenshots/regular.png) | ![](https://raw.githubusercontent.com/benrosen78/chrysalis/master/Screenshots/darkmode.png) | 23 | 24 | # Thanks 25 | 26 | Thank you so much to @twodayslate for putting together tweak battles. Thank you @veerklempt for designing Chrysalis. 27 | 28 | Thanks to the amazing supporters of tweak battles. Their names are as follows: 29 | 30 | @redzrex, Boris S, @twodayslate, Eric, Borsato92, cj81499, mootjeuh, Ziph0n, /u/DervishSkater, Corporal, Pixxaddict, Matteo Piccina, josh\_boothman, Moshe Siegel, Ian L, @rauseo12, wizage, RushNY, @BrianOverly, @thetomcanuck, winlogon0, Jason R., CONATH, JimDotR, Andrew, Acidschnee, Cody, Connor, Shadow Games, echo000, Jonathan Gautreau , Blink, ShaneSparkyYYZ, kamikasky, MaxD, @tilgut, Torben, MeatyCheetos, Lei33, K S LEE, @RichResk, @sekrit\_, Maortega89, @frkbmb\_, Kyle, Robert, @pwned24k, OhSpazz, Jessyreynosa3, Jessie mejia, Jp\_delon, dantesieg, @codsane, Alex S., Spencer, HHumbert 31 | 32 | And a special thanks to the following diamond supporters! You're very generous and we appreciate that. 33 | 34 | Josh Gibson, @sel2by3, platypusw90, @Beezure 35 | 36 | 37 | # License 38 | Open sourced under the [Apache 2.0 License](https://github.com/benrosen78/chrysalis/blob/master/LICENSE). 39 | 40 | Copyright (C) 2015 Ben Rosen, Carlos Perez, Adam Demasi, Anh Nguyen 41 | 42 | Chrysalis—A 3d touch-based app switcher 43 | 44 | Licensed under the Apache License, Version 2.0 (the "License"); 45 | you may not use this file except in compliance with the License. 46 | You may obtain a copy of the License at 47 | 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | 50 | Unless required by applicable law or agreed to in writing, software 51 | distributed under the License is distributed on an "AS IS" BASIS, 52 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | See the License for the specific language governing permissions and 54 | limitations under the License. 55 | -------------------------------------------------------------------------------- /Screenshots/darkmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/Screenshots/darkmode.png -------------------------------------------------------------------------------- /Screenshots/regular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/Screenshots/regular.png -------------------------------------------------------------------------------- /TBCSAppSwitcherCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | @class TBCSDisplayItem; 2 | 3 | @interface TBCSAppSwitcherCollectionViewCell : UICollectionViewCell 4 | 5 | @property (nonatomic, retain) TBCSDisplayItem *displayItem; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /TBCSAppSwitcherCollectionViewCell.x: -------------------------------------------------------------------------------- 1 | #import "TBCSAppSwitcherCollectionViewCell.h" 2 | #import "TBCSDisplayItem.h" 3 | #import "TBCSPreferencesManager.h" 4 | #import 5 | 6 | @implementation TBCSAppSwitcherCollectionViewCell { 7 | TBCSDisplayItem *_displayItem; 8 | UIImageView *_appIconImageView; 9 | } 10 | 11 | - (instancetype)initWithFrame:(CGRect)frame { 12 | if (self = [super initWithFrame:frame]) { 13 | _appIconImageView = [[UIImageView alloc] init]; 14 | _appIconImageView.frame = CGRectMake(0, 0, 55.0, 55.0); 15 | _appIconImageView.center = self.contentView.center; 16 | _appIconImageView.layer.shadowColor = [UIColor darkGrayColor].CGColor; 17 | _appIconImageView.layer.shadowOffset = CGSizeMake(0.5, 0.5); 18 | _appIconImageView.layer.shadowOpacity = 0.5; 19 | _appIconImageView.layer.shadowRadius = 0.5; 20 | _appIconImageView.clipsToBounds = NO; 21 | 22 | [self.contentView addSubview:_appIconImageView]; 23 | } 24 | return self; 25 | } 26 | 27 | - (TBCSDisplayItem *)displayItem { 28 | return _displayItem; 29 | } 30 | 31 | - (void)setDisplayItem:(TBCSDisplayItem *)displayItem { 32 | if ([displayItem.type isEqualToString:@"Homescreen"]) { 33 | // if it‘s the home screen icon, we have our own icon for that 34 | BOOL darkMode = [TBCSPreferencesManager sharedInstance].darkMode; 35 | _appIconImageView.image = [[UIImage imageNamed:darkMode ? @"home-dark" : @"home-light" inBundle:bundle] _applicationIconImageForFormat:MIIconVariantDefault precomposed:YES scale:[[UIScreen mainScreen] scale]]; 36 | } else { 37 | // get the app’s icon 38 | _appIconImageView.image = [UIImage _applicationIconImageForBundleIdentifier:displayItem.displayIdentifier format:MIIconVariantDefault scale:[[UIScreen mainScreen] scale]]; 39 | } 40 | } 41 | 42 | #pragma mark - Memory management 43 | 44 | - (void)dealloc { 45 | [_appIconImageView release]; 46 | 47 | [super dealloc]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /TBCSAppSwitcherManager.h: -------------------------------------------------------------------------------- 1 | @class TBCSDisplayItem; 2 | 3 | @interface TBCSAppSwitcherManager : NSObject 4 | 5 | + (NSMutableArray *)displayItems; 6 | + (void)quitAllApps; 7 | + (void)suspend; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /TBCSAppSwitcherManager.x: -------------------------------------------------------------------------------- 1 | #import "TBCSAppSwitcherManager.h" 2 | #import "TBCSDisplayItem.h" 3 | #import 4 | #import 5 | #import 6 | 7 | @interface SBDisplayItem : NSObject { 8 | NSString *_displayIdentifier; 9 | } 10 | 11 | + (instancetype)displayItemWithType:(NSString *)type displayIdentifier:(NSString *)identifier; 12 | 13 | @end 14 | 15 | @interface SBAppSwitcherModel : NSObject 16 | 17 | + (instancetype)sharedInstance; 18 | 19 | - (NSArray *)mainSwitcherDisplayItems; 20 | - (void)remove:(SBDisplayItem *)displayItem; 21 | 22 | @end 23 | 24 | @implementation TBCSAppSwitcherManager 25 | 26 | + (NSMutableArray *)displayItems { 27 | NSArray *sbDisplayItems = ((SBAppSwitcherModel *)[%c(SBAppSwitcherModel) sharedInstance]).mainSwitcherDisplayItems; 28 | NSMutableArray *displayItems = [NSMutableArray array]; 29 | 30 | for (SBDisplayItem *displayItem in sbDisplayItems) { 31 | [displayItems addObject:[TBCSDisplayItem displayItemWithSBDisplayItem:displayItem]]; 32 | } 33 | 34 | SpringBoard *app = (SpringBoard *)[UIApplication sharedApplication]; 35 | 36 | // if we’re in an app, it’ll be at position 0. remove it 37 | if (app._accessibilityFrontMostApplication) { 38 | [displayItems removeObjectAtIndex:0]; 39 | } 40 | 41 | return displayItems; 42 | } 43 | 44 | + (void)quitAllApps { 45 | for (TBCSDisplayItem *displayItem in self.displayItems) { 46 | [[%c(SBAppSwitcherModel) sharedInstance] remove:displayItem.sbDisplayItem]; 47 | } 48 | } 49 | 50 | + (void)suspend { 51 | SpringBoard *app = (SpringBoard *)[UIApplication sharedApplication]; 52 | SBApplication *frontmostApp = app._accessibilityFrontMostApplication; 53 | 54 | if (frontmostApp) { 55 | [[%c(SBApplicationController) sharedInstance] applicationService:nil suspendApplicationWithBundleIdentifier:frontmostApp.bundleIdentifier]; 56 | } 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /TBCSAppSwitcherViewController.h: -------------------------------------------------------------------------------- 1 | @interface TBCSAppSwitcherViewController : UIViewController 2 | 3 | @property (nonatomic) BOOL useDemoApps; 4 | 5 | - (void)updateViewToNewPoint:(CGPoint)point; 6 | 7 | - (void)openAppAtPoint:(CGPoint)point; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /TBCSAppSwitcherViewController.x: -------------------------------------------------------------------------------- 1 | #import "TBCSAppSwitcherViewController.h" 2 | #import "TBCSAppSwitcherCollectionViewCell.h" 3 | #import "TBCSAppSwitcherManager.h" 4 | #import "TBCSDisplayItem.h" 5 | #import "TBCSPreferencesManager.h" 6 | #import 7 | #import 8 | #import 9 | 10 | static NSString *const kTBCSAppSwitcherCollectionViewCellIdentifier = @"ChrysalisAppSwitcherCell"; 11 | 12 | @implementation TBCSAppSwitcherViewController { 13 | NSArray *_displayItems; 14 | 15 | UIVisualEffectView *_blurEffectView; 16 | UICollectionView *_collectionView; 17 | UIView *_slidingIndicatorView; 18 | UILabel *_noAppsLabel; 19 | 20 | UIView *_closeButtonContainerView; 21 | UIView *_dividerView; 22 | UIImageView *_closeAppsImageView; 23 | 24 | CAShapeLayer *_chevronPathMaskLayer; 25 | CAShapeLayer *_rectanglePathMaskLayer; 26 | CAGradientLayer *_gradientLayer; 27 | NSLayoutConstraint *_closeButtonConstraint; 28 | 29 | BOOL _showHomeScreenButton; 30 | } 31 | 32 | #pragma mark - UIViewController 33 | 34 | - (void)loadView { 35 | [super loadView]; 36 | 37 | UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:[TBCSPreferencesManager sharedInstance].blurEffectStyle]; 38 | _blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 39 | _blurEffectView.translatesAutoresizingMaskIntoConstraints = NO; 40 | [self.view addSubview:_blurEffectView]; 41 | 42 | CALayer *containerLayer = [CALayer layer]; 43 | 44 | // chevron 45 | 46 | UIBezierPath *chevronBezierPath = [UIBezierPath bezierPath]; 47 | [chevronBezierPath moveToPoint: CGPointMake(1.5, 45.68)]; 48 | [chevronBezierPath addCurveToPoint: CGPointMake(29.5, 6.68) controlPoint1: CGPointMake(1.5, 35.98) controlPoint2: CGPointMake(29.5, 38.68)]; 49 | [chevronBezierPath addCurveToPoint: CGPointMake(29.5, 87.68) controlPoint1: CGPointMake(29.5, -25.32) controlPoint2: CGPointMake(29.5, 121.98)]; 50 | [chevronBezierPath addCurveToPoint: CGPointMake(1.5, 45.68) controlPoint1: CGPointMake(29.5, 53.38) controlPoint2: CGPointMake(1.5, 55.38)]; 51 | [chevronBezierPath closePath]; 52 | chevronBezierPath.miterLimit = 4; 53 | 54 | [chevronBezierPath applyTransform:CGAffineTransformMakeScale(0.5, 0.5)]; 55 | [chevronBezierPath fill]; 56 | 57 | _chevronPathMaskLayer = [[CAShapeLayer alloc] init]; 58 | _chevronPathMaskLayer.path = chevronBezierPath.CGPath; 59 | [containerLayer addSublayer:_chevronPathMaskLayer]; 60 | 61 | // rectangle 62 | 63 | _rectanglePathMaskLayer = [[CAShapeLayer alloc] init]; 64 | 65 | UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(14, 0, self.view.frame.size.width-14, self.view.frame.size.height) byRoundingCorners:( UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(9.0, 9.0)]; 66 | [rectanglePath fill]; 67 | _rectanglePathMaskLayer.path = rectanglePath.CGPath; 68 | [containerLayer addSublayer:_rectanglePathMaskLayer]; 69 | 70 | _blurEffectView.layer.mask = containerLayer; 71 | 72 | // other views 73 | 74 | _slidingIndicatorView = [[UIView alloc] init]; 75 | _slidingIndicatorView.frame = CGRectMake(17.5, 0.0, 65.0, 65.0); 76 | _slidingIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 77 | _slidingIndicatorView.center = CGPointMake(_slidingIndicatorView.center.x, self.view.center.y); 78 | _slidingIndicatorView.alpha = 0.4; 79 | _slidingIndicatorView.backgroundColor = [UIColor whiteColor]; 80 | _slidingIndicatorView.layer.masksToBounds = YES; 81 | _slidingIndicatorView.layer.cornerRadius = 18.0; 82 | [self.view addSubview:_slidingIndicatorView]; 83 | 84 | UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; 85 | flowLayout.itemSize = CGSizeMake(70.0, 70.0); 86 | flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; 87 | flowLayout.minimumInteritemSpacing = 0; 88 | flowLayout.minimumLineSpacing = 0; 89 | 90 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; 91 | _collectionView.translatesAutoresizingMaskIntoConstraints = NO; 92 | _collectionView.backgroundColor = [UIColor clearColor]; 93 | _collectionView.delegate = self; 94 | _collectionView.dataSource = self; 95 | _collectionView.scrollEnabled = NO; 96 | [_collectionView registerClass:[TBCSAppSwitcherCollectionViewCell class] forCellWithReuseIdentifier:kTBCSAppSwitcherCollectionViewCellIdentifier]; 97 | [self.view addSubview:_collectionView]; 98 | 99 | _gradientLayer = [[CAGradientLayer alloc] init]; 100 | _gradientLayer.startPoint = CGPointMake(0.0, 0.5); 101 | _gradientLayer.endPoint = CGPointMake(1.0, 0.5); 102 | _gradientLayer.colors = @[(id)[UIColor blackColor].CGColor, (id)[UIColor clearColor].CGColor]; 103 | _gradientLayer.locations = @[@0.93, @1.0]; 104 | _collectionView.layer.mask = _gradientLayer; 105 | 106 | _noAppsLabel = [[UILabel alloc] init]; 107 | _noAppsLabel.translatesAutoresizingMaskIntoConstraints = NO; 108 | _noAppsLabel.text = @"no apps"; 109 | _noAppsLabel.textAlignment = NSTextAlignmentCenter; 110 | _noAppsLabel.alpha = 0.6; 111 | _noAppsLabel.font = [UIFont systemFontOfSize:30.0]; 112 | [_collectionView addSubview:_noAppsLabel]; 113 | 114 | _closeButtonContainerView = [[UIView alloc] init]; 115 | _closeButtonContainerView.translatesAutoresizingMaskIntoConstraints = NO; 116 | [self.view addSubview:_closeButtonContainerView]; 117 | 118 | _dividerView = [[UIView alloc] init]; 119 | _dividerView.translatesAutoresizingMaskIntoConstraints = NO; 120 | _dividerView.alpha = 0.45; 121 | _dividerView.backgroundColor = [UIColor whiteColor]; 122 | [_closeButtonContainerView addSubview:_dividerView]; 123 | 124 | _closeAppsImageView = [[UIImageView alloc] init]; 125 | _closeAppsImageView.translatesAutoresizingMaskIntoConstraints = NO; 126 | _closeAppsImageView.image = [UIImage imageNamed:@"x" inBundle:[NSBundle bundleWithPath:@"/Library/PreferenceBundles/ChrysalisPrefs.bundle"]]; 127 | _closeAppsImageView.alpha = 0.45; 128 | _closeAppsImageView.contentMode = UIViewContentModeCenter; 129 | [_closeButtonContainerView addSubview:_closeAppsImageView]; 130 | 131 | // auto layout 132 | 133 | NSDictionary *views = @{ 134 | @"self": self.view, 135 | @"blurEffectView": _blurEffectView, 136 | @"collectionView": _collectionView, 137 | @"dividerView": _dividerView, 138 | @"closeAppsImageView": _closeAppsImageView, 139 | @"closeButtonContainerView": _closeButtonContainerView, 140 | @"noAppsLabel": _noAppsLabel 141 | }; 142 | 143 | [self.view hb_addCompactConstraints:@[ 144 | @"blurEffectView.left = self.left", 145 | @"blurEffectView.right = self.right", 146 | @"blurEffectView.top = self.top", 147 | @"blurEffectView.bottom = self.bottom", 148 | 149 | @"collectionView.top = self.top", 150 | @"collectionView.bottom = self.bottom", 151 | 152 | @"noAppsLabel.left = collectionView.left", 153 | @"noAppsLabel.right = collectionView.right", 154 | @"noAppsLabel.top = collectionView.top", 155 | @"noAppsLabel.bottom = collectionView.bottom", 156 | 157 | @"closeButtonContainerView.top = self.top", 158 | @"closeButtonContainerView.bottom = self.bottom", 159 | ] metrics:nil views:views]; 160 | 161 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[collectionView][closeButtonContainerView]|" options:kNilOptions metrics:nil views:views]]; 162 | 163 | [_closeButtonContainerView hb_addCompactConstraints:@[ 164 | @"dividerView.top = closeButtonContainerView.top", 165 | @"dividerView.bottom = closeButtonContainerView.bottom", 166 | 167 | @"closeAppsImageView.top = closeButtonContainerView.top", 168 | @"closeAppsImageView.bottom = closeButtonContainerView.bottom", 169 | ] metrics:nil views:views]; 170 | 171 | [_closeButtonContainerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[dividerView(==0.5)][closeAppsImageView(==45)]|" options:kNilOptions metrics:nil views:views]]; 172 | 173 | // prefs 174 | 175 | [self configurePreferences]; 176 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configurePreferences) name:HBPreferencesDidChangeNotification object:[TBCSPreferencesManager sharedInstance].preferences]; 177 | } 178 | 179 | - (void)viewWillAppear:(BOOL)animated { 180 | [super viewWillAppear:animated]; 181 | 182 | [self _updateAppsInSwitcher]; 183 | [self configurePreferences]; 184 | } 185 | 186 | - (void)viewWillLayoutSubviews { 187 | [super viewWillLayoutSubviews]; 188 | 189 | _gradientLayer.frame = self.view.bounds; 190 | 191 | _chevronPathMaskLayer.frame = CGRectMake(0, self.view.frame.size.height/2-25, 14, 34); 192 | _rectanglePathMaskLayer.frame = self.view.bounds; 193 | 194 | UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(14, 0, self.view.frame.size.width-14, self.view.frame.size.height) byRoundingCorners:( UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(9.0, 9.0)]; 195 | [rectanglePath fill]; 196 | 197 | _rectanglePathMaskLayer.path = rectanglePath.CGPath; 198 | } 199 | 200 | #pragma mark - Collection View Delegate 201 | 202 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 203 | TBCSAppSwitcherCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kTBCSAppSwitcherCollectionViewCellIdentifier forIndexPath:indexPath]; 204 | cell.displayItem = _displayItems[indexPath.row]; 205 | return cell; 206 | } 207 | 208 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 209 | return [_displayItems count]; 210 | } 211 | 212 | #pragma mark - Update 213 | 214 | - (void)_updateAppsInSwitcher { 215 | [_displayItems release]; 216 | 217 | NSMutableArray *displayItems = [NSMutableArray array]; 218 | 219 | if (_useDemoApps) { 220 | // fill in standard example apps to display in demo situations 221 | for (NSString *identifier in @[ @"com.apple.mobilemail", @"com.apple.AppStore", @"com.apple.Music", @"com.apple.mobilenotes", @"com.apple.mobileslideshow", @"com.apple.mobilesafari", @"com.apple.Preferences" ]) { 222 | [displayItems addObject:[TBCSDisplayItem displayItemWithType:@"App" displayIdentifier:identifier]]; 223 | } 224 | } else { 225 | // get the list of apps 226 | displayItems = [TBCSAppSwitcherManager displayItems]; 227 | } 228 | 229 | if (_showHomeScreenButton && (_useDemoApps || ((SpringBoard *)[UIApplication sharedApplication])._accessibilityFrontMostApplication)) { 230 | [displayItems insertObject:[TBCSDisplayItem homeScreenDisplayItem] atIndex:0]; 231 | } 232 | 233 | _displayItems = [displayItems copy]; 234 | 235 | // reload the collection view 236 | [_collectionView reloadData]; 237 | 238 | // do we have any apps open? 239 | if (_displayItems.count > 0) { 240 | // if so, we can hide the label, show the sliding indicator 241 | _noAppsLabel.hidden = YES; 242 | _slidingIndicatorView.hidden = NO; 243 | } else { 244 | // otherwise, we want the opposite 245 | _noAppsLabel.hidden = NO; 246 | _slidingIndicatorView.hidden = YES; 247 | } 248 | } 249 | 250 | #pragma mark - Gesture 251 | 252 | - (BOOL)_isPointOutOfBounds:(CGPoint)point { 253 | UIView *superview = self.view.superview; 254 | 255 | CGFloat top = superview.frame.origin.y; 256 | CGFloat bottom = top + superview.frame.size.height; 257 | 258 | return point.y < top - 150.f || point.y > bottom + 200.f; 259 | } 260 | 261 | - (NSUInteger)_indexForPoint:(CGPoint)point contentOffset:(CGPoint)contentOffset { 262 | // from the point of the finger, get the index of the icon 263 | // the last 45pt are reserved for the close apps button 264 | // TODO: support contentOffset 265 | if (point.x > self.view.frame.size.width - 45.0 && !_closeButtonContainerView.hidden) { 266 | return NSUIntegerMax; 267 | } else { 268 | return roundf((point.x - 50.0) / 70.0); 269 | } 270 | } 271 | 272 | - (void)updateViewToNewPoint:(CGPoint)point { 273 | NSUInteger index = [self _indexForPoint:point contentOffset:CGPointZero]; 274 | CGRect potentialFrame = _slidingIndicatorView.frame; 275 | 276 | if ([self _isPointOutOfBounds:point]) { 277 | potentialFrame.origin.x += potentialFrame.size.width / 2; 278 | potentialFrame.origin.y += potentialFrame.size.height / 2; 279 | potentialFrame.size.width = 0; 280 | potentialFrame.size.height = 0; 281 | } else if (index == NSUIntegerMax) { 282 | potentialFrame = CGRectMake(self.view.frame.size.width - 40, 0, 35, 35); 283 | } else if (index < _displayItems.count) { 284 | potentialFrame = CGRectMake((index * 70.0) + 17.5, 0, 65, 65); 285 | } 286 | 287 | [UIView animateWithDuration:0.3 delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:15.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ 288 | _slidingIndicatorView.frame = potentialFrame; 289 | _slidingIndicatorView.center = CGPointMake(_slidingIndicatorView.center.x, self.view.center.y); 290 | } completion:nil]; 291 | } 292 | 293 | - (void)openAppAtPoint:(CGPoint)point { 294 | if ([self _isPointOutOfBounds:point]) { 295 | return; 296 | } 297 | 298 | NSUInteger index = [self _indexForPoint:point contentOffset:CGPointZero]; 299 | 300 | if (index == NSUIntegerMax) { 301 | [TBCSAppSwitcherManager quitAllApps]; 302 | 303 | for (UICollectionViewCell *cell in _collectionView.visibleCells) { 304 | UIView *view = cell.contentView; 305 | [UIView animateWithDuration:0.2 delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:15.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ 306 | view.transform = CGAffineTransformMakeScale(0.15, 0.15); 307 | view.alpha = 0.0; 308 | } completion:^(BOOL completion) { 309 | view.transform = CGAffineTransformIdentity; 310 | view.alpha = 1.0; 311 | }]; 312 | } 313 | 314 | return; 315 | } else if (index == 0 && _showHomeScreenButton) { 316 | [TBCSAppSwitcherManager suspend]; 317 | } else if (_displayItems.count > index) { 318 | TBCSDisplayItem *displayItem = _displayItems[index]; 319 | [(SpringBoard *)[UIApplication sharedApplication] launchApplicationWithIdentifier:displayItem.displayIdentifier suspended:NO]; 320 | } 321 | } 322 | 323 | #pragma mark - Preferences 324 | 325 | - (void)configurePreferences { 326 | TBCSPreferencesManager *preferences = [TBCSPreferencesManager sharedInstance]; 327 | 328 | _showHomeScreenButton = preferences.showHomeScreenButton; 329 | 330 | _closeButtonContainerView.hidden = !preferences.showQuitAppsButton; 331 | 332 | if (_closeButtonContainerView.hidden) { 333 | _closeButtonConstraint = [NSLayoutConstraint hb_compactConstraint:@"self.width = 0" metrics:nil views:nil self:_closeButtonContainerView]; 334 | [_closeButtonContainerView addConstraint:_closeButtonConstraint]; 335 | } else if (_closeButtonConstraint) { 336 | [_closeButtonContainerView removeConstraint:_closeButtonConstraint]; 337 | [_closeButtonConstraint release]; 338 | _closeButtonConstraint = nil; 339 | } 340 | 341 | [UIView animateWithDuration:1 animations:^{ 342 | _blurEffectView.effect = [UIBlurEffect effectWithStyle:[TBCSPreferencesManager sharedInstance].blurEffectStyle]; 343 | 344 | _dividerView.alpha = 0.0; 345 | _closeAppsImageView.alpha = 0.0; 346 | }]; 347 | 348 | UIColor *selectedColor = preferences.darkMode ? [UIColor whiteColor] : [UIColor blackColor]; 349 | _dividerView.backgroundColor = selectedColor; 350 | _closeAppsImageView.image = [_closeAppsImageView.image _flatImageWithColor:selectedColor]; 351 | 352 | [UIView animateWithDuration:0.5 animations:^{ 353 | _dividerView.alpha = 0.45; 354 | _closeAppsImageView.alpha = 0.45; 355 | }]; 356 | 357 | [self _updateAppsInSwitcher]; 358 | } 359 | 360 | #pragma mark - Memory management 361 | 362 | - (void)dealloc { 363 | [_displayItems release]; 364 | 365 | [_blurEffectView release]; 366 | [_collectionView release]; 367 | [_slidingIndicatorView release]; 368 | [_noAppsLabel release]; 369 | 370 | [_closeButtonContainerView release]; 371 | [_dividerView release]; 372 | [_closeAppsImageView release]; 373 | 374 | [_chevronPathMaskLayer release]; 375 | [_rectanglePathMaskLayer release]; 376 | [_gradientLayer release]; 377 | [_closeButtonConstraint release]; 378 | 379 | [super dealloc]; 380 | } 381 | 382 | @end 383 | -------------------------------------------------------------------------------- /TBCSDisplayItem.h: -------------------------------------------------------------------------------- 1 | @class SBDisplayItem; 2 | 3 | @interface TBCSDisplayItem : NSObject 4 | 5 | + (instancetype)displayItemWithSBDisplayItem:(SBDisplayItem *)displayItem; 6 | + (instancetype)displayItemWithType:(NSString *)type displayIdentifier:(NSString *)displayIdentifier; 7 | + (instancetype)homeScreenDisplayItem; 8 | 9 | - (instancetype)initWithType:(NSString *)type displayIdentifier:(NSString *)displayIdentifier; 10 | 11 | - (SBDisplayItem *)sbDisplayItem; 12 | 13 | @property (readonly, copy, nonatomic) NSString *displayIdentifier; 14 | @property (readonly, copy, nonatomic) NSString *type; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /TBCSDisplayItem.x: -------------------------------------------------------------------------------- 1 | #import "TBCSDisplayItem.h" 2 | #import 3 | #import 4 | 5 | @implementation TBCSDisplayItem 6 | 7 | + (instancetype)displayItemWithSBDisplayItem:(SBDisplayItem *)displayItem { 8 | if (!%c(SBDisplayItem)) { 9 | return nil; 10 | } 11 | 12 | return [self displayItemWithType:displayItem.type displayIdentifier:displayItem.displayIdentifier]; 13 | } 14 | 15 | + (instancetype)displayItemWithType:(NSString *)type displayIdentifier:(NSString *)displayIdentifier { 16 | return [[[self alloc] initWithType:type displayIdentifier:displayIdentifier] autorelease]; 17 | } 18 | 19 | + (instancetype)homeScreenDisplayItem { 20 | return [self displayItemWithType:@"Homescreen" displayIdentifier:FBSystemAppBundleID()]; 21 | } 22 | 23 | - (instancetype)initWithType:(NSString *)type displayIdentifier:(NSString *)displayIdentifier { 24 | self = [self init]; 25 | 26 | if (self) { 27 | _type = [type copy]; 28 | _displayIdentifier = [displayIdentifier copy]; 29 | } 30 | 31 | return self; 32 | } 33 | 34 | - (SBDisplayItem *)sbDisplayItem { 35 | if (!%c(SBDisplayItem)) { 36 | return nil; 37 | } 38 | 39 | return [%c(SBDisplayItem) displayItemWithType:self.type displayIdentifier:self.displayIdentifier]; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /TBCSPreferencesManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | static NSString *const kTBCSPreferencesManagerHadFirstRunKey = @"HadFirstRun"; 4 | static NSString *const kTBCSPreferencesManagerDarkModeKey = @"DarkMode"; 5 | static NSString *const kTBCSPreferencesManagerQuitAppsButtonKey = @"QuitAppsButton"; 6 | static NSString *const kTBCSPreferencesManagerHomeScreenButtonKey = @"HomeScreenButton"; 7 | 8 | @interface TBCSPreferencesManager : NSObject 9 | 10 | + (instancetype)sharedInstance; 11 | 12 | @property (nonatomic, retain, readonly) HBPreferences *preferences; 13 | 14 | @property (nonatomic) BOOL hadFirstRun; 15 | 16 | @property (nonatomic, readonly) BOOL darkMode; 17 | @property (nonatomic, readonly) UIBlurEffectStyle blurEffectStyle; 18 | 19 | @property (nonatomic, readonly) BOOL showQuitAppsButton; 20 | @property (nonatomic, readonly) BOOL showHomeScreenButton; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TBCSPreferencesManager.m: -------------------------------------------------------------------------------- 1 | #import "TBCSPreferencesManager.h" 2 | #import 3 | #include 4 | 5 | @implementation TBCSPreferencesManager { 6 | BOOL _hadFirstRun; 7 | } 8 | 9 | + (instancetype)sharedInstance { 10 | static TBCSPreferencesManager *sharedInstance; 11 | static dispatch_once_t onceToken; 12 | dispatch_once(&onceToken, ^{ 13 | sharedInstance = [[self alloc] init]; 14 | }); 15 | 16 | return sharedInstance; 17 | } 18 | 19 | - (instancetype)init { 20 | if (self = [super init]) { 21 | _preferences = [[HBPreferences alloc] initWithIdentifier:@"com.tweakbattles.chrysalis"]; 22 | 23 | [_preferences registerBool:&_hadFirstRun default:NO forKey:kTBCSPreferencesManagerHadFirstRunKey]; 24 | [_preferences registerBool:&_darkMode default:NO forKey:kTBCSPreferencesManagerDarkModeKey]; 25 | 26 | [_preferences registerBool:&_showQuitAppsButton default:YES forKey:kTBCSPreferencesManagerQuitAppsButtonKey]; 27 | [_preferences registerBool:&_showHomeScreenButton default:NO forKey:kTBCSPreferencesManagerHomeScreenButtonKey]; 28 | } 29 | return self; 30 | } 31 | 32 | - (BOOL)hadFirstRun { 33 | return _hadFirstRun; 34 | } 35 | 36 | - (void)setHadFirstRun:(BOOL)hadFirstRun { 37 | [_preferences setBool:hadFirstRun forKey:kTBCSPreferencesManagerHadFirstRunKey]; 38 | } 39 | 40 | - (UIBlurEffectStyle)blurEffectStyle { 41 | return _darkMode ? UIBlurEffectStyleDark : UIBlurEffectStyleLight; 42 | } 43 | 44 | #pragma mark - Memory management 45 | 46 | - (void)dealloc { 47 | [_preferences release]; 48 | 49 | [super dealloc]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /TBCSTutorialViewController.h: -------------------------------------------------------------------------------- 1 | @interface TBCSTutorialViewController : UIViewController 2 | 3 | @end 4 | -------------------------------------------------------------------------------- /TBCSTutorialViewController.x: -------------------------------------------------------------------------------- 1 | #import "TBCSTutorialViewController.h" 2 | #import "TBCSAppSwitcherViewController.h" 3 | #import 4 | #import 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | #import 11 | 12 | @import CoreText; 13 | 14 | @implementation TBCSTutorialViewController { 15 | UIView *_containerView; 16 | } 17 | 18 | #pragma mark - UIViewController 19 | 20 | - (void)loadView { 21 | [super loadView]; 22 | 23 | [self loadInFonts]; 24 | 25 | // Add a light tint to create some seperation for the text 26 | self.view.backgroundColor = [UIColor colorWithWhite:2.0f/255.0f alpha:0.3]; 27 | 28 | UIView *containerView = [[[UIView alloc] init] autorelease]; 29 | containerView.translatesAutoresizingMaskIntoConstraints = NO; 30 | [self.view addSubview:containerView]; 31 | 32 | UILabel *headerLabel = [[[UILabel alloc] init] autorelease]; 33 | headerLabel.font = [UIFont fontWithName:@"NexaLight" size:36]; 34 | headerLabel.text = @"CHRYSALIS"; 35 | headerLabel.textColor = [UIColor whiteColor]; 36 | headerLabel.textAlignment = NSTextAlignmentCenter; 37 | headerLabel.translatesAutoresizingMaskIntoConstraints = NO; 38 | [containerView addSubview:headerLabel]; 39 | 40 | UILabel *pronunciationLabel = [[[UILabel alloc] init] autorelease]; 41 | pronunciationLabel.font = [UIFont fontWithName:@"NexaLight" size:15]; 42 | pronunciationLabel.text = @"kriss·uh·lis"; 43 | pronunciationLabel.textColor = [UIColor whiteColor]; 44 | pronunciationLabel.textAlignment = NSTextAlignmentCenter; 45 | pronunciationLabel.translatesAutoresizingMaskIntoConstraints = NO; 46 | [containerView addSubview:pronunciationLabel]; 47 | 48 | UILabel *shortDescriptionLabel = [[[UILabel alloc] init] autorelease]; 49 | shortDescriptionLabel.numberOfLines = 0; 50 | shortDescriptionLabel.font = [UIFont fontWithName:@"NexaLight" size:18]; 51 | shortDescriptionLabel.text = [NSString stringWithFormat:@"a minimalist app switcher for your %@", [UIDevice currentDevice].localizedModel]; 52 | shortDescriptionLabel.textColor = [UIColor whiteColor]; 53 | shortDescriptionLabel.textAlignment = NSTextAlignmentCenter; 54 | shortDescriptionLabel.translatesAutoresizingMaskIntoConstraints = NO; 55 | [containerView addSubview:shortDescriptionLabel]; 56 | 57 | UILabel *detailLabel = [[[UILabel alloc] init] autorelease]; 58 | detailLabel.numberOfLines = 0; 59 | detailLabel.font = [UIFont fontWithName:@"billy" size:36]; 60 | detailLabel.text = 61 | [NSString stringWithFormat:@"%@\n\n%@\n\n%@", [UIDevice currentDevice]._supportsForceTouch 62 | ? @"- force touch/hold on the left side of the screen to reveal the app icons." 63 | : @"- swipe from the left side of the screen to reveal the app icons.", 64 | @"- continuing to slide on the app switcher zone without releasing to select an app", 65 | @"- slide to the × button to close all apps"]; 66 | detailLabel.textColor = [UIColor whiteColor]; 67 | detailLabel.textAlignment = NSTextAlignmentLeft; 68 | detailLabel.translatesAutoresizingMaskIntoConstraints = NO; 69 | [containerView addSubview:detailLabel]; 70 | 71 | UIView *switcherContainerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, containerView.frame.size.width, 95)] autorelease]; 72 | switcherContainerView.translatesAutoresizingMaskIntoConstraints = NO; 73 | [containerView addSubview:switcherContainerView]; 74 | 75 | TBCSAppSwitcherViewController *switcherViewController = [[[%c(TBCSAppSwitcherViewController) alloc] init] autorelease]; 76 | switcherViewController.useDemoApps = YES; 77 | switcherViewController.view.userInteractionEnabled = NO; 78 | switcherViewController.view.translatesAutoresizingMaskIntoConstraints = NO; 79 | [self addChildViewController:switcherViewController]; 80 | [switcherContainerView addSubview:switcherViewController.view]; 81 | [switcherViewController didMoveToParentViewController:self]; 82 | [switcherViewController viewWillAppear:NO]; 83 | 84 | NSDictionary *views = @{ 85 | @"self": self.view, 86 | @"containerView": containerView, 87 | @"headerLabel": headerLabel, 88 | @"pronunciationLabel": pronunciationLabel, 89 | @"shortDescriptionLabel": shortDescriptionLabel, 90 | @"detailLabel": detailLabel, 91 | @"switcherContainerView": switcherContainerView, 92 | @"switcherView": switcherViewController.view 93 | }; 94 | 95 | [self.view hb_addCompactConstraints:@[ 96 | @"containerView.left = self.left", 97 | @"containerView.right = self.right" 98 | ] metrics:nil views:views]; 99 | 100 | [containerView hb_addCompactConstraints:@[ 101 | @"headerLabel.left = containerView.left", 102 | @"headerLabel.right = containerView.right", 103 | 104 | @"pronunciationLabel.left = containerView.left", 105 | @"pronunciationLabel.right = containerView.right", 106 | 107 | @"shortDescriptionLabel.left = containerView.left", 108 | @"shortDescriptionLabel.right = containerView.right", 109 | 110 | @"detailLabel.left = containerView.left + 20", 111 | @"detailLabel.right = containerView.right - 20", 112 | 113 | @"switcherContainerView.left = containerView.left", 114 | @"switcherContainerView.right = containerView.right", 115 | ] metrics:nil views:views]; 116 | 117 | [switcherContainerView hb_addCompactConstraints:@[ 118 | @"switcherView.left = switcherContainerView.left", 119 | @"switcherView.right = switcherContainerView.right", 120 | @"switcherView.top = switcherContainerView.top", 121 | @"switcherView.bottom = switcherContainerView.bottom", 122 | ] metrics:nil views:views]; 123 | 124 | [containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-55-[headerLabel][pronunciationLabel]-4-[shortDescriptionLabel]-35-[detailLabel]-35-[switcherContainerView(==95)]|" options:kNilOptions metrics:nil views:views]]; 125 | } 126 | 127 | #pragma mark - Show/Hide 128 | 129 | - (void)viewWillAppear:(BOOL)animated { 130 | [super viewWillAppear:animated]; 131 | 132 | SBIconListView *rootIcons = [[%c(SBIconController) sharedInstance] currentRootIconList]; 133 | SBIconListView *dockIcons = [[%c(SBIconController) sharedInstance] dockListView]; 134 | SBRootFolderController *rootController = [[%c(SBIconController) sharedInstance] _rootFolderController]; 135 | 136 | self.view.alpha = 0; 137 | 138 | [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 139 | self.view.alpha = 1; 140 | 141 | rootIcons.alpha = 0.2; 142 | dockIcons.alpha = 0.2; 143 | [rootController.contentView setPageControlHidden:YES]; 144 | [rootController.contentView.dockView setBackgroundAlpha:0.2f]; 145 | } completion:nil]; 146 | } 147 | 148 | - (void)viewWillDisappear:(BOOL)animated { 149 | [super viewWillDisappear:animated]; 150 | 151 | SBRootIconListView *rootIcons = [[%c(SBIconController) sharedInstance] currentRootIconList]; 152 | SBDockIconListView *dockIcons = [[%c(SBIconController) sharedInstance] dockListView]; 153 | SBRootFolderController *rootController = [[%c(SBIconController) sharedInstance] _rootFolderController]; 154 | 155 | [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 156 | self.view.alpha = 0; 157 | 158 | rootIcons.alpha = 1.0; 159 | dockIcons.alpha = 1.0; 160 | [rootController.contentView setPageControlHidden:NO]; 161 | [rootController.contentView.dockView setBackgroundAlpha:1.0f]; 162 | } completion:nil]; 163 | } 164 | 165 | #pragma mark - Fonts 166 | 167 | - (void)loadInFonts { 168 | static dispatch_once_t onceToken; 169 | dispatch_once(&onceToken, ^{ 170 | NSArray *fonts = @[ @"Billy.ttf", @"Nexa.otf" ]; 171 | NSBundle *bundle = [NSBundle bundleWithPath:@"/Library/PreferenceBundles/ChrysalisPrefs.bundle"]; 172 | 173 | for (NSString *font in fonts) { 174 | NSURL *url = [bundle URLForResource:font.stringByDeletingPathExtension withExtension:font.pathExtension subdirectory:@"fonts"]; 175 | 176 | CGDataProviderRef dataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)url); 177 | CGFontRef font = CGFontCreateWithDataProvider(dataProvider); 178 | CGDataProviderRelease(dataProvider); 179 | CTFontManagerRegisterGraphicsFont(font, nil); 180 | CGFontRelease(font); 181 | } 182 | }); 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /TBCSWindow.h: -------------------------------------------------------------------------------- 1 | @class TBCSAppSwitcherViewController; 2 | 3 | @interface TBCSWindow : UIWindow 4 | 5 | + (instancetype)sharedInstance; 6 | 7 | - (void)showTutorial; 8 | 9 | - (void)startAppSwitcher:(CGPoint)point; 10 | - (void)updateToPoint:(CGPoint)point; 11 | - (void)removeFromPoint:(CGPoint)point; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TBCSWindow.x: -------------------------------------------------------------------------------- 1 | #import "TBCSWindow.h" 2 | #import "TBCSAppSwitcherViewController.h" 3 | #import "TBCSTutorialViewController.h" 4 | #import 5 | 6 | static CGFloat const kTBCSAppSwitcherHeight = 95.f; 7 | 8 | @implementation TBCSWindow 9 | 10 | + (instancetype)sharedInstance { 11 | static TBCSWindow *sharedInstance; 12 | static dispatch_once_t onceToken; 13 | dispatch_once(&onceToken, ^{ 14 | sharedInstance = [[self alloc] init]; 15 | }); 16 | 17 | return sharedInstance; 18 | } 19 | 20 | - (instancetype)init { 21 | if (self = [super init]) { 22 | self.frame = [UIScreen mainScreen].bounds; 23 | self.windowLevel = UIWindowLevelAlertReal+2; 24 | self.backgroundColor = [UIColor clearColor]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)showTutorial { 30 | self.rootViewController = [[[TBCSTutorialViewController alloc] init] autorelease]; 31 | [self.rootViewController viewWillAppear:YES]; 32 | 33 | self.hidden = NO; 34 | } 35 | 36 | - (void)startAppSwitcher:(CGPoint)point { 37 | if (![self.rootViewController isKindOfClass:TBCSAppSwitcherViewController.class]) { 38 | self.rootViewController = [[[TBCSAppSwitcherViewController alloc] init] autorelease]; 39 | self.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width/-2, 0, [[UIScreen mainScreen] bounds].size.width, kTBCSAppSwitcherHeight); 40 | self.layer.anchorPoint = CGPointMake(0, 0.5f); 41 | } 42 | 43 | [self.rootViewController viewWillAppear:YES]; 44 | 45 | // i’m self centered hahaHAHAHA GET IT 46 | self.center = CGPointMake(self.center.x, point.y); 47 | self.hidden = NO; 48 | self.alpha = 0; 49 | self.transform = CGAffineTransformMakeScale(0.15, 0.15); 50 | 51 | [UIView animateWithDuration:0.1 animations:^{ 52 | self.alpha = 1; 53 | self.transform = CGAffineTransformIdentity; 54 | }]; 55 | } 56 | 57 | - (void)removeFromPoint:(CGPoint)point { 58 | TBCSAppSwitcherViewController *appSwitcher = (TBCSAppSwitcherViewController *)self.rootViewController; 59 | [appSwitcher openAppAtPoint:point]; 60 | 61 | [UIView animateWithDuration:0.1 delay:0.2 options:UIViewAnimationOptionCurveEaseIn animations:^{ 62 | self.transform = CGAffineTransformMakeScale(0.15, 0.15); 63 | self.alpha = 0; 64 | } completion:^(BOOL completed) { 65 | self.hidden = YES; 66 | }]; 67 | } 68 | 69 | - (void)updateToPoint:(CGPoint)point { 70 | TBCSAppSwitcherViewController *appSwitcher = (TBCSAppSwitcherViewController *)self.rootViewController; 71 | [appSwitcher updateViewToNewPoint:point]; 72 | } 73 | 74 | #pragma mark - Touches 75 | 76 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 77 | [self.rootViewController viewWillDisappear:YES]; 78 | 79 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC * 0.4)), dispatch_get_main_queue(), ^{ 80 | self.rootViewController.view.hidden = YES; 81 | self.hidden = YES; 82 | }); 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import "TBCSPreferencesManager.h" 2 | #import "TBCSWindow.h" 3 | #import 4 | #import 5 | #import 6 | #import 7 | #import 8 | 9 | %hook SBUIController 10 | 11 | - (void)_addRemoveSwitcherGesture { 12 | %orig; 13 | 14 | UIGestureRecognizer *switcherForcePressRecognizer = [self valueForKey:@"_switcherForcePressRecognizer"]; 15 | 16 | // if the gesture recognizer doesn’t exist, the device doesn’t have 3d touch 17 | if (!switcherForcePressRecognizer) { 18 | SBScreenEdgePanGestureRecognizer *gestureRecognizer = [[%c(SBScreenEdgePanGestureRecognizer) alloc] initWithTarget:self action:@selector(_handleSwitcherForcePressGesture:) type:SBSystemGestureTypeSwitcherForcePress]; 19 | gestureRecognizer.delegate = self; 20 | gestureRecognizer.edges = UIRectEdgeLeft; 21 | gestureRecognizer.maximumNumberOfTouches = 1; 22 | [self setValue:gestureRecognizer forKey:@"_switcherForcePressRecognizer"]; 23 | 24 | SBMainDisplaySystemGestureManager *gestureManager = [%c(SBSystemGestureManager) mainDisplayManager]; 25 | [gestureManager addGestureRecognizer:gestureRecognizer withType:SBSystemGestureTypeSwitcherForcePress]; 26 | } 27 | } 28 | 29 | - (void)_handleSwitcherForcePressGesture:(UIGestureRecognizer *)gestureRecognizer { 30 | TBCSWindow *window = [TBCSWindow sharedInstance]; 31 | CGPoint activationPoint = [gestureRecognizer locationInView:[self window]]; 32 | switch (gestureRecognizer.state) { 33 | case UIGestureRecognizerStateBegan: 34 | [window startAppSwitcher:activationPoint]; 35 | break; 36 | case UIGestureRecognizerStateChanged: 37 | [window updateToPoint:activationPoint]; 38 | break; 39 | case UIGestureRecognizerStateEnded: 40 | case UIGestureRecognizerStateCancelled: 41 | case UIGestureRecognizerStateFailed: 42 | [window removeFromPoint:activationPoint]; 43 | break; 44 | } 45 | } 46 | 47 | %end 48 | 49 | %hook SBMainDisplaySystemGestureManager 50 | 51 | - (BOOL)_shouldEnableSystemGestureWithType:(SBSystemGestureType)type { 52 | // override so the edge pan gesture is enabled even if 3d touch isn’t 53 | // available 54 | if (type == SBSystemGestureTypeSwitcherForcePress) { 55 | return YES; 56 | } 57 | 58 | return %orig; 59 | } 60 | 61 | %end 62 | 63 | %hook SBLockScreenViewController 64 | - (void)finishUIUnlockFromSource:(int)arg1 { 65 | %orig; 66 | 67 | if (![[TBCSPreferencesManager sharedInstance] hadFirstRun]) { 68 | [[TBCSPreferencesManager sharedInstance] setHadFirstRun:YES]; 69 | [[TBCSWindow sharedInstance] showTutorial]; 70 | } 71 | } 72 | %end 73 | 74 | %ctor { 75 | if (IN_SPRINGBOARD) { 76 | %init; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.tweakbattles.chrysalis 2 | Name: Chrysalis 3 | Depends: mobilesubstrate, ws.hbang.common (>= 1.7) 4 | Version: 1.1 5 | Architecture: iphoneos-arm 6 | Description: A modern, gesture based app switcher 7 | Maintainer: Ben & Carlos & Kirb & Veerklempt 8 | Author: Ben & Carlos & Kirb & Veerklempt 9 | Support: https://www.hbang.ws/faq/ 10 | Section: Tweaks 11 | -------------------------------------------------------------------------------- /prefs/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | BUNDLE_NAME = ChrysalisPrefs 4 | ChrysalisPrefs_FILES = $(wildcard *.m) $(wildcard *.x) 5 | ChrysalisPrefs_INSTALL_PATH = /Library/PreferenceBundles 6 | ChrysalisPrefs_FRAMEWORKS = UIKit MessageUI 7 | ChrysalisPrefs_PRIVATE_FRAMEWORKS = Preferences 8 | ChrysalisPrefs_EXTRA_FRAMEWORKS = CepheiPrefs 9 | ChrysalisPrefs_LIBRARIES = MobileGestalt 10 | 11 | include $(THEOS_MAKE_PATH)/bundle.mk 12 | 13 | internal-stage:: 14 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 15 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/ChrysalisPrefs.plist$(ECHO_END) 16 | -------------------------------------------------------------------------------- /prefs/Resources/About.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | headerCellClass 11 | TBCSAboutHeaderView 12 | 13 | 14 | cell 15 | PSGroupCell 16 | headerCellClass 17 | HBImageTableCell 18 | height 19 | 100 20 | icon 21 | footerLogo.png 22 | 23 | 24 | title 25 | About 26 | 27 | 28 | -------------------------------------------------------------------------------- /prefs/Resources/Advanced.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | 11 | 12 | cell 13 | PSSwitchCell 14 | default 15 | 16 | defaults 17 | com.tweakbattles.chrysalis 18 | key 19 | DarkMode 20 | label 21 | Dark Mode 22 | icon 23 | darkmode.png 24 | PostNotification 25 | com.tweakbattles.chrysalis/ReloadPrefs 26 | 27 | 28 | cell 29 | PSGroupCell 30 | 31 | 32 | cell 33 | PSSwitchCell 34 | default 35 | 36 | defaults 37 | com.tweakbattles.chrysalis 38 | key 39 | QuitAppsButton 40 | label 41 | Quit Apps Button 42 | icon 43 | kill.png 44 | PostNotification 45 | com.tweakbattles.chrysalis/ReloadPrefs 46 | 47 | 48 | cell 49 | PSSwitchCell 50 | default 51 | 52 | defaults 53 | com.tweakbattles.chrysalis 54 | key 55 | HomeScreenButton 56 | label 57 | Home Screen Button 58 | icon 59 | home.png 60 | PostNotification 61 | com.tweakbattles.chrysalis/ReloadPrefs 62 | 63 | 64 | title 65 | Advanced 66 | 67 | 68 | -------------------------------------------------------------------------------- /prefs/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ChrysalisPrefs 9 | CFBundleIdentifier 10 | com.tweakbattles.chrysalisprefs 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | HBPackageIdentifier 22 | com.tweakbattles.chrysalis 23 | NSPrincipalClass 24 | TBCSRootListController 25 | 26 | 27 | -------------------------------------------------------------------------------- /prefs/Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | headerCellClass 11 | HBImageTableCell 12 | height 13 | 100 14 | icon 15 | headerImage.png 16 | 17 | 18 | cell 19 | PSSwitchCell 20 | default 21 | 22 | defaults 23 | com.tweakbattles.chrysalis 24 | key 25 | Enabled 26 | label 27 | ENABLED 28 | icon 29 | enable.png 30 | PostNotification 31 | com.tweakbattles.chrysalis/ReloadPrefs 32 | 33 | 51 | 52 | cell 53 | PSLinkCell 54 | detail 55 | TBCSAdvancedListController 56 | icon 57 | advanced.png 58 | label 59 | Advanced 60 | 61 | 62 | cell 63 | PSGroupCell 64 | 65 | 66 | cell 67 | PSLinkCell 68 | detail 69 | TBCSAboutListController 70 | icon 71 | makers.png 72 | label 73 | About 74 | 75 | 76 | cell 77 | PSLinkCell 78 | label 79 | Support 80 | icon 81 | support.png 82 | action 83 | showSupportEmailController 84 | 85 | 86 | cell 87 | PSGroupCell 88 | headerCellClass 89 | HBImageTableCell 90 | height 91 | 100 92 | icon 93 | footerLogo.png 94 | 95 | 96 | title 97 | Chrysalis 98 | 99 | 100 | -------------------------------------------------------------------------------- /prefs/Resources/advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/advanced.png -------------------------------------------------------------------------------- /prefs/Resources/advanced@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/advanced@2x.png -------------------------------------------------------------------------------- /prefs/Resources/advanced@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/advanced@3x.png -------------------------------------------------------------------------------- /prefs/Resources/darkmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/darkmode.png -------------------------------------------------------------------------------- /prefs/Resources/darkmode@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/darkmode@2x.png -------------------------------------------------------------------------------- /prefs/Resources/darkmode@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/darkmode@3x.png -------------------------------------------------------------------------------- /prefs/Resources/enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/enable.png -------------------------------------------------------------------------------- /prefs/Resources/enable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/enable@2x.png -------------------------------------------------------------------------------- /prefs/Resources/enable@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/enable@3x.png -------------------------------------------------------------------------------- /prefs/Resources/fonts/Billy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/fonts/Billy.ttf -------------------------------------------------------------------------------- /prefs/Resources/fonts/Nexa.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/fonts/Nexa.otf -------------------------------------------------------------------------------- /prefs/Resources/footerLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/footerLogo.png -------------------------------------------------------------------------------- /prefs/Resources/footerLogo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/footerLogo@2x.png -------------------------------------------------------------------------------- /prefs/Resources/footerLogo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/footerLogo@3x.png -------------------------------------------------------------------------------- /prefs/Resources/headerImage-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerImage-568h@2x.png -------------------------------------------------------------------------------- /prefs/Resources/headerImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerImage.png -------------------------------------------------------------------------------- /prefs/Resources/headerImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerImage@2x.png -------------------------------------------------------------------------------- /prefs/Resources/headerImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerImage@3x.png -------------------------------------------------------------------------------- /prefs/Resources/headerLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerLogo.png -------------------------------------------------------------------------------- /prefs/Resources/headerLogo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerLogo@2x.png -------------------------------------------------------------------------------- /prefs/Resources/headerLogo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/headerLogo@3x.png -------------------------------------------------------------------------------- /prefs/Resources/home-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-dark.png -------------------------------------------------------------------------------- /prefs/Resources/home-dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-dark@2x.png -------------------------------------------------------------------------------- /prefs/Resources/home-dark@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-dark@3x.png -------------------------------------------------------------------------------- /prefs/Resources/home-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-light.png -------------------------------------------------------------------------------- /prefs/Resources/home-light@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-light@2x.png -------------------------------------------------------------------------------- /prefs/Resources/home-light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home-light@3x.png -------------------------------------------------------------------------------- /prefs/Resources/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home.png -------------------------------------------------------------------------------- /prefs/Resources/home@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home@2x.png -------------------------------------------------------------------------------- /prefs/Resources/home@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/home@3x.png -------------------------------------------------------------------------------- /prefs/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/icon.png -------------------------------------------------------------------------------- /prefs/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/icon@2x.png -------------------------------------------------------------------------------- /prefs/Resources/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/icon@3x.png -------------------------------------------------------------------------------- /prefs/Resources/kill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/kill.png -------------------------------------------------------------------------------- /prefs/Resources/kill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/kill@2x.png -------------------------------------------------------------------------------- /prefs/Resources/kill@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/kill@3x.png -------------------------------------------------------------------------------- /prefs/Resources/makers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/makers.png -------------------------------------------------------------------------------- /prefs/Resources/makers@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/makers@2x.png -------------------------------------------------------------------------------- /prefs/Resources/makers@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/makers@3x.png -------------------------------------------------------------------------------- /prefs/Resources/name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/name.png -------------------------------------------------------------------------------- /prefs/Resources/name@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/name@2x.png -------------------------------------------------------------------------------- /prefs/Resources/name@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/name@3x.png -------------------------------------------------------------------------------- /prefs/Resources/position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/position.png -------------------------------------------------------------------------------- /prefs/Resources/position@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/position@2x.png -------------------------------------------------------------------------------- /prefs/Resources/position@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/position@3x.png -------------------------------------------------------------------------------- /prefs/Resources/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/preview.png -------------------------------------------------------------------------------- /prefs/Resources/preview@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/preview@2x.png -------------------------------------------------------------------------------- /prefs/Resources/preview@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/preview@3x.png -------------------------------------------------------------------------------- /prefs/Resources/support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/support.png -------------------------------------------------------------------------------- /prefs/Resources/support@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/support@2x.png -------------------------------------------------------------------------------- /prefs/Resources/support@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/support@3x.png -------------------------------------------------------------------------------- /prefs/Resources/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/x.png -------------------------------------------------------------------------------- /prefs/Resources/x@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/x@2x.png -------------------------------------------------------------------------------- /prefs/Resources/x@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benrosen78/chrysalis/de727ada7636cf3438511e88aa0b2f7e5c61a670/prefs/Resources/x@3x.png -------------------------------------------------------------------------------- /prefs/TBCSAboutCreatorView.h: -------------------------------------------------------------------------------- 1 | typedef NS_ENUM(NSInteger, TBCSAboutCreatorType) { 2 | TBCSAboutCreatorTypeDeveloper, 3 | TBCSAboutCreatorTypeDesigner 4 | }; 5 | 6 | @interface TBCSAboutCreatorView : UIButton 7 | 8 | - (instancetype)initWithTwitterUsername:(NSString *)username name:(NSString *)name creatorType:(TBCSAboutCreatorType)creatorType; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /prefs/TBCSAboutCreatorView.m: -------------------------------------------------------------------------------- 1 | #import "TBCSAboutCreatorView.h" 2 | 3 | #define URL_ENCODE(string) [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)(string), NULL, CFSTR(":/=,!$& '()*+;[]@#?"), kCFStringEncodingUTF8) autorelease] 4 | 5 | @implementation TBCSAboutCreatorView { 6 | NSString *_twitterUsername; 7 | } 8 | 9 | - (instancetype)initWithTwitterUsername:(NSString *)username name:(NSString *)name creatorType:(TBCSAboutCreatorType)creatorType { 10 | if ((self = [[self.class buttonWithType:UIButtonTypeSystem] retain])) { 11 | _twitterUsername = [username copy]; 12 | 13 | // this kinda breaks model-view-controller 14 | [self addTarget:self action:@selector(openTwitterAccount) forControlEvents:UIControlEventTouchUpInside]; 15 | 16 | UIImageView *avatarImageView = [[[UIImageView alloc] init] autorelease]; 17 | avatarImageView.alpha = 0.0; 18 | avatarImageView.layer.masksToBounds = YES; 19 | avatarImageView.layer.cornerRadius = 46.5; 20 | avatarImageView.translatesAutoresizingMaskIntoConstraints = NO; 21 | [self addSubview:avatarImageView]; 22 | [self addConstraint:[NSLayoutConstraint constraintWithItem:avatarImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]]; 23 | [self addConstraint:[NSLayoutConstraint constraintWithItem:avatarImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:93]]; 24 | [self addConstraint:[NSLayoutConstraint constraintWithItem:avatarImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:93]]; 25 | [self addConstraint:[NSLayoutConstraint constraintWithItem:avatarImageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 26 | 27 | UILabel *nameLabel = [[[UILabel alloc] init] autorelease]; 28 | nameLabel.text = [name copy]; 29 | nameLabel.font = [UIFont systemFontOfSize:12.5]; 30 | nameLabel.translatesAutoresizingMaskIntoConstraints = NO; 31 | [self addSubview:nameLabel]; 32 | [self addConstraint:[NSLayoutConstraint constraintWithItem:nameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:avatarImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:4]]; 33 | [self addConstraint:[NSLayoutConstraint constraintWithItem:nameLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 34 | 35 | UILabel *creatorTypeLabel = [[[UILabel alloc] init] autorelease]; 36 | creatorTypeLabel.text = creatorType == TBCSAboutCreatorTypeDeveloper ? @"Developer" : @"Designer"; 37 | creatorTypeLabel.font = [UIFont systemFontOfSize:10.0]; 38 | creatorTypeLabel.translatesAutoresizingMaskIntoConstraints = NO; 39 | [self addSubview:creatorTypeLabel]; 40 | [self addConstraint:[NSLayoutConstraint constraintWithItem:creatorTypeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:nameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:1.5]]; 41 | [self addConstraint:[NSLayoutConstraint constraintWithItem:creatorTypeLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 42 | 43 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 44 | NSError *error = nil; 45 | NSData *data = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://twitter.com/%@/profile_image?size=original", URL_ENCODE(username)]]] returningResponse:nil error:&error]; 46 | 47 | if (error) { 48 | HBLogError(@"error loading twitter avatar: %@", error); 49 | return; 50 | } 51 | 52 | dispatch_async(dispatch_get_main_queue(), ^{ 53 | avatarImageView.image = [UIImage imageWithData:data]; 54 | 55 | [UIView animateWithDuration:0.15 animations:^{ 56 | avatarImageView.alpha = 1; 57 | }]; 58 | }); 59 | }); 60 | } 61 | return self; 62 | } 63 | 64 | #pragma mark - Callbacks 65 | 66 | - (void)openTwitterForUser { 67 | NSString *encodedUser = URL_ENCODE(_twitterUsername); 68 | NSURL *url = nil; 69 | 70 | if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"aphelion://"]]) { 71 | url = [NSURL URLWithString:[@"aphelion://profile/" stringByAppendingString:encodedUser]]; 72 | } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetbot://"]]) { 73 | url = [NSURL URLWithString:[@"tweetbot:///user_profile/" stringByAppendingString:encodedUser]]; 74 | } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitterrific://"]]) { 75 | url = [NSURL URLWithString:[@"twitterrific:///profile?screen_name=" stringByAppendingString:encodedUser]]; 76 | } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetings://"]]) { 77 | url = [NSURL URLWithString:[@"tweetings:///user?screen_name=" stringByAppendingString:encodedUser]]; 78 | } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]]) { 79 | url = [NSURL URLWithString:[@"twitter://user?screen_name=" stringByAppendingString:encodedUser]]; 80 | } else { 81 | url = [NSURL URLWithString:[@"https://mobile.twitter.com/" stringByAppendingString:encodedUser]]; 82 | } 83 | 84 | [[UIApplication sharedApplication] openURL:url]; 85 | } 86 | 87 | #pragma mark - Memory management 88 | 89 | - (void)dealloc { 90 | [_twitterUsername release]; 91 | 92 | [super dealloc]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /prefs/TBCSAboutHeaderView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface TBCSAboutHeaderView : PSTableCell 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /prefs/TBCSAboutHeaderView.m: -------------------------------------------------------------------------------- 1 | #import "TBCSAboutHeaderView.h" 2 | #import "TBCSAboutCreatorView.h" 3 | #import 4 | 5 | @implementation TBCSAboutHeaderView 6 | 7 | #pragma mark initialization 8 | 9 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier { 10 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier]) { 11 | TBCSAboutCreatorView *benCreatorView = [[[TBCSAboutCreatorView alloc] initWithTwitterUsername:@"benr9500" name:@"Ben Rosen" creatorType:TBCSAboutCreatorTypeDeveloper] autorelease]; 12 | benCreatorView.translatesAutoresizingMaskIntoConstraints = NO; 13 | [self.contentView addSubview:benCreatorView]; 14 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:benCreatorView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:21]]; 15 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:benCreatorView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:0.57 constant:0]]; 16 | 17 | TBCSAboutCreatorView *carlosCreatorView = [[[TBCSAboutCreatorView alloc] initWithTwitterUsername:@"cpdigdarkroom" name:@"CP Digital Darkroom" creatorType:TBCSAboutCreatorTypeDeveloper] autorelease]; 18 | carlosCreatorView.translatesAutoresizingMaskIntoConstraints = NO; 19 | [self.contentView addSubview:carlosCreatorView]; 20 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:carlosCreatorView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:21]]; 21 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:carlosCreatorView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.43 constant:0]]; 22 | 23 | TBCSAboutCreatorView *kirbCreatorView = [[[TBCSAboutCreatorView alloc] initWithTwitterUsername:@"hbkirb" name:@"Adam Demasi (kirb)" creatorType:TBCSAboutCreatorTypeDeveloper] autorelease]; 24 | kirbCreatorView.translatesAutoresizingMaskIntoConstraints = NO; 25 | [self.contentView addSubview:kirbCreatorView]; 26 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:kirbCreatorView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:168]]; 27 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:kirbCreatorView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:0.57 constant:0]]; 28 | 29 | TBCSAboutCreatorView *veerklemptCreatorView = [[[TBCSAboutCreatorView alloc] initWithTwitterUsername:@"veerklempt" name:@"Veerklempt" creatorType:TBCSAboutCreatorTypeDesigner] autorelease]; 30 | veerklemptCreatorView.translatesAutoresizingMaskIntoConstraints = NO; 31 | [self.contentView addSubview:veerklemptCreatorView]; 32 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:veerklemptCreatorView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:168]]; 33 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:veerklemptCreatorView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.43 constant:0]]; 34 | 35 | UIImage *chrysalisLogo = [[UIImage imageNamed:@"headerLogo" inBundle:[NSBundle bundleForClass:self.class]] _flatImageWithColor:[UIColor colorWithRed:0.812 green:0.812 blue:0.835 alpha:1.00]]; 36 | UIImageView *chrysalisLogoImageView = [[[UIImageView alloc] init] autorelease]; 37 | chrysalisLogoImageView.image = chrysalisLogo; 38 | chrysalisLogoImageView.backgroundColor = self.superview.superview.backgroundColor; 39 | chrysalisLogoImageView.translatesAutoresizingMaskIntoConstraints = NO; 40 | [self.contentView addSubview:chrysalisLogoImageView]; 41 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:chrysalisLogoImageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 42 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:chrysalisLogoImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:303]]; 43 | 44 | UIView *leftSeparator = [[[UIView alloc] init] autorelease]; 45 | leftSeparator.backgroundColor = [UIColor colorWithRed:0.812 green:0.812 blue:0.835 alpha:1.00]; 46 | leftSeparator.translatesAutoresizingMaskIntoConstraints = NO; 47 | [self.contentView addSubview:leftSeparator]; 48 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:leftSeparator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:chrysalisLogoImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 49 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:leftSeparator attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:18]]; 50 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:leftSeparator attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:chrysalisLogoImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:-20]]; 51 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:leftSeparator attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:1.5]]; 52 | 53 | UIView *rightSeparator = [[[UIView alloc] init] autorelease]; 54 | rightSeparator.backgroundColor = [UIColor colorWithRed:0.812 green:0.812 blue:0.835 alpha:1.00]; 55 | rightSeparator.translatesAutoresizingMaskIntoConstraints = NO; 56 | [self.contentView addSubview:rightSeparator]; 57 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:rightSeparator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:chrysalisLogoImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; 58 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:rightSeparator attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:chrysalisLogoImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:20]]; 59 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:rightSeparator attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-18]]; 60 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:rightSeparator attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:1.5]]; 61 | 62 | UILabel *thankLabel = [[[UILabel alloc] init] autorelease]; 63 | thankLabel.text = @"Thank you for purchasing this tweak. Enjoy!"; 64 | thankLabel.font = [UIFont systemFontOfSize:10]; 65 | thankLabel.translatesAutoresizingMaskIntoConstraints = NO; 66 | [self.contentView addSubview:thankLabel]; 67 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:thankLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 68 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:thankLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:chrysalisLogoImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:15]]; 69 | 70 | UILabel *specialThanksLabel = [[[UILabel alloc] init] autorelease]; 71 | specialThanksLabel.text = @"SPECIAL THANKS TO"; 72 | specialThanksLabel.font = [UIFont systemFontOfSize:12]; 73 | specialThanksLabel.translatesAutoresizingMaskIntoConstraints = NO; 74 | [self.contentView addSubview:specialThanksLabel]; 75 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:specialThanksLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]]; 76 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:specialThanksLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:thankLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:22]]; 77 | 78 | UILabel *supportersLabel = [[[UILabel alloc] init] autorelease]; 79 | supportersLabel.text = @"@redzrex, Boris S, @twodayslate, Eric, Borsato92, cj81499, mootjeuh, Ziph0n, /u/DervishSkater, Corporal, Pixxaddict, Matteo Piccina, josh_boothman, Moshe Siegel, Ian L, @rauseo12, wizage, RushNY, @BrianOverly, @thetomcanuck, winlogon0, Jason R., CONATH, JimDotR, Andrew, Acidschnee, Cody, Connor, Shadow Games, echo000, Jonathan Gautreau , Blink, ShaneSparkyYYZ, kamikasky, MaxD, @tilgut, Torben, MeatyCheetos, Lei33, K S LEE, @RichResk, @sekrit_, Maortega89, @frkbmb_, Kyle, Robert, @pwned24k, OhSpazz, Jessyreynosa3, Jessie mejia , Jp_delon, dantesieg, @codsane, Alex S., Spencer, HHumbert, Josh Gibson, @sel2by3, platypusw90, @Beezure"; 80 | supportersLabel.font = [UIFont systemFontOfSize:10]; 81 | supportersLabel.numberOfLines = 0; 82 | supportersLabel.translatesAutoresizingMaskIntoConstraints = NO; 83 | [self.contentView addSubview:supportersLabel]; 84 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:supportersLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:18]]; 85 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:supportersLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-18]]; 86 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:supportersLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:specialThanksLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:8]]; 87 | 88 | } 89 | return self; 90 | } 91 | 92 | - (instancetype)initWithSpecifier:(PSSpecifier *)specifier { 93 | return [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil specifier:specifier]; 94 | } 95 | 96 | #pragma mark size 97 | 98 | - (CGFloat)preferredHeightForWidth:(CGFloat)width { 99 | return 527.f; 100 | } 101 | 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /prefs/TBCSAboutListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface TBCSAboutListController : HBListController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /prefs/TBCSAboutListController.m: -------------------------------------------------------------------------------- 1 | #import "TBCSAboutListController.h" 2 | #import "TBCSAboutCreatorView.h" 3 | #import 4 | 5 | @implementation TBCSAboutListController 6 | 7 | #pragma mark Cephei - HBListController 8 | 9 | + (NSString *)hb_specifierPlist { 10 | return @"About"; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /prefs/TBCSAdvancedBackgroundGradientView.h: -------------------------------------------------------------------------------- 1 | @interface TBCSAdvancedBackgroundGradientView : UIView 2 | 3 | @end 4 | -------------------------------------------------------------------------------- /prefs/TBCSAdvancedBackgroundGradientView.m: -------------------------------------------------------------------------------- 1 | #import "TBCSAdvancedBackgroundGradientView.h" 2 | 3 | @implementation TBCSAdvancedBackgroundGradientView 4 | 5 | + (Class)layerClass { 6 | return CAGradientLayer.class; 7 | } 8 | 9 | - (instancetype)init { 10 | if (self = [super init]) { 11 | ((CAGradientLayer *)self.layer).colors = @[ 12 | (id)[UIColor colorWithRed:0.498 green:0.498 blue:0.506 alpha:1.00].CGColor, 13 | (id)[UIColor colorWithRed:0.651 green:0.651 blue:0.663 alpha:1.00].CGColor, 14 | (id)[UIColor colorWithRed:0.776 green:0.776 blue:0.792 alpha:1.00].CGColor, 15 | (id)[UIColor colorWithRed:0.875 green:0.875 blue:0.894 alpha:1.00].CGColor 16 | ]; 17 | 18 | CAGradientLayer *maskLayer = [CAGradientLayer layer]; 19 | maskLayer.locations = @[ @0.85f, @1 ]; 20 | maskLayer.colors = @[ 21 | (id)[UIColor blackColor].CGColor, 22 | (id)[UIColor clearColor].CGColor, 23 | ]; 24 | self.layer.mask = maskLayer; 25 | } 26 | 27 | return self; 28 | } 29 | 30 | - (void)layoutSubviews { 31 | [super layoutSubviews]; 32 | 33 | self.layer.mask.frame = self.bounds; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /prefs/TBCSAdvancedListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface TBCSAdvancedListController : HBListController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /prefs/TBCSAdvancedListController.x: -------------------------------------------------------------------------------- 1 | #import "TBCSAdvancedListController.h" 2 | #import "../TBCSAppSwitcherViewController.h" 3 | #include 4 | #import "TBCSAdvancedBackgroundGradientView.h" 5 | #import 6 | #import 7 | 8 | @implementation TBCSAdvancedListController { 9 | TBCSAdvancedBackgroundGradientView *_backgroundGradientView; 10 | TBCSAppSwitcherViewController *_appSwitcherViewController; 11 | } 12 | 13 | #pragma mark Cephei - HBListController 14 | 15 | + (NSString *)hb_specifierPlist { 16 | return @"Advanced"; 17 | } 18 | 19 | #pragma mark TBCSAdvancedListController 20 | 21 | - (instancetype)init { 22 | if (self = [super init]) { 23 | dlopen("/Library/MobileSubstrate/DynamicLibraries/Chrysalis.dylib", RTLD_NOW); 24 | } 25 | return self; 26 | } 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | 31 | _backgroundGradientView = [[TBCSAdvancedBackgroundGradientView alloc] init]; 32 | _backgroundGradientView.frame = CGRectMake(0, 0, self.table.frame.size.width, 183); 33 | _backgroundGradientView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 34 | 35 | UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 34, self.table.frame.size.width, 95)] autorelease]; 36 | containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 37 | [_backgroundGradientView addSubview:containerView]; 38 | 39 | _appSwitcherViewController = [[%c(TBCSAppSwitcherViewController) alloc] init]; 40 | _appSwitcherViewController.useDemoApps = YES; 41 | _appSwitcherViewController.view.userInteractionEnabled = NO; 42 | _appSwitcherViewController.view.frame = containerView.bounds; 43 | 44 | [containerView addSubview:_appSwitcherViewController.view]; 45 | [self addChildViewController:_appSwitcherViewController]; 46 | [_appSwitcherViewController didMoveToParentViewController:self]; 47 | 48 | self.table.tableHeaderView = _backgroundGradientView; 49 | } 50 | 51 | - (void)viewDidAppear:(BOOL)animated { 52 | [super viewDidAppear:animated]; 53 | [self.realNavigationController.navigationBar _setHidesShadow:YES]; 54 | } 55 | 56 | - (void)viewDidLayoutSubviews { 57 | [super viewDidLayoutSubviews]; 58 | [self.realNavigationController.navigationBar _setHidesShadow:YES]; 59 | } 60 | 61 | - (void)viewWillDisappear:(BOOL)animated { 62 | [super viewWillDisappear:animated]; 63 | [self.realNavigationController.navigationBar _setHidesShadow:NO]; 64 | [_appSwitcherViewController removeFromParentViewController]; 65 | } 66 | 67 | #pragma mark - Memory management 68 | 69 | - (void)dealloc { 70 | [_backgroundGradientView release]; 71 | [_appSwitcherViewController release]; 72 | 73 | [super dealloc]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /prefs/TBCSRootListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface TBCSRootListController : HBRootListController 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /prefs/TBCSRootListController.m: -------------------------------------------------------------------------------- 1 | #import "TBCSRootListController.h" 2 | #import 3 | #import 4 | 5 | @implementation TBCSRootListController 6 | 7 | + (NSString *)hb_specifierPlist { 8 | return @"Root"; 9 | } 10 | 11 | + (NSString *)hb_shareText { 12 | return @"I'm using Chrysalis to beautifully switch between apps. Download today from BigBoss! @benr9500 @cpdigdarkroom @hbkirb @veerklempt"; 13 | } 14 | 15 | + (NSString *)hb_shareURL { 16 | return @"http://tweakbattles.com/"; 17 | } 18 | 19 | + (UIColor *)hb_tintColor { 20 | return [UIColor colorWithRed:0.169f green:0.796f blue:0.518f alpha:1.00f]; 21 | } 22 | 23 | + (UIColor *)hb_navigationBarTintColor { 24 | return [UIColor colorWithRed:0.424f green:0.424f blue:0.431f alpha:1.00f]; 25 | } 26 | 27 | + (BOOL)hb_invertedNavigationBar { 28 | return YES; 29 | } 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | 34 | UIImage *headerLogo = [[UIImage imageNamed:@"headerLogo" inBundle:[NSBundle bundleForClass:self.class]] _flatImageWithColor:[UIColor whiteColor]]; 35 | self.navigationItem.titleView = [[[UIImageView alloc] initWithImage:headerLogo] autorelease]; 36 | self.navigationItem.titleView.alpha = 0.0; 37 | 38 | [self performSelector:@selector(animateIconAlpha) withObject:nil afterDelay:0.5]; 39 | } 40 | 41 | - (void)animateIconAlpha { 42 | [UIView animateWithDuration:0.5 animations:^{ 43 | self.navigationItem.titleView.alpha = 1; 44 | } completion:nil]; 45 | } 46 | 47 | - (void)showSupportEmailController { 48 | UIViewController *viewController = (UIViewController *)[HBSupportController supportViewControllerForBundle:[NSBundle bundleForClass:self.class] preferencesIdentifier:@"com.tweakbattles.chrysalis"]; 49 | [self.navigationController pushViewController:viewController animated:YES]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /prefs/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | ChrysalisPrefs 9 | cell 10 | PSLinkCell 11 | detail 12 | TBCSRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | Chrysalis 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------