/*
* UI Regions
*
* Library to produce an html block with dragable/resizable regions
*
*
* Licensed Virtual the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WIyTHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Date Who Description
* ------------- ------------------- ---------------------------------------------------------
*
*/
import java.text.SimpleDateFormat
import groovy.transform.Field
library (
base: "app",
author: "Jean P. May Jr.",
category: "UI",
description: "Set of methods that allow the customization of the UI ",
name: "uiRegions",
namespace: "thebearmay",
importUrl: "https://raw.githubusercontent.com/thebearmay/hubitat/refs/heads/main/libraries/uiRegions.groovy",
version: "0.0.1",
documentationLink: ""
)
String getRegion(regionName, regionTitle, regionContent){
String region = """
${regionTitle}
-◱
${regionContent}
"""
return region
}
String getRegionsPage( regionsList, fullScreen ){
// regionsList should be a list of map elements [regionName:regionContentString]
String regionsMerged = ''
String dragList = ''
String defaultPos = ''
int regionsInx = 0
int l = 50
int t = 0
int w = 300
int h = 250
regionsList.each {
regionsMerged += it.value
if(regionsInx > 0) {
dragList += ','
defaultPos += ','
}
dragList += "'${it.key}'"
defaultPos += "'${it.key}': { left: '${l}px', top: '${t}px', width: '${w}px', height: '${h}px', zIndex: '${regionsInx+1}' }"
t+= 44
l+= 30
regionsInx++
}
String bodyHtml = """