feat: admin login audit in SQLite; Settings Admin Card ID from DB; Scanner dashboard UI

Backend / data
- Add AdminLoginRecords table (Username, EmployeeId, LoginTimeUtc); record on each admin login
- Add IAdminAuditService (RecordLoginAsync, GetLastLogin); AdminAuditService implementation
- Settings: Admin Card ID always prefilled from last admin login in DB (AdminLoginRecords.EmployeeId), fallback "ADMIN"
- Wire AdminAuditService in App.xaml.cs; inject into AdminLoginViewModel and SettingsViewModel

UI
- Scanner Dashboard: two-panel layout (left: employee card with photo, name, department, employee ID, order; right: order placement + stats)
- Employee section: larger fonts and spacing, circular profile image, sample data and asset (emppic.jpeg)
- Menu bar: Site / Settings / Logout in WrapPanel for responsive layout; consistent button sizing
- Dashboard and card responsive (ScrollViewer, MinWidth 0, card MinWidth 360 / MaxWidth 1150)
- Scanner status: activity-based only (connected when input received; no hardware detection)
pull/1/head
SYED MUSTUFA AHMED NAQVI 2026-02-04 18:18:17 +05:00
parent 7bc5ffc77e
commit 90380bf4fb
16 changed files with 648 additions and 386 deletions

View File

@ -31,6 +31,7 @@ public partial class App : Application
var configService = new ConfigService(); var configService = new ConfigService();
var rfidService = new RfidService(dbFactory, configService); var rfidService = new RfidService(dbFactory, configService);
var syncService = new SyncService(dbFactory, configService); var syncService = new SyncService(dbFactory, configService);
var adminAuditService = new AdminAuditService(dbFactory);
var session = new AppSession(); var session = new AppSession();
var authenticationUrl = "https://portal.utopiaindustries.pk/uind/rest/auth/user/"; var authenticationUrl = "https://portal.utopiaindustries.pk/uind/rest/auth/user/";
var authService = new AuthService(authenticationUrl); var authService = new AuthService(authenticationUrl);
@ -39,11 +40,11 @@ public partial class App : Application
NavigationService navigationService = null!; NavigationService navigationService = null!;
navigationService = new NavigationService( navigationService = new NavigationService(
session, session,
() => new AdminLoginViewModel(authService, session, navigationService, configService), () => new AdminLoginViewModel(authService, session, navigationService, configService, adminAuditService),
() => new ScannerDashboardViewModel(rfidService, navigationService, session, configService), () => new ScannerDashboardViewModel(rfidService, navigationService, session, configService),
() => new MainDashboardViewModel(navigationService, rfidService, configService, session), () => new MainDashboardViewModel(navigationService, rfidService, configService, session),
() => new AdminSettingsAuthViewModel(authService, session, navigationService, configService), () => new AdminSettingsAuthViewModel(authService, session, navigationService, configService),
() => new SettingsViewModel(configService, navigationService)); () => new SettingsViewModel(configService, navigationService, adminAuditService));
var mainViewModel = new MainViewModel(navigationService); var mainViewModel = new MainViewModel(navigationService);

View File

@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace UtopiaCanteenSystem.Converters
{
/// <summary>
/// Converts a string URI (e.g. pack:// or file path) to an ImageSource for Image controls.
/// </summary>
public class StringToImageSourceConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var path = value?.ToString();
if (string.IsNullOrWhiteSpace(path))
return null;
try
{
var uri = new Uri(path, UriKind.RelativeOrAbsolute);
return new BitmapImage(uri);
}
catch
{
return null;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
@ -9,9 +9,10 @@ namespace UtopiaCanteenSystem.Converters
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
return string.IsNullOrWhiteSpace(value?.ToString()) var visible = !string.IsNullOrWhiteSpace(value?.ToString());
? Visibility.Collapsed if (string.Equals(parameter?.ToString(), "Invert", StringComparison.OrdinalIgnoreCase))
: Visibility.Visible; visible = !visible;
return visible ? Visibility.Visible : Visibility.Collapsed;
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View File

@ -17,6 +17,7 @@ public class AppDbContext : DbContext
public DbSet<Labour> Labour { get; set; } public DbSet<Labour> Labour { get; set; }
public DbSet<ScanRecord> ScanRecords { get; set; } public DbSet<ScanRecord> ScanRecords { get; set; }
public DbSet<AdminLoginRecord> AdminLoginRecords { get; set; }
public AppDbContext() { } public AppDbContext() { }
@ -44,6 +45,12 @@ public class AppDbContext : DbContext
e.HasIndex(x => x.IsSynced); e.HasIndex(x => x.IsSynced);
e.HasIndex(x => x.ScanTime); e.HasIndex(x => x.ScanTime);
}); });
modelBuilder.Entity<AdminLoginRecord>(e =>
{
e.HasKey(x => x.Id);
e.HasIndex(x => x.LoginTimeUtc);
});
} }
/// <summary> /// <summary>
@ -53,6 +60,7 @@ public class AppDbContext : DbContext
{ {
Database.EnsureCreated(); Database.EnsureCreated();
UpgradeScanRecordsSchemaIfNeeded(); UpgradeScanRecordsSchemaIfNeeded();
EnsureAdminLoginTableExists();
} }
/// <summary> /// <summary>
@ -95,4 +103,30 @@ public class AppDbContext : DbContext
// Ignore; existing DB may already have columns or be incompatible // Ignore; existing DB may already have columns or be incompatible
} }
} }
/// <summary>
/// Lightweight creation of AdminLoginRecords table for existing databases.
/// </summary>
private void EnsureAdminLoginTableExists()
{
try
{
var conn = Database.GetDbConnection();
if (conn.State != ConnectionState.Open)
conn.Open();
using var cmd = conn.CreateCommand();
cmd.CommandText =
"CREATE TABLE IF NOT EXISTS AdminLoginRecords (" +
"Id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"Username TEXT NOT NULL, " +
"EmployeeId TEXT NOT NULL, " +
"LoginTimeUtc TEXT NOT NULL)";
cmd.ExecuteNonQuery();
}
catch
{
// Ignore; table may already exist or DB may be read-only.
}
}
} }

View File

@ -3,10 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Utopia Canteen System" Title="Utopia Canteen System"
Icon="pack://siteoforigin:,,,/assets/favicon.ico" Icon="pack://siteoforigin:,,,/assets/favicon.ico"
MinHeight="600" MinWidth="800" MinHeight="400" MinWidth="480"
WindowStartupLocation="CenterScreen" Width="900" Height="700"
SizeToContent="WidthAndHeight"> WindowStartupLocation="CenterScreen">
<Grid> <Grid>
<ContentControl Content="{Binding CurrentViewModel}" /> <ContentControl Content="{Binding CurrentViewModel}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -0,0 +1,14 @@
namespace UtopiaCanteenSystem.Models;
/// <summary>
/// Audit record of an admin login on this kiosk/device.
/// Passwords are NEVER stored here only identity and timestamps.
/// </summary>
public class AdminLoginRecord
{
public int Id { get; set; }
public string Username { get; set; } = string.Empty;
public string EmployeeId { get; set; } = string.Empty;
public DateTime LoginTimeUtc { get; set; }
}

View File

@ -0,0 +1,59 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using UtopiaCanteenSystem.Data;
using UtopiaCanteenSystem.Models;
namespace UtopiaCanteenSystem.Services;
/// <summary>
/// Persists simple admin login audit records to the local SQLite database.
/// </summary>
public class AdminAuditService : IAdminAuditService
{
private readonly DbContextFactory _dbFactory;
public AdminAuditService(DbContextFactory dbFactory)
{
_dbFactory = dbFactory;
}
public async Task RecordLoginAsync(string username, string employeeId)
{
try
{
await using var db = _dbFactory.CreateDbContext();
var record = new AdminLoginRecord
{
Username = username ?? string.Empty,
EmployeeId = employeeId ?? string.Empty,
LoginTimeUtc = DateTime.UtcNow
};
db.AdminLoginRecords.Add(record);
await db.SaveChangesAsync().ConfigureAwait(false);
}
catch
{
// Audit failures should never block login; ignore errors.
}
}
/// <summary>
/// Returns the most recent admin login record for this kiosk, or null if none exist.
/// </summary>
public AdminLoginRecord? GetLastLogin()
{
try
{
using var db = _dbFactory.CreateDbContext();
return db.AdminLoginRecords
.OrderByDescending(x => x.LoginTimeUtc)
.FirstOrDefault();
}
catch
{
return null;
}
}
}

View File

@ -0,0 +1,11 @@
using System.Threading.Tasks;
using UtopiaCanteenSystem.Models;
namespace UtopiaCanteenSystem.Services;
public interface IAdminAuditService
{
Task RecordLoginAsync(string username, string employeeId);
AdminLoginRecord? GetLastLogin();
}

View File

@ -10,6 +10,7 @@ public partial class AdminLoginViewModel : ObservableObject
private readonly AppSession _session; private readonly AppSession _session;
private readonly INavigationService _navigation; private readonly INavigationService _navigation;
private readonly IConfigService _config; private readonly IConfigService _config;
private readonly IAdminAuditService _adminAudit;
[ObservableProperty] [ObservableProperty]
private string _username = string.Empty; private string _username = string.Empty;
@ -27,12 +28,18 @@ public partial class AdminLoginViewModel : ObservableObject
[ObservableProperty] [ObservableProperty]
private bool _rememberCredentials; private bool _rememberCredentials;
public AdminLoginViewModel(IAuthService authService, AppSession session, INavigationService navigation, IConfigService config) public AdminLoginViewModel(
IAuthService authService,
AppSession session,
INavigationService navigation,
IConfigService config,
IAdminAuditService adminAudit)
{ {
_authService = authService; _authService = authService;
_session = session; _session = session;
_navigation = navigation; _navigation = navigation;
_config = config; _config = config;
_adminAudit = adminAudit;
RememberCredentials = _config.GetRememberAdminCredentials(); RememberCredentials = _config.GetRememberAdminCredentials();
if (RememberCredentials) if (RememberCredentials)
@ -76,6 +83,9 @@ public partial class AdminLoginViewModel : ObservableObject
_session.SetAdminAuthenticated(user, result.EmployeeId); _session.SetAdminAuthenticated(user, result.EmployeeId);
// Persist who logged in (for audit / reporting).
await _adminAudit.RecordLoginAsync(user, result.EmployeeId).ConfigureAwait(false);
// Persist credentials only if user opted in. // Persist credentials only if user opted in.
_config.SetRememberAdminCredentials(RememberCredentials); _config.SetRememberAdminCredentials(RememberCredentials);
if (RememberCredentials) if (RememberCredentials)

View File

@ -21,6 +21,8 @@ public partial class ScannerDashboardViewModel : ObservableObject
private readonly INavigationService _navigation; private readonly INavigationService _navigation;
private readonly AppSession _session; private readonly AppSession _session;
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly DispatcherTimer _scannerStatusTimer;
private DateTime? _lastScanActivityUtc;
private readonly Dispatcher _uiDispatcher; private readonly Dispatcher _uiDispatcher;
private readonly DebounceTimer _debounceTimer; private readonly DebounceTimer _debounceTimer;
@ -31,9 +33,6 @@ public partial class ScannerDashboardViewModel : ObservableObject
private string _cooldownBlockedCardId = string.Empty; private string _cooldownBlockedCardId = string.Empty;
private bool _suppressCooldownRewrite; private bool _suppressCooldownRewrite;
private readonly DispatcherTimer _scannerStatusTimer;
private DateTime? _lastScanActivityUtc;
private readonly DispatcherTimer _clockTimer; private readonly DispatcherTimer _clockTimer;
private readonly object _submitLock = new(); private readonly object _submitLock = new();
@ -103,7 +102,29 @@ public partial class ScannerDashboardViewModel : ObservableObject
/// <summary>Display string for current site (e.g. "SITE : 1").</summary> /// <summary>Display string for current site (e.g. "SITE : 1").</summary>
public string CurrentSiteDisplay => string.IsNullOrWhiteSpace(SiteNumber) ? "SITE : 1" : $"SITE : {SiteNumber.Trim()}"; public string CurrentSiteDisplay => string.IsNullOrWhiteSpace(SiteNumber) ? "SITE : 1" : $"SITE : {SiteNumber.Trim()}";
public ScannerDashboardViewModel(IRfidService rfidService, INavigationService navigation, AppSession session, IConfigService configService) // --- Left panel: Employee information (sample data for display; replace with real lookup when available) ---
[ObservableProperty]
private string _employeeName = "Syed Mustufa Ahmed Naqvi";
[ObservableProperty]
private string _employeeDepartment = "Technology";
[ObservableProperty]
private string _employeeId = "15399";
/// <summary>Item selected by the employee for the order (e.g. Chicken Biryani).</summary>
[ObservableProperty]
private string _employeeOrderItem = "Chicken Biryani";
/// <summary>Optional profile image path; null = show placeholder.</summary>
[ObservableProperty]
private string? _employeeProfileImagePath = "pack://siteoforigin:,,,/assets/emp-pic/emppic.jpeg";
public ScannerDashboardViewModel(
IRfidService rfidService,
INavigationService navigation,
AppSession session,
IConfigService configService)
{ {
_rfidService = rfidService; _rfidService = rfidService;
_navigation = navigation; _navigation = navigation;
@ -135,7 +156,7 @@ public partial class ScannerDashboardViewModel : ObservableObject
_cooldownTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(CooldownTickSeconds) }; _cooldownTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(CooldownTickSeconds) };
_cooldownTimer.Tick += (_, _) => UpdateCooldownMessage(); _cooldownTimer.Tick += (_, _) => UpdateCooldownMessage();
// Activity-based scanner status. // Activity-based scanner status (keyboard-wedge style scanners).
_scannerStatusTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; _scannerStatusTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
_scannerStatusTimer.Tick += (_, _) => UpdateScannerStatusFromActivity(); _scannerStatusTimer.Tick += (_, _) => UpdateScannerStatusFromActivity();
_scannerStatusTimer.Start(); _scannerStatusTimer.Start();
@ -217,17 +238,17 @@ public partial class ScannerDashboardViewModel : ObservableObject
} }
} }
// Clear any previous message once a new scan starts (outside cooldown). // Any incoming characters means activity from the scanner keyboard wedge.
if (!string.IsNullOrWhiteSpace(value) && !string.IsNullOrEmpty(Message))
Message = string.Empty;
// Any incoming characters means activity.
if (!string.IsNullOrWhiteSpace(value)) if (!string.IsNullOrWhiteSpace(value))
{ {
_lastScanActivityUtc = DateTime.UtcNow; _lastScanActivityUtc = DateTime.UtcNow;
ScannerStatus = "Connected"; ScannerStatus = "Connected";
} }
// Clear any previous message once a new scan starts (outside cooldown).
if (!string.IsNullOrWhiteSpace(value) && !string.IsNullOrEmpty(Message))
Message = string.Empty;
// Don't auto-submit while cooldown is active or while we're processing. // Don't auto-submit while cooldown is active or while we're processing.
if (!_isCooldownActive && !IsProcessing) if (!_isCooldownActive && !IsProcessing)
RestartDebounceTimer(); RestartDebounceTimer();
@ -246,6 +267,23 @@ public partial class ScannerDashboardViewModel : ObservableObject
ScannerStatus = "Disconnected"; ScannerStatus = "Disconnected";
} }
private void UpdateScannerStatusFromActivity()
{
if (_lastScanActivityUtc is null)
{
if (!string.Equals(ScannerStatus, "Disconnected", StringComparison.Ordinal))
ScannerStatus = "Disconnected";
return;
}
var inactiveFor = DateTime.UtcNow - _lastScanActivityUtc.Value;
if (inactiveFor > ScannerInactivityTimeout &&
!string.Equals(ScannerStatus, "Disconnected", StringComparison.Ordinal))
{
ScannerStatus = "Disconnected";
}
}
[RelayCommand] [RelayCommand]
private void Logout() private void Logout()
{ {
@ -430,22 +468,6 @@ public partial class ScannerDashboardViewModel : ObservableObject
IsSuccess = false; IsSuccess = false;
} }
private void UpdateScannerStatusFromActivity()
{
if (_lastScanActivityUtc is null)
{
if (!string.Equals(ScannerStatus, "Disconnected", StringComparison.Ordinal))
ScannerStatus = "Disconnected";
return;
}
if (DateTime.UtcNow - _lastScanActivityUtc.Value > ScannerInactivityTimeout)
{
if (!string.Equals(ScannerStatus, "Disconnected", StringComparison.Ordinal))
ScannerStatus = "Disconnected";
}
}
~ScannerDashboardViewModel() ~ScannerDashboardViewModel()
{ {
_scannerStatusTimer.Stop(); _scannerStatusTimer.Stop();

View File

@ -11,6 +11,7 @@ public partial class SettingsViewModel : ObservableObject
{ {
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly INavigationService _navigation; private readonly INavigationService _navigation;
private readonly IAdminAuditService _adminAudit;
[ObservableProperty] [ObservableProperty]
private string _syncApiEndpoint = string.Empty; private string _syncApiEndpoint = string.Empty;
@ -30,10 +31,11 @@ public partial class SettingsViewModel : ObservableObject
[ObservableProperty] [ObservableProperty]
private bool _isSaving; private bool _isSaving;
public SettingsViewModel(IConfigService configService, INavigationService navigation) public SettingsViewModel(IConfigService configService, INavigationService navigation, IAdminAuditService adminAudit)
{ {
_configService = configService; _configService = configService;
_navigation = navigation; _navigation = navigation;
_adminAudit = adminAudit;
LoadFromConfig(); LoadFromConfig();
} }
@ -42,7 +44,13 @@ public partial class SettingsViewModel : ObservableObject
{ {
SyncApiEndpoint = _configService.GetSyncApiEndpoint(); SyncApiEndpoint = _configService.GetSyncApiEndpoint();
ScanTimeoutSeconds = _configService.GetScanTimeoutSeconds().ToString(); ScanTimeoutSeconds = _configService.GetScanTimeoutSeconds().ToString();
AdminCardId = _configService.GetAdminCardId();
// Always prefer the latest admin login from the database.
var last = _adminAudit.GetLastLogin();
if (last != null && !string.IsNullOrWhiteSpace(last.EmployeeId))
AdminCardId = last.EmployeeId;
else
AdminCardId = "ADMIN";
} }
[RelayCommand] [RelayCommand]

View File

@ -51,27 +51,30 @@
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="#F0F2F5"> <Grid Background="#F0F2F5" MinHeight="0" MinWidth="0">
<Viewbox Stretch="Uniform" <ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center" HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Center" Padding="16"
MaxWidth="650" HorizontalAlignment="Stretch"
MaxHeight="900"> VerticalAlignment="Stretch">
<Border HorizontalAlignment="Center" <Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
VerticalAlignment="Center" HorizontalAlignment="Stretch">
Padding="40" <Border HorizontalAlignment="Center"
MinWidth="450" VerticalAlignment="Center"
MaxWidth="560" Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
Background="White" MaxWidth="560"
CornerRadius="12"> MinWidth="280"
<Border.Effect> Padding="24"
<DropShadowEffect BlurRadius="24" Background="White"
ShadowDepth="0" CornerRadius="12">
Opacity="0.08" <Border.Effect>
Color="#000000"/> <DropShadowEffect BlurRadius="24"
</Border.Effect> ShadowDepth="0"
Opacity="0.08"
Color="#000000"/>
</Border.Effect>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@ -81,8 +84,8 @@
<Grid HorizontalAlignment="Center" Margin="0,0,0,12"> <Grid HorizontalAlignment="Center" Margin="0,0,0,12">
<Image x:Name="LogoImage" <Image x:Name="LogoImage"
Source="pack://siteoforigin:,,,/assets/logo4.png" Source="pack://siteoforigin:,,,/assets/logo4.png"
Height="190" Height="140"
MaxWidth="520" MaxWidth="400"
Stretch="Uniform" Stretch="Uniform"
HorizontalAlignment="Center" HorizontalAlignment="Center"
ImageFailed="LogoImage_OnImageFailed"/> ImageFailed="LogoImage_OnImageFailed"/>
@ -171,8 +174,9 @@
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>
</Border> </Border>
</Viewbox> </Grid>
</ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -76,27 +76,30 @@
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="#F0F2F5"> <Grid Background="#F0F2F5" MinHeight="0" MinWidth="0">
<Viewbox Stretch="Uniform" <ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center" HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Center" Padding="16"
MaxWidth="700" HorizontalAlignment="Stretch"
MaxHeight="900"> VerticalAlignment="Stretch">
<Border HorizontalAlignment="Center" <Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
VerticalAlignment="Center" HorizontalAlignment="Stretch">
Padding="40" <Border HorizontalAlignment="Center"
MinWidth="520" VerticalAlignment="Center"
MaxWidth="620" Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
Background="White" MaxWidth="620"
CornerRadius="12"> MinWidth="280"
<Border.Effect> Padding="24"
<DropShadowEffect BlurRadius="24" Background="White"
ShadowDepth="0" CornerRadius="12">
Opacity="0.08" <Border.Effect>
Color="#000000"/> <DropShadowEffect BlurRadius="24"
</Border.Effect> ShadowDepth="0"
Opacity="0.08"
Color="#000000"/>
</Border.Effect>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@ -147,9 +150,9 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*" MinWidth="0"/>
<ColumnDefinition Width="16"/> <ColumnDefinition Width="16"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*" MinWidth="0"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Grid.Column="0" <Button Grid.Column="0"
@ -199,8 +202,9 @@
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>
</Border> </Border>
</Viewbox> </Grid>
</ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -4,7 +4,9 @@
xmlns:local="clr-namespace:UtopiaCanteenSystem.Converters"> xmlns:local="clr-namespace:UtopiaCanteenSystem.Converters">
<UserControl.Resources> <UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
<local:StringToVisibilityConverter x:Key="StringToVisibility"/> <local:StringToVisibilityConverter x:Key="StringToVisibility"/>
<local:StringToImageSourceConverter x:Key="StringToImageSource"/>
<SolidColorBrush x:Key="AccentBrush" Color="#5BA3A0"/> <SolidColorBrush x:Key="AccentBrush" Color="#5BA3A0"/>
<SolidColorBrush x:Key="AccentBorderBrush" Color="#995BA3A0"/> <SolidColorBrush x:Key="AccentBorderBrush" Color="#995BA3A0"/>
@ -18,10 +20,10 @@
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="{StaticResource AccentBrush}"/> <Setter Property="Background" Value="{StaticResource AccentBrush}"/>
<Setter Property="BorderThickness" Value="0"/> <Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="18"/> <Setter Property="FontSize" Value="20"/>
<Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Padding" Value="24,12"/> <Setter Property="Padding" Value="28,14"/>
<Setter Property="MinHeight" Value="50"/> <Setter Property="MinHeight" Value="56"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
@ -144,7 +146,7 @@
<Style x:Key="StatusTextStyle" TargetType="TextBlock"> <Style x:Key="StatusTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource MutedTextBrush}"/> <Setter Property="Foreground" Value="{StaticResource MutedTextBrush}"/>
<Setter Property="FontSize" Value="14"/> <Setter Property="FontSize" Value="15"/>
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="FontWeight" Value="SemiBold"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding ScannerStatus}" Value="Connected"> <DataTrigger Binding="{Binding ScannerStatus}" Value="Connected">
@ -172,7 +174,7 @@
<Setter Property="BorderBrush" Value="#86efac"/> <Setter Property="BorderBrush" Value="#86efac"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="8"/> <Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="14"/> <Setter Property="Padding" Value="18"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding IsSuccess}" Value="False"> <DataTrigger Binding="{Binding IsSuccess}" Value="False">
<Setter Property="Background" Value="#fee2e2"/> <Setter Property="Background" Value="#fee2e2"/>
@ -182,306 +184,354 @@
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="#F0F2F5"> <Grid Background="#F0F2F5" MinHeight="0" MinWidth="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" <ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto"
Padding="40"> Padding="16"
<Border HorizontalAlignment="Center" HorizontalAlignment="Stretch"
VerticalAlignment="Top" VerticalAlignment="Stretch">
Width="{Binding RelativeSource={RelativeSource AncestorType=ScrollViewer}, Path=ViewportWidth}" <Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
MaxWidth="900" MinWidth="0"
Padding="40" HorizontalAlignment="Stretch">
Background="White" <Border HorizontalAlignment="Center"
CornerRadius="12"> VerticalAlignment="Center"
<Border.Effect> MinWidth="360"
<DropShadowEffect BlurRadius="24" Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
ShadowDepth="0" MaxWidth="1150"
Opacity="0.08" Padding="20"
Color="#000000"/> Background="White"
</Border.Effect> CornerRadius="12">
<Border.Effect>
<DropShadowEffect BlurRadius="24"
ShadowDepth="0"
Opacity="0.08"
Color="#000000"/>
</Border.Effect>
<Grid> <Grid MinWidth="0">
<Grid.RowDefinitions> <Grid.ColumnDefinitions>
<RowDefinition Height="Auto"/> <ColumnDefinition Width="*" MinWidth="0" MaxWidth="480"/>
<RowDefinition Height="Auto"/> <ColumnDefinition Width="16"/>
<RowDefinition Height="Auto"/> <ColumnDefinition Width="*" MinWidth="0"/>
<RowDefinition Height="Auto"/> </Grid.ColumnDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Menu button (top-right, prominent) --> <!-- Left Panel: Employee Information (larger text and profile to use space) -->
<ToggleButton x:Name="MenuToggleButton" <Border Grid.Column="0"
Grid.Row="0" MinWidth="0"
HorizontalAlignment="Right" Background="#f4f4f4"
VerticalAlignment="Top" BorderBrush="#e2e8f0"
Margin="0,0,0,8" BorderThickness="1"
IsChecked="{Binding IsMenuOpen, Mode=TwoWay}" CornerRadius="10"
Unchecked="MenuToggleButton_Unchecked" Padding="24">
Background="#f4f7f7" <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
BorderBrush="#e2e8f0" <StackPanel>
BorderThickness="1" <!-- Top row: circular profile image (left) + name (right) -->
Padding="14,10" <Grid Margin="0,0,0,24">
MinWidth="48" <Grid.ColumnDefinitions>
MinHeight="44" <ColumnDefinition Width="Auto"/>
FontSize="22" <ColumnDefinition Width="*" MinWidth="0"/>
FontWeight="SemiBold" </Grid.ColumnDefinitions>
Foreground="{StaticResource TitleTextBrush}" <!-- Profile image (circular); set EmployeeProfileImagePath to show photo -->
Focusable="False" <Grid Grid.Column="0" Width="110" Height="110" Margin="0,0,18,0">
IsTabStop="False" <Ellipse Fill="#e2e8f0"/>
ToolTip="Menu" <Image Source="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToImageSource}}"
Cursor="Hand"> Stretch="UniformToFill"
<ToggleButton.Content>⋮</ToggleButton.Content> Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}}">
<ToggleButton.Style> <Image.Clip>
<Style TargetType="ToggleButton"> <EllipseGeometry Center="55,55" RadiusX="55" RadiusY="55"/>
<Setter Property="Template"> </Image.Clip>
<Setter.Value> </Image>
<ControlTemplate TargetType="ToggleButton"> <TextBlock Text="—"
<Border x:Name="MenuBtnBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="8" Padding="{TemplateBinding Padding}"> FontSize="32"
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> Foreground="{StaticResource MutedTextBrush}"
</Border> HorizontalAlignment="Center"
<ControlTemplate.Triggers> VerticalAlignment="Center"
<Trigger Property="IsMouseOver" Value="True"> Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}, ConverterParameter=Invert}"/>
<Setter TargetName="MenuBtnBorder" Property="Background" Value="#e8eeed"/> </Grid>
<Setter TargetName="MenuBtnBorder" Property="BorderBrush" Value="{StaticResource AccentBrush}"/> <StackPanel Grid.Column="1" VerticalAlignment="Center" MinWidth="0">
</Trigger> <TextBlock Text="Name" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
<Trigger Property="IsChecked" Value="True"> <TextBlock Text="{Binding EmployeeName}" FontSize="22" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap"/>
<Setter TargetName="MenuBtnBorder" Property="Background" Value="#e0e7e6"/> <TextBlock Text="{Binding EmployeeDepartment}" FontSize="16" Foreground="{StaticResource MutedTextBrush}" Margin="0,6,0,0" TextTrimming="CharacterEllipsis"/>
<Setter TargetName="MenuBtnBorder" Property="BorderBrush" Value="{StaticResource AccentBrush}"/> </StackPanel>
</Trigger> </Grid>
</ControlTemplate.Triggers> <TextBlock Text="Department:" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
</ControlTemplate> <TextBlock Text="{Binding EmployeeDepartment}" FontSize="19" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,0,18" TextTrimming="CharacterEllipsis"/>
</Setter.Value> <TextBlock Text="Employee ID:" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
</Setter> <TextBlock Text="{Binding EmployeeId}" FontSize="19" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,0,18" TextTrimming="CharacterEllipsis"/>
</Style> <TextBlock Text="Order" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
</ToggleButton.Style> <TextBlock Text="{Binding EmployeeOrderItem}" FontSize="19" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap"/>
</ToggleButton> </StackPanel>
</ScrollViewer>
<!-- Inline menu panel (opens inside dashboard) -->
<Border x:Name="MenuPanel"
Grid.Row="1"
Background="#f8fafc"
BorderBrush="#e2e8f0"
BorderThickness="1"
CornerRadius="8"
Padding="16"
Margin="0,0,0,12"
Visibility="{Binding IsMenuOpen, Converter={StaticResource BoolToVisibility}}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="SITE :" VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,8,0"/>
<TextBox x:Name="SiteNumberTextBox"
Text="{Binding SiteNumber, UpdateSourceTrigger=PropertyChanged}"
Width="80"
FontSize="14"
Padding="8,6"
VerticalContentAlignment="Center"
PreviewTextInput="SiteNumberTextBox_PreviewTextInput"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Content="Settings"
Command="{Binding OpenSettingsCommand}"
Style="{StaticResource SecondaryButtonStyle}"
Margin="0,0,12,0"
Focusable="False"
IsTabStop="False"/>
<Button Command="{Binding LogoutCommand}"
Style="{StaticResource LogoutLinkButtonStyle}"
Focusable="False"
IsTabStop="False">
<StackPanel Orientation="Horizontal">
<TextBlock Text="⎋" FontSize="14" Margin="0,0,8,0" VerticalAlignment="Center"/>
<TextBlock Text="Logout" FontSize="14" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Border>
<!-- Top section -->
<StackPanel Grid.Row="2" HorizontalAlignment="Center">
<Image Source="pack://siteoforigin:,,,/assets/logo4.png"
Height="180"
MaxWidth="480"
Stretch="Uniform"
Margin="0,0,0,16"/>
<TextBlock Text="Tap card to place order"
FontSize="16"
Foreground="{StaticResource MutedTextBrush}"
HorizontalAlignment="Center"
Margin="0,8,0,0"/>
</StackPanel>
<!-- Order input -->
<StackPanel Grid.Row="3" Margin="0,24,0,0">
<Border MinHeight="50"
CornerRadius="8"
BorderBrush="{StaticResource AccentBorderBrush}"
BorderThickness="2">
<Grid>
<TextBox x:Name="RfidInputTextBox"
Text="{Binding CardIdInput, UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
BorderThickness="0"
FontSize="18"
MinHeight="50"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Focusable="True"
KeyDown="RfidInputTextBox_OnKeyDown"
LostKeyboardFocus="RfidInputTextBox_OnLostKeyboardFocus"/>
<TextBlock Text="Scan..."
Foreground="Gray"
FontSize="18"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextAlignment="Center"
IsHitTestVisible="False"
Visibility="{Binding IsWatermarkVisible, Converter={StaticResource BoolToVisibility}}"/>
</Grid>
</Border> </Border>
<Button Content="PLACE ORDER" <!-- Divider between panels -->
Command="{Binding ScanCommand}" <Border Grid.Column="1" Width="1" Background="#e2e8f0" HorizontalAlignment="Center" MinWidth="0"/>
Margin="0,16,0,0"
HorizontalAlignment="Stretch"
Style="{StaticResource RoundedButtonStyle}"/>
</StackPanel>
<!-- Status row + timestamp --> <!-- Right Panel: Order placement + statistics -->
<StackPanel Grid.Row="4" Margin="0,18,0,0" HorizontalAlignment="Center"> <Border Grid.Column="2"
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> MinWidth="0"
<TextBlock Style="{StaticResource StatusIconStyle}" Margin="0,0,8,0"/> Background="White"
<TextBlock Text="{Binding ScannerStatusDisplay}" Style="{StaticResource StatusTextStyle}"/> CornerRadius="10"
</StackPanel> Padding="16">
<TextBlock Text="{Binding CurrentTime}" <Grid MinWidth="0">
FontSize="14"
Foreground="{StaticResource MutedTextBrush}"
Margin="0,10,0,0"
HorizontalAlignment="Center"/>
</StackPanel>
<!-- Divider -->
<Border Grid.Row="5"
Height="1"
Background="#e2e8f0"
Margin="0,24,0,24"/>
<!-- Cooldown alert: ask customer to rescan after countdown -->
<Border Grid.Row="6"
Background="#fef2f2"
BorderBrush="#fca5a5"
BorderThickness="2"
CornerRadius="8"
Padding="20"
Margin="0,0,0,16"
Visibility="{Binding ShowCooldownAlert, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding CooldownAlertMessage}"
FontSize="20"
FontWeight="Bold"
Foreground="{StaticResource ErrorTextBrush}"
TextWrapping="Wrap"
TextAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
<!-- Dashboard section -->
<Grid Grid.Row="7">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,0,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="#f4f7f7" CornerRadius="8" Padding="24" Margin="0,0,8,0">
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="{Binding TodaysScans}"
FontSize="56"
FontWeight="Bold"
Foreground="{StaticResource TitleTextBrush}"
HorizontalAlignment="Center"/>
<TextBlock Text="Today's Customer"
FontSize="16"
Foreground="{StaticResource MutedTextBrush}"
HorizontalAlignment="Center"
Margin="0,6,0,0"/>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#f4f7f7" CornerRadius="8" Padding="24" Margin="8,0,0,0">
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="{Binding TotalOrders}"
FontSize="56"
FontWeight="Bold"
Foreground="{StaticResource TitleTextBrush}"
HorizontalAlignment="Center"/>
<TextBlock Text="Total Orders"
FontSize="16"
Foreground="{StaticResource MutedTextBrush}"
HorizontalAlignment="Center"
Margin="0,6,0,0"/>
</StackPanel>
</Border>
</Grid>
<Border Grid.Row="1" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="8" Padding="16" Margin="0,0,0,16">
<Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Margin="0,0,12,12"> <!-- Menu button (top-right) -->
<TextBlock Text="LAST CARD" FontSize="12" Foreground="{StaticResource MutedTextBrush}" FontWeight="SemiBold"/> <ToggleButton x:Name="MenuToggleButton"
<TextBlock Text="{Binding LastCardId}" FontSize="20" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" /> Grid.Row="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,0,0,12"
IsChecked="{Binding IsMenuOpen, Mode=TwoWay}"
Unchecked="MenuToggleButton_Unchecked"
Background="#f4f7f7"
BorderBrush="#e2e8f0"
BorderThickness="1"
Padding="14,10"
MinWidth="48"
MinHeight="44"
FontSize="22"
FontWeight="SemiBold"
Foreground="{StaticResource TitleTextBrush}"
Focusable="False"
IsTabStop="False"
ToolTip="Menu"
Cursor="Hand">
<ToggleButton.Content>⋮</ToggleButton.Content>
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="MenuBtnBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="8" Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="MenuBtnBorder" Property="Background" Value="#e8eeed"/>
<Setter TargetName="MenuBtnBorder" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="MenuBtnBorder" Property="Background" Value="#e0e7e6"/>
<Setter TargetName="MenuBtnBorder" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
<!-- Inline menu panel (responsive: wraps; Settings/Logout with consistent sizing) -->
<Border x:Name="MenuPanel"
Grid.Row="1"
MinWidth="0"
Background="#f8fafc"
BorderBrush="#e2e8f0"
BorderThickness="1"
CornerRadius="8"
Padding="14"
Margin="0,0,0,12"
Visibility="{Binding IsMenuOpen, Converter={StaticResource BoolToVisibility}}">
<WrapPanel Orientation="Horizontal"
VerticalAlignment="Center"
Margin="0,2,0,2">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,20,0">
<TextBlock Text="SITE :" VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,8,0"/>
<TextBox x:Name="SiteNumberTextBox"
Text="{Binding SiteNumber, UpdateSourceTrigger=PropertyChanged}"
Width="72"
MinWidth="56"
FontSize="14"
Padding="8,8"
MinHeight="40"
VerticalContentAlignment="Center"
PreviewTextInput="SiteNumberTextBox_PreviewTextInput"/>
</StackPanel>
<Button Content="Settings"
Command="{Binding OpenSettingsCommand}"
Style="{StaticResource SecondaryButtonStyle}"
Margin="0,0,10,0"
MinWidth="100"
MinHeight="44"
Padding="16,10"
FontSize="14"
Focusable="False"
IsTabStop="False"/>
<Button Command="{Binding LogoutCommand}"
Style="{StaticResource LogoutLinkButtonStyle}"
MinWidth="100"
MinHeight="44"
Padding="16,10"
Focusable="False"
IsTabStop="False">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="⎋" FontSize="14" Margin="0,0,8,0" VerticalAlignment="Center"/>
<TextBlock Text="Logout" FontSize="14" FontWeight="SemiBold" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</WrapPanel>
</Border>
<!-- Logo + instruction -->
<StackPanel Grid.Row="2" HorizontalAlignment="Center" MinWidth="0">
<Image Source="pack://siteoforigin:,,,/assets/logo4.png"
Height="100"
MaxWidth="320"
Stretch="Uniform"
Margin="0,0,0,8"/>
<TextBlock Text="Tap card to place order"
FontSize="16"
Foreground="{StaticResource MutedTextBrush}"
HorizontalAlignment="Center"
TextAlignment="Center"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" Margin="12,0,0,12"> <!-- Scan box + Place Order button -->
<TextBlock Text="LAST ORDER TIME" FontSize="12" Foreground="{StaticResource MutedTextBrush}" FontWeight="SemiBold"/> <StackPanel Grid.Row="3" Margin="0,16,0,0" MinWidth="0">
<TextBlock Text="{Binding LastScanTimeDisplay}" FontSize="20" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" /> <Border MinHeight="50"
CornerRadius="8"
BorderBrush="{StaticResource AccentBorderBrush}"
BorderThickness="2">
<Grid>
<TextBox x:Name="RfidInputTextBox"
Text="{Binding CardIdInput, UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
BorderThickness="0"
FontSize="18"
MinHeight="50"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Focusable="True"
KeyDown="RfidInputTextBox_OnKeyDown"
LostKeyboardFocus="RfidInputTextBox_OnLostKeyboardFocus"/>
<TextBlock Text="Scan..."
Foreground="Gray"
FontSize="18"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextAlignment="Center"
IsHitTestVisible="False"
Visibility="{Binding IsWatermarkVisible, Converter={StaticResource BoolToVisibility}}"/>
</Grid>
</Border>
<Button Content="PLACE ORDER"
Command="{Binding ScanCommand}"
Margin="0,12,0,0"
HorizontalAlignment="Stretch"
Style="{StaticResource RoundedButtonStyle}"/>
</StackPanel> </StackPanel>
<!-- Scanner status + timestamp -->
<StackPanel Grid.Row="4" Margin="0,14,0,0" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Style="{StaticResource StatusIconStyle}" Margin="0,0,8,0"/>
<TextBlock Text="{Binding ScannerStatusDisplay}" Style="{StaticResource StatusTextStyle}"/>
</StackPanel>
<TextBlock Text="{Binding CurrentTime}"
FontSize="14"
Foreground="{StaticResource MutedTextBrush}"
Margin="0,6,0,0"
HorizontalAlignment="Center"/>
</StackPanel>
<!-- Divider -->
<Border Grid.Row="5" Height="1" Background="#e2e8f0" Margin="0,14,0,14"/>
<!-- Cooldown alert -->
<Border Grid.Row="6"
Background="#fef2f2"
BorderBrush="#fca5a5"
BorderThickness="2"
CornerRadius="8"
Padding="14"
Margin="0,0,0,12"
Visibility="{Binding ShowCooldownAlert, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding CooldownAlertMessage}"
FontSize="18"
FontWeight="Bold"
Foreground="{StaticResource ErrorTextBrush}"
TextWrapping="Wrap"
TextAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
<!-- Statistics -->
<Grid Grid.Row="7" MinWidth="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,0,0,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="0"/>
<ColumnDefinition Width="*" MinWidth="0"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="#f4f7f7" CornerRadius="8" Padding="16" Margin="0,0,6,0">
<StackPanel HorizontalAlignment="Center" MinWidth="0">
<TextBlock Text="{Binding TodaysScans}" FontSize="40" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" HorizontalAlignment="Center"/>
<TextBlock Text="Today's Customer" FontSize="14" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center" Margin="0,4,0,0" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#f4f7f7" CornerRadius="8" Padding="16" Margin="6,0,0,0">
<StackPanel HorizontalAlignment="Center" MinWidth="0">
<TextBlock Text="{Binding TotalOrders}" FontSize="40" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" HorizontalAlignment="Center"/>
<TextBlock Text="Total Orders" FontSize="14" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center" Margin="0,4,0,0" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
<Border Grid.Row="1" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="8" Padding="12" Margin="0,0,0,12">
<Grid MinWidth="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="0"/>
<ColumnDefinition Width="*" MinWidth="0"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,8,0">
<TextBlock Text="LAST CARD" FontSize="12" Foreground="{StaticResource MutedTextBrush}" FontWeight="SemiBold"/>
<TextBlock Text="{Binding LastCardId}" FontSize="16" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0"/>
</StackPanel>
<StackPanel Grid.Column="1" Margin="8,0,0,0">
<TextBlock Text="LAST ORDER TIME" FontSize="12" Foreground="{StaticResource MutedTextBrush}" FontWeight="SemiBold"/>
<TextBlock Text="{Binding LastScanTimeDisplay}" FontSize="16" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0"/>
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="2"
Style="{StaticResource StatusBorderStyle}"
Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}">
<TextBlock Text="{Binding Message}" FontSize="16" FontWeight="SemiBold" TextWrapping="Wrap">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource SuccessTextBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSuccess}" Value="False">
<Setter Property="Foreground" Value="{StaticResource ErrorTextBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</Grid>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Row="2"
Style="{StaticResource StatusBorderStyle}"
Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}">
<TextBlock Text="{Binding Message}"
FontSize="16"
FontWeight="SemiBold"
Foreground="{StaticResource SuccessTextBrush}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource SuccessTextBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSuccess}" Value="False">
<Setter Property="Foreground" Value="{StaticResource ErrorTextBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</Grid> </Grid>
</Grid>
</Border> </Border>
</Grid>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,4 +1,4 @@
<UserControl x:Class="UtopiaCanteenSystem.Views.SettingsView" <UserControl x:Class="UtopiaCanteenSystem.Views.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Resources> <UserControl.Resources>
@ -167,13 +167,19 @@
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="{StaticResource AppBackground}"> <Grid Background="{StaticResource AppBackground}" MinHeight="0" MinWidth="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" <ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
Padding="40"> Padding="16"
<StackPanel HorizontalAlignment="Center" HorizontalAlignment="Stretch"
Width="{Binding RelativeSource={RelativeSource AncestorType=ScrollViewer}, Path=ViewportWidth}" VerticalAlignment="Stretch">
MaxWidth="1200"> <Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
HorizontalAlignment="Stretch">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
MaxWidth="1200"
MinWidth="280">
<!-- Title section --> <!-- Title section -->
<StackPanel Orientation="Horizontal" Margin="0,0,0,24"> <StackPanel Orientation="Horizontal" Margin="0,0,0,24">
<Border Width="48" Height="48" Background="#eef2f2" CornerRadius="24" Margin="0,0,16,0"> <Border Width="48" Height="48" Background="#eef2f2" CornerRadius="24" Margin="0,0,16,0">
@ -209,7 +215,7 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Card header --> <!-- Card header -->
<StackPanel Grid.Row="0" Margin="32,24,32,16"> <StackPanel Grid.Row="0" Margin="24,20,24,12">
<TextBlock Text="Configuration" <TextBlock Text="Configuration"
FontSize="24" FontSize="24"
FontWeight="Bold" FontWeight="Bold"
@ -221,7 +227,7 @@
</StackPanel> </StackPanel>
<!-- Form fields --> <!-- Form fields -->
<StackPanel Grid.Row="1" Margin="32,0,32,0"> <StackPanel Grid.Row="1" Margin="24,0,24,0">
<TextBlock Text="Scan Timeout (seconds)" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" /> <TextBlock Text="Scan Timeout (seconds)" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" />
<TextBox Text="{Binding ScanTimeoutSeconds, UpdateSourceTrigger=PropertyChanged}" <TextBox Text="{Binding ScanTimeoutSeconds, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource ModernTextBoxStyle}" Margin="0,8,0,8" /> Style="{StaticResource ModernTextBoxStyle}" Margin="0,8,0,8" />
@ -230,7 +236,7 @@
Foreground="{StaticResource MutedText}" Foreground="{StaticResource MutedText}"
Margin="0,0,0,20" /> Margin="0,0,0,20" />
<TextBlock Text="Admin Card ID" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" /> <TextBlock Text="Admin Employee ID" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" />
<TextBox Text="{Binding AdminCardId, UpdateSourceTrigger=PropertyChanged}" <TextBox Text="{Binding AdminCardId, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource ModernTextBoxStyle}" Margin="0,8,0,8" /> Style="{StaticResource ModernTextBoxStyle}" Margin="0,8,0,8" />
<TextBlock Text="Card ID with admin access to settings." <TextBlock Text="Card ID with admin access to settings."
@ -318,10 +324,10 @@
</StackPanel> </StackPanel>
<!-- Button row --> <!-- Button row -->
<Border Grid.Row="2" BorderBrush="{StaticResource BorderBrush}" BorderThickness="0,1,0,0" Padding="32,24" Background="#f9fbfb"> <Border Grid.Row="2" BorderBrush="{StaticResource BorderBrush}" BorderThickness="0,1,0,0" Padding="24,20" Background="#f9fbfb">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" MinWidth="0"/>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<WrapPanel Grid.Column="1" HorizontalAlignment="Right"> <WrapPanel Grid.Column="1" HorizontalAlignment="Right">
@ -339,7 +345,8 @@
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
</StackPanel> </StackPanel>
</Grid>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

BIN
assets/emp-pic/emppic.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB