Skip to content

Commit

Permalink
[Meta] Updated for v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
LacertosusRepo committed Jul 17, 2021
1 parent cfff861 commit c0fbc6f
Show file tree
Hide file tree
Showing 69 changed files with 905 additions and 180 deletions.
249 changes: 244 additions & 5 deletions docs/index.html

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion docuowl/2.Cells/4.LDStylePickerCell/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A style picker just like Apple's light/dark mode picker. Useful for visually con
- label `string`
- String to be displayed below the option's image.

- appearanceOption `string`
- appearanceOption `string/integer`
- Value that will be saved when the option is selected.

- image `string`
Expand All @@ -18,6 +18,9 @@ A style picker just like Apple's light/dark mode picker. Useful for visually con
- imageAlt `string`
- Name of an alternative image to be displayed when the device is in dark mode. This is an optional key, if ignored the normal image will be used in both light & dark mode.

- id `string`
- Identifier for the option view.

- infoMessage `string`
- Message for the info alert.

Expand Down
3 changes: 3 additions & 0 deletions docuowl/2.Cells/5.LDSwitchWithInfoCell/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ Your favorite switch cell but with button to show an alert with more information
- infoMessage `string`
- Message for the info alert.

- infoAlternativeStyle `bool`
- Alternative style using the whole cell as a button for more information. A subtitle is displayed beneath the cell's label which can be overridden using the `cellSubtitleText` key.

- localizationTable `string`
- Name of localization table to lookup localization key.
43 changes: 43 additions & 0 deletions docuowl/ParvusConstraint/1.ld_constrainView/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
Title: ld_constrainView
---
Constrain specified anchors from one view to another with optional constants.

#- Parameters
- primaryView `UIView`
- View to be anchored.

- secondaryView `UIView`
- View to be anchored to.

- anchors `string`
- Anchors to add constraints to. Abbreviations are used and each should be separated by a string.
- <span style="color:#DE2218">w</span>
- Width Anchor

- <span style="color:#DE2218">h</span>
- Height Anchor

- <span style="color:#DE2218">x</span>
- Center X Anchor

- <span style="color:#DE2218">y</span>
- Center Y Anchor

- <span style="color:#DE2218">top</span>
- Top Anchor

- <span style="color:#DE2218">bottom</span>
- Bottom Anchor

- <span style="color:#DE2218">leading</span>
- Leading Anchor

- <span style="color:#DE2218">trailing</span>
- Trailing Anchor

- constants `LDLayoutConstants`
- Struct with constants for each anchor. Multiple helper functions to allow to create `LDLayoutConstants`.

- Return Value `array`
- Array of constraints added to the `primaryView`. Each constraint's identifier is set to the corresponding anchor used for the constraint.
12 changes: 12 additions & 0 deletions docuowl/ParvusConstraint/1.ld_constrainView/sidenotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! Declaration
```objc
+(NSArray <NSLayoutConstraint *>*)ld_constrainView:(UIView *)primaryView toView:(UIView *)secondaryView anchors:(NSString *)anchors constants:(LDLayoutConstants)constants;
+(NSArray <NSLayoutConstraint *>*)ld_constrainView:(UIView *)primaryView toView:(UIView *)secondaryView anchors:(NSString *)anchors;
```

#! Example Usage
```objc
[NSLayoutConstraint ld_constrainView:firstView toView:otherView anchors:@"w, h" constants:LDSizeConstantsMake(100, 50)];

[NSLayoutConstraint ld_constrainView:firstView toView:otherView anchors:@"x, leading, trailing"];
```
17 changes: 17 additions & 0 deletions docuowl/ParvusConstraint/2.ld_centerView/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Title: ld_centerView
---
Constrain view to the center X and Y anchors of a specified view. Also add height and width anchors.

#- Parameters
- primaryView `UIView`
- View to be anchored.

- secondaryView `UIView`
- View to be anchored to.

- constants `LDLayoutConstants`
- Struct with constants for each anchor. Multiple helper functions to allow to create `LDLayoutConstants`.

- Return Value `array`
- Array of constraints added to the `primaryView`. Each constraint's identifier is set to the corresponding anchor used for the constraint.
9 changes: 9 additions & 0 deletions docuowl/ParvusConstraint/2.ld_centerView/sidenotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! Declaration
```objc
+(NSArray <NSLayoutConstraint *>*)ld_centerView:(UIView *)primaryView inView:(UIView *)secondaryView constants:(LDLayoutConstants)constants;
```

#! Example Usage
```objc
[NSLayoutConstraint ld_centerView:firstView inView:otherView constants:LDSizeConstantsMake(200, 40)];
```
17 changes: 17 additions & 0 deletions docuowl/ParvusConstraint/3.ld_sizeView/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Title: ld_sizeView
---
Constrain view's width and height anchors to constants.

#- Parameters
- primaryView `UIView`
- View to be anchored.

- secondaryView `UIView`
- View to be anchored to.

- constants `LDLayoutConstants`
- Struct with constants for each anchor. Multiple helper functions to allow to create `LDLayoutConstants`.

- Return Value `array`
- Array of constraints added to the `primaryView`. Each constraint's identifier is set to the corresponding anchor used for the constraint.
9 changes: 9 additions & 0 deletions docuowl/ParvusConstraint/3.ld_sizeView/sidenotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! Declaration
```objc
+(NSArray <NSLayoutConstraint *>*)ld_sizeView:(UIView *)primaryView inView:(UIView *)secondaryView constants:(LDLayoutConstants)constants;
```

#! Example Usage
```objc
[NSLayoutConstraint ld_sizeView:firstView inView:otherView constants:LDSizeConstantsMake(96, 82)];
```
69 changes: 69 additions & 0 deletions docuowl/ParvusConstraint/4.LDLayoutConstraints/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
Title: LDLayoutConstants
---
Struct with constants for each anchor. Multiple helper functions to allow to create `LDLayoutConstants`.

#- Parameters
- width `float`
- Width anchor constant.

- height `float`
- Height anchor constant.

- x `float`
- Center X anchor constant.

- y `float`
- Center Y anchor constant.

- top `float`
- Top anchor constant.

- bottom `float`
- Bottom anchor constant.

- leading `float`
- Leading anchor constant.

- trailing `float`
- Trailing anchor constant.

- Return Value `LDLayoutConstants`
- Constants to be used with ParvusConstraint.

---
#- Functions
- LDLayoutConstantsMake()
- Function with parameters for each constant. Very long.

- LDSelectConstantsMake()
- Function using a dictionary to set only specific constants.
- <span style="color:#DE2218">w</span>
- Width Constant

- <span style="color:#DE2218">h</span>
- Height Constant

- <span style="color:#DE2218">x</span>
- Center X Constant

- <span style="color:#DE2218">y</span>
- Center Y Constant

- <span style="color:#DE2218">tp</span>
- Top Constant

- <span style="color:#DE2218">b</span>
- Bottom Constant

- <span style="color:#DE2218">l</span>
- Leading Constant

- <span style="color:#DE2218">tl</span>
- Trailing Constant

- LDSizeConstantsMake()
- Function with parameters only for width and height constants.

- LDEdgeConstantsMake()
- Function with parameters for top, bottom, leading, and trailing constants.
29 changes: 29 additions & 0 deletions docuowl/ParvusConstraint/4.LDLayoutConstraints/sidenotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! Declaration
```objc
struct LDLayoutConstants {
CGFloat width;
CGFloat height;
CGFloat x;
CGFloat y;
CGFloat top;
CGFloat bottom;
CGFloat leading;
CGFloat trailing;
};
```

#! Example Usage
```objc
LDLayoutConstants constants;
constants.width = 100;
constants.top = -5;
constants.y = 23;
```

