Skip to content

Commit

Permalink
Merge pull request #257 from OudomMunint/dev
Browse files Browse the repository at this point in the history
PR: Dev => Main
  • Loading branch information
OudomMunint authored Dec 18, 2024
2 parents 25e1f98 + acc213f commit ac5fd19
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 65 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# MAUI iOS Build
build-ios:
runs-on: macos-14
runs-on: macos-15
name: iOS Build
steps:
- name: Checkout
Expand All @@ -59,7 +59,7 @@ jobs:
dotnet workload install maui --ignore-failed-sources
- name: Select Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app
run: sudo xcode-select -s /Applications/Xcode_16.0.app

- name: Build MAUI iOS
run: |
Expand All @@ -74,4 +74,4 @@ jobs:
- name: Create Release
uses: ncipollo/[email protected]
with:
tag: v1.7.7.8
tag: v1.7.7.8
106 changes: 54 additions & 52 deletions Views/Dashboard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,87 @@
Title="Dashboard"
NavigationPage.HasNavigationBar="False">

<Grid ColumnSpacing="10" RowSpacing="10" Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid ColumnSpacing="10" RowSpacing="10" Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="{OnIdiom Phone=135, Tablet=*}"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="{OnIdiom Phone=0, Tablet=*}"/>
<ColumnDefinition Width="{OnIdiom Phone=0, Tablet=*}"/>
</Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{OnIdiom Phone=135, Tablet=*}" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="{OnIdiom Phone=0, Tablet=*}" />
<ColumnDefinition Width="{OnIdiom Phone=0, Tablet=*}" />
</Grid.ColumnDefinitions>

<!-- Title -->
<views:HeaderGrid x:Name="HeaderGrid" Grid.Row="0" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=5}"/>
<!-- Title -->
<views:HeaderGrid x:Name="HeaderGrid" Grid.Row="0" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=5}" />

<!-- Labels -->
<Frame Grid.Row="1" Grid.Column="0" Style="{DynamicResource ChartFrame}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>
<!-- Labels -->
<Frame Grid.Row="1" Grid.Column="0" Style="{DynamicResource ChartFrame}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>

<ScrollView Padding="{OnIdiom Phone='0,0,0,0', Tablet='10,10,10,10'}">
<StackLayout>
<!--<Label Text="👋 Hello!" VerticalOptions="Start" HorizontalOptions="Start" FontSize="Title" FontFamily="Inter-Regular"/>-->
<Label x:Name="todoitems" FontAttributes="Bold" Style="{StaticResource PriorityLabel}" />
<Label x:Name="todoitems2" FontAttributes="Bold" Style="{StaticResource PriorityLabel}" />
<Label x:Name="lowpriority" Style="{StaticResource PriorityLabel}"/>
<Label x:Name="lowpriority" Style="{StaticResource PriorityLabel}" />
<Label x:Name="mediumpriority" Style="{StaticResource PriorityLabel}" />
<Label x:Name="highpriority" Style="{StaticResource PriorityLabel}" />
<Label x:Name="criticalpriority" Style="{StaticResource PriorityLabel}" />
<!--<Label x:Name="hasattcount" FontSize="Medium" Style="{StaticResource PriorityLabel}" Text="{Binding ItemHasAttachment}"
LineBreakMode="WordWrap"/>-->
</StackLayout>
</ScrollView>
</Frame>
</Frame>

<!-- Priority Chart -->
<Frame Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="{OnIdiom Phone=1, Tablet=3}" Style="{DynamicResource ChartFrame}"
Padding="{OnPlatform iOS=30, Android=40}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>

<charts:ChartView x:Name="chartView" WidthRequest="{OnPlatform iOS=185, Android=160}"/>
</Frame>
<!-- Priority Chart -->
<Frame Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="{OnIdiom Phone=1, Tablet=3}" Style="{DynamicResource ChartFrame}"
Padding="{OnPlatform iOS=30, Android={OnIdiom Phone=40, Tablet=0}}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>

<!--Attachment Count Chart-->
<Frame Grid.Row="2" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=2}" Grid.Column="{OnIdiom Phone=0, Tablet=0}" Style="{DynamicResource ChartFrame}"
Grid.RowSpan="{OnIdiom Phone=1, Tablet=3}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>

<charts:ChartView x:Name="chartView3" />
</Frame>
<charts:ChartView x:Name="chartView" WidthRequest="{OnIdiom Phone={OnPlatform iOS=185, Android=160}, Tablet=210}" />
</Frame>

<!-- Tasks Chart -->
<Frame Grid.Row="{OnIdiom Phone=3, Tablet=2}" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=2}" Grid.Column="{OnIdiom Phone=0, Tablet=2}"
Grid.RowSpan="{OnIdiom Phone=1, Tablet=3}" Style="{DynamicResource ChartFrame}" >
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>

<charts:ChartView x:Name="chartView2" />
</Frame>
<!--Attachment Count Chart-->
<Frame Grid.Row="2" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=2}" Grid.Column="{OnIdiom Phone=0, Tablet=0}"
Style="{DynamicResource ChartFrame}"
Grid.RowSpan="{OnIdiom Phone=1, Tablet=3}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>

<ListView x:Name="listView" IsVisible="False" CachingStrategy="RecycleElement" BackgroundColor="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}">
<charts:ChartView x:Name="chartView3" />
</Frame>

<!-- Tasks Chart -->
<Frame Grid.Row="{OnIdiom Phone=3, Tablet=2}" Grid.ColumnSpan="{OnIdiom Phone=3, Tablet=2}" Grid.Column="{OnIdiom Phone=0, Tablet=2}"
Grid.RowSpan="{OnIdiom Phone=1, Tablet=3}"
Style="{DynamicResource ChartFrame}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>

<charts:ChartView x:Name="chartView2" />
</Frame>

<ListView x:Name="listView" IsVisible="False" CachingStrategy="RecycleElement" BackgroundColor="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<VerticalStackLayout>
<Label Text="{Binding Name}"/>
<Label Text="{Binding Name}" />
</VerticalStackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
</ContentPage>
2 changes: 1 addition & 1 deletion Views/TodoListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
</ListView>
<!-- Loading Indicator -->
<!--"{Binding IsBusy, Source={x:Reference todoListPage}}"-->
<AbsoluteLayout IsVisible="{Binding IsPageLoading, Source={x:Reference todoListPage}}" Grid.RowSpan="5" Margin="0" Padding="0" BackgroundColor="Black"
<AbsoluteLayout IsVisible="{Binding IsPageLoading, Source={x:Reference todoListPage}}" Grid.Row="2" Margin="0" Padding="0" BackgroundColor="Black"
Opacity="{OnPlatform Android=0.5, iOS=0.7}">
<StackLayout Margin="0" Padding="0" AbsoluteLayout.LayoutBounds="0.5,0.5,AutoSize,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional"
HorizontalOptions="CenterAndExpand" VerticalOptions="FillAndExpand">
Expand Down
57 changes: 48 additions & 9 deletions Views/TodoListPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ protected override async void OnAppearing()
await SetPinnedOnlyListSource();
await UpdateListView();
await UpdateCollectionView();
ApplySavedSorting();

IsPageLoading = false;
}
Expand Down Expand Up @@ -293,6 +294,38 @@ public async void OpenMenu(object sender, EventArgs e)

}

private void SaveSortingPreference(string sortingType, bool isAscending)
{
Preferences.Set("SortingKey", sortingType);
Preferences.Set("SortDirectionKey", isAscending);
}

private void ApplySavedSorting()
{
var sortingType = Preferences.Get("SortingKey", "none");
var isAscending = Preferences.Get("SortDirectionKey", true);

IEnumerable<Todoitem> items = listView.ItemsSource as IEnumerable<Todoitem>;

switch (sortingType)
{
case "date":
items = isAscending ? items.OrderBy(item => item.Date) : items.OrderByDescending(item => item.Date);
break;
case "priority":
items = items.OrderBy(item => TodoListPage.GetPriorityValue(item.Priority));
break;
case "pinned":
items = items.OrderByDescending(item => item.IsPinned);
break;
case "none":
default:
return; // No sorting
}

listView.ItemsSource = items.ToList();
}

//Sorting
private void SortByDateClicked(object sender, EventArgs e)
{
Expand All @@ -302,6 +335,8 @@ private void SortByDateClicked(object sender, EventArgs e)
? ((IEnumerable<Todoitem>)listView.ItemsSource).OrderBy(item => item.Date)
: ((IEnumerable<Todoitem>)listView.ItemsSource).OrderByDescending(item => item.Date);
listView.ItemsSource = sortedItems.ToList();

SaveSortingPreference("date", sortByDateAscending);
}

public async void OpenSortMenu(object sender, EventArgs e)
Expand All @@ -313,26 +348,30 @@ public async void OpenSortMenu(object sender, EventArgs e)

var action = await Application.Current.MainPage.DisplayActionSheet("Sorting", "Cancel", null, new[] { sortbydate, sortbypriority, sortbypinned, clearsorting });

if (action != null && action.Equals(sortbydate))
if (action == sortbydate)
{
var sortedItems = ((IEnumerable<Todoitem>)listView.ItemsSource).OrderByDescending(item => item.Date);
listView.ItemsSource = sortedItems.ToList();
SaveSortingPreference("date", false); // Descending
}
else if (action != null && action.Equals(sortbypriority))
else if (action == sortbypriority)
{
var sortedItems = ((IEnumerable<Todoitem>)listView.ItemsSource).OrderBy(item => TodoListPage.GetPriorityValue(item.Priority));
listView.ItemsSource = sortedItems.ToList();
SaveSortingPreference("priority", true); // Ascending
}
else if (action != null && action.Equals(clearsorting)) // Handle clear sorting option
{
// Reset ListView
listView.ItemsSource = ((IEnumerable<Todoitem>)listView.ItemsSource).ToList();
await UpdateListView();
}
else if (action != null && action.Equals(sortbypinned))
else if (action == sortbypinned)
{
var sortedItems = ((IEnumerable<Todoitem>)listView.ItemsSource).OrderByDescending(item => item.IsPinned);
listView.ItemsSource = sortedItems.ToList();
SaveSortingPreference("pinned", false); // Descending
}
else if (action == clearsorting)
{
listView.ItemsSource = ((IEnumerable<Todoitem>)listView.ItemsSource).ToList();
Preferences.Remove("SortingKey");
Preferences.Remove("SortDirectionKey");
await UpdateListView();
}
}

Expand Down

0 comments on commit ac5fd19

Please sign in to comment.