Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Entry: Read-only Entry and Editor #1972

Merged
merged 25 commits into from
Jan 10, 2019
Merged

[Enhancement] Entry: Read-only Entry and Editor #1972

merged 25 commits into from
Jan 10, 2019

Conversation

almirvuk
Copy link
Contributor

@almirvuk almirvuk commented Feb 24, 2018

Description of Change

This PR adds the IsReadOnly bindable property to the InputView i.e.Editor and Entry controls. Default value is false so this change and usage of this property is backwards compatible.

Bugs Fixed

API Changes

Added:

  • BindableProperty InputView.IsReadOnlyProperty;

Changed:

  • None

Behavioral Changes

  • None

Supported Platforms

  • iOS
  • Android
  • UWP
  • Tizen
  • WPF
  • macOS
  • GTK

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

Remark

There was a section "Implications for CSS", can I get more info about that, is there any way for me to implement that also.

@almirvuk almirvuk changed the title [Enhancement] Entry: Read-only entry #1678 [Enhancement #1678] Entry: Read-only Entry and Editor Feb 24, 2018
@almirvuk almirvuk changed the title [Enhancement #1678] Entry: Read-only Entry and Editor [Enhancement] Entry: Read-only Entry (and Editor) Feb 24, 2018
@samhouts samhouts added this to Ready in v3.1.0 via automation Feb 24, 2018
@samhouts samhouts changed the title [Enhancement] Entry: Read-only Entry (and Editor) [Enhancement] Entry: Read-only Entry and Editor Feb 24, 2018
@@ -19,6 +19,7 @@ public EntryRenderer()
RegisterPropertyHandler(Entry.PlaceholderProperty, UpdatePlaceholder);
RegisterPropertyHandler(Entry.PlaceholderColorProperty, UpdatePlaceholderColor);
RegisterPropertyHandler(InputView.MaxLengthProperty, UpdateMaxLength);
RegisterPropertyHandler(Entry.IsReadOnlyProperty, UpdateIsReadOnly);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whitespace preceeding the if was lost here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I will fix that also :)

@@ -106,6 +107,10 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateMaxLength();
else if (e.PropertyName == Specifics.DetectReadingOrderFromContentProperty.PropertyName)
UpdateDetectReadingOrderFromContent();
else if (e.PropertyName == InputView.IsReadOnlyProperty.PropertyName)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can skip adding curly braces if there is a single statement nested under a predicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine

@@ -146,5 +147,10 @@ string MaxLengthFilter(ElmSharp.Entry entry, string s)

return null;
}

void UpdateIsReadOnly()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can move this above MaxLengthFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine.


void UpdateIsReadOnly()
{
Control.UserInteractionEnabled = !Element.IsReadOnly;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an FYI that UpdateEditable is also changing UserInteractionEnabled. If I set IsEnabled to false, then the control becomes read-only even though IsReadOnly is false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please look at other renderers to see if they are doing similar work. We should make sure IsEnabled and IsReadOnly play nice together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice point, thanks! :) Will fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If I set IsEnabled to false, then the control becomes read-only even though IsReadOnly is false.".

Yes, the main task of this Enhancement is to make control ReadOnly without changing the look of it, so if you set IsEnabled to false it will be "read-only" and also it will have a look like it is disabled. But if you are using only IsReadOnly = true, it will become ReadOnly and the look will not change.

So, maybe the best approach is to set IsReadOnly to true if IsEnabled == false ? :)

Copy link
Contributor

@adamped adamped Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename UpdateIsReadOnly() to UpdateUserInteraction()

In UpdateEditable, change the assignment of UserInteractionEnabled to point at this function instead.

Then in this function, do
Control.UserInteractionEnabled = !Element.IsReadonly && Element.IsEnabled

I think that should work, but you get the gist. You need to account for both properties now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yap @adamped suggestion is the correct one, we should have 1 method to handle this, the others call this.

Copy link
Contributor Author

@almirvuk almirvuk Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, and my personal deadline for this is like end of this weekend, we will see :)

@samhouts samhouts moved this from Ready to In Review in v3.1.0 Feb 27, 2018
Copy link
Member

@samhouts samhouts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Need to address the IsEnabled/IsReadOnly possible conflicts raised by @adrianknight89.
  2. Failing unit tests.

Thanks!

@rmarinho
Copy link
Member

Hey @almirvuk do you think you can address the comments on the PR and rebase?!

Thanks

@almirvuk
Copy link
Contributor Author

almirvuk commented Mar 21, 2018

@rmarinho can you please take a look at this comment/question #1972 (comment)

What do you think about this?

Also I am very close to finishing this, I think I need to finish Unit Tests, I have made some changes but I am stuck and I need somebody opinion about IsEnabled/IsReadOnly behaviour... and resolving these conflicts with rebase will be easy.

@samhouts samhouts added this to In Progress in Enhancements Mar 22, 2018
@dnfclas
Copy link

dnfclas commented Apr 9, 2018

CLA assistant check
All CLA requirements met.

@almirvuk
Copy link
Contributor Author

almirvuk commented Apr 9, 2018

I made some changes for iOS EditorRenderer that was problematic in the last pull request. I still need to do rebase and see what is the problem with unit tests (if they are mandatory?)... Can you please take a look. Thanks! 🙂

@rmarinho
Copy link
Member

Hey @almirvuk can you rebase , and yes unit tests are mandatory

@almirvuk
Copy link
Contributor Author

almirvuk commented May 5, 2018

@rmarinho I will do this by the end of the tomorrow :) Thanks

@almirvuk
Copy link
Contributor Author

almirvuk commented May 7, 2018

Unit tests and rebase, done ✔️

@almirvuk
Copy link
Contributor Author

almirvuk commented May 7, 2018

Obviously...there is a issue with my last push, I will fix this and do another one. Sorry 🙂

@samhouts samhouts added this to In Review in v3.6.0 May 7, 2018
@samhouts samhouts removed this from In Review in v3.1.0 May 7, 2018
@davidortinau davidortinau added this to the 3.1.0 milestone May 17, 2018
@samhouts samhouts removed this from In Review in v3.6.0 May 18, 2018
@samhouts samhouts removed this from the 3.1.0 milestone May 18, 2018
@samhouts samhouts added the retarget-branch-required PR or associated issues target a milestone. Please target this PR to the matching branch. label May 18, 2018
@samhouts samhouts added this to In Review in v3.1.0 May 18, 2018
@samhouts samhouts added this to In Review in v3.6.0 May 18, 2018
@almirvuk
Copy link
Contributor Author

almirvuk commented Jan 8, 2019

@PureWeen I invited you as collaborator on my fork repo, do I need to do anything else? :)

@PureWeen
Copy link
Contributor

PureWeen commented Jan 8, 2019

@almirvuk that looks like it worked! thank you

