Skip to content

Commit

Permalink
- Added sample files for online DB connection so that anyone can have…
Browse files Browse the repository at this point in the history
… a look at how the OnlineDataAccessRepository files look like.

- Added an ExitApp functionality from MenuBar (Will tinker it a bit more later)
  • Loading branch information
YBTopaz8 committed Oct 25, 2023
1 parent 31f4e71 commit 72199ec
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/FlowHub.Main/bin/Debug/net7.0-windows10.0.19041.0/win10-x64/FlowHub.Main.dll",
"args": [],
"cwd": "${workspaceFolder}/FlowHub.Main",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/FlowHub-MAUI.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/FlowHub-MAUI.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/FlowHub-MAUI.sln"
],
"problemMatcher": "$msCompile"
}
]
}
2 changes: 1 addition & 1 deletion FlowHub.DataAccess/FlowHub.DataAccess.csproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.2.1" /> <PackageReference Include="CommunityToolkit.Diagnostics" Version="8.2.1" />
<PackageReference Include="LiteDB.Async" Version="0.1.7" /> <PackageReference Include="LiteDB.Async" Version="0.1.7" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" /> <PackageReference Include="MongoDB.Driver" Version="2.22.0" />
</ItemGroup> </ItemGroup>


<ItemGroup> <ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions FlowHub.DataAccess/Platforms/Android/OnlineDataAccessRepository.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace FlowHub.DataAccess;

public class OnlineDataAccessRepository : IOnlineCredentialsRepository
{
public IMongoDatabase OnlineMongoDatabase { get; set; }
public void GetOnlineConnection()
{
if (Connectivity.Current.NetworkAccess.Equals(NetworkAccess.Internet))
{
IMongoDatabase db = new MongoClient("<< YOUR ATLAS CONNECTION STRING >>")
.GetDatabase("<<YOUR DB NAME>>");
OnlineMongoDatabase = db;
}
else
{
_ = Shell.Current.DisplayAlert("No Internet Found!", "Please Connect your devcice to the internet", "OK");
}
}
}
24 changes: 24 additions & 0 deletions FlowHub.DataAccess/Platforms/Windows/OnlineDataAccessRepository.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace FlowHub.DataAccess;

public class OnlineDataAccessRepository : IOnlineCredentialsRepository
{
public IMongoDatabase OnlineMongoDatabase { get; set; }
public void GetOnlineConnection()
{
if (Connectivity.Current.NetworkAccess.Equals(NetworkAccess.Internet))
{
IMongoDatabase db = new MongoClient("<< YOUR ATLAS CONNECTION STRING " +
"YOU CAN FIND IT IN YOUR MONGODB ATLAS" +
"GO TO YOUR DATABSE UNDER DEPLOYMENT" +
"YOU'LL SEE YOUR CLUSTER (OR CREATE ONE IF INEXISTANT)" +
"ON YOUR CLUSTER THERE WILL BE A CONNECT BUTTON, CLICK ON IT AND CLICK DRIVERS" +
"FOR WINDOWS, USE DRIVER : C#/.NET AND VERSION 2.13 or Later!!!!>>")
.GetDatabase("<<YOUR DB NAME>>");
OnlineMongoDatabase = db;
}
else
{
_ = Shell.Current.DisplayAlert("No Internet Found!", "Please Connect your devcice to the internet", "OK");
}
}
}
6 changes: 4 additions & 2 deletions FlowHub.Main/AppShell.xaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Shell.NavBarIsVisible="False" Shell.NavBarIsVisible="False"
Shell.FlyoutBehavior="Disabled" Shell.FlyoutBehavior="Disabled"
CurrentItem ="{x:Reference login}"> CurrentItem ="{x:Reference login}">

<FlyoutItem FlyoutDisplayOptions="AsMultipleItems" <FlyoutItem FlyoutDisplayOptions="AsMultipleItems"
Route="FileTab"> Route="FileTab">


Expand All @@ -23,7 +23,9 @@
Route="HomePageD"/> Route="HomePageD"/>


