@nativescript-community/ui-collectionview 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ios.d.ts CHANGED
@@ -92,7 +92,7 @@ export declare class CollectionView extends CollectionViewBase {
92
92
  }
93
93
  interface ViewItemIndex {
94
94
  }
95
- declare type ItemView = View & ViewItemIndex;
95
+ type ItemView = View & ViewItemIndex;
96
96
  declare class CollectionViewCell extends UICollectionViewCell {
97
97
  owner: WeakRef<ItemView>;
98
98
  currentIndex: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-collectionview",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Allows you to easily add a collection view (grid list view) to your projects. Supports vertical and horizontal modes, templating, and more.",
5
5
  "main": "./index",
6
6
  "sideEffects": false,
@@ -56,5 +56,5 @@
56
56
  },
57
57
  "license": "Apache-2.0",
58
58
  "readmeFilename": "README.md",
59
- "gitHead": "1c3456a693c41eadf509ecf5b26defe94b1b3f66"
59
+ "gitHead": "3eb64b60bab938d79853920e290ee8f26afbf178"
60
60
  }
@@ -1,3 +1,3 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nativescript.collectionview">
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nativescript.collectionview" >
3
3
  </manifest>
@@ -1,7 +1,8 @@
1
1
  dependencies {
2
2
  def androidXRecyclerViewVersion = project.hasProperty("androidXRecyclerViewVersion") ? project.androidXRecyclerViewVersion : "1.3.0"
3
3
  implementation "androidx.recyclerview:recyclerview:$androidXRecyclerViewVersion"
4
- implementation ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0@aar'){
5
- transitive=true
6
- }
4
+ // implementation ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0@aar'){
5
+ // transitive=true
6
+ // }
7
+ // implementation 'jp.wasabeef:recyclerview-animators:4.0.2'
7
8
  }
@@ -6,8 +6,14 @@ import android.view.View;
6
6
  import java.util.HashMap;
7
7
 
8
8
  public class GridLayoutManager extends androidx.recyclerview.widget.GridLayoutManager {
9
+
9
10
  private HashMap<Integer, Integer> childSizesMap = new HashMap();
10
11
  public boolean isScrollEnabled = true;
12
+ public LayoutCompletedListener layoutCompletedListener;
13
+
14
+ public interface LayoutCompletedListener {
15
+ public void onLayoutCompleted();
16
+ }
11
17
 
12
18
  public GridLayoutManager(Context context, int spanCount) {
13
19
  super(context, spanCount);
@@ -20,6 +26,9 @@ public class GridLayoutManager extends androidx.recyclerview.widget.GridLayoutMa
20
26
  View child = getChildAt(i);
21
27
  childSizesMap.put(getPosition(child), child.getHeight());
22
28
  }
29
+ if (layoutCompletedListener != null) {
30
+ layoutCompletedListener.onLayoutCompleted();
31
+ }
23
32
  }
24
33
 
25
34
  public int computeVerticalScrollOffset(RecyclerView.State state) {
@@ -0,0 +1,22 @@
1
+ package com.nativescript.collectionview;
2
+ import androidx.recyclerview.widget.RecyclerView;
3
+ import android.view.View;
4
+ import android.graphics.Rect;
5
+
6
+ public class OverlapDecoration extends RecyclerView.ItemDecoration {
7
+
8
+ public int top = 0;
9
+ public int right = 0;
10
+ public int bottom = 0;
11
+ public int left = 0;
12
+
13
+ @Override
14
+ public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
15
+ final int itemPosition = parent.getChildAdapterPosition(view);
16
+ int position = parent.getChildAdapterPosition(view);
17
+ boolean isLast = position == state.getItemCount()-1;
18
+ if (itemPosition == 0) {
19
+ return; }
20
+ outRect.set(left, top, right, bottom);
21
+ }
22
+ }
@@ -5,11 +5,15 @@ import android.view.View;
5
5
  import android.view.ViewGroup;
6
6
  import android.util.Log;
7
7
  import androidx.recyclerview.widget.LinearSmoothScroller;
8
+ // import jp.wasabeef.recyclerview.animators.FadeInAnimator;
9
+ // import jp.wasabeef.recyclerview.animators.BaseItemAnimator;
10
+ import android.view.animation.OvershootInterpolator;
8
11
 
9
12
  public class RecyclerView extends androidx.recyclerview.widget.RecyclerView {
10
13
  static final String TAG = "RecyclerView";
11
14
  public SizeChangedListener sizeChangedListener = null;
12
15
  protected com.nativescript.collectionview.SmoothScroller smoothScroller;
16
+ // public FadeInAnimator animator;
13
17
  public RecyclerView(Context context) {
14
18
  this(context, null);
15
19
  }
@@ -21,6 +25,15 @@ public class RecyclerView extends androidx.recyclerview.widget.RecyclerView {
21
25
  setHasFixedSize(true);
22
26
  setFocusable(true);
23
27
  setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
28
+
29
+
30
+ // animator = new FadeInAnimator();
31
+ // animator.setInterpolator(new OvershootInterpolator());
32
+ // animator.setMoveDuration(200);
33
+ // setItemAnimator(animator);
34
+ // Change animations are enabled by default since support-v7-recyclerview v22.
35
+ // Need to disable them when using animation indicator.
36
+ // animator.setSupportsChangeAnimations(false);
24
37
  }
25
38
 
26
39
  static public RecyclerView createRecyclerView(Context context) {
@@ -46,7 +59,14 @@ public class RecyclerView extends androidx.recyclerview.widget.RecyclerView {
46
59
  sizeChangedListener.onMeasure();
47
60
  }
48
61
  }
49
-
62
+ @Override
63
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
64
+ super.onLayout(changed, l, t, r, b);
65
+ if (sizeChangedListener != null) {
66
+ sizeChangedListener.onLayout(changed, l, t, r, b);
67
+ }
68
+ }
69
+
50
70
  @Override
51
71
  public void smoothScrollToPosition(int position) {
52
72
  this.smoothScrollToPosition(position, LinearSmoothScroller.SNAP_TO_START);
@@ -1,6 +1,7 @@
1
1
  package com.nativescript.collectionview;
2
2
 
3
3
  public interface SizeChangedListener {
4
- public void onSizeChanged(int w, int h, int oldw, int oldh);
4
+ // public void onSizeChanged(int w, int h, int oldw, int oldh);
5
+ public void onLayout(boolean changed, int l, int t, int r, int b);
5
6
  public void onMeasure();
6
7
  }
package/react/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import { CoreTypes, ItemEventData, ItemsSource, View } from '@nativescript/core';
3
3
  import { NSVElement, NativeScriptProps, ViewAttributes } from 'react-nativescript';
4
4
  import { CollectionView as NativeScriptCollectionView } from '..';
5
- export declare type CellViewContainer = View;
6
- declare type CellFactory = (item: any) => React.ReactElement;
5
+ export type CellViewContainer = View;
6
+ type CellFactory = (item: any) => React.ReactElement;
7
7
  export declare function registerCollectionView(): void;
8
8
  interface CollectionViewAttributes extends ViewAttributes {
9
9
  colWidth?: CoreTypes.PercentLengthType | string;
@@ -33,7 +33,7 @@ declare global {
33
33
  }
34
34
  }
35
35
  }
36
- declare type OwnProps = {
36
+ type OwnProps = {
37
37
  items: ItemsSource | any[];
38
38
  /** User may specify cellFactory for single-template or cellFactories for multi-template. */
39
39
  cellFactory?: CellFactory;
@@ -52,10 +52,10 @@ declare type OwnProps = {
52
52
  onCellRecycle?: (container: CellViewContainer) => void;
53
53
  };
54
54
  } & Omit<CollectionViewAttributes, 'onItemLoading'>;
55
- declare type Props = OwnProps & {
55
+ type Props = OwnProps & {
56
56
  forwardedRef?: React.RefObject<NSVElement<NativeScriptCollectionView>>;
57
57
  };
58
- declare type NumberKey = number | string;
58
+ type NumberKey = number | string;
59
59
  interface State {
60
60
  nativeCells: Record<NumberKey, CellViewContainer>;
61
61
  nativeCellToItemIndex: Map<CellViewContainer, NumberKey>;
package/svelte/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="svelte-native" />
2
1
  import { NativeViewElementNode, ViewNode } from 'svelte-native/dom';
3
2
  import { CollectionView } from '..';
4
3
  declare module '@nativescript/core/ui/core/view-base' {
@@ -10,6 +10,14 @@ declare namespace com {
10
10
  }
11
11
  export class GridLayoutManager extends androidx.recyclerview.widget.GridLayoutManager {
12
12
  isScrollEnabled: boolean;
13
+ layoutCompletedListener: LayoutCompletedListener;
14
+ }
15
+ export namespace GridLayoutManager {
16
+
17
+ export class LayoutCompletedListener {
18
+ onLayoutCompleted();
19
+ constructor(implementation?: { onLayoutCompleted() });
20
+ }
13
21
  }
14
22
  export class PreCachingGridLayoutManager extends GridLayoutManager {
15
23
  setExtraLayoutSpace(space: number);
@@ -41,8 +49,8 @@ declare namespace com {
41
49
  smoothScrollToPosition(position: number, snapPosition?: number);
42
50
  }
43
51
  export class SizeChangedListener {
44
- constructor(impl?: { onSizeChanged(w: number, h: number, oldw: number, oldh: number); onMeasure() });
45
- onSizeChanged(w: number, h: number, oldw: number, oldh: number);
52
+ constructor(impl?: { onLayout(changed:boolean, l: number, t: number, r: number, b: number); onMeasure() });
53
+ onLayout(changed:boolean, l: number, t: number, r: number, b: number);
46
54
  onMeasure();
47
55
  }
48
56
  export class OnScrollListener extends androidx.recyclerview.widget.RecyclerView.OnScrollListener {
@@ -71,6 +79,12 @@ declare namespace com {
71
79
  }
72
80
 
73
81
  export class SmoothScroller extends androidx.recyclerview.widget.LinearSmoothScroller {}
82
+ export class OverlapDecoration extends androidx.recyclerview.widget.RecyclerView.ItemDecoration {
83
+ public top: number;
84
+ public right: number;
85
+ public bottom: number;
86
+ public left: number;
87
+ }
74
88
  }
75
89
  }
76
90
  }