Bug fixes
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
<HorizontalStackLayout Spacing="10">
|
<HorizontalStackLayout Spacing="10">
|
||||||
<Label Text="{Binding .}"
|
<Label Text="{Binding .}"
|
||||||
VerticalOptions="Center"
|
VerticalOptions="Center"
|
||||||
TextColor="{Binding Source={x:Reference NavMenu}, Path=SelectedItem, Converter={StaticResource StringMatchTextConverter}, ConverterParameter={Binding .}}" />
|
TextColor="#333333" />
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using PCPal.Configurator.Views.LCD;
|
|||||||
using PCPal.Configurator.Views.OLED;
|
using PCPal.Configurator.Views.OLED;
|
||||||
using PCPal.Configurator.Views.TFT;
|
using PCPal.Configurator.Views.TFT;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using PCPal.Configurator.Models;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace PCPal.Configurator;
|
namespace PCPal.Configurator;
|
||||||
|
|
||||||
@@ -17,6 +19,7 @@ public partial class AppShell : Shell, INotifyPropertyChanged
|
|||||||
|
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
|
||||||
public bool IsConnected
|
public bool IsConnected
|
||||||
{
|
{
|
||||||
get => _isConnected;
|
get => _isConnected;
|
||||||
@@ -58,6 +61,7 @@ public partial class AppShell : Shell, INotifyPropertyChanged
|
|||||||
|
|
||||||
public AppShell()
|
public AppShell()
|
||||||
{
|
{
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_serviceProvider = IPlatformApplication.Current?.Services;
|
_serviceProvider = IPlatformApplication.Current?.Services;
|
||||||
@@ -71,6 +75,14 @@ public partial class AppShell : Shell, INotifyPropertyChanged
|
|||||||
// Start with LCD view
|
// Start with LCD view
|
||||||
NavMenu.SelectedItem = "1602 LCD Display";
|
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
|
// Start connection monitoring in the background
|
||||||
StartConnectivityMonitoring();
|
StartConnectivityMonitoring();
|
||||||
}
|
}
|
||||||
@@ -91,6 +103,8 @@ public partial class AppShell : Shell, INotifyPropertyChanged
|
|||||||
{
|
{
|
||||||
if (e.CurrentSelection.FirstOrDefault() is string selection)
|
if (e.CurrentSelection.FirstOrDefault() is string selection)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ContentView view = selection switch
|
ContentView view = selection switch
|
||||||
{
|
{
|
||||||
"1602 LCD Display" => _serviceProvider?.GetService<LcdConfigView>(),
|
"1602 LCD Display" => _serviceProvider?.GetService<LcdConfigView>(),
|
||||||
|
|||||||
@@ -76,38 +76,24 @@ public class ConnectionStatusColorConverter : IValueConverter
|
|||||||
// Converts a string to a color based on matching
|
// Converts a string to a color based on matching
|
||||||
public class StringMatchConverter : IValueConverter
|
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)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
// For matching menu items
|
// For matching menu items
|
||||||
if (value is string currentValue && parameter is string targetValue)
|
if (parameter is string targetValue)
|
||||||
{
|
{
|
||||||
if (currentValue == targetValue)
|
string currentValue = value as string;
|
||||||
{
|
|
||||||
// Default to background coloring
|
|
||||||
Color returnColor = Application.Current.Resources["PrimaryLight"] as Color ?? Colors.LightBlue;
|
|
||||||
|
|
||||||
// Check for additional parameter context
|
// Either it's explicitly selected, or it's the default item and nothing is selected yet
|
||||||
if (targetValue.EndsWith(":TextColor"))
|
if (currentValue == targetValue || (currentValue == null && targetValue == DefaultNavItem))
|
||||||
{
|
{
|
||||||
// Strip the ":TextColor" suffix before comparison
|
return Application.Current.Resources["PrimaryLight"] as Color ?? Colors.LightBlue;
|
||||||
string strippedTarget = targetValue.Substring(0, targetValue.Length - 10);
|
|
||||||
if (currentValue == strippedTarget)
|
|
||||||
{
|
|
||||||
return Application.Current.Resources["Primary"] as Color ?? Colors.Black;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnColor;
|
// Return transparent for non-selected items
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return default values
|
|
||||||
if (parameter is string param && param == "TextColor")
|
|
||||||
{
|
|
||||||
return Application.Current.Resources["TextSecondary"] as Color ?? Colors.Gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default background is transparent
|
|
||||||
return Colors.Transparent;
|
return Colors.Transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,18 +269,23 @@ public class RelativeTimeConverter : IValueConverter
|
|||||||
// Add this new converter for text color specifically
|
// Add this new converter for text color specifically
|
||||||
public class StringMatchTextConverter : IValueConverter
|
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)
|
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 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;
|
return Application.Current.Resources["TextSecondary"] as Color ?? Colors.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,6 +657,10 @@ public class OledConfigViewModel : BaseViewModel
|
|||||||
IsMarkupEditorSelected = tab == "markup";
|
IsMarkupEditorSelected = tab == "markup";
|
||||||
IsTemplatesSelected = tab == "templates";
|
IsTemplatesSelected = tab == "templates";
|
||||||
|
|
||||||
|
OnPropertyChanged(nameof(IsVisualEditorSelected));
|
||||||
|
OnPropertyChanged(nameof(IsMarkupEditorSelected));
|
||||||
|
OnPropertyChanged(nameof(IsTemplatesSelected));
|
||||||
|
|
||||||
switch (tab)
|
switch (tab)
|
||||||
{
|
{
|
||||||
case "visual":
|
case "visual":
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public class SettingsViewModel : BaseViewModel
|
|||||||
public ICommand StartServiceCommand { get; }
|
public ICommand StartServiceCommand { get; }
|
||||||
public ICommand StopServiceCommand { get; }
|
public ICommand StopServiceCommand { get; }
|
||||||
public ICommand RestartServiceCommand { get; }
|
public ICommand RestartServiceCommand { get; }
|
||||||
public ICommand CheckForUpdatesCommand { get; }
|
|
||||||
|
|
||||||
public SettingsViewModel(IConfigurationService configService, ISerialPortService serialPortService)
|
public SettingsViewModel(IConfigurationService configService, ISerialPortService serialPortService)
|
||||||
{
|
{
|
||||||
@@ -142,7 +141,6 @@ public class SettingsViewModel : BaseViewModel
|
|||||||
StartServiceCommand = new Command(async () => await StartServiceAsync());
|
StartServiceCommand = new Command(async () => await StartServiceAsync());
|
||||||
StopServiceCommand = new Command(async () => await StopServiceAsync());
|
StopServiceCommand = new Command(async () => await StopServiceAsync());
|
||||||
RestartServiceCommand = new Command(async () => await RestartServiceAsync());
|
RestartServiceCommand = new Command(async () => await RestartServiceAsync());
|
||||||
CheckForUpdatesCommand = new Command(async () => await CheckForUpdatesAsync());
|
|
||||||
|
|
||||||
// Subscribe to serial port connection changes
|
// Subscribe to serial port connection changes
|
||||||
_serialPortService.ConnectionStatusChanged += OnConnectionStatusChanged;
|
_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)
|
private void OnConnectionStatusChanged(object sender, bool isConnected)
|
||||||
{
|
{
|
||||||
MainThread.BeginInvokeOnMainThread(() =>
|
MainThread.BeginInvokeOnMainThread(() =>
|
||||||
|
|||||||
@@ -1,39 +1,12 @@
|
|||||||
using System.Windows.Input;
|
namespace PCPal.Configurator.ViewModels;
|
||||||
|
|
||||||
namespace PCPal.Configurator.ViewModels;
|
|
||||||
|
|
||||||
public class TftConfigViewModel : BaseViewModel
|
public class TftConfigViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
public ICommand NotifyCommand { get; }
|
|
||||||
|
|
||||||
public TftConfigViewModel()
|
public TftConfigViewModel()
|
||||||
{
|
{
|
||||||
Title = "TFT Display Configuration";
|
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
Padding="20,10"
|
Padding="20,10"
|
||||||
WidthRequest="160">
|
WidthRequest="160">
|
||||||
<Label Text="Visual Editor"
|
<Label Text="Visual Editor"
|
||||||
TextColor="{Binding IsVisualEditorSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
|
TextColor="{Binding IsVisualEditorSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer Command="{Binding SwitchToVisualEditorCommand}" />
|
<TapGestureRecognizer Command="{Binding SwitchToVisualEditorCommand}" />
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
Padding="20,10"
|
Padding="20,10"
|
||||||
WidthRequest="160">
|
WidthRequest="160">
|
||||||
<Label Text="Markup Editor"
|
<Label Text="Markup Editor"
|
||||||
TextColor="{Binding IsMarkupEditorSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
|
TextColor="{Binding IsMarkupEditorSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer Command="{Binding SwitchToMarkupEditorCommand}" />
|
<TapGestureRecognizer Command="{Binding SwitchToMarkupEditorCommand}" />
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
Padding="20,10"
|
Padding="20,10"
|
||||||
WidthRequest="160">
|
WidthRequest="160">
|
||||||
<Label Text="Templates"
|
<Label Text="Templates"
|
||||||
TextColor="{Binding IsTemplatesSelected, Converter={StaticResource BoolToColorConverter}, ConverterParameter=White}"
|
TextColor="{Binding IsTemplatesSelected, Converter={StaticResource BoolToTextColorConverter}, ConverterParameter=White}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer Command="{Binding SwitchToTemplatesCommand}" />
|
<TapGestureRecognizer Command="{Binding SwitchToTemplatesCommand}" />
|
||||||
|
|||||||
@@ -233,10 +233,6 @@
|
|||||||
<Label Text="License: MIT" />
|
<Label Text="License: MIT" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
<Button Text="Check for Updates"
|
|
||||||
Command="{Binding CheckForUpdatesCommand}"
|
|
||||||
HorizontalOptions="Start"
|
|
||||||
Margin="0,10,0,0" />
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,7 @@
|
|||||||
</Border.StrokeShape>
|
</Border.StrokeShape>
|
||||||
|
|
||||||
<VerticalStackLayout Spacing="20" HorizontalOptions="Center" Padding="30">
|
<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!"
|
<Label Text="TFT Display Support Coming Soon!"
|
||||||
FontSize="24"
|
FontSize="24"
|
||||||
@@ -65,12 +62,7 @@
|
|||||||
HorizontalOptions="Start" />
|
HorizontalOptions="Start" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
<Button Text="Notify Me When Available"
|
|
||||||
Command="{Binding NotifyCommand}"
|
|
||||||
BackgroundColor="{StaticResource Primary}"
|
|
||||||
TextColor="White"
|
|
||||||
HorizontalOptions="Center"
|
|
||||||
Margin="0,10,0,0" />
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user