Skip to content

Commit

Permalink
fix: fix adaptive background gradients (#13447)
Browse files Browse the repository at this point in the history
* fix: fix adaptive background gradients

* fix: also clear cache, set colors again
  • Loading branch information
hansemannn authored May 17, 2022
1 parent 49657d9 commit 6435c02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiGradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ typedef enum {
@property (nonatomic, readwrite, assign) BOOL backfillEnd;

- (void)paintContext:(CGContextRef)context bounds:(CGRect)bounds;
- (void)clearCache;
- (void)setColors:(NSArray *)newColors;

+ (TiGradient *)gradientFromObject:(id)value proxy:(TiProxy *)proxy;

Expand Down
11 changes: 10 additions & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/TiUIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,25 @@ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
[super traitCollectionDidChange:previousTraitCollection];

// Redraw the border- and view shadow color since they're using CGColor references
// Redraw the border color
id borderColor = [self.proxy valueForKey:@"borderColor"];
if (borderColor != nil) {
[self setBorderColor_:borderColor];
}

// Redraw the view shadow color
id viewShadowColor = [self.proxy valueForKey:@"viewShadowColor"];
if (viewShadowColor != nil) {
[self setViewShadowColor_:viewShadowColor];
}

// Redraw the background gradient
TiGradient *backgroundGradient = [self.proxy valueForKey:@"backgroundGradient"];
if (backgroundGradient != nil) {
[backgroundGradient clearCache];
[backgroundGradient setColors:[backgroundGradient valueForKey:@"colors"]];
[self setBackgroundGradient_:backgroundGradient];
}
}

#pragma mark - Accessibility API
Expand Down

0 comments on commit 6435c02

Please sign in to comment.