What is a Constraint in SwiftUI? - swiftui

I'm getting this error [LayoutConstraints] Unable to simultaneously satisfy constraints. with a bunch of logs below it (shown below). There is this post attempting to solve it. But I'm not sure what a constraint is and I can't find any documentation on it's definition/diagrams.
Is there an explanation anywhere on what constraints are? This documentation on NSLayoutConstraint is pretty dense and cryptic to me e.g. "constraint based layout system." An explanation would be super beneficial to help me debug this.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6000021777a0 UIView:0x7fe80893f840.trailing == _UIBackButtonMaskView:0x7fe808939a90.trailing (active)>",
"<NSLayoutConstraint:0x600002168780 'Mask_Trailing_Trailing' _UIBackButtonMaskView:0x7fe808939a90.trailing == BackButton.trailing (active, names: BackButton:0x7fe808a18380 )>",
"<NSLayoutConstraint:0x6000021688c0 'MaskEV_Leading_BIB_Trailing' H:[_UIModernBarButton:0x7fe80891d0c0]-(0)-[UIView:0x7fe80893f840] (active)>",
"<NSLayoutConstraint:0x600002168fa0 'UINav_static_button_horiz_position' _UIModernBarButton:0x7fe80891d0c0.leading == UILayoutGuide:0x600003b61880'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600002169040 'UINavItemContentGuide-leading' H:[BackButton]-(6)-[UILayoutGuide:0x600003b61260'UINavigationBarItemContentLayoutGuide'] (active, names: BackButton:0x7fe808a18380 )>",
"<NSLayoutConstraint:0x60000217f7a0 'UINavItemContentGuide-trailing' UILayoutGuide:0x600003b61260'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x7fe808b2a9a0.trailing (active)>",
"<NSLayoutConstraint:0x60000216f1b0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7fe808b2a9a0.width == 0 (active)>",
"<NSLayoutConstraint:0x60000217fb60 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600003b61880'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x7fe808b2a9a0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000021777a0 UIView:0x7fe80893f840.trailing == _UIBackButtonMaskView:0x7fe808939a90.trailing (active)>

Related

How to set required fields in Power Apps

I have various Text input fields in my blank page of Power Apps, I want to implement a functionality where the user is unable to submit the form if any of the fields are kept blank. I saw various sources and used this on my submit BUTTON. Selecting DisplayMode and writing this code there:
If(!IsBlank(TLow.Text || !IsBlank( THigh.Text ||
!IsBlank(TTime.Text || !IsBlank( AlertSeverity.Text ||
!IsBlank(RTime.Text || !IsBlank(An.Text)))))),
DisplayMode.Disabled,DisplayMode.Edit)
However I am unable to achieve what I want ( i.e Submit button should only be enabled if all the fields are filled )
Where am I going wrong?
I was doing a very small error , I was not converting "number" to "Text" value. This is the code I implemented and achieved my functionality
If(!IsBlank(AlertDescription.Text) && !IsBlank(AlertSeverity.Text)
&& !IsBlank(Value(ThresholdHigh.Text))
&& !IsBlank(Value(ThresholdLow.Text))
&& !IsBlank(Value(ThresholdTime.Text))
&& !IsBlank(Value(ResolutionTime.Text)),DisplayMode.Edit,DisplayMode.Disabled)

JMeter - How can I use multiple conditions in IF Controller?

Here is my code:
In If Controller -> Condition (Default Javascript) I am providing following
"${responsecode}" == "404" || "${responsecode}" == "500" && "${responseMessage}" == "Not Found"
Yes you can, assuming your current condition SMTP Sampler will be executed:
If ${responsecode} variable is 404
OR
If ${responsecode} variable is 500 AND ${responseMessage} variable is Not Found
I doubt that you will get Not Found message given Response Code 500, most likely you will get an Internal Server Error there so maybe you should amend your condition to look like:
"${responsecode}" == "500" || ("${responsecode}" == "404" && "${responseMessage}" == "Not Found")
In case when If Controller doesn't behave as expected first of all check jmeter.log file for any JavaScript-related errors, it will give you some clue regarding what's wrong with your setup. You can also use __javaScript() function and View Results Tree listener combination to visualize the result of your If Controller condition:
See How to Use JMeter's 'IF' Controller article for more details on conditionally running samplers via If Controller.

Sitecore gender personalization

I added personalization rule in my Sitecore site - "Where the gender of the current contact is Male", but I can't figure out how to set "Visitors settings" to test it.
I'll be very grateful if someone can help me with this.
Thanks in advance!
The only Gender condition I found in default Sitecore 8 installation is the one coming from Social module (that is now built-in) located at /sitecore/system/Settings/Rules/Definitions/Macros/Social/Gender in Sitecore tree. Looking up its code I see the following code:
protected override bool Execute(T ruleContext)
{
if (!AnalyticsSettings.Enabled || Tracker.Current == null || Tracker.Current.Contact == null)
return false;
return string.Equals(this.GenderValue, ((IGenderConditionManager) ResolutionExtensions.Get<IGenderConditionManager>((IResolutionRoot) ExecutingContext.Current.IoC, new IParameter[0])).GetGender(GuidExtensions.GetIdentifier(Tracker.Current.Contact.ContactId)).ToString(), StringComparison.OrdinalIgnoreCase);
}
From the code above we can see that to make Gender condition work, you should have analytics and tracking up and running. So if you have that enabled - ensure all settings are correct and it works indeed.
User membership provider does not have gender settings by itself; so the rule condition above can take it only from tracking.

How to change controller property from component?

I have a property in the controller. I want to use a component to update that controller property. The usual component parameter passing works when I'm using a text field like the guides say, but in my case, I'm changing the value in code, not input fields. The binding seems to be broken.
What method similar to propertyDidChange() or notifyPropertyChange() should I use to accomplish this? Can you also provide a simple example so I know WHERE to make that method call?
personalities controller
`import Ember from 'ember'`
PersonalitiesController = Ember.ArrayController.extend
eiValue: ->
if params.name
params.name.charAt(0)
else
'e'
nsValue: ->
if params.name
params.name.charAt(1)
else
'n'
tfValue: ->
if params.name
params.name.charAt(2)
else
't'
pjValue: ->
if params.name
params.name.charAt(3)
else
'p'
type: (->
this.get('eiValue') + this.get('nsValue') + this.get('tfValue') + this.get('pjValue')
).property('eiValue', 'nsValue', 'tfValue', 'pjValue')
typeChanged: ((model, type)->
Ember.run.once(this, 'routeToPersonality')
).observes('type')
routeToPersonality: ->
this.get('controller').transitionToRoute('personality', this.get('type'))
`export default PersonalitiesController`
personalities template
%dichotomy-selector type=type
component
`import Ember from 'ember'`
DichotomySelectorComponent = Ember.Component.extend
eiValue: 'e'
nsValue: 'n'
tfValue: 't'
pjValue: 'p'
type: (->
newValue = this.get('eiValue') + this.get('nsValue') + this.get('tfValue') + this.get('pjValue')
this.set('controller.type', newValue)
).property('eiValue', 'nsValue', 'tfValue', 'pjValue')
actions:
toggleEI: ->
eiValue = this.get('eiValue')
if eiValue == 'e'
this.set('eiValue', 'i')
else if eiValue == 'i'
this.set('eiValue', 'e')
toggleNS: ->
nsValue = this.get('nsValue')
if nsValue == 'n'
this.set('nsValue', 's')
else if nsValue == 's'
this.set('nsValue', 'n')
toggleTF: ->
tfValue = this.get('tfValue')
if tfValue == 't'
this.set('tfValue', 'f')
else if tfValue == 'f'
this.set('tfValue', 't')
togglePJ: ->
pjValue = this.get('pjValue')
if pjValue == 'p'
this.set('pjValue', 'j')
else if pjValue == 'j'
this.set('pjValue', 'p')
`export default DichotomySelectorComponent`
You should be able to use this.set("controller.property", value) in a method inside the component, per the docs here: http://emberjs.com/api/classes/Ember.Component.html#property_controller
Edit September 2016
This answer has been the victim of the ongoing evolution of Ember, and the associated changes in best practices. It is amazing to see how different Ember is from just 1.5 years ago. The old answer has been totally rejected by the community as evidenced by the votes (negative as I type this), in fact I don't think it even works anymore. As of mid-2016 in Ember 2.x the generally accepted answer to this question is to create an action in the controller that changes the property, pass that action to the component, and call the action when the value changes on the component. But now you can use the action helper to pass a regular method instead of an action, and use component life cycle hooks to detect changes in the component instead of using an observer or computed property. You could also use a service instead. More changes on the way, I am sure.
For any future readers, any questions you need to research about Ember make sure that you filter results by time, you only want results within the last year.

How could you unit test against this bad Linq-To-SQL predicate?

Given the following example code:
Table<Person> tableToQuery = MethodThatGetsReferenceToPersonTable();
string searchType = "NonUser";
IQueryable<Person> queryResults = tableToQuery.Where(p =>
(p.IsMale == false) && // exclude male people
type.Equals("User", StringComparison.OrdinalIgnoreCase)
? p.User != null : p.User == null);
I am new to L2S, but do have some of experience with EntityFramework. I would not expect the above query to work correctly in an ORM like EF because of the type.Equals that gets invoked in the predicate's ternary expression. I would instead expect EF to throw an exception since it cannot convert that part of the predicate into a (SQL) store expression.
With L2S, it seems that the .Where is returning data, but it is not excluding items where p.Male == true when type == "NonUser. I have already fixed the code above to pull the type.Equals ternary out of the predicate and return correct results, and am now trying to write a test to assert the correct results. The problem I am running into is that the L2S code is actually behind an IRepository<Person> interface.
So the actual code looks more like this:
string searchType = "NonUser";
ICriteria<Person> query = new Query<Person>(p =>
(p.IsMale == false) && // exclude male people
type.Equals("User", StringComparison.OrdinalIgnoreCase)
? p.User != null : p.User == null);
IQueryable<Person> = _peopleRepository.FindByQuery(query)
...and the _peopleRepository implementation just passes the query.Predicate as an argument to the L2S Table<Person>.Where.
Questions:
Is it correct that the L2S Table<Person>.Where is not returning the correct results because of the ternary expression in the lambda predicate? I assume so since taking the ternary out an generating separate ICriteria<Person> objects depending on the value of searchType is yielding correct results. However I am not so certain if this is because L2S cannot convert the ternary into a store expression, or if it is caused by something else.
Since the method under test depends on a IRepository<Person> instance, how could I actually write a unit test around this? Mocking the IRepository<Person> in a unit test would not allow us to test the effects of the lambda on real underlying data. Creating a FakePersonRepository backed by some kind of IList<Person> would not reveal the actual defect either because the above lambda with the ternary expression returns expected results using linq-to-objects. Is there any way we could mock part of L2S so that we can possibly generate SQL using the lambda, and write assertions against that instead?
Is this just something we have to do with an integration test and an actual L2S context with connection string, and cannot properly unit test? My definition of "integration test" means "connect to an actual database running in a separate process from the test runner using some kind of connection string", whereas "unit test" means "do everything in the test runner process".
Is it correct that the L2S (...) is not returning the correct results
It does return correct results, but not the results you expect, because you read the query as a human being and not as a compiler. The latter reads this:
tableToQuery.Where(p =>
((p.IsMale == false) && type.Equals("User", StringComparison.OrdinalIgnoreCase))
? p.User != null
: p.User == null);
We humans tend to read this:
tableToQuery.Where(p => (p.IsMale == false) &&
(type.Equals("User", StringComparison.OrdinalIgnoreCase)
? p.User != null
: p.User == null));
2./3. how could I actually write a unit test around this?
Mocking and unit testing is virtually impossible. I stick to integration tests when I want to test the behavior of a data layer. For Entity Framework I collected some reasons for integration tests here. Much of it applies too LINQ-to-SQL as well.