Skip to content

Commit 1cff7a8

Browse files
committed
Init
1 parent c489032 commit 1cff7a8

File tree

15 files changed

+463
-131
lines changed

15 files changed

+463
-131
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using CommunityToolkit.WinUI;
5+
6+
namespace Files.App.Controls
7+
{
8+
public partial class MenuFlyoutItemHeader : MenuFlyoutItem
9+
{
10+
[GeneratedDependencyProperty]
11+
public partial bool Header { get; set; }
12+
13+
public MenuFlyoutItemHeader()
14+
{
15+
//this.InitializeComponent();
16+
}
17+
}
18+
}

src/Files.App.Controls/Omnibar/Omnibar.Events.cs

Lines changed: 4 additions & 3 deletions
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

src/Files.App.Controls/Omnibar/Omnibar.Properties.cs

Lines changed: 11 additions & 0 deletions
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
}

src/Files.App.Controls/Omnibar/Omnibar.cs

Lines changed: 11 additions & 10 deletions
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
}

src/Files.App.Controls/Omnibar/Omnibar.xaml

Lines changed: 0 additions & 1 deletion
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

src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs

Lines changed: 8 additions & 0 deletions
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
}

src/Files.App/Data/Items/NavigationBarSuggestionItem.cs

Lines changed: 1 addition & 0 deletions
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;
Lines changed: 7 additions & 0 deletions
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+
}
Lines changed: 7 additions & 0 deletions
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+
}

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,9 +2141,6 @@
21412141
<data name="SplittingSize" xml:space="preserve">
21422142
<value>Splitting size</value>
21432143
</data>
2144-
<data name="DoNotSplit" xml:space="preserve">
2145-
<value>Do not split</value>
2146-
</data>
21472144
<data name="CD" xml:space="preserve">
21482145
<value>CD</value>
21492146
</data>
@@ -2198,15 +2195,6 @@
21982195
<data name="EditSettingsFile" xml:space="preserve">
21992196
<value>Edit settings file</value>
22002197
</data>
2201-
<data name="EditSettingsFileDescription" xml:space="preserve">
2202-
<value>Open settings file in your default editor</value>
2203-
</data>
2204-
<data name="ReleaseNotes" xml:space="preserve">
2205-
<value>Release Notes</value>
2206-
</data>
2207-
<data name="ReleaseNotesDescription" xml:space="preserve">
2208-
<value>Open Release Notes</value>
2209-
</data>
22102198
<data name="CannotCreateShortcutDialogTitle" xml:space="preserve">
22112199
<value>Creating a shortcut in this location requires administrator privileges</value>
22122200
</data>
@@ -3508,7 +3496,7 @@
35083496
<data name="StatusCenter_GitCloneInProgress_SubHeader" xml:space="preserve">
35093497
<value>Cloning {0} from "{1}" to "{2}"</value>
35103498
<comment>Shown in a StatusCenter card.</comment>
3511-
</data>
3499+
</data>
35123500
<data name="StatusCenter_InstallFontCanceled_Header" xml:space="preserve">
35133501
<value>Canceled installing {0} fonts</value>
35143502
<comment>Shown in a StatusCenter card.</comment>
@@ -3540,7 +3528,7 @@
35403528
<data name="StatusCenter_InstallFontInProgress_SubHeader" xml:space="preserve">
35413529
<value>Installing {0} font(s) from "{1}"</value>
35423530
<comment>Shown in a StatusCenter card.</comment>
3543-
</data>
3531+
</data>
35443532
<data name="StatusCenter_CopyCanceled_Header" xml:space="preserve">
35453533
<value>Canceled copying {0} item(s) to "{1}"</value>
35463534
<comment>Shown in a StatusCenter card.</comment>
@@ -3700,9 +3688,6 @@
37003688
<data name="FailedToSetBackground" xml:space="preserve">
37013689
<value>Failed to set the background wallpaper</value>
37023690
</data>
3703-
<data name="FailedToOpenSettingsFile" xml:space="preserve">
3704-
<value>Failed to open the settings file</value>
3705-
</data>
37063691
<data name="GitDeleteBranch" xml:space="preserve">
37073692
<value>Delete Git branch</value>
37083693
</data>
@@ -4122,18 +4107,6 @@
41224107
<value>Add to shelf</value>
41234108
<comment>Tooltip that displays when dragging items to the Shelf Pane</comment>
41244109
</data>
4125-
<data name="EnterHashToCompare" xml:space="preserve">
4126-
<value>Enter a hash to compare</value>
4127-
<comment>Placeholder that appears in the compare hash text box</comment>
4128-
</data>
4129-
<data name="HashesMatch" xml:space="preserve">
4130-
<value>Matches {0}</value>
4131-
<comment>Appears when two compared hashes match, e.g. "Matches SHA256"</comment>
4132-
</data>
4133-
<data name="HashesDoNotMatch" xml:space="preserve">
4134-
<value>No matches found</value>
4135-
<comment>Appears when two compared hashes don't match</comment>
4136-
</data>
41374110
<data name="PathOrAlias" xml:space="preserve">
41384111
<value>Path or alias</value>
41394112
</data>
@@ -4177,6 +4150,33 @@
41774150
<value>Cannot clone repo</value>
41784151
<comment>Cannot clone repo dialog title</comment>
41794152
</data>
4153+
<data name="DoNotSplit" xml:space="preserve">
4154+
<value>Do not split</value>
4155+
</data>
4156+
<data name="EditSettingsFileDescription" xml:space="preserve">
4157+
<value>Open settings file in your default editor</value>
4158+
</data>
4159+
<data name="ReleaseNotes" xml:space="preserve">
4160+
<value>Release Notes</value>
4161+
</data>
4162+
<data name="ReleaseNotesDescription" xml:space="preserve">
4163+
<value>Open Release Notes</value>
4164+
</data>
4165+
<data name="FailedToOpenSettingsFile" xml:space="preserve">
4166+
<value>Failed to open the settings file</value>
4167+
</data>
4168+
<data name="EnterHashToCompare" xml:space="preserve">
4169+
<value>Enter a hash to compare</value>
4170+
<comment>Placeholder that appears in the compare hash text box</comment>
4171+
</data>
4172+
<data name="HashesMatch" xml:space="preserve">
4173+
<value>Matches {0}</value>
4174+
<comment>Appears when two compared hashes match, e.g. "Matches SHA256"</comment>
4175+
</data>
4176+
<data name="HashesDoNotMatch" xml:space="preserve">
4177+
<value>No matches found</value>
4178+
<comment>Appears when two compared hashes don't match</comment>
4179+
</data>
41804180
<data name="CompareFile" xml:space="preserve">
41814181
<value>Compare a file</value>
41824182
<comment>Button that appears in file hash properties that allows the user to compare two files</comment>
@@ -4193,4 +4193,7 @@
41934193
<data name="EnableOmnibar" xml:space="preserve">
41944194
<value>Enable Omnibar</value>
41954195
</data>
4196+
<data name="OmnibarPathModeTextPlaceholder" xml:space="preserve">
4197+
<value>Enter a path to navigate to...</value>
4198+
</data>
41964199
</root>

0 commit comments

Comments
 (0)