Bug fixes

This commit is contained in:
NinjaPug
2025-05-09 14:37:11 -04:00
parent 6b07cf82fb
commit 943cdec951
9 changed files with 53 additions and 98 deletions

View File

@@ -45,7 +45,7 @@
<HorizontalStackLayout Spacing="10">
<Label Text="{Binding .}"
VerticalOptions="Center"
TextColor="{Binding Source={x:Reference NavMenu}, Path=SelectedItem, Converter={StaticResource StringMatchTextConverter}, ConverterParameter={Binding .}}" />
TextColor="#333333" />
</HorizontalStackLayout>
</Border>
</DataTemplate>

View File

@@ -5,6 +5,8 @@ using PCPal.Configurator.Views.LCD;
using PCPal.Configurator.Views.OLED;
using PCPal.Configurator.Views.TFT;
using System.ComponentModel;
using PCPal.Configurator.Models;
using System.Collections.ObjectModel;
namespace PCPal.Configurator;
@@ -17,6 +19,7 @@ public partial class AppShell : Shell, INotifyPropertyChanged
private readonly IServiceProvider _serviceProvider;
public bool IsConnected
{
get => _isConnected;
@@ -58,6 +61,7 @@ public partial class AppShell : Shell, INotifyPropertyChanged
public AppShell()
{
InitializeComponent();
_serviceProvider = IPlatformApplication.Current?.Services;
@@ -71,6 +75,14 @@ public partial class AppShell : Shell, INotifyPropertyChanged
// Start with LCD view
NavMenu.SelectedItem = "1602 LCD Display";
// Just manually load the view
var lcdView = _serviceProvider?.GetService<LcdConfigView>();
if (lcdView != null)
{
ContentContainer.Content = lcdView;
}
// Start connection monitoring in the background
StartConnectivityMonitoring();
}
@@ -91,6 +103,8 @@ public partial class AppShell : Shell, INotifyPropertyChanged
{
if (e.CurrentSelection.FirstOrDefault() is string selection)
{
ContentView view = selection switch
{
"1602 LCD Display" => _serviceProvider?.GetService<LcdConfigView>(),

View File

@@ -76,38 +76,24 @@ public class ConnectionStatusColorConverter : IValueConverter
// Converts a string to a color based on matching
public class StringMatchConverter : IValueConverter
{
// Default navigation item
private const string DefaultNavItem = "1602 LCD Display";
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// For matching menu items
if (value is string currentValue && parameter is string targetValue)
if (parameter is string targetValue)
{
if (currentValue == targetValue)
{
// Default to background coloring
Color returnColor = Application.Current.Resources["PrimaryLight"] as Color ?? Colors.LightBlue;
string currentValue = value as string;
// Check for additional parameter context
if (targetValue.EndsWith(":TextColor"))
// Either it's explicitly selected, or it's the default item and nothing is selected yet
if (currentValue == targetValue || (currentValue == null && targetValue == DefaultNavItem))
{
// Strip the ":TextColor" suffix before comparison
string strippedTarget = targetValue.Substring(0, targetValue.Length - 10);
if (currentValue == strippedTarget)
{
return Application.Current.Resources["Primary"] as Color ?? Colors.Black;
return Application.Current.Resources["PrimaryLight"] as Color ?? Colors.LightBlue;
}
}
return returnColor;
}
}
// Return default values
if (parameter is string param && param == "TextColor")
{
return Application.Current.Resources["TextSecondary"] as Color ?? Colors.Gray;
}
// Default background is transparent
// Return transparent for non-selected items
return Colors.Transparent;
}
@@ -283,18 +269,23 @@ public class RelativeTimeConverter : IValueConverter
// Add this new converter for text color specifically
public class StringMatchTextConverter : IValueConverter
{
// Default navigation item
private const string DefaultNavItem = "1602 LCD Display";
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string currentValue && parameter is string targetValue)
if (parameter is string targetValue)
{
if (currentValue == targetValue)
string currentValue = value as string;
// Either it's explicitly selected, or it's the default item and nothing is selected yet
if (currentValue == targetValue || (currentValue == null && targetValue == DefaultNavItem))
{
// Return text color for selected item
return Application.Current.Resources["Primary"] as Color ?? Colors.Blue;
}
}
// Return default text color
// Return default text color for non-selected items
return Application.Current.Resources["TextSecondary"] as Color ?? Colors.Gray;
}

View File

@@ -657,6 +657,10 @@ public class OledConfigViewModel : BaseViewModel
IsMarkupEditorSelected = tab == "markup";
IsTemplatesSelected = tab == "templates";
OnPropertyChanged(nameof(IsVisualEditorSelected));
OnPropertyChanged(nameof(IsMarkupEditorSelected));
OnPropertyChanged(nameof(IsTemplatesSelected));
switch (tab)
{
case "visual":

View File

@@ -106,7 +106,6 @@ public class SettingsViewModel : BaseViewModel
public ICommand StartServiceCommand { get; }
public ICommand StopServiceCommand { get; }
public ICommand RestartServiceCommand { get; }
public ICommand CheckForUpdatesCommand { get; }
public SettingsViewModel(IConfigurationService configService, ISerialPortService serialPortService)
{
@@ -142,7 +141,6 @@ public class SettingsViewModel : BaseViewModel
StartServiceCommand = new Command(async () => await StartServiceAsync());
StopServiceCommand = new Command(async () => await StopServiceAsync());
RestartServiceCommand = new Command(async () => await RestartServiceAsync());
CheckForUpdatesCommand = new Command(async () => await CheckForUpdatesAsync());
// Subscribe to serial port connection changes
_serialPortService.ConnectionStatusChanged += OnConnectionStatusChanged;
@@ -421,19 +419,6 @@ public class SettingsViewModel : BaseViewModel
}
}
private async Task CheckForUpdatesAsync()
{
try
{
await Shell.Current.DisplayAlert("Check for Updates",
"You are currently running the latest version (1.0.0).", "OK");
}
catch (Exception ex)
{
await Shell.Current.DisplayAlert("Error", $"Failed to check for updates: {ex.Message}", "OK");
}
}
private void OnConnectionStatusChanged(object sender, bool isConnected)
{
MainThread.BeginInvokeOnMainThread(() =>

View File

@@ -1,39 +1,12 @@
using System.Windows.Input;
namespace PCPal.Configurator.ViewModels;
namespace PCPal.Configurator.ViewModels;
public class TftConfigViewModel : BaseViewModel
{
public ICommand NotifyCommand { get; }
public TftConfigViewModel()
{
Title = "TFT Display Configuration";
// Initialize commands
NotifyCommand = new Command(async () => await NotifyWhenAvailableAsync());
}
private async Task NotifyWhenAvailableAsync()
{
// Display a prompt for the user's email
string result = await Shell.Current.DisplayPromptAsync(
"Notification Sign-up",
"Enter your email to be notified when TFT display support becomes available:",
"Subscribe",
"Cancel",
"email@example.com",
keyboard: Keyboard.Email);
if (!string.IsNullOrWhiteSpace(result))
{
// In a real app, we would save this email to a notification list
// Display confirmation
await Shell.Current.DisplayAlert(
"Thank You!",
"We'll notify you when TFT display support is ready. Your email has been registered for updates.",
"OK");
}
}
}

View File

@@ -29,7 +29,7 @@
Padding="20,10"
WidthRequest="160">
<Label Text="Visual Editor"
TextColor="{Binding IsVisualEditorSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
TextColor="{Binding IsVisualEditorSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
HorizontalOptions="Center" />
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SwitchToVisualEditorCommand}" />
@@ -43,7 +43,7 @@
Padding="20,10"
WidthRequest="160">
<Label Text="Markup Editor"
TextColor="{Binding IsMarkupEditorSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
TextColor="{Binding IsMarkupEditorSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
HorizontalOptions="Center" />
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SwitchToMarkupEditorCommand}" />
@@ -57,7 +57,7 @@
Padding="20,10"
WidthRequest="160">
<Label Text="Templates"
TextColor="{Binding IsTemplatesSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
TextColor="{Binding IsTemplatesSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
HorizontalOptions="Center" />
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SwitchToTemplatesCommand}" />

View File

@@ -233,10 +233,6 @@
<Label Text="License: MIT" />
</VerticalStackLayout>
<Button Text="Check for Updates"
Command="{Binding CheckForUpdatesCommand}"
HorizontalOptions="Start"
Margin="0,10,0,0" />
</VerticalStackLayout>
</Border>

View File

@@ -27,10 +27,7 @@
</Border.StrokeShape>
<VerticalStackLayout Spacing="20" HorizontalOptions="Center" Padding="30">
<Image Source="coming_soon.png"
WidthRequest="150"
HeightRequest="150"
HorizontalOptions="Center" />
<Label Text="TFT Display Support Coming Soon!"
FontSize="24"
@@ -65,12 +62,7 @@
HorizontalOptions="Start" />
</VerticalStackLayout>
<Button Text="Notify Me When Available"
Command="{Binding NotifyCommand}"
BackgroundColor="{StaticResource Primary}"
TextColor="White"
HorizontalOptions="Center"
Margin="0,10,0,0" />
</VerticalStackLayout>
</Border>