From d55c6826e2799d6126e94ec1236cb4fec348472b Mon Sep 17 00:00:00 2001
From: Paul-Winpenny <92634321+Paul-Winpenny@users.noreply.github.com>
Date: Thu, 24 Oct 2024 18:06:35 +0100
Subject: [PATCH] Added the side boxes with different text, they will have to
 become seperate components though (or children).

---
 App/RobobinApp/Resources/Styles/appstyle.css  | 45 ++++++++++++++-----
 App/RobobinApp/RobobinApp.csproj              |  3 ++
 App/RobobinApp/RobobinApp.csproj.user         |  3 ++
 .../ViewModels/ConnectionPageViewModel.cs     | 12 ++---
 App/RobobinApp/Views/LeftBox.xaml             | 12 +++++
 App/RobobinApp/Views/LeftBox.xaml.cs          | 12 +++++
 App/RobobinApp/Views/MainPage.xaml            | 33 +++++++++-----
 App/RobobinApp/Views/SideBox.xaml             | 18 ++++++++
 App/RobobinApp/Views/SideBox.xaml.cs          | 32 +++++++++++++
 9 files changed, 142 insertions(+), 28 deletions(-)
 create mode 100644 App/RobobinApp/Views/LeftBox.xaml
 create mode 100644 App/RobobinApp/Views/LeftBox.xaml.cs
 create mode 100644 App/RobobinApp/Views/SideBox.xaml
 create mode 100644 App/RobobinApp/Views/SideBox.xaml.cs

diff --git a/App/RobobinApp/Resources/Styles/appstyle.css b/App/RobobinApp/Resources/Styles/appstyle.css
index e7f7ab9e..a9bc7726 100644
--- a/App/RobobinApp/Resources/Styles/appstyle.css
+++ b/App/RobobinApp/Resources/Styles/appstyle.css
@@ -62,14 +62,39 @@ stacklayout > image {
 }
 
 .sideBox {
-    background-color: lightgray; /* Change to your preferred background color */
-    border: 1px solid black; /* Optional: adds a border */
-    padding: 20px; /* Space inside the box */
-    margin: auto; /* Centers the box horizontally */
-    width: 150px; /* Fixed width, adjust as needed */
-    height: 100px; /* Fixed height, adjust as needed */
-    display: flex; /* Enables flexbox for centering content */
-    justify-content: center; /* Centers content horizontally */
-    align-items: center; /* Centers content vertically */
-    border-radius: 8px; /* Optional: rounded corners */
+    margin: 0;
+    padding: 0;
+}
+
+.side-box-frame {
+    margin: 10;
+    padding: 0;
+    background-color: transparent;
+    border-color: transparent;
+    horizontal-options: fill-and-expand;
+}
+
+.side-box-header {
+    background-color: #647687;
+    padding: 10 5;
+}
+
+.side-box-header-text {
+    color: #FFFFFF;
+    font-size: 16;
+}
+
+.side-box-content {
+    background-color: #E8EDF1;
+    padding: 10;
+    height: 200;
+}
+
+    .side-box-content Label {
+        margin: 0;
+        padding: 0;
+    }
+
+.side-box-vertical-stack {
+    spacing: 0;
 }
\ No newline at end of file
diff --git a/App/RobobinApp/RobobinApp.csproj b/App/RobobinApp/RobobinApp.csproj
index 7d3108fc..68992df4 100644
--- a/App/RobobinApp/RobobinApp.csproj
+++ b/App/RobobinApp/RobobinApp.csproj
@@ -57,5 +57,8 @@
         <MauiXaml Update="Views\ConnectionPage.xaml">
             <Generator>MSBuild:Compile</Generator>
         </MauiXaml>
+        <MauiXaml Update="Views\SideBox.xaml">
+          <Generator>MSBuild:Compile</Generator>
+        </MauiXaml>
     </ItemGroup>
 </Project>
diff --git a/App/RobobinApp/RobobinApp.csproj.user b/App/RobobinApp/RobobinApp.csproj.user
index 4aca8770..ed220129 100644
--- a/App/RobobinApp/RobobinApp.csproj.user
+++ b/App/RobobinApp/RobobinApp.csproj.user
@@ -18,6 +18,9 @@
     <MauiXaml Update="Views\ConnectionPage.xaml">
       <SubType>Designer</SubType>
     </MauiXaml>
+    <MauiXaml Update="Views\SideBox.xaml">
+      <SubType>Designer</SubType>
+    </MauiXaml>
   </ItemGroup>
   <ItemGroup>
     <None Update="Platforms\Windows\Package.appxmanifest">
diff --git a/App/RobobinApp/ViewModels/ConnectionPageViewModel.cs b/App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
index 9afd9cff..265a9f81 100644
--- a/App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
+++ b/App/RobobinApp/ViewModels/ConnectionPageViewModel.cs
@@ -44,8 +44,8 @@ namespace RobobinApp.ViewModels
         public const string SendReceiveServiceUUID = "00000001-710e-4a5b-8d75-3e5b444bc3cf";
         public const string rxUUID = "00000002-710e-4a5b-8d75-3e5b444bc3cf";
         public const string wxUUID = "00000003-710e-4a5b-8d75-3e5b444bc3cf";
-        public const string readCharacteristicName = "CPU Temperature";
-        public const string writeCharacteristicName = "Temperature Units (F or C)";
+        public const string readCharacteristicName = "SSID List";
+        public const string writeCharacteristicName = "SSID name and password";
 
 
         public string tempUnit = "C";
@@ -166,10 +166,10 @@ namespace RobobinApp.ViewModels
             //Delay 5 seconds
             await Task.Delay(2500);
 
-            //var networks = await ReadOperationAsync();
-            var networks = "Network1\nNetwork2\nNetwork3"; // For testing
+            var networks = await ReadOperationAsync();
+            //var networks = "Network1\nNetwork2\nNetwork3"; // For testing
             Debug.WriteLine(networks);
-            var delimiter = "\n";
+            var delimiter = '\n';   //Test to see if actual SSID has \n, see if it breaks things
             var networkList = networks.Split(delimiter);
             var addedSsids = new HashSet<string>(); 
 
@@ -396,7 +396,7 @@ namespace RobobinApp.ViewModels
                                 {
                                     WriteCharacteristic = characteristic;
                                     const string command = "SCAN";                                  
-                                    await WriteOperationAsync(command);
+                                    //await WriteOperationAsync(command);
                                     ScanForWifiNetworks();
 
                                 }
diff --git a/App/RobobinApp/Views/LeftBox.xaml b/App/RobobinApp/Views/LeftBox.xaml
new file mode 100644
index 00000000..6b5fff0d
--- /dev/null
+++ b/App/RobobinApp/Views/LeftBox.xaml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="RobobinApp.Views.LeftBox"
+             BackgroundColor="Lavender">
+    <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
+        <Label BackgroundColor="Black">Test</Label>
+        
+        <Label BackgroundColor="Black">Test</Label>
+        
+    </VerticalStackLayout>
+</ContentView>
diff --git a/App/RobobinApp/Views/LeftBox.xaml.cs b/App/RobobinApp/Views/LeftBox.xaml.cs
new file mode 100644
index 00000000..6a829747
--- /dev/null
+++ b/App/RobobinApp/Views/LeftBox.xaml.cs
@@ -0,0 +1,12 @@
+using Microsoft.Maui.Controls;
+
+namespace RobobinApp.Views
+{
+    public partial class LeftBox : ContentView
+    {
+        public LeftBox()
+        {
+            InitializeComponent();
+        }
+    }
+}
diff --git a/App/RobobinApp/Views/MainPage.xaml b/App/RobobinApp/Views/MainPage.xaml
index 804bf685..f5007a27 100644
--- a/App/RobobinApp/Views/MainPage.xaml
+++ b/App/RobobinApp/Views/MainPage.xaml
@@ -19,11 +19,6 @@
         </ResourceDictionary>
     </ContentPage.Resources>
 
-    <ContentPage.MenuBarItems>
-        <MenuBarItem Text="Admin">
-            <MenuFlyoutItem Text="Connect to Robobin" Command="{Binding ConnectToRobobinCommand}" />
-        </MenuBarItem>
-    </ContentPage.MenuBarItems>
 
     <Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
         <Grid.RowDefinitions>
@@ -35,24 +30,38 @@
             <ColumnDefinition Width="1*" />
         </Grid.ColumnDefinitions>
 
-        <Frame StyleClass="sideFrame" 
+        <VerticalStackLayout StyleClass="sideFrame" 
                HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                Grid.Column="0" Grid.Row="0">
-        
+            <HorizontalStackLayout HorizontalOptions="Start" VerticalOptions="End">
+                <Button Text="Admin" HorizontalOptions="Start" VerticalOptions="Start" Command="{Binding ConnectToRobobinCommand}"/>
+                <Button Text="Setup" HorizontalOptions="Start" VerticalOptions="Start" Command="{Binding ConnectToRobobinCommand}"/>
 
+            </HorizontalStackLayout>
 
-            <Button Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding ConnectToRobobinCommand}"/>
-        </Frame>
+
+
+            <local:SideBox Grid.Column="0" Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
+            <local:SideBox Grid.Column="0" Grid.Row="1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HeaderTitle= "Status:" />
+            
+
+        </VerticalStackLayout>
         <Frame StyleClass="mainFrame" 
                HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                Grid.Column="1" Grid.Row="0">
             <Label Text="{Binding StatusMessage}" HorizontalOptions="Center" VerticalOptions="Center"/>
         </Frame>
 
-        <Frame StyleClass="sideFrame" 
+        <VerticalStackLayout StyleClass="sideFrame" 
                HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                Grid.Column="2" Grid.Row="0">
-            <Button Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding ConnectToRobobinCommand}"/>
-        </Frame>
+            <HorizontalStackLayout HorizontalOptions="Start" VerticalOptions="End">
+                <Button Text="Info" HorizontalOptions="Start" VerticalOptions="Start"  />
+
+            </HorizontalStackLayout>
+
+            <local:SideBox Grid.Column="0" Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HeaderTitle= "Mode:" />
+            <local:SideBox Grid.Column="0" Grid.Row="1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HeaderTitle= "Admin:" />
+        </VerticalStackLayout>
     </Grid>
 </ContentPage>
diff --git a/App/RobobinApp/Views/SideBox.xaml b/App/RobobinApp/Views/SideBox.xaml
new file mode 100644
index 00000000..799f3e5c
--- /dev/null
+++ b/App/RobobinApp/Views/SideBox.xaml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="RobobinApp.Views.SideBox"
+             StyleClass="SideBox">
+    <Frame StyleClass="side-box-frame">
+        <VerticalStackLayout>
+            <Grid StyleClass="side-box-header">
+                <Label x:Name="HeaderText"
+                       Text="Queue Position:"
+                       StyleClass="side-box-header-text"/>
+            </Grid>
+            <Grid StyleClass="side-box-content">
+                <ContentPresenter />
+            </Grid>
+        </VerticalStackLayout>
+    </Frame>
+</ContentView>
\ No newline at end of file
diff --git a/App/RobobinApp/Views/SideBox.xaml.cs b/App/RobobinApp/Views/SideBox.xaml.cs
new file mode 100644
index 00000000..e115f034
--- /dev/null
+++ b/App/RobobinApp/Views/SideBox.xaml.cs
@@ -0,0 +1,32 @@
+namespace RobobinApp.Views
+{
+    public partial class SideBox : ContentView
+    {
+        public static readonly BindableProperty HeaderTitleProperty =
+            BindableProperty.Create(nameof(HeaderTitle),
+                                  typeof(string),
+                                  typeof(SideBox),
+                                  defaultValue: "Queue Position:",
+                                  propertyChanged: OnHeaderTitleChanged);
+
+        public string HeaderTitle
+        {
+            get => (string)GetValue(HeaderTitleProperty);
+            set => SetValue(HeaderTitleProperty, value);
+        }
+
+        public SideBox()
+        {
+            InitializeComponent();
+        }
+
+        protected static void OnHeaderTitleChanged(BindableObject bindable, object oldValue, object newValue)
+        {
+            var control = (SideBox)bindable;
+            if (control.HeaderText != null)
+            {
+                control.HeaderText.Text = newValue?.ToString();
+            }
+        }
+    }
+}
\ No newline at end of file
-- 
GitLab