Skip to content

Commit 255e712

Browse files
committed
Init
1 parent ee6674e commit 255e712

14 files changed

+425
-132
lines changed

Diff for: src/Files.App.Controls/Omnibar/Omnibar.Events.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private void Omnibar_SizeChanged(object sender, SizeChangedEventArgs e)
1616

1717
private void AutoSuggestBox_GotFocus(object sender, RoutedEventArgs e)
1818
{
19-
_isFocused = true;
19+
IsFocused = true;
2020

2121
VisualStateManager.GoToState(CurrentSelectedMode, "Focused", true);
2222
VisualStateManager.GoToState(_textBox, "InputAreaVisible", true);
@@ -30,7 +30,7 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
3030
if (_textBox.ContextFlyout.IsOpen)
3131
return;
3232

33-
_isFocused = false;
33+
IsFocused = false;
3434

3535
if (CurrentSelectedMode?.ContentOnInactive is not null)
3636
{
@@ -92,7 +92,8 @@ private void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
9292

9393
private void AutoSuggestBox_TextChanged(object sender, TextChangedEventArgs e)
9494
{
95-
CurrentSelectedMode!.Text = _textBox.Text;
95+
if (string.Compare(_textBox.Text, CurrentSelectedMode!.Text, StringComparison.OrdinalIgnoreCase) is not 0)
96+
CurrentSelectedMode!.Text = _textBox.Text;
9697

9798
// UpdateSuggestionListView();
9899

Diff for: src/Files.App.Controls/Omnibar/Omnibar.Properties.cs

+11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ public partial class Omnibar
1313
[GeneratedDependencyProperty]
1414
public partial OmnibarMode? CurrentSelectedMode { get; set; }
1515

16+
[GeneratedDependencyProperty]
17+
public partial string? CurrentSelectedModeName { get; set; }
18+
1619
[GeneratedDependencyProperty]
1720
public partial Thickness AutoSuggestBoxPadding { get; set; }
21+
22+
[GeneratedDependencyProperty]
23+
public partial bool IsFocused { get; set; }
24+
25+
partial void OnCurrentSelectedModeChanged(OmnibarMode? newValue)
26+
{
27+
CurrentSelectedModeName = newValue?.ModeName;
28+
}
1829
}
1930
}

Diff for: src/Files.App.Controls/Omnibar/Omnibar.cs

+11-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public partial class Omnibar : Control
2828
private Border _textBoxSuggestionsContainerBorder = null!;
2929
private ListView _textBoxSuggestionsListView = null!;
3030

31-
private bool _isFocused;
3231
private string _userInput = string.Empty;
3332
private OmnibarTextChangeReason _textChangeReason = OmnibarTextChangeReason.None;
3433

@@ -148,15 +147,15 @@ public void ChangeMode(OmnibarMode modeToExpand, bool shouldFocus = false, bool
148147
CurrentSelectedMode = modeToExpand;
149148

150149
_textChangeReason = OmnibarTextChangeReason.ProgrammaticChange;
151-
_textBox.Text = CurrentSelectedMode.Text ?? string.Empty;
150+
ChangeTextBoxText(CurrentSelectedMode.Text ?? string.Empty);
152151

153152
// Move cursor of the TextBox to the tail
154153
_textBox.Select(_textBox.Text.Length, 0);
155154

156155
VisualStateManager.GoToState(CurrentSelectedMode, "Focused", true);
157156
CurrentSelectedMode.OnChangingCurrentMode(true);
158157

159-
if (_isFocused)
158+
if (IsFocused)
160159
{
161160
VisualStateManager.GoToState(CurrentSelectedMode, "Focused", true);
162161
VisualStateManager.GoToState(_textBox, "InputAreaVisible", true);
@@ -174,7 +173,7 @@ public void ChangeMode(OmnibarMode modeToExpand, bool shouldFocus = false, bool
174173
if (shouldFocus)
175174
_textBox.Focus(FocusState.Keyboard);
176175

177-
TryToggleIsSuggestionsPopupOpen(_isFocused && CurrentSelectedMode?.SuggestionItemsSource is not null);
176+
TryToggleIsSuggestionsPopupOpen(IsFocused && CurrentSelectedMode?.SuggestionItemsSource is not null);
178177

179178
// Remove the reposition transition from the all modes
180179
if (useTransition)
@@ -189,7 +188,7 @@ public void ChangeMode(OmnibarMode modeToExpand, bool shouldFocus = false, bool
189188

190189
public bool TryToggleIsSuggestionsPopupOpen(bool wantToOpen)
191190
{
192-
if (wantToOpen && (!_isFocused || CurrentSelectedMode?.SuggestionItemsSource is null))
191+
if (wantToOpen && (!IsFocused || CurrentSelectedMode?.SuggestionItemsSource is null))
193192
return false;
194193

195194
_textBoxSuggestionsPopup.IsOpen = wantToOpen;
@@ -205,10 +204,15 @@ public void ChooseSuggestionItem(object obj)
205204
if (CurrentSelectedMode.UpdateTextOnSelect)
206205
{
207206
_textChangeReason = OmnibarTextChangeReason.SuggestionChosen;
208-
_textBox.Text = GetObjectText(obj);
207+
ChangeTextBoxText(GetObjectText(obj));
209208
}
210209

211210
SuggestionChosen?.Invoke(this, new(CurrentSelectedMode, obj));
211+
}
212+
213+
internal protected void ChangeTextBoxText(string text)
214+
{
215+
_textBox.Text = text;
212216

213217
// Move the cursor to the end of the TextBox
214218
_textBox?.Select(_textBox.Text.Length, 0);
@@ -245,10 +249,7 @@ private void RevertTextToUserInput()
245249
_textBoxSuggestionsListView.SelectedIndex = -1;
246250
_textChangeReason = OmnibarTextChangeReason.ProgrammaticChange;
247251

248-
_textBox.Text = _userInput ?? "";
249-
250-
// Move the cursor to the end of the TextBox
251-
_textBox?.Select(_textBox.Text.Length, 0);
252+
ChangeTextBoxText(_userInput ?? "");
252253
}
253254
}
254255
}

Diff for: src/Files.App.Controls/Omnibar/Omnibar.xaml

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
Height="{TemplateBinding Height}"
134134
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
135135
Background="{TemplateBinding Background}"
136-
CornerRadius="{TemplateBinding CornerRadius}"
137136
TabFocusNavigation="Local">
138137
<!-- Mode Button -->
139138
<Border

Diff for: src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs

+8
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,13 @@ public partial class OmnibarMode
3939

4040
[GeneratedDependencyProperty(DefaultValue = true)]
4141
public partial bool UpdateTextOnSelect { get; set; }
42+
43+
partial void OnTextChanged(string? newValue)
44+
{
45+
if (_ownerRef is null || _ownerRef.TryGetTarget(out var owner) is false)
46+
return;
47+
48+
owner.ChangeTextBoxText(newValue ?? string.Empty);
49+
}
4250
}
4351
}

Diff for: src/Files.App/Data/Items/NavigationBarSuggestionItem.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Files.App.Data.Items
55
{
6+
[Obsolete("Remove once Omnibar goes out of experimental.")]
67
public sealed partial class NavigationBarSuggestionItem : ObservableObject
78
{
89
private string? _Text;

Diff for: src/Files.App/Data/Models/BreadcrumbBarItemModel.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Files.App.Data.Models
5+
{
6+
internal record BreadcrumbBarItemModel(string Text);
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Files.App.Data.Models
5+
{
6+
internal record OmnibarPathModeSuggestionModel(string Path, string DisplayName);
7+
}

Diff for: src/Files.App/Strings/en-US/Resources.resw

+32-29
Original file line numberDiff line numberDiff line change
@@ -2138,9 +2138,6 @@
21382138
<data name="SplittingSize" xml:space="preserve">
21392139
<value>Splitting size</value>
21402140
</data>
2141-
<data name="DoNotSplit" xml:space="preserve">
2142-
<value>Do not split</value>
2143-
</data>
21442141
<data name="CD" xml:space="preserve">
21452142
<value>CD</value>
21462143
</data>
@@ -2195,15 +2192,6 @@
21952192
<data name="EditSettingsFile" xml:space="preserve">
21962193
<value>Edit settings file</value>
21972194
</data>
2198-
<data name="EditSettingsFileDescription" xml:space="preserve">
2199-
<value>Open settings file in your default editor</value>
2200-
</data>
2201-
<data name="ReleaseNotes" xml:space="preserve">
2202-
<value>Release Notes</value>
2203-
</data>
2204-
<data name="ReleaseNotesDescription" xml:space="preserve">
2205-
<value>Open Release Notes</value>
2206-
</data>
22072195
<data name="CannotCreateShortcutDialogTitle" xml:space="preserve">
22082196
<value>Creating a shortcut in this location requires administrator privileges</value>
22092197
</data>
@@ -3505,7 +3493,7 @@
35053493
<data name="StatusCenter_GitCloneInProgress_SubHeader" xml:space="preserve">
35063494
<value>Cloning {0} from "{1}" to "{2}"</value>
35073495
<comment>Shown in a StatusCenter card.</comment>
3508-
</data>
3496+
</data>
35093497
<data name="StatusCenter_InstallFontCanceled_Header" xml:space="preserve">
35103498
<value>Canceled installing {0} fonts</value>
35113499
<comment>Shown in a StatusCenter card.</comment>
@@ -3537,7 +3525,7 @@
35373525
<data name="StatusCenter_InstallFontInProgress_SubHeader" xml:space="preserve">
35383526
<value>Installing {0} font(s) from "{1}"</value>
35393527
<comment>Shown in a StatusCenter card.</comment>
3540-
</data>
3528+
</data>
35413529
<data name="StatusCenter_CopyCanceled_Header" xml:space="preserve">
35423530
<value>Canceled copying {0} item(s) to "{1}"</value>
35433531
<comment>Shown in a StatusCenter card.</comment>
@@ -3697,9 +3685,6 @@
36973685
<data name="FailedToSetBackground" xml:space="preserve">
36983686
<value>Failed to set the background wallpaper</value>
36993687
</data>
3700-
<data name="FailedToOpenSettingsFile" xml:space="preserve">
3701-
<value>Failed to open the settings file</value>
3702-
</data>
37033688
<data name="GitDeleteBranch" xml:space="preserve">
37043689
<value>Delete Git branch</value>
37053690
</data>
@@ -4119,18 +4104,6 @@
41194104
<value>Add to shelf</value>
41204105
<comment>Tooltip that displays when dragging items to the Shelf Pane</comment>
41214106
</data>
4122-
<data name="EnterHashToCompare" xml:space="preserve">
4123-
<value>Enter a hash to compare</value>
4124-
<comment>Placeholder that appears in the compare hash text box</comment>
4125-
</data>
4126-
<data name="HashesMatch" xml:space="preserve">
4127-
<value>Matches {0}</value>
4128-
<comment>Appears when two compared hashes match, e.g. "Matches SHA256"</comment>
4129-
</data>
4130-
<data name="HashesDoNotMatch" xml:space="preserve">
4131-
<value>No matches found</value>
4132-
<comment>Appears when two compared hashes don't match</comment>
4133-
</data>
41344107
<data name="PathOrAlias" xml:space="preserve">
41354108
<value>Path or alias</value>
41364109
</data>
@@ -4174,6 +4147,33 @@
41744147
<value>Cannot clone repo</value>
41754148
<comment>Cannot clone repo dialog title</comment>
41764149
</data>
4150+
<data name="DoNotSplit" xml:space="preserve">
4151+
<value>Do not split</value>
4152+
</data>
4153+
<data name="EditSettingsFileDescription" xml:space="preserve">
4154+
<value>Open settings file in your default editor</value>
4155+
</data>
4156+
<data name="ReleaseNotes" xml:space="preserve">
4157+
<value>Release Notes</value>
4158+
</data>
4159+
<data name="ReleaseNotesDescription" xml:space="preserve">
4160+
<value>Open Release Notes</value>
4161+
</data>
4162+
<data name="FailedToOpenSettingsFile" xml:space="preserve">
4163+
<value>Failed to open the settings file</value>
4164+
</data>
4165+
<data name="EnterHashToCompare" xml:space="preserve">
4166+
<value>Enter a hash to compare</value>
4167+
<comment>Placeholder that appears in the compare hash text box</comment>
4168+
</data>
4169+
<data name="HashesMatch" xml:space="preserve">
4170+
<value>Matches {0}</value>
4171+
<comment>Appears when two compared hashes match, e.g. "Matches SHA256"</comment>
4172+
</data>
4173+
<data name="HashesDoNotMatch" xml:space="preserve">
4174+
<value>No matches found</value>
4175+
<comment>Appears when two compared hashes don't match</comment>
4176+
</data>
41774177
<data name="CompareFile" xml:space="preserve">
41784178
<value>Compare a file</value>
41794179
<comment>Button that appears in file hash properties that allows the user to compare two files</comment>
@@ -4190,4 +4190,7 @@
41904190
<data name="EnableOmnibar" xml:space="preserve">
41914191
<value>Enable Omnibar</value>
41924192
</data>
4193+
<data name="OmnibarPathModeTextPlaceholder" xml:space="preserve">
4194+
<value>Enter a path to navigate to...</value>
4195+
</data>
41934196
</root>

0 commit comments

Comments
 (0)