diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..edad2944383fffb584973cd763e95ac8251948f6 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/App/RobobinApp/MainPage.xaml.cs b/App/RobobinApp/MainPage.xaml.cs deleted file mode 100644 index 42688b302de1e536fd355768e8dae057902626f4..0000000000000000000000000000000000000000 --- a/App/RobobinApp/MainPage.xaml.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Windows.Input; -using Microsoft.Maui.Controls; - -namespace RobobinApp -{ - public partial class MainPage : ContentPage - { - public ICommand ConnectToRobobinCommand { get; } - - public MainPage() - { - InitializeComponent(); - - // Create the command and assign it to the handler method - ConnectToRobobinCommand = new Command(OnConnectToRobobin); - BindingContext = this; // Set the BindingContext to the current page - } - - // Command handler method - private void OnConnectToRobobin() - { - // Logic to connect to Robobin goes here - DisplayAlert("Connection", "Connecting to Robobin...", "OK"); - } - } -} diff --git a/App/RobobinApp/RobobinApp.csproj.user b/App/RobobinApp/RobobinApp.csproj.user index f75ca0bc127906404937a30dbb3805c75dc4df4c..1c649b0efce9a13abc7e4fca338a5ee46e7d5ec1 100644 --- a/App/RobobinApp/RobobinApp.csproj.user +++ b/App/RobobinApp/RobobinApp.csproj.user @@ -5,9 +5,5 @@ <ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework> <ActiveDebugProfile>Windows Machine</ActiveDebugProfile> </PropertyGroup> - <ItemGroup> - <MauiXaml Update="LeftBox.xaml"> - <SubType>Designer</SubType> - </MauiXaml> - </ItemGroup> + <ItemGroup /> </Project> \ No newline at end of file diff --git a/App/RobobinApp/ViewModels/MainPageViewModel.cs b/App/RobobinApp/ViewModels/MainPageViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..fd52b835b428c35dfa0c837468178e173789b2ea --- /dev/null +++ b/App/RobobinApp/ViewModels/MainPageViewModel.cs @@ -0,0 +1,67 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows.Input; +using Microsoft.Maui.Controls; + +namespace RobobinApp +{ + public class MainPageViewModel : INotifyPropertyChanged + { + private bool _isBusy; + private string _statusMessage; + + public ICommand ConnectToRobobinCommand { get; } + + public MainPageViewModel() + { + ConnectToRobobinCommand = new Command(async () => await OnConnectToRobobin()); + } + + public bool IsBusy + { + get => _isBusy; + set + { + _isBusy = value; + OnPropertyChanged(); + } + } + + public string StatusMessage + { + get => _statusMessage; + set + { + _statusMessage = value; + OnPropertyChanged(); + } + } + + private async Task OnConnectToRobobin() + { + try + { + IsBusy = true; + StatusMessage = "Connecting to Robobin..."; + StatusMessage = "Connected to Robobin!"; + await Application.Current.MainPage.DisplayAlert("Connection", StatusMessage, "OK"); + } + catch (Exception ex) + { + StatusMessage = $"Failed to connect: {ex.Message}"; + await Application.Current.MainPage.DisplayAlert("Error", StatusMessage, "OK"); + } + finally + { + IsBusy = false; + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/App/RobobinApp/LeftBox.xaml b/App/RobobinApp/Views/LeftBox.xaml similarity index 100% rename from App/RobobinApp/LeftBox.xaml rename to App/RobobinApp/Views/LeftBox.xaml diff --git a/App/RobobinApp/LeftBox.xaml.cs b/App/RobobinApp/Views/LeftBox.xaml.cs similarity index 100% rename from App/RobobinApp/LeftBox.xaml.cs rename to App/RobobinApp/Views/LeftBox.xaml.cs diff --git a/App/RobobinApp/MainPage.xaml b/App/RobobinApp/Views/MainPage.xaml similarity index 73% rename from App/RobobinApp/MainPage.xaml rename to App/RobobinApp/Views/MainPage.xaml index 5ca20cb2fdaedc01bfb1e134a31d2c8a58b41782..50c57893ae4276fe151c4b67bc99ee753bb06885 100644 --- a/App/RobobinApp/MainPage.xaml +++ b/App/RobobinApp/Views/MainPage.xaml @@ -1,57 +1,51 @@ -<?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" - 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 --> +<?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" + xmlns:local="clr-namespace:RobobinApp" + x:Class="RobobinApp.MainPage" + Title=""> + + <ContentPage.Resources> + <ResourceDictionary> + <ResourceDictionary Source="../Resources/Styles/Styles.xaml" /> + </ResourceDictionary> + </ContentPage.Resources> + + <ContentPage.BindingContext> + <local:MainPageViewModel /> + </ContentPage.BindingContext> + + <ContentPage.MenuBarItems> + <MenuBarItem Text="Admin"> + <MenuFlyoutItem Text="Connect to Robobin" Command="{Binding ConnectToRobobinCommand}" /> + </MenuBarItem> + </ContentPage.MenuBarItems> + + <Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> + <Grid.RowDefinitions> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*" /> + <ColumnDefinition Width="2*" /> + <ColumnDefinition Width="1*" /> + </Grid.ColumnDefinitions> + <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> + + <Frame BackgroundColor="White" BorderColor="Black" CornerRadius="5" + 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" + HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" + Grid.Column="2" Grid.Row="0"> + <Label Text="Right Box" HorizontalOptions="Center" VerticalOptions="Center"/> + </Frame> + + <ActivityIndicator IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" + VerticalOptions="Center" HorizontalOptions="Center"/> + </Grid> +</ContentPage> diff --git a/App/RobobinApp/Views/MainPage.xaml.cs b/App/RobobinApp/Views/MainPage.xaml.cs new file mode 100644 index 0000000000000000000000000000000000000000..12de2551ca87df74faab0d3aa8a2d759f648c1ad --- /dev/null +++ b/App/RobobinApp/Views/MainPage.xaml.cs @@ -0,0 +1,12 @@ +using Microsoft.Maui.Controls; + +namespace RobobinApp +{ + public partial class MainPage : ContentPage + { + public MainPage() + { + InitializeComponent(); + } + } +} diff --git a/README.md b/README.md index 72fb4b5c55adc224374b58821ce1a183110df963..0a7db2f0bf2dcb9960c4898a2519de0c5ab94886 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,10 @@ For open source projects, say how it is licensed. ## Project status If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. + + + +for the application, we are following MVVM +Model: Handles data and business logic (e.g., represents a Robobin object). +View: Displays the UI and interacts with the user (e.g., buttons, labels). +ViewModel: Connects the Model to the View, providing data and commands (e.g., logic to connect to Robobin and update the status). \ No newline at end of file