feature: add flower

This commit is contained in:
2023-08-02 23:45:04 +08:00
parent 155ca9ad9c
commit 31cfaee4f0
55 changed files with 2416 additions and 308 deletions

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:l="clr-namespace:Blahblah.FlowerApp"
xmlns:ctl="clr-namespace:Blahblah.FlowerApp.Controls"
xmlns:user="clr-namespace:Blahblah.FlowerApp.Views.User"
xmlns:mdl="clr-namespace:Blahblah.FlowerApp.Data.Model"
x:Class="Blahblah.FlowerApp.Views.User.LogItemPage"
x:Name="logItemPage"
x:DataType="mdl:LogItem"
Title="{Binding Category}">
<ScrollView>
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="12" Margin="20"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="6">
<ctl:SecondaryLabel Text="ID:"/>
<Label Grid.Column="1" Text="{Binding Id}"/>
<ctl:SecondaryLabel Grid.Row="1" Text="Time:"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding LogUnixTime, Converter={StaticResource dateTimeConverter}}"/>
<ctl:SecondaryLabel Grid.Row="2" Text="Type:"/>
<Label Grid.Row="2" Grid.Column="1" Text="{Binding LogType}"/>
<ctl:SecondaryLabel Grid.Row="3" Text="Category:"/>
<Label Grid.Row="3" Grid.Column="1" Text="{Binding Category}"/>
<ctl:SecondaryLabel Grid.Row="4" Text="Source:"/>
<Label Grid.Row="4" Grid.Column="1" Text="{Binding Source}"/>
<ctl:SecondaryLabel Grid.Row="5" Text="Client agent:"/>
<Label Grid.Row="5" Grid.Column="1" Text="{Binding ClientAgent}"/>
<ctl:SecondaryLabel Grid.Row="6" Text="Message:" VerticalOptions="Start"/>
<Label Grid.Row="6" Grid.Column="1" Text="{Binding Message}" LineBreakMode="WordWrap"/>
<ctl:SecondaryLabel Grid.Row="7" Text="Description:" VerticalOptions="Start"/>
<Label Grid.Row="7" Grid.Column="1" Text="{Binding Description}" LineBreakMode="WordWrap"/>
</Grid>
</ScrollView>
</ContentPage>

View File

@@ -0,0 +1,13 @@
using Blahblah.FlowerApp.Data.Model;
namespace Blahblah.FlowerApp.Views.User;
public partial class LogItemPage : ContentPage
{
public LogItemPage(LogItem log)
{
BindingContext = log;
InitializeComponent();
}
}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<l:AppContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:l="clr-namespace:Blahblah.FlowerApp"
xmlns:ctl="clr-namespace:Blahblah.FlowerApp.Controls"
xmlns:mdl="clr-namespace:Blahblah.FlowerApp.Data.Model"
xmlns:user="clr-namespace:Blahblah.FlowerApp.Views.User"
x:Class="Blahblah.FlowerApp.Views.User.LogPage"
x:Name="logPage"
x:DataType="user:LogPage"
Title="Logs">
<Grid BindingContext="{x:Reference logPage}">
<ListView ItemsSource="{Binding Logs}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="mdl:LogItem">
<ViewCell>
<HorizontalStackLayout Margin="16,0" Spacing="12">
<HorizontalStackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ItemCommand, Source={x:Reference logPage}}"
CommandParameter="{Binding .}"/>
</HorizontalStackLayout.GestureRecognizers>
<ctl:SecondaryLabel FontSize="10" Text="{Binding LogUnixTime, Converter={StaticResource dateTimeConverter}}" VerticalOptions="Center"/>
<Label Text="{Binding Message}" VerticalOptions="Center" LineBreakMode="TailTruncation"/>
</HorizontalStackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</l:AppContentPage>

View File

@@ -0,0 +1,39 @@
using Blahblah.FlowerApp.Data;
using Blahblah.FlowerApp.Data.Model;
using Microsoft.Extensions.Logging;
using static Blahblah.FlowerApp.Extensions;
namespace Blahblah.FlowerApp.Views.User;
public partial class LogPage : AppContentPage
{
static readonly BindableProperty LogsProperty = CreateProperty<LogItem[], LogPage>(nameof(Logs));
public LogItem[] Logs
{
get => GetValue<LogItem[]>(LogsProperty);
set => SetValue(LogsProperty, value);
}
public Command ItemCommand { get; }
public LogPage(FlowerDatabase database, ILogger logger) : base(database, logger)
{
ItemCommand = new Command(async o =>
{
if (o is LogItem item)
{
await Navigation.PushAsync(new LogItemPage(item));
}
});
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
Task.Run(async () => Logs = await Database.GetLogs());
}
}