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
9 changes: 9 additions & 0 deletions src/feedback.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ export interface FeedbackShowOptions {
* Default depends on the 'type' property.
*/
backgroundColor?: Color;
/**
* Use gradient as background color. When this is used it overrides any 'backgroundColor' that is set.
* Default depends on the 'type' property.
*/
gradientColors?: Array<Color>;
/**
* The direction the gradient colors should span.
*/
gradientDirection?: 'left' | 'right' | 'up' | 'down';
/**
* A resource like 'customimage' which refers to:
* - iOS: App_Resources/customimage.png (and [email protected] / [email protected])
Expand Down
30 changes: 29 additions & 1 deletion src/feedback.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,35 @@ export class Feedback extends FeedbackCommon {
Feedback.getType(options.type),
Feedback.getPosition(options.position));

if (options.backgroundColor) {
if (options.gradientColors) {
message.alertViewBackgroundColor = UIColor.clearColor;

const layerGradient = CAGradientLayer.layer();
layerGradient.colors = NSArray.arrayWithArray(options.gradientColors.map(c => c.ios.CGColor));

const gradientDirection = options.gradientDirection || 'down';
switch (gradientDirection) {
case 'up':
layerGradient.startPoint = CGPointMake(.5, 1);
layerGradient.endPoint = CGPointMake(.5, 0);
break;
case 'left':
layerGradient.startPoint = CGPointMake(.5, 0);
layerGradient.endPoint = CGPointMake(.5, 1);
break;
case 'right':
layerGradient.startPoint = CGPointMake(0, .5);
layerGradient.endPoint = CGPointMake(1, .5);
break;
default:
layerGradient.startPoint = CGPointMake(.5, 0);
layerGradient.endPoint = CGPointMake(.5, 1);
break;
}
layerGradient.frame = message.view.bounds;

message.view.layer.insertSublayerAtIndex(layerGradient, 0);
} else if (options.backgroundColor) {
message.alertViewBackgroundColor = options.backgroundColor.ios;
}

Expand Down