Skip to content

Commit

Permalink
Fix animated icon glitches
Browse files Browse the repository at this point in the history
Swapping the eye icon was leading to color glitches, due to some bug deep within react-native-reanimated.

The solution involves rendering a single `Animated.Text` component, and simply changing the text content inside. This avoids re-wiring the Reanimated dependency graph, which is what seems to be causing the problem.

We achieve this with *almost* the same icon API as before by adding an `off` property to the eye icon, to switch between the two variants. We also refactor the animated icon implementation to use a raw text element, instead of the react-native-vector-icon wrapper component.
  • Loading branch information
swansontec committed Jan 17, 2024
1 parent 435537d commit d1e1e8c
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 182 deletions.
50 changes: 14 additions & 36 deletions src/__tests__/modals/__snapshots__/CategoryModal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -704,25 +704,14 @@ exports[`CategoryModal should render with a subcategory 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 22,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 22,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down Expand Up @@ -2135,25 +2124,14 @@ exports[`CategoryModal should render with an empty subcategory 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 0,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down
50 changes: 14 additions & 36 deletions src/__tests__/modals/__snapshots__/WalletListModal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,14 @@ exports[`WalletListModal should render with loading props 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 22,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 22,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down Expand Up @@ -392,25 +381,14 @@ exports[`WalletListModal should render with loading props 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 0,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,25 +639,14 @@ exports[`CreateWalletAccountSelect renders 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 0,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,25 +613,14 @@ exports[`CreateWalletImportScene should render with loading props 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 0,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,25 +379,14 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 22,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 22,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down Expand Up @@ -563,25 +552,14 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
}
>
<Text
adjustsFontSizeToFit={true}
allowFontScaling={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#FFFFFF",
"fontSize": 0,
},
{
"fontFamily": "anticon",
"fontStyle": "normal",
"fontWeight": "normal",
},
{},
]
{
"color": "#FFFFFF",
"fontFamily": "anticon",
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
}
>
Expand Down
Loading

0 comments on commit d1e1e8c

Please sign in to comment.