forked from ish-app/ish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Theodore Dubois
committed
Sep 23, 2018
1 parent
7b4e98a
commit 515b742
Showing
11 changed files
with
437 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// AccessoryButton.h | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 9/22/18. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
IB_DESIGNABLE @interface BarButton : UIButton | ||
|
||
@property IBInspectable UIColor *highlightedBackgroundColor; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AccessoryButton.m | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 9/22/18. | ||
// | ||
|
||
#import "BarButton.h" | ||
|
||
@interface BarButton () | ||
@property UIColor *defaultColor; | ||
@end | ||
|
||
@implementation BarButton | ||
|
||
- (void)awakeFromNib { | ||
[super awakeFromNib]; | ||
self.layer.cornerRadius = 5; | ||
self.layer.shadowOffset = CGSizeMake(0, 1); | ||
self.layer.shadowOpacity = 0.4; | ||
self.layer.shadowRadius = 0; | ||
self.defaultColor = self.backgroundColor; | ||
} | ||
|
||
- (void)chooseBackground { | ||
if (self.selected || self.highlighted) { | ||
self.backgroundColor = self.highlightedBackgroundColor; | ||
} else { | ||
self.backgroundColor = self.defaultColor; | ||
} | ||
} | ||
|
||
- (void)setHighlighted:(BOOL)highlighted { | ||
[super setHighlighted:highlighted]; | ||
[self chooseBackground]; | ||
} | ||
- (void)setSelected:(BOOL)selected { | ||
[super setSelected:selected]; | ||
[self chooseBackground]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// BarViewController.h | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 9/23/18. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface BarViewController : UIViewController | ||
|
||
@property (weak) IBOutlet UIButton *controlKey; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// BarViewController.m | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 9/23/18. | ||
// | ||
|
||
#import "BarViewController.h" | ||
|
||
@interface BarViewController () | ||
|
||
@property (weak, nonatomic) IBOutlet UIStackView *bar; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *barTop; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *barBottom; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *barLeading; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *barTrailing; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *barButtonWidth; | ||
@property (weak, nonatomic) IBOutlet UIButton *hideKeyboardButton; | ||
|
||
@end | ||
|
||
@implementation BarViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) { | ||
[self.bar removeArrangedSubview:self.hideKeyboardButton]; | ||
[self.hideKeyboardButton removeFromSuperview]; | ||
} | ||
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone) { | ||
self.view.frame = CGRectMake(0, 0, 100, 48); | ||
} else { | ||
self.view.frame = CGRectMake(0, 0, 100, 55); | ||
} | ||
} | ||
|
||
- (void)viewWillLayoutSubviews { | ||
CGSize screen = UIScreen.mainScreen.bounds.size; | ||
CGSize bar = self.view.bounds.size; | ||
// set sizing parameters on bar | ||
// numbers stolen from iVim and modified somewhat | ||
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone) { | ||
// phone | ||
[self setBarHorizontalPadding:6 verticalPadding:6 buttonWidth:32]; | ||
} else if (bar.width == screen.width || bar.width == screen.height) { | ||
// full-screen ipad | ||
[self setBarHorizontalPadding:15 verticalPadding:8 buttonWidth:43]; | ||
} else if (bar.width <= 320) { | ||
// slide over | ||
[self setBarHorizontalPadding:8 verticalPadding:8 buttonWidth:26]; | ||
} else { | ||
// split view | ||
[self setBarHorizontalPadding:10 verticalPadding:8 buttonWidth:36]; | ||
} | ||
[UIView performWithoutAnimation:^{ | ||
[self.view layoutIfNeeded]; | ||
}]; | ||
} | ||
|
||
- (void)setBarHorizontalPadding:(CGFloat)horizontal verticalPadding:(CGFloat)vertical buttonWidth:(CGFloat)buttonWidth { | ||
self.barLeading.constant = self.barTrailing.constant = horizontal; | ||
self.barTop.constant = self.barBottom.constant = vertical; | ||
self.barButtonWidth.constant = buttonWidth; | ||
} | ||
|
||
- (IBAction)pressEscape:(id)sender { | ||
[self pressKey:@"\x1b"]; | ||
} | ||
- (IBAction)pressTab:(id)sender { | ||
[self pressKey:@"\t"]; | ||
} | ||
- (void)pressKey:(NSString *)key { | ||
[UIApplication.sharedApplication sendAction:@selector(insertText:) to:nil from:key forEvent:nil]; | ||
} | ||
|
||
- (IBAction)pressControl:(id)sender { | ||
self.controlKey.selected = !self.controlKey.selected; | ||
} | ||
|
||
@end | ||
|
||
@interface BarView : UIView | ||
@property IBOutlet UIViewController *barViewController; | ||
@end | ||
@implementation BarView | ||
|
||
- (void)layoutSubviews { | ||
// this is broken for some reason otherwise | ||
[self.barViewController viewWillLayoutSubviews]; | ||
[super layoutSubviews]; | ||
} | ||
|
||
@end |
Oops, something went wrong.