{
Control.Editable = !Element.IsReadOnly;
if (Element.IsReadOnly && Control.Window?.FirstResponder == Control.CurrentEditor)
Control.Window?.MakeFirstResponder(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarinho I added this code on MacOS to fix #4834 so please re-review macos

{
Control.Editable = !Element.IsReadOnly;
if (Element.IsReadOnly && Control.Window?.FirstResponder == Control.CurrentEditor)
Control.Window?.MakeFirstResponder(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarinho I added this code on MacOS to fix #4834 so please re-review macos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PureWeen PureWeen requested a review from rmarinho January 8, 2019 23:51
@PureWeen
Copy link
Contributor

PureWeen commented Jan 9, 2019

Android UI test failures are on 39821 (not caused by this change, fixed by #4866)
IOS10 passed but github is just reporting it wrong

Once MacOS changes are approved we can merge

@almirvuk
Copy link
Contributor Author

almirvuk commented Jan 9, 2019

Nice, thank you @PureWeen for the help with this PR 🤗

@PureWeen
Copy link
Contributor

@almirvuk Thank you for the good work! Hopefully we can get it merged before the PRs anniversary next month

@PureWeen PureWeen merged commit 5001460 into xamarin:master Jan 10, 2019
v3.6.0 automation moved this from In Progress to Done Jan 10, 2019
@PureWeen PureWeen deleted the feature/1678-read-only-entry branch January 10, 2019 16:21
PureWeen pushed a commit that referenced this pull request Jan 24, 2019
- fixes #1678
- fixes #4834

* InputView BindableProperty IsReadOnly

* Android Editor and Entry setup

* MacOS Editor and Entry setup

* Tizen Editor and Entry setup

* UAP Editor and Entry setup

* WPF Editor and Entry setup

* iOS Editor and Entry setup

* Issue1678 - TestContentPage added

* Tests added

* Tizen Editor and Entry fix

* UI Test fix

* Android fix for Entry and Editor.

* Unit Tests fix.

* Android Renderer first try.

* MacOS Entry renderer small fix.

* UpdateEditable fix.

* Android Entry and Editor reduced number of calls to BP.

* fix TestAttributes conflicts

* Remove keyboard

* [macOS] relinquish first responder

* [Android] remove call to UpdateCursorSelection

* [UWP] fix tabs
andreinitescu pushed a commit to andreinitescu/Xamarin.Forms that referenced this pull request Jan 29, 2019
- fixes xamarin#1678
- fixes xamarin#4834

* InputView BindableProperty IsReadOnly

* Android Editor and Entry setup

* MacOS Editor and Entry setup

* Tizen Editor and Entry setup

* UAP Editor and Entry setup

* WPF Editor and Entry setup

* iOS Editor and Entry setup

* Issue1678 - TestContentPage added

* Tests added

* Tizen Editor and Entry fix

* UI Test fix

* Android fix for Entry and Editor.

* Unit Tests fix.

* Android Renderer first try.

* MacOS Entry renderer small fix.

* UpdateEditable fix.

* Android Entry and Editor reduced number of calls to BP.

* fix TestAttributes conflicts

* Remove keyboard

* [macOS] relinquish first responder

* [Android] remove call to UpdateCursorSelection

* [UWP] fix tabs
@samhouts samhouts added this to Done in v4.0.0 Feb 2, 2019
@samhouts samhouts removed this from Done in v3.6.0 Feb 2, 2019
@samhouts samhouts modified the milestones: 4.0.0, 3.6.0 Feb 6, 2019
@samhouts samhouts removed this from Done in v4.0.0 Feb 7, 2019
@samhouts samhouts added this to Done in v3.6.0 Feb 7, 2019
@minaairsupport
Copy link

Nice work guys but I have small comment regarding to test case you provide to prove this feature is working , I think it will be better if you not just check the flag but implment the feature itseld
like

Entry entry = new Entry();
entry.SetValue(InputView.IsReadOnlyProperty, isReadOnly);
entry.Text = "Any thing"; // I make not sure if this the right poisition may be it should before set flag 
Assert.AreEqual(isReadOnly, entry.IsReadOnly);
//other assert 

test case provide

[TestCase(true)]
		public void IsReadOnlyTest(bool isReadOnly)
		{
			Entry entry = new Entry();
			entry.SetValue(InputView.IsReadOnlyProperty, isReadOnly);
			Assert.AreEqual(isReadOnly, entry.IsReadOnly);
		}

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested t/bug 🐛 labels Jun 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API-change Heads-up to reviewers that this PR may contain an API change community-sprint e/9 🕘 9 F100 inactive Issue is older than 6 months and needs to be retested t/bug 🐛 t/enhancement ➕
Projects
No open projects
Sprint 140
  
Blocked
Sprint 141
  
Blocked
Sprint 144
  
Ready for Review (PRs)
v3.6.0
  
Done