LoginPage.xaml 1.8 KB
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:conv="clr-namespace:IndustrialControl.Converters"
             x:Class="IndustrialControl.Pages.LoginPage"
             Title="登录">

    <ContentPage.Resources>
        <ResourceDictionary>
            <conv:BoolNegationConverter x:Key="NotBool" />
            <conv:EyeGlyphConverter x:Key="EyeGlyphConverter" />
        </ResourceDictionary>
    </ContentPage.Resources>

    <Grid Padding="24" RowDefinitions="Auto,*">
        <VerticalStackLayout Spacing="12">

            <Label Text="联创数智管家" FontAttributes="Bold" FontSize="28"/>

            <Entry Placeholder="请输入用户名" Text="{Binding UserName}"/>

            <!-- 密码输入 + 眼睛图标 -->
            <Grid ColumnDefinitions="*,Auto">
                <Entry
                    Grid.Column="0"
                    Placeholder="请输入登录密码"
                    Text="{Binding Password}"
                    IsPassword="{Binding ShowPassword, Converter={StaticResource NotBool}}" />

                <ImageButton Grid.Column="1"
                             VerticalOptions="Center"
                             BackgroundColor="Transparent"
                             Command="{Binding TogglePasswordCommand}">
                    <ImageButton.Source>
                        <FontImageSource Glyph="{Binding ShowPassword, Converter={StaticResource EyeGlyphConverter}}"
                                         FontFamily="MaterialIcons"  Color="Gray" Size="20"/>
                    </ImageButton.Source>
                </ImageButton>
            </Grid>

            <Button Text="登录" Command="{Binding LoginCommand}"/>
        </VerticalStackLayout>
    </Grid>
</ContentPage>