Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MDCSwipeToChoose/Internal/Views/UIView+MDCBorderedLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

- (void)constructBorderedLabelWithText:(NSString *)text
color:(UIColor *)color
size:(CGFloat)size
angle:(CGFloat)angle;

@end
9 changes: 6 additions & 3 deletions MDCSwipeToChoose/Internal/Views/UIView+MDCBorderedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ @implementation UIView (MDCBorderedLabel)

- (void)constructBorderedLabelWithText:(NSString *)text
color:(UIColor *)color
size:(CGFloat)size
angle:(CGFloat)angle {


self.layer.borderColor = color.CGColor;
self.layer.borderWidth = 5.f;
self.layer.cornerRadius = 10.f;

UILabel *label = [[UILabel alloc] initWithFrame:self.bounds];
label.text = [text uppercaseString];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont fontWithName:@"HelveticaNeue-CondensedBlack"
size:48.f];
size:size];
label.textColor = color;
[self addSubview:label];

self.transform = CGAffineTransformRotate(CGAffineTransformIdentity,
MDCDegreesToRadians(angle));
}
Expand Down
22 changes: 16 additions & 6 deletions MDCSwipeToChoose/Public/Options/MDCSwipeToChooseViewOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
*/
@property (nonatomic, strong) UIColor *likedColor;

/*!
* The image used to displayed in the `likeView`. If this is present, it will take
/* The image used to displayed in the `likeView`. If this is present, it will take
* precedence over the likeText
*/
@property (nonatomic, strong) UIImage *likedImage;
Expand All @@ -60,6 +59,12 @@
*/
@property (nonatomic, assign) CGFloat likedRotationAngle;

/*!
* The size of the text in the `likedView`. A default value is provided in the
* `-init` method.
*/
@property (nonatomic, assign) CGFloat likedTextSize;

/*!
* The text displayed in the `nopeView`. A default value is provided in the
* `-init` method.
Expand All @@ -73,16 +78,21 @@
@property (nonatomic, strong) UIColor *nopeColor;

/*!
* The image used to displayed in the `nopeView`. If this is present, it will take
* precedence over the nopeText
* The rotation angle of the `nopeView`. A default value is provided in the
* `-init` method.
*/
@property (nonatomic, assign) CGFloat nopeRotationAngle;

/* The image used to displayed in the `nopeView`. If this is present, it will take
* precedence over the likeText
*/
@property (nonatomic, strong) UIImage *nopeImage;

/*!
* The rotation angle of the `nopeView`. A default value is provided in the
* The size of the text in the `nopeView`. A default value is provided in the
* `-init` method.
*/
@property (nonatomic, assign) CGFloat nopeRotationAngle;
@property (nonatomic, assign) CGFloat nopeTextSize;

/*!
* The distance, in pixels, that a view must be panned in order to constitue a selection.
Expand Down
6 changes: 4 additions & 2 deletions MDCSwipeToChoose/Public/Options/MDCSwipeToChooseViewOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ - (instancetype)init {
_likedText = [NSLocalizedString(@"liked", nil) uppercaseString];
_likedColor = [UIColor colorWith8BitRed:29.f green:245.f blue:106.f alpha:1.f];
_likedRotationAngle = -15.f;

_likedTextSize = 48.f;

_nopeText = [NSLocalizedString(@"nope", nil) uppercaseString];
_nopeColor = [UIColor colorWith8BitRed:247.f green:91.f blue:37.f alpha:1.f];
_nopeRotationAngle = 15.f;

_nopeTextSize = 48.f;

_threshold = 100.f;
}
return self;
Expand Down
10 changes: 6 additions & 4 deletions MDCSwipeToChoose/Public/Views/MDCSwipeToChooseView.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)constructImageView {

- (void)constructLikedView {
CGFloat yOrigin = (self.options.likedImage ? MDCSwipeToChooseViewImageTopPadding : MDCSwipeToChooseViewTopPadding);

CGRect frame = CGRectMake(MDCSwipeToChooseViewHorizontalPadding,
yOrigin,
CGRectGetMidX(self.imageView.bounds),
Expand All @@ -89,6 +89,7 @@ - (void)constructLikedView {
self.likedView = [[UIView alloc] initWithFrame:frame];
[self.likedView constructBorderedLabelWithText:self.options.likedText
color:self.options.likedColor
size:self.options.likedTextSize
angle:self.options.likedRotationAngle];
}
self.likedView.alpha = 0.f;
Expand All @@ -111,6 +112,7 @@ - (void)constructNopeView {
self.nopeView = [[UIView alloc] initWithFrame:frame];
[self.nopeView constructBorderedLabelWithText:self.options.nopeText
color:self.options.nopeColor
size:self.options.nopeTextSize
angle:self.options.nopeRotationAngle];
}
self.nopeView.alpha = 0.f;
Expand All @@ -121,7 +123,7 @@ - (void)setupSwipeToChoose {
MDCSwipeOptions *options = [MDCSwipeOptions new];
options.delegate = self.options.delegate;
options.threshold = self.options.threshold;

__block UIView *likedImageView = self.likedView;
__block UIView *nopeImageView = self.nopeView;
__weak MDCSwipeToChooseView *weakself = self;
Expand All @@ -136,12 +138,12 @@ - (void)setupSwipeToChoose {
likedImageView.alpha = state.thresholdRatio;
nopeImageView.alpha = 0.f;
}

if (weakself.options.onPan) {
weakself.options.onPan(state);
}
};

[self mdc_swipeToChooseSetup:options];
}

Expand Down