@@ -217,89 +217,19 @@ export class GridView extends common.GridView {
217217
218218//#region Styling
219219export class GridViewStyler implements style . Styler {
220- private static setSectionInset ( gridView : GridView , padding : common . Padding ) {
221- let flowLayout = < UICollectionViewFlowLayout > gridView . ios . collectionViewLayout ;
222- let currentInset = flowLayout . sectionInset ;
223-
224- flowLayout . sectionInset = {
225- top : padding . top !== undefined ? padding . top : currentInset . top ,
226- right : padding . right !== undefined ? padding . right : currentInset . right ,
227- bottom : padding . bottom !== undefined ? padding . bottom : currentInset . bottom ,
228- left : padding . left !== undefined ? padding . left : currentInset . left
229- } ;
230- }
231-
232- //#region Padding Top Property
233- private static setPaddingTop ( gridView : GridView , newValue : number ) {
234- GridViewStyler . setSectionInset ( gridView , { top : newValue } ) ;
220+ private static setNativePaddingsProperty ( view : GridView , newValue : any ) {
221+ ( < UICollectionViewFlowLayout > view . ios . collectionViewLayout ) . sectionInset =
222+ UIEdgeInsetsFromString ( `{${ newValue . top } ,${ newValue . left } ,${ newValue . bottom } ,${ newValue . right } }` ) ;
235223 }
236- private static resetPaddingTop ( gridView : GridView , nativeValue : number ) {
237- GridViewStyler . setPaddingTop ( gridView , nativeValue ) ;
238- }
239- private static getNativePaddingTopValue ( gridView : GridView ) : any {
240- return ( < UICollectionViewFlowLayout > gridView . ios . collectionViewLayout ) . sectionInset . top ;
241- }
242- //#endregion
243224
244- //#region Padding Right Property
245- private static setPaddingRight ( gridView : GridView , newValue : number ) {
246- GridViewStyler . setSectionInset ( gridView , { right : newValue } ) ;
247- }
248- private static resetPaddingRight ( gridView : GridView , nativeValue : number ) {
249- GridViewStyler . setPaddingRight ( gridView , nativeValue ) ;
250- }
251- private static getNativePaddingRightValue ( gridView : GridView ) : any {
252- return ( < UICollectionViewFlowLayout > gridView . ios . collectionViewLayout ) . sectionInset . right ;
253- }
254- //#endregion
255-
256- //#region Padding Bottom Property
257- private static setPaddingBottom ( gridView : GridView , newValue : number ) {
258- GridViewStyler . setSectionInset ( gridView , { bottom : newValue } ) ;
259- }
260- private static resetPaddingBottom ( gridView : GridView , nativeValue : number ) {
261- GridViewStyler . setPaddingBottom ( gridView , nativeValue ) ;
262- }
263- private static getNativePaddingBottomValue ( gridView : GridView ) : any {
264- return ( < UICollectionViewFlowLayout > gridView . ios . collectionViewLayout ) . sectionInset . bottom ;
225+ private static resetNativePaddingsProperty ( view : GridView , nativeValue : any ) {
226+ ( < UICollectionViewFlowLayout > view . ios . collectionViewLayout ) . sectionInset = UIEdgeInsetsFromString ( "{0,0,0,0}" ) ;
265227 }
266- //#endregion
267-
268- //#region Padding Left Property
269- private static setPaddingLeft ( gridView : GridView , newValue : number ) {
270- GridViewStyler . setSectionInset ( gridView , { left : newValue } ) ;
271- }
272- private static resetPaddingLeft ( gridView : GridView , nativeValue : number ) {
273- GridViewStyler . setPaddingLeft ( gridView , nativeValue ) ;
274- }
275- private static getNativePaddingLeftValue ( gridView : GridView ) : any {
276- return ( < UICollectionViewFlowLayout > gridView . ios . collectionViewLayout ) . sectionInset . left ;
277- }
278- //#endregion
279228
280229 public static registerHandlers ( ) {
281- style . registerHandler ( style . paddingTopProperty ,
282- new style . StylePropertyChangedHandler ( GridViewStyler . setPaddingTop ,
283- GridViewStyler . resetPaddingTop ,
284- GridViewStyler . getNativePaddingTopValue ) ,
285- "GridView" ) ;
286-
287- style . registerHandler ( style . paddingRightProperty ,
288- new style . StylePropertyChangedHandler ( GridViewStyler . setPaddingRight ,
289- GridViewStyler . resetPaddingRight ,
290- GridViewStyler . getNativePaddingRightValue ) ,
291- "GridView" ) ;
292-
293- style . registerHandler ( style . paddingBottomProperty ,
294- new style . StylePropertyChangedHandler ( GridViewStyler . setPaddingBottom ,
295- GridViewStyler . resetPaddingBottom ,
296- GridViewStyler . getNativePaddingBottomValue ) ,
297- "GridView" ) ;
298-
299- style . registerHandler ( style . paddingLeftProperty ,
300- new style . StylePropertyChangedHandler ( GridViewStyler . setPaddingLeft ,
301- GridViewStyler . resetPaddingLeft ,
302- GridViewStyler . getNativePaddingLeftValue ) ,
230+ style . registerHandler ( style . nativePaddingsProperty ,
231+ new style . StylePropertyChangedHandler ( GridViewStyler . setNativePaddingsProperty ,
232+ GridViewStyler . resetNativePaddingsProperty ) ,
303233 "GridView" ) ;
304234 }
305235
0 commit comments