<md-dialog aria-label="Settings">
    <form ng-cloak>
        <md-toolbar>
            <div class="md-toolbar-tools">
                <h2 translate>settings.SETTINGS</h2>
                <span flex></span>
                <md-button class="md-icon-button" ng-click="ctrl.cancel()">
                    <md-icon aria-label="Close dialog" class="material-icons md-24">close</md-icon>
                </md-button>
            </div>
        </md-toolbar>
        <md-dialog-content>
            <div class="md-dialog-content">
                <section>
                    <md-subheader class="md-accent"><span translate>settings.notifications.NOTIFICATIONS</span>
                    </md-subheader>
                    <md-list flex>
                        <md-list-item ng-if="ctrl.notificationApiAvailable && ctrl.notificationPermission !== false">
                            <md-checkbox
                                    ng-disabled="!ctrl.notificationApiAvailable || ctrl.notificationPermission === false"
                                    ng-model="ctrl.desktopNotifications"
                                    ng-change="ctrl.setWantsNotifications(ctrl.desktopNotifications)"
                                    aria-label="Show desktop notifications">
                                <span translate>settings.notifications.SHOW_NOTIFICATIONS</span>
                            </md-checkbox>
                        </md-list-item>
                        <md-list-item ng-if="ctrl.desktopNotifications && ctrl.notificationApiAvailable && ctrl.notificationPermission !== false">
                            <md-checkbox
                                    ng-disabled="!ctrl.desktopNotifications"
                                    ng-model="ctrl.notificationPreview"
                                    ng-change="ctrl.setWantsPreview(ctrl.notificationPreview)"
                                    aria-label="Show message preview">
                                <span translate>settings.notifications.SHOW_PREVIEW</span>
                            </md-checkbox>
                        </md-list-item>
                        <md-list-item>
                            <md-checkbox
                                    ng-model="ctrl.notificationSound"
                                    ng-change="ctrl.setWantsSound(ctrl.notificationSound)"
                                    aria-label="Play notification sound">
                                <span translate>settings.notifications.PLAY_SOUND</span>
                            </md-checkbox>
                        </md-list-item>
                    </md-list>
                    <div ng-if="!ctrl.notificationApiAvailable" class="status status-no">
                        <i class="material-icons md-24">error</i>
                        <span translate>error.NOTIFICATION_API_NOT_AVAILABLE</span>
                    </div>
                    <div ng-if="ctrl.notificationPermission === false && ctrl.notificationApiAvailable" class="status status-no">
                        <i class="material-icons md-24">error</i> <span translate>error.NOTIFICATION_PERMISSION_DENIED</span>
                        <a href="https://threema.ch/de/faq/web_notifications"
                           target="_blank" rel="noopener noreferrer">
                            <p translate>error.NOTIFICATION_PERMISSION_DENIED_LEARN_MORE</p>
                        </a>
                    </div>
                </section>
            </div>
        </md-dialog-content>
        <md-dialog-actions layout="row">
            <span flex></span>
            <md-button ng-click="ctrl.cancel()">
                <span translate>common.OK</span>
            </md-button>
        </md-dialog-actions>
    </form>
</md-dialog>

