Browse Source

Improved Main Page Responsiveness
Improved Delivery List Layout
Fixed broke "Mark as Delivered" button in Delivery Edit

Frank van den Bos 1 year ago
parent
commit
d95e3d0f89

+ 1 - 1
prs.mobile.new/PRS.Mobile.Droid/Properties/AndroidManifest.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="739000" android:versionName="7.39.0" package="comal.timesheets.Android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="740000" android:versionName="7.40.0" package="comal.timesheets.Android">
 	<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="33" />
 	<queries>
 		<intent>

+ 1 - 1
prs.mobile.new/PRS.Mobile.iOS/Info.plist

@@ -27,7 +27,7 @@
 	<key>CFBundleIdentifier</key>
 	<string>com.prsdigital.prssiteapp</string>
 	<key>CFBundleVersion</key>
-	<string>7.39.0</string>
+	<string>7.40.0</string>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>CFBundleName</key>

+ 14 - 16
prs.mobile.new/PRS.Mobile/Data Models/Lists/Delivery/DeliveryShell.cs

@@ -17,11 +17,12 @@ namespace PRS.Mobile
                 .Map(nameof(_jobid), x => x.Job.ID)
                 .Map(nameof(_jobNumber), x => x.Job.JobNumber)
                 .Map(nameof(_jobName), x => x.Job.Name)
-                .Map(nameof(Date), x => x.Date)
                 .Map(nameof(ContactName), x => x.Contact.Name)
-                .Map(nameof(_booked), x => x.Assignment.Date)
-                .Map(nameof(_delivered), x => x.Delivered)
-                .Map(nameof(_due), x => x.Due)
+
+                .Map(nameof(Due), x => x.Due)
+                .Map(nameof(Booked), x => x.Assignment.Date)
+                .Map(nameof(Delivered), x => x.Delivered)
+
                 .Map(nameof(Address), x => x.Location.Address)
                 .Map(nameof(Latitude), x=>x.Address.Location.Latitude)
                 .Map(nameof(Longitude), x=>x.Address.Location.Longitude)
@@ -55,22 +56,19 @@ namespace PRS.Mobile
         public String Address => Get<String>();
         public String ContactName => Get<String>();
         
-        private DateTime _booked => Get<DateTime>();
-        private DateTime _due => Get<DateTime>();
-        private DateTime _delivered => Get<DateTime>();
-                
+        public DateTime Due => Get<DateTime>();
+        public DateTime Booked => Get<DateTime>();
+
+        public DateTime Delivered
+        {
+            get => Get<DateTime>();
+            set => Set(value);
+        }
+
         public String Job => _jobid != Guid.Empty 
             ? $"{_jobNumber}: {_jobName}" 
             : "";
         
-        public DateTime Date => _delivered.IsEmpty() 
-            ? _booked.IsEmpty() 
-                ? _due 
-                : _booked 
-            : _delivered;
-        
-        public DateTime Delivered => _delivered;
-
         public double Latitude => Get<double>();
         public double Longitude => Get<double>();
 

+ 28 - 41
prs.mobile.new/PRS.Mobile/MainPage.xaml.cs

@@ -62,6 +62,15 @@ namespace PRS.Mobile
             App.Data.BluetoothScanFinished += OnBluetothScanFinished;
             
             InitializeComponent();
+            
+            ProgressVisible = true;
+            
+            var logo = Path.Combine(CoreRepository.CacheFolder(), "logo.png");
+            if (File.Exists(logo))
+                _splash.Source = FileImageSource.FromFile(logo);
+            else
+                _splash.Source = ImageSource.FromFile("splash");
+            
             _profiles = new LocalConfiguration<MobileDatabaseSettings>().LoadAll();
             if (_profiles.Count > 1)
             {
@@ -86,7 +95,9 @@ namespace PRS.Mobile
                 _menu.Items.Add(settings);
             }
             
-            ProgressVisible = true;
+            BackButtonEnabled = App.IsSharedDevice;
+
+            SetupModules();
             
             // LocalNotificationCenter.Current.NotificationActionTapped += (Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e) =>
             // {
@@ -167,16 +178,8 @@ namespace PRS.Mobile
 
         protected override void OnAppearing()
         {
-                        
-            var logo = Path.Combine(CoreRepository.CacheFolder(), "logo.png");
-            if (File.Exists(logo))
-                _splash.Source = FileImageSource.FromFile(logo);
-            else
-                _splash.Source = ImageSource.FromFile("splash");
-            
             _pollingToken = new CancellationTokenSource();
-
-                
+            
             StartMonitoringNotifications();
             StartMonitoringTasks();
             StartMonitoringVersion();
@@ -185,27 +188,22 @@ namespace PRS.Mobile
             //ProgressVisible = false;
             if (_selectionpage == null)
             {
-                
-                //LoadHRToDos(); to be uncommented when ready for roll out
-
                 CheckTimeSheet();
             }
             
             _selectionpage = null;
 
             Task.WaitAll(_setuptasks);
-
-            ProgressVisible = false;
-
+            
             RefreshScreen();
             base.OnAppearing();
         }
         
         protected override void OnDisappearing()
         {
-            base.OnDisappearing();
-            
+            EnableModules(false);
             _pollingToken.Cancel();
+            base.OnDisappearing();
         }
         
         private void OnBluetothScanFinished(BluetoothEventArgs args)
