diff --git a/AppShell.xaml b/AppShell.xaml index 3d377c7..31c8d46 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -11,5 +11,4 @@ Title="Home" ContentTemplate="{DataTemplate local:Views.DashboardPage}" Route="Views.DashboardPage" /> - diff --git a/Justice.csproj b/Justice.csproj index e36fb25..5c4cf93 100644 --- a/Justice.csproj +++ b/Justice.csproj @@ -87,6 +87,9 @@ MSBuild:Compile + + MSBuild:Compile + diff --git a/Justice.csproj.user b/Justice.csproj.user index 3743e56..94c866c 100644 --- a/Justice.csproj.user +++ b/Justice.csproj.user @@ -26,6 +26,9 @@ Designer + + Designer + diff --git a/Views/DashboardPage.xaml.cs b/Views/DashboardPage.xaml.cs index 75b9774..153c178 100644 --- a/Views/DashboardPage.xaml.cs +++ b/Views/DashboardPage.xaml.cs @@ -23,7 +23,7 @@ public partial class DashboardPage : ContentPage } private void OnViewReportClicked(object sender, EventArgs e) { - DisplayAlert("View Reports button clicked", "Reports", "OK"); + Navigation.PushAsync(new ViewReportsPage()); } private void OnIncidentReportClicked(object sender, EventArgs e) { diff --git a/Views/ViewReportsPage.xaml b/Views/ViewReportsPage.xaml new file mode 100644 index 0000000..c49bd6b --- /dev/null +++ b/Views/ViewReportsPage.xaml @@ -0,0 +1,28 @@ + + + + + diff --git a/Views/ViewReportsPage.xaml.cs b/Views/ViewReportsPage.xaml.cs new file mode 100644 index 0000000..a9f8b34 --- /dev/null +++ b/Views/ViewReportsPage.xaml.cs @@ -0,0 +1,64 @@ +using Justice.Helpers; +using Justice.Models; +using System; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using Justice.Services; + +namespace Justice.Views +{ + public partial class ViewReportsPage : ContentPage + { + private readonly DatabaseHelper _databaseHelper; + public ObservableCollection Reports { get; set; } + + public ViewReportsPage() + { + InitializeComponent(); + _databaseHelper = new DatabaseHelper(); + Reports = new ObservableCollection(); + ReportsListView.ItemsSource = Reports; + } + + protected override async void OnAppearing() + { + base.OnAppearing(); + await LoadReportsAsync(); + } + + private async Task LoadReportsAsync() + { + try + { + var reportsFromDb = await _databaseHelper.GetAllAsync(); + Reports.Clear(); + + foreach (var report in reportsFromDb) + { + Reports.Add(report); + } + } + catch (Exception ex) + { + await DisplayAlert("Error", $"Failed to load reports: {ex.Message}", "OK"); + } + } + + private async void OnReportSelected(object sender, SelectedItemChangedEventArgs e) + { + if (e.SelectedItem is IncidentReport selectedReport) + { + await DisplayAlert("Report Details", + $"Type: {selectedReport.IncidentType}\n" + + $"Description: {selectedReport.Description}\n" + + $"Address: {selectedReport.Address}\n" + + $"Submitted on: {selectedReport.DateTime:MMM dd, yyyy HH:mm}\n" + + $"Attachment: {(string.IsNullOrWhiteSpace(selectedReport.AttachmentPath) ? "None" : "Attached")}", + "OK"); + + // Deselect the item + ReportsListView.SelectedItem = null; + } + } + } +} diff --git a/bin/Debug/net9.0-android/Justice.dll b/bin/Debug/net9.0-android/Justice.dll index 2d1a0de..0468665 100644 Binary files a/bin/Debug/net9.0-android/Justice.dll and b/bin/Debug/net9.0-android/Justice.dll differ diff --git a/bin/Debug/net9.0-android/Justice.pdb b/bin/Debug/net9.0-android/Justice.pdb index 09b4a2c..71fd9a6 100644 Binary files a/bin/Debug/net9.0-android/Justice.pdb and b/bin/Debug/net9.0-android/Justice.pdb differ diff --git a/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk b/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk index 988db9c..88bcc1c 100644 Binary files a/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk and b/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk differ diff --git a/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig b/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig index 322d0cf..abbc759 100644 Binary files a/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig and b/bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig differ diff --git a/bin/Debug/net9.0-android/com.companyname.justice.apk b/bin/Debug/net9.0-android/com.companyname.justice.apk index bdebdf9..c04d6a7 100644 Binary files a/bin/Debug/net9.0-android/com.companyname.justice.apk and b/bin/Debug/net9.0-android/com.companyname.justice.apk differ diff --git a/bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll b/bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll index 671ab5f..ccfeeb2 100644 Binary files a/bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll and b/bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll differ diff --git a/bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb b/bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb index 7113e5c..477e778 100644 Binary files a/bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb and b/bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb differ diff --git a/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll b/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll index d7c9140..1e9ce3a 100644 Binary files a/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll and b/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll differ diff --git a/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb b/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb index c6c5f35..ad03f72 100644 Binary files a/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb and b/bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb differ diff --git a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll index a3fb5f4..8ee2137 100644 Binary files a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll and b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll differ diff --git a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe index af19186..0b8aeb3 100644 Binary files a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe and b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe differ diff --git a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb index 2116d98..a91338f 100644 Binary files a/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb and b/bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb differ