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

<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
<?import org.cryptomator.ui.controls.FontAwesome5Spinner?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns:fx="http://javafx.com/fxml"
	  xmlns="http://javafx.com/javafx"
	  fx:controller="org.cryptomator.ui.addvaultwizard.CreateNewVaultLocationController"
	  prefWidth="450"
	  prefHeight="450"
	  spacing="12"
	  alignment="CENTER_LEFT">
	<fx:define>
		<ToggleGroup fx:id="locationPresetsToggler"/>
		<FontAwesome5IconView fx:id="badLocation" styleClass="glyph-icon-red" glyph="TIMES"/>
		<FontAwesome5IconView fx:id="goodLocation" styleClass="glyph-icon-primary" glyph="CHECK"/>
	</fx:define>
	<padding>
		<Insets topRightBottomLeft="24"/>
	</padding>
	<children>
		<Region VBox.vgrow="ALWAYS"/>

		<Label wrapText="true" text="%addvaultwizard.new.locationInstruction"/>
		<ScrollPane hbarPolicy="NEVER">
			<VBox fx:id="radioButtonVBox" spacing="6">
				<!-- PLACEHOLDER, more radio buttons are added programmatically via controller -->
				<HBox fx:id="customLocationRadioBtn" spacing="12" alignment="CENTER_LEFT">
					<RadioButton fx:id="customRadioButton" toggleGroup="${locationPresetsToggler}" text="%addvaultwizard.new.directoryPickerLabel"/>
					<Button contentDisplay="LEFT" text="%addvaultwizard.new.directoryPickerButton" onAction="#chooseCustomVaultPath" disable="${controller.usePresetPath}">
						<graphic>
							<FontAwesome5IconView glyph="FOLDER_OPEN"/>
						</graphic>
					</Button>
				</HBox>
			</VBox>
		</ScrollPane>
		<Region prefHeight="2"/>
		<Label wrapText="true" text="%addvaultwizard.new.locationLoading" visible="${controller.loadingPresetLocations}" managed="${controller.loadingPresetLocations}" graphicTextGap="8">
			<graphic>
				<FontAwesome5Spinner/>
			</graphic>
		</Label>

		<Region prefHeight="12" VBox.vgrow="NEVER"/>

		<VBox spacing="6">
			<Label text="%addvaultwizard.new.locationLabel" labelFor="$locationTextField"/>
			<TextField fx:id="locationTextField" promptText="%addvaultwizard.new.locationPrompt" text="${controller.vaultPath}" editable="false" disable="${!controller.anyRadioButtonSelected}" HBox.hgrow="ALWAYS"/>
			<Label fx:id="locationStatusLabel" alignment="CENTER_RIGHT" wrapText="true" visible="${controller.anyRadioButtonSelected}" maxWidth="Infinity" graphicTextGap="6"/>
		</VBox>

		<Region VBox.vgrow="ALWAYS"/>

		<ButtonBar buttonMinWidth="120" buttonOrder="B+X">
			<buttons>
				<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
				<Button text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" onAction="#next" defaultButton="true" disable="${!controller.validVaultPath}"/>
			</buttons>
		</ButtonBar>
	</children>
</VBox>
