Skip to content

Commit 70bef97

Browse files
authored
Merge pull request #277 from OudomMunint/dev
Dev => Main
2 parents fe1bff1 + 80b8367 commit 70bef97

9 files changed

+55
-11
lines changed

Constants.cs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace ToDoListApp
1+
namespace ToDoListApp
82
{
93
public static class Constants
104
{
@@ -14,7 +8,6 @@ public static class Constants
148
SQLite.SQLiteOpenFlags.ReadWrite |
159
SQLite.SQLiteOpenFlags.Create |
1610
SQLite.SQLiteOpenFlags.SharedCache |
17-
SQLite.SQLiteOpenFlags.Memory |
1811
SQLite.SQLiteOpenFlags.Uri;
1912

2013
public static string DatabasePath
@@ -26,4 +19,4 @@ public static string DatabasePath
2619
}
2720
}
2821
}
29-
}
22+
}

Resources/Images/arrowup.png

337 Bytes
Loading

Resources/Images/arrowupwhite.png

381 Bytes
Loading

Views/Controls/ScrollToTopBtn.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ToDoListApp.Views.Controls
2+
{
3+
public partial class ScrollToTopBtn
4+
{
5+
public ScrollToTopBtn()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

Views/Controls/ScrollToTopBtn.xaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Button xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="ToDoListApp.Views.Controls.ScrollToTopBtn"
5+
ImageSource="arrowupwhite.png"
6+
BackgroundColor="{StaticResource Primary}"
7+
CornerRadius="{OnPlatform Android=30, iOS=23}"
8+
HeightRequest="45"
9+
WidthRequest="45"
10+
VerticalOptions="End"
11+
HorizontalOptions="End"
12+
Padding="12"
13+
Margin="30,30,30,85">
14+
<Button.Shadow>
15+
<Shadow Brush="Black"
16+
Offset="2,3"
17+
Radius="10"
18+
Opacity="0.5"/>
19+
</Button.Shadow>
20+
</Button>

Views/Dashboard.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:charts="clr-namespace:Microcharts.Maui;assembly=Microcharts.Maui"
55
xmlns:views="clr-namespace:ToDoListApp.Views"
6+
xmlns:models="clr-namespace:ToDoListApp.Models"
67
x:Class="ToDoListApp.Views.Dashboard"
78
NavigationPage.HasNavigationBar="False"
89
Title="">
@@ -77,7 +78,7 @@
7778
<DataTemplate>
7879
<ViewCell>
7980
<VerticalStackLayout>
80-
<Label Text="{Binding Name}" />
81+
<!--<Label Text="{Binding Name, Source={x:Reference models}}" />-->
8182
</VerticalStackLayout>
8283
</ViewCell>
8384
</DataTemplate>

Views/HeaderGrid.xaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4-
x:Class="ToDoListApp.Views.HeaderGrid">
4+
x:Class="ToDoListApp.Views.HeaderGrid"
5+
xmlns:this="clr-namespace:ToDoListApp.Views"
6+
x:DataType="this:HeaderGrid">
57

68
<Grid HorizontalOptions="Fill">
79
<Grid.RowDefinitions>

Views/TodoListPage.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,6 @@
267267

268268
<!-- Fab -->
269269
<controls:AddBtn x:Name="Fab" Grid.Row="2" Clicked="OnItemAdded"/>
270+
<controls:ScrollToTopBtn x:Name="TopScrollBtn" Grid.Row="2" Clicked="TopScrollBtn_Clicked"/>
270271
</Grid>
271272
</ContentPage>

Views/TodoListPage.xaml.cs

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using static ToDoListApp.ToastService;
99
using System;
1010
using System.ComponentModel;
11+
using ToDoListApp.Views.Controls;
1112

1213
namespace ToDoListApp.Views
1314
{
@@ -73,6 +74,7 @@ protected override async void OnAppearing()
7374
await UpdateListView();
7475
await UpdateCollectionView();
7576
ApplySavedSorting();
77+
TopScrollBtn.IsVisible = false;
7678

7779
#if ANDROID
7880
IsPageLoading = false;
@@ -574,6 +576,15 @@ async void listView_Scrolled2(System.Object sender, Microsoft.Maui.Controls.Scro
574576
// await MainThread.InvokeOnMainThreadAsync(async () =>
575577
// await Fab.ScaleTo(1.0, 75, Easing.CubicIn));
576578

579+
if (e.ScrollY > scrollThreshold)
580+
{
581+
TopScrollBtn.IsVisible = true;
582+
}
583+
else
584+
{
585+
TopScrollBtn.IsVisible = false;
586+
}
587+
577588
if (DeviceInfo.Platform == DevicePlatform.iOS)
578589
{
579590
await SearchBar.HideKeyboardAsync();
@@ -680,5 +691,11 @@ private async void markasdoneitem_Clicked(System.Object sender, System.EventArgs
680691
}
681692
}
682693
}
694+
695+
private void TopScrollBtn_Clicked(object sender, EventArgs e)
696+
{
697+
var firstItem = listView.ItemsSource.Cast<object>().FirstOrDefault();
698+
listView.ScrollTo(firstItem, ScrollToPosition.Start, animated: true);
699+
}
683700
}
684701
}

0 commit comments

Comments
 (0)