-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b47d58d
commit 6be214d
Showing
6 changed files
with
62 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import memoize from 'lodash/memoize'; | ||
import { Dimensions } from 'react-native'; | ||
|
||
const { width } = Dimensions.get('window'); | ||
|
||
enum BREAKPOINTS { | ||
// xsphone = 320, | ||
smphone = 360, // small android phone: 360 | ||
// mdphone = 375, // iphoneSE and up | ||
// lgphone = 390, // iphone15 and up | ||
// xlphone = 400, | ||
} | ||
|
||
/** | ||
* Check if the screen is at least the specified breakpoint | ||
**/ | ||
const up = (min: keyof typeof BREAKPOINTS): boolean => { | ||
return width > BREAKPOINTS[min]; | ||
}; | ||
|
||
/** | ||
* Check if the screen is at most the specified breakpoint | ||
**/ | ||
const down = (max: keyof typeof BREAKPOINTS): boolean => { | ||
return width <= BREAKPOINTS[max]; | ||
}; | ||
|
||
const breakpoints = { | ||
up: memoize(up), | ||
down: memoize(down), | ||
}; | ||
|
||
type TBreakpoints = typeof breakpoints; | ||
|
||
const useBreakpoints = (): TBreakpoints => { | ||
return breakpoints; | ||
}; | ||
|
||
export default useBreakpoints; |