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

Began layout, added admin button. Custom component (hopefully) won't be too bad.

parent 6195f454
No related branches found
No related tags found
1 merge request!1App now has a basic structure and BLE support
......@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RobobinApp"
Shell.FlyoutBehavior="Disabled"
Title="RobobinApp">
<ShellContent
......
<?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.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
{
public partial class LeftBox : ContentView
{
public LeftBox()
{
InitializeComponent();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RobobinApp.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
xmlns:local="clr-namespace:RobobinApp"
x:Class="RobobinApp.MainPage"
Title="">
<ContentPage.Resources>
<ResourceDictionary>
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.MenuBarItems>
<MenuBarItem Text="Admin">
<MenuFlyoutItem Text="Connect to Robobin" Command="{Binding ConnectToRobobinCommand}" />
</MenuBarItem>
</ContentPage.MenuBarItems>
<!-- Main grid that holds all elements -->
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<!-- Only one row filling the available height -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<!-- Left box -->
<ColumnDefinition Width="2*" />
<!-- Center box (bigger) -->
<ColumnDefinition Width="1*" />
<!-- Right box -->
</Grid.ColumnDefinitions>
<!-- Left side box -->
<local:LeftBox Grid.Column="0" Grid.Row="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
<!-- Center (big) box -->
<Frame BackgroundColor="White" BorderColor="Black" CornerRadius="5"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Grid.Column="1" Grid.Row="0">
<Label Text="Center Box" HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>
<!-- Right side box -->
<Frame BackgroundColor="Lavender" BorderColor="Black" CornerRadius="5"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Grid.Column="2" Grid.Row="0">
<Label Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>
</Grid>
</ContentPage>
namespace RobobinApp;
using System.Windows.Input;
using Microsoft.Maui.Controls;
public partial class MainPage : ContentPage
namespace RobobinApp
{
int count = 0;
public partial class MainPage : ContentPage
{
public ICommand ConnectToRobobinCommand { get; }
public MainPage()
{
InitializeComponent();
}
public MainPage()
{
InitializeComponent();
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
// Create the command and assign it to the handler method
ConnectToRobobinCommand = new Command(OnConnectToRobobin);
BindingContext = this; // Set the BindingContext to the current page
}
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
// Command handler method
private void OnConnectToRobobin()
{
// Logic to connect to Robobin goes here
DisplayAlert("Connection", "Connecting to Robobin...", "OK");
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="PrimaryColor">#4CAF50</Color>
<Color x:Key="SecondaryColor">#2196F3</Color>
<Color x:Key="BackgroundColor">#121212</Color>
<Color x:Key="TextColor">#FFFFFF</Color>
<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource TextColor}"/>
</Style>
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}"/>
<Setter Property="TextColor" Value="#FFFFFF"/>
</Style>
</ResourceDictionary>
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<!-- Light Theme Colors -->
<Color x:Key="PrimaryColor">#4CAF50</Color>
<!-- Green -->
<Color x:Key="SecondaryColor">#2196F3</Color>
<!-- Blue -->
<Color x:Key="BackgroundColor">#FFFFFF</Color>
<!-- White -->
<Color x:Key="TextColor">#000000</Color>
<!-- Black -->
<!-- Default Styles -->
<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource TextColor}"/>
</Style>
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}"/>
<Setter Property="TextColor" Value="#FFFFFF"/>
</Style>
</ResourceDictionary>
This diff is collapsed.
......@@ -63,10 +63,13 @@
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Resources\Styles\DarkTheme.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Styles\LightTheme.xaml">
<Compile Update="LeftBox.xaml.cs">
<DependentUpon>LeftBox.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="LeftBox.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
......
......@@ -5,4 +5,9 @@
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
</PropertyGroup>
<ItemGroup>
<MauiXaml Update="LeftBox.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>
</Project>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment