Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for applying custom styling for the application #16

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FuelCostCalculator/FuelCostCalculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.14" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.14" />
Expand Down
6 changes: 5 additions & 1 deletion FuelCostCalculator/HistoryPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FuelCostCalculator.HistoryPage"
Title="History"
xmlns:local="clr-namespace:FuelCostCalculator">
<Shell.TitleView>
<Grid>
<Label Text="History" Style="{StaticResource SubHeadline}" HorizontalOptions="Start" VerticalOptions="Center" />
</Grid>
</Shell.TitleView>
<ContentPage.Content>
<StackLayout>
<ListView x:Name="historyListView"
Expand Down
10 changes: 5 additions & 5 deletions FuelCostCalculator/HistoryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
if (!(args.SelectedItem is HistoryItemViewModel selectedItem))
return;

string message = $"Date: {selectedItem.Date}\n" +
$"Distance: {selectedItem.Distance}\n" +
string message = $"Date: {selectedItem.Date}\n\n" +
$"Distance (km): {selectedItem.Distance}\n" +
$"Average fuel consumption (l/100km): {selectedItem.AvgFuelConsumption}\n" +
$"Price of the gas: {selectedItem.GasPrice}\n" +
$"Price of the gas (€): {selectedItem.GasPrice}\n" +
$"Number of people sharing the fuel cost: {selectedItem.NumberOfPeople}\n" +
$"Cost: {Math.Round(selectedItem.Cost, 2)}";
$"Cost (€): {Math.Round(selectedItem.Cost, 2)}";

await DisplayAlert("History Item Details", message, "OK");
await DisplayAlert("Details", message, "OK");

((ListView)sender).SelectedItem = null;
}
Expand Down
28 changes: 15 additions & 13 deletions FuelCostCalculator/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
<?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"
xmlns:mct="clr-namespace:CommunityToolkit.Maui.Behaviors;assembly=CommunityToolkit.Maui"
x:Class="FuelCostCalculator.MainPage">

<Page.Behaviors>
<mct:StatusBarBehavior StatusBarColor="Black" />
</Page.Behaviors>

<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">

<StackLayout Padding="0,25,0,0">
<StackLayout Padding="0,20,0,-35">
<Image
Source="gaspump.jpg"
HeightRequest="130"
HeightRequest="170"
Aspect="AspectFit"
ScaleY="1.5"
ScaleX="1.5"
SemanticProperties.Description="Old gas pump" />
</StackLayout>

<Label
Text="Fuel cost calculator"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1"
FontFamily="Cabin_Condensed-Regular" />
SemanticProperties.HeadingLevel="Level1" />

<Label
Text="Travelled distance (km):"
SemanticProperties.Description="Travelled distance"
FontFamily="Cabin_Condensed-Regular" />
Text="Travelled distance (km)"
SemanticProperties.Description="Travelled distance" />

<Entry
x:Name="TravelledDistance"
Expand All @@ -35,8 +40,7 @@

<Label
Text="Average fuel consumption (l/100km)"
SemanticProperties.Description="Average fuel consumption of the vehicle"
FontFamily="Cabin_Condensed-Regular" />
SemanticProperties.Description="Average fuel consumption of the vehicle" />

<Entry
x:Name="AvgFuelConsumption"
Expand All @@ -45,8 +49,7 @@

<Label
Text="Price of the gas (€/l)"
SemanticProperties.Description="Price of the gas at the moment"
FontFamily="Cabin_Condensed-Regular" />
SemanticProperties.Description="Price of the gas at the moment" />

<Entry
x:Name="GasPrice"
Expand All @@ -56,8 +59,7 @@

<Label
Text="Number of people sharing the fuel cost (optional)"
SemanticProperties.Description="Number of people sharing the fuel cost"
FontFamily="Cabin_Condensed-Regular" />
SemanticProperties.Description="Number of people sharing the fuel cost" />

<Entry
x:Name="CostShareAmount"
Expand Down
6 changes: 5 additions & 1 deletion FuelCostCalculator/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using Microsoft.Extensions.Logging;

namespace FuelCostCalculator
{
Expand All @@ -9,10 +10,13 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("Roboto-VariableFont_wght.ttf", "RobotoVariableFont");
fonts.AddFont("Roboto-Italic-VariableFont_wght.ttf", "RobotoItalicVariableFont");
});

#if DEBUG
Expand Down
Loading
Loading