<abstract:SpecialImapCredentialsPageAbstract
    x:Class="Wino.Views.SpecialImapCredentialsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:abstract="using:Wino.Mail.WinUI.Views.Abstract"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:domain="using:Wino.Core.Domain"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <ScrollViewer
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        VerticalScrollBarVisibility="Auto">
        <StackPanel
            MaxWidth="440"
            Margin="0,24,0,24"
            HorizontalAlignment="Center"
            Spacing="20">

            <!--  Provider logo  -->
            <Image
                Height="48"
                HorizontalAlignment="Center"
                Source="{x:Bind ViewModel.WizardContext.SelectedProvider.ProviderImage, Mode=OneWay}"
                Stretch="Uniform" />

            <!--  Title / subtitle  -->
            <StackPanel Spacing="4">
                <TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{x:Bind ViewModel.WizardContext.SelectedProvider.Name, Mode=OneWay}" />
                <TextBlock
                    Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                    Style="{StaticResource BodyTextBlockStyle}"
                    Text="{x:Bind domain:Translator.ProviderSelection_SpecialImap_Subtitle}" />
            </StackPanel>

            <!--  Display Name  -->
            <TextBox
                Header="{x:Bind domain:Translator.ProviderSelection_DisplayNameHeader}"
                PlaceholderText="{x:Bind domain:Translator.ProviderSelection_DisplayNamePlaceholder}"
                Text="{x:Bind ViewModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

            <!--  Email  -->
            <TextBox
                Header="{x:Bind domain:Translator.ProviderSelection_EmailHeader}"
                PlaceholderText="{x:Bind domain:Translator.ProviderSelection_EmailPlaceholder}"
                Text="{x:Bind ViewModel.EmailAddress, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

            <!--  App-Specific Password  -->
            <PasswordBox
                x:Name="AppPasswordBox"
                Header="{x:Bind domain:Translator.ProviderSelection_AppPasswordHeader}"
                PasswordChanged="AppPasswordChanged" />

            <HyperlinkButton
                HorizontalAlignment="Right"
                Command="{x:Bind ViewModel.OpenAppPasswordHelpCommand}"
                Content="{x:Bind domain:Translator.ProviderSelection_AppPasswordHelp}" />

            <!--  Divider  -->
            <Rectangle Height="1" Fill="{ThemeResource CardStrokeColorDefaultBrush}" />

            <!--  Calendar Mode  -->
            <TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Text="{x:Bind domain:Translator.ProviderSelection_CalendarModeHeader}" />

            <ListView
                x:Name="CalendarModeListView"
                IsItemClickEnabled="False"
                SelectionChanged="CalendarModeSelectionChanged"
                SelectionMode="Single">
                <!--  Disabled  -->
                <ListViewItem>
                    <Grid Padding="12" ColumnSpacing="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <FontIcon
                            VerticalAlignment="Center"
                            FontSize="18"
                            Glyph="&#xEA67;" />
                        <StackPanel Grid.Column="1" Spacing="2">
                            <TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.ProviderSelection_CalendarMode_DisabledTitle}" />
                            <TextBlock
                                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                Style="{StaticResource CaptionTextBlockStyle}"
                                Text="{x:Bind domain:Translator.ProviderSelection_CalendarMode_DisabledDescription}"
                                TextWrapping="Wrap" />
                        </StackPanel>
                    </Grid>
                </ListViewItem>
                <!--  CalDAV  -->
                <ListViewItem>
                    <Grid Padding="12" ColumnSpacing="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <FontIcon
                            VerticalAlignment="Center"
                            FontSize="18"
                            Glyph="&#xE753;" />
                        <StackPanel Grid.Column="1" Spacing="2">
                            <TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.ProviderSelection_CalendarMode_CalDavTitle}" />
                            <TextBlock
                                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                Style="{StaticResource CaptionTextBlockStyle}"
                                Text="{x:Bind ViewModel.CalendarModeCalDavDescription, Mode=OneWay}"
                                TextWrapping="Wrap" />
                        </StackPanel>
                    </Grid>
                </ListViewItem>
                <!--  Local  -->
                <ListViewItem>
                    <Grid Padding="12" ColumnSpacing="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <FontIcon
                            VerticalAlignment="Center"
                            FontSize="18"
                            Glyph="&#xE7F8;" />
                        <StackPanel Grid.Column="1" Spacing="2">
                            <TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.ProviderSelection_CalendarMode_LocalTitle}" />
                            <TextBlock
                                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                Style="{StaticResource CaptionTextBlockStyle}"
                                Text="{x:Bind domain:Translator.ProviderSelection_CalendarMode_LocalDescription}"
                                TextWrapping="Wrap" />
                        </StackPanel>
                    </Grid>
                </ListViewItem>
            </ListView>

            <!--  Continue Button  -->
            <Button
                HorizontalAlignment="Stretch"
                Command="{x:Bind ViewModel.ProceedCommand}"
                Content="{x:Bind domain:Translator.ProviderSelection_ContinueButton}"
                IsEnabled="{x:Bind ViewModel.CanProceed, Mode=OneWay}"
                Style="{StaticResource AccentButtonStyle}" />

        </StackPanel>
    </ScrollViewer>

</abstract:SpecialImapCredentialsPageAbstract>