@@ -259,9 +257,18 @@ namespace PRS.Mobile
         protected override void UpdateTransportStatus()
         {
             base.UpdateTransportStatus();
-            RefreshScreen();
+
+            EnableModules(App.Data.IsConnected());
         }
-        
+
+        private void EnableModules(bool enabled)
+        {
+            Tools.BeginUpdate();
+            foreach (var item in Tools.Items)
+                item.IsEnabled = enabled;
+            Tools.EndUpdate();
+        }
+
         private CancellationTokenSource _pollingToken = new CancellationTokenSource();
         
         private void StartMonitoringNotifications()
@@ -388,10 +395,6 @@ namespace PRS.Mobile
         
         private void RefreshScreen()
         {
-         
-            BackButtonEnabled = App.IsSharedDevice;
-
-            SetupModules();
             
             SetupClockOnButton(_settings.ClockOnDisabled);
             
@@ -432,23 +435,7 @@ namespace PRS.Mobile
                 ? $"{_currenttimesheet?.JobLink.JobNumber}: {_currenttimesheet?.JobLink.Name}"
                 : "Select Job";
             
-            Assignments.IsEnabled = App.Data.IsConnected();
-            Deliveries.IsEnabled = App.Data.IsConnected();
-            Equipment.IsEnabled = App.Data.IsConnected();
-            Manufacturing.IsEnabled = App.Data.IsConnected();
-            Forms.IsEnabled = App.Data.IsConnected();
-            InOut.IsEnabled = App.Data.IsConnected();
-            MyHR.IsEnabled = App.Data.IsConnected();
-            Meetings.IsEnabled = App.Data.IsConnected();
-            Notifications.IsEnabled = App.Data.IsConnected();
-            Products.IsEnabled = App.Data.IsConnected();
-            PurchaseOrders.IsEnabled = App.Data.IsConnected();
-            Scans.IsEnabled = App.Data.IsConnected();
-            Site.IsEnabled = App.Data.IsConnected();
-            StoreRequis.IsEnabled = App.Data.IsConnected();
-            MyTasks.IsEnabled = App.Data.IsConnected();
-            Warehousing.IsEnabled = App.Data.IsConnected();
-
+           
         }
         
         #endregion

+ 1 - 1
prs.mobile.new/PRS.Mobile/Modules/Deliveries/Edit/DeliveryEdit.xaml.cs

@@ -57,7 +57,7 @@ namespace PRS.Mobile
         {
             Device.BeginInvokeOnMainThread(() =>
             {
-                bool changed = Item.ID == Guid.Empty || Item.IsChanged();
+                bool changed = Item?.ID == Guid.Empty || Item?.IsChanged() == true;
                 _save.IsVisible = changed;
                 _image.IsVisible = !changed && Selector.SelectedItem?.Index == 3;
                 _form.IsVisible = !changed && Selector.SelectedItem?.Index == 4;

+ 10 - 3
prs.mobile.new/PRS.Mobile/Modules/Deliveries/Edit/Views/DeliveryEditDetailsView.xaml

@@ -9,6 +9,12 @@
     x:Class="PRS.Mobile.DeliveryEditDetailsView"
     x:DataType="local:DeliveryEditViewModel">
     
+    <local:DeliveryEditView.Resources>
+        <local:DeliveryDateConverter x:Key="DeliveryDateConverter"/>
+        <local:DeliveryCompletedConverter x:Key="DeliveryCompletedConverter"/>
+
+    </local:DeliveryEditView.Resources>
+    
     <local:DeliveryEditView.Content>
         
         <Grid RowSpacing="5">
@@ -24,7 +30,7 @@
 
             <mobile:MobileDateButton 
                 Grid.Row="0"
-                Date="{Binding Item.Date, StringFormat='{0:dd MMMM yy}'}" 
+                Date="{Binding Item, Converter={StaticResource DeliveryDateConverter}, StringFormat='{}{0:dd MMM yy}'}" 
                 HeightRequest="50" 
                 Prefix="Due:" />
 
@@ -108,8 +114,9 @@
             
             <mobile:MobileButton 
                 Grid.Row="6"
-                Text ="Complete" 
-                HeightRequest="50" />
+                Text ="{Binding Item, Converter={StaticResource DeliveryCompletedConverter}}" 
+                HeightRequest="50"
+                Clicked="Complete_Clicked"/>
             
         </Grid>
     </local:DeliveryEditView.Content>

+ 23 - 526
prs.mobile.new/PRS.Mobile/Modules/Deliveries/Edit/Views/DeliveryEditDetailsView.xaml.cs

@@ -13,6 +13,19 @@ using Xamarin.Essentials;
 
 namespace PRS.Mobile
 {
+
+    public class DeliveryCompletedConverter : UtilityConverter<DeliveryShell?, String>
+    {
+        protected override string Convert(DeliveryShell? value)
+        {
+            return value == null
+                ? ""
+                : value.Delivered.IsEmpty()
+                    ? "Mark as Delivered"
+                    : "Clear Delivery Flag";
+        }
+    }
+    
     public delegate void DeliverySaved();
     public partial class DeliveryEditDetailsView
     {
@@ -31,539 +44,23 @@ namespace PRS.Mobile
         public DeliveryEditDetailsView()
         {
             InitializeComponent();
-            
-        }
-
-        public override void Refresh()
-        {
-            RefreshPage();
         }
         
-        private void RefreshPage()
+        public override void Refresh()
         {
-            // JobName.Text = ViewModel.Item.Job
-            // TypeLbl.Text = _delivery.Type.Description;
-            // ContactNameLbl.Text = _delivery.Contact.Name;
-            // streetEdt.Text = _delivery.Address.Street;
-            // cityEdt.Text = _delivery.Address.City;
-            // statePicker.SelectedIndex = SelectState();
-            // postCodeEdt.Text = _delivery.Address.PostCode;
-            // EmployeeName.Text = _delivery.Employee.Name;
-            // deliveryNotesEdt.Text = _delivery.Notes;
-            // dueDate.Date = !_delivery.Due.IsEmpty()
-            //     ? _delivery.Due
-            //     : DateTime.Today;
-            //
-            // convertToTaskBtn.Text = _delivery.KanbanNumber != 0
-            //     ? "Saved To Task " + _delivery.KanbanNumber
-            //     : "Create Task";
-            // convertToTaskBtn.IsEnabled = (_delivery.ID != Guid.Empty) && (_delivery.KanbanNumber == 0);
-            //
-            // convertToTaskBtn.IsEnabled = _delivery.ID != Guid.Empty;
-            //
-            // CompleteDeliveryButton.IsEnabled = !_delivery.Delivered.IsEmpty() && (_delivery.ID != Guid.Empty);
-            //
-            // streetEdt.Text = _delivery.Contact.Address.Street;
-            // cityEdt.Text = _delivery.Contact.Address.City;
-            // postCodeEdt.Text = _delivery.Contact.Address.PostCode;
-            // ContactNameLbl.Text = _delivery.Contact.Name;
-            //                     
-            // EmployeeName.Text = _delivery.Employee.Name;
-            //                     
-            // if (_delivery.Location.Longitude != 0 && _delivery.Location.Latitude != 0)
-            // {
-            //     DeliveredFlagFrame.IsVisible = true;
-            //     DeliveredLbl.IsVisible = true;
-            //     DeliveredDetails.Text = "Loading Delivered Flag Details";
-            //     if (string.IsNullOrWhiteSpace(_delivery.Location.Address))
-            //     {
-            //         GetLocationFromDetails();
-            //     }
-            //     else
-            //         ShowDeliveredDetails(false);
-            // }
             
         }
         
-
-
-        
-        #region Create Delivery or add delivered flag
-        
-        // async void CreateDelivery()
-        // {
-        //     try
-        //     {
-        //         using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Saving Delivery"))
-        //         {
-        //             _delivery.Due = dueDate.Date; //unable to make duedate changed event without crashing the screen on startup....
-        //             new Client<Delivery>().Save(_delivery, "Updated From Mobile Device");
-        //
-        //             if (newPhotoDocuments.Count != 0)
-        //             {
-        //                 new Client<Document>().Save(newPhotoDocuments, "Photo Taken on Device");
-        //
-        //                 ObservableList<DeliveryDocument> newDeliveryDocuments = new ObservableList<DeliveryDocument>();
-        //                 foreach (Document doc in newPhotoDocuments)
-        //                 {
-        //                     var deliveryDocument = new DeliveryDocument();
-        //                     deliveryDocument.EntityLink.ID = _delivery.ID;
-        //                     deliveryDocument.DocumentLink.ID = doc.ID;
-        //                     deliveryDocument.DocumentLink.FileName = doc.FileName;
-        //                     newDeliveryDocuments.Add(deliveryDocument);
-        //                 }
-        //                 new Client<DeliveryDocument>().Save(newDeliveryDocuments, "Photo Taken on Device");
-        //                 newPhotoDocuments.Clear();
-        //             }
-        //         }
-        //         string successMessage = "Delivery Created" + System.Environment.NewLine + "Delivery Number: " + _delivery.Number;
-        //     }
-        //     catch (Exception ex)
-        //     {
-        //         await MaterialDialog.Instance.AlertAsync("Error creating delivery", ex.Message, "OK");
-        //     }
-        //     OnDeliverySaved?.Invoke();
-        //     await Navigation.PopAsync();
-        // }
-        //
-        // private async void CompleteDelivery()
-        // {
-        //     try
-        //     {
-        //         using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Getting Location..Please wait"))
-        //         {
-        //             LocationServices locationServices = new LocationServices();
-        //             locationServices.OnLocationFound += LocationFound;
-        //             locationServices.OnLocationError += LocationError;
-        //             locationServices.GetLocation();
-        //             Thread.Sleep(1000); //"Getting Location" notification disappears too quickly on some devices - ensures a minimum of 1 second while location tasks execute on other threads
-        //         }
-        //     }
-        //     catch { }
-        //
-        // }
-        //
-        // private async void LocationFound(LocationServices sender)
-        // {
-        //     try
-        //     {
-        //         using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Getting Location..Please wait"))
-        //         {
-        //             _delivery.Location.Latitude = sender.Latitude;
-        //             _delivery.Location.Longitude = sender.Longitude;
-        //             _delivery.Location.Timestamp = DateTime.Now;
-        //             _delivery.Location.Address = sender.Address;
-        //             _delivery.DeliveredBy.ID = App.Data.Me.ID;
-        //             _delivery.DeliveredBy.Name = App.Data.Me.Name;
-        //             address = sender.Address;
-        //             _delivery.Delivered = DateTime.Now;
-        //
-        //             await Task.Run(() =>
-        //             {
-        //                 new Client<Delivery>().Save(_delivery, "Updated From Mobile Device");
-        //             });
-        //         }
-        //         await MaterialDialog.Instance.AlertAsync("Success", "Delivered: " + _delivery.Delivered.ToString("hh:mm:ss tt dd-MMM-yy")
-        //         + System.Environment.NewLine + "Location Now: " + address
-        //         , "OK");
-        //         ShowDeliveredDetails();
-        //     }
-        //     catch { }
-        // }
-        //
-        // private async void LocationError(LocationServices sender, Exception error)
-        // {
-        //     await MaterialDialog.Instance.AlertAsync("GPS Error", error.Message, "OK");
-        // }
-        #endregion
-
-
-        #region Load Screen values from Database
-
-
-        // public IEnumerable<Placemark> Addresses
-        // {
-        //     get { return addresses; }
-        //     set { addresses = value; ShowDeliveredDetails(); }
-        // }
-        //
-        // private void ShowDeliveredDetails(bool wait = true)
-        // {
-        //     Task.Run(() =>
-        //     {
-        //         if (wait)
-        //         {
-        //             Thread.Sleep(5000);
-        //         }
-        //         Device.BeginInvokeOnMainThread(() =>
-        //         {
-        //             CompleteDeliveryButton.IsEnabled = false;
-        //             DeliveredFlagFrame.IsVisible = true;
-        //             DeliveredLbl.IsVisible = true;
-        //             if (string.IsNullOrWhiteSpace(address))
-        //             {
-        //                 if (!string.IsNullOrWhiteSpace(_delivery.Location.Address))
-        //                     address = _delivery.Location.Address;
-        //                 else
-        //                     address = "(Address service failed). Driver was at Latitude: " + _delivery.Location.Latitude + " Longitude: " + _delivery.Location.Longitude;
-        //             }
-        //             DeliveredDetails.Text = address + " at " + _delivery.Delivered.ToString("hh:mm:ss tt dd MMM yy") + System.Environment.NewLine
-        //             + "by: " + _delivery.DeliveredBy.Name;
-        //             openMapBtn.IsEnabled = true;
-        //         });
-        //     });
-        //     
-        // }
-
-        // private async void GetLocationFromDetails()
-        // {
-        //     await Task.Run(async () =>
-        //     {
-        //         try
-        //         {
-        //             Addresses = await Geocoding.GetPlacemarksAsync(_delivery.Location.Latitude, _delivery.Location.Longitude);
-        //             Placemark placemark = null;
-        //             foreach (var cur in Addresses)
-        //             {
-        //                 placemark = cur;
-        //                 if (placemark != null)
-        //                 {
-        //                     address = String.Format("{0} {1} {2}", placemark.SubThoroughfare, placemark.Thoroughfare, placemark.Locality);
-        //                     _delivery.Location.Address = address;
-        //                     return;
-        //                 }
-        //             }
-        //             
-        //         }
-        //         catch
-        //         {
-        //             address = "Longitude: " + _delivery.Location.Longitude + "Latitude: " + _delivery.Location.Latitude + " Address service failed to load address";
-        //         }
-        //     });
-        // }
-        //
-        // private async void OpenMapBtn_Clicked(object sender, EventArgs e)
-        // {
-        //     var location = new Xamarin.Essentials.Location(_delivery.Location.Latitude, _delivery.Location.Longitude);
-        //     var options = new MapLaunchOptions { };
-        //     await Map.OpenAsync(location, options);
-        // }
-
-         #endregion
-
-        #region Values Changed Events
-
-        // private async void SelectType_Clicked(object sender, EventArgs e)
-        // {
-        //     try
-        //     {
-        //         Dictionary<string, Guid> deliveryTypePairs = new Dictionary<string, Guid>();
-        //         List<string> _deliveryTypes = new List<string>();
-        //         var table = new Client<DeliveryType>().Query(new Filter<DeliveryType>(x => x.Description).IsNotEqualTo(string.Empty));
-        //         foreach (CoreRow row in table.Rows)
-        //         {
-        //             DeliveryType _deliveryType = row.ToObject<DeliveryType>();
-        //             _deliveryTypes.Add(_deliveryType.Description);
-        //             deliveryTypePairs.Add(_deliveryType.Description, _deliveryType.ID);
-        //         }
-        //         if (_deliveryTypes.Count != 0)
-        //         {
-        //             int choice = await MaterialDialog.Instance.SelectChoiceAsync("Choose Delivery Type", _deliveryTypes);
-        //             if (choice != -1)
-        //             {
-        //                 _delivery.Type.Description = _deliveryTypes[choice];
-        //                 TypeLbl.Text = _deliveryTypes[choice];
-        //                 _delivery.Type.ID = deliveryTypePairs[_deliveryTypes[choice]];
-        //             }
-        //         }
-        //     }
-        //     catch { }
-        // }
-
-        // private void SelectJob_Clicked(object sender, EventArgs e)
-        // {
-        //
-        //     _selectionpage = new JobSelectionPage(
-        //         (job) =>
-        //         {
-        //             _delivery.Job.ID = job.ID;
-        //             _delivery.Job.Name = job.Name;
-        //             _delivery.Job.JobNumber = job.JobNumber;
-        //             JobName.Text = _delivery.Job.Name + " (" + _delivery.Job.JobNumber + ")";
-        //         }
-        //     );
-        //     Navigation.PushAsync(_selectionpage);
-        // }
-
-        #region Address
-        
-        // private void StreetEdt_Changed(object sender, EventArgs e)
-        // {
-        //     _delivery.Address.Street = streetEdt.Text;
-        // }
-        //
-        // private void CityEdt_Changed(object sender, EventArgs e)
-        // {
-        //     _delivery.Address.City = cityEdt.Text;
-        // }
-        // private void StatePicker_Changed(object sender, EventArgs e)
-        // {
-        //     _delivery.Address.State = statePicker.SelectedItem.ToString();
-        // }
-        // private void PostCode_Changed(object sender, EventArgs e)
-        // {
-        //     _delivery.Address.PostCode = postCodeEdt.Text;
-        // }
-        //
-        //
-        //
-        // private int SelectState()
-        // {
-        //     int state = 0;
-        //     switch (_delivery.Address.State)
-        //     {
-        //         case "Western Australia":
-        //             state = 0;
-        //             break;
-        //         case "Victoria":
-        //             state = 1;
-        //             break;
-        //         case "South Australia":
-        //             state = 2;
-        //             break;
-        //         case "New South Wales":
-        //             state = 3;
-        //             break;
-        //         case "Queensland":
-        //             state = 4;
-        //             break;
-        //         case "Tasmania":
-        //             state = 5;
-        //             break;
-        //         default:
-        //             state = 0;
-        //             break;
-        //     }
-        //     return state;
-        // }
-
-        #endregion Address
-
-        // private async void SelectContact_Clicked(object sender, EventArgs e)
-        // {
-        //     _selectionpage = new ContactSelectionPage(
-        //         (contact) =>
-        //         {
-        //             if (contact != null)
-        //             {
-        //                 _delivery.Contact.Address.Street = contact.Street;
-        //                 _delivery.Contact.Address.City = contact.City;
-        //                 _delivery.Contact.Address.PostCode = contact.PostCode;
-        //                 _delivery.Contact.Address.State = contact.State;
-        //             }
-        //         }
-        //     );
-        //     Navigation.PushAsync(_selectionpage);
-        // }
-        //
-        // private void SelectCustomerPage()
-        // {
-        //     //if (_searching)
-        //     //    return;
-        //     //else
-        //     //{
-        //     //    _searching = true;
-        //     //    GenericSelectionPage page = new GenericSelectionPage
-        //     // (
-        //     // "Select Customer",
-        //     // new SelectionViewModel<CustomerContact>
-        //     // (
-        //     // new Filter<CustomerContact>(x => x.Contact.ID).IsNotEqualTo(Guid.Empty).And(x => x.Contact.Address.Street).IsNotEqualTo(string.Empty),
-        //     // new Expression<Func<CustomerContact, object>>[] { x => x.Contact.Name, x => x.Contact.Address.Street, x => x.Contact.Address.City },
-        //     // new Expression<Func<CustomerContact, object>>[] { x => x.Contact.Address.PostCode, x => x.Contact.ID, x => x.Contact },
-        //     // new SortOrder<CustomerContact>(x => x.Contact.Name)
-        //     // ));
-        //     //    page.OnItemSelected += (row) =>
-        //     //    {
-        //     //        var customerContact = row.ToObject<CustomerContact>();
-        //     //        _delivery.Contact.Address.Street = customerContact.Contact.Address.Street;
-        //     //        _delivery.Contact.Address.City = customerContact.Contact.Address.City;
-        //     //        _delivery.Contact.Address.PostCode = customerContact.Contact.Address.PostCode;
-        //     //        _delivery.Contact.Address.State = customerContact.Contact.Address.State;
-        //     //        Device.BeginInvokeOnMainThread(() =>
-        //     //        {
-        //     //            streetEdt.Text = _delivery.Contact.Address.Street;
-        //     //            cityEdt.Text = _delivery.Contact.Address.City;
-        //     //            postCodeEdt.Text = _delivery.Contact.Address.PostCode;
-        //     //            ContactNameLbl.Text = _delivery.Contact.Name;
-        //     //        });
-        //     //    };
-        //     //    Navigation.PushAsync(page);
-        //     //}
-        // }
-        //
-        // private void SelectSupplierPage()
-        // {
-        //     //if (_searching)
-        //     //    return;
-        //     //else
-        //     //{
-        //     //    _searching = true;
-        //     //    GenericSelectionPage page = new GenericSelectionPage
-        //     // (
-        //     // "Select Supplier",
-        //     // new SelectionViewModel<SupplierContact>
-        //     // (
-        //     // new Filter<SupplierContact>(x => x.Contact.ID).IsNotEqualTo(Guid.Empty).And(x =>x.Contact.Address.Street).IsNotEqualTo(string.Empty),
-        //     // new Expression<Func<SupplierContact, object>>[] { x => x.Contact.Name, x => x.Contact.Address.Street, x => x.Contact.Address.City },
-        //     // new Expression<Func<SupplierContact, object>>[] { x => x.Contact.Address.PostCode, x => x.Contact.ID, x => x.Contact },
-        //     // new SortOrder<SupplierContact>(x => x.Contact.Name)
-        //     // ));
-        //     //    page.OnItemSelected += (row) =>
-        //     //    {
-        //     //        SupplierContact supplierContact = row.ToObject<SupplierContact>();
-        //     //        _delivery.Contact.ID = supplierContact.Contact.ID;
-        //     //        _delivery.Contact.Address.Street = supplierContact.Contact.Address.Street;
-        //     //        _delivery.Contact.Address.City = supplierContact.Contact.Address.City;
-        //     //        _delivery.Contact.Address.PostCode = supplierContact.Contact.Address.PostCode;
-        //     //        _delivery.Contact.Address.State = supplierContact.Contact.Address.State;
-        //     //        Device.BeginInvokeOnMainThread(() =>
-        //     //        {
-        //     //            streetEdt.Text = _delivery.Contact.Address.Street;
-        //     //            cityEdt.Text = _delivery.Contact.Address.City;
-        //     //            postCodeEdt.Text = _delivery.Contact.Address.PostCode;
-        //     //            ContactNameLbl.Text = _delivery.Contact.Name;
-        //     //        });                   
-        //
-        //     //    };
-        //     //    Navigation.PushAsync(page);
-        //     //}
-        // }
-        //
-        //
-        // private void SelectEmployee_Clicked(object sender, EventArgs e)
-        // {
-        //     _selectionpage = new EmployeeSelectionPage(
-        //         (employee) =>
-        //         {
-        //             if (employee != null)
-        //             {
-        //                 _delivery.Employee.ID = employee.ID;
-        //                 _delivery.Employee.Name = employee.Name;
-        //             }
-        //         }
-        //     );
-        //     Navigation.PushAsync(_selectionpage);
-        // }
-        //
-        // private void DeliveryNotes_Completed(object sender, EventArgs e)
-        // {
-        //     _delivery.Notes = deliveryNotesEdt.Text;
-        // }
-        #endregion
-        
-        #region last row buttons
-        // void ConvertToTaskBtn_Clicked(Object sender, EventArgs e)
-        // {
-        //     _selectionpage = new EmployeeSelectionPage(
-        //         (employee) =>
-        //         {
-        //             if (employee != null)
-        //             {
-        //                 Kanban kanban = new Kanban();
-        //                 kanban.EmployeeLink.ID = employee.ID;
-        //                 ConfirmPerson(employee.Name, kanban);
-        //             }
-        //         }
-        //     );
-        //     Navigation.PushAsync(_selectionpage);
-        // }
-        //
-        // async void ConfirmPerson(string name, Kanban kanban)
-        // {
-        //     var confirm = await MaterialDialog.Instance.ConfirmAsync("Confirm send to " + name);
-        //     if (confirm == true)
-        //         CreateKanban(kanban);
-        // }
-
-        // async void CreateKanban(Kanban kanban)
-        // {
-        //     try
-        //     {
-        //         convertToTaskBtn.Text = "Saving..";
-        //         convertToTaskBtn.IsEnabled = false;
-        //         await Task.Run(() =>
-        //         {
-        //             kanban.ManagerLink.ID = App.Data.Me.ID;
-        //             kanban.Title = "Delivery " + _delivery.Number + System.Environment.NewLine +
-        //             "Delivery Type: " + _delivery.Type.Description + System.Environment.NewLine +
-        //             App.Data.Me.Name + " converted to Task for further action";
-        //             kanban.DueDate = DateTime.Today;
-        //             kanban.Category = "Open";
-        //             if (!_delivery.Job.ID.Equals(Guid.Empty)) kanban.JobLink.ID = _delivery.Job.ID;
-        //             kanban.Description = _delivery.Notes;
-        //
-        //             new Client<Kanban>().Save(kanban, "Kanban Created from Deliveries Module");
-        //             _delivery.KanbanNumber = kanban.Number;
-        //             new Client<Delivery>().Save(_delivery, "Updated From Mobile Device");
-        //
-        //             List<KanbanDocument> kanbanDocuments = new List<KanbanDocument>();
-        //
-        //             if (existingDocumentIDs.Count != 0)
-        //             {
-        //                 foreach (Guid id in existingDocumentIDs)
-        //                 {
-        //                     KanbanDocument kanbanDocument = new KanbanDocument();
-        //                     kanbanDocument.DocumentLink.ID = id;
-        //                     kanbanDocument.EntityLink.ID = kanban.ID;
-        //                     kanbanDocuments.Add(kanbanDocument);
-        //                 }
-        //             }
-        //
-        //
-        //             if (kanbanDocuments.Count != 0)
-        //             {
-        //                 new Client<KanbanDocument>().Save(kanbanDocuments, "Updated from mobile device");
-        //             }
-        //
-        //
-        //
-        //             List<KanbanSubscriber> subscribers = new List<KanbanSubscriber>();
-        //
-        //             KanbanSubscriber sub1 = new KanbanSubscriber();
-        //             sub1.Kanban.ID = kanban.ID;
-        //             sub1.Employee.ID = kanban.EmployeeLink.ID;
-        //             sub1.Assignee = true;
-        //             subscribers.Add(sub1);
-        //
-        //             //KanbanSubscriber sub2 = new KanbanSubscriber();
-        //             //sub2.Kanban.ID = kanban.ID;
-        //             //sub2.Employee.ID = kanban.ManagerLink.ID;
-        //             //sub2.Manager = true;
-        //             //if (sub2.Employee.ID != sub1.Employee.ID)
-        //             //    subscribers.Add(sub2);
-        //
-        //             new Client<KanbanSubscriber>().Save(subscribers, "Updated from mobile device");
-        //
-        //             Device.BeginInvokeOnMainThread(() =>
-        //             {
-        //                 convertToTaskBtn.Text = "Saved To Task " + kanban.Number;
-        //             });
-        //         });
-        //
-        //         //save kanban - return kanban ID
-        //         //load list of photos - save as kanbandocs
-        //         //save subscribers
-        //     }
-        //     catch { }
-        // }
-        //
-
-        #endregion
-
-        private void MobileButton_OnClicked(object sender, MobileButtonClickEventArgs args)
+        private void Complete_Clicked(object sender, MobileButtonClickEventArgs args)
         {
-            
+            if (ViewModel.Item == null)
+                return;
+            ViewModel.Item.Delivered = ViewModel.Item.Delivered.IsEmpty()
+                ? DateTime.Now
+                : DateTime.MinValue;
+            (sender as MobileButton).BindingContext = null;
+            (sender as MobileButton).BindingContext = ViewModel;
+            DoChanged(nameof(ViewModel.Item.Delivered));
         }
 
 

+ 4 - 0
prs.mobile.new/PRS.Mobile/Modules/Deliveries/Edit/Views/DeliveryEditItemsView.xaml

@@ -63,6 +63,7 @@
                                     Text="{Binding Description}"
                                     FontAttributes="Bold"
                                     FontSize="Small"
+                                    TextColor="Black"
                                     Grid.Row="0"
                                     Grid.Column="0"
                                     LineBreakMode="TailTruncation"
@@ -72,6 +73,7 @@
                                     Text="{Binding Setout, StringFormat='Setout: {0}'}"
                                     FontAttributes="Italic"
                                     FontSize="Micro"
+                                    TextColor="Black"
                                     Grid.Row="1"
                                     Grid.Column="0"
                                     LineBreakMode="TailTruncation"
@@ -81,6 +83,7 @@
                                     Text="{Binding Rack, StringFormat='Rack #{0}'}"
                                     FontAttributes="Italic"
                                     FontSize="Micro"
+                                    TextColor="Black"
                                     Grid.Row="1"
                                     Grid.Column="1"
                                     LineBreakMode="TailTruncation"
@@ -90,6 +93,7 @@
                                     Text="{Binding Requi, StringFormat='Requi #{0}'}"
                                     FontAttributes="Italic"
                                     FontSize="Micro"
+                                    TextColor="Black"
                                     Grid.Row="1"
                                     Grid.Column="2"
                                     LineBreakMode="WordWrap"

+ 34 - 40
prs.mobile.new/PRS.Mobile/Modules/Deliveries/List/DeliveryList.xaml

@@ -10,9 +10,11 @@
 >
     
     <mobile:MobilePage.Resources>
-        <mobile:DateTimeToBooleanConverter x:Key="DeliveredConverter" EmptyResult="False"/>
-        <mobile:DateTimeToBooleanConverter x:Key="OpenConverter" EmptyResult="True"/>
+        <local:DeliveryColorConverter x:Key="DeliveryBackgroundConverter" Delivered="DimGray" Booked="LightGreen" Due="LightGray" />
+        <local:DeliveryColorConverter x:Key="DeliveryForegroundConverter" Delivered="WhiteSmoke" Booked="Black" Due="DimGray" />
         <local:DeliveryDescriptionConverter x:Key="DeliveryDescriptionConverter"/>
+        <local:DeliveryDateConverter x:Key="DeliveryDateConverter"/>
+        <local:DeliveryStatusConverter x:Key="DeliveryStatusConverter"/>
     </mobile:MobilePage.Resources>
     
     <mobile:MobilePage.PrimaryMenu>
@@ -50,15 +52,16 @@
 
                         <mobile:MobileCard
                             IsClickable="True"
-                            Clicked="Delivery_Clicked">
+                            Clicked="Delivery_Clicked"
+                            BackgroundColor="{Binding ., Converter={StaticResource DeliveryBackgroundConverter}}"
+                            Padding="5">
                             
                             <Grid x:DataType="local:DeliveryShell">
                         
                                 <Grid.ColumnDefinitions>
-                                    <ColumnDefinition Width="40" />
+                                    <ColumnDefinition Width="Auto" />
                                     <ColumnDefinition Width="*" />
-                                    <ColumnDefinition Width="80" />                            
-                                    <ColumnDefinition Width="40" />
+                                    <ColumnDefinition Width="Auto" />                            
                                 </Grid.ColumnDefinitions>
         
                                 <Grid.RowDefinitions>
@@ -71,7 +74,7 @@
                                     Grid.Row="0"
                                     Grid.Column="0"
                                     FontSize="Small"
-                                    TextColor="Black"
+                                    TextColor="{Binding ., Converter={StaticResource DeliveryForegroundConverter}}"
                                     LineHeight="1"
                                     HorizontalTextAlignment="Center"/>
                                 
@@ -80,50 +83,41 @@
                                     Grid.Row="0"
                                     Grid.Column="1"
                                     FontSize="Small"
-                                    TextColor="Black"
+                                    TextColor="{Binding ., Converter={StaticResource DeliveryForegroundConverter}}"
                                     LineHeight="1"
-                                    HorizontalTextAlignment="Center"/>
-        
+                                    HorizontalTextAlignment="Start"
+                                    LineBreakMode="TailTruncation"/>
+                                
                                 <Label  
-                                    Text="{Binding Address}"
-                                    Grid.Row="1"
-                                    Grid.Column="0"
-                                    Grid.ColumnSpan="2"
+                                    Text="{Binding ., Converter={StaticResource DeliveryStatusConverter}}"
+                                    Grid.Row="0"
+                                    Grid.Column="2"
                                     FontSize="Small"
-                                    TextColor="Black"
+                                    TextColor="{Binding ., Converter={StaticResource DeliveryForegroundConverter}}"
                                     LineHeight="1"
-                                    LineBreakMode="TailTruncation"/>
-        
+                                    HorizontalTextAlignment="Center"/>
+                                
                                 <Label  
-                                    Text="{Binding Date, StringFormat='{}{0:dd/MM/yy}'}"
-                                    Grid.Row="0"
+                                    Text="{Binding ., Converter={StaticResource DeliveryDateConverter}, StringFormat='{}{0:dd MMM yy}'}"
+                                    Grid.Row="1"
                                     Grid.Column="2"
                                     FontSize="Small"
-                                    TextColor="Black"
+                                    TextColor="{Binding ., Converter={StaticResource DeliveryForegroundConverter}}"
                                     LineHeight="1"
                                     HorizontalTextAlignment="Center"/>
         
-                                <Image 
-                                    Source="tick"
-                                    Grid.Column="3"
-                                    Grid.Row="0"
-                                    Grid.RowSpan="2"
-                                    IsVisible="{Binding Delivered, Converter={StaticResource DeliveredConverter}}"
-                                    HeightRequest="40"
-                                    WidthRequest="40"
-                                    Margin="5"/>
+                                <Label  
+                                    Text="{Binding Address}"
+                                    Grid.Row="1"
+                                    Grid.Column="0"
+                                    Grid.ColumnSpan="2"
+                                    FontSize="Micro"
+                                    FontAttributes="Italic"
+                                    TextColor="{Binding ., Converter={StaticResource DeliveryForegroundConverter}}"
+                                    LineHeight="1"
+                                    LineBreakMode="WordWrap"/>
+
                                 
-                                <Image 
-                                    Source="circle_gray"
-                                    Grid.Column="3"
-                                    Grid.Row="0"
-                                    Grid.RowSpan="2"
-                                    IsVisible="{Binding Delivered, Converter={StaticResource OpenConverter}}"
-                                    HeightRequest="40"
-                                    WidthRequest="40"
-                                    Opacity="0.05"
-                                    Margin="5"/>
-        
                             </Grid>    
 
                         </mobile:MobileCard>

+ 54 - 9
prs.mobile.new/PRS.Mobile/Modules/Deliveries/List/DeliveryList.xaml.cs

@@ -28,6 +28,55 @@ namespace PRS.Mobile
                 : "";
         }
     }
+
+    public class DeliveryDateConverter : UtilityConverter<DeliveryShell?, DateTime>
+    {
+        protected override DateTime Convert(DeliveryShell? value)
+        {
+            return value == null
+                ? DateTime.MinValue
+                : !value.Delivered.IsEmpty()
+                    ? value.Delivered
+                    : !value.Booked.IsEmpty()
+                        ? value.Booked
+                        : value.Due;
+        }
+    }
+    public class DeliveryStatusConverter : UtilityConverter<DeliveryShell?, String>
+    {
+        
+        protected override String Convert(DeliveryShell? value)
+        {
+            return value == null
+                ? ""
+                : !value.Delivered.IsEmpty()
+                    ? "DELIVERED"
+                    : !value.Booked.IsEmpty()
+                        ? "BOOKED"
+                        : "DUE";
+        }
+    }
+    
+    
+    public class DeliveryColorConverter : UtilityConverter<DeliveryShell?, Color>
+    {
+        
+        public Color Delivered { get; set; }
+        public Color Booked { get; set; }
+        public Color Due { get; set; }
+        public Color Unknown { get; set; }
+        
+        protected override Color Convert(DeliveryShell? value)
+        {
+            return value == null
+                ? Unknown
+                : !value.Delivered.IsEmpty()
+                    ? Delivered
+                    : !value.Booked.IsEmpty()
+                        ? Booked
+                        : Due;
+        }
+    }
     
     public class DeliveryModuleSettings : ILocalConfigurationSettings
     {
@@ -65,17 +114,14 @@ namespace PRS.Mobile
                     var text = (sender as MobileMenuItem)?.Text ?? "";
                     _settings.FilterName = text;
                     new LocalConfiguration<DeliveryModuleSettings>().Save(_settings);
-                    App.Data.Deliveries.SelectFilter(text);
-                    
-                    RefreshData(true, false);
+                    RefreshData(true, true);
                 };
                 _filter.Items.Add(item);
             }
             _filter.IsVisible = _filter.Items.Any();
-            
-            RefreshData(false, true);
         }
 
+
         private void RefreshData(bool force, bool async)
         {
             App.Data.Deliveries.SelectFilter(_settings.FilterName);     
@@ -94,7 +140,8 @@ namespace PRS.Mobile
         {
             Title = String.IsNullOrWhiteSpace(_settings.FilterName) ? "Delivery List" : _settings.FilterName;
             App.Data.Deliveries.Search(FilterShell);
-            _deliveries.ItemsSource ??= App.Data.Deliveries.Items;
+            _deliveries.ItemsSource = null;
+            _deliveries.ItemsSource = App.Data.Deliveries.Items;
         }
 
 
@@ -133,11 +180,9 @@ namespace PRS.Mobile
         {
             base.OnAppearing();
             if ((_newshell != null) && (_newshell.ID != Guid.Empty))
-            {
                 App.Data.Deliveries.CommitItem(_newshell);
-                Refresh();
-            }
             _newshell = null;
+            RefreshData(false, true);
         }
         
         private void AddDelivery_OnClicked(object sender, MobileMenuButtonClickedEventArgs args)