diff --git a/lib/const.dart b/lib/const.dart index 861eadf..ff06530 100644 --- a/lib/const.dart +++ b/lib/const.dart @@ -36,66 +36,6 @@ class EntityState { } -class EntityUIAction { - static const moreInfo = 'more-info'; - static const toggle = 'toggle'; - static const callService = 'call-service'; - static const navigate = 'navigate'; - static const none = 'none'; - - String tapAction = EntityUIAction.moreInfo; - String tapNavigationPath; - String tapService; - Map tapServiceData; - String holdAction = EntityUIAction.none; - String holdNavigationPath; - String holdService; - Map holdServiceData; - String doubleTapAction = EntityUIAction.none; - String doubleTapNavigationPath; - String doubleTapService; - Map doubleTapServiceData; - - EntityUIAction({rawEntityData}) { - if (rawEntityData != null) { - if (rawEntityData["tap_action"] != null) { - if (rawEntityData["tap_action"] is String) { - tapAction = rawEntityData["tap_action"]; - } else { - tapAction = - rawEntityData["tap_action"]["action"] ?? EntityUIAction.moreInfo; - tapNavigationPath = rawEntityData["tap_action"]["navigation_path"]; - tapService = rawEntityData["tap_action"]["service"]; - tapServiceData = rawEntityData["tap_action"]["service_data"]; - } - } - if (rawEntityData["hold_action"] != null) { - if (rawEntityData["hold_action"] is String) { - holdAction = rawEntityData["hold_action"]; - } else { - holdAction = - rawEntityData["hold_action"]["action"] ?? EntityUIAction.none; - holdNavigationPath = rawEntityData["hold_action"]["navigation_path"]; - holdService = rawEntityData["hold_action"]["service"]; - holdServiceData = rawEntityData["hold_action"]["service_data"]; - } - } - if (rawEntityData["double_tap_action"] != null) { - if (rawEntityData["double_tap_action"] is String) { - doubleTapAction = rawEntityData["double_tap_action"]; - } else { - doubleTapAction = - rawEntityData["double_tap_action"]["action"] ?? EntityUIAction.none; - doubleTapNavigationPath = rawEntityData["double_tap_action"]["navigation_path"]; - doubleTapService = rawEntityData["double_tap_action"]["service"]; - doubleTapServiceData = rawEntityData["double_tap_action"]["service_data"]; - } - } - } - } - -} - class CardType { static const HORIZONTAL_STACK = "horizontal-stack"; static const VERTICAL_STACK = "vertical-stack"; diff --git a/lib/entities/entity_wrapper.class.dart b/lib/entities/entity_wrapper.class.dart index 4d2fb8c..5233e5f 100644 --- a/lib/entities/entity_wrapper.class.dart +++ b/lib/entities/entity_wrapper.class.dart @@ -154,4 +154,64 @@ class EntityWrapper { } } +} + +class EntityUIAction { + static const moreInfo = 'more-info'; + static const toggle = 'toggle'; + static const callService = 'call-service'; + static const navigate = 'navigate'; + static const none = 'none'; + + String tapAction = EntityUIAction.moreInfo; + String tapNavigationPath; + String tapService; + Map tapServiceData; + String holdAction = EntityUIAction.moreInfo; + String holdNavigationPath; + String holdService; + Map holdServiceData; + String doubleTapAction = EntityUIAction.none; + String doubleTapNavigationPath; + String doubleTapService; + Map doubleTapServiceData; + + EntityUIAction({rawEntityData}) { + if (rawEntityData != null) { + if (rawEntityData["tap_action"] != null) { + if (rawEntityData["tap_action"] is String) { + tapAction = rawEntityData["tap_action"]; + } else { + tapAction = + rawEntityData["tap_action"]["action"] ?? EntityUIAction.moreInfo; + tapNavigationPath = rawEntityData["tap_action"]["navigation_path"]; + tapService = rawEntityData["tap_action"]["service"]; + tapServiceData = rawEntityData["tap_action"]["service_data"]; + } + } + if (rawEntityData["hold_action"] != null) { + if (rawEntityData["hold_action"] is String) { + holdAction = rawEntityData["hold_action"]; + } else { + holdAction = + rawEntityData["hold_action"]["action"] ?? EntityUIAction.none; + holdNavigationPath = rawEntityData["hold_action"]["navigation_path"]; + holdService = rawEntityData["hold_action"]["service"]; + holdServiceData = rawEntityData["hold_action"]["service_data"]; + } + } + if (rawEntityData["double_tap_action"] != null) { + if (rawEntityData["double_tap_action"] is String) { + doubleTapAction = rawEntityData["double_tap_action"]; + } else { + doubleTapAction = + rawEntityData["double_tap_action"]["action"] ?? EntityUIAction.none; + doubleTapNavigationPath = rawEntityData["double_tap_action"]["navigation_path"]; + doubleTapService = rawEntityData["double_tap_action"]["service"]; + doubleTapServiceData = rawEntityData["double_tap_action"]["service_data"]; + } + } + } + } + } \ No newline at end of file