mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			167 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			167 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C
		
	
| 
											9 years ago
										 | //
 | ||
| 
											7 years ago
										 | //  Copyright (c) 2019 Open Whisper Systems. All rights reserved.
 | ||
| 
											9 years ago
										 | //
 | ||
|  | 
 | ||
| 
											9 years ago
										 | #import <PureLayout/PureLayout.h>
 | ||
| 
											9 years ago
										 | #import <UIKit/UIKit.h>
 | ||
|  | 
 | ||
| 
											8 years ago
										 | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
| 
											7 years ago
										 | typedef void (^UIViewVisitorBlock)(UIView *view); | ||
|  | 
 | ||
| 
											9 years ago
										 | // A convenience method for doing responsive layout. Scales between two
 | ||
|  | // reference values (for iPhone 5 and iPhone 7 Plus) to the current device
 | ||
|  | // based on screen width, linearly interpolating.
 | ||
|  | CGFloat ScaleFromIPhone5To7Plus(CGFloat iPhone5Value, CGFloat iPhone7PlusValue); | ||
|  | 
 | ||
|  | // A convenience method for doing responsive layout. Scales a reference
 | ||
|  | // value (for iPhone 5) to the current device based on screen width,
 | ||
|  | // linearly interpolating through the origin.
 | ||
|  | CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); | ||
|  | 
 | ||
|  | // A set of helper methods for doing layout with PureLayout.
 | ||
|  | @interface UIView (OWS) | ||
|  | 
 | ||
|  | // Pins the width of this view to the width of its superview, with uniform margins.
 | ||
| 
											8 years ago
										 | - (NSArray<NSLayoutConstraint *> *)autoPinWidthToSuperviewWithMargin:(CGFloat)margin; | ||
|  | - (NSArray<NSLayoutConstraint *> *)autoPinWidthToSuperview; | ||
| 
											7 years ago
										 | - (NSArray<NSLayoutConstraint *> *)autoPinWidthToSuperviewMargins; | ||
| 
											9 years ago
										 | // Pins the height of this view to the height of its superview, with uniform margins.
 | ||
| 
											8 years ago
										 | - (NSArray<NSLayoutConstraint *> *)autoPinHeightToSuperviewWithMargin:(CGFloat)margin; | ||
|  | - (NSArray<NSLayoutConstraint *> *)autoPinHeightToSuperview; | ||
| 
											9 years ago
										 | 
 | ||
| 
											7 years ago
										 | - (NSArray<NSLayoutConstraint *> *)ows_autoPinToSuperviewEdges; | ||
|  | - (NSArray<NSLayoutConstraint *> *)ows_autoPinToSuperviewMargins; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | - (NSLayoutConstraint *)autoHCenterInSuperview; | ||
|  | - (NSLayoutConstraint *)autoVCenterInSuperview; | ||
| 
											9 years ago
										 | 
 | ||
| 
											9 years ago
										 | - (void)autoPinWidthToWidthOfView:(UIView *)view; | ||
|  | - (void)autoPinHeightToHeightOfView:(UIView *)view; | ||
|  | 
 | ||
|  | - (NSLayoutConstraint *)autoPinToSquareAspectRatio; | ||
| 
											7 years ago
										 | - (NSLayoutConstraint *)autoPinToAspectRatioWithSize:(CGSize)size; | ||
| 
											8 years ago
										 | - (NSLayoutConstraint *)autoPinToAspectRatio:(CGFloat)ratio; | ||
| 
											7 years ago
										 | - (NSLayoutConstraint *)autoPinToAspectRatio:(CGFloat)ratio relation:(NSLayoutRelation)relation; | ||
| 
											9 years ago
										 | 
 | ||
| 
											9 years ago
										 | #pragma mark - Content Hugging and Compression Resistance
 | ||
|  | 
 | ||
|  | - (void)setContentHuggingLow; | ||
|  | - (void)setContentHuggingHigh; | ||
|  | - (void)setContentHuggingHorizontalLow; | ||
|  | - (void)setContentHuggingHorizontalHigh; | ||
|  | - (void)setContentHuggingVerticalLow; | ||
|  | - (void)setContentHuggingVerticalHigh; | ||
|  | 
 | ||
|  | - (void)setCompressionResistanceLow; | ||
|  | - (void)setCompressionResistanceHigh; | ||
|  | - (void)setCompressionResistanceHorizontalLow; | ||
|  | - (void)setCompressionResistanceHorizontalHigh; | ||
|  | - (void)setCompressionResistanceVerticalLow; | ||
|  | - (void)setCompressionResistanceVerticalHigh; | ||
|  | 
 | ||
| 
											9 years ago
										 | #pragma mark - Manual Layout
 | ||
|  | 
 | ||
|  | - (CGFloat)left; | ||
|  | - (CGFloat)right; | ||
|  | - (CGFloat)top; | ||
|  | - (CGFloat)bottom; | ||
|  | - (CGFloat)width; | ||
|  | - (CGFloat)height; | ||
|  | 
 | ||
|  | - (void)centerOnSuperview; | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - RTL
 | ||
|  | 
 | ||
|  | // For correct right-to-left layout behavior, use "leading" and "trailing",
 | ||
|  | // not "left" and "right".
 | ||
|  | //
 | ||
