Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the UI channel selector by splitting the previous monolithic DeviceChannelSelector XAML into per-device selector components, and introducing a shared base class plus a registry-based factory to load the appropriate selector at runtime.
Changes:
- Added per-device
*ChannelSelectorViewXAML + code-behind components underUI/Controls/Devices. - Introduced
DeviceChannelSelectorViewBase(shared bindable properties + button registration wiring) andIDeviceChannelSelectorView(static device identity). - Refactored
DeviceChannelSelectorto dynamically instantiate the correct per-device selector via a registry; updated the project file to ensure XAML compilation.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| BrickController2/BrickController2/UI/Controls/Devices/WeDo2ChannelSelectorView.xaml.cs | New WeDo2 selector view code-behind using shared base registration. |
| BrickController2/BrickController2/UI/Controls/Devices/WeDo2ChannelSelectorView.xaml | New WeDo2 selector layout extracted from the old monolithic XAML. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicMoveChannelSelectorView.xaml.cs | New Technic Move selector with device-dependent visibility logic. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicMoveChannelSelectorView.xaml | New Technic Move selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicHubChannelSelectorView.xaml.cs | New Technic Hub selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicHubChannelSelectorView.xaml | New Technic Hub selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickLightChannelSelectorView.xaml.cs | New SBrick Light selector with custom port/subchannel handling. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickLightChannelSelectorView.xaml | New SBrick Light selector layout (includes settings UI). |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickChannelSelectorView.xaml.cs | New SBrick selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickChannelSelectorView.xaml | New SBrick selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PowerFunctionsChannelSelectorView.xaml.cs | New Infrared/Power Functions selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PowerFunctionsChannelSelectorView.xaml | New Infrared/Power Functions selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PoweredUpChannelSelectorView.xaml.cs | New Powered Up selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PoweredUpChannelSelectorView.xaml | New Powered Up selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PfxBrickChannelSelectorView.xaml.cs | New PFx Brick selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PfxBrickChannelSelectorView.xaml | New PFx Brick selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK6ChannelSelectorView.xaml.cs | New MK6 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK6ChannelSelectorView.xaml | New MK6 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK5ChannelSelectorView.xaml.cs | New MK5 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK5ChannelSelectorView.xaml | New MK5 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK4ChannelSelectorView.xaml.cs | New MK4 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK4ChannelSelectorView.xaml | New MK4 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK3_8ChannelSelectorView.xaml.cs | New MK3_8 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK3_8ChannelSelectorView.xaml | New MK3_8 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK_DIYChannelSelectorView.xaml.cs | New MK_DIY selector view code-behind (stamps MK4 labels intentionally). |
| BrickController2/BrickController2/UI/Controls/Devices/MK_DIYChannelSelectorView.xaml | New MK_DIY selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM8ChannelSelectorView.xaml.cs | New JieStar SCM8 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM8ChannelSelectorView.xaml | New JieStar SCM8 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM4ChannelSelectorView.xaml.cs | New JieStar SCM4 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM4ChannelSelectorView.xaml | New JieStar SCM4 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/DuploTrainHubChannelSelectorView.xaml.cs | New Duplo Train Hub selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/DuploTrainHubChannelSelectorView.xaml | New Duplo Train Hub selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/CircuitCubesChannelSelectorView.xaml.cs | New Circuit Cubes selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/CircuitCubesChannelSelectorView.xaml | New Circuit Cubes selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/CaDARaceCarChannelSelectorView.xaml.cs | New CaDA Race Car selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/CaDARaceCarChannelSelectorView.xaml | New CaDA Race Car selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizzChannelSelectorView.xaml.cs | New BuWizz selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizzChannelSelectorView.xaml | New BuWizz selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizz3ChannelSelectorView.xaml.cs | New BuWizz3 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizz3ChannelSelectorView.xaml | New BuWizz3 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BoostChannelSelectorView.xaml.cs | New Boost selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BoostChannelSelectorView.xaml | New Boost selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/IDeviceChannelSelectorView.cs | New interface providing compile-time device type identity for selector views. |
| BrickController2/BrickController2/UI/Controls/Devices/DeviceChannelSelectorViewBase.cs | New shared base class that wires up button commands and SelectedChannel propagation. |
| BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml.cs | Refactored selector to registry-driven dynamic child view instantiation. |
| BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml | Simplified host XAML to a content placeholder for the active selector view. |
| BrickController2/BrickController2/BrickController2.csproj | Ensures new per-device XAML views are compiled as MAUI XAML. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+82
to
+86
| @@ -152,7 +83,7 @@ private static object OnCoerceDevice(BindableObject bindable, object value) | |||
| { | |||
| if (bindable is DeviceChannelSelector dcs && value is Device device) | |||
| { | |||
| // enforce update | |||
| // enforce update even when the same Device reference is re-set (e.g. TechnicMove PlayVM mode change) | |||
Comment on lines
+54
to
+58
| // Register device channel selector views | ||
| foreach (var viewType in GetSubClassesOf<DeviceChannelSelectorViewBase>().Where(t => !t.IsAbstract && typeof(IDeviceChannelSelectorView).IsAssignableFrom(t))) | ||
| { | ||
| var deviceType = GetDeviceType(viewType); | ||
| builder.RegisterType(viewType).Keyed<DeviceChannelSelectorViewBase>(deviceType); |
Comment on lines
+6
to
+8
| /// <summary> | ||
| /// Provides a compile-time device-type identity for each channel selector view so that | ||
| /// </summary> |
Comment on lines
+10
to
+12
| /// <summary> | ||
| /// Generic, fallback channel selector for <see cref="DeviceManagement.DeviceType.None"/>. | ||
| /// Presents a single Picker whose items are the 1-based channel names ("1", "2", ...), |
Comment on lines
+44
to
+56
| protected override void OnSelectedChannelChanged(int channel) | ||
| { | ||
| base.OnSelectedChannelChanged(channel); | ||
|
|
||
| if (ChannelPicker.SelectedIndex == channel) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| _suppressPickerSelectionChanged = true; | ||
| ChannelPicker.SelectedIndex = channel; | ||
| _suppressPickerSelectionChanged = false; | ||
| } |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new keyed selector views are never consumed, so the active UI still uses the old monolithic selector.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (8)
Resolve keyed device selector views in the selector host · New Android Release builds enable trimming (<PublishTrimmed>true</PublishTrimmed>). These channel… Make DeviceType abstract to enforce implementation · New OnSelectedChannelChanged assigns ChannelPicker.SelectedIndex directly from SelectedChannel. If… DeviceChannelSelector.DeviceProperty currently triggers OnDeviceChanged from both the coerceValue… Localize the picker title · New The summary references <see cref="DeviceManagement.DeviceType.None"/>, but the enum doesn’t define… The XML summary is incomplete (it ends mid-sentence), which makes the generated docs unclear.
Resolved since last review (3)
Comment on lines
+55
to
+58
| foreach (var viewType in GetSubClassesOf<DeviceChannelSelectorViewBase>().Where(t => !t.IsAbstract && typeof(IDeviceChannelSelectorView).IsAssignableFrom(t))) | ||
| { | ||
| var deviceType = GetDeviceType(viewType); | ||
| builder.RegisterType(viewType).Keyed<DeviceChannelSelectorViewBase>(deviceType); |
| public interface IDeviceChannelSelectorView | ||
| { | ||
| /// <summary>The <see cref="DeviceType"/> this view handles.</summary> | ||
| static virtual DeviceType DeviceType => throw new InvalidOperationException(); |
Comment on lines
+2
to
+14
| <devices:DeviceChannelSelectorViewBase | ||
| xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:devices="clr-namespace:BrickController2.UI.Controls.Devices" | ||
| x:Class="BrickController2.UI.Controls.Devices.GenericChannelSelectorView"> | ||
|
|
||
| <ContentView.Content> | ||
| <Grid> | ||
| <Picker x:Name="ChannelPicker" | ||
| Title="Channel" | ||
| HorizontalOptions="Fill" | ||
| VerticalOptions="Center" | ||
| SelectedIndexChanged="OnChannelPickerSelectedIndexChanged"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.