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: linear gradient android #45433

Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f84c01
Linear gradient
intergalacticspacehighway Jun 20, 2024
19a21d3
fix
intergalacticspacehighway Jul 15, 2024
f7ac2c7
revert ios changes
intergalacticspacehighway Jul 15, 2024
1b50d8a
nits
intergalacticspacehighway Jul 15, 2024
b75d4af
fix: snapshot test
intergalacticspacehighway Jul 15, 2024
d79e1d3
rename background to experimental_backgroundImage
intergalacticspacehighway Jul 19, 2024
d38772c
merge main
intergalacticspacehighway Jul 19, 2024
f382d98
fix snapshot tests
intergalacticspacehighway Jul 19, 2024
6ffd05d
fix: prettier format
intergalacticspacehighway Jul 19, 2024
1d6f728
gate experimental_backgroundImage to fabric only
intergalacticspacehighway Jul 20, 2024
1ee4743
fix: native static view config warning
intergalacticspacehighway Jul 20, 2024
9cf5c15
fix: prettier
intergalacticspacehighway Jul 20, 2024
badf935
fix: type
intergalacticspacehighway Jul 20, 2024
d4e1436
chore: improve examples
intergalacticspacehighway Jul 20, 2024
6c0fe54
Merge branch 'main' into feat/linear-gradient-android
intergalacticspacehighway Jul 27, 2024
3df8f0e
fix: case insensitive css linear gradient values
intergalacticspacehighway Jul 27, 2024
98c6cf6
improve testcases
intergalacticspacehighway Jul 27, 2024
0c4e20a
improve testcases
intergalacticspacehighway Jul 27, 2024
62aa6b3
rename type background image primitive to gradient value
intergalacticspacehighway Jul 28, 2024
cfa017f
convert css gradient to kotlin
intergalacticspacehighway Jul 28, 2024
7531702
rename cssgradient and move to uimanager style package
intergalacticspacehighway Jul 28, 2024
0cc8e89
merge main
intergalacticspacehighway Jul 28, 2024
8b43b07
fix types
intergalacticspacehighway Jul 28, 2024
b944b8f
move experimental_backgroundImage to view only
intergalacticspacehighway Jul 28, 2024
c29529f
baseviewprops handle enablePropIteratorSetter
intergalacticspacehighway Jul 28, 2024
085262c
move backgroundimage check to formsview
intergalacticspacehighway Jul 29, 2024
6592715
align style object closely to css spec
intergalacticspacehighway Jul 29, 2024
1cb92de
fix: ts type
intergalacticspacehighway Jul 29, 2024
2557da0
more test cases
intergalacticspacehighway Jul 29, 2024
f3c5aa3
case insensitive linear gradient fn test
intergalacticspacehighway Jul 29, 2024
28034d4
cleanup
intergalacticspacehighway Jul 29, 2024
2f1bf9e
draw gradient above background color
intergalacticspacehighway Jul 31, 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
Prev Previous commit
Next Next commit
improve testcases
null value testcases

multiple gradient new line testcase

multiple gradient new line testcase
  • Loading branch information
intergalacticspacehighway committed Jul 27, 2024
commit 0c4e20a06124694c378a3af37d9b410107807b10
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ describe('processBackgroundImage', () => {
]);
});

it('should return empty array for null values', () => {
let result = processBackgroundImage('');
expect(result).toEqual([]);
result = processBackgroundImage(null);
expect(result).toEqual([]);
result = processBackgroundImage(undefined);
expect(result).toEqual([]);
});

it('should return empty array for invalid values', () => {
let result = processBackgroundImage('linear-');
expect(result).toEqual([]);
});

it('should process a linear gradient with whitespaces in direction', () => {
const input = 'linear-gradient(to bottom right, red, blue)';
const result = processBackgroundImage(input);
Expand All @@ -63,6 +77,23 @@ describe('processBackgroundImage', () => {
]);
});

it('should process a linear gradient with random whitespaces', () => {
const input =
' linear-gradient(to bottom right, red 30%, blue 80%) ';
const result = processBackgroundImage(input);
expect(result).toEqual([
{
type: 'linearGradient',
start: {x: 0, y: 0},
end: {x: 1, y: 1},
colorStops: [
{color: processColor('red'), position: 0.3},
{color: processColor('blue'), position: 0.8},
],
},
]);
});

it('should process a linear gradient with angle', () => {
const input = 'linear-gradient(45deg, red, blue)';
const result = processBackgroundImage(input);
Expand Down Expand Up @@ -116,14 +147,26 @@ describe('processBackgroundImage', () => {
});

it('should process multiple linear gradients', () => {
const input =
'linear-gradient(to right, red, blue), linear-gradient(to bottom, green, yellow)';
const input = `
linear-gradient(to right, red, blue),
linear-gradient(to bottom, green, yellow)`;
const result = processBackgroundImage(input);
expect(result).toHaveLength(2);
expect(result[0].type).toEqual('linearGradient');
expect(result[0].start).toEqual({x: 0, y: 0.5});
expect(result[0].end).toEqual({x: 1, y: 0.5});
expect(result[0].colorStops).toEqual([
{color: processColor('red'), position: 0},
{color: processColor('blue'), position: 1},
]);
expect(result[1].type).toEqual('linearGradient');
expect(result[1].start).toEqual({x: 0.5, y: 0});
expect(result[1].end).toEqual({x: 0.5, y: 1});

expect(result[1].colorStops).toEqual([
{color: processColor('green'), position: 0},
{color: processColor('yellow'), position: 1},
]);
});

it('should process a linear gradient with multiple color stops', () => {
Expand Down Expand Up @@ -202,6 +245,12 @@ describe('processBackgroundImage', () => {
expect(result).toEqual([]);
});

it('should return empty array for invalid color stop unit', () => {
const input = 'linear-gradient(to left, red 5, blue)';
const result = processBackgroundImage(input);
expect(result).toEqual([]);
});

it('should process an array of BackgroundPrimitive objects', () => {
const input = [
{
Expand Down