阿拉伯语适配

This commit is contained in:
liyuhua
2024-04-12 17:52:35 +08:00
parent cbeae1c6ad
commit ebf377fe42
17 changed files with 123 additions and 635 deletions

View File

@@ -252,8 +252,7 @@
237700E32BC7D7C000D661F1 /* NSMutableAttributedString+MSRTL.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700E22BC7D7C000D661F1 /* NSMutableAttributedString+MSRTL.m */; };
237700E62BC7E81F00D661F1 /* UITextField+MSRTL.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700E52BC7E81F00D661F1 /* UITextField+MSRTL.m */; };
237700E92BC7E88E00D661F1 /* UITextView+MSRTL.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700E82BC7E88E00D661F1 /* UITextView+MSRTL.m */; };
237700EC2BC914B400D661F1 /* UINavigationController+MSRTL.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700EB2BC914B400D661F1 /* UINavigationController+MSRTL.m */; };
237700F42BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700F32BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.m */; };
237700EC2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.m in Sources */ = {isa = PBXBuildFile; fileRef = 237700EB2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.m */; };
237B94BC2A984DA7007853E3 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */; };
237B94BD2A984DA7007853E3 /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B32A984DA7007853E3 /* XPNobleTrumpetModel.m */; };
237B94BE2A984DA7007853E3 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B72A984DA7007853E3 /* XPRoomTrumpetViewController.m */; };
@@ -1991,10 +1990,8 @@
237700E52BC7E81F00D661F1 /* UITextField+MSRTL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITextField+MSRTL.m"; sourceTree = "<group>"; };
237700E72BC7E88E00D661F1 /* UITextView+MSRTL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UITextView+MSRTL.h"; sourceTree = "<group>"; };
237700E82BC7E88E00D661F1 /* UITextView+MSRTL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UITextView+MSRTL.m"; sourceTree = "<group>"; };
237700EA2BC914B400D661F1 /* UINavigationController+MSRTL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+MSRTL.h"; sourceTree = "<group>"; };
237700EB2BC914B400D661F1 /* UINavigationController+MSRTL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+MSRTL.m"; sourceTree = "<group>"; };
237700F22BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+FDFullscreenPopGesture.h"; sourceTree = "<group>"; };
237700F32BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+FDFullscreenPopGesture.m"; sourceTree = "<group>"; };
237700EA2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UISwipeGestureRecognizer+MSRTL.h"; sourceTree = "<group>"; };
237700EB2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UISwipeGestureRecognizer+MSRTL.m"; sourceTree = "<group>"; };
237B94AD2A984DA7007853E3 /* XPTrumpetPresenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPTrumpetPresenter.h; sourceTree = "<group>"; };
237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPTrumpetPresenter.m; sourceTree = "<group>"; };
237B94B02A984DA7007853E3 /* XPRoomTrumpetProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetProtocol.h; sourceTree = "<group>"; };
@@ -4804,7 +4801,6 @@
189DD56C26DF5B5400AB55B1 /* CustomUI */ = {
isa = PBXGroup;
children = (
237700F12BC91F8400D661F1 /* FDFullscreenPopGesture */,
237700D42BC7D3DC00D661F1 /* MSRTL */,
E8FE3C292994D0CC0006C6C7 /* SwitchView */,
E81E09C6290F719C00A1F410 /* Adbvertise */,
@@ -5603,21 +5599,12 @@
237700E52BC7E81F00D661F1 /* UITextField+MSRTL.m */,
237700E72BC7E88E00D661F1 /* UITextView+MSRTL.h */,
237700E82BC7E88E00D661F1 /* UITextView+MSRTL.m */,
237700EA2BC914B400D661F1 /* UINavigationController+MSRTL.h */,
237700EB2BC914B400D661F1 /* UINavigationController+MSRTL.m */,
237700EA2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.h */,
237700EB2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.m */,
);
path = MSRTL;
sourceTree = "<group>";
};
237700F12BC91F8400D661F1 /* FDFullscreenPopGesture */ = {
isa = PBXGroup;
children = (
237700F22BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.h */,
237700F32BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.m */,
);
path = FDFullscreenPopGesture;
sourceTree = "<group>";
};
237B94AB2A984DA7007853E3 /* NobleTrumpet */ = {
isa = PBXGroup;
children = (
@@ -11056,7 +11043,7 @@
E8A3539128FE5F0F0014A784 /* WishGiftInfoModel.m in Sources */,
2305EEF62AD67E5500AD403C /* PIRoomPhotoAlbumItemCell.m in Sources */,
E85E7B3C2A4EB0D300B6D00A /* XPGuildSuperAdminRoomCollectionViewCell.m in Sources */,
237700EC2BC914B400D661F1 /* UINavigationController+MSRTL.m in Sources */,
237700EC2BC914B400D661F1 /* UISwipeGestureRecognizer+MSRTL.m in Sources */,
23D321E82ADFED10006B259C /* PIRoomSendRedPacketItemVC.m in Sources */,
E85E7B2A2A4EB0D300B6D00A /* XPGuildTimeMonthPickerView.m in Sources */,
E87E62782A3F5907002F68C9 /* XPNewHomePartyTableViewCell.m in Sources */,
@@ -11346,7 +11333,6 @@
E8788945273A55C200BF1D57 /* XPGiftInfoView.m in Sources */,
9BF5192628801D4700B6BE92 /* XPAcrossRoomPKCountDownView.m in Sources */,
239141CC2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m in Sources */,
237700F42BC91F8400D661F1 /* UINavigationController+FDFullscreenPopGesture.m in Sources */,
23D321DC2ADFBFF6006B259C /* PIInputRedPacketView.m in Sources */,
23E9E99E2A80C7AF00B792F2 /* XPMineGuildPersonalBillRecordItemView.m in Sources */,
E87DF4F52A42CC49009C1185 /* HomeMenuInfoModel.m in Sources */,

View File

@@ -55,12 +55,12 @@ UIKIT_EXTERN NSString * adImageName;
if (isMSRTL()) {
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
[UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
// [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
} else {
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
[UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
// [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}
}

View File

@@ -1,66 +0,0 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import <UIKit/UIKit.h>
/// "UINavigation+FDFullscreenPopGesture" extends UINavigationController's swipe-
/// to-pop behavior in iOS 7+ by supporting fullscreen pan gesture. Instead of
/// screen edge, you can now swipe from any place on the screen and the onboard
/// interactive pop transition works seamlessly.
///
/// Adding the implementation file of this category to your target will
/// automatically patch UINavigationController with this feature.
@interface UINavigationController (FDFullscreenPopGesture)
/// The gesture recognizer that actually handles interactive pop.
@property (nonatomic, strong, readonly) UIPanGestureRecognizer *fd_fullscreenPopGestureRecognizer;
/// The RTL gesture recognizer that actually handles interactive pop.
@property (nonatomic, strong, readonly) UIScreenEdgePanGestureRecognizer *fd_rtlFullscreenPopGestureRecognizer;
/// A view controller is able to control navigation bar's appearance by itself,
/// rather than a global way, checking "fd_prefersNavigationBarHidden" property.
/// Default to YES, disable it if you don't want so.
@property (nonatomic, assign) BOOL fd_viewControllerBasedNavigationBarAppearanceEnabled;
@end
/// Allows any view controller to disable interactive pop gesture, which might
/// be necessary when the view controller itself handles pan gesture in some
/// cases.
@interface UIViewController (FDFullscreenPopGesture)
/// Whether the interactive pop gesture is disabled when contained in a navigation
/// stack.
@property (nonatomic, assign) BOOL fd_interactivePopDisabled;
/// Indicate this view controller prefers its navigation bar hidden or not,
/// checked when view controller based navigation bar's appearance is enabled.
/// Default to NO, bars are more likely to show.
@property (nonatomic, assign) BOOL fd_prefersNavigationBarHidden;
/// Max allowed initial distance to left edge when you begin the interactive pop
/// gesture. 0 by default, which means it will ignore this limit.
@property (nonatomic, assign) CGFloat fd_interactivePopMaxAllowedInitialDistanceToLeftEdge;
@end

View File

@@ -1,485 +0,0 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import "UINavigationController+FDFullscreenPopGesture.h"
#import <objc/runtime.h>
#import <MessageUI/MessageUI.h>
#pragma mark - _FDFullscreenPopGestureRecognizerDelegate
@interface _FDFullscreenPopGestureRecognizerDelegate : NSObject <UIGestureRecognizerDelegate>
@property (nonatomic, weak) UINavigationController *navigationController;
@end
@implementation _FDFullscreenPopGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer
{
// Ignore when no view controller is pushed into the navigation stack.
if (self.navigationController.viewControllers.count <= 1) {
return NO;
}
// Ignore when the active view controller doesn't allow interactive pop.
UIViewController *topViewController = self.navigationController.viewControllers.lastObject;
if (topViewController.fd_interactivePopDisabled) {
return NO;
}
// Ignore when the beginning location is beyond max allowed initial distance to left edge.
CGPoint beginningLocation = [gestureRecognizer locationInView:gestureRecognizer.view];
// fd_interactivePopMaxAllowedInitialDistanceToLeftEdgex
CGFloat maxAllowedInitialDistance = topViewController.fd_interactivePopMaxAllowedInitialDistanceToLeftEdge;
if (maxAllowedInitialDistance > 0 && beginningLocation.x > maxAllowedInitialDistance) {
return NO;
}
// Ignore pan gesture when the navigation controller is currently in transition.
// KVC NavigationController _isTransitioning
if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) {
return NO;
}
// Prevent calling the handler when the gesture begins in an opposite direction.
//
CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view];
BOOL isLeftToRight = [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight;
CGFloat multiplier = isLeftToRight ? 1 : -1;
if ((translation.x * multiplier) <= 0) {
return NO;
}
return YES;
}
@end
#pragma mark - _FDFullRTLScreenPopGestureRecognizerDelegate
@interface _FDFullRTLScreenPopGestureRecognizerDelegate : NSObject <UIGestureRecognizerDelegate>
@property (nonatomic, weak) UINavigationController *navigationController;
@end
@implementation _FDFullRTLScreenPopGestureRecognizerDelegate
//
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
// Ignore when no view controller is pushed into the navigation stack.
if (self.navigationController.viewControllers.count <= 1) {
return NO;
}
// Ignore when the active view controller doesn't allow interactive pop.
UIViewController *topViewController = self.navigationController.viewControllers.lastObject;
if (topViewController.fd_interactivePopDisabled) {
return NO;
}
// Ignore when the beginning location is beyond max allowed initial distance to left edge.
CGPoint beginningLocation = [gestureRecognizer locationInView:gestureRecognizer.view];
CGFloat maxAllowedInitialDistance = topViewController.fd_interactivePopMaxAllowedInitialDistanceToLeftEdge;
if (maxAllowedInitialDistance > 0 && beginningLocation.x > maxAllowedInitialDistance) {
return NO;
}
// Ignore pan gesture when the navigation controller is currently in transition.
if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) {
return NO;
}
return YES;
}
@end
#pragma mark - _FDViewControllerWillAppearInjectBlock
typedef void (^_FDViewControllerWillAppearInjectBlock)(UIViewController *viewController, BOOL animated);
#pragma mark - UIViewController (FDFullscreenPopGesturePrivate)
@interface UIViewController (FDFullscreenPopGesturePrivate)
@property (nonatomic, copy) _FDViewControllerWillAppearInjectBlock fd_willAppearInjectBlock;
@end
@implementation UIViewController (FDFullscreenPopGesturePrivate)
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
//viewWillAppear
SEL originalSelector = @selector(viewWillAppear:);
SEL swizzledSelector = @selector(fd_viewWillAppear:);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (success) {
// class_addMethod YES
// 使 class_getInstanceMethod originalSelector class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
// mrc_viewWillAppear mrc_viewWillAppear
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
//viewWillDisappear
SEL originalSelector2 = @selector(viewWillDisappear:);
SEL swizzledSelector2 = @selector(fd_viewWillDisappear:);
Method originalMethod2 = class_getInstanceMethod(class, originalSelector2);
Method swizzledMethod2 = class_getInstanceMethod(class, swizzledSelector2);
BOOL success2 = class_addMethod(class, originalSelector2, method_getImplementation(swizzledMethod2), method_getTypeEncoding(swizzledMethod2));
if (success2) {
class_replaceMethod(class, swizzledSelector2, method_getImplementation(originalMethod2), method_getTypeEncoding(originalMethod2));
} else {
method_exchangeImplementations(originalMethod2, swizzledMethod2);
}
});
}
- (void)fd_viewWillAppear:(BOOL)animated
{
// Forward to primary implementation.
// viewWillAppear
[self fd_viewWillAppear:animated];
// block block
if (self.fd_willAppearInjectBlock) {
self.fd_willAppearInjectBlock(self, animated);
}
///
// fd_prefersNavigationBarHidden-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(CGFLOAT_MIN * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIViewController *vc = [self.navigationController.viewControllers lastObject];
if (vc.fd_prefersNavigationBarHidden) {
[self.navigationController setNavigationBarHidden:YES animated:NO];
} else {
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
});
}
- (void)fd_viewWillDisappear:(BOOL)animated{
[self fd_viewWillDisappear:animated];
///
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(CGFLOAT_MIN * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIViewController *vc = [self.navigationController.viewControllers lastObject];
if (vc.fd_prefersNavigationBarHidden) {
[self.navigationController setNavigationBarHidden:YES animated:NO];
} else {
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
});
}
- (_FDViewControllerWillAppearInjectBlock)fd_willAppearInjectBlock
{
// 1. fd_willAppearInjectBlockget
// 2. getkeyvalueblock
return objc_getAssociatedObject(self, _cmd);
}
- (void)setFd_willAppearInjectBlock:(_FDViewControllerWillAppearInjectBlock)block
{
// 1. fd_willAppearInjectBlockset
// 2. blockvalue getkeyblock
// 3. fd_willAppearInjectBlockgetblock
objc_setAssociatedObject(self, @selector(fd_willAppearInjectBlock), block, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
@end
#pragma mark - RTLEdgePanGesture
@interface RTLEdgePanGesture : UIScreenEdgePanGestureRecognizer
@end
@implementation RTLEdgePanGesture
// ,
// :,,使
- (CGPoint)translationInView:(UIView *)view {
if (isMSRTL()) {
// APP
return [super translationInView:view];
}
if ([UIDevice currentDevice].systemVersion.doubleValue > 9.0) {
CGPoint oldP = [super translationInView:view];
// app
return CGPointMake(-oldP.x, oldP.y);
}
return [super translationInView:view];
}
@end
#pragma mark - UINavigationController (FDFullscreenPopGesture)
@implementation UINavigationController (FDFullscreenPopGesture)
+ (void)load {
// Inject "-pushViewController:animated:"
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(pushViewController:animated:);
SEL swizzledSelector = @selector(fd_pushViewController:animated:);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
// 1.class_addMethod
// 2.
// 3.
// 4.class_addMethodpush (fd_push)
// 5.class_replaceMethodfd_push(push)
// 6.
// 7.pushViewController:animated: fd_pushViewController:animated:
BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (success) {
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
- (void)fd_pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// interactivePopGestureRecognizerView
//
// doc:http://t.cn/RssK6mz
// APP ||
if (isMSRTL()) {
if (![self.interactivePopGestureRecognizer.view.gestureRecognizers containsObject:self.fd_rtlFullscreenPopGestureRecognizer]) {
// Add our own gesture recognizer to where the onboard screen edge pan gesture recognizer is attached to.
[self.interactivePopGestureRecognizer.view addGestureRecognizer:self.fd_rtlFullscreenPopGestureRecognizer];
// Forward the gesture events to the private handler of the onboard gesture recognizer.
// interactivePopGestureRecognizertarget , action handleNavigationTransition,
// Runtimetarget, action
NSArray *internalTargets = [self.interactivePopGestureRecognizer valueForKey:@"targets"];
// get releate target
id internalTarget = [internalTargets.firstObject valueForKey:@"target"];
// get handleNavigationTransition sel
SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:");
self.fd_rtlFullscreenPopGestureRecognizer.delegate = self.fd_popRTLGestureRecognizerDelegate;
// add target and action to this gesture
[self.fd_rtlFullscreenPopGestureRecognizer addTarget:internalTarget action:internalAction];
// Disable the onboard gesture recognizer.
self.interactivePopGestureRecognizer.enabled = NO;
}
} else {
if (![self.interactivePopGestureRecognizer.view.gestureRecognizers containsObject:self.fd_fullscreenPopGestureRecognizer]) {
// Add our own gesture recognizer to where the onboard screen edge pan gesture recognizer is attached to.
[self.interactivePopGestureRecognizer.view addGestureRecognizer:self.fd_fullscreenPopGestureRecognizer];
// Forward the gesture events to the private handler of the onboard gesture recognizer.
NSArray *internalTargets = [self.interactivePopGestureRecognizer valueForKey:@"targets"];
id internalTarget = [internalTargets.firstObject valueForKey:@"target"];
SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:");
self.fd_fullscreenPopGestureRecognizer.delegate = self.fd_popGestureRecognizerDelegate;
[self.fd_fullscreenPopGestureRecognizer addTarget:internalTarget action:internalAction];
// Disable the onboard gesture recognizer.
self.interactivePopGestureRecognizer.enabled = NO;
}
}
// Handle perferred navigation bar appearance.
[self fd_setupViewControllerBasedNavigationBarAppearanceIfNeeded:viewController];
//MessageUI
if ([self isKindOfClass:[MFMessageComposeViewController class]]) {
[self fd_pushViewController:viewController animated:animated];
[[self.viewControllers lastObject] navigationItem].rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismissModal:)];
return;
}
// Forward to primary implementation. pushViewController:animated
if (![self.viewControllers containsObject:viewController]) {
[self fd_pushViewController:viewController animated:animated];
}
}
- (void)dismissModal:(UIButton *)sender
{
[[self.viewControllers lastObject] dismissViewControllerAnimated:YES completion:nil];
}
// pushViewControllerblock
- (void)fd_setupViewControllerBasedNavigationBarAppearanceIfNeeded:(UIViewController *)appearingViewController
{
if (!self.fd_viewControllerBasedNavigationBarAppearanceEnabled) {
return;
}
// viewWillAppearsetNavigationBarHidden:animated:NavigationBar
__weak typeof(self) weakSelf = self;
_FDViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
[strongSelf setNavigationBarHidden:viewController.fd_prefersNavigationBarHidden animated:animated];
}
};
// Setup will appear inject block to appearing view controller.
// Setup disappearing view controller as well, because not every view controller is added into
// stack by pushing, maybe by "-setViewControllers:".
appearingViewController.fd_willAppearInjectBlock = block;
UIViewController *disappearingViewController = self.viewControllers.lastObject;
if (disappearingViewController && !disappearingViewController.fd_willAppearInjectBlock) {
disappearingViewController.fd_willAppearInjectBlock = block;
}
}
- (_FDFullscreenPopGestureRecognizerDelegate *)fd_popGestureRecognizerDelegate
{
// 1.1.pan
// 2.
// 3.weak
_FDFullscreenPopGestureRecognizerDelegate *delegate = objc_getAssociatedObject(self, _cmd);
if (!delegate) {
delegate = [[_FDFullscreenPopGestureRecognizerDelegate alloc] init];
delegate.navigationController = self;
objc_setAssociatedObject(self, _cmd, delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return delegate;
}
- (UIPanGestureRecognizer *)fd_fullscreenPopGestureRecognizer
{
UIPanGestureRecognizer *panGestureRecognizer = objc_getAssociatedObject(self, _cmd);
if (!panGestureRecognizer) {
panGestureRecognizer = [[UIPanGestureRecognizer alloc] init];
panGestureRecognizer.maximumNumberOfTouches = 1;
objc_setAssociatedObject(self, _cmd, panGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return panGestureRecognizer;
}
- (_FDFullRTLScreenPopGestureRecognizerDelegate *)fd_popRTLGestureRecognizerDelegate {
_FDFullRTLScreenPopGestureRecognizerDelegate *rtlDelegate = objc_getAssociatedObject(self, _cmd);
if (!rtlDelegate) {
rtlDelegate = [[_FDFullRTLScreenPopGestureRecognizerDelegate alloc] init];
rtlDelegate.navigationController = self;
objc_setAssociatedObject(self, _cmd, rtlDelegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return rtlDelegate;
}
- (UIScreenEdgePanGestureRecognizer *)fd_rtlFullscreenPopGestureRecognizer {
UIScreenEdgePanGestureRecognizer *rtlPanGestureRecognizer = objc_getAssociatedObject(self, _cmd);
if (!rtlPanGestureRecognizer) {
rtlPanGestureRecognizer = [[RTLEdgePanGesture alloc] init];
rtlPanGestureRecognizer.edges = UIRectEdgeRight;
if (isMSRTL() == NO) {
// APP , APP
rtlPanGestureRecognizer.edges = UIRectEdgeLeft;
}
objc_setAssociatedObject(self, _cmd, rtlPanGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return rtlPanGestureRecognizer;
}
- (BOOL)fd_viewControllerBasedNavigationBarAppearanceEnabled
{
NSNumber *number = objc_getAssociatedObject(self, _cmd);
if (number) {
return number.boolValue;
}
self.fd_viewControllerBasedNavigationBarAppearanceEnabled = YES;
return YES;
}
- (void)setFd_viewControllerBasedNavigationBarAppearanceEnabled:(BOOL)enabled
{
SEL key = @selector(fd_viewControllerBasedNavigationBarAppearanceEnabled);
objc_setAssociatedObject(self, key, @(enabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
#pragma mark - UIViewController (FDFullscreenPopGesture)
@implementation UIViewController (FDFullscreenPopGesture)
- (BOOL)fd_interactivePopDisabled
{
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
- (void)setFd_interactivePopDisabled:(BOOL)disabled
{
objc_setAssociatedObject(self, @selector(fd_interactivePopDisabled), @(disabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)fd_prefersNavigationBarHidden
{
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
- (void)setFd_prefersNavigationBarHidden:(BOOL)hidden
{
objc_setAssociatedObject(self, @selector(fd_prefersNavigationBarHidden), @(hidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (CGFloat)fd_interactivePopMaxAllowedInitialDistanceToLeftEdge
{
#if CGFLOAT_IS_DOUBLE
return [objc_getAssociatedObject(self, _cmd) doubleValue];
#else
return [objc_getAssociatedObject(self, _cmd) floatValue];
#endif
}
- (void)setFd_interactivePopMaxAllowedInitialDistanceToLeftEdge:(CGFloat)distance
{
SEL key = @selector(fd_interactivePopMaxAllowedInitialDistanceToLeftEdge);
objc_setAssociatedObject(self, key, @(MAX(0, distance)), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end

View File

@@ -18,7 +18,7 @@ UIEdgeInsets RSRTLEdgeInsetsWithInsets(UIEdgeInsets insets) {
return insets;
}
+ (void)load{
if (isMSRTL()) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method oldMethod = class_getInstanceMethod(self, @selector(setContentEdgeInsets:));
@@ -33,7 +33,7 @@ UIEdgeInsets RSRTLEdgeInsetsWithInsets(UIEdgeInsets insets) {
Method newTitleMethod = class_getInstanceMethod(self, @selector(msrtl_setTitleEdgeInsets:));
method_exchangeImplementations(oldTitleMethod,newTitleMethod);
});
}
}
- (void)msrtl_setContentEdgeInsets:(UIEdgeInsets)contentEdgeInsets {

View File

@@ -1,37 +0,0 @@
//
// UINavigationController+MSRTL.m
// YuMi
//
// Created by duoban on 2024/4/12.
//
#import "UINavigationController+MSRTL.h"
@implementation UINavigationController (MSRTL)
+ (void)load
{
if (isMSRTL()) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method oldMethod = class_getInstanceMethod(self, @selector(initWithNibName:bundle:));
Method newMethod = class_getInstanceMethod(self, @selector(msrtl_initWithNibName:bundle:));
method_exchangeImplementations(oldMethod, newMethod);
});
}
}
- (instancetype)msrtl_initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
{
if ([self msrtl_initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
if (@available(iOS 9.0, *)) {
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}
}
return self;
}
@end

View File

@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UINavigationController (MSRTL)
@interface UISwipeGestureRecognizer (MSRTL)
@end

View File

@@ -0,0 +1,36 @@
//
// UINavigationController+MSRTL.m
// YuMi
//
// Created by duoban on 2024/4/12.
//
#import "UISwipeGestureRecognizer+MSRTL.h"
@implementation UISwipeGestureRecognizer (MSRTL)
+ (void)load
{
Method oldAttMethod = class_getInstanceMethod(self,@selector(setDirection:));
Method newAttMethod = class_getInstanceMethod(self,@selector(msrtl_setDirection:));
method_exchangeImplementations(oldAttMethod, newAttMethod); //
}
- (void)msrtl_setDirection:(UISwipeGestureRecognizerDirection)direction
{
if (isMSRTL()) {
if (direction == UISwipeGestureRecognizerDirectionRight) {
direction = UISwipeGestureRecognizerDirectionLeft;
} else if (direction == UISwipeGestureRecognizerDirectionLeft) {
direction = UISwipeGestureRecognizerDirectionRight;
}
}
[self msrtl_setDirection:direction];
}
@end

View File

@@ -9,7 +9,7 @@
@implementation UITextField (MSRTL)
+ (void)load {
if(isMSRTL()){
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@@ -28,7 +28,7 @@
Method newMethod = class_getInstanceMethod(self, @selector(msrtl_setAttributedPlaceholder:));
method_exchangeImplementations(oldMethod, newMethod); //
});
}
}

View File

@@ -10,7 +10,7 @@
@implementation UITextView (MSRTL)
+ (void)load {
if(isMSRTL()){
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method oldInitMethod = class_getInstanceMethod(self,@selector(initWithFrame:));
@@ -29,7 +29,7 @@
Method newMethod = class_getInstanceMethod(self, @selector(msrtl_setAttributedPlaceholder:));
method_exchangeImplementations(oldMethod, newMethod); //
});
}
}
- (instancetype)msrtl_initWithFrame:(CGRect)frame {

View File

@@ -73,21 +73,20 @@
[self initSubViewConstraints];
[self.presenter getMineSettingDataSourceWith:self.userInfo];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(setNavVeiw) name:@"kChanecNavView" object:nil];
}
-(void)setNavVeiw{
UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"common_nav_back"]ms_SetImageForRTL] style:UIBarButtonItemStyleDone target:self action:@selector(backClick)];
leftBarButtonItem.tintColor = [DJDKMIMOMColor mainTextColor];
self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.leftBarButtonItem = leftBarButtonItem;
}
-(void)switchLanguage:(NSNotification *)not{
for (UIView *obj in self.view.subviews) {
[obj removeFromSuperview];
}
UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"common_nav_back"]ms_SetImageForRTL] style:UIBarButtonItemStyleDone target:self action:@selector(backClick)];
leftBarButtonItem.tintColor = [DJDKMIMOMColor mainTextColor];
self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.leftBarButtonItem = nil;
if (isMSRTL()){
self.navigationItem.rightBarButtonItem = leftBarButtonItem;
}else{
self.navigationItem.leftBarButtonItem = leftBarButtonItem;
}
[self.presenter clearList];
self.tableView = nil;
self.datasource = nil;

View File

@@ -48,13 +48,13 @@
language = @"ar";
}
if ([language isEqualToString:@"ar"]) {
// [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
[UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
} else {
// [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
[UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
@@ -63,7 +63,10 @@
[NSBundle setLanguageText:language];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kSwitchLanguage" object:language];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter]postNotificationName:@"kChanecNavView" object:language];
[self.navigationController popViewControllerAnimated:YES];
});
}
#pragma mark - UITableViewDelegate And UITableViewDataSource

View File

@@ -234,6 +234,14 @@
self.layer.shadowColor = UIColorRGBAlpha(0xFFFFFF, 0.1).CGColor;
self.layer.shadowOffset = CGSizeMake(0, 5);
self.layer.mask = layer;
if (isMSRTL()) {
self.scrollView.transform = CGAffineTransformMakeRotation(M_PI);
self.stackView.transform = CGAffineTransformMakeRotation(M_PI);
}else{
self.scrollView.transform = CGAffineTransformIdentity;
self.stackView.transform = CGAffineTransformIdentity;
}
}
- (void)initSubViewConstraints {

View File

@@ -95,12 +95,12 @@
- (void)settingButtonAction:(UIButton *)sender {
self.recommendRoomView.frame = CGRectMake(KScreenWidth, 0, 250, KScreenHeight);
FFPopup *popup = [FFPopup popupWithContentView:self.recommendRoomView];
popup.showType = FFPopupShowType_SlideInFromRight;
popup.dismissType = FFPopupDismissType_SlideOutToRight;
popup.showType = isMSRTL() ? FFPopupShowType_SlideInFromLeft:FFPopupShowType_SlideInFromRight;
popup.dismissType = isMSRTL() ? FFPopupDismissType_SlideOutToLeft : FFPopupDismissType_SlideOutToRight;
popup.maskType = FFPopupMaskType_Dimmed;
popup.dimmedMaskAlpha = 0.0;
popup.shouldDismissOnBackgroundTouch = YES;
FFPopupHorizontalLayout horizontalLayout = FFPopupHorizontalLayout_Right;
FFPopupHorizontalLayout horizontalLayout = isMSRTL() ? FFPopupHorizontalLayout_Left : FFPopupHorizontalLayout_Right;
FFPopupVerticalLayout verticalLayout = FFPopupVerticalLayout_Center;
[popup showWithLayout:FFPopupLayoutMake(horizontalLayout, verticalLayout) duration:0.0];
popup.didFinishDismissingBlock = ^{

View File

@@ -58,6 +58,23 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
[self.scrolView addSubview:microView];
}
}
if (isMSRTL()) {
self.scrolView.transform = CGAffineTransformMakeRotation(M_PI);
NSArray *subViews = self.scrolView.subviews;
for (UIView *subView in subViews) {
if ([subView isKindOfClass:[LittleGameMicroView class]]) {
subView.transform = CGAffineTransformMakeRotation(M_PI);
}
}
}else{
self.scrolView.transform = CGAffineTransformIdentity;
NSArray *subViews = self.scrolView.subviews;
for (UIView *subView in subViews) {
if ([subView isKindOfClass:[LittleGameMicroView class]]) {
subView.transform = CGAffineTransformIdentity;
}
}
}
}
return self;
}

View File

@@ -138,6 +138,14 @@
[self.backImageView addSubview:self.fourthBallView];
[self.backImageView addSubview:self.fifthBallView];
self.ballViewList = @[self.firstBallView, self.secondBallView, self.thirdBallView, self.fourthBallView, self.fifthBallView];
if (isMSRTL()) {
self.scrollView.transform = CGAffineTransformMakeRotation(M_PI);
self.backImageView.transform = CGAffineTransformMakeRotation(M_PI);
}else{
self.scrollView.transform = CGAffineTransformIdentity;
self.backImageView.transform = CGAffineTransformIdentity;
}
}
- (void)initSubViewConstraints {

View File

@@ -9,20 +9,39 @@
///Tool
#import "DJDKMIMOMColor.h"
@interface BaseNavigationController ()
@interface BaseNavigationController ()<UIGestureRecognizerDelegate>
@end
@implementation BaseNavigationController
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.delegate = self;
}
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage) name:@"kChanecNavView" object:nil];
[self themeConfig];
if(isMSRTL()){
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}else{
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
-(void)switchLanguage{
if(isMSRTL()){
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}else{
self.navigationBar.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;;
self.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if(self.topViewController == viewController) return;
if (self.childViewControllers.count > 0) {