-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Added Resource list and view pages. * Wired up resource list with profile view
- Loading branch information
1 parent
54d594a
commit c5efed5
Showing
5 changed files
with
207 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
crisischeckin/CrisisCheckinMobile/CrisisCheckinMobile/ResourceListPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CrisisCheckinMobile.ApiClient; | ||
using CrisisCheckinMobile.ViewModels; | ||
using Xamarin.Forms; | ||
|
||
namespace CrisisCheckinMobile | ||
{ | ||
//public class ResourceListPage : MasterDetailPage | ||
|
||
public class ResourceListPage : ContentPage | ||
{ | ||
private ListView _resourceListView; | ||
private EventHandler<SelectedItemChangedEventArgs> _itemSelectedEventHandler; | ||
|
||
public IEnumerable<ResourceListItemViewModel> ResourceList | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public ResourceListPage() | ||
{ | ||
var task = Init(); | ||
|
||
} | ||
|
||
private async Task Init() | ||
{ | ||
_itemSelectedEventHandler = (sender, args) => | ||
{ | ||
if (args.SelectedItem == null) | ||
return; | ||
|
||
var selectedItem = args.SelectedItem as ResourceListItemViewModel; | ||
|
||
Navigation.PushAsync(new ResourceViewPage(selectedItem)); | ||
|
||
}; | ||
|
||
BackgroundColor = Constants.HtBoxDarkBrown; | ||
|
||
Padding = new Thickness(0, Device.OnPlatform(20,0,0), 0, 0); | ||
|
||
Title = "Resources for: Big Disaster"; //TODO - Add Disaster Name | ||
|
||
// TODO: Get data from the API | ||
//ICrisisCheckInApiClient apiClient = new CrisisCheckInApiClient(); | ||
//var dtos = await apiClient.GetCommitmentsList(2); //TODO: wire up to Auth0 so we don't have to pass person ID | ||
//Data = dtos.Select(c => new DisasterListItemViewModel(c)); | ||
|
||
ResourceList = new List<ResourceListItemViewModel> | ||
{ | ||
new ResourceListItemViewModel | ||
{ | ||
Description = "Dump Truck", | ||
Type = "Heavy Machines", | ||
PersonFullName = "Bob Smith", | ||
Location_State = "Maine", | ||
Qty = 2 | ||
}, | ||
new ResourceListItemViewModel | ||
{ | ||
Description = "Poland Spring Water", | ||
Type = "Water", | ||
PersonFullName = "Mike Smith", | ||
Location_State = "Maine", | ||
Qty = 500 | ||
} | ||
}; | ||
|
||
_resourceListView = new ListView | ||
{ | ||
ItemsSource = ResourceList, | ||
BackgroundColor = Constants.HtBoxDarkBrown | ||
}; | ||
_resourceListView.ItemSelected += _itemSelectedEventHandler; | ||
var cell = new DataTemplate(typeof(TextCell)); | ||
cell.SetBinding(TextCell.TextProperty, new Binding("Type")); | ||
cell.SetBinding(TextCell.DetailProperty, new Binding("Description")); | ||
cell.SetValue(TextCell.TextColorProperty, Color.White); | ||
cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown); | ||
_resourceListView.ItemTemplate = cell; | ||
|
||
Content = _resourceListView; | ||
} | ||
|
||
~ResourceListPage() // TODO: put somewhere else? | ||
{ | ||
if (_resourceListView != null) | ||
{ | ||
_resourceListView.ItemSelected -= _itemSelectedEventHandler; | ||
} | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
crisischeckin/CrisisCheckinMobile/CrisisCheckinMobile/ResourceViewPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using CrisisCheckinMobile.ViewModels; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms; | ||
|
||
namespace CrisisCheckinMobile | ||
{ | ||
public class ResourceViewPage : ContentPage | ||
{ | ||
public ResourceViewPage(ResourceListItemViewModel resourceItem) | ||
{ | ||
var task = Init(resourceItem); | ||
} | ||
|
||
private async Task Init(ResourceListItemViewModel resourceItem) | ||
{ | ||
|
||
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); | ||
BackgroundColor = Constants.HtBoxDarkBrown; | ||
|
||
this.Title = resourceItem.Type; | ||
|
||
var descriptionLabel = new Label | ||
{ | ||
Text = resourceItem.Description, | ||
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), | ||
TextColor = Constants.HtBoxLightBrown | ||
}; | ||
|
||
var personLabel = new Label | ||
{ | ||
Text = $"Contact Person: {resourceItem.PersonFullName}", | ||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), | ||
TextColor = Color.White | ||
}; | ||
|
||
var stateLabel = new Label | ||
{ | ||
Text = $"State: {resourceItem.Location_State}", | ||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), | ||
TextColor = Color.White | ||
}; | ||
|
||
var quantityLabel = new Label | ||
{ | ||
Text = $"Qty: {resourceItem.Qty.ToString()}", | ||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), | ||
TextColor = Color.White | ||
}; | ||
|
||
Content = new ScrollView | ||
{ | ||
Content = new StackLayout | ||
{ | ||
Spacing = 10, | ||
Children = { descriptionLabel, personLabel, stateLabel, quantityLabel } | ||
} | ||
}; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ischeckin/CrisisCheckinMobile/CrisisCheckinMobile/ViewModels/ResourceListItemViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CrisisCheckinMobile.ViewModels | ||
{ | ||
public class ResourceListItemViewModel | ||
{ | ||
public int ResourceId { get; set; } | ||
public string Description { get; set; } | ||
public string Type { get; set; } | ||
public string PersonFullName { get; set; } | ||
public string Location_State { get; set; } | ||
public decimal Qty { get; set; } //TODO - can we have partial quantities, should this be an INT? | ||
|
||
|
||
//public DateTime StartOfAvailability { get; set; } | ||
//public DateTime EndOfAvailability { get; set; } | ||
//public string Location_BuildingName { get; set; } | ||
//public string Location_AddressLine1 { get; set; } | ||
//public string Location_AddressLine2 { get; set; } | ||
//public string Location_AddressLine3 { get; set; } | ||
//public string Location_City { get; set; } | ||
//public string Location_County { get; set; } | ||
//public string Location_State { get; set; } | ||
//public string Location_Country { get; set; } | ||
//public string Location_PostalCode { get; set; } | ||
//public decimal Qty { get; set; } //TODO - can we have partial quantities, should this be an INT? | ||
//public int Status { get; set; } | ||
//public int Allocator_OrganizationId { get; set; } | ||
//public int DisasterId { get; set; } | ||
//public int ResourceTypeId { get; set; } | ||
//public int PersonId { get; set; } | ||
//public DateTime EntryMade { get; set; } | ||
} | ||
} |