<!--

    Copyright © 2016-2023 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<ng-container [formGroup]="valueCardWidgetSettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.value-card.value-card-style</div>
    <tb-image-cards-select rowHeight="{{ horizontal ? '3:1' : '7:5' }}"
                           [cols]="{columns: horizontal ? 2 : 4,
                                    breakpoints: {
                                      'lt-md': horizontal ? 1 : 2
                                    }}"
                           label="{{ 'widgets.value-card.layout' | translate }}" formControlName="layout">
      <tb-image-cards-select-option *ngFor="let layout of valueCardLayouts"
                                    [value]="layout"
                                    [image]="valueCardLayoutImageMap.get(layout)">
        {{ valueCardLayoutTranslationMap.get(layout) | translate }}
      </tb-image-cards-select-option>
    </tb-image-cards-select>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide" formControlName="autoScale">
        {{ 'widgets.value-card.auto-scale' | translate }}
      </mat-slide-toggle>
    </div>
    <div class="tb-form-row space-between">
      <mat-slide-toggle class="mat-slide" formControlName="showLabel">
        {{ 'widgets.value-card.label' | translate }}
      </mat-slide-toggle>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <tb-font-settings formControlName="labelFont"
                          [previewText]="label">
        </tb-font-settings>
        <tb-color-settings formControlName="labelColor" settingsKey="{{'widgets.value-card.label' | translate }}">
        </tb-color-settings>
      </div>
    </div>
    <div [fxShow]="iconEnabled" class="tb-form-row">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showIcon">
        {{ 'widgets.value-card.icon' | translate }}
      </mat-slide-toggle>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field appearance="outline" class="flex number" subscriptSizing="dynamic">
          <input matInput type="number" min="0" formControlName="iconSize" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-css-unit-select fxFlex formControlName="iconSizeUnit"></tb-css-unit-select>
        <tb-material-icon-select asBoxInput
                                 iconClearButton
                                 [color]="valueCardWidgetSettingsForm.get('iconColor').value?.color"
                                 formControlName="icon">
        </tb-material-icon-select>
        <tb-color-settings formControlName="iconColor" settingsKey="{{'widgets.value-card.icon' | translate }}">
        </tb-color-settings>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <div translate>widgets.value-card.value</div>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <tb-font-settings formControlName="valueFont"
                          [previewText]="valuePreviewFn">
        </tb-font-settings>
        <tb-color-settings formControlName="valueColor" settingsKey="{{'widgets.value-card.value' | translate }}">
        </tb-color-settings>
      </div>
    </div>
    <div [fxShow]="dateEnabled" class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showDate">
        {{ 'widgets.value-card.date' | translate }}
      </mat-slide-toggle>
      <div fxFlex.gt-xs fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <tb-date-format-select fxFlex formControlName="dateFormat"></tb-date-format-select>
        <tb-font-settings formControlName="dateFont"
                          [previewText]="datePreviewFn">
        </tb-font-settings>
        <tb-color-settings formControlName="dateColor" settingsKey="{{'widgets.value-card.date' | translate }}">
        </tb-color-settings>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.background.background' | translate }}</div>
      <tb-background-settings formControlName="background">
      </tb-background-settings>
    </div>
  </div>
</ng-container>
