Add initial project structure with basic view models, views, and resources
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using CryptoPortfolio_Tracker.ViewModels;
|
||||
using System;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace CryptoPortfolio_Tracker.Views;
|
||||
|
||||
public partial class MainView : NavigationPage
|
||||
{
|
||||
public static MainView Current { get; set; } = null!;
|
||||
|
||||
private WindowToastManager _toastManager = null!;
|
||||
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
Current = this;
|
||||
}
|
||||
|
||||
protected override async void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
_toastManager = new WindowToastManager(TopLevel.GetTopLevel(this));
|
||||
|
||||
if (CurrentPage == null)
|
||||
await PushAsync(new LoginView()
|
||||
{
|
||||
DataContext = new LoginViewModel()
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowToast(string message, NotificationType type)
|
||||
{
|
||||
_toastManager.Show(
|
||||
content: message,
|
||||
showIcon: true,
|
||||
showClose: true,
|
||||
type: type,
|
||||
expiration: TimeSpan.FromSeconds(3),
|
||||
classes: ["Light"]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user