<ion-menu contentId="menu-content" (ionDidClose)="onMenuClose()" (ionDidOpen)="onMenuOpen()">
  <ion-content>
    <ion-list lines="none">
      <ion-item [color]="cu ? 'primary' : 'danger'" (click)="onMenuToggle()">
        <ion-label>
          <h1>{{cu ? cu.peripheral.name : ('No connection' | translate)}}</h1>
          <h2>{{cu?.peripheral.address}}</h2>
          <h3 *ngIf="cu">
            <span translate>Firmware version</span>
            {{version | async | cuversion}}
          </h3>
        </ion-label>
        <ion-icon slot="end" [name]="mode ? 'caret-down-sharp' : 'caret-up-sharp'"></ion-icon>
      </ion-item>
      <div *ngIf="mode">
        <ion-item-group>
          <ion-menu-toggle auto-hide="false">
            <ion-item button [disabled]="!cu" (click)="startPractice()">
              <ion-icon name="speedometer-sharp" slot="start"></ion-icon>
              <ion-label translate>Free Practice</ion-label>
            </ion-item>
            <ion-item button [disabled]="!cu" (click)="startQualifying()">
              <ion-icon name="stopwatch-sharp" slot="start"></ion-icon>
              <ion-label translate>Qualifying</ion-label>
            </ion-item>
            <ion-item button [disabled]="!cu" (click)="startRace()">
              <ion-icon name="trophy-sharp" slot="start"></ion-icon>
              <ion-label translate>Race</ion-label>
            </ion-item>
          </ion-menu-toggle>
        </ion-item-group>
        <ion-item-group>
          <ion-menu-toggle auto-hide="false">
            <ion-item button routerLink="/drivers">
              <ion-icon name="people-sharp" slot="start"></ion-icon>
              <ion-label translate>Drivers</ion-label>
            </ion-item>
            <ion-item button routerLink="/colors">
              <ion-icon name="color-palette-sharp" slot="start"></ion-icon>
              <ion-label translate>Colors</ion-label>
            </ion-item>
            <ion-item button [disabled]="!cu" routerLink="/tuning">
              <ion-icon name="build-sharp" slot="start"></ion-icon>
              <ion-label translate>Tuning</ion-label>
            </ion-item>
          </ion-menu-toggle>
        </ion-item-group>
        <ion-item-group>
          <ion-menu-toggle auto-hide="false">
            <ion-item button routerLink="/settings">
              <ion-icon menuClose name="settings-sharp" slot="start"></ion-icon>
              <ion-label translate>Settings</ion-label>
            </ion-item>
            <ion-item button (click)="exitApp()" *ngIf="exitApp">
              <ion-icon name="exit-sharp" slot="start"></ion-icon>
              <ion-label translate>Exit</ion-label>
            </ion-item>
          </ion-menu-toggle>
        </ion-item-group>
      </div>
      <div *ngIf="!mode">
        <ion-item-group *ngIf="open">
          <connections [selected]="cu?.peripheral"></connections>
        </ion-item-group>
        <ion-item-group *ngIf="cu">
          <ion-item button (click)="reconnect()">
            <ion-icon name="refresh-sharp" slot="start"></ion-icon>
            <ion-label translate>Reconnect</ion-label>
          </ion-item>
        </ion-item-group>
      </div>
    </ion-list>
  </ion-content>
</ion-menu>