<ShellContent Title="Log Out"/> <ShellContent Title="Log Out"/>
<ShellContent Title="Exit" /> <ShellContent Title="Exit"
ContentTemplate="{DataTemplate views:ExitApp}"
Route="ExitApp"/>
</Tab> </Tab>


<Tab Title="Flow Outs" Icon="{AppThemeBinding Dark= initiate_money_transfer_d.png,Light= initiate_money_transfer_d.png}"> <Tab Title="Flow Outs" Icon="{AppThemeBinding Dark= initiate_money_transfer_d.png,Light= initiate_money_transfer_d.png}">
Expand Down
2 changes: 2 additions & 0 deletions FlowHub.Main/AppShell.xaml.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public AppShell()
{ {
InitializeComponent(); InitializeComponent();


Routing.RegisterRoute(nameof(ExitApp), typeof(ExitApp));

Routing.RegisterRoute(nameof(HomePageD), typeof(HomePageD)); Routing.RegisterRoute(nameof(HomePageD), typeof(HomePageD));
Routing.RegisterRoute(nameof(LoginD), typeof(LoginD)); Routing.RegisterRoute(nameof(LoginD), typeof(LoginD));


Expand Down
13 changes: 8 additions & 5 deletions FlowHub.Main/FlowHub.Main.csproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="akgul.Maui.DataGrid" Version="3.0.0" /> <PackageReference Include="akgul.Maui.DataGrid" Version="3.0.0" />
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.2.1" /> <PackageReference Include="CommunityToolkit.Diagnostics" Version="8.2.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.3.0" /> <PackageReference Include="CommunityToolkit.Maui" Version="6.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.5" /> <PackageReference Include="HarfBuzzSharp" Version="7.3.0" />
<PackageReference Include="itext7" Version="8.0.1" /> <PackageReference Include="itext7" Version="8.0.1" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.1" /> <PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.1" />
<PackageReference Include="LiteDB.Async" Version="0.1.7" /> <PackageReference Include="LiteDB.Async" Version="0.1.7" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-beta.603" /> <PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-beta.603" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Plugin.Maui.AddToCalendar" Version="1.0.0" /> <PackageReference Include="Plugin.Maui.AddToCalendar" Version="1.0.0" />
<PackageReference Include="SkiaSharp" Version="2.88.5" /> <PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="UraniumUI.Icons.FontAwesome" Version="2.5.5" /> <PackageReference Include="UraniumUI.Icons.FontAwesome" Version="2.5.6" />
<PackageReference Include="UraniumUI.Material" Version="2.5.5" /> <PackageReference Include="UraniumUI.Material" Version="2.5.6" />
</ItemGroup> </ItemGroup>


<ItemGroup> <ItemGroup>
Expand Down Expand Up @@ -183,6 +183,9 @@
<MauiXaml Update="Views\Desktop\Debts\ManageDebtsPageD.xaml"> <MauiXaml Update="Views\Desktop\Debts\ManageDebtsPageD.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\Desktop\ExitApp.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Desktop\Expenditures\ManageExpendituresPageD.xaml"> <MauiXaml Update="Views\Desktop\Expenditures\ManageExpendituresPageD.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
Expand Down
2 changes: 2 additions & 0 deletions FlowHub.Main/MauiProgram.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public static MauiApp CreateMauiApp()
builder.Services.AddSingleton<UpSertDebtVM>(); builder.Services.AddSingleton<UpSertDebtVM>();
/*------------------------REGISTERING DESKTOP VIEWS ----------------------------------------------------------------------------*/ /*------------------------REGISTERING DESKTOP VIEWS ----------------------------------------------------------------------------*/


builder.Services.AddSingleton<ExitApp>();

/*-- Section for HomePage AND Login --*/ /*-- Section for HomePage AND Login --*/
builder.Services.AddSingleton<HomePageD>(); builder.Services.AddSingleton<HomePageD>();
builder.Services.AddSingleton<LoginD>(); builder.Services.AddSingleton<LoginD>();
Expand Down
6 changes: 4 additions & 2 deletions FlowHub.Main/PopUpPages/InputCurrencyForPrintPopUpPage.xaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
<Label x:Name="DisplayAlertText" FontSize="18"/> <Label x:Name="DisplayAlertText" FontSize="18"/>


<HorizontalStackLayout Spacing="8"> <HorizontalStackLayout Spacing="8">
<material:CheckBox Text="Change Currency" x:Name="ChangeCurrencyCheckBox" Margin="5,0" CheckChanged="ChangeCurrencyCheckBox_CheckChanged"/> <material:CheckBox Text="Change Currency" x:Name="ChangeCurrencyCheckBox"
Margin="5,0" CheckChanged="ChangeCurrencyCheckBox_CheckChanged"
TextColor="{AppThemeBinding Dark=White}"/>


<Picker x:Name="CurrencyPicker" Title="Select a Currency" IsVisible="{Binding IsChecked, Source={x:Reference ChangeCurrencyCheckBox}}"/> <Picker x:Name="CurrencyPicker" Title="Select a Currency" IsVisible="{Binding IsChecked, Source={x:Reference ChangeCurrencyCheckBox}}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout HorizontalOptions="EndAndExpand" Spacing="5"> <HorizontalStackLayout HorizontalOptions="EndAndExpand" Spacing="5">
<Button Text="Cancel" FontSize="18" BackgroundColor="Transparent" <Button Text="Cancel" FontSize="18" BackgroundColor="Transparent"
TextColor="{AppThemeBinding Dark={StaticResource NegativeActionBtnDark},Light= {StaticResource NegativeActionBtnDark} }" TextColor="{AppThemeBinding Dark={StaticResource NegativeActionBtnDark},Light= {StaticResource NegativeActionBtnDark} }"
Clicked="OnNoButtonClicked"/> Clicked="OnNoButtonClicked"/>
<Button Text="Yes" FontSize="20" BackgroundColor="Transparent" FontAttributes="Bold" <Button Text="Yes" FontSize="19" BackgroundColor="Transparent" FontAttributes="Bold"
TextColor="{AppThemeBinding Dark={StaticResource Primary},Light= {StaticResource Primary}}" TextColor="{AppThemeBinding Dark={StaticResource Primary},Light= {StaticResource Primary}}"
Clicked="OnYesButtonClicked"/> Clicked="OnYesButtonClicked"/>
</HorizontalStackLayout> </HorizontalStackLayout>
Expand Down
4 changes: 3 additions & 1 deletion FlowHub.Main/ViewModels/Debts/ManageDebtsVM.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public void ApplyChanges()
{ {
var filteredAndSortedDebts = debtRepo.OfflineDebtList var filteredAndSortedDebts = debtRepo.OfflineDebtList
.Where(x => !x.IsDeleted) .Where(x => !x.IsDeleted)
.OrderByDescending(x => x.UpdateDateTime).ToList(); .OrderByDescending(x => x.UpdateDateTime)
.Distinct()
.ToList();


ListOfPeopleNames = filteredAndSortedDebts ListOfPeopleNames = filteredAndSortedDebts
.Select(x => x.PersonOrOrganization.Name) .Select(x => x.PersonOrOrganization.Name)
Expand Down
12 changes: 12 additions & 0 deletions FlowHub.Main/Views/Desktop/ExitApp.xaml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FlowHub.Main.Views.Desktop.ExitApp"
Title="ExitApp">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
30 changes: 30 additions & 0 deletions FlowHub.Main/Views/Desktop/ExitApp.xaml.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace FlowHub.Main.Views.Desktop;

public partial class ExitApp : ContentPage
{
public ExitApp()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();

OnExitAppearing();
}

async void OnExitAppearing()
{
bool result = await DisplayAlert("Confirm Exit", "Do You Want To Exit Application?", "Yes", "No");
//bool result = (bool)await Shell.Current.ShowPopupAsync(new AcceptCancelPopUpAlert("ss"));
if (result)
{
Environment.Exit(0);
}
else
{
await Shell.Current.GoToAsync($"//{nameof(HomePageD)}", true);
Debug.WriteLine("Cancelled Exit");
}
}
}
5 changes: 5 additions & 0 deletions FlowHub.Main/Views/Desktop/HomePageD.xaml.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace FlowHub.Main.Views.Desktop;
[QueryProperty(nameof(StartAction), nameof(StartAction))] [QueryProperty(nameof(StartAction), nameof(StartAction))]
public partial class HomePageD : ContentPage public partial class HomePageD : ContentPage
{ {

int startAction; int startAction;
public int StartAction public int StartAction
{ {
Expand All @@ -20,7 +21,9 @@ public HomePageD(HomePageVM vm)
InitializeComponent(); InitializeComponent();
viewModel = vm; viewModel = vm;
BindingContext = vm; BindingContext = vm;

} }

bool _isInitialized; bool _isInitialized;
protected override async void OnAppearing() protected override async void OnAppearing()
{ {
Expand All @@ -40,4 +43,6 @@ void RunAppStartAction()
MainThread.BeginInvokeOnMainThread(async () => await viewModel.GoToAddExpenditurePage()); MainThread.BeginInvokeOnMainThread(async () => await viewModel.GoToAddExpenditurePage());
} }
} }


} }
2 changes: 1 addition & 1 deletion FlowHub.Main/Views/Mobile/HomePageM.xaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</StackLayout> </StackLayout>


<StackLayout Grid.Column="1" HorizontalOptions="End"> <StackLayout Grid.Column="1" HorizontalOptions="End">
<Label FontAttributes="Bold"> <Label FontAttributes="Bold" HorizontalTextAlignment="End">
<Label.Text> <Label.Text>
<MultiBinding StringFormat="{}{0:n2} {1}"> <MultiBinding StringFormat="{}{0:n2} {1}">
<Binding Path="AmountSpent"/> <Binding Path="AmountSpent"/>
Expand Down
8 changes: 8 additions & 0 deletions FlowHub.Main/Views/Mobile/HomePageM.xaml.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,14 @@
using SkiaSharp;
using SkiaSharp.Views.Maui.Controls;

namespace FlowHub.Main.Views.Mobile; namespace FlowHub.Main.Views.Mobile;


[QueryProperty(nameof(StartAction), nameof(StartAction))] [QueryProperty(nameof(StartAction), nameof(StartAction))]
public partial class HomePageM : ContentPage public partial class HomePageM : ContentPage
{ {
SKCanvasView canvasView;


int startAction; int startAction;
public int StartAction public int StartAction
{ {
Expand Down Expand Up @@ -40,4 +46,6 @@ void RunAppStartAction()
MainThread.BeginInvokeOnMainThread(async () => await viewModel.GoToAddExpenditurePage()); MainThread.BeginInvokeOnMainThread(async () => await viewModel.GoToAddExpenditurePage());
} }
} }


} }
2 changes: 1 addition & 1 deletion FlowHub.Main/Views/UpSertExpendituresPopUp.xaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<HorizontalStackLayout HorizontalOptions="Center" Margin="0,15,0,0" Spacing="15"> <HorizontalStackLayout HorizontalOptions="Center" Margin="0,15,0,0" Spacing="15">
<Button input:FormView.IsSubmitButton="True" <Button input:FormView.IsSubmitButton="True"
Text="Save Flow Out" BackgroundColor="{StaticResource SaveBtnColor}" TextColor="White" Text="Save Flow Out" BackgroundColor="{StaticResource SaveBtnColor}" TextColor="White"
FontSize="20" FontAttributes="Bold"/> FontSize="19" FontAttributes="Bold"/>


<Button Command="{Binding CancelBtnCommand}" <Button Command="{Binding CancelBtnCommand}"
Text="Cancel" BackgroundColor="{StaticResource NegativeActionBtnDark}" TextColor="White" Text="Cancel" BackgroundColor="{StaticResource NegativeActionBtnDark}" TextColor="White"
Expand Down

0 comments on commit 72199ec

Please sign in to comment.