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

Add isMIUI helper #98

Merged
merged 3 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ declare module "react-device-detect" {
export import isWindows = ReactDeviceDetect.isWindows;
export import isMacOs = ReactDeviceDetect.isMacOs;
export import withOrientationChange = ReactDeviceDetect.withOrientationChange;
export import isMIUI = ReactDeviceDetect.isMIUI;
}

declare namespace ReactDeviceDetect {
Expand Down Expand Up @@ -196,4 +197,6 @@ declare namespace ReactDeviceDetect {
export const isWindows: boolean;

export const isMacOs: boolean;

export const isMIUI: boolean;
}
9 changes: 8 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ var BROWSER_TYPES = {
CHROMIUM: "Chromium",
IE: 'IE',
MOBILE_SAFARI: "Mobile Safari",
EDGE_CHROMIUM: "Edge Chromium"
EDGE_CHROMIUM: "Edge Chromium",
MIUI: "MIUI Browser"
};
var OS_TYPES = {
IOS: 'iOS',
Expand Down Expand Up @@ -444,6 +445,10 @@ var isIEType = function isIEType() {
return browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
};

var isMIUIType = function isMIUIType() {
return browser.name === BROWSER_TYPES.MIUI;
};

var isElectronType = function isElectronType() {
var nav = getNavigatorInstance();
var ua = nav && nav.userAgent.toLowerCase();
Expand Down Expand Up @@ -550,6 +555,7 @@ var isEdgeChromium = isEdgeChromiumType();
var isLegacyEdge = isEdgeType();
var isWindows = isWindowsType();
var isMacOs = isMacOsType();
var isMIUI = isMIUIType();

var AndroidView = function AndroidView(_ref) {
var renderWithFragment = _ref.renderWithFragment,
Expand Down Expand Up @@ -789,6 +795,7 @@ exports.isIPad13 = isIPad13;
exports.isIPhone13 = isIPhone13;
exports.isIPod13 = isIPod13;
exports.isLegacyEdge = isLegacyEdge;
exports.isMIUI = isMIUI;
exports.isMacOs = isMacOs;
exports.isMobile = isMobile;
exports.isMobileOnly = isMobileOnly;
Expand Down
2 changes: 2 additions & 0 deletions src/components/helpers/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const isSafariType = () => browser.name === BROWSER_TYPES.SAFARI || browser.name
const isMobileSafariType = () => browser.name === BROWSER_TYPES.MOBILE_SAFARI;
const isOperaType = () => browser.name === BROWSER_TYPES.OPERA;
const isIEType = () => browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
const isMIUIType = () => browser.name === BROWSER_TYPES.MIUI;
const isElectronType = () => {
const nav = getNavigatorInstance();
const ua = nav && nav.userAgent.toLowerCase();
Expand Down Expand Up @@ -111,3 +112,4 @@ export const isEdgeChromium = isEdgeChromiumType();
export const isLegacyEdge = isEdgeType();
export const isWindows = isWindowsType();
export const isMacOs = isMacOsType();
export const isMIUI = isMIUIType();
3 changes: 2 additions & 1 deletion src/components/helpers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const BROWSER_TYPES = {
CHROMIUM: "Chromium",
IE: 'IE',
MOBILE_SAFARI: "Mobile Safari",
EDGE_CHROMIUM: "Edge Chromium"
EDGE_CHROMIUM: "Edge Chromium",
MIUI: "MIUI Browser"
};

export const OS_TYPES = {
Expand Down