function hexToRgba(hex, alpha) {let r, g, bif (hex.length === 4) {r = "0x" + hex[1] + hex[1]g = "0x" + hex[2] + hex[2]b = "0x" + hex[3] + hex[3]} else if (hex.length === 7) {r = "0x" + hex[1] + hex[2]g = "0x" + hex[3] + hex[4]b = "0x" + hex[5] + hex[6]}return "rgba(" + +r + "," + +g + "," + +b + "," + alpha.toString() + ")"}const MyButton = styled(Pressable,{bg: "$red500:alpha-50",},{descendantStyle: ["_text"],},{propertyResolver: {backgroundColor: (rawValue, resolver) => {if (rawValue.includes(":alpha-")) {let opacity = resolver(rawValue.split(":alpha-")[1], "opacity")let value = rawValue.split(":alpha-")[0]return hexToRgba(resolver(value), opacity)} else {return resolver(rawValue)}},},})
function hexToRgba(hex, alpha) {let r, g, bif (hex.length === 4) {r = "0x" + hex[1] + hex[1]g = "0x" + hex[2] + hex[2]b = "0x" + hex[3] + hex[3]} else if (hex.length === 7) {r = "0x" + hex[1] + hex[2]g = "0x" + hex[3] + hex[4]b = "0x" + hex[5] + hex[6]}return "rgba(" + +r + "," + +g + "," + +b + "," + alpha.toString() + ")"}const MyButton = styled(Pressable,{bg: "$red500:alpha-50",},{descendantStyle: ["_text"],},{propertyResolver: {// ✔️backgroundColor: (rawValue, resolver) => {if (rawValue.includes(":alpha-")) {let opacity = resolver(rawValue.split(":alpha-")[1], "opacity")let value = rawValue.split(":alpha-")[0]return hexToRgba(resolver(value), opacity)} else {return resolver(rawValue)}},// ❌bg: (rawValue, resolver) => {if (rawValue.includes(":alpha-")) {let opacity = resolver(rawValue.split(":alpha-")[1], "opacity")let value = rawValue.split(":alpha-")[0]return hexToRgba(resolver(value), opacity)} else {return resolver(rawValue)}},},})
import React from "react"import { styled } from "@gluestack-style/react"import { AppProvider } from "./Provider"import { LinearGradient } from "expo-linear-gradient"const StyledLinearGradient = styled(LinearGradient,{bg: "$primary500",h: "$40",w: "$40",},{ resolveProps: ["colors"] },{propertyTokenMap: {colors: "colors",},propertyResolver: {props: {colors: (value: any, resolver: any) => {return value.map((color: any) => resolver(color))},},},})export function PropertyResolver({ ...args }: any) {return (<AppProvider><StyledLinearGradientcolors={["$red400", "$blue300"]}{...args}></StyledLinearGradient></AppProvider>)}export default PropertyResolver
import { createConfig } from "@gluestack-style/react"export const config = createConfig({aliases: {bg: "backgroundColor",backgroundColor: "backgroundColor",// ...},tokens: {// ...},globalStyle: {// ...},propertyResolver: {backgroundColor: (rawValue, resolver) => {if (rawValue.includes(":alpha-")) {let opacity = resolver(rawValue.split(":alpha-")[1], "opacity")let value = rawValue.split(":alpha-")[0]return hexToRgba(resolver(value), opacity)} else {return resolver(rawValue)}},},} as const)