Titanium: Animate an element in a ListItem/ ListView - titanium

I want to animate an element in a ListItem
For example, consider the following simple ListView:
<ListView>
<Templates>
<ItemTemplate name="foo">
<View layout="vertical">
<Label color="red" id="label" bindId="bExampleLabel"/>
<Button onClick="onClickButton">Click Me to make the label go blue</Button>
</View>
</ItemTemplate>
</Templates>
<ListSection id="exampleListSection">
<ListItem template="foo" bExampleLabel:text="Example 1"></ListItem>
<ListItem template="foo" bExampleLabel:text="Example 2"></ListItem>
</ListSection
</ListView>
and the following script:
function onClickButton(e) {
var item = $.exampleListSection.getItemAt(e.itemIndex);
item.bExampleLabel = {
color: 'blue'
};
$.exampleListSection.updateItemAt(e.itemIndex, item);
}
The above XML code simply has a ListView which contains 2 ListItem, which each contains a label and a button. When you click the button, it makes the label go blue.
However I want it so that it animates it to blue.
Usually this is done like so:
$.elementId.animate({
color: 'blue'
});
However, I do not know how to do this in the context of a ListItem as you cannot seem to access the objects directly.

you can't animate ListItem in listView, you can change only the item properties accessing with bindId
templates : Dictionary
Contain key-value pairs mapping a style name (key) to an ItemTemplate (value).
This property cannot be changed once a window has been opened.
if you want to set animation in listing use TableView, and you can do what you want with TableViewRow

Related

How can I test a MUI check box with no label using data-testid?

I want to test a checkbox that has no label. The point is that there are other checkboxes as well so I cant use getByRole.
I have tried to use data-testid, but apparently, it's not working.
How am I supposed to check if that checkbox is checked(toBeChecked())?
<Checkbox
data-testid={item?.id}
key={item?.id}
id={item?.id.toString()}
color="secondary"
checked={item?.checked}
disabled={hasAll}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
if (item) {
item.checked = e.target.checked;
setFinalData(updateItemInArray(finalData, {
item,
index,
}));
}
}}
/>
The proper way to do this would be to add an aria-label to your checkbox, so it's announced correctly by screen readers:
<Checkbox inputProps={{ 'aria-label': 'Select row 1' }} />
This way, you'll be able to select it in your tests using getByLabelText.
If you want to use data-testid, you can place it on the checkbox similarly to aria-label:
<Checkbox inputProps={{ 'data-testid': 'checkbox1' }} />
Note that if you're using Typescript, you'd have to cast the inputProps to React.InputHTMLAttributes<HTMLInputElement> as data attributes are not a part of InputHTMLAttributes:
<Checkbox inputProps={{ 'data-testid': 'checkbox1' } as React.InputHTMLAttributes<HTMLInputElement>} />

How to replace the checkbox from the UI Fabric DetailsList component

How can I replace the circle checkbox of a DetailsList in office-ui-fabric-react with a normal square CheckBox component? I see onRenderCheckbox so I try something like this:
onRenderCheckbox={(props) => (<Checkbox checked={props.checked} />)}
or
onRenderCheckbox={(props) => (<Checkbox {...props} />)}
I can see the square checkbox but I can't select it.
What it the proper way to do this?
Thanks in advance...
When you render the Checkbox component, it handles the click itself (and thus it won't percolate up to the row so it can toggle selection accordingly), so you need to prevent it with the pointer-events: none style.
onRenderCheckbox(props) {
return (
<div style={{ pointerEvents: 'none' }}>
<Checkbox checked={props.checked} />
</div>
);
}
Check it out here: https://codepen.io/anon/pen/zQXEPr

Keyboard Overlaps on Entry when using the SlideOverKit MenuContainerPage

I have added the MenuContainerPage of SlideOverKit on which we are using the Entry but when entry got the focus keyboard hide the entry in iOS. I also tried using the Xam.Plugins.Forms.KeyboardOverlap plugin, it only works when Page is inherited from ContentPage.
So could you please help me to resolve the issue.
Create a ScrollView and add your Entry in the ScrollView. Then the keyboard will not hide the Entry.
In C# like this:
Content = new ScrollView {
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Spacing = 10,
Children = {
//Other Controls...
new Entry { }
}
}
};
In Xaml like this:
<ScrollView>
<StackLayout>
<!--Other Controls...-->
<Entry />
</StackLayout>
</ScrollView>

Touchable elements like Buttons,TouchableHighlight etc not working within FlatList

Touchable elements within a FlatList do not register touches. Why is the following code not working? Any help is appreciated. Thankyou.
_listener = () => {
Alert.alert('Touched');
}
renderItem({item, index}){
return<View>
<Button
title = "Button"
color = "#ccc"
onPress={this._listener}
/>
</View>
}
If you add extraData={this.state} within the flatlist you can get it to register touches.
You need to bind your function, so you would have something like this:
<Button
title = "Button"
color = "#ccc"
onPress={this._listener.bind(this)}
/>

React Native - Pagination of ListViews in ScrollView?

I have 3 ListView components inside a single ScrollView component like this:
<ScrollView>
<Header />
<ListView onEndReached={() => alert('load more 1')}/>
<ListView onEndReached={() => alert('load more 2')}/>
<ListView onEndReached={() => alert('load more 3')}/>
<Footer />
</ScrollView>
The Header component has some common content and also has 3 tabs, which trigger showing the respective ListView
The issue is any ListView with onEndReached={() => alert('load more 1')} never runs the alert, so I can never load more as I scroll down and hit the end of the listview. Remove the wrapping ScrollView and the alert runs, but the common Header doesn't scroll, since we just removed the wrapping ScrollView. The header needs to scroll with the listview, which is why I wrapped everything that needs to scroll in the ScrollView.
IMPORTANT NOTE:
I can't really use ListView with renderHeader={this.header}, for this scenario. Because, even though the Header will scroll, it will rerender the common Header and the 3 tabs for each ListView each time a ListView renders, instead of once. So a new Header rerender each time for each ListView won't cut it for the app.
Looking for a solution to this problem, where the Header scrolls with the listviews and the onEndReached is triggered for the visible ListView.
I think you're going to have to solve this by changing the dataSource in each listView in response to what header element is selected instead of loading three different ListViews.
getInitialState() {
return {
currentList: this.ds.cloneWithRowsAndSections(INITIAL_DATA);
}
},
render() {
return <ListView renderHeader={this._renderHeader} dataSource={this.state.currentList}/>
}
The only reason you wouldn't want to do this is if you wanted to maintain the scroll position in the three sub ListViews, but that wouldn't be useful because you always have to scroll to the top to change which ListView you're looking at anyway.
Then in your _renderHeader function you would render a selector that populates currentList with different data depending on the header selected.
In styling you can set it's position as relative with top:0 and left:0 . This way it will remain static on top.
<View>
<Header style={{position:"relative",top:0,left:0,height:30,width:Dimensions.get("window").width}} />
<ListView />
<ListView />
<ListView />
<Footer />
</View>
Second option which may work in scrollview is to specify height for all three ListView.
You can maybe use ScrollView::onScroll but it will be a little hacky. You will need to know the size of your listviews.
Work with ListView only
Maybe the best solution will be to play with the ListView dataSource and the onEndReached function.
If you update you dataset when ListView::onEndReached is triggered, I think you can add more elements to your ListView. This way, you do not need to do hacky things with ListViews in ScrollViews.