Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change style and size of mini-window #85

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

justinshannon
Copy link
Contributor

@justinshannon justinshannon commented Jan 19, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced compact window interaction with new hover controls
    • Added observation time tracking for METAR data
  • Improvements

    • Refined button styling and control themes
    • Improved data handling for Wind and Altimeter properties
    • Streamlined compact window layout and responsiveness
  • UI Changes

    • Updated compact window design with dynamic control visibility
    • Simplified item template structure

Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Walkthrough

This pull request introduces comprehensive changes to the vATIS Desktop application's user interface and view models. The modifications focus on enhancing the visual styling of buttons, improving the compact window's interactivity, and adding new properties to the ATIS station view model. The changes include new control themes for buttons, updated window layout, and refined event handling for better user experience.

Changes

File Change Summary
vATIS.Desktop/Ui/Styles/Buttons.axaml Added new control themes for PinButtonSmall, CompactViewButtonSmall, and HyperlinkButtonSave. Updated existing themes for CloseButton, MinimizeButton, and CompactViewButton
vATIS.Desktop/Ui/ViewModels/AtisStationViewModel.cs Added ObservationTime property, modified Wind and Altimeter properties to trim whitespace
vATIS.Desktop/Ui/ViewModels/CompactWindowViewModel.cs Removed CurrentTime property, added IsControlsVisible property, updated Stations property
vATIS.Desktop/Ui/Windows/CompactWindow.axaml Adjusted window properties, replaced Grid with Panel, modified item template structure
vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs Added OnPointerEntered and OnPointerExited methods, modified OnPointerPressed drag operation logic

Sequence Diagram

sequenceDiagram
    participant User
    participant CompactWindow
    participant ViewModel
    
    User->>CompactWindow: Move mouse over window
    CompactWindow->>ViewModel: Set IsControlsVisible = true
    CompactWindow->>User: Show window controls
    
    User->>CompactWindow: Move mouse away
    CompactWindow->>ViewModel: Set IsControlsVisible = false
    CompactWindow->>User: Hide window controls
Loading

Possibly related PRs

Poem

🐰 A rabbit's tale of buttons bright,
Compact windows dancing with delight,
Trimmed and styled with coding grace,
Controls that hide and then embrace,
A UI journey, smooth and light! 🖱️


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
vATIS.Desktop/Ui/Styles/Buttons.axaml (4)

Line range hint 130-147: Consider using theme resources for colors.

While the implementation is good, consider moving the hardcoded colors (Coral, #ff9973) to theme resources for better maintainability and theme customization support.

-				<TextBlock Text="{TemplateBinding Content}" Foreground="Coral">
+				<TextBlock Text="{TemplateBinding Content}" Foreground="{DynamicResource SaveLinkForeground}">
 					<TextBlock.Styles>
 						<Style Selector="TextBlock:pointerover">
-							<Setter Property="Foreground" Value="#ff9973"/>
+							<Setter Property="Foreground" Value="{DynamicResource SaveLinkForegroundHover}"/>

Line range hint 343-383: Consider using theme resources for colors.

The close button implementation is solid, but consider moving the hardcoded colors (#C0392B, #dc6d62) to theme resources for better maintainability and theme customization.

-		<Setter Property="Background" Value="#C0392B"/>
-		<Setter Property="BorderBrush" Value="#C0392B"/>
+		<Setter Property="Background" Value="{DynamicResource CloseButtonBackground}"/>
+		<Setter Property="BorderBrush" Value="{DynamicResource CloseButtonBorder}"/>

385-407: Consider extracting common properties to a base theme.

The PinButtonSmall theme shares several properties with the regular PinButton theme, including the SVG path data. Consider creating a base theme to reduce duplication.

+    <ControlTheme x:Key="BasePinButton" TargetType="ToggleButton">
+        <Setter Property="Content">
+            <Template>
+                <Viewbox UseLayoutRounding="True">
+                    <Path x:Name="Glyph"
+                          Stretch="UniformToFill"
+                          HorizontalAlignment="Center"
+                          VerticalAlignment="Center"
+                          FlowDirection="LeftToRight"
+                          Fill="White"
+                          Data="M7.374 12.268l-5.656 5.657A1 1 0 1 1 .303 16.51l5.657-5.656L1.718 6.61A6.992 6.992 0 0 1 7.9 4.67L11.617.954a2 2 0 0 1 2.828 0l2.829 2.828a2 2 0 0 1 0 2.829l-3.716 3.716a6.992 6.992 0 0 1-1.941 6.183l-4.243-4.242z"/>
+                </Viewbox>
+            </Template>
+        </Setter>
+    </ControlTheme>

-    <ControlTheme x:Key="PinButtonSmall" BasedOn="{StaticResource Dark}" TargetType="ToggleButton">
+    <ControlTheme x:Key="PinButtonSmall" BasedOn="{StaticResource BasePinButton}" TargetType="ToggleButton">

452-469: Consider extracting common properties to a base theme.

Similar to the pin button, the CompactViewButtonSmall theme shares several properties with the regular CompactViewButton theme. Consider creating a base theme to reduce duplication.

+    <ControlTheme x:Key="BaseCompactViewButton" TargetType="Button">
+        <Setter Property="Content">
+            <Template>
+                <Viewbox UseLayoutRounding="True">
+                    <Path x:Name="Glyph"
+                          Stretch="UniformToFill"
+                          HorizontalAlignment="Center"
+                          VerticalAlignment="Center"
+                          Fill="White"
+                          Data="M 5.7474 345.3495 c -0 -1.9898 -0.7898 -3.8969 -2.197 -5.304 c -1.4064 -1.4064 -3.3135 -2.1963 -5.304 -2.197 l -64.2463 0 l 156.7472 -156.7458 l -0.0007 64.2456 c 0 1.9898 0.7898 3.8969 2.197 5.304 c 1.4064 1.4064 3.3135 2.1963 5.304 2.197 l 20.0012 -0 c 1.9884 -0 3.8962 -0.7905 5.3026 -2.197 c 1.4064 -1.4064 2.197 -3.3142 2.197 -5.3026 L 125.7483 128.8554 C 125.7483 126.8656 124.9578 124.9578 123.5514 123.5514 c -1.4064 -1.4064 -3.3135 -2.1963 -5.304 -2.197 L 1.7508 121.3551 c -1.9891 0.0007 -3.8962 0.7905 -5.3026 2.197 c -1.4064 1.4064 -2.197 3.3142 -2.197 5.304 l 0.0007 20.0005 c 0 2.0704 0.84 3.9457 2.197 5.3026 c 1.3569 1.3569 3.2322 2.197 5.304 2.197 l 64.247 -0.0007 l -156.7472 156.7458 l 0.0007 -64.2456 c -0 -1.9898 -0.7898 -3.8969 -2.197 -5.304 c -1.4064 -1.4064 -3.3135 -2.1963 -5.304 -2.197 l -20.0012 0 c -1.9884 0 -3.8962 0.7905 -5.3026 2.197 c -1.4064 1.4064 -2.197 3.3142 -2.197 5.3026 l 0 116.4944 c 0.0007 2.0711 0.84 3.9471 2.197 5.304 c 1.3569 1.3569 3.2329 2.1963 5.304 2.197 l 116.4958 -0 c 1.9884 -0 3.8962 -0.7905 5.3026 -2.197 c 1.4064 -1.4064 2.197 -3.3142 2.197 -5.3026 L 5.7474 345.3495 z"/>
+                </Viewbox>
+            </Template>
+        </Setter>
+    </ControlTheme>

-    <ControlTheme x:Key="CompactViewButtonSmall" BasedOn="{StaticResource Dark}" TargetType="Button">
+    <ControlTheme x:Key="CompactViewButtonSmall" BasedOn="{StaticResource BaseCompactViewButton}" TargetType="Button">
vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs (1)

72-86: Simplify null checks using null-conditional operator.

The implementation can be more concise while maintaining the same functionality.

-    private void OnPointerEntered(object? sender, PointerEventArgs e)
-    {
-        if (ViewModel != null)
-        {
-            ViewModel.IsControlsVisible = true;
-        }
-    }
-
-    private void OnPointerExited(object? sender, PointerEventArgs e)
-    {
-        if (ViewModel != null)
-        {
-            ViewModel.IsControlsVisible = false;
-        }
-    }
+    private void OnPointerEntered(object? sender, PointerEventArgs e) => 
+        ViewModel?.IsControlsVisible = true;
+
+    private void OnPointerExited(object? sender, PointerEventArgs e) => 
+        ViewModel?.IsControlsVisible = false;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10b1d8f and 58976ee.

📒 Files selected for processing (5)
  • vATIS.Desktop/Ui/Styles/Buttons.axaml (11 hunks)
  • vATIS.Desktop/Ui/ViewModels/AtisStationViewModel.cs (16 hunks)
  • vATIS.Desktop/Ui/ViewModels/CompactWindowViewModel.cs (2 hunks)
  • vATIS.Desktop/Ui/Windows/CompactWindow.axaml (1 hunks)
  • vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (macos-latest)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (9)
vATIS.Desktop/Ui/Styles/Buttons.axaml (1)

55-74: LGTM! Clean template structure.

The template structure is well-organized with proper spacing and alignment.

vATIS.Desktop/Ui/ViewModels/CompactWindowViewModel.cs (2)

43-49: LGTM! Clean MVVM implementation.

The property implementation correctly uses RaiseAndSetIfChanged for proper change notification.


52-58: LGTM! Well-documented property with proper MVVM implementation.

The IsControlsVisible property is correctly implemented with change notification and clear documentation.

vATIS.Desktop/Ui/Windows/CompactWindow.axaml (4)

9-11: LGTM! Clear window size constraints.

The window size constraints (MinHeight=50, MinWidth=100, MaxWidth=400) provide good bounds for the compact window.


20-27: LGTM! Well-structured Border with proper event handling.

The Border implementation includes all necessary pointer events and styling properties.


29-32: LGTM! Clean implementation of controls visibility.

The StackPanel correctly uses IsVisible binding to implement the hover functionality.


33-48: LGTM! Well-organized ItemsControl template.

The ItemsControl and its template provide a clean, structured layout for displaying station information.

vATIS.Desktop/Ui/ViewModels/AtisStationViewModel.cs (2)

397-404: LGTM! Well-documented ObservationTime property.

The property is properly implemented with change notification and clear documentation.


421-421: LGTM! Improved data cleanliness with Trim().

The Wind and Altimeter properties now properly trim whitespace, ensuring clean data.

Also applies to: 430-430

@justinshannon justinshannon added this pull request to the merge queue Jan 21, 2025
Merged via the queue into main with commit 59bfdf0 Jan 21, 2025
7 checks passed
@justinshannon justinshannon deleted the feature/mini-window-sizing branch January 21, 2025 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant