View report update

main
unknown 6 months ago
parent 38ca3b3d10
commit e49bf6af26
  1. 1
      AppShell.xaml
  2. 3
      Justice.csproj
  3. 3
      Justice.csproj.user
  4. 2
      Views/DashboardPage.xaml.cs
  5. 28
      Views/ViewReportsPage.xaml
  6. 64
      Views/ViewReportsPage.xaml.cs
  7. BIN
      bin/Debug/net9.0-android/Justice.dll
  8. BIN
      bin/Debug/net9.0-android/Justice.pdb
  9. BIN
      bin/Debug/net9.0-android/com.companyname.justice-Signed.apk
  10. BIN
      bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig
  11. BIN
      bin/Debug/net9.0-android/com.companyname.justice.apk
  12. BIN
      bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll
  13. BIN
      bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb
  14. BIN
      bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll
  15. BIN
      bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb
  16. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll
  17. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe
  18. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb

@ -11,5 +11,4 @@
Title="Home" Title="Home"
ContentTemplate="{DataTemplate local:Views.DashboardPage}" ContentTemplate="{DataTemplate local:Views.DashboardPage}"
Route="Views.DashboardPage" /> Route="Views.DashboardPage" />
</Shell> </Shell>

@ -87,6 +87,9 @@
<MauiXaml Update="Views\SosPage.xaml"> <MauiXaml Update="Views\SosPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\ViewReportsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -26,6 +26,9 @@
<MauiXaml Update="Views\SosPage.xaml"> <MauiXaml Update="Views\SosPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\ViewReportsPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="App.xaml"> <None Update="App.xaml">

@ -23,7 +23,7 @@ public partial class DashboardPage : ContentPage
} }
private void OnViewReportClicked(object sender, EventArgs e) 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) private void OnIncidentReportClicked(object sender, EventArgs e)
{ {

@ -0,0 +1,28 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Justice.Views.ViewReportsPage"
Title="View Reports">
<StackLayout Padding="20">
<Label Text="Submitted Reports" FontSize="Large" HorizontalOptions="Center" />
<!-- List of Reports -->
<ListView x:Name="ReportsListView"
HasUnevenRows="True"
ItemSelected="OnReportSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10">
<Label Text="{Binding IncidentType}" FontSize="Medium" FontAttributes="Bold" />
<Label Text="{Binding Address}" FontSize="Small" TextColor="Gray" />
<Label Text="{Binding DateTime, StringFormat='Submitted on: {0:MMM dd, yyyy HH:mm}'}"
FontSize="Small" />
<Label Text="{Binding Description}" FontSize="Small" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>

@ -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<IncidentReport> Reports { get; set; }
public ViewReportsPage()
{
InitializeComponent();
_databaseHelper = new DatabaseHelper();
Reports = new ObservableCollection<IncidentReport>();
ReportsListView.ItemsSource = Reports;
}
protected override async void OnAppearing()
{
base.OnAppearing();
await LoadReportsAsync();
}
private async Task LoadReportsAsync()
{
try
{
var reportsFromDb = await _databaseHelper.GetAllAsync<IncidentReport>();
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;
}
}
}
}
Loading…
Cancel
Save