<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<?import javafx.geometry.Insets?>
<?import tornadofx.control.Form?>
<?import tornadofx.control.Fieldset?>
<?import tornadofx.control.Field?>
<?import javafx.scene.image.ImageView?>
<?import org.fxmisc.flowless.VirtualizedScrollPane?>
<?import org.fxmisc.richtext.CodeArea?>
<?import com.sparrowwallet.sparrow.control.CopyableLabel?>
<?import org.controlsfx.glyphfont.Glyph?>
<?import com.sparrowwallet.sparrow.control.CopyableTextField?>
<?import com.sparrowwallet.sparrow.control.ScriptArea?>

<BorderPane stylesheets="@receive.css, @wallet.css, @../script.css, @../descriptor.css, @../general.css" styleClass="wallet-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.wallet.ReceiveController">
    <center>

        <GridPane styleClass="receive-form" hgap="10.0" vgap="10.0">
            <padding>
                <Insets left="25.0" right="25.0" top="25.0" />
            </padding>
            <columnConstraints>
                <ColumnConstraints prefWidth="620" />
                <ColumnConstraints prefWidth="140" />
            </columnConstraints>
            <rowConstraints>
                <RowConstraints />
            </rowConstraints>
            <Form GridPane.columnIndex="0" GridPane.rowIndex="0">
                <Fieldset inputGrow="ALWAYS" text="Receive" styleClass="header">
                    <Field text="Address:">
                        <CopyableTextField fx:id="address" styleClass="address-text-field" editable="false"/>
                    </Field>
                    <Field text="Label:">
                        <TextField fx:id="label" />
                    </Field>
                    <Field fx:id="derivationField" text="Derivation:">
                        <CopyableLabel fx:id="derivationPath" />
                    </Field>
                    <Field fx:id="lastUsedField" text="Last Used:">
                        <Label fx:id="lastUsed" contentDisplay="RIGHT" />
                    </Field>
                </Fieldset>
            </Form>

            <AnchorPane GridPane.columnIndex="1" GridPane.rowIndex="0">
                <ImageView fx:id="qrCode" styleClass="qr-code" AnchorPane.rightAnchor="5"/>
            </AnchorPane>

            <Separator styleClass="form-separator" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="1" />

            <Form GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="2">
                <Fieldset inputGrow="SOMETIMES" text="Required ScriptPubKey">
                    <Field text="Script:">
                        <VirtualizedScrollPane>
                            <content>
                                <ScriptArea fx:id="scriptPubKeyArea" editable="false" wrapText="true" prefHeight="47" maxHeight="47" styleClass="uneditable-codearea" />
                            </content>
                        </VirtualizedScrollPane>
                    </Field>
                </Fieldset>
            </Form>

            <Form GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="3">
                <Fieldset inputGrow="SOMETIMES" text="Output Descriptor">
                    <Field text="Descriptor:">
                        <VirtualizedScrollPane>
                            <content>
                                <CodeArea fx:id="outputDescriptor" editable="false" wrapText="true" prefHeight="68" maxHeight="68" styleClass="uneditable-codearea" />
                            </content>
                        </VirtualizedScrollPane>
                    </Field>
                </Fieldset>
            </Form>

        </GridPane>
    </center>
    <bottom>
        <AnchorPane>
            <padding>
                <Insets left="25.0" right="25.0" bottom="25.0" />
            </padding>
            <HBox AnchorPane.rightAnchor="10">
                <Button fx:id="displayAddress" graphicTextGap="5" text="Display Address" AnchorPane.rightAnchor="10" onAction="#displayAddress">
                    <graphic>
                        <Glyph fontFamily="Font Awesome 5 Brands Regular" fontSize="12" icon="USB" />
                    </graphic>
                </Button>
                <Region HBox.hgrow="ALWAYS" style="-fx-min-width: 20px" />
                <Button fx:id="nextAddress" graphicTextGap="5" text="Get Next Address" defaultButton="true" AnchorPane.rightAnchor="10" onAction="#getNewAddress">
                    <graphic>
                        <Glyph fontFamily="FontAwesome" icon="ARROW_DOWN" fontSize="12" />
                    </graphic>
                </Button>
            </HBox>
        </AnchorPane>
    </bottom>
</BorderPane>