mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +02:00
Merge pull request #120 from aglitchman/patch-2
Optimize Mobile/Web detection
This commit is contained in:
commit
b254448e54
@ -51,6 +51,10 @@ M.PIVOTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.SYS_INFO = sys.get_sys_info()
|
||||||
|
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name
|
||||||
|
|
||||||
|
|
||||||
M.OS = {
|
M.OS = {
|
||||||
ANDROID = "Android",
|
ANDROID = "Android",
|
||||||
IOS = "iPhone OS",
|
IOS = "iPhone OS",
|
||||||
|
@ -5,6 +5,7 @@ local const = require("druid.const")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local system_name = sys.get_sys_info().system_name
|
||||||
|
|
||||||
--- Text node or icon node can be nil
|
--- Text node or icon node can be nil
|
||||||
local function get_text_width(text_node)
|
local function get_text_width(text_node)
|
||||||
@ -182,16 +183,14 @@ end
|
|||||||
--- Check if device is mobile (Android or iOS)
|
--- Check if device is mobile (Android or iOS)
|
||||||
-- @function helper..is_mobile
|
-- @function helper..is_mobile
|
||||||
function M.is_mobile()
|
function M.is_mobile()
|
||||||
local system_name = sys.get_sys_info().system_name
|
return const.CURRENT_SYSTEM_NAME == const.OS.IOS or const.CURRENT_SYSTEM_NAME == const.OS.ANDROID
|
||||||
return system_name == const.OS.IOS or system_name == const.OS.ANDROID
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if device is HTML5
|
--- Check if device is HTML5
|
||||||
-- @function helper.is_web
|
-- @function helper.is_web
|
||||||
function M.is_web()
|
function M.is_web()
|
||||||
local system_name = sys.get_sys_info().system_name
|
return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER
|
||||||
return system_name == const.OS.BROWSER
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user