Skip to content

Commit

Permalink
Add link to GitHub repo on about flyout (#1449)
Browse files Browse the repository at this point in the history
* Add link to GitHub repo on about flyout

* Update AboutFlyout page GitHub link margin.

* Update AboutPage GitHub link string.
  • Loading branch information
chaitanyamehta authored Dec 11, 2020
1 parent 61d06b2 commit c479378
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/Calculator/AboutFlyout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -72,5 +73,21 @@
Click="FeedbackButton_Click"/>

</StackPanel>
<RichTextBlock x:Name="AboutFlyoutContribute"
Grid.Row="2"
Grid.ColumnSpan="2"
Margin="12,18,12,6"
HorizontalAlignment="Left"
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
FontSize="{ThemeResource BodyFontSize}"
TextWrapping="Wrap">
<Paragraph>
<Run x:Name="ContributeRunBeforeLink"/><Hyperlink NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939"
TextDecorations="None"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?linkid=2099939">
<Run x:Name="ContributeRunLink"/>
</Hyperlink><Run x:Name="ContributeRunAfterLink"/>
</Paragraph>
</RichTextBlock>
</Grid>
</UserControl>
29 changes: 29 additions & 0 deletions src/Calculator/AboutFlyout.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ AboutFlyout::AboutFlyout()
auto copyrightText =
LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("AboutControlCopyright"), StringReference(to_wstring(BUILD_YEAR).c_str()));
AboutControlCopyrightRun->Text = copyrightText;

InitializeContributeTextBlock();
}

void AboutFlyout::FeedbackButton_Click(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
Expand All @@ -61,3 +63,30 @@ void AboutFlyout::SetDefaultFocus()
{
AboutFlyoutEULA->Focus(::FocusState::Programmatic);
}

void AboutFlyout::InitializeContributeTextBlock()
{
auto resProvider = AppResourceProvider::GetInstance();
std::wstring contributeHyperlinkText = resProvider->GetResourceString(L"AboutFlyoutContribute")->Data();

// The resource string has the 'GitHub' hyperlink wrapped with '%HL%'.
// Break the string and assign pieces appropriately.
static const std::wstring delimiter{ L"%HL%" };
static const size_t delimiterLength{ delimiter.length() };

// Find the delimiters.
size_t firstSplitPosition = contributeHyperlinkText.find(delimiter, 0);
assert(firstSplitPosition != std::wstring::npos);
size_t secondSplitPosition = contributeHyperlinkText.find(delimiter, firstSplitPosition + 1);
assert(secondSplitPosition != std::wstring::npos);
size_t hyperlinkTextLength = secondSplitPosition - (firstSplitPosition + delimiterLength);

// Assign pieces.
auto contributeTextBeforeHyperlink = ref new String(contributeHyperlinkText.substr(0, firstSplitPosition).c_str());
auto contributeTextLink = ref new String(contributeHyperlinkText.substr(firstSplitPosition + delimiterLength, hyperlinkTextLength).c_str());
auto contributeTextAfterHyperlink = ref new String(contributeHyperlinkText.substr(secondSplitPosition + delimiterLength).c_str());

ContributeRunBeforeLink->Text = contributeTextBeforeHyperlink;
ContributeRunLink->Text = contributeTextLink;
ContributeRunAfterLink->Text = contributeTextAfterHyperlink;
}
1 change: 1 addition & 0 deletions src/Calculator/AboutFlyout.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public
private:
void FeedbackButton_Click(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void SetVersionString();
void InitializeContributeTextBlock();
};
} /* namespace CalculatorApp */
4 changes: 4 additions & 0 deletions src/Calculator/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,10 @@
<value>© %1 Microsoft. All rights reserved.</value>
<comment>{Locked="%1"}. Copyright statement, displayed on the About panel. %1 = the current year (4 digits)</comment>
</data>
<data name="AboutFlyoutContribute" xml:space="preserve">
<value>To learn how you can contribute to Windows Calculator, check out the project on %HL%GitHub%HL%.</value>
<comment>{Locked="%HL%GitHub%HL%"}. GitHub link, Displayed on the About panel</comment>
</data>
<data name="AboutButton.Content" xml:space="preserve">
<value>About</value>
<comment>The text that shows in the dropdown navigation control to open About panel</comment>
Expand Down
15 changes: 8 additions & 7 deletions src/Calculator/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Style x:Key="AboutFlyoutPresenterStyle" TargetType="FlyoutPresenter">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="AutomationProperties.AccessibilityView" Value="Raw"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
</Style>
<Style x:Key="NavViewItemStyle" TargetType="muxc:NavigationViewItem">
<Setter Property="KeyTipPlacementMode" Value="Right"/>
Expand Down Expand Up @@ -174,18 +175,18 @@

<muxc:NavigationView.PaneFooter>
<muxc:NavigationViewItem x:Name="AboutButton"
x:Uid="AboutButton"
Style="{StaticResource NavViewItemStyle}"
Tapped="OnAboutButtonClick">
x:Uid="AboutButton"
Style="{StaticResource NavViewItemStyle}"
Tapped="OnAboutButtonClick">
<muxc:NavigationViewItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xe946;"/>
</muxc:NavigationViewItem.Icon>
<FlyoutBase.AttachedFlyout>
<Flyout x:Name="AboutPageFlyout"
x:Uid="AboutPageFlyout"
Closed="OnAboutFlyoutClosed"
FlyoutPresenterStyle="{StaticResource AboutFlyoutPresenterStyle}"
Opened="OnAboutFlyoutOpened">
x:Uid="AboutPageFlyout"
Closed="OnAboutFlyoutClosed"
FlyoutPresenterStyle="{StaticResource AboutFlyoutPresenterStyle}"
Opened="OnAboutFlyoutOpened">
<local:AboutFlyout x:Name="AboutPage" x:Load="False"/>
</Flyout>
</FlyoutBase.AttachedFlyout>
Expand Down

0 comments on commit c479378

Please sign in to comment.