RTL swipe issue when project has a localized infoPlist (iOS)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- ios, objective-c, react-native
- 領域
- mobile-dev
調査の方向性
アラビア語の iOS ケースを再現し、その後、各 UIPageViewController が構成されている RNCPagerView.m と RNCPagerViewComponentView.mm を調査する。報告されている semantic-content のワークアラウンドと動作を比較する。ローカライズされた Info.plist のサポートにより RTL と LTR の両方で pager のスワイプが機能し、文書化されたテキスト方向の動作を壊していなければ完了とする。
索引モデルが issue の本文から書いたものです。
説明
Environment
This is my current configuration, but I noticed the issue on many different versions and setups as well.
"react": "18.3.1",
"react-native": "0.76.3",
"react-native-pager-view": "6.7.0",
"react-native-gesture-handler": "2.20.2",
"react-native-reanimated": "3.16.1",
Description
I discovered that when the Info.plist is localized for Arabic (RTL language), the swipe gestures in react-native-pager-view become unresponsive.
The pages become "sticky" and cannot be swiped, whereas everything works fine when the device language is set to English or on Android devices it works fine RTL & LTR.
The issue only occurs when these condition are all met:
- Device is in RTL langauge like: Arabic.
2.Its an iOS device. - Xcode project has a localized infoPlist string file or string catalogue.
- The localized infoPlist for the RTL langauge, has a translated string.
1- Example project working fine (Swiping works: ✅) (Simulator lang: AR | Localization file: NO)
Video:
https://github.com/user-attachments/assets/859ed657-b77e-42cd-a7d0-90fdaa360220
2- Example project with issue (Swiping does not work: ❌) (Simulator lang: AR | Localization file: YES)
in this example you can see how swiping does not work. only tapping.
Also you can see how I can't switch between RTL & LTR, its fixed to RTL.
Video:
https://github.com/user-attachments/assets/bf15f8e9-ce47-4851-8cae-e60054275134
Tested on real devices as well, and tried to modify all those variables:
- Native vs JS.
- Fabric On & Off.
- New Architecture On & Off.
The issue still stays the same.
Reproducible Demo
- Create a new React Native project and install react-native-pager-view.
- Add RTL language to the xcode project.
- Localize the Info.plist file to include Arabic, and add translation to app name for example.
- Implement react-native-pager-view in your project.
- Change the device language to Arabic.
- Run the app on an iOS device/simulator and observe that the swipe gestures for the pager do not work properly - and pages become stuck.
Temporary fix
I was able to apply a fix that solved it for me temporrary.
It appears that the UIPageViewController is inheriting an RTL layout from the localized Info.plist, which interferes with the swipe gestures.
A temporary workaround is to force the UIPageViewController's view layout to left-to-right by adding the following line here in package file:
File: RNCPagerView.m
before this line:
pageViewController.delegate = self;
pageViewController.dataSource = self;
I added:
//force ltr layout to restore swipe gesture
pageViewController.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
File: RNCPagerViewComponentView.mm (for fabric)
before this line:
_nativePageViewController.dataSource = self;
_nativePageViewController.delegate = self;
I added:
//force ltr layout to restore swipe gesture
_nativePageViewController.view.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
This fixed it for me I can swipe normally on RTL & LTR, and it did not break RTL & LTR layout support.
The only thing I noticed is that if a I have a component that does not have a textAlign assigned, I will have to assign it to avoid LTR direction by defualt when device is LTR but app is RTL.
Another fix:
I noticed that adding the same change to project file AppDelegate.m fixes it too:
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
within didFinishLaunchingWithOptions.
Localized InfoPlist example
example of localized InfoPlist.xcstrings file you can use to reporoduce this, make sure Arabic is added to the supported project localizations.
{
"sourceLanguage" : "en",
"strings" : {
"CFBundleDisplayName" : {
"comment" : "Bundle display name",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "translated",
"value" : "عرض الصفحات"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "PagerViewExample"
}
}
}
},
"CFBundleName" : {
"comment" : "Bundle name",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "ReactTestApp"
}
}
}
},
"NSCameraUsageDescription" : {
"comment" : "Privacy - Camera Usage Description",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "The camera is needed to scan QR codes for JS bundle URLs"
}
}
}
}
},
"version" : "1.0"
}
- 主要言語
- TypeScript
- スター
- 3.4k
- フォーク
- 485
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 24
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
callstack/react-native-pager-view のほかの issue
-
iOS: PagerScrollDelegate proxies to itself and overflows the stack when the weak originalDelegate dies対応中かも @lvlrSajjad が 35 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
callstack/react-native-pager-view#1146 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
callstack/react-native-pager-view#1144 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
callstack/react-native-pager-view#1141 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
callstack/react-native-pager-view#1099 · コメント 8 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
callstack/react-native-pager-view#1081 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
callstack/react-native-pager-view の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
chrisparsons83/flexspotff#215 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vitest-dev/vitest#11633 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信