| 
											8 years ago
										 | // These methods use layoutMarginsGuide anchors, which behave differently than
 | ||
|  | // the PureLayout alternatives you indicated. Honoring layoutMargins is
 | ||
|  | // particularly important in cell layouts, where it lets us align with the
 | ||
|  | // complicated built-in behavior of table and collection view cells' default
 | ||
|  | // contents.
 | ||
|  | //
 | ||
| 
											8 years ago
										 | // NOTE: the margin values are inverted in RTL layouts.
 | ||
| 
											7 years ago
										 | 
 | ||
| 
											8 years ago
										 | - (NSArray<NSLayoutConstraint *> *)autoPinLeadingAndTrailingToSuperviewMargin; | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToSuperviewMargin; | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToSuperviewMarginWithInset:(CGFloat)margin; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToSuperviewMargin; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToSuperviewMarginWithInset:(CGFloat)margin; | ||
|  | 
 | ||
|  | - (NSLayoutConstraint *)autoPinTopToSuperviewMargin; | ||
|  | - (NSLayoutConstraint *)autoPinTopToSuperviewMarginWithInset:(CGFloat)margin; | ||
|  | - (NSLayoutConstraint *)autoPinBottomToSuperviewMargin; | ||
|  | - (NSLayoutConstraint *)autoPinBottomToSuperviewMarginWithInset:(CGFloat)margin; | ||
|  | 
 | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToTrailingEdgeOfView:(UIView *)view; | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToTrailingEdgeOfView:(UIView *)view offset:(CGFloat)margin; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToLeadingEdgeOfView:(UIView *)view; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToLeadingEdgeOfView:(UIView *)view offset:(CGFloat)margin; | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToEdgeOfView:(UIView *)view; | ||
|  | - (NSLayoutConstraint *)autoPinLeadingToEdgeOfView:(UIView *)view offset:(CGFloat)margin; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToEdgeOfView:(UIView *)view; | ||
|  | - (NSLayoutConstraint *)autoPinTrailingToEdgeOfView:(UIView *)view offset:(CGFloat)margin; | ||
| 
											8 years ago
										 | // Return Right on LTR and Left on RTL.
 | ||
| 
											8 years ago
										 | - (NSTextAlignment)textAlignmentUnnatural; | ||
| 
											8 years ago
										 | // Leading and trailing anchors honor layout margins.
 | ||
|  | // When using a UIView as a "div" to structure layout, we don't want it to have margins.
 | ||
|  | - (void)setHLayoutMargins:(CGFloat)value; | ||
| 
											8 years ago
										 | 
 | ||
| 
											7 years ago
										 | - (NSArray<NSLayoutConstraint *> *)autoPinToEdgesOfView:(UIView *)view; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (void)traverseViewHierarchyWithVisitor:(UIViewVisitorBlock)visitor; | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - Containers
 | ||
|  | 
 | ||
|  | + (UIView *)containerView; | ||
|  | 
 | ||
|  | + (UIView *)verticalStackWithSubviews:(NSArray<UIView *> *)subviews spacing:(int)spacing; | ||
|  | 
 | ||
| 
											9 years ago
										 | #pragma mark - Debugging
 | ||
|  | 
 | ||
|  | - (void)addBorderWithColor:(UIColor *)color; | ||
|  | - (void)addRedBorder; | ||
|  | 
 | ||
| 
											9 years ago
										 | // Add red border to self, and all subviews recursively.
 | ||
|  | - (void)addRedBorderRecursively; | ||
|  | 
 | ||
| 
											9 years ago
										 | @end | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | #pragma mark -
 | ||
|  | 
 | ||
|  | @interface UIScrollView (OWS) | ||
|  | 
 | ||
| 
											7 years ago
										 | // Returns YES if contentInsetAdjustmentBehavior is disabled.
 | ||
|  | - (BOOL)applyScrollViewInsetsFix; | ||
| 
											8 years ago
										 | 
 | ||
|  | @end | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark -
 | ||
|  | 
 | ||
|  | @interface UIStackView (OWS) | ||
|  | 
 | ||
| 
											7 years ago
										 | - (UIView *)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor; | ||
| 
											8 years ago
										 | 
 | ||
| 
											7 years ago
										 | - (UIView *)addBorderViewWithColor:(UIColor *)color strokeWidth:(CGFloat)strokeWidth cornerRadius:(CGFloat)cornerRadius; | ||
|  | 
 | ||
| 
											8 years ago
										 | @end | ||
|  | 
 | ||
| 
											7 years ago
										 | #pragma mark -
 | ||
|  | 
 | ||
|  | @interface UIAlertAction (OWS) | ||
|  | 
 | ||
|  | + (instancetype)actionWithTitle:(nullable NSString *)title | ||
|  |         accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier | ||
|  |                           style:(UIAlertActionStyle)style | ||
|  |                         handler:(void (^__nullable)(UIAlertAction *action))handler; | ||
|  | 
 | ||
|  | @end | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - Macros
 | ||
|  | 
 | ||
| 
											7 years ago
										 | CGFloat CGHairlineWidth(void); | ||
| 
											7 years ago
										 | 
 | ||
| 
											8 years ago
										 | NS_ASSUME_NONNULL_END |