-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MVVM for the Actions page (#14292)
## Summary of the Pull Request Implements an `ActionsViewModel` for the `Actions` page in the SUI ## References ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments A few annoyances: - Because of the shifts in the UI when switching between edit mode/regular mode on the `KeyBindingViewModel`s, the page used to manually handle moving focus accordingly so that focus does not get lost. However, the page no longer owns the `KeyBindingViewModel`, instead the `ActionsViewModel` owns them but the `ActionsViewModel` cannot manually move focus around since it does not own the UI Element. So, the `ActionsViewModel` emits an event for the page to catch that tells the page to move focus (`FocusContainer`). - Similarly, the page used to manually update the `ContainerBackground` of the `KeyBindingViewModel` when the kbdVM enters `EditMode`. The `ActionsViewModel` does not have access to the page's resources though (to determine the correct background brush to use). So, the `ActionsViewModel` emits another event for the page to catch (`UpdateBackground`). ## Validation Steps Performed Actions page still works as before --------- Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
- Loading branch information
1 parent
d3a18b9
commit f30cbef
Showing
10 changed files
with
618 additions
and
513 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import "EnumEntry.idl"; | ||
import "ActionsViewModel.idl"; | ||
|
||
namespace Microsoft.Terminal.Settings.Editor | ||
{ | ||
runtimeclass ModifyKeyBindingEventArgs | ||
{ | ||
Microsoft.Terminal.Control.KeyChord OldKeys { get; }; | ||
Microsoft.Terminal.Control.KeyChord NewKeys { get; }; | ||
String OldActionName { get; }; | ||
String NewActionName { get; }; | ||
} | ||
|
||
runtimeclass KeyBindingViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged | ||
{ | ||
// Settings Model side | ||
String Name { get; }; | ||
String KeyChordText { get; }; | ||
|
||
// UI side | ||
Boolean ShowEditButton { get; }; | ||
Boolean IsInEditMode { get; }; | ||
Boolean IsNewlyAdded { get; }; | ||
Microsoft.Terminal.Control.KeyChord ProposedKeys; | ||
Object ProposedAction; | ||
Windows.UI.Xaml.Controls.Flyout AcceptChangesFlyout; | ||
String EditButtonName { get; }; | ||
String CancelButtonName { get; }; | ||
String AcceptButtonName { get; }; | ||
String DeleteButtonName { get; }; | ||
Windows.UI.Xaml.Media.Brush ContainerBackground { get; }; | ||
|
||
void EnterHoverMode(); | ||
void ExitHoverMode(); | ||
void ActionGotFocus(); | ||
void ActionLostFocus(); | ||
void EditButtonGettingFocus(); | ||
void EditButtonLosingFocus(); | ||
IObservableVector<String> AvailableActions { get; }; | ||
void ToggleEditMode(); | ||
void AttemptAcceptChanges(); | ||
void CancelChanges(); | ||
void DeleteKeyBinding(); | ||
|
||
event Windows.Foundation.TypedEventHandler<KeyBindingViewModel, ModifyKeyBindingEventArgs> ModifyKeyBindingRequested; | ||
event Windows.Foundation.TypedEventHandler<KeyBindingViewModel, Microsoft.Terminal.Control.KeyChord> DeleteKeyBindingRequested; | ||
} | ||
|
||
runtimeclass ActionsPageNavigationState | ||
{ | ||
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings; | ||
}; | ||
|
||
[default_interface] runtimeclass Actions : Windows.UI.Xaml.Controls.Page | ||
{ | ||
Actions(); | ||
ActionsPageNavigationState State { get; }; | ||
|
||
IObservableVector<KeyBindingViewModel> KeyBindingList { get; }; | ||
ActionsViewModel ViewModel { get; }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.