Skip to content

Commit

Permalink
Item #656 - Add/View Resources (#673)
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
fhilton authored and BillWagner committed Jun 19, 2016
1 parent 54d594a commit c5efed5
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
</Compile>
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceListPage.cs" />
<Compile Include="ResourceViewPage.cs" />
<Compile Include="SaveLoad\Serialize.cs" />
<Compile Include="SaveLoad\ISaveAndLoad.cs" />
<Compile Include="App.cs" />
<Compile Include="ViewModels\ProfileViewModel.cs" />
<Compile Include="ViewModels\CommitmentViewModel.cs" />
<Compile Include="ViewModels\DisasterListItemViewModel.cs" />
<Compile Include="Views\ProfileView.xaml.cs">
<DependentUpon>ProfileView.xaml</DependentUpon>
</Compile>
Expand All @@ -72,6 +72,9 @@
<Compile Include="Views\RegistrationPage.xaml.cs">
<DependentUpon>RegistrationPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\CommitmentViewModel.cs" />
<Compile Include="ViewModels\DisasterListItemViewModel.cs" />
<Compile Include="ViewModels\ResourceListItemViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Fusillade, Version=0.6.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
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;
}
}
}
}
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 }
}
};

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ICommand GoToViewDisasterResources
return new Command(async () =>
{
//TODO
await navigation.PushAsync(new TemporaryView());
await navigation.PushAsync(new ResourceListPage());
});
}
}
Expand Down
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; }
}
}

0 comments on commit c5efed5

Please sign in to comment.