Skip to content
Permalink
Browse files
codes -expense tracker application
  • Loading branch information
doryumusharon committed Nov 18, 2020
1 parent ab95cdf commit 0d3eadff1d7864449c0f6be333908b57d457903e
Show file tree
Hide file tree
Showing 26 changed files with 566 additions and 44 deletions.
@@ -63,6 +63,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Xam.Plugins.Forms.ImageCircle">
<Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.1141" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
</ItemGroup>
@@ -132,6 +132,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="Xam.Plugins.Forms.ImageCircle">
<Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.1141" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
</ItemGroup>
@@ -14,17 +14,17 @@ namespace ExpenseTracker
InitializeComponent();


/* if (!string.IsNullOrEmpty(Preferences.Get("MyFirebaseRefreshToken", "")))
/*if (!string.IsNullOrEmpty(Preferences.Get("MyFirebaseRefreshToken", "")))
{
MainPage = new NavigationPage(new Home());
}
else
{
MainPage = new NavigationPage(new LoginPage());
}*/
MainPage = new NavigationPage(new LoginPage());
// MainPage = new NavigationPage(new LoginPage());

// MainPage = new LoginPage();
MainPage = new HomePage();
//MainPage = Navigat new LoginPage();
//MainPage = new MainPage();
}
@@ -14,11 +14,15 @@
<PackageReference Include="FirebaseAuthentication.net" Version="3.4.0" />
<PackageReference Include="FirebaseDatabase.net" Version="4.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Xam.Plugins.Forms.ImageCircle" Version="3.0.0.5" />
<PackageReference Include="Xamarin.Forms" Version="4.6.0.1141" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="views\auth\ChangePassword.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\auth\LoginPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
@@ -31,5 +35,23 @@
<EmbeddedResource Update="views\home\Home.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\home\HomePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\home\HomePageDetail.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\home\HomePageMaster.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\pages\CategoryPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\pages\ExpenseDetailsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="views\pages\ExpensePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ExpenseTracker.model
{
class CatergoryAmount
{

public int id { get; set; }
public double amount { get; set; }
public string categoryName { get; set; }
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ExpenseTracker.model
{
class SideDrawerMenu
{

public string Title { get; set; }
public string Icon { get; set; }
public Type TargetType { get; set; }
}
}
@@ -27,7 +27,7 @@ namespace ExpenseTracker.viewModel
id=item.Object.id,


}).ToList();
}).Reverse().ToList();
}

public async Task AddExpense(double amount, string narration, int expenseCategory, string id)
@@ -89,12 +89,9 @@ namespace ExpenseTracker.viewModel
.Child("Category")
.OnceAsync<ExpenseCategory>()).Select(item => new ExpenseCategory
{


id = item.Object.id,
name= item.Object.name,


}).ToList();
}

@@ -143,6 +140,57 @@ namespace ExpenseTracker.viewModel
await firebase.Child("Category").Child(toDeletePerson.Key).DeleteAsync();

}

//Queries


//getting total amount of expenses
public async Task<double> GetTotalAmountOfExpense()
{
double totalAmount=0.0;
var allExpense = await GetAllExpense();
for (int i= 0; i< allExpense.Count;i++)
{
totalAmount += allExpense[i].amount;

}

return totalAmount;
}


//get total amount spent on each category
public async Task<List<CatergoryAmount>> GetTotalAmountOfExpensePerCategory()
{
List<CatergoryAmount> categoryAmount = new List<CatergoryAmount>();
var allCategories = await GetAllCategory();
var allExpense = await GetAllExpense();
for (int i = 0; i <= allCategories.Count; i++)
{
double amount = 0;
var currentCategory = allCategories[i];
for (int j = 0; j <= allExpense.Count; j++)
{

var currentExpenses = allExpense[j];
if (currentCategory.id==currentExpenses.expenseCategory)
{
amount += currentExpenses.amount;
}

}
categoryAmount.Add(new CatergoryAmount
{
amount = amount,
id = currentCategory.id,
categoryName=currentCategory.name,
});

}

return categoryAmount;
}

}
}

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ExpenseTracker.views.auth.ChangePassword">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace ExpenseTracker.views.auth
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ChangePassword : ContentPage
{
public ChangePassword()
{
InitializeComponent();
}
}
}
@@ -8,7 +8,7 @@
<StackLayout Margin="20" VerticalOptions="CenterAndExpand" Spacing="20" Orientation="Vertical">
<BoxView HeightRequest="1" HorizontalOptions="FillAndExpand" BackgroundColor="White"/>
<Entry Placeholder="User Email" x:Name="UserLoginEmail"></Entry>
<Entry Placeholder="User Password" x:Name="UserLoginPassword"></Entry>
<Entry Placeholder="User Password" IsPassword="true" x:Name="UserLoginPassword"></Entry>
<Button BackgroundColor="Purple" Clicked="loginbutton_Clicked" TextColor="White" Text="Login" x:Name="loginbutton"/>
<Button
Grid.Row="1" Grid.Column="0"
@@ -5,7 +5,7 @@

<StackLayout Margin="20" VerticalOptions="CenterAndExpand" Spacing="20" Orientation="Vertical">
<Entry Placeholder="User New Email" x:Name="UserNewEmail"></Entry>
<Entry Placeholder="User New Password" x:Name="UserNewPassword"></Entry>
<Entry Placeholder="User New Password" IsPassword="true" x:Name="UserNewPassword"></Entry>
<Button BackgroundColor="Purple" TextColor="White" Text="Signup" Clicked="signupbutton_Clicked" x:Name="signupbutton"/>
<Button
Grid.Row="1" Grid.Column="0"
@@ -20,17 +20,18 @@
<Image Source="overlay.png" Aspect="Fill" HeightRequest="300" VerticalOptions="StartAndExpand"/>
<StackLayout Orientation="Horizontal" Spacing="20" HorizontalOptions="Start" VerticalOptions="Start" Margin="20,50">
<ImageButton Source="menu.png" WidthRequest="23" HeightRequest="15" HorizontalOptions="Start" VerticalOptions="Center" />
<Label Text="LONDON, GB" FontSize="16" VerticalOptions="Center" TextColor="White"/>

</StackLayout>

<StackLayout Orientation="Vertical" Margin="0,20" HorizontalOptions="Center" VerticalOptions="Center">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Image Source="weather.png" WidthRequest="50" HeightRequest="50" VerticalOptions="Center"/>
<Label Text="12" TextColor="White" FontSize="70" FontAttributes="Bold" VerticalOptions="Center"/>
<Label Text="°C" TextColor="White" FontSize="34" VerticalOptions="Center"/>
<!--<Image Source="weather.png" WidthRequest="50" HeightRequest="50" VerticalOptions="Center"/>-->
<Label Text="GHC" TextColor="White" FontSize="20" VerticalOptions="Center"/>
<Label Text="0.00" x:Name="totalAmount" TextColor="White" FontSize="70" FontAttributes="Bold" VerticalOptions="Center"/>

</StackLayout>
<Label Text="Light intensity drizzle rain" TextColor="White" FontSize="16" HorizontalOptions="Center"/>
<Label Text="June 15, 09:03 AM" TextColor="White" FontSize="12" HorizontalOptions="Center"/>
<Label Text="Total Expenses" TextColor="White" FontSize="25" HorizontalOptions="Center"/>
<Label x:Name="currentTime" Text="June 15, 09:03 AM" TextColor="White" FontSize="12" HorizontalOptions="Center"/>
</StackLayout>
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand">
<Grid.ColumnDefinitions>
@@ -94,9 +95,12 @@
<ContentView x:Name="popupLoginView" BackgroundColor="#C0808080" Padding="10, 0" IsVisible="false" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<StackLayout Orientation="Vertical" HeightRequest="250" WidthRequest="300" BackgroundColor="White">
<Entry x:Name="amt" Margin="20,20,20,10" Placeholder="Amount"></Entry>
<Entry x:Name="amt" Keyboard="Numeric" Margin="20,20,20,10" Placeholder="Amount"></Entry>
<Label Margin="20,0,20,0" x:Name="AmountError" TextColor="Red" IsVisible="false"/>
<Entry x:Name="narration" Margin="20,0,20,0" Placeholder="Narration"></Entry>
<Picker Margin="20,0,20,0" ItemDisplayBinding="{Binding name}" x:Name="CategoryEntry" Title="Select Caegory"></Picker>
<Label Margin="20,0,20,0" x:Name="NarationError" TextColor="Red" IsVisible="false"/>
<Picker Margin="20,0,20,0" ItemDisplayBinding="{Binding name}" x:Name="CategoryEntry" Title="Select Category"></Picker>
<Label Margin="20,0,20,0" x:Name="CategoryError" TextColor="Red" IsVisible="false"/>
<Button Margin="20,0,20,0" Text="Add Expense" Clicked="BtnAddExpense"/>
</StackLayout>
</StackLayout>
@@ -106,35 +110,36 @@

<!--Popup Area Add Expense-->

<ContentView x:Name="popupCategoryView" BackgroundColor="#C0808080" Padding="10, 0" IsVisible="false" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
<ContentView x:Name="popupCategoryView" BackgroundColor="#C0808080" Padding="30, 20" IsVisible="false" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<StackLayout Orientation="Vertical" HeightRequest="250" WidthRequest="300" BackgroundColor="White">
<Entry x:Name="id" Margin="20,20,20,10" Placeholder="ID"></Entry>
<StackLayout Orientation="Vertical" Padding="0, 40" HeightRequest="100" WidthRequest="300" BackgroundColor="White">

<Entry x:Name="name" Margin="20,0,20,0" Placeholder="Name"></Entry>

<Button Margin="20,0,20,0" Text="Add Category" Clicked="BtnAddCategory"/>
<Label Margin="20,0,20,0" x:Name="CategoryNameError" TextColor="Red" IsVisible="false"/>
<Button Margin="20,0,20,0" BackgroundColor="Purple" TextColor="White" Text="Add Category" Clicked="BtnAddCategory"/>
</StackLayout>
</StackLayout>
</ContentView>
<!--End Popup -->
<ListView x:Name="WeatherForecastList" ItemsSource="{Binding Weathers}" SeparatorVisibility="None"

<ListView x:Name="AllExpense" ItemsSource="{Binding Weathers}" SeparatorVisibility="None"
Grid.Row="3" Margin="20,0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<Frame BackgroundColor="White" BorderColor="#F0F0F0" Padding="5" Margin="0,0,0,5" HasShadow="False">
<Grid HeightRequest="50" HorizontalOptions="FillAndExpand" VerticalOptions="Start">
<Grid HeightRequest="70" HorizontalOptions="FillAndExpand" VerticalOptions="Start">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Date}" TextColor="#757575" FontSize="12" VerticalOptions="Center" Margin="20,0"/>
<Label Text="{Binding narration}" TextColor="#757575" FontSize="12" VerticalOptions="Center" Margin="20,0"/>
<Image Grid.Column="1" Source="{Binding Icon}" WidthRequest="38" HeightRequest="38" HorizontalOptions="Center" VerticalOptions="Center"/>
<StackLayout Grid.Column="2" Orientation="Horizontal" Margin="20,0" HorizontalOptions="End" VerticalOptions="Center">
<Label Text="{Binding Temp}" TextColor="Black" FontSize="30" FontAttributes="Bold" VerticalOptions="Center"/>
<Label Text="°C" TextColor="Black" FontSize="15" VerticalOptions="Center"/>
<Label Text="Ghc" TextColor="Black" FontSize="12" VerticalOptions="Center"/>
<Label Text="{Binding amount}" TextColor="Black" FontSize="20" FontAttributes="Bold" VerticalOptions="Center"/>

</StackLayout>
</Grid>
</Frame>

0 comments on commit 0d3eadf

Please sign in to comment.