commit b9e73ec94d541cf55705de3f15870b6c9a97294a Author: adalberto Date: Mon Oct 6 22:45:28 2025 -0600 primer commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..add57be --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/.idea/.idea.SysMe/.idea/.gitignore b/.idea/.idea.SysMe/.idea/.gitignore new file mode 100644 index 0000000..f72e677 --- /dev/null +++ b/.idea/.idea.SysMe/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/contentModel.xml +/.idea.SysMe.iml +/projectSettingsUpdater.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.SysMe/.idea/encodings.xml b/.idea/.idea.SysMe/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.SysMe/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.SysMe/.idea/indexLayout.xml b/.idea/.idea.SysMe/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.SysMe/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..1a64aca --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,23 @@ + + + + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SysMe.Android/Icon.png b/SysMe.Android/Icon.png new file mode 100644 index 0000000..3c39845 Binary files /dev/null and b/SysMe.Android/Icon.png differ diff --git a/SysMe.Android/MainActivity.cs b/SysMe.Android/MainActivity.cs new file mode 100644 index 0000000..3e4f95e --- /dev/null +++ b/SysMe.Android/MainActivity.cs @@ -0,0 +1,21 @@ +using Android.App; +using Android.Content.PM; +using Avalonia; +using Avalonia.Android; + +namespace SysMe.Android; + +[Activity( + Label = "SysMe.Android", + Theme = "@style/MyTheme.NoActionBar", + Icon = "@drawable/icon", + MainLauncher = true, + ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)] +public class MainActivity : AvaloniaMainActivity +{ + protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) + { + return base.CustomizeAppBuilder(builder) + .WithInterFont(); + } +} \ No newline at end of file diff --git a/SysMe.Android/Properties/AndroidManifest.xml b/SysMe.Android/Properties/AndroidManifest.xml new file mode 100644 index 0000000..7853530 --- /dev/null +++ b/SysMe.Android/Properties/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/SysMe.Android/Resources/AboutResources.txt b/SysMe.Android/Resources/AboutResources.txt new file mode 100644 index 0000000..c2bca97 --- /dev/null +++ b/SysMe.Android/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/SysMe.Android/Resources/drawable-night-v31/avalonia_anim.xml b/SysMe.Android/Resources/drawable-night-v31/avalonia_anim.xml new file mode 100644 index 0000000..dde4b5a --- /dev/null +++ b/SysMe.Android/Resources/drawable-night-v31/avalonia_anim.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SysMe.Android/Resources/drawable-v31/avalonia_anim.xml b/SysMe.Android/Resources/drawable-v31/avalonia_anim.xml new file mode 100644 index 0000000..94f27d9 --- /dev/null +++ b/SysMe.Android/Resources/drawable-v31/avalonia_anim.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SysMe.Android/Resources/drawable/splash_screen.xml b/SysMe.Android/Resources/drawable/splash_screen.xml new file mode 100644 index 0000000..2e920b4 --- /dev/null +++ b/SysMe.Android/Resources/drawable/splash_screen.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/SysMe.Android/Resources/values-night/colors.xml b/SysMe.Android/Resources/values-night/colors.xml new file mode 100644 index 0000000..3d47b6f --- /dev/null +++ b/SysMe.Android/Resources/values-night/colors.xml @@ -0,0 +1,4 @@ + + + #212121 + diff --git a/SysMe.Android/Resources/values-v31/styles.xml b/SysMe.Android/Resources/values-v31/styles.xml new file mode 100644 index 0000000..d5ecec4 --- /dev/null +++ b/SysMe.Android/Resources/values-v31/styles.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/SysMe.Android/Resources/values/colors.xml b/SysMe.Android/Resources/values/colors.xml new file mode 100644 index 0000000..59279d5 --- /dev/null +++ b/SysMe.Android/Resources/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + diff --git a/SysMe.Android/Resources/values/styles.xml b/SysMe.Android/Resources/values/styles.xml new file mode 100644 index 0000000..6e534de --- /dev/null +++ b/SysMe.Android/Resources/values/styles.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/SysMe.Android/SysMe.Android.csproj b/SysMe.Android/SysMe.Android.csproj new file mode 100644 index 0000000..1015325 --- /dev/null +++ b/SysMe.Android/SysMe.Android.csproj @@ -0,0 +1,39 @@ + + + Exe + net9.0-android + 21 + enable + com.CompanyName.SysMe + 1 + 1.0 + apk + false + + + armeabi-v7a;x86;arm64-v8a;x86_64 + AnyCPU + false + + + armeabi-v7a;x86;arm64-v8a;x86_64 + AnyCPU + false + full + + + + + Resources\drawable\Icon.png + + + + + + + + + + + + diff --git a/SysMe.Browser/Program.cs b/SysMe.Browser/Program.cs new file mode 100644 index 0000000..b4eb6f1 --- /dev/null +++ b/SysMe.Browser/Program.cs @@ -0,0 +1,15 @@ +using System.Runtime.Versioning; +using System.Threading.Tasks; +using Avalonia; +using Avalonia.Browser; +using SysMe; + +internal sealed partial class Program +{ + private static Task Main(string[] args) => BuildAvaloniaApp() + .WithInterFont() + .StartBrowserAppAsync("out"); + + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure(); +} \ No newline at end of file diff --git a/SysMe.Browser/Properties/AssemblyInfo.cs b/SysMe.Browser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f31aed8 --- /dev/null +++ b/SysMe.Browser/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")] \ No newline at end of file diff --git a/SysMe.Browser/Properties/launchSettings.json b/SysMe.Browser/Properties/launchSettings.json new file mode 100644 index 0000000..15c5b22 --- /dev/null +++ b/SysMe.Browser/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "SysMe.Browser": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:7169;http://localhost:5235", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}" + } + } +} diff --git a/SysMe.Browser/SysMe.Browser.csproj b/SysMe.Browser/SysMe.Browser.csproj new file mode 100644 index 0000000..41cfc7b --- /dev/null +++ b/SysMe.Browser/SysMe.Browser.csproj @@ -0,0 +1,16 @@ + + + net9.0-browser + Exe + true + enable + + + + + + + + + + diff --git a/SysMe.Browser/runtimeconfig.template.json b/SysMe.Browser/runtimeconfig.template.json new file mode 100644 index 0000000..b96a943 --- /dev/null +++ b/SysMe.Browser/runtimeconfig.template.json @@ -0,0 +1,10 @@ +{ + "wasmHostProperties": { + "perHostConfig": [ + { + "name": "browser", + "host": "browser" + } + ] + } +} \ No newline at end of file diff --git a/SysMe.Browser/wwwroot/app.css b/SysMe.Browser/wwwroot/app.css new file mode 100644 index 0000000..1d6f754 --- /dev/null +++ b/SysMe.Browser/wwwroot/app.css @@ -0,0 +1,58 @@ +/* HTML styles for the splash screen */ +.avalonia-splash { + position: absolute; + height: 100%; + width: 100%; + background: white; + font-family: 'Outfit', sans-serif; + justify-content: center; + align-items: center; + display: flex; + pointer-events: none; +} + +/* Light theme styles */ +@media (prefers-color-scheme: light) { + .avalonia-splash { + background: white; + } + + .avalonia-splash h2 { + color: #1b2a4e; + } + + .avalonia-splash a { + color: #0D6EFD; + } +} + +@media (prefers-color-scheme: dark) { + .avalonia-splash { + background: #1b2a4e; + } + + .avalonia-splash h2 { + color: white; + } + + .avalonia-splash a { + color: white; + } +} + +.avalonia-splash h2 { + font-weight: 400; + font-size: 1.5rem; +} + +.avalonia-splash a { + text-decoration: none; + font-size: 2.5rem; + display: block; +} + +.avalonia-splash.splash-close { + transition: opacity 200ms, display 200ms; + display: none; + opacity: 0; +} diff --git a/SysMe.Browser/wwwroot/favicon.ico b/SysMe.Browser/wwwroot/favicon.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/SysMe.Browser/wwwroot/favicon.ico differ diff --git a/SysMe.Browser/wwwroot/index.html b/SysMe.Browser/wwwroot/index.html new file mode 100644 index 0000000..1701c42 --- /dev/null +++ b/SysMe.Browser/wwwroot/index.html @@ -0,0 +1,36 @@ + + + + + SysMe.Browser + + + + + + +
+
+

+ Powered by + + + + + + + + + + + + + + +

+
+
+ + + + diff --git a/SysMe.Browser/wwwroot/main.js b/SysMe.Browser/wwwroot/main.js new file mode 100644 index 0000000..bf1555e --- /dev/null +++ b/SysMe.Browser/wwwroot/main.js @@ -0,0 +1,13 @@ +import { dotnet } from './_framework/dotnet.js' + +const is_browser = typeof window != "undefined"; +if (!is_browser) throw new Error(`Expected to be running in a browser`); + +const dotnetRuntime = await dotnet + .withDiagnosticTracing(false) + .withApplicationArgumentsFromQuery() + .create(); + +const config = dotnetRuntime.getConfig(); + +await dotnetRuntime.runMain(config.mainAssemblyName, [globalThis.location.href]); diff --git a/SysMe.Desktop/Program.cs b/SysMe.Desktop/Program.cs new file mode 100644 index 0000000..a7dd45f --- /dev/null +++ b/SysMe.Desktop/Program.cs @@ -0,0 +1,21 @@ +using System; +using Avalonia; + +namespace SysMe.Desktop; + +sealed class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} \ No newline at end of file diff --git a/SysMe.Desktop/SysMe.Desktop.csproj b/SysMe.Desktop/SysMe.Desktop.csproj new file mode 100644 index 0000000..d184c11 --- /dev/null +++ b/SysMe.Desktop/SysMe.Desktop.csproj @@ -0,0 +1,27 @@ + + + WinExe + + net9.0 + enable + true + + + + app.manifest + + + + + + + None + All + + + + + + + diff --git a/SysMe.Desktop/app.manifest b/SysMe.Desktop/app.manifest new file mode 100644 index 0000000..9b688cb --- /dev/null +++ b/SysMe.Desktop/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/SysMe.sln b/SysMe.sln new file mode 100644 index 0000000..4d03a61 --- /dev/null +++ b/SysMe.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32811.315 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysMe", "SysMe\SysMe.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysMe.Desktop", "SysMe.Desktop\SysMe.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysMe.Browser", "SysMe.Browser\SysMe.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysMe.Android", "SysMe.Android\SysMe.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DA99C4E-89E3-4049-9C22-0A7EC60D83D8}" + ProjectSection(SolutionItems) = preProject + Directory.Packages.props = Directory.Packages.props + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Release|Any CPU.Build.0 = Release|Any CPU + {ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Release|Any CPU.Build.0 = Release|Any CPU + {1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Release|Any CPU.Build.0 = Release|Any CPU + {7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {83CB65B8-011F-4ED7-BCD3-A6CFA935EF7E} + EndGlobalSection +EndGlobal diff --git a/SysMe/App.axaml b/SysMe/App.axaml new file mode 100644 index 0000000..591376c --- /dev/null +++ b/SysMe/App.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SysMe/App.axaml.cs b/SysMe/App.axaml.cs new file mode 100644 index 0000000..6d85b75 --- /dev/null +++ b/SysMe/App.axaml.cs @@ -0,0 +1,53 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Data.Core.Plugins; +using System.Linq; +using Avalonia.Markup.Xaml; +using SysMe.ViewModels; +using SysMe.Views; + +namespace SysMe; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + // Avoid duplicate validations from both Avalonia and the CommunityToolkit. + // More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins + DisableAvaloniaDataAnnotationValidation(); + desktop.MainWindow = new LoginWindow() + { + DataContext = new LoginViewModel() + }; + } + else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform) + { + singleViewPlatform.MainView = new LoginView() + { + DataContext = new LoginViewModel() + }; + } + + base.OnFrameworkInitializationCompleted(); + } + + private void DisableAvaloniaDataAnnotationValidation() + { + // Get an array of plugins to remove + var dataValidationPluginsToRemove = + BindingPlugins.DataValidators.OfType().ToArray(); + + // remove each entry found + foreach (var plugin in dataValidationPluginsToRemove) + { + BindingPlugins.DataValidators.Remove(plugin); + } + } +} \ No newline at end of file diff --git a/SysMe/Assets/avalonia-logo.ico b/SysMe/Assets/avalonia-logo.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/SysMe/Assets/avalonia-logo.ico differ diff --git a/SysMe/Service/INavigationService.cs b/SysMe/Service/INavigationService.cs new file mode 100644 index 0000000..f064702 --- /dev/null +++ b/SysMe/Service/INavigationService.cs @@ -0,0 +1,11 @@ +namespace SysMe.Service; + +using ViewModels.Base; + +public interface INavigationService +{ + void NavigateTo() where TViewModel : ViewModelBase; + void NavigateTo(object parameter) where TViewModel : ViewModelBase; + void GoBack(); + void SetMainView(object view); +} \ No newline at end of file diff --git a/SysMe/Service/NavigationService.cs b/SysMe/Service/NavigationService.cs new file mode 100644 index 0000000..9de3c15 --- /dev/null +++ b/SysMe/Service/NavigationService.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using SysMe.ViewModels; +using SysMe.ViewModels.Base; +using SysMe.Views; + +namespace SysMe.Service; + +public class NavigationService +{ + private readonly Stack _navigationStack = new(); + + public void NavigateTo() where TViewModel : ViewModelBase + { + NavigateTo(null); + } + + public void NavigateTo(object parameter) where TViewModel : ViewModelBase + { + var viewModel = CreateViewModel(); + + if (viewModel != null) + { + // Navegar según la plataforma + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + NavigateDesktop(desktop, viewModel); + } + else if (Application.Current?.ApplicationLifetime is ISingleViewApplicationLifetime singleView) + { + NavigateSingleView(singleView, viewModel); + } + } + } + + public void GoBack() + { + if (_navigationStack.Count > 1) + { + _navigationStack.Pop(); + var previousViewModel = _navigationStack.Peek(); + + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + NavigateDesktop(desktop, previousViewModel); + } + else if (Application.Current?.ApplicationLifetime is ISingleViewApplicationLifetime singleView) + { + NavigateSingleView(singleView, previousViewModel); + } + } + } + + public void SetMainView(object view) + { + if (Application.Current?.ApplicationLifetime is ISingleViewApplicationLifetime singleView) + { + singleView.MainView = (Control)view; + } + } + + private void NavigateDesktop(IClassicDesktopStyleApplicationLifetime desktop, ViewModelBase viewModel) + { + var viewType = viewModel.GetType(); + + if (viewType == typeof(LoginViewModel)) + { + var loginWindow = new LoginWindow(); + desktop.MainWindow = loginWindow; + loginWindow.Show(); + + // Cerrar MainWindow si existe + var mainWindow = desktop.Windows.OfType().FirstOrDefault(); + mainWindow?.Close(); + } + else if (viewType == typeof(MainViewModel)) + { + var mainWindow = new MainWindow(); + desktop.MainWindow = mainWindow; + mainWindow.Show(); + + // Cerrar LoginWindow si existe + var loginWindow = desktop.Windows.OfType().FirstOrDefault(); + loginWindow?.Close(); + } + } + + private void NavigateSingleView(ISingleViewApplicationLifetime singleView, ViewModelBase viewModel) + { + var view = CreateViewForViewModel(viewModel); + if (view is Control control) + { + singleView.MainView = control; + } + } + + private static ViewModelBase? CreateViewModel() where TViewModel : ViewModelBase + { + return Activator.CreateInstance(); + } + + private static object CreateViewForViewModel(ViewModelBase viewModel) + { + return viewModel switch + { + LoginViewModel => new LoginView { DataContext = viewModel }, + MainViewModel => new MainView { DataContext = viewModel }, + DashboardViewModel => new DashboardView{ DataContext = viewModel }, + _ => throw new ArgumentException($"No view defined for {viewModel.GetType().Name}") + }; + } +} \ No newline at end of file diff --git a/SysMe/SysMe.csproj b/SysMe/SysMe.csproj new file mode 100644 index 0000000..e93f1a8 --- /dev/null +++ b/SysMe/SysMe.csproj @@ -0,0 +1,32 @@ + + + net9.0 + enable + latest + true + + + + + + + + + + + + + + None + All + + + + + + + + + + + diff --git a/SysMe/ViewLocator.cs b/SysMe/ViewLocator.cs new file mode 100644 index 0000000..f9e6131 --- /dev/null +++ b/SysMe/ViewLocator.cs @@ -0,0 +1,31 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using SysMe.ViewModels; +using SysMe.ViewModels.Base; + +namespace SysMe; + +public class ViewLocator : IDataTemplate +{ + public Control? Build(object? param) + { + if (param is null) + return null; + + var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object? data) + { + return data is ViewModelBase; + } +} \ No newline at end of file diff --git a/SysMe/ViewModels/Base/ViewModelBase.cs b/SysMe/ViewModels/Base/ViewModelBase.cs new file mode 100644 index 0000000..21cdb36 --- /dev/null +++ b/SysMe/ViewModels/Base/ViewModelBase.cs @@ -0,0 +1,33 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SysMe.Service; + +namespace SysMe.ViewModels.Base; + +public partial class ViewModelBase : ObservableObject +{ + protected readonly NavigationService NavigationService; + + public ViewModelBase() + { + NavigationService = new NavigationService(); + } + + [RelayCommand] + protected virtual void NavigateToMain() + { + NavigationService.NavigateTo(); + } + + [RelayCommand] + protected virtual void NavigateToLogin() + { + NavigationService.NavigateTo(); + } + + [RelayCommand] + protected virtual void GoBack() + { + NavigationService.GoBack(); + } +} \ No newline at end of file diff --git a/SysMe/ViewModels/DashboardViewModel.cs b/SysMe/ViewModels/DashboardViewModel.cs new file mode 100644 index 0000000..4ae9906 --- /dev/null +++ b/SysMe/ViewModels/DashboardViewModel.cs @@ -0,0 +1,71 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SysMe.ViewModels.Base; + +namespace SysMe.ViewModels; + +public partial class DashboardViewModel : ViewModelBase +{ + // Propiedades para los cards de resumen + [ObservableProperty] + private int activeChildrenCount = 45; + + [ObservableProperty] + private int presentTodayCount = 38; + + [ObservableProperty] + private string weeklyAverage = "85%"; + + [ObservableProperty] + private int totalExpedientsCount = 52; + + public DashboardViewModel() + { + RecentExpedients = new ObservableCollection() + { + new RecentExpedient { ChildName = "María González", LastUpdate = "Actualizado hace 2 horas" }, + new RecentExpedient { ChildName = "Carlos Rodríguez", LastUpdate = "Actualizado hace 4 horas" }, + new RecentExpedient { ChildName = "Ana Martínez", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Luis Hernández", LastUpdate = "Actualizado hace 1 día" }, + new RecentExpedient { ChildName = "Sofía López", LastUpdate = "Actualizado hace 2 días" } + }; + } + + // Lista de expedientes recientes - SIN [ObservableProperty] + public ObservableCollection RecentExpedients { get; } + + // Comandos de navegación + [RelayCommand] + private void NavigateToHome() + { + // Lógica para navegar a Inicio + } + + [RelayCommand] + private void NavigateToExpedients() + { + // Lógica para navegar a Expedientes + } + + [RelayCommand] + private void NavigateToAttendance() + { + // Lógica para navegar a Asistencia + } +} + +public partial class RecentExpedient : ObservableObject +{ + [ObservableProperty] + private string childName = string.Empty; + + [ObservableProperty] + private string lastUpdate = string.Empty; +} \ No newline at end of file diff --git a/SysMe/ViewModels/LoginViewModel.cs b/SysMe/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..35340e1 --- /dev/null +++ b/SysMe/ViewModels/LoginViewModel.cs @@ -0,0 +1,43 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SysMe.ViewModels.Base; + +namespace SysMe.ViewModels; + +public partial class LoginViewModel : ViewModelBase +{ + [ObservableProperty] + private string _username = string.Empty; + + [ObservableProperty] + private string _password = string.Empty; + + [ObservableProperty] + private string _message = string.Empty; + + [ObservableProperty] + private bool _hasMessage; + + [RelayCommand] + private void Login() + { + if (string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password)) + { + Message = "Por favor ingrese usuario y contraseña."; + return; + } + + // Lógica de autenticación aquí + if (Username == "admin" && Password == "123") + { + Message = "Login exitoso!"; + NavigateToMain(); + } + else + { + Message = "Credenciales incorrectas."; + } + + HasMessage = !string.IsNullOrEmpty(Message); + } +} \ No newline at end of file diff --git a/SysMe/ViewModels/MainViewModel.cs b/SysMe/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..c781916 --- /dev/null +++ b/SysMe/ViewModels/MainViewModel.cs @@ -0,0 +1,17 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using SysMe.ViewModels.Base; +namespace SysMe.ViewModels; + +public partial class MainViewModel : ViewModelBase +{ + [ObservableProperty] + private string _welcomeMessage = "Bienvenido al Sistema"; + + [ObservableProperty] + private string _currentUser = "Usuario"; + + public MainViewModel() + { + // Inicialización específica del Main + } +} \ No newline at end of file diff --git a/SysMe/Views/DashboardView.axaml b/SysMe/Views/DashboardView.axaml new file mode 100644 index 0000000..912e6c6 --- /dev/null +++ b/SysMe/Views/DashboardView.axaml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + +