Skip to content
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

Jwoo/toggle view update #4204

Merged
merged 4 commits into from
Jun 26, 2020
Merged

Jwoo/toggle view update #4204

merged 4 commits into from
Jun 26, 2020

Conversation

jwoo-msft
Copy link
Member

@jwoo-msft jwoo-msft commented Jun 22, 2020

Related Issue

Fixed #4052, Fixed #3978

Description

#4052 mentioned that "stretch" and "auto" did not work very well when Input.Toggle is the only item of Column. This is an expected behavior since the input toggle is implemented using UITableView, and label space provided by UITableView has strong compression resistance. However, using UITableView as a superview for Input.Toggle is too heavy since UITableView has functions that can't be utilized in Input.Toggle. Implemented Input.Toggle as a XIB instance that allows easier customization of Input.Toggle, and used simpler UI inside the XIB.

How Verified

How you verified the fix, including one or all of the following:

  1. attached screen shots.
    AFTER
    image

BEFORE
image

  1. existing json cards are verified.
Microsoft Reviewers: Open in CodeFlow

@shalinijoshi19
Copy link
Member

@golddove is added to the review. #Closed

@@ -37,38 +38,47 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
{
std::shared_ptr<HostConfig> config = [acoConfig getHostConfig];
std::shared_ptr<BaseCardElement> elem = [acoElem element];
std::shared_ptr<ToggleInput> toggleBlck = std::dynamic_pointer_cast<ToggleInput>(elem);
std::shared_ptr<ToggleInput> adaptiveToggleInput = std::dynamic_pointer_cast<ToggleInput>(elem);

NSBundle *bundle = [NSBundle bundleWithIdentifier:@"MSFT.AdaptiveCards"];
if (!bundle) { // https://github.com/Microsoft/AdaptiveCards/issues/1834
Copy link
Member

Choose a reason for hiding this comment

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

Microsoft [](start = 41, length = 9)

Nit: This looks to be a TODO; In that case, can you update teh comment to be more explicit following a "TODO: [Link to the tracking issue] Log warnings and errors"

toggleView.title.textColor = getForegroundUIColorFromAdaptiveAttribute(config, viewGroup.style);
toggleView.title.adjustsFontSizeToFitWidth = NO;
if (!adaptiveToggleInput->GetWrap()) {
toggleView.title.numberOfLines = 1;
Copy link
Member

Choose a reason for hiding this comment

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

1; [](start = 41, length = 2)

In general for code readability avoid hardcoded literals and magic numbers; Trying to understand the logic here - So if wrap property isnt specified we interpret/default to 1 for its title line count? This almost feels like an initialization operation that say can be handled at the constructor for ACRToggleInputView no?

Copy link
Member Author

Choose a reason for hiding this comment

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

iOS renderer defaults number of lines to zero. If zero, text box will keep increasing its height with longer text. iOS renderer limits number of lines to 1, and its effect is same as having wrap property set to "false".

Copy link
Member

@shalinijoshi19 shalinijoshi19 left a comment

Choose a reason for hiding this comment

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

:shipit:

@jwoo-msft jwoo-msft merged commit f3e9ee6 into main Jun 26, 2020
@jwoo-msft jwoo-msft deleted the jwoo/toggle-view-update branch June 26, 2020 17:19
jwoo-msft added a commit that referenced this pull request Jul 7, 2020
* fixed the crash when there is no image is provided

* Updated Toggle Input to respond better to superview's width

* updated default value of toggle switch

Co-authored-by: shalinijoshi19 <shalinij@microsoft.com>
@shalinijoshi19 shalinijoshi19 added this to the 20.06 milestone Jul 10, 2020
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* fixed the crash when there is no image is provided

* Updated Toggle Input to respond better to superview's width

* updated default value of toggle switch

Co-authored-by: shalinijoshi19 <shalinij@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants