Made a new LogPage for showing the logfile as opposed to opening it with an external app, for android's sake

This commit is contained in:
2026-01-07 20:25:26 -06:00
parent be28a8f025
commit 2fb3679279
4 changed files with 43 additions and 7 deletions

View File

@@ -12,8 +12,16 @@
<TextBox Grid.Column="1" x:Name="SearchBox" Watermark="Search..." VerticalContentAlignment="Center"/> <TextBox Grid.Column="1" x:Name="SearchBox" Watermark="Search..." VerticalContentAlignment="Center"/>
<Button x:Name="SearchButton" Classes="icon" Grid.Column="2" Content="&#xe30c;" VerticalAlignment="Center" /> <Button x:Name="SearchButton" Classes="icon" Grid.Column="2" Content="&#xe30c;" VerticalAlignment="Center" />
</Grid> </Grid>
<StackPanel x:Name="CritterStack" HorizontalAlignment="Stretch" Spacing="10" /> <StackPanel x:Name="CritterStack" HorizontalAlignment="Stretch" Spacing="10" />
<Label x:Name="NoResultsLabel"
Foreground="{DynamicResource PrimaryForeground}"
FontSize="15"
Content="No results"
VerticalAlignment="Center"
HorizontalAlignment="Center"
IsVisible="False"/>
<Button x:Name="AddButton" Classes="icon" HorizontalAlignment="Stretch">&#xe3d4;</Button> <Button x:Name="AddButton" Classes="icon" HorizontalAlignment="Stretch">&#xe3d4;</Button>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>

View File

@@ -0,0 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="CritterFolio.Pages.LogPage">
<ScrollViewer>
<TextBox x:Name="OutputBox" IsReadOnly="True" />
</ScrollViewer>
</UserControl>

View File

@@ -0,0 +1,23 @@
using System;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace CritterFolio.Pages;
public partial class LogPage : Page
{
public LogPage()
{
InitializeComponent();
}
public override void Refresh()
{
var path = Path.Combine(AppContext.BaseDirectory, "log.txt");
if (!File.Exists(path)) return;
var text = File.ReadAllText(path);
OutputBox.Text = text;
}
}

View File

@@ -24,12 +24,7 @@ public partial class TestPage : Page
private void OpenLogButtonClicked(object? sender, RoutedEventArgs args) private void OpenLogButtonClicked(object? sender, RoutedEventArgs args)
{ {
var logFilePath = Path.Combine(AppContext.BaseDirectory, "log.txt"); Sys.Navigation?.PushPage(new LogPage());
if (!File.Exists(logFilePath)) return;
var launcher = TopLevel.GetTopLevel(this)?.Launcher;
if (launcher is null) return;
launcher.LaunchUriAsync(new Uri("file://" + logFilePath));
} }