Skip to content
Snippets Groups Projects
Commit 10adbe94 authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

Css added, now making it pretty is key

parent 8a848bbb
No related branches found
No related tags found
1 merge request!1App now has a basic structure and BLE support
<?xml version = "1.0" encoding = "UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RobobinApp"
......@@ -9,6 +9,8 @@
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<StyleSheet Source="/Resources/Styles/appstyle.css" />
</ResourceDictionary>
</Application.Resources>
</Application>
using Plugin.BLE.Abstractions.Contracts;
using Plugin.BLE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Robobin.Interfaces
{
public class BluetoothLEService : IBluetoothLEService
{
public IBluetoothLE Current => CrossBluetoothLE.Current;
}
public class AdapterService : IAdapterService
{
public IAdapter Adapter => CrossBluetoothLE.Current.Adapter;
}
}

using Shiny;
namespace RobobinApp;
......@@ -11,7 +10,7 @@ public static class MauiProgram
var builder = MauiApp
.CreateBuilder()
.UseMauiApp<App>()
.UseShiny()
.ConfigureFonts(fonts =>
{
......@@ -20,7 +19,7 @@ public static class MauiProgram
});
builder.Services.AddBluetoothLE();
return builder.Build();
}
......
navigationpage {
-maui-bar-background-color: lightgray;
}
^contentpage {
background-color: lightgray;
}
#listView {
background-color: lightgray;
}
stacklayout {
margin: 20;
-maui-spacing: 6;
}
grid {
row-gap: 6;
column-gap: 6;
}
.mainPageTitle {
font-style: bold;
font-size: 14;
}
.mainPageSubtitle {
margin-top: 15;
}
.detailPageTitle {
font-style: bold;
font-size: 14;
text-align: center;
}
.detailPageSubtitle {
text-align: center;
font-style: italic;
}
listview image {
height: 60;
width: 60;
}
stacklayout > image {
height: 200;
width: 200;
}
.mainFrame {
background-color: White;
border-color: Black;
corner-radius: 5;
}
.sideFrame {
background-color: #2B333E;
border-color: Black;
corner-radius: 5;
}
.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 */
}
\ No newline at end of file
......@@ -272,6 +272,7 @@ namespace RobobinApp.ViewModels
Debug.WriteLine("Starting scanning for devices...");
await _adapter.StartScanningForDevicesAsync();
}
catch (Exception ex)
{
......@@ -289,12 +290,30 @@ namespace RobobinApp.ViewModels
e.Device.Id.ToString()
);
// Check if the device is already in the list
if (!BluetoothDevices.Any(d => d.MacAddress == bluetoothDevice.MacAddress))
{
// Device is new, add it
Microsoft.Maui.Controls.Device.BeginInvokeOnMainThread(() => BluetoothDevices.Add(bluetoothDevice));
}
}
private void RemoveUnavailableDevices(IEnumerable<IDevice> availableDevices)
{
var currentDevices = BluetoothDevices.ToList(); // Copy current list
foreach (var device in currentDevices)
{
if (!availableDevices.Any(d => d.Id.ToString() == device.MacAddress))
{
// Device is no longer available, remove it
Microsoft.Maui.Controls.Device.BeginInvokeOnMainThread(() => BluetoothDevices.Remove(device));
Debug.WriteLine($"Removed unavailable device: {device.MacAddress}");
}
}
}
private async Task<IDevice> TryConnectAsync(Guid deviceId, int retryCount = 3)
{
......@@ -367,6 +386,7 @@ namespace RobobinApp.ViewModels
Debug.WriteLine($"{characteristic.Uuid} |{characteristic.Name}");
if (characteristic.Name.Equals(readCharacteristicName))
{
ReadCharacteristic = characteristic;
var result = await ReadOperationAsync();
......
<?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>
using Microsoft.Maui.Controls;
namespace RobobinApp.Views
{
public partial class LeftBox : ContentView
{
public LeftBox()
{
InitializeComponent();
}
}
}
......@@ -2,6 +2,8 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RobobinApp.Views"
xmlns:viewModels="clr-namespace:RobobinApp.ViewModels"
x:Class="RobobinApp.Views.MainPage"
Title="">
......@@ -12,6 +14,8 @@
<ContentPage.Resources>
<ResourceDictionary>
<ResourceDictionary Source="../Resources/Styles/Styles.xaml" />
<StyleSheet Source="/Resources/Styles/appstyle.css" />
</ResourceDictionary>
</ContentPage.Resources>
......@@ -31,18 +35,24 @@
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<local:LeftBox Grid.Column="0" Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
<Frame StyleClass="sideFrame"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Grid.Column="0" Grid.Row="0">
<Frame BackgroundColor="White" BorderColor="Black" CornerRadius="5"
<Button Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding ConnectToRobobinCommand}"/>
</Frame>
<Frame StyleClass="mainFrame"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Grid.Column="1" Grid.Row="0">
<Label Text="{Binding StatusMessage}" HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>
<Frame BackgroundColor="Lavender" BorderColor="Black" CornerRadius="5"
<Frame StyleClass="sideFrame"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Grid.Column="2" Grid.Row="0">
<Button Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding ConnectToRobobinCommand}"/>
<Button Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding ConnectToRobobinCommand}"/>
</Frame>
</Grid>
</ContentPage>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment