2
votes

I'm using RadListView telerik ui component for NativeScript in may NativeScript Angular 2 application.

When I set the event itemTap and/or itemHold they work very well but without the usual tap effect (ripple) on the list row.

Is there a way to add this effect?

Thanks all in advance :)

2
You could use nativescript-ripple plugin, which provides this functionality. You could also review the demo in the plugin's repo , where has been shown how to use it in your app - github.com/bradmartin/nativescript-ripple/tree/master/demo. - Nikolay Tsonev
@NikolayTsonev I tried the plugin but it blocks the listview's itemTap event from firing. :( - Androidian

2 Answers

0
votes

In my opinion this is something related with the plugin. As a solution you could set tap event to the Ripple component and to get the element id, which will help you to distinguish selected item. I am attaching sample code.

main-page.xml

<Page xmlns:RL="nativescript-ripple" xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
 <GridLayout>
  <ListView items="{{ source }}"  loaded="onLoaded">
      <ListView.itemTemplate>
        <RL:Ripple rippleColor="#d50000" id="{{index}}" tap="onTap2">
            <StackLayout  >
                  <Label text="{{title}}" textWrap="true" />
            </StackLayout>
          </RL:Ripple>
      </ListView.itemTemplate>
  </ListView>

 </GridLayout>
</Page>

main-page.ts

import { EventData } from 'data/observable';
import { Page } from 'ui/page';
import { HelloWorldModel } from './main-view-model';
import {StackLayout} from "ui/layouts/stack-layout"

// Event handler for Page "navigatingTo" event attached in main-page.xml
export function navigatingTo(args: EventData) {
  // Get the event sender
  let page = <Page>args.object;
  var array=[];
  for(var i=0;i<100; i++)
  {
    array.push({index:""+i,title:"title "+i});
  }
  page.bindingContext = {"source":array};
}

export function onTap2(args){
  console.log("sample");
  var layouts = args.object;
  var id = layouts.get("id");
  console.log(id);
}
0
votes

It has something to do with the class "list-group-item" you add to your itemTemplate. If you remove the class you can see the ripple again, however without styling... I did the following:

1) add this css styling

.list-group .list-group-item-ripple {
  color: #212121;
  font-size: 16;
  margin: 0;
  padding: 16;
}
.list-group .list-group-item-ripple Label {
  vertical-align: center;
}
.list-group .list-group-item-ripple .thumb {
  stretch: fill;
  width: 40;
  height: 40;
  margin-right: 16;
}
.list-group .list-group-item-ripple.active {
  background-color: #e0e0e0;
}
.list-group .list-group-item-ripple .list-group-item-text {
  color: #757575;
  font-size: 14;
}

now, in your xml instead of using "list-group-item" class, you will use "list-group-item-ripple".

Only this and it should work. Obs.: Notice the the listview tap event is intended to be used using the property "itemTap" ON "" tag, not as a tap event on child elements!