Khởi tạo ban đầu
This commit is contained in:
23
hooks/use-platform.ts
Normal file
23
hooks/use-platform.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export type PlatformType = "ios" | "android" | "web";
|
||||
|
||||
export const usePlatform = (): PlatformType => {
|
||||
return Platform.OS as PlatformType;
|
||||
};
|
||||
|
||||
export const useIsIOS = (): boolean => {
|
||||
return Platform.OS === "ios";
|
||||
};
|
||||
|
||||
export const useIsAndroid = (): boolean => {
|
||||
return Platform.OS === "android";
|
||||
};
|
||||
|
||||
export const useIsWeb = (): boolean => {
|
||||
return Platform.OS === "web";
|
||||
};
|
||||
|
||||
export const getPlatform = (): PlatformType => {
|
||||
return Platform.OS as PlatformType;
|
||||
};
|
||||
Reference in New Issue
Block a user