-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Small changes following faster global search pr (#1320)
* Small changes following faster global search pr * Fix lint error
- Loading branch information
1 parent
8f783fd
commit cdc4ddc
Showing
12 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ThemeColors } from '@theme/types'; | ||
import color from 'color'; | ||
import { useAppSettings } from '@hooks/persisted'; | ||
import { interpolateColor } from 'react-native-reanimated'; | ||
|
||
const useLoadingColors = (theme: ThemeColors) => { | ||
const highlightColor = color(theme.primary).alpha(0.08).string(); | ||
const backgroundColor = color(theme.surface); | ||
|
||
let adjustedBackgroundColor; | ||
|
||
if (backgroundColor.isDark()) { | ||
adjustedBackgroundColor = | ||
backgroundColor.luminosity() !== 0 | ||
? backgroundColor.lighten(0.1).toString() | ||
: backgroundColor.negate().darken(0.98).toString(); | ||
} else { | ||
adjustedBackgroundColor = backgroundColor.darken(0.04).toString(); | ||
} | ||
|
||
const { disableLoadingAnimations } = useAppSettings(); | ||
|
||
if (disableLoadingAnimations) { | ||
//If loading animations is disabled highlight color is never shown so make background color more visible to compensate | ||
adjustedBackgroundColor = interpolateColor( | ||
0.01, //I have no idea why the interpolation amount has to be so small, I think its cus of the massive difference in alpha | ||
[0, 1], | ||
[adjustedBackgroundColor, highlightColor], | ||
); | ||
} | ||
|
||
return [highlightColor, adjustedBackgroundColor]; | ||
}; | ||
export default useLoadingColors; |