-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A mostly-functioning WASDK ScrollView handler * Forgot to check these in * Add request method to IScrollView * Working implementation of CommandMapper and working WinUI ScrollView scroll requests * Remove Actions from PropertyMapper and into CommandMapper * Ported Android ScrollViewRenderer to handler * De-linqify * iOS ScrollViewHandler * ScrollViewHandler iOS (with ContentSize) * Add device tests for ScrollViewHandlers * Remove defunct tests * Fix NRE * Reinstate IntrinsicContentSize check - the bug this was removed to prevent is fixed by PR #1700. * Fix nullability * Fix whitespace * Whitespace * Whitespace * Yes, I'm being picky about whitespace Co-authored-by: Jonathan Dick <jondick@gmail.com> Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
- Loading branch information
1 parent
6230651
commit 16d56c6
Showing
39 changed files
with
991 additions
and
187 deletions.
There are no files selected for viewing
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
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
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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Command = System.Action<Microsoft.Maui.IElementHandler, Microsoft.Maui.IElement, object?>; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public abstract class CommandMapper | ||
{ | ||
readonly Dictionary<string, Command> _mapper = new(); | ||
|
||
CommandMapper? _chained; | ||
|
||
public CommandMapper() | ||
{ | ||
} | ||
|
||
public CommandMapper(CommandMapper chained) | ||
{ | ||
Chained = chained; | ||
} | ||
|
||
private protected virtual void SetPropertyCore(string key, Command action) | ||
{ | ||
_mapper[key] = action; | ||
} | ||
|
||
private protected virtual void InvokeCore(string key, IElementHandler viewHandler, IElement virtualView, object? args) | ||
{ | ||
var action = GetCommandCore(key); | ||
action?.Invoke(viewHandler, virtualView, args); | ||
} | ||
|
||
private protected virtual Command? GetCommandCore(string key) | ||
{ | ||
if (_mapper.TryGetValue(key, out var action)) | ||
return action; | ||
else if (Chained is not null) | ||
return Chained.GetCommandCore(key); | ||
else | ||
return null; | ||
} | ||
|
||
internal void Invoke(IElementHandler viewHandler, IElement? virtualView, string property, object? args) | ||
{ | ||
if (virtualView == null) | ||
return; | ||
|
||
InvokeCore(property, viewHandler, virtualView, args); | ||
} | ||
|
||
public CommandMapper? Chained | ||
{ | ||
get => _chained; | ||
set | ||
{ | ||
_chained = value; | ||
} | ||
} | ||
} | ||
|
||
public class CommandMapper<TVirtualView, TViewHandler> : CommandMapper | ||
where TVirtualView : IElement | ||
where TViewHandler : IElementHandler | ||
{ | ||
public CommandMapper() | ||
{ | ||
} | ||
|
||
public CommandMapper(CommandMapper chained) | ||
: base(chained) | ||
{ | ||
} | ||
|
||
public Action<TViewHandler, TVirtualView, object?> this[string key] | ||
{ | ||
get | ||
{ | ||
var action = GetCommandCore(key) ?? throw new IndexOutOfRangeException($"Unable to find mapping for '{nameof(key)}'."); | ||
return new Action<TViewHandler, TVirtualView, object?>((h, v, o) => action.Invoke(h, v, o)); | ||
} | ||
set => Add(key, value); | ||
} | ||
|
||
|
||
public void Add(string key, Action<TViewHandler, TVirtualView> action) => | ||
Add(key, action); | ||
|
||
public void Add(string key, Action<TViewHandler, TVirtualView, object?> action) => | ||
SetPropertyCore(key, (h, v, o) => action?.Invoke((TViewHandler)h, (TVirtualView)v, o)); | ||
} | ||
|
||
public class CommandMapper<TVirtualView> : PropertyMapper<TVirtualView, IElementHandler> | ||
where TVirtualView : IElement | ||
{ | ||
public CommandMapper() | ||
{ | ||
} | ||
|
||
public CommandMapper(PropertyMapper chained) | ||
: base(chained) | ||
{ | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.