#! Functions
```objc
LDLayoutConstants LDLayoutConstantsMake(CGFloat width, CGFloat height, CGFloat x, CGFloat y, CGFloat top, CGFloat bottom, CGFloat leading, CGFloat trailing);
LDLayoutConstants LDSelectConstantsMake(NSDictionary <NSString *, NSNumber *>*constantsDict);
LDLayoutConstants LDSizeConstantsMake(CGFloat width, CGFloat height);
LDLayoutConstants LDEdgeConstantsMake(CGFloat top, CGFloat bottom, CGFloat leading, CGFloat trailing);
```
4 changes: 4 additions & 0 deletions docuowl/ParvusConstraint/meta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
Title: ParvusConstraint
---
Additions to NSLayoutConstraint that allows for (limited) easier constraints.
9 changes: 5 additions & 4 deletions source/LDAnimatedTitleView.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#import <UIKit/UIKit.h>

#import "NSLayoutConstraint+ParvusConstraint.h"
#import "LDAnimatedTitleView.h"

@implementation LDAnimatedTitleView {
Expand All @@ -23,11 +25,10 @@ -(instancetype)initWithTitle:(NSString *)title textColor:(UIColor *)color minimu

[self addSubview:_titleLabel];

[NSLayoutConstraint activateConstraints:@[
[self.widthAnchor constraintEqualToAnchor:_titleLabel.widthAnchor],
[self.heightAnchor constraintEqualToAnchor:_titleLabel.heightAnchor],
[NSLayoutConstraint ld_constrainView:self toView:_titleLabel anchors:@"w, h"];
[NSLayoutConstraint ld_constrainView:_titleLabel toView:self anchors:@"x"];

[_titleLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
[NSLayoutConstraint activateConstraints:@[
_yConstraint = [_titleLabel.centerYAnchor constraintEqualToAnchor:self.centerYAnchor constant:100],
]];
}
Expand Down
57 changes: 23 additions & 34 deletions source/LDHeaderView.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <version.h>

#import "sources/Common.h"
#import "sources/MTMaterialView.h"
#import "NSLayoutConstraint+ParvusConstraint.h"
#import "LDHeaderView.h"

NSString *const LDHeaderOptionIconFileName = @"LDHeaderOptionIconFileName";
Expand Down Expand Up @@ -69,11 +68,7 @@ -(instancetype)initWithTitle:(NSString *)title subtitles:(NSArray<NSString *> *)
_subtitleLabel.alpha = 0;

//Add constraints
[NSLayoutConstraint activateConstraints:@[
[_stackView.widthAnchor constraintEqualToAnchor:self.widthAnchor constant:-75],
[_stackView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
[_stackView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
]];
[NSLayoutConstraint ld_constrainView:_stackView toView:self anchors:@"w, x, y" constants:LDSelectConstantsMake(@{@"w" : @-75})];

//Configure views for layout
[self configureViewsForStyle:[options[LDHeaderOptionHeaderStyle] intValue]];
Expand Down Expand Up @@ -101,22 +96,7 @@ -(instancetype)initWithTitle:(NSString *)title subtitles:(NSArray<NSString *> *)
materialView.translatesAutoresizingMaskIntoConstraints = NO;
[self insertSubview:materialView atIndex:0];

UIImage *materialBackgroundImage;
NSString *materialBackgroundImageFileName = options[LDHeaderOptionBackgroundImageFileName] ?: nil;
if([materialBackgroundImageFileName isEqualToString:@"DeviceWallpaper"]) {
NSData *wallpaperData = [NSData dataWithContentsOfFile:@"/User/Library/SpringBoard/OriginalLockBackground.cpbitmap"];
if(wallpaperData) {
CFArrayRef wallpaperArrayRef = CPBitmapCreateImagesFromData((__bridge CFDataRef)wallpaperData, NULL, 1, NULL);
NSArray *wallpaperArray = (__bridge NSArray *)wallpaperArrayRef;
materialBackgroundImage = [[UIImage alloc] initWithCGImage:(__bridge CGImageRef)(wallpaperArray[0])];
CFRelease(wallpaperArrayRef);
}

} else if(materialBackgroundImageFileName.length > 0) {
materialBackgroundImage = [self getImageNamed:materialBackgroundImageFileName];
}

UIImageView *materialBackgroundImageView = [[UIImageView alloc] initWithImage:materialBackgroundImage];
UIImageView *materialBackgroundImageView = [[UIImageView alloc] init];
materialBackgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
materialBackgroundImageView.clipsToBounds = YES;
materialBackgroundImageView.layer.cornerRadius = 10;
Expand All @@ -125,17 +105,26 @@ -(instancetype)initWithTitle:(NSString *)title subtitles:(NSArray<NSString *> *)
[materialBackgroundImageView setContentCompressionResistancePriority:0 forAxis:UILayoutConstraintAxisVertical];
[self insertSubview:materialBackgroundImageView atIndex:0];

[NSLayoutConstraint activateConstraints:@[
[materialBackgroundImageView.widthAnchor constraintEqualToAnchor:_stackView.widthAnchor constant:50],
[materialBackgroundImageView.heightAnchor constraintEqualToAnchor:_stackView.heightAnchor constant:20],
[materialBackgroundImageView.centerXAnchor constraintEqualToAnchor:_stackView.centerXAnchor],
[materialBackgroundImageView.centerYAnchor constraintEqualToAnchor:_stackView.centerYAnchor],

[materialView.widthAnchor constraintEqualToAnchor:_stackView.widthAnchor constant:50],
[materialView.heightAnchor constraintEqualToAnchor:_stackView.heightAnchor constant:20],
[materialView.centerXAnchor constraintEqualToAnchor:_stackView.centerXAnchor],
[materialView.centerYAnchor constraintEqualToAnchor:_stackView.centerYAnchor],
]];
__weak UIImageView *imageView = materialBackgroundImageView;

NSString *materialBackgroundImageFileName = options[LDHeaderOptionBackgroundImageFileName] ?: nil;
if([materialBackgroundImageFileName isEqualToString:@"DeviceWallpaper"]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSData *wallpaperData = [NSData dataWithContentsOfFile:@"/User/Library/SpringBoard/OriginalLockBackground.cpbitmap"];
if(wallpaperData) {
CFArrayRef wallpaperArrayRef = CPBitmapCreateImagesFromData((__bridge CFDataRef)wallpaperData, NULL, 1, NULL);
NSArray *wallpaperArray = (__bridge NSArray *)wallpaperArrayRef;
imageView.image = [[UIImage alloc] initWithCGImage:(__bridge CGImageRef)(wallpaperArray[0])];
CFRelease(wallpaperArrayRef);
}
});

} else if(materialBackgroundImageFileName.length > 0) {
materialBackgroundImageView.image = [self getImageNamed:materialBackgroundImageFileName];;
}

[NSLayoutConstraint ld_constrainView:materialBackgroundImageView toView:_stackView anchors:@"w, h, x, y" constants:LDSizeConstantsMake(50, 20)];
[NSLayoutConstraint ld_constrainView:materialView toView:_stackView anchors:@"w, h, x, y" constants:LDSizeConstantsMake(50, 20)];
}
}

Expand Down
5 changes: 2 additions & 3 deletions source/LDInputSegmentTableCell.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#import <Preferences/PSSpecifier.h>
#import "sources/Common.h"
#import "LDInputSegmentTableCell.h"

Expand All @@ -11,7 +10,7 @@ -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStri
self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier];

if(self) {
_segmentValues = [specifier propertyForKey:@"validValues"];
_segmentValues = [specifier propertyForKey:PSValidValuesKey];

_inputButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
_inputButton.contentEdgeInsets = UIEdgeInsetsMake(4, 4, 4, 4);
Expand All @@ -30,7 +29,7 @@ -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStri
}

-(void)inputButtonTapped {
NSString *inputTitle = ([self.specifier propertyForKey:@"inputTitle"]) ?: [self.specifier propertyForKey:@"label"];
NSString *inputTitle = ([self.specifier propertyForKey:@"inputTitle"]) ?: [self.specifier propertyForKey:PSTitleKey];
NSString *inputMessage = [self.specifier propertyForKey:@"inputMessage"] ?: @"No input message provided for this cell.";

NSBundle *bundle = [self.specifier.target bundle];
Expand Down
Loading

0 comments on commit c0fbc6f

Please sign in to comment.