Browse Source

Improved Menu Handling in Mobile Equipment Module
Renamed ScanModule to DocScannerModule

Frank van den Bos 1 year ago
parent
commit
db86c56a58

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

@@ -956,6 +956,6 @@ namespace PRS.Mobile
 
         public void UpdatePageTapped(object sender, EventArgs args) => Navigation.PushAsync(new UpdatePage());
         
-        private void ScanModuleTapped(object sender, EventArgs e) => Navigation.PushAsync(new ScanModule());
+        private void ScanModuleTapped(object sender, EventArgs e) => Navigation.PushAsync(new DocScannerModule());
     }
 }

+ 1 - 1
prs.mobile.new/PRS.Mobile/Modules/Scans/ScanModule.xaml → prs.mobile.new/PRS.Mobile/Modules/DocScanner/DocScannerModule.xaml

@@ -4,7 +4,7 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:mobile="clr-namespace:InABox.Mobile;assembly=InABox.Mobile.Shared"
              xmlns:local="clr-namespace:PRS.Mobile;assembly=PRS.Mobile"
-             x:Class="PRS.Mobile.ScanModule"
+             x:Class="PRS.Mobile.DocScannerModule"
              Title="Submitted Documents">
     <mobile:MobilePage.PrimaryMenu>
         

+ 2 - 2
prs.mobile.new/PRS.Mobile/Modules/Scans/ScanModule.xaml.cs → prs.mobile.new/PRS.Mobile/Modules/DocScanner/DocScannerModule.xaml.cs

@@ -12,12 +12,12 @@ using Xamarin.Forms.Xaml;
 namespace PRS.Mobile
 {
     [XamlCompilation(XamlCompilationOptions.Compile)]
-    public partial class ScanModule
+    public partial class DocScannerModule
     {
         private DataEntryTagModel _tags;
         private DataEntryDocumentModel _dataEntriesDocument;
         
-        public ScanModule()
+        public DocScannerModule()
         {
             _dataEntriesDocument = new DataEntryDocumentModel(App.Data,
                 () => new Filter<DataEntryDocument>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)

+ 28 - 4
prs.mobile.new/PRS.Mobile/Modules/Equipment/Edit/EquipmentEdit.xaml

@@ -11,12 +11,25 @@
         <local:EquipmentEditViewModel x:Name="_viewmodel" />
     </mobile:MobilePage.BindingContext>
     
+    <mobile:MobilePage.Resources>
+        <mobile:BooleanToBooleanConverter x:Key="NotTrue" Invert="True" />
+        <mobile:IntToBooleanConverter x:Key="SpecPageVisible" Value="1" />
+        <mobile:IntToBooleanConverter x:Key="MapPageVisible" Value="2" />
+        <mobile:IntToBooleanConverter x:Key="ImagesPageVisible" Value="3" />
+        <mobile:BooleanMatcher x:Key="MatchAll" Type="All" />
+    </mobile:MobilePage.Resources>
+    
     <mobile:MobilePage.PrimaryMenu>
         
         <mobile:MobileMenuButton
             x:Name="_specsheet"
-            IsVisible="False"
             Image="camera">
+            <mobile:MobileMenuButton.IsVisible>
+                <MultiBinding Converter="{StaticResource MatchAll}">
+                    <Binding Path="IsChanged" Converter="{StaticResource NotTrue}"/>
+                    <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource SpecPageVisible}" />
+                </MultiBinding>
+            </mobile:MobileMenuButton.IsVisible>
             <mobile:MobileMenuButton.Items>
                 <mobile:MobileMenuItem Text="Take Photo" Clicked="_specsheetphoto_Clicked" />
                 <mobile:MobileMenuItem Text="Browse Library" Clicked="_specsheetlibrary_Clicked" />
@@ -25,14 +38,25 @@
         
         <mobile:MobileMenuButton
             x:Name="_maprefresh"
-            IsVisible="False"
             Image="refresh"
-            Clicked="_maprefresh_OnClicked"/>
+            Clicked="_maprefresh_OnClicked">
+            <mobile:MobileMenuButton.IsVisible>
+                <MultiBinding Converter="{StaticResource MatchAll}">
+                    <Binding Path="IsChanged" Converter="{StaticResource NotTrue}"/>
+                    <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource MapPageVisible}" />
+                </MultiBinding>
+            </mobile:MobileMenuButton.IsVisible>
+        </mobile:MobileMenuButton>
         
         <mobile:MobileMenuButton
             x:Name="_images"
-            IsVisible="False"
             Image="plus">
+            <mobile:MobileMenuButton.IsVisible>
+                <MultiBinding Converter="{StaticResource MatchAll}">
+                    <Binding Path="IsChanged" Converter="{StaticResource NotTrue}"/>
+                    <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource ImagesPageVisible}" />
+                </MultiBinding>
+            </mobile:MobileMenuButton.IsVisible>
             <mobile:MobileMenuButton.Items>
                 <mobile:MobileMenuItem Text="Take Photo" Clicked="_imagesphoto_Clicked" />
                 <mobile:MobileMenuItem Text="Browse Library" Clicked="_imageslibrary_Clicked" />

+ 0 - 8
prs.mobile.new/PRS.Mobile/Modules/Equipment/Edit/EquipmentEdit.xaml.cs

@@ -55,14 +55,6 @@ namespace PRS.Mobile
         
         private void CheckChanged()
         {
-            Device.BeginInvokeOnMainThread(() =>
-            {
-                bool changed = Item.ID == Guid.Empty || Item.IsChanged();
-                //_save.IsVisible = changed;
-                _specsheet.IsVisible = !changed && _tabStrip.SelectedItem.Index == 1;
-                _maprefresh.IsVisible = !changed && _tabStrip.SelectedItem.Index == 2;
-                _images.IsVisible = !changed && _tabStrip.SelectedItem.Index == 3;
-            });
         }
         
         private void Details_OnChanged(object sender, MobileViewChangedEventArgs eventargs)

+ 3 - 0
prs.mobile.new/PRS.Mobile/Modules/Equipment/Edit/EquipmentEditViewModel.cs

@@ -1,3 +1,4 @@
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -27,6 +28,8 @@ namespace PRS.Mobile
                     Item.Longitude
                 );
         
+        public bool IsChanged => Item == null || Item.ID == Guid.Empty || Item.IsChanged();
+        
         public EquipmentEditViewModel()
         {
             Documents = new EquipmentDocumentModel(App.Data,