package net.shadowfacts.phycon.screen.console import net.minecraft.client.MinecraftClient import net.minecraft.text.TranslatableText import net.shadowfacts.cacao.geometry.Axis import net.shadowfacts.cacao.util.Color import net.shadowfacts.cacao.view.Label import net.shadowfacts.cacao.view.StackView import net.shadowfacts.cacao.view.View import net.shadowfacts.cacao.viewcontroller.ViewController import net.shadowfacts.kiwidsl.dsl import net.shadowfacts.phycon.block.DeviceBlockEntity import net.shadowfacts.phycon.screen.ClipboardButton /** * @author shadowfacts */ class DeviceDetailsViewController(val device: DeviceBlockEntity): ViewController() { override fun viewDidLoad() { super.viewDidLoad() val stack = StackView(Axis.VERTICAL, StackView.Distribution.LEADING, spacing = 4.0) view.addSubview(stack) val name = device.cachedState.block.name.styled { it.withBold(true) } val deviceNameLabel = Label(name).apply { textColor = Color.TEXT } stack.addArrangedSubview(deviceNameLabel) val ipLabel = Label(TranslatableText("gui.phycon.console.details.ip", device.ipAddress.toString())).apply { textColor = Color.TEXT } stack.addArrangedSubview(ipLabel) val copyIP = ClipboardButton { MinecraftClient.getInstance().keyboard.clipboard = device.ipAddress.toString() } view.addSubview(copyIP) val macLabel = Label(TranslatableText("gui.phycon.console.details.mac", device.macAddress.toString())).apply { textColor = Color.TEXT } stack.addArrangedSubview(macLabel) val copyMAC = ClipboardButton { MinecraftClient.getInstance().keyboard.clipboard = device.macAddress.toString() } view.addSubview(copyMAC) view.solver.dsl { stack.leftAnchor equalTo view.leftAnchor stack.topAnchor equalTo view.topAnchor copyIP.leftAnchor equalTo (ipLabel.rightAnchor + 2) copyIP.topAnchor equalTo ipLabel.topAnchor copyMAC.leftAnchor equalTo (macLabel.rightAnchor + 2) copyMAC.topAnchor equalTo macLabel.topAnchor } } }