Skip to content

Commit

Permalink
Apply changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasia Orishchenko committed Jul 29, 2020
1 parent e72dc27 commit 6382ad1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
19 changes: 10 additions & 9 deletions windows/ReactTestApp/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using winrt::Windows::ApplicationModel::Core::CoreApplication;
using winrt::Windows::ApplicationModel::Core::CoreApplicationViewTitleBar;
using winrt::Windows::Foundation::IAsyncAction;
using winrt::Windows::UI::Colors;
using winrt::Windows::UI::ViewManagement::ApplicationView;
using winrt::Windows::UI::Xaml::RoutedEventArgs;
using winrt::Windows::UI::Xaml::Window;
Expand Down Expand Up @@ -38,7 +39,7 @@ namespace winrt::ReactTestApp::implementation

auto &components = manifest.value().components;
for (auto &&c : components) {
MenuFlyoutItem newMenuItem = GetComponentMenuButton(c);
MenuFlyoutItem newMenuItem = MakeComponentMenuButton(c);
menuItems.Append(newMenuItem);
}

Expand Down Expand Up @@ -78,12 +79,12 @@ namespace winrt::ReactTestApp::implementation
ReactRootView().ComponentName(s.as<ComponentViewModel>()->AppKey());
}

void MainPage::OpenReactMenu(IInspectable const &, RoutedEventArgs)
void MainPage::OnReactMenuClick(IInspectable const &, RoutedEventArgs)
{
ReactButton().Flyout().ShowAt(ReactButton());
ReactMenuButton().Flyout().ShowAt(ReactMenuButton());
}

MenuFlyoutItem MainPage::GetComponentMenuButton(::ReactTestApp::Component &component)
MenuFlyoutItem MainPage::MakeComponentMenuButton(::ReactTestApp::Component &component)
{
hstring componentDisplayName = to_hstring(component.displayName.value_or(component.appKey));
hstring appKey = to_hstring(component.appKey);
Expand All @@ -101,18 +102,18 @@ namespace winrt::ReactTestApp::implementation
{
// Set close, minimize and maximize icons background to transparent
auto appView = ApplicationView::GetForCurrentView().TitleBar();
appView.ButtonBackgroundColor(winrt::Windows::UI::Colors::Transparent());
appView.BackgroundColor(winrt::Windows::UI::Colors::Transparent());
appView.ButtonBackgroundColor(Colors::Transparent());
appView.BackgroundColor(Colors::Transparent());

auto coreTitleBar = CoreApplication::GetCurrentView().TitleBar();
coreTitleBar.LayoutMetricsChanged({this, &MainPage::CoreTitleBarLayoutMetricsChanged});
coreTitleBar.LayoutMetricsChanged({this, &MainPage::OnCoreTitleBarLayoutMetricsChanged});
coreTitleBar.ExtendViewIntoTitleBar(true);
Window::Current().SetTitleBar(BackgroundElement());
}

// Adjust height of custom title bar to match close, minimize and maximize icons
void MainPage::CoreTitleBarLayoutMetricsChanged(CoreApplicationViewTitleBar const &sender,
IInspectable const &)
void MainPage::OnCoreTitleBarLayoutMetricsChanged(CoreApplicationViewTitleBar const &sender,
IInspectable const &)
{
TitleBar().Height(sender.Height());
}
Expand Down
8 changes: 4 additions & 4 deletions windows/ReactTestApp/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace winrt::ReactTestApp::implementation
Windows::UI::Xaml::RoutedEventArgs);
void LoadFromDevServer(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs);
void OpenReactMenu(Windows::Foundation::IInspectable const &,
winrt::Windows::UI::Xaml::RoutedEventArgs);
void OnReactMenuClick(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs);
Windows::Foundation::IAsyncAction
OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const &e);
using Base = MainPageT;
Expand All @@ -25,8 +25,8 @@ namespace winrt::ReactTestApp::implementation
void SetReactComponentName(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs);
Windows::UI::Xaml::Controls::MenuFlyoutItem
GetComponentMenuButton(::ReactTestApp::Component &component);
void CoreTitleBarLayoutMetricsChanged(
MakeComponentMenuButton(::ReactTestApp::Component &component);
void OnCoreTitleBarLayoutMetricsChanged(
Windows::ApplicationModel::Core::CoreApplicationViewTitleBar const &sender,
Windows::Foundation::IInspectable const &);
void SetUpTitleBar();
Expand Down
23 changes: 8 additions & 15 deletions windows/ReactTestApp/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@

<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ButtonBackground" Color="{ThemeResource SystemAltHighColor}"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ButtonBackground" Color="{ThemeResource SystemAltHighColor}"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="ButtonBackground" Color="{ThemeResource SystemAltHighColor}"/>
</ResourceDictionary>
</Page.Resources>

Expand All @@ -29,18 +22,18 @@

<Grid x:Name="TitleBar">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
<ColumnDefinition/>
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
</Grid.ColumnDefinitions>
<Grid x:Name="BackgroundElement" Grid.Column="1" Background="Transparent">
<Grid x:Name="BackgroundElement" Background="Transparent">
<TextBlock x:Name="AppTitle" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>

<Button Grid.Column="1" Content="React" x:Name="ReactButton" Click="OpenReactMenu">
<Button Content="React" x:Name="ReactMenuButton" Click="OnReactMenuClick">
<Button.Flyout>
<MenuFlyout x:Name="MenuFlyout" Placement="BottomEdgeAlignedLeft">
<MenuFlyout.MenuFlyoutPresenterStyle>
<Style TargetType= "MenuFlyoutPresenter" >
<Setter Property = "Margin" Value= "0,-5,0,0"/>
</Style>
</MenuFlyout.MenuFlyoutPresenterStyle>
<MenuFlyoutItem Text="Load from JS bundle" Click="LoadFromJSBundle"/>
<MenuFlyoutItem Text="Load from dev server" Click="LoadFromDevServer"/>
<MenuFlyoutSeparator/>
Expand Down
1 change: 0 additions & 1 deletion windows/ReactTestApp/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Windows.UI.Xaml.Shapes.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Navigation.h>
Expand Down

0 comments on commit 6382ad1

Please sign in to comment.