Browse Source

Improved Signature Pad in Digital Forms
Added Progress Indicator in Site Forms Module
Fixed Crash in Digital Forms Option View

Frank van den Bos 1 year ago
parent
commit
89d9d9da48

+ 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="726100" android:versionName="7.26.1" package="comal.timesheets.Android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="727100" android:versionName="7.27.1" 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.26.1</string>
+	<string>7.27.1</string>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>CFBundleName</key>

+ 8 - 0
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/DigitalFormHost.xaml.cs

@@ -39,6 +39,7 @@ namespace PRS.Mobile
             
             
             InitializeComponent();
+            ProgressVisible = true;
             
             NavigationPage.SetHasBackButton(this, false);
             
@@ -74,6 +75,12 @@ namespace PRS.Mobile
             formViewerScroller.Content = viewer;
         }
 
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+            ProgressVisible = false;
+        }
+
         private void ExitBtn_Clicked(object sender, EventArgs e)
         {
             RetainedResults.IsFormRetained = false;
@@ -146,6 +153,7 @@ namespace PRS.Mobile
                             RetainedResults.RetainedFormName = Model.DigitalFormLayout.Description;
                             RetainedResults.Results = new Dictionary<string, string>();
                         }
+                        
                         using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Saving"))
                         {
                             viewer.SaveData(saveForLater);

+ 87 - 105
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/QAFormViewer.cs

@@ -1016,6 +1016,9 @@ namespace PRS.Mobile
             View view = null;
             DFLayoutSignaturePad dFLayoutSignaturePad = element as DFLayoutSignaturePad;
             var isrequired = dFLayoutSignaturePad.Properties.Required;
+            
+            // if we have a value, then show the image
+            // We need a clear button to be able to reset it
             if (loadData.TryGetValue(dFLayoutSignaturePad.Name, out value))
             {
                 if (!string.IsNullOrWhiteSpace(value))
@@ -1025,52 +1028,40 @@ namespace PRS.Mobile
                     embeddedImageCapture.DataToImage(data);
                     view = embeddedImageCapture;
                     view.IsEnabled = false;
+                    view.HeightRequest = 200;
                 }
             }
             else
             {
-                SfSignaturePad signaturePad = new SfSignaturePad();
-                EmbeddedImageCapture hiddenEmbeddedImageCapture = new EmbeddedImageCapture() { HeightRequest = 200, IsVisible = false, IsEnabled = false };
-                if (isrequired) signaturePad.BackgroundColor = isRequiredColor;
-                signaturePad.MinimumHeightRequest = 200;
-                signaturePad.MinimumStrokeWidth = 0.2;
-                signaturePad.MaximumStrokeWidth = 17;
-                Button clearButton = new Button()
+                // If we don't have a value, show the signaturepad + utility buttons
+                SfSignaturePad signaturePad = new SfSignaturePad()
                 {
-                    Text = "Clear",
-                    HorizontalOptions = LayoutOptions.FillAndExpand,
-                    VerticalOptions = LayoutOptions.End,
-                    Margin = 0,
-                    BackgroundColor = Color.FromHex("#15C7C1"),
-                    FontAttributes = FontAttributes.Bold,
-                    TextColor = Color.White,
-                    CornerRadius = 5,
-                    Padding = 1
+                    MinimumStrokeWidth = 0.2,
+                    MaximumStrokeWidth = 17
                 };
-                clearButton.Clicked += (object sender, EventArgs e) =>
+                if (isrequired) 
+                    signaturePad.BackgroundColor = isRequiredColor;
+                signaturePad.SetValue(Grid.ColumnProperty,0);
+                signaturePad.SetValue(Grid.ColumnSpanProperty,3);
+                signaturePad.SetValue(Grid.RowProperty,0);
+                
+                EmbeddedImageCapture hiddenEmbeddedImageCapture = new EmbeddedImageCapture()
                 {
-                    signaturePad.IsVisible = true;
-                    hiddenEmbeddedImageCapture.IsVisible = false;
-                    useSavedSignatures.Remove(dFLayoutSignaturePad.Name);
-                    signaturePad.Clear();
+                    IsVisible = false, 
+                    IsEnabled = false
                 };
-                Grid.SetColumn(clearButton, 2);
-
-                Button signNowButton = new Button()
+                hiddenEmbeddedImageCapture.SetValue(Grid.ColumnProperty,0);
+                hiddenEmbeddedImageCapture.SetValue(Grid.ColumnSpanProperty,3);
+                hiddenEmbeddedImageCapture.SetValue(Grid.RowProperty,0);
+                
+                MobileButton createSignatureButton = new MobileButton()
                 {
-                    Text = "Apply Saved",
-                    HorizontalOptions = LayoutOptions.FillAndExpand,
-                    VerticalOptions = LayoutOptions.End,
-                    Margin = 0,
-                    BackgroundColor = Color.FromHex("#15C7C1"),
-                    FontAttributes = FontAttributes.Bold,
-                    TextColor = Color.White,
-                    CornerRadius = 5,
-                    Padding = 1
+                    Text = "Save New"
                 };
-                signNowButton.Clicked += (object sender, EventArgs e) =>
+                createSignatureButton.Clicked += (sender, args) =>
                 {
-                    if (Application.Current.Properties.ContainsKey("SavedSignature"))
+                    SignatureSaver saver = new SignatureSaver();
+                    saver.OnSignatureSaved += () =>
                     {
                         Task.Run(() =>
                         {
@@ -1081,26 +1072,19 @@ namespace PRS.Mobile
                         hiddenEmbeddedImageCapture.IsVisible = true;
                         if (!useSavedSignatures.Contains(dFLayoutSignaturePad.Name))
                             useSavedSignatures.Add(dFLayoutSignaturePad.Name);
-                    }
+                    };
+                    Navigation.PushAsync(saver);
                 };
-                Grid.SetColumn(signNowButton, 1);
-
-                Button createSignatureButton = new Button()
-                {
-                    Text = "Save New",
-                    HorizontalOptions = LayoutOptions.FillAndExpand,
-                    VerticalOptions = LayoutOptions.End,
-                    Margin = 0,
-                    BackgroundColor = Color.FromHex("#15C7C1"),
-                    FontAttributes = FontAttributes.Bold,
-                    TextColor = Color.White,
-                    CornerRadius = 5,
-                    Padding = 1
+                createSignatureButton.SetValue(Grid.ColumnProperty,0);
+                createSignatureButton.SetValue(Grid.RowProperty,1);
+                
+                MobileButton signNowButton = new MobileButton()
+                {
+                    Text = "Apply Saved",
                 };
-                createSignatureButton.Clicked += (object sender, EventArgs e) =>
+                signNowButton.Clicked += (sender, args) =>
                 {
-                    SignatureSaver saver = new SignatureSaver();
-                    saver.OnSignatureSaved += () =>
+                    if (Application.Current.Properties.ContainsKey("SavedSignature"))
                     {
                         Task.Run(() =>
                         {
@@ -1111,28 +1095,38 @@ namespace PRS.Mobile
                         hiddenEmbeddedImageCapture.IsVisible = true;
                         if (!useSavedSignatures.Contains(dFLayoutSignaturePad.Name))
                             useSavedSignatures.Add(dFLayoutSignaturePad.Name);
-                    };
-                    Navigation.PushAsync(saver);
+                    }
                 };
-                Grid.SetColumn(createSignatureButton, 0);
-
-                Grid buttonsGrid = new Grid { Margin = 0, Padding = 0, VerticalOptions = LayoutOptions.End };
-                buttonsGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
-                buttonsGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
-                buttonsGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
-                buttonsGrid.Children.Add(createSignatureButton);
-                buttonsGrid.Children.Add(signNowButton);
-                buttonsGrid.Children.Add(clearButton);
-
-                Grid grid = new Grid() { Margin = 0, Padding = 0 };
-                grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(200, GridUnitType.Absolute) });
-                Grid.SetRow(signaturePad, 0);
-                Grid.SetRow(hiddenEmbeddedImageCapture, 0);
-
-                grid.Children.Add(hiddenEmbeddedImageCapture);
+                signNowButton.SetValue(Grid.ColumnProperty,1);
+                signNowButton.SetValue(Grid.RowProperty,1);
+                
+                MobileButton clearButton = new MobileButton()
+                {
+                    Text = "Clear",
+                };
+                clearButton.Clicked += (sender, args) => 
+                {
+                    signaturePad.IsVisible = true;
+                    hiddenEmbeddedImageCapture.IsVisible = false;
+                    useSavedSignatures.Remove(dFLayoutSignaturePad.Name);
+                    signaturePad.Clear();
+                };
+                clearButton.SetValue(Grid.ColumnProperty,2);
+                clearButton.SetValue(Grid.RowProperty,1);
+                
+                Grid grid = new Grid { Padding = 5, ColumnSpacing = 5 };
+                grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(200, GridUnitType.Absolute) });
+                grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Absolute) });
+                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
+                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
+                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
+                
                 grid.Children.Add(signaturePad);
-                grid.Children.Add(buttonsGrid);
-
+                grid.Children.Add(hiddenEmbeddedImageCapture);
+                grid.Children.Add(createSignatureButton);
+                grid.Children.Add(signNowButton);
+                grid.Children.Add(clearButton);
+                
                 view = grid;
             }
 
@@ -1293,7 +1287,8 @@ namespace PRS.Mobile
                 if (element is DFLayoutField)
                 {
                     pairs[element as DFLayoutField] = view;
-                    if (isSecure || readOnly || !string.IsNullOrWhiteSpace((element as DFLayoutField).GetPropertyValue<string>("Expression")))
+                    if (isSecure || readOnly ||
+                        !string.IsNullOrWhiteSpace((element as DFLayoutField).GetPropertyValue<string>("Expression")))
                         view.IsEnabled = false;
 
                     if (requiresFrame)
@@ -1325,7 +1320,9 @@ namespace PRS.Mobile
                 }
 
                 if (element.Row > 0)
-                    SetRow(view, element.Row - 1); //rows and columns coming in from the desktop designer start from 1, not 0 (most of the time??)
+                    SetRow(view,
+                        element.Row -
+                        1); //rows and columns coming in from the desktop designer start from 1, not 0 (most of the time??)
                 else if (element.Row == 0)
                     SetRow(view, dfLayout.RowHeights.Count + 1);
                 if (element.RowSpan > 0)
@@ -1333,7 +1330,9 @@ namespace PRS.Mobile
                 else if (element.RowSpan == 0)
                     SetRowSpan(view, 1);
                 if (element.Column > 0)
-                    SetColumn(view, element.Column - 1); //rows and columns coming in from the desktop designer start from 1, not 0 (most of the time??)
+                    SetColumn(view,
+                        element.Column -
+                        1); //rows and columns coming in from the desktop designer start from 1, not 0 (most of the time??)
                 if (element.ColumnSpan > 0)
                     SetColumnSpan(view, element.ColumnSpan);
 
@@ -1348,24 +1347,24 @@ namespace PRS.Mobile
                         view = lblView;
                     }
                 }
-                else if (element.ColumnSpan == 0) SetColumnSpan(view, 1);
+                else if (element.ColumnSpan == 0)
+                    SetColumnSpan(view, 1);
 
-                view.SetValue(Grid.MarginProperty, 0.01);
+                //view.SetValue(Grid.MarginProperty, 0.01);
 
-                if (element is DFLayoutSignaturePad)
-                    view.Margin = new Thickness(25, 0, 25, 0);
+                //if (element is DFLayoutSignaturePad)
+                //    view.Margin = new Thickness(25, 0, 25, 0);
 
-                Device.BeginInvokeOnMainThread(() =>
-                {
-                    Children.Add(view);
-                });
+                Device.BeginInvokeOnMainThread(() => { Children.Add(view); });
 
                 if (element is DFLayoutHeader)
                     if ((element as DFLayoutHeader).Collapsed)
                         headersToCollapse.Add(view as DigitalFormsHeader);
             }
-            catch
-            { }
+            catch (Exception e)
+            {
+                MobileLogging.Log(e,"DFLayout");
+            }
         }
         #endregion
 
@@ -2102,26 +2101,9 @@ namespace PRS.Mobile
 
         private string GetStringFromOptionField(View view)
         {
-            if (Device.RuntimePlatform == Device.iOS)
-            {
-                var iOSPicker = view as CustomPickeriOS;
-                if (iOSPicker.SelectedIndex != -1)
-                {
-                    return iOSPicker.SelectedItem.ToString();
-                }
-                else
-                    return "";
-            }
-            else
-            {
-                var picker = view as Picker;
-                if (picker.SelectedIndex != -1)
-                {
-                    return picker.SelectedItem.ToString();
-                }
-                else
-                    return "";
-            }
+            if (view is MobileTabStrip strip)
+                return strip.SelectedItem?.Text ?? "";
+            return "";
         }
 
         public object GetFieldData(string fieldName, string dataField)

+ 1 - 1
prs.mobile.new/PRS.Mobile/Modules/Site/SiteForms/SiteForms.xaml

@@ -10,6 +10,6 @@
     </local:SitePage.PrimaryMenu>
     
     <local:SitePage.PageContent>
-        <local:ExistingForms x:Name="_forms" FormTapped="_forms_OnFormTapped" Margin="5,5,5,0"/>
+        <local:ExistingForms x:Name="_forms" FormTapped="_forms_OnFormTapped" Margin="5"/>
     </local:SitePage.PageContent>
 </local:SitePage>

+ 5 - 1
prs.mobile.new/PRS.Mobile/Modules/Site/SiteForms/SiteForms.xaml.cs

@@ -1,7 +1,9 @@
 using System;
 using System.Linq;
+using System.Threading.Tasks;
 using Comal.Classes;
 using InABox.Core;
+using InABox.Mobile.Shared;
 using Syncfusion.XForms.RichTextEditor;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
@@ -67,7 +69,9 @@ namespace PRS.Mobile
 
         private void _forms_OnFormTapped(object sender, ExistingFormTappedEventArgs args)
         {
-            _forms.EditForm<Job,JobLink,JobForm>(args.Shell,Job.Entity);
+            ProgressVisible = true;
+            _forms.EditForm<Job, JobLink, JobForm>(args.Shell, Job.Entity);
+            ProgressVisible = false;
         }
     }
 }