parent
e77ebc692c
commit
47f3cf95c7
After Width: | Height: | Size: 56 KiB |
@ -0,0 +1,47 @@ |
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
||||
x:Class="Justice.Views.AddContactPage" |
||||
Title="Add Emergency Contact"> |
||||
|
||||
<StackLayout Padding="20"> |
||||
<Label Text="Name" FontSize="Medium" /> |
||||
<Entry x:Name="NameEntry" Placeholder="Enter name" /> |
||||
|
||||
<Label Text="Mobile Number" FontSize="Medium" /> |
||||
<Entry x:Name="MobileNumberEntry" Placeholder="Enter mobile number" Keyboard="Telephone" /> |
||||
|
||||
<Label Text="Group" FontSize="Medium" /> |
||||
<Picker x:Name="GroupPicker"> |
||||
<Picker.ItemsSource> |
||||
<x:Array Type="{x:Type x:String}"> |
||||
<x:String>Parents</x:String> |
||||
<x:String>Friends</x:String> |
||||
<x:String>Colleagues</x:String> |
||||
<x:String>Others</x:String> |
||||
</x:Array> |
||||
</Picker.ItemsSource> |
||||
</Picker> |
||||
<Button Text="Save Contact" Clicked="OnSaveContactClicked" /> |
||||
<ScrollView> |
||||
<StackLayout> |
||||
<Grid RowSpacing="10" ColumnSpacing="10"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="*"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Border Grid.Column="0" HeightRequest="100" Margin="1"> |
||||
|
||||
</Border> |
||||
<Border Grid.Column="1" HeightRequest="100"> |
||||
|
||||
</Border> |
||||
<Border Grid.Column="2" HeightRequest="100"> |
||||
|
||||
</Border> |
||||
|
||||
</Grid> |
||||
</StackLayout> |
||||
</ScrollView> |
||||
</StackLayout> |
||||
</ContentPage> |
@ -0,0 +1,39 @@ |
||||
using Justice.Models; |
||||
using Justice.Views; |
||||
using Justice.Helpers; |
||||
|
||||
|
||||
namespace Justice.Views; |
||||
|
||||
public partial class AddContactPage : ContentPage |
||||
{ |
||||
private readonly DatabaseHelper _databaseHelper; |
||||
public AddContactPage() |
||||
{ |
||||
InitializeComponent(); |
||||
_databaseHelper = new DatabaseHelper(); |
||||
} |
||||
private async void OnSaveContactClicked(object sender, EventArgs e) |
||||
{ |
||||
try |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(NameEntry.Text) || string.IsNullOrWhiteSpace(MobileNumberEntry.Text) || GroupPicker.SelectedItem == null) |
||||
{ |
||||
await DisplayAlert("Error", "All Fields Required", "OK"); |
||||
} |
||||
var contact = new EmergencyContact |
||||
{ |
||||
Name = NameEntry.Text, |
||||
MobileNumber = MobileNumberEntry.Text, |
||||
Group = GroupPicker.SelectedItem.ToString() |
||||
}; |
||||
await _databaseHelper.InsertAsync(contact); |
||||
await DisplayAlert("Success", "Contact Saved Successfully", "OK"); |
||||
await Navigation.PushAsync(new EmergencyContactsPage()); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
await DisplayAlert("Success", $"{ex}", "OK"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
<?xml version="1.0" encoding="utf-8" ?> |
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
||||
x:Class="Justice.Views.EmergencyContactsPage" |
||||
Title="EmergencyContactsPage"> |
||||
<VerticalStackLayout> |
||||
<Label |
||||
Text="Welcome to .NET MAUI!" |
||||
VerticalOptions="Center" |
||||
HorizontalOptions="Center" /> |
||||
</VerticalStackLayout> |
||||
</ContentPage> |
@ -0,0 +1,15 @@ |
||||
using Justice.Helpers; |
||||
|
||||
namespace Justice.Views; |
||||
|
||||
public partial class EmergencyContactsPage : ContentPage |
||||
{ |
||||
private readonly DatabaseHelper _databaseHelper; |
||||
public EmergencyContactsPage() |
||||
{ |
||||
InitializeComponent(); |
||||
_databaseHelper = new DatabaseHelper(); |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue