import { BackgroundStyle } from '../common/Common';
import { ButtonConfiguration } from '../common/Common';
import { DeepPartial, PartiallyConstructible } from '../../utils';
import { ForegroundStyle } from '../common/Common';
import { StyledText } from '../common/Common';

/**
Configuration of the top bar's appearance.
*/
export class TopBarConfiguration extends PartiallyConstructible {
  /**
    Appearance of the top bar's title.
    */
  public title: StyledText = new StyledText({
    visible: false,
    text: 'Scan Item',
    color: '?sbColorOnPrimary',
  });
  /**
    The visual mode used for the top bar.
    Default is SOLID
    */
  public mode: TopBarMode = 'SOLID';
  /**
    The visual mode used for the status bar icons.
    Default is LIGHT
    */
  public statusBarMode: StatusBarMode = 'LIGHT';
  /**
    The background color of the top bar to be used when the visual mode is specified as SOLID. Otherwise ignored.
    Default is "?sbColorPrimary"
    */
  public backgroundColor: string = '?sbColorPrimary';
  /**
    Configuration of the 'cancel' button's appearance.
    */
  public cancelButton: ButtonConfiguration = new ButtonConfiguration({
    text: 'Cancel',
    background: new BackgroundStyle({
      strokeColor: '#00000000',
      fillColor: '#00000000',
      strokeWidth: 0.0,
    }),
    foreground: new ForegroundStyle({ color: '?sbColorOnPrimary' }),
  });

  /** @param source {@displayType `DeepPartial<TopBarConfiguration>`} */
  public constructor(source: DeepPartial<TopBarConfiguration> = {}) {
    super();
    if (source.title !== undefined) {
      this.title = new StyledText(source.title);
    }
    if (source.mode !== undefined) {
      this.mode = source.mode;
    }
    if (source.statusBarMode !== undefined) {
      this.statusBarMode = source.statusBarMode;
    }
    if (source.backgroundColor !== undefined) {
      this.backgroundColor = source.backgroundColor;
    }
    if (source.cancelButton !== undefined) {
      this.cancelButton = new ButtonConfiguration(source.cancelButton);
    }
  }
}

/**
The visual mode used for the status bar icons.

- `DARK`:
   Display all icons in the status bar in black.
- `LIGHT`:
   Display all icons in the status bar in white.
- `HIDDEN`:
   Hide the status bar icons.
*/
export type StatusBarMode = 'DARK' | 'LIGHT' | 'HIDDEN';

/**
The visual mode used for the top bar.

- `SOLID`:
   Display the top bar with a background color or with transparency.
- `GRADIENT`:
   Display the top bar with a gradient background color or a gradient with transparency. The buttons will still be visible.
- `HIDDEN`:
   Hide the top bar completely.
*/
export type TopBarMode = 'SOLID' | 'GRADIENT' | 'HIDDEN';
