Skip to content

Commit

Permalink
2.1.4 JXRTLFlowLayout 的RTL适配
Browse files Browse the repository at this point in the history
  • Loading branch information
jx committed May 27, 2024
1 parent a55dd07 commit 660d219
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion JXPagingView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "JXPagingView"
s.version = "2.1.3"
s.version = "2.1.4"
s.summary = "类似微博主页、简书主页等效果。多页面嵌套,既可以上下滑动,也可以左右滑动切换页面。支持HeaderView悬浮、支持下拉刷新、上拉加载更多。"
s.homepage = "https://github.com/pujiaxin33/JXPagingView"
s.author = { "pujiaxin33" => "[email protected]" }
Expand Down
4 changes: 2 additions & 2 deletions Sources/JXPagerView/JXPagerListContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "JXPagerListContainerView.h"
#import <objc/runtime.h>

#import "JXRTLFlowLayout.h"
@interface JXPagerListContainerScrollView: UIScrollView <UIGestureRecognizerDelegate>
@property (nonatomic, assign, getter=isCategoryNestPagingEnabled) BOOL categoryNestPagingEnabled;
@end
Expand Down Expand Up @@ -158,7 +158,7 @@ - (void)initializeViews {
}
[self.containerVC.view addSubview:self.scrollView];
}else {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
JXRTLFlowLayout *layout = [[JXRTLFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
Expand Down
4 changes: 2 additions & 2 deletions Sources/JXPagerView/JXPagerSmoothView.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "JXPagerSmoothView.h"

#import "JXRTLFlowLayout.h"
static NSString *JXPagerSmoothViewCollectionViewCellIdentifier = @"cell";

@interface JXPagerSmoothCollectionView : UICollectionView <UIGestureRecognizerDelegate>
Expand Down Expand Up @@ -66,7 +66,7 @@ - (instancetype)initWithDataSource:(id<JXPagerSmoothViewDataSource>)dataSource
- (void)initializeViews {
self.pagerHeaderContainerView = [[UIView alloc] init];

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
JXRTLFlowLayout *layout = [[JXRTLFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
Expand Down
16 changes: 16 additions & 0 deletions Sources/JXPagerView/JXRTLFlowLayout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// JXRTLFlowLayout.h
//
//
// Created by loong on 2024/3/14.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface JXRTLFlowLayout : UICollectionViewFlowLayout

@end

NS_ASSUME_NONNULL_END
17 changes: 17 additions & 0 deletions Sources/JXPagerView/JXRTLFlowLayout.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// JXRTLFlowLayout.m
//
//
// Created by loong on 2024/3/14.
//

#import "JXRTLFlowLayout.h"

@implementation JXRTLFlowLayout


- (BOOL)flipsHorizontallyInOppositeLayoutDirection {
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:UIView.appearance.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
}

@end
2 changes: 1 addition & 1 deletion Sources/JXPagingView/JXPagingListContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ open class JXPagingListContainerView: UIView {
}
containerVC.view.addSubview(scrollView)
}else if type == .collectionView {
let layout = UICollectionViewFlowLayout()
let layout = JXRTLFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
Expand Down
2 changes: 1 addition & 1 deletion Sources/JXPagingView/JXPagingSmoothView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ open class JXPagingSmoothView: UIView {
public init(dataSource: JXPagingSmoothViewDataSource) {
self.dataSource = dataSource
pagingHeaderContainerView = UIView()
let layout = UICollectionViewFlowLayout()
let layout = JXRTLFlowLayout()
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.scrollDirection = .horizontal
Expand Down
16 changes: 16 additions & 0 deletions Sources/JXPagingView/JXRTLFlowLayout.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// JXPagingView.swift
// JXRTLFlowLayout
//
// Created by jx on 2024/5/27.
//

import UIKit

class JXRTLFlowLayout: UICollectionViewFlowLayout {
override var flipsHorizontallyInOppositeLayoutDirection: Bool {
get {
return UIView.userInterfaceLayoutDirection(for: UIView.appearance().semanticContentAttribute) == .rightToLeft
}
}
}

0 comments on commit 660d219

Please sign in to comment.