Skip to content

Commit

Permalink
Added launch flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
nerocui committed Jun 6, 2024
1 parent 116d458 commit b282b3d
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 15 deletions.
2 changes: 1 addition & 1 deletion JitHub.Data.InMemoryCache/InMemoryCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using JitHub.Services.GitHub;
using JitHub.Services.Interfaces;

namespace JitHub.Data.Caching;

Expand Down
2 changes: 1 addition & 1 deletion JitHub.Data.InMemoryCache/JitHub.Data.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\JitHub.Services.GitHubService\JitHub.Services.GitHub.csproj" />
<ProjectReference Include="..\JitHub.Services.Interfaces\JitHub.Services.Interfaces.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions JitHub.Services.Accounts/LocalAccountsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public LocalAccountService(ISettingsService settingsService, INavigationService
{
_settingsService = settingsService;
_navigationService = navigationService;
_passwordVault = new PasswordVault();
Authenticated = CheckAuth(GetUser());
}

Expand Down
14 changes: 7 additions & 7 deletions JitHub.Services.Common/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using JitHub.Services.Interfaces;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JitHub.Services.Common;

public class NavigationService : INavigationService
{
public void GoHome()
private Frame _rootFrame;

public void Init(Frame rootFrame)
{
throw new NotImplementedException();
_rootFrame = rootFrame;
}

public void NavigateTo(string title, Type page)
{
throw new NotImplementedException();
// TODO: do something with the title
_rootFrame.Navigate(page);
}

public void NavigateTo(string title, Type page, object parameter)
Expand Down
1 change: 0 additions & 1 deletion JitHub.Services.Interfaces/INavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public interface INavigationService
public void Unauthorized();
public void NavigateTo(string title, Type page);
public void NavigateTo(string title, Type page, object parameter);
public void GoHome();
public void RepoNagivateTo(Type page);
public void RepoNagivateTo(Type page, object parameter);
}
10 changes: 7 additions & 3 deletions JitHub/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ABI.System;
using JitHub.Pages;
using JitHub.Services.Accounts;
using JitHub.Services.AI;
using JitHub.Services.Common;
Expand Down Expand Up @@ -64,6 +65,9 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
m_window = new MainWindow();
}
m_window.Activate();
var navigationService = ServiceProvider.GetService<INavigationService>();
((NavigationService)navigationService).Init(((MainWindow)m_window).GetRootFrame());

var authenticated = false;
var activatedEventArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
if (activatedEventArgs.Kind == ExtendedActivationKind.Protocol && activatedEventArgs.Data is ProtocolActivatedEventArgs protocolArgs)
Expand All @@ -89,12 +93,12 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar

if (authenticated)
{
var navigationService = ServiceProvider.GetService<INavigationService>();
navigationService.GoHome();

navigationService.NavigateTo("Home", typeof(ShellPage));
}
else
{
// go to login page
navigationService.NavigateTo("Login", typeof(LoginPage));
}
}

Expand Down
6 changes: 6 additions & 0 deletions JitHub/JitHub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Remove="Pages\LoginPage.xaml" />
<None Remove="Pages\ShellPage.xaml" />
</ItemGroup>

Expand Down Expand Up @@ -80,6 +81,11 @@
<ProjectReference Include="..\JitHub.Services.GitHubService\JitHub.Services.GitHub.csproj" />
<ProjectReference Include="..\JitHub.Services.Interfaces\JitHub.Services.Interfaces.csproj" />
</ItemGroup>
<ItemGroup>
<Page Update="Pages\LoginPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\ShellPage.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
2 changes: 1 addition & 1 deletion JitHub/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Frame x:Name="ShellFrame"/>
<Frame x:Name="RootFrame"/>
</winex:WindowEx>
8 changes: 7 additions & 1 deletion JitHub/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using JitHub.Pages;
using Microsoft.UI.Xaml.Controls;

namespace JitHub;

Expand All @@ -7,6 +8,11 @@ public sealed partial class MainWindow : WinUIEx.WindowEx
public MainWindow()
{
this.InitializeComponent();
ShellFrame.Navigate(typeof(ShellPage));
RootFrame.Navigate(typeof(ShellPage));
}

public Frame GetRootFrame()
{
return RootFrame;
}
}
15 changes: 15 additions & 0 deletions JitHub/Pages/LoginPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="JitHub.Pages.LoginPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:JitHub.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<TextBlock Text="Login"/>
</Grid>
</Page>
31 changes: 31 additions & 0 deletions JitHub/Pages/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace JitHub.Pages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class LoginPage : Page
{
public LoginPage()
{
this.InitializeComponent();
}
}
}

0 comments on commit b282b3d

Please sign in to comment.