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

Enhancement & optimisation of loads #120

Merged
merged 8 commits into from
May 19, 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
6 changes: 4 additions & 2 deletions AresNews/AresNews/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Color x:Key="Primary" >#4AC776</Color>
<Color x:Key="SelectionColor" >#528e70</Color>
<Color x:Key="PrimaryAccent" >#1DB954</Color>
<Color x:Key="DarkPrimary" >#14813A</Color>
<Color x:Key="Secondary" >#666666</Color>
<Color x:Key="Alternate">#8B8E92</Color>
<Color x:Key="Dark" >#191414</Color>
Expand All @@ -26,6 +27,7 @@
<helpers:ThumbnailConverter x:Key="ThumbnailConverter"/>
<helpers:BoolInverseConverter x:Key="BoolInverseConverter"/>
<helpers:ZeroToFalseConverter x:Key="ZeroToFalseConverter"/>
<helpers:ZeroToTrueConverter x:Key="ZeroToTrueConverter"/>

<ResourceDictionary>
<OnPlatform x:Key="TitleRightMargin"
Expand Down Expand Up @@ -60,7 +62,7 @@
<Setter Property="FontSize" Value="20" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="TextColor" Value="{StaticResource Primary}" />
<Setter Property="TextColor" Value="{StaticResource Light}" />

</Style>
<Style TargetType="Label"
Expand All @@ -73,7 +75,7 @@
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />

<Setter Property="TextColor" Value="{StaticResource Primary}" />
<Setter Property="TextColor" Value="{StaticResource Light}" />

</Style>
</Application.Resources>
Expand Down
6 changes: 3 additions & 3 deletions AresNews/AresNews/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static void CloseDb()
/// <summary>
/// Function to start the data base
/// </summary>
public static async void StartDb()
public static void StartDb()
{
const SQLite.SQLiteOpenFlags Flags =
// open the database in read/write mode
Expand All @@ -163,8 +163,8 @@ public static async void StartDb()
SQLite.SQLiteOpenFlags.Create |
// enable multi-threaded database access
SQLite.SQLiteOpenFlags.SharedCache;
// Just use whatever directory SpecialFolder.Personal returns
string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
// Just use whatever directory SpecialFolder.Personal returns
string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

var path = Path.Combine(libraryPath, "ares.db3");
var pathBackUp = Path.Combine(libraryPath, "aresBackup.db3");
Expand Down
8 changes: 4 additions & 4 deletions AresNews/AresNews/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
x:Class="AresNews.AppShell"
xmlns:control="clr-namespace:AresNews.Controls"
Shell.TabBarBackgroundColor="{StaticResource LightDark}"
Shell.TabBarUnselectedColor="{StaticResource Primary}"
Shell.TabBarTitleColor="{StaticResource Light}"
Shell.TabBarUnselectedColor="{StaticResource Light}"
Shell.TabBarTitleColor="{StaticResource Primary}"
Shell.BackgroundColor="{StaticResource LightDark}"
FlyoutBackgroundColor="{StaticResource LightDark}"
Shell.ForegroundColor="{StaticResource Primary}"
Shell.ForegroundColor="{StaticResource Light}"
FlyoutWidth="270"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:viewmodels="clr-namespace:AresNews.ViewModels">
Expand Down Expand Up @@ -61,7 +61,7 @@
Text="{Binding Icon}"
FontFamily="FaSolid"
FontSize="23"
TextColor="{StaticResource Primary}"/>
TextColor="{StaticResource Light}"/>
<!-- Title -->
<Label Grid.Column="1"
Text="{Binding Title}"
Expand Down
4 changes: 2 additions & 2 deletions AresNews/AresNews/Controls/ArticlePreview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<Frame.Background>
<LinearGradientBrush EndPoint="0,1">

<GradientStop Color="{StaticResource Light}"
<GradientStop Color="{StaticResource Primary}"
Offset="0.1" />
<GradientStop Color="{StaticResource Light}"
Offset="0.0" />
Expand Down Expand Up @@ -135,7 +135,7 @@
</Grid.RowDefinitions>
<!-- Headline -->
<Label Grid.Row="0"
Text="{Binding Headline, Converter={StaticResource MaxLengthConverter}, ConverterParameter=120}}"
Text="{Binding Headline, Converter={StaticResource MaxLengthConverter}, ConverterParameter=120}"
TextColor="{StaticResource FontColor}"
Margin="10,0"
TextType="Html"
Expand Down
35 changes: 4 additions & 31 deletions AresNews/AresNews/Controls/BookmarkButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,20 @@
Value="true">
<Setter Property="FontFamily"
Value="FaSolid" />
<Setter Property="TextColor"
Value="{StaticResource Primary}" />
</DataTrigger>
<DataTrigger TargetType="Button"
Binding="{Binding IsSaved}"
Value="false">
<Setter Property="FontFamily"
Value="FaRegular" />
<Setter Property="TextColor"
Value="{StaticResource Light}" />
</DataTrigger>
</Button.Triggers>
</Button>
</Frame>

<!--
<Frame
Style="{StaticResource ButtonFrame}"
BindingContext="{Binding Source={RelativeSource TemplatedParent}}"
xct:TouchEffect.Command="{Binding Command}"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.CommandParameter="{Binding CommandParameter}">

<Label Text="&#xf02e;"
Style="{StaticResource LabelButtonStyle}">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="Button_Clicked"/>
</Label.GestureRecognizers>
<Label.Triggers>
<DataTrigger TargetType="Button"
Binding="{Binding IsSaved}"
Value="true">
<Setter Property="FontFamily"
Value="FaSolid" />
</DataTrigger>
<DataTrigger TargetType="Button"
Binding="{Binding IsSaved}"
Value="false">
<Setter Property="FontFamily"
Value="FaRegular" />
</DataTrigger>
</Label.Triggers>
</Label>
</Frame>
-->
</ControlTemplate>
</ContentView.Resources>
</ContentView>
30 changes: 30 additions & 0 deletions AresNews/AresNews/Helpers/Comparers/ArticleComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using AresNews.Models;
using System;
using System.Collections.Generic;

namespace AresNews.Helpers.Comparers
{
public class ArticleComparer : IEqualityComparer<Article>
{
public bool Equals(Article x, Article y)
{
if (Object.ReferenceEquals(x, y)) return true;

if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;

// Replace "PropertyName" with the name of the property you want to compare
return x.Id == y.Id;
}

public int GetHashCode(Article article)
{
if (Object.ReferenceEquals(article, null)) return 0;

// Replace "PropertyName" with the name of the property you want to compare
int hashProductName = article.Id == null ? 0 : article.Id.GetHashCode();

return hashProductName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ZeroToFalseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((int)value) >= 0;
return ((int)value) > 0;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
19 changes: 19 additions & 0 deletions AresNews/AresNews/Helpers/Converters/ZeroToTrueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using Xamarin.Forms;

namespace AresNews.Helpers
{
public class ZeroToTrueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((int)value) == 0;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Loading