-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port Editor Placeholder text and color properties #573
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
10ecb92
Editor placeholder in progress
brunck c463a8d
mostly iOS changes
brunck cb36c55
Merge branch 'main' into editor-placeholder
brunck b119d3a
Placholder text and color properties; added tests
brunck 89afc30
Added more [PortHandler]
brunck d591f35
cleanup
brunck eac65a5
cleanup
brunck 807adac
cleanup
brunck a8f2ff3
Merge branch 'main' into editor-placeholder
brunck 0b356bb
Fix merge
brunck 8995e66
Merge remote-tracking branch 'origin/main' into pr/573
mattleibow 9a71782
Merge remote-tracking branch 'origin/main' into pr/573
mattleibow 52b93ff
Changes after code review
brunck e5c3655
Merge main
hartez 9b7da6c
Merge main
hartez 5a9b189
Fix merge issues
hartez File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using UIKit; | ||
using Microsoft.Maui.Platform.iOS; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public static class EditorExtensions | ||
{ | ||
public static void UpdatePlaceholder(this MauiTextView textView, IEditor editor) | ||
{ | ||
textView.PlaceholderText = editor.Placeholder; | ||
} | ||
|
||
public static void UpdatePlaceholderColor(this MauiTextView textView, IEditor editor, UIColor? defaultPlaceholderColor) | ||
{ | ||
Color placeholderColor = editor.PlaceholderColor; | ||
if (placeholderColor.IsDefault) | ||
textView.PlaceholderTextColor = defaultPlaceholderColor; | ||
else | ||
textView.PlaceholderTextColor = placeholderColor.ToNative(); | ||
} | ||
} | ||
} |
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,67 @@ | ||
using UIKit; | ||
using CoreGraphics; | ||
using Foundation; | ||
|
||
namespace Microsoft.Maui.Platform.iOS | ||
{ | ||
public class MauiTextView : UITextView | ||
{ | ||
UILabel PlaceholderLabel { get; } = new UILabel | ||
{ | ||
BackgroundColor = UIColor.Clear, | ||
Lines = 0 | ||
}; | ||
|
||
public MauiTextView(CGRect frame) : base(frame) | ||
{ | ||
InitPlaceholderLabel(); | ||
} | ||
|
||
public string? PlaceholderText | ||
{ | ||
get => PlaceholderLabel.Text; | ||
set | ||
{ | ||
PlaceholderLabel.Text = value; | ||
PlaceholderLabel.SizeToFit(); | ||
} | ||
} | ||
|
||
public UIColor? PlaceholderTextColor | ||
{ | ||
get => PlaceholderLabel.TextColor; | ||
set => PlaceholderLabel.TextColor = value; | ||
} | ||
|
||
public void HidePlaceholder(bool hide) | ||
{ | ||
PlaceholderLabel.Hidden = hide; | ||
} | ||
|
||
void InitPlaceholderLabel() | ||
{ | ||
AddSubview(PlaceholderLabel); | ||
|
||
var edgeInsets = TextContainerInset; | ||
var lineFragmentPadding = TextContainer.LineFragmentPadding; | ||
|
||
var vConstraints = NSLayoutConstraint.FromVisualFormat( | ||
"V:|-" + edgeInsets.Top + "-[PlaceholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(), | ||
NSDictionary.FromObjectsAndKeys( | ||
new NSObject[] { PlaceholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) | ||
); | ||
|
||
var hConstraints = NSLayoutConstraint.FromVisualFormat( | ||
"H:|-" + lineFragmentPadding + "-[PlaceholderLabel]-" + lineFragmentPadding + "-|", | ||
0, new NSDictionary(), | ||
NSDictionary.FromObjectsAndKeys( | ||
new NSObject[] { PlaceholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) | ||
); | ||
|
||
PlaceholderLabel.TranslatesAutoresizingMaskIntoConstraints = false; | ||
|
||
AddConstraints(hConstraints); | ||
AddConstraints(vConstraints); | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.