Skip to content

Conversation

@CatchABus
Copy link
Contributor

@CatchABus CatchABus commented Feb 5, 2025

PR Checklist

What is the current behavior?

Right now, core has no support for enforcing a layout direction.

What is the new behavior?

Added css direction inherited property for a minimal RTL support.
This property will use the native APIs of each platform which means that enforcing a layout direction will automatically provide the default native direction experience.

For example, iOS UINavigationBar will align back button to the right in the case of RTL.

The following cases will additionally be affected by layout direction:

  • Navigation transition
    • The regular slide transition will slide to the right in the case of RTL direction
    • The regular flip transition will flip to the left in the case of RTL direction (it used to and will flip to the right in the case of LTR)
  • Corrected the iOS button text alignment. Core demands that the default is center just like android
  • Added support for start and end values to horizontalAlignment property in order for views to be able to align based on layout direction
  • The Label default or initial text alignment shall respect the layout direction
  • Added hasRtlSupport helper function to determine whether an app supports RTL (it's always true for iOS)
  • Regarding iOS horizontal ScrollView, the initial scrollbar position will align to the end in the case of RTL direction (this was a default on android)
  • Added missing iOS FlexboxLayout layout direction support for flex alignment and direction
  • Added support for affecting text-overflow ellipsis dot position based on new direction property

Few things to consider:

  • Text alignment does not support start and end values yet. It's doable but will require extra workaround for iOS since it only provides left and right for aligning to each side. For the time being, users can rely on text-align: initial the default of which is left for LTR and right for RTL
  • Android does not support RTL by default. Users will have to append the android:supportsRtl="true" flag to Application tag in AndroidManifest.xml in order to support it

NativeScript app templates shall not support RTL by default since it adds extra burden to layout and processing and it's a feature meant for a small number of languages.
User is responsible to enable RTL in one's own app using android:supportsRtl="true".

This PR adds a set a features to have as many needs as possible based on #7094 #9465 requests.
Fixes/Implements/Closes #6051 #6156.

@kefahB
Copy link
Contributor

kefahB commented Jul 14, 2025

Hello @CatchABus,

Maybe we can consider add flag like ´rtl´to the NS cli, this will add extra stuff for android and maybe IOS.

Yes it is for a small number of language, but if NS gain full support for arabic and asiatic languages, it will be a new huge market.

@CatchABus CatchABus marked this pull request as ready for review November 5, 2025 23:34
@nx-cloud
Copy link

nx-cloud bot commented Nov 5, 2025

View your CI Pipeline Execution ↗ for commit f82dc3d

Command Status Duration Result
nx test apps-automated -c=ios ✅ Succeeded 2m 57s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-06 00:00:33 UTC

@CatchABus CatchABus marked this pull request as draft November 5, 2025 23:47
@CatchABus CatchABus marked this pull request as ready for review November 6, 2025 00:06
@NathanWalker NathanWalker requested a review from Copilot November 6, 2025 00:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Right-to-Left (RTL) layout support to NativeScript Core. It introduces a new direction CSS property that allows developers to control layout direction at the view level, with support for automatic detection based on system settings on both iOS and Android platforms.

  • Adds RTL support through a new direction CSS property with values ltr, rtl, and null (default/inherit)
  • Implements platform-specific layout direction detection and handling for iOS and Android
  • Updates text components (Label, Button, TextField, TextView) to properly handle text ellipsis based on direction
  • Extends horizontal alignment to support logical start and end values alongside physical left and right

Reviewed Changes

Copilot reviewed 41 out of 48 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tools/assets/App_Resources/Android/src/main/AndroidManifest.xml Enables RTL support in Android manifest and fixes indentation
packages/core/utils/layout-helper/index.*.ts Adds hasRtlSupport() function to detect RTL capability
packages/core/ui/styling/style-properties.ts Registers the direction CSS property
packages/core/ui/core/view/index.*.ts Implements native direction setters for iOS and Android
packages/core/ui/text-base/index.*.ts Updates text alignment and ellipsis handling for RTL
packages/core/ui/text-field/index.ios.ts Adds direction-aware line breaking for text fields
packages/core/ui/text-view/index.ios.ts Adds direction-aware line breaking for text views
packages/core/ui/label/index.*.ts Adds direction-aware ellipsis positioning
packages/core/ui/button/index.*.ts Updates button text alignment and ellipsis for RTL
packages/core/ui/layouts/*/index.ios.ts Updates layout calculations for RTL in FlexboxLayout and StackLayout
packages/core/ui/scroll-view/index.ios.ts Implements RTL-aware scroll position initialization
packages/core/ui/frame/index.*.ts Updates navigation transitions to respect RTL direction
packages/core/application/application*.ts Adds layout direction detection and change events
packages/core/core-types/index.ts Defines LayoutDirectionType and adds start/end to horizontal alignment
apps/automated/src/ui/label/label-tests*.ts Updates tests for RTL support
apps/automated/src/application/application-tests.*.ts Adds layout direction initialization tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { ScrollView as ScrollViewDefinition, ScrollEventData } from '.';
import { ContentView } from '../content-view';
import { profile } from '../../profiling';
import { ContentView } from '../content-view';
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused imports but the change also removes interface augmentation and type definitions. This could be a breaking change if external code references ScrollViewBase.on(event: 'scroll', ...) signature.

Copilot uses AI. Check for mistakes.
@NathanWalker NathanWalker merged commit e434373 into NativeScript:main Nov 6, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android align-text bug with Arabic characters

3 participants