Skip to content

Commit f3858c1

Browse files
committed
feat: Simplify new tab page code
1 parent d0c353c commit f3858c1

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

src/Bluebird/Pages/NewTabPage.xaml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,19 @@
4949
</Grid.ColumnDefinitions>
5050
<TextBox
5151
x:Name="UrlBox"
52+
Grid.Column="0"
5253
Width="400"
5354
IsSpellCheckEnabled="False"
5455
KeyDown="UrlBox_KeyDown"
5556
Loaded="UrlBox_Loaded"
5657
PlaceholderText="Type here to search or enter url" />
57-
<StackPanel
58+
<Button
5859
Grid.Column="1"
60+
Height="32"
5961
Margin="5,0,0,0"
60-
Orientation="Horizontal">
61-
<Button
62-
Grid.Column="0"
63-
Height="32"
64-
Click="SearchButton_Click"
65-
Tag="Search">
66-
<Button.Content>
67-
<FontIcon Glyph="&#xE721;" />
68-
</Button.Content>
69-
</Button>
70-
<Button
71-
Grid.Column="1"
72-
Height="32"
73-
Margin="5,0,0,0"
74-
Click="SearchButton_Click"
75-
Content=""
76-
Tag="AISearch" />
77-
</StackPanel>
62+
Click="AISearchButton_Click"
63+
Content=""
64+
ToolTipService.ToolTip="Search with AI" />
7865
</Grid>
7966
</Grid>
8067
<!--<ListView

src/Bluebird/Pages/NewTabPage.xaml.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ private void UrlBox_KeyDown(object sender, KeyRoutedEventArgs e)
3737
if (e.Key == VirtualKey.Enter)
3838
{
3939
string input = (sender as TextBox).Text;
40-
ProcessQueryAndGo(input);
40+
if (!string.IsNullOrEmpty(input))
41+
{
42+
ProcessQueryAndGo(input);
43+
}
4144
}
4245
}
4346

@@ -47,20 +50,12 @@ private void NavigateToUrl(string query)
4750
Frame.Navigate(typeof(WebViewPage), parameters, new DrillInNavigationTransitionInfo());
4851
}
4952

50-
private void SearchButton_Click(object sender, RoutedEventArgs e)
53+
private void AISearchButton_Click(object sender, RoutedEventArgs e)
5154
{
5255
string query = UrlBox.Text;
5356
if (!string.IsNullOrEmpty(query))
5457
{
55-
switch ((sender as Button).Tag)
56-
{
57-
case "Search":
58-
ProcessQueryAndGo(query);
59-
break;
60-
case "AISearch":
61-
NavigateToUrl("https://www.perplexity.ai/search?q=" + query);
62-
break;
63-
}
58+
NavigateToUrl("https://www.perplexity.ai/search?q=" + query);
6459
}
6560
}
6661

0 commit comments

Comments
 (0)