diff --git a/ACTerm/ACTerm.csproj b/ACTerm/ACTerm.csproj
index 95ceb9e..9a6d6a9 100644
--- a/ACTerm/ACTerm.csproj
+++ b/ACTerm/ACTerm.csproj
@@ -18,4 +18,7 @@
+
+
+
diff --git a/ACTerm/DialogService.cs b/ACTerm/DialogService.cs
new file mode 100644
index 0000000..8b7fdb1
--- /dev/null
+++ b/ACTerm/DialogService.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Threading.Tasks;
+using AutoCatCore.MVVM;
+using Terminal.Gui;
+
+namespace ACTerm
+{
+ class DialogService : IDialogService
+ {
+ public async Task ShowErrorDialogAsync(string message, string title = "Error")
+ {
+ //var ok = new Button("OK");
+ //var text = new Label(message) { X = 1, Y = 1, Width = Dim.Fill() - 1, Height = Dim.Fill() - 1, TextAlignment = TextAlignment.Centered };
+ //var dialog = new Dialog(title, 40, 8, ok);
+ //dialog.Add(text);
+ //ok.Clicked += () => { Application.RequestStop(); };
+ //Application.Run(dialog);
+
+ MessageBox.ErrorQuery(title, message, "OK");
+ }
+ }
+}
diff --git a/ACTerm/Program.cs b/ACTerm/Program.cs
index ff0eacc..0bdb1ef 100644
--- a/ACTerm/Program.cs
+++ b/ACTerm/Program.cs
@@ -1,12 +1,42 @@
using System;
+using Terminal.Gui;
+using ACTerm.Views;
+using System.Threading.Tasks;
+using AutoCatCore.ViewModel;
namespace ACTerm
{
class Program
{
- static void Main(string[] args)
+ static async Task Main(string[] args)
{
- Console.WriteLine("Hello World!");
+ Application.Init();
+
+ var authVM = new AuthViewModel(new DialogService());
+ await authVM.Init();
+
+ if (!authVM.isLoggedIn)
+ {
+ var loginDialog = AuthDialog.CreateNew(authVM);
+ Application.Top.Add(loginDialog);
+ }
+ else
+ {
+ //var mainWindow = new Window("Wnd");
+ //top.Add(mainWindow);
+ var history = new FrameView("History") { X = 0, Y = 0, Width = Dim.Percent(30), Height = Dim.Fill() - 1 };
+ var detail = new FrameView("Vehicle details") { X = Pos.Percent(30), Y = 0, Width = Dim.Percent(70), Height = Dim.Fill() - 1 };
+
+ // Statusbar
+ var about = new StatusItem(Key.F1, "~F1~ - About", () => { });
+ var quit = new StatusItem(Key.ControlQ, "~Ctrl+Q~ - Quit", () => { Application.Shutdown(); });
+ var statusBar = new StatusBar(new[] { about, quit });
+
+ Application.Top.Add(history, detail, statusBar);
+ Application.Top.StatusBar = statusBar;
+ }
+
+ Application.Run();
}
}
}
diff --git a/ACTerm/Views/AuthDialog.cs b/ACTerm/Views/AuthDialog.cs
new file mode 100644
index 0000000..b2c32fd
--- /dev/null
+++ b/ACTerm/Views/AuthDialog.cs
@@ -0,0 +1,44 @@
+using System;
+using AutoCatCore.ViewModel;
+using Terminal.Gui;
+
+namespace ACTerm.Views
+{
+ public class AuthDialog: Dialog
+ {
+ private AuthViewModel viewModel;
+ private TextField emailField;
+ private TextField passwordField;
+
+
+ public AuthDialog(NStack.ustring title, int width, int height, params Button[] buttons): base(title, width, height, buttons)
+ {
+ }
+
+ public static AuthDialog CreateNew(AuthViewModel VM)
+ {
+ var login = new Button("Login");
+ var cancel = new Button("Cancel");
+
+ var loginLabel = new Label("Email:") { X = 1, Y = 2, Width = 10, Height = 1 };
+ var passwordLabel = new Label("Password:") { X = 1, Y = 4, Width = 10, Height = 1 };
+ var dialog = new AuthDialog("AutoCat Login", 60, 10, login, cancel);
+ dialog.emailField = new TextField() { X = 11, Y = 2, Width = Dim.Fill() - 1, Height = 1 };
+ dialog.passwordField = new TextField() { X = 11, Y = 4, Width = Dim.Fill() - 1, Height = 1, Secret = true };
+ dialog.Add(loginLabel, dialog.emailField, passwordLabel, dialog.passwordField);
+
+ dialog.emailField.SetFocus();
+ dialog.viewModel = VM;
+
+ cancel.Clicked += () => { Application.RequestStop(); };
+ login.Clicked += dialog.LoginClicked;
+
+ return dialog;
+ }
+
+ async void LoginClicked()
+ {
+ await viewModel.Login(emailField.Text.ToString(), passwordField.Text.ToString());
+ }
+ }
+}
diff --git a/ACTerm/autocat.db b/ACTerm/autocat.db
deleted file mode 100644
index 7462f41..0000000
Binary files a/ACTerm/autocat.db and /dev/null differ
diff --git a/AutoCatCore/ViewModel/AuthViewModel.cs b/AutoCatCore/ViewModel/AuthViewModel.cs
index 15c6b53..87552ff 100644
--- a/AutoCatCore/ViewModel/AuthViewModel.cs
+++ b/AutoCatCore/ViewModel/AuthViewModel.cs
@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
-namespace AutoCat.ViewModel
+namespace AutoCatCore.ViewModel
{
public class AuthViewModel
{
@@ -23,10 +23,9 @@ namespace AutoCat.ViewModel
public AuthViewModel(IDialogService dialogService)
{
this.dialogService = dialogService;
- Init();
}
- private async void Init()
+ public async Task Init()
{
dbContext = new AutoCatDbContext();
await dbContext.Database.EnsureCreatedAsync();