Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filters support FeColorMatrix and FilterImage #2316

Merged
merged 45 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f24dc44
feat: add filter props to codegen renderable components
jakex7 Jun 26, 2024
17040b7
fix: extract opacity allow percentage values
jakex7 Jun 26, 2024
945c4bd
feat: introduce Filter and FeColorMatrix components on js side
jakex7 Jun 26, 2024
d3d1106
feat: create base FilterPrimitive and implement FeColorMatrix on android
jakex7 Jun 26, 2024
1383d8c
feat: apply Filter on render (android)
jakex7 Jun 26, 2024
a0d10a4
feat: relativeOn
jakex7 Jun 26, 2024
9441bf7
chore: generate paper files with codegen
jakex7 Jun 26, 2024
af1408b
feat: extract filter props
jakex7 Jun 26, 2024
8779534
feat: create base FilterPrimitive and implement FeColorMatrix on Appl…
jakex7 Jun 26, 2024
f7c2f92
feat: introduce Filter elementa and register filters on SvgView
jakex7 Jun 26, 2024
dccedd3
feat: apply filter on render (iOS)
jakex7 Jun 26, 2024
25b2cfe
feat: ntroduce and expose FilterImage component as a subpackage
jakex7 Jun 26, 2024
54dada1
test: add FeColorMatrix to example app
jakex7 Jun 26, 2024
0070897
test: add FilterImage to example app
jakex7 Jun 26, 2024
7adc9a9
feat: crop filters on iOS
jakex7 Jun 27, 2024
2e31af6
fix: crop filters on iOS
jakex7 Jun 27, 2024
41c4b3c
feat: crop filters on android
jakex7 Jun 27, 2024
74b7b00
feat: expose bitmap to use it as background source
jakex7 Jun 27, 2024
a5d13ad
test: clean imports in example app
jakex7 Jun 27, 2024
53e2387
docs: remove todo from readme and update USAGE.md
jakex7 Jun 28, 2024
8341da7
fix: make FilterImage container overflow hidden
jakex7 Jun 28, 2024
8b4213a
docs: update filter USAGE and add screenshots
jakex7 Jun 28, 2024
e0941b8
fix: crop rect on iOS
jakex7 Jun 28, 2024
49e6c6e
docs: duplicate Example to FabricExample
jakex7 Jul 2, 2024
7852a57
Merge branch 'main' into @jakex7/filtersFeColorMatrix
jakex7 Jul 2, 2024
1e2ba72
docs: remove examples title
jakex7 Jul 3, 2024
17b59b2
fix: make resultsMap private
jakex7 Jul 3, 2024
ff98501
fix: change exceptions to more meaningful names
jakex7 Jul 3, 2024
742fc40
fix: update bitmap names and fix element bounds
jakex7 Jul 3, 2024
ef4aa7f
fix: use getters
jakex7 Jul 3, 2024
1f64c60
fix: use relativeOn function in relativeOnWidth, relativeOnHeight, re…
jakex7 Jul 3, 2024
0d53477
fix: remove saturation range warning
jakex7 Jul 3, 2024
36726ac
Revert "fix: extract opacity allow percentage values"
jakex7 Jul 3, 2024
439e8e0
Revert "docs: remove examples title"
jakex7 Jul 3, 2024
425a0eb
change: extract Filters type ot separate type
jakex7 Jul 3, 2024
13a3674
fix: throw error on invalid filter subview
jakex7 Jul 3, 2024
75e9e80
fix: extractFilter types
jakex7 Jul 3, 2024
25d1773
fix: extractResizeMode on FilterImage
jakex7 Jul 3, 2024
b952bdf
Merge branch 'main' into @jakex7/filtersFeColorMatrix
jakex7 Jul 3, 2024
ca324ed
fix: install warn-once and use as warning form primitiveUnits prop
jakex7 Jul 5, 2024
ba2059c
Merge branch 'main' into @jakex7/filtersFeColorMatrix
jakex7 Jul 5, 2024
7969928
remove: fabric example src
jakex7 Jul 5, 2024
ce5a942
fix: extract resize mode on android
jakex7 Jul 8, 2024
6855ee9
Merge branch 'main' into @jakex7/filtersFeColorMatrix
jakex7 Jul 10, 2024
9837434
fix: use macos platform view
jakex7 Jul 10, 2024
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: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ module.exports = {
'prettier',
'plugin:import/typescript',
],
plugins: ['react', 'react-native', 'import', '@typescript-eslint', 'react-hooks'],
plugins: [
'react',
'react-native',
'import',
'@typescript-eslint',
'react-hooks',
],
env: {
'react-native/react-native': true,
},
settings: {
'import/core-modules': [
'react-native-svg',
'react-native-svg/css',
'react-native-svg/filter-image',
],
'import/resolver': {
'babel-module': {
Expand Down
8 changes: 4 additions & 4 deletions Example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNSVG (15.2.0-rc.0):
- RNSVG (15.3.0):
- React-Core
- SocketRocket (0.7.0)
- Yoga (0.0.0)
Expand Down Expand Up @@ -1423,10 +1423,10 @@ SPEC CHECKSUMS:
React-utils: f013537c3371270d2095bff1d594d00d4bc9261b
ReactCommon: 2cde697fd80bd31da1d6448d25a5803088585219
RNReanimated: 310731ce451b841548f5103111daa904082ce5d3
RNSVG: 55bf7e6e90717321191cde721072df87e9f8a024
RNSVG: a48668fd382115bc89761ce291a81c4ca5f2fd2e
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 56f906bf6c11c931588191dde1229fd3e4e3d557
Yoga: ff1d575b119f510a5de23c22a794872562078ccf

PODFILE CHECKSUM: 1db1bb5b37b884512b54b2c75095b3e51c78e6ad

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
154 changes: 64 additions & 90 deletions Example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,86 +13,13 @@ import {
ScrollView,
TouchableHighlight,
TouchableOpacity,
SafeAreaView,
} from 'react-native';
import {Modal, Platform} from 'react-native';
import {Svg, Circle, Line} from 'react-native-svg';

import * as examples from './examples';

const hairline = StyleSheet.hairlineWidth;

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
alignItems: 'center',
overflow: 'hidden',
},
contentContainer: {
alignSelf: 'stretch',
borderTopWidth: hairline,
borderTopColor: '#ccc',
borderBottomWidth: hairline,
borderBottomColor: '#ccc',
flexWrap: 'wrap',
flexDirection: 'row',
marginHorizontal: 10,
},
welcome: {
padding: 10,
color: '#f60',
fontSize: 18,
fontWeight: 'bold',
},
link: {
height: 40,
alignSelf: 'stretch',
width: Dimensions.get('window').width / 2 - 10,
},
title: {
marginLeft: 10,
},
cell: {
height: 40,
paddingHorizontal: 10,
alignSelf: 'stretch',
alignItems: 'center',
flexDirection: 'row',
borderTopWidth: hairline,
borderTopColor: '#ccc',
marginTop: -hairline,
backgroundColor: 'transparent',
},
close: {
position: 'absolute',
right: 20,
top: 40,
},
scroll: {
position: 'absolute',
top: 30,
right: 10,
bottom: 20,
left: 10,
backgroundColor: '#fff',
},
scrollContent: {
borderTopWidth: hairline,
borderTopColor: '#ccc',
},
example: {
paddingVertical: 25,
alignSelf: 'stretch',
alignItems: 'center',
borderBottomWidth: hairline,
borderBottomColor: '#ccc',
},
sampleTitle: {
marginHorizontal: 15,
fontSize: 16,
color: '#666',
},
});
import {commonStyles} from './commonStyles';

const names: (keyof typeof examples)[] = [
'Svg',
Expand All @@ -116,6 +43,8 @@ const names: (keyof typeof examples)[] = [
'Transforms',
'Markers',
'Mask',
'Filters',
'FilterImage',
];

const initialState = {
Expand All @@ -142,8 +71,8 @@ export default class SvgExample extends Component {
content: (
<View>
{samples.map((Sample, i) => (
<View style={styles.example} key={`sample-${i}`}>
<Text style={styles.sampleTitle}>{Sample.title}</Text>
<View style={commonStyles.example} key={`sample-${i}`}>
<Text style={commonStyles.sampleTitle}>{Sample.title}</Text>
<Sample />
</View>
))}
Expand Down Expand Up @@ -171,9 +100,9 @@ export default class SvgExample extends Component {
underlayColor="#ccc"
key={`example-${name}`}
onPress={() => this.show(name)}>
<View style={styles.cell}>
<View style={commonStyles.cell}>
{icon}
<Text style={styles.title}>{name}</Text>
<Text style={commonStyles.title}>{name}</Text>
</View>
</TouchableHighlight>
);
Expand All @@ -182,28 +111,30 @@ export default class SvgExample extends Component {

modalContent = () => (
<>
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContent}
scrollEnabled={this.state.scroll}>
{this.state.content}
</ScrollView>
<View style={styles.close}>
<SafeAreaView style={{flex: 1}}>
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContent}
scrollEnabled={this.state.scroll}>
{this.state.content}
</ScrollView>
</SafeAreaView>
<SafeAreaView style={styles.close}>
<TouchableOpacity activeOpacity={0.7} onPress={this.hide}>
<Svg height="20" width="20">
<Circle cx="10" cy="10" r="10" fill="red" />
<Line x1="4" y1="4" x2="16" y2="16" stroke="#fff" strokeWidth="2" />
<Line x1="4" y1="16" x2="16" y2="4" stroke="#fff" strokeWidth="2" />
</Svg>
</TouchableOpacity>
</View>
</SafeAreaView>
</>
);

render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>SVG library for React Apps</Text>
<SafeAreaView style={styles.container}>
<Text style={commonStyles.welcome}>SVG library for React Apps</Text>
<View style={styles.contentContainer}>{this.getExamples()}</View>
{(Platform.OS === 'windows' || Platform.OS === 'macos') &&
this.state.modal ? (
Expand All @@ -217,7 +148,50 @@ export default class SvgExample extends Component {
{this.modalContent()}
</Modal>
)}
</View>
</SafeAreaView>
);
}
}

const hairline = StyleSheet.hairlineWidth;

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
alignItems: 'center',
overflow: 'hidden',
},
contentContainer: {
alignSelf: 'stretch',
borderTopWidth: hairline,
borderTopColor: '#ccc',
borderBottomWidth: hairline,
borderBottomColor: '#ccc',
flexWrap: 'wrap',
flexDirection: 'row',
marginHorizontal: 10,
},
link: {
height: 40,
alignSelf: 'stretch',
width: Dimensions.get('window').width / 2 - 10,
},
close: {
position: 'absolute',
right: 20,
top: 20,
},
scroll: {
position: 'absolute',
top: 30,
right: 10,
bottom: 20,
left: 10,
backgroundColor: '#fff',
},
scrollContent: {
borderTopWidth: hairline,
borderTopColor: '#ccc',
},
});
Binary file added Example/src/assets/office.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Example/src/commonStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {StyleSheet} from 'react-native';

const hairline = StyleSheet.hairlineWidth;

export const commonStyles = StyleSheet.create({
welcome: {
padding: 10,
color: '#f60',
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
link: {
height: 40,
},
title: {
marginLeft: 10,
},
cell: {
height: 40,
paddingHorizontal: 10,
alignSelf: 'stretch',
alignItems: 'center',
flexDirection: 'row',
borderTopWidth: hairline,
borderTopColor: '#ccc',
marginTop: -hairline,
},
example: {
paddingVertical: 25,
alignSelf: 'stretch',
alignItems: 'center',
borderBottomWidth: hairline,
borderBottomColor: '#ccc',
},
sampleTitle: {
marginHorizontal: 15,
fontSize: 16,
color: '#666',
},
});
4 changes: 4 additions & 0 deletions Example/src/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import * as Reanimated from './examples/Reanimated';
import * as Transforms from './examples/Transforms';
import * as Markers from './examples/Markers';
import * as Mask from './examples/Mask';
import * as Filters from './examples/Filters';
import * as FilterImage from './examples/FilterImage';

export {
Svg,
Expand All @@ -42,4 +44,6 @@ export {
Transforms,
Markers,
Mask,
Filters,
FilterImage,
};
Loading
Loading