Build native title and person surfaces
This commit is contained in:
parent
9be55c570a
commit
0db05174b1
535 changed files with 3088 additions and 17 deletions
|
|
@ -81,6 +81,12 @@ def render_tokens(tokens: dict) -> tuple[str, str]:
|
|||
elif isinstance(token.get("dp"), dict):
|
||||
for suffix, dimension in token["dp"].items():
|
||||
lines.append(f" val {name}{suffix[0].upper() + suffix[1:]} = {number(dimension)}.dp")
|
||||
elif group_name == "image" and isinstance(token.get("px"), list):
|
||||
for suffix, dimension in zip(("Width", "Height"), token["px"]):
|
||||
lines.append(f" const val {name}{suffix} = {int(dimension)}")
|
||||
elif group_name == "image" and isinstance(value, dict):
|
||||
for suffix, count in value.items():
|
||||
lines.append(f" const val {name}{suffix[0].upper() + suffix[1:]} = {int(count)}")
|
||||
elif isinstance(value, (float, int)) and not isinstance(value, bool):
|
||||
lines.append(f" const val {name} = {number(value)}f")
|
||||
elif kind in ("gradient", "filter", "rule") and isinstance(value, str):
|
||||
|
|
@ -100,9 +106,10 @@ def main() -> None:
|
|||
arguments = parser.parse_args()
|
||||
tokens = json.loads((ROOT / "tokens.json").read_text())
|
||||
tokens.update(json.loads((ROOT / "shell-tokens.json").read_text()))
|
||||
tokens.update(json.loads((ROOT / "title-tokens.json").read_text()))
|
||||
kotlin, css = render_tokens(tokens)
|
||||
outputs = {str(KOTLIN): kotlin, "tokens.css": css}
|
||||
inputs = ["tokens.json", "shell-tokens.json", "generate_tokens.py"]
|
||||
inputs = ["tokens.json", "shell-tokens.json", "title-tokens.json", "generate_tokens.py"]
|
||||
checksums = {name: hashlib.sha256((ROOT / name).read_bytes()).hexdigest() for name in inputs}
|
||||
checksums.update({name: hashlib.sha256(content.encode()).hexdigest() for name, content in outputs.items()})
|
||||
outputs["tokens.sha256"] = "".join(f"{checksum} {name}\n" for name, checksum in sorted(checksums.items()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue