Skip to content
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
206 changes: 206 additions & 0 deletions App/Controls/DealPreview.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:stroked="https://vapolia.eu/Vapolia.StrokedLabel"
xmlns:ctrl="clr-namespace:GamHubApp.Controls"
x:DataType="ctrl:DealPreview"
x:Name="preview"
x:Class="GamHubApp.Controls.DealPreview">
<Grid RowDefinitions="220,50"
x:Name="DealBlock"
Padding="10">
<Border Grid.Row="0"
StrokeShape="RoundRectangle 8"
x:Name="thumbnail">
<Image Source="{Binding Deal.Image, Source={x:Reference preview}}"
HorizontalOptions="Fill"
VerticalOptions="Fill"
Aspect="Fill"/>

<Border.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.Navigate}"
BindingContext="{Binding BindingContext,
Source={x:Reference thumbnail},
x:DataType=Border}"/>
</Border.Behaviors>
</Border>

<Border Grid.Row="0"
IsVisible="{Binding Deal.ExpirationDisplayed, Source={x:Reference preview}}"
StrokeShape="RoundRectangle 10"
HorizontalOptions="Start"
VerticalOptions="Start"
HeightRequest="30"
BackgroundColor="{StaticResource BackgroundColor}"
StrokeThickness="1"
Stroke="{Binding Deal.Expires,
Source={x:Reference preview},
Converter={StaticResource TimeUntilColourConverter}}"
Margin="2,5"
Padding="5,2"
x:Name="timestampCard">
<Label TextColor="{StaticResource FontColor}"
VerticalTextAlignment="Center">
<Label.FormattedText>
<FormattedString>
<Span FontFamily="P-Medium" Text="Ends in "/>
<Span FontFamily="P-Bold"
Text="{Binding Deal.Expires,
Source={x:Reference preview}, Converter={StaticResource TimeUntilConverter}}"
TextColor="{Binding Deal.Expires, Converter={StaticResource TimeUntilColourConverter}}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<Border.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.Navigate,
Source={x:Reference preview}}"
BindingContext="{Binding BindingContext,
Source={x:Reference timestampCard},
x:DataType=Border}"/>
</Border.Behaviors>
</Border>
<Label Grid.Row="1"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
Text="{Binding Deal.Title,
Source={x:Reference preview}}"
TextColor="{StaticResource FontColor}"
FontFamily="P-Bold"
x:Name="label"
FontSize="20">
<Label.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.Navigate,
Source={x:Reference preview}}"
BindingContext="{Binding BindingContext,
Source={x:Reference label},
x:DataType=Label}"/>

</Label.Behaviors>
</Label>
<Grid RowDefinitions="*,30,40"
Grid.Row="0"
RowSpacing="5">
<Border Grid.Row="1"
StrokeShape="RoundRectangle 8"
HorizontalOptions="Start"
VerticalOptions="End"
HeightRequest="30"
Margin="5,0"
Stroke="{DynamicResource BackgroundColor}"
StrokeThickness="2"
IsVisible="{Binding Deal.GemRewards,
Source={x:Reference preview}, Converter={StaticResource NotNullOrEmptyStringConverter}}"
BackgroundColor="{StaticResource Dark}">

<Border.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.Navigate,
Source={x:Reference preview}}"
BindingContext="{Binding BindingContext,
Source={x:Reference discountCard},
x:DataType=Border}"/>
</Border.Behaviors>
<Label Margin="5"
FontSize="15"
Padding="0"
HorizontalOptions="End"
VerticalOptions="Center">
<Label.FormattedText>
<FormattedString>
<Span Text="Earn"
FontFamily="P-Regular"
TextColor="{DynamicResource FontColor}"/>
<Span Text=" "/>
<Span
Text="&#xf3a5;"
FontFamily="FaSolid"
TextColor="{DynamicResource DiscountColor}"/>
<Span Text=" "/>
<Span Text="{Binding Deal.GemRewards,
Source={x:Reference preview}}"
FontFamily="P-Bold"
TextColor="{DynamicResource FontColor}"/>
</FormattedString>
</Label.FormattedText>
</Label>
</Border>
<Border Grid.Row="2"
StrokeShape="RoundRectangle 0,20,8,0"
HorizontalOptions="Start"
VerticalOptions="End"
HeightRequest="40"
WidthRequest="100"
x:Name="discountCard"
IsVisible="{Binding Deal.Discount,
Source={x:Reference preview},
Converter={StaticResource NotNullOrEmptyStringConverter}}"
BackgroundColor="{StaticResource DiscountColor}">

<Border.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.Navigate,
Source={x:Reference preview}}"
BindingContext="{Binding BindingContext,
Source={x:Reference discountCard},
x:DataType=Border}"/>
</Border.Behaviors>
<Label
Text="{Binding Deal.Discount,
Source={x:Reference preview}}"
TextColor="{StaticResource FontColor}"
FontFamily="P-Bold"
stroked:StrokedLabel.StrokeColor="{StaticResource Dark}"
stroked:StrokedLabel.StrokeWidth="2"
HorizontalOptions="Center"
VerticalOptions="Center"
FontSize="20"
/>
</Border>

</Grid>
<Grid Grid.Row="0"
RowDefinitions="50,*">
<Border Grid.Row="0"
StrokeShape="RoundRectangle 0,8,20,0"
HorizontalOptions="End"
VerticalOptions="Start"
HeightRequest="50"
WidthRequest="100"
x:Name="partner"
BackgroundColor="White">
<Image Source="{Binding Deal.Partner.Logo,
Source={x:Reference preview}}"
HorizontalOptions="Fill"
VerticalOptions="Fill"/>
</Border>
<Button Grid.Row="0"
Grid.RowSpan="2"
BackgroundColor="Transparent"
Command="{Binding Deal.Navigate,
Source={x:Reference preview}}"/>

<!-- Share button-->
<Border Grid.Row="1"
Style="{StaticResource ButtonBorder}"
WidthRequest="60"
StrokeShape="RoundRectangle 20,0,0,8"
VerticalOptions="End"
HorizontalOptions="End"
Margin="0"
x:Name="share"
BackgroundColor="{StaticResource BackgroundColor}">
<Border.Behaviors>
<mct:TouchBehavior Command="{Binding Deal.ShareDeal,
Source={x:Reference preview}}"
BindingContext="{Binding BindingContext,
Source={x:Reference share},
x:DataType=Border}"/>
</Border.Behaviors>
<Label Style="{StaticResource LabelButtonStyle}"
TextColor="{StaticResource VeryLightDark }"
Text="&#xf14d;"
/>
</Border>

</Grid>
</Grid>
</ContentView>
22 changes: 22 additions & 0 deletions App/Controls/DealPreview.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using GamHubApp.Models;

namespace GamHubApp.Controls;

public partial class DealPreview : ContentView
{
public static readonly BindableProperty DealProperty = BindableProperty.Create(propertyName: nameof(Deal),
returnType: typeof(Deal),
declaringType: typeof(DealPreview),
defaultBindingMode: BindingMode.OneWay);
public Deal Deal
{
get => (Deal)GetValue(DealProperty);
set => SetValue(DealProperty, value);
}

public DealPreview()
{
InitializeComponent();
BindingContext = this;
}
}
3 changes: 3 additions & 0 deletions App/GamHubApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Controls\DealPreview.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Styles\Colors.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand Down
2 changes: 1 addition & 1 deletion App/Models/Deal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ public Command ShareDeal
}
}
[JsonIgnore, Ignore]
public bool EpirationDisplayed { get => (Expires - DateTime.Now).TotalDays < 30; }
public bool ExpirationDisplayed { get => (Expires - DateTime.Now).TotalDays < 30; }
}
4 changes: 2 additions & 2 deletions App/Services/Fetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public string PlatformsStr { get; private set; }

#if IOS
private readonly IRevenueCatBilling _revenueCatBilling;

Check warning on line 55 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-ios / iOS Publish

The field 'Fetcher._revenueCatBilling' is never used
#endif
public Fetcher(GeneralDataBase generalDataBase,
BackUpDataBase backUpDataBase,
Expand Down Expand Up @@ -330,7 +330,7 @@
cancellationToken: cts.Token,
unSuccessCallback: e => _ = HandleHttpException(e)));
}
catch (Exception ex)

Check warning on line 333 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-ios / iOS Publish

The variable 'ex' is declared but never used

Check warning on line 333 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-android / Android Publish

The variable 'ex' is declared but never used
{
#if DEBUG
Debug.WriteLine(ex);
Expand Down Expand Up @@ -405,7 +405,7 @@
parameters: parameters,jsonBody: null,
unSuccessCallback: e => _ = HandleHttpException(e))));
}
catch (Exception ex)

Check warning on line 408 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-ios / iOS Publish

The variable 'ex' is declared but never used

Check warning on line 408 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-android / Android Publish

The variable 'ex' is declared but never used
{
#if DEBUG
Debug.WriteLine(ex);
Expand Down Expand Up @@ -448,7 +448,7 @@
return [];
return new ([.. articleTrends]);
}
catch (Exception ex)

Check warning on line 451 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-ios / iOS Publish

The variable 'ex' is declared but never used

Check warning on line 451 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-android / Android Publish

The variable 'ex' is declared but never used
{
#if DEBUG
Debug.WriteLine(ex);
Expand Down Expand Up @@ -496,7 +496,7 @@
return new ([.. dealTrends]);

}
catch (Exception ex)

Check warning on line 499 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-ios / iOS Publish

The variable 'ex' is declared but never used

Check warning on line 499 in App/Services/Fetcher.cs

View workflow job for this annotation

GitHub Actions / build-android / Android Publish

The variable 'ex' is declared but never used
{
#if DEBUG
Debug.WriteLine(ex);
Expand Down Expand Up @@ -536,14 +536,14 @@
/// Get all the deals
/// </summary>
/// <returns>all the deals</returns>
public async Task<Collection<Deal>> GetDeals()
public async Task<Collection<Deal>> GetDeals(string filterCode = null)
{
if (!Fetcher.CheckFeasability())
return [];
ResetHandler();
try
{
string filterCode = Preferences.Get(PreferencesKeys.DealFilterCode, null);
filterCode ??= Preferences.Get(PreferencesKeys.DealFilterCode, null);

using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(5));
Expand Down
Loading
Loading