Skip to content
Merged
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
25 changes: 22 additions & 3 deletions RNTester/js/ActivityIndicatorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import React, {Component} from 'react';
import {ActivityIndicator, StyleSheet, View} from 'react-native';
const Platform = require('Platform');

/**
* Optional Flowtype state and timer types definition
Expand Down Expand Up @@ -99,8 +100,18 @@ exports.examples = [
render() {
return (
<View style={styles.horizontal}>
<ActivityIndicator color="#0000ff" />
<ActivityIndicator color="#aa00aa" />
<ActivityIndicator
color={
Platform.OS === 'macos'
? {dynamic: {light: 'black', dark: 'white'}}
: '#0000ff'
}
/>
<ActivityIndicator
color={
Platform.OS === 'macos' ? {semantic: 'textColor'} : '#aa00aa'
Comment thread
tom-un marked this conversation as resolved.
}
/>
<ActivityIndicator color="#aa3300" />
<ActivityIndicator color="#00aa00" />
</View>
Expand Down Expand Up @@ -148,7 +159,7 @@ exports.examples = [
size="large"
/>
);
}
},
},
{
platform: 'android',
Expand Down Expand Up @@ -184,5 +195,13 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'space-around',
padding: 8,
...Platform.select({
macos: {
backgroundColor: {semantic: 'windowBackgroundColor'},
},
default: {
backgroundColor: undefined,
},
}),
},
});
35 changes: 24 additions & 11 deletions React/Views/RCTActivityIndicatorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,31 @@ - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndi
}
}

Comment thread
tom-un marked this conversation as resolved.
- (void)setColor:(UIColor*)color
- (void)setColor: (UIColor*)color
{
_color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"];
[colorPoly setDefaults];
CIVector *redVector = [CIVector vectorWithX:color.redComponent Y:0 Z:0 W:0];
CIVector *greenVector = [CIVector vectorWithX:color.greenComponent Y:0 Z:0 W:0];
CIVector *blueVector = [CIVector vectorWithX:color.blueComponent Y:0 Z:0 W:0];
[colorPoly setValue:redVector forKey:@"inputRedCoefficients"];
[colorPoly setValue:greenVector forKey:@"inputGreenCoefficients"];
[colorPoly setValue:blueVector forKey:@"inputBlueCoefficients"];
self.contentFilters = @[colorPoly];
if (_color != color) {
_color = color;
[self setNeedsDisplay:YES];
}
}

- (void)updateLayer
{
[super updateLayer];
if (_color) {
CGFloat r, g, b, a;
[[_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a];

CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"];
[colorPoly setDefaults];
CIVector *redVector = [CIVector vectorWithX:r Y:0 Z:0 W:0];
CIVector *greenVector = [CIVector vectorWithX:g Y:0 Z:0 W:0];
CIVector *blueVector = [CIVector vectorWithX:b Y:0 Z:0 W:0];
[colorPoly setValue:redVector forKey:@"inputRedCoefficients"];
[colorPoly setValue:greenVector forKey:@"inputGreenCoefficients"];
[colorPoly setValue:blueVector forKey:@"inputBlueCoefficients"];
self.contentFilters = @[colorPoly];
}
}

- (void)setHidesWhenStopped:(BOOL)hidesWhenStopped
Expand Down