Skip to content

Commit ff13656

Browse files
committed
translate
1 parent 975b6e2 commit ff13656

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

docs/HOWTO.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
# Адаптивная верстка на React Native
22

3-
> Описание проблем, возникших при портировании классического React приложения в React Native можно прочитать в этой статье. Речь идет о поддержке различных форм факторов устройств, в том числе, Galaxy Fold
3+
> The challenges encountered when porting a classic React application to React Native are discussed in this article. It focuses on supporting various device form factors, including the Galaxy Fold.
44
55
## Проблема
66

7-
Некоторое время назад начал разработку мобильного приложения на React Native. Проблема в том, что требованием к приложению является Galaxy Fold и Samsung DeX
7+
Some time ago, I started developing a mobile application with React Native. The issue is that the application needs to support both the Galaxy Fold and Samsung DeX.
88

99
![fold](../assets/fold.png)
1010

11-
Как следствие, встал вопрос реализации адаптивной верстки форм.Одно и тоже приложение должно рисовать формы в одну колонку в режиме телефона и две колонки в режиме планшета. Если писать разный код компоновок, придется дублировать логику форм, как минимум, новое поле добавляется два раза.
12-
11+
As a result, the question of implementing adaptive layout forms arose. The same application needs to render forms in a single column mode on phones and two columns in tablet mode. If different layout codes are written, it would require duplicating form logic; at the very least, a new field would be added twice.
1312
![dex](../assets/dex.png)
1413

15-
Yoga Layout, движок верстки из React Native, поддерживает только flexbox. В результате, грамотно реализовать верстку, избегая излишней вложенности View, является нетривиальной задачей: вложенные группы должны отображаться от верхнего края родителя, поля ввода должны равняться на нижний край строки отображения (baseline)
14+
Yoga Layout, the layout engine from React Native, only supports flexbox. Consequently, implementing layouts correctly while avoiding excessive nesting of Views is a non-trivial task: nested groups must be displayed from the top edge of the parent, and input fields must align to the bottom edge of the display line (baseline).
1615

1716
![top_baseline](../assets/top_baseline.png)
1817

19-
Если принебречь правилом привязки групп полей к верхнему краю, получится уродство
18+
Ignoring the rule of binding field groups to the top edge results in an ugly layout.
2019

2120
![bottom_baseline_issue](../assets/bottom_baseline_issue.png)
2221

23-
Поля внутри группы должны быть привязаны к нижнему краю строки
22+
Fields within a group should be bound to the bottom edge of the row.
2423

2524
![bottom_baseline](../assets/bottom_baseline.png)
2625

27-
Уродство при верхнем baseline для полей не очевидно с первого взгляда, но очень бросается при использование standard полей из Material 1 на Android 4
26+
The ugliness of having a top baseline for fields is not immediately obvious but becomes very noticeable when using standard fields from Material 1 on Android 4.
2827

2928
![top_baseline_issue](../assets/top_baseline_issue.png)
3029

31-
## Решение проблемы
30+
## Solution
3231

33-
Для того, чтобы делегировать сложную задачу грамотной компоновки форм более дешевому специалисту, был разработан шаблонизатор, генерирующий верстку по указанным выше правилам из JSON шаблона. Пример шаблона в блоке кода ниже
32+
To delegate the complex task of proper form layout to a less specialized developer, a templating system was developed that generates layouts according to the rules mentioned above from a JSON template. An example template is shown in the code block below:
3433

3534
```tsx
3635
import { One, FieldType, TypedField } from 'rn-declarative';
@@ -131,7 +130,7 @@ export const MainPage = () => {
131130
export default MainPage;
132131
```
133132
134-
Библиотека разделена на два модуля: [rn-declarative](https://www.npmjs.com/package/rn-declarative) и [rn-declarative-eva](https://www.npmjs.com/package/rn-declarative-eva). Первая содержит базовую логику и не зависит от UI kit: может быть установлена в любом проекте не зависимо от версии `react-native` или фреймворка (поддерживается как `Expo`, так и starter kit от `react-native-community`). Кроме `react` и `react-native` других зависимостей нет.
133+
The library is divided into two modules: [rn-declarative](https://www.npmjs.com/package/rn-declarative) and [rn-declarative-eva](https://www.npmjs.com/package/rn-declarative-eva) . The first contains the core logic and does not depend on a UI kit: it can be installed in any project regardless of the `react-native` version or framework (both `Expo` and `react-native-community` starter kits are supported). Besides `react` and `react-native`, there are no other dependencies.
135134
136135
```tsx
137136
import { useMediaContext } from 'rn-declarative'
@@ -141,7 +140,7 @@ import { useMediaContext } from 'rn-declarative'
141140
const { isPhone, isTablet, isDesktop } = useMediaContext();
142141
```
143142
144-
Настройка ширины компоновок и полей осуществляется через свойства объектов `phoneStyle`, `tabletStyle` и `desktopStyle`. Если не хотим менять стиль исходя из форм-фактора устройства, можно написать просто `style`. Подключение UI Kit осуществляется через контекст с слотами `<OneSlotFactory />` для подключения реализации `FieldType`.
143+
Layout and field widths are configured using `phoneStyle`, `tabletStyle`, and `desktopStyle` properties. If you don't want to change the style based on the device form factor, you can just use `style`. Connecting a UI Kit is done through the context with slots `<OneSlotFactory />` for implementing `FieldType`.
145144
146145
```tsx
147146
import { Toggle } from '@ui-kitten/components';
@@ -190,7 +189,7 @@ const defaultSlots = {
190189
</OneSlotFactory>
191190
```
192191
193-
P.S. Любой другой компонент или пользовательскую верстку можно прозрачно интегрировать через `FieldType.Component` (есть `onChange` и `value`) или `FieldType.Layout`
192+
P.S. Any other component or custom layout can be seamlessly integrated through `FieldType.Component` (with `onChange` and `value`) or `FieldType.Layout`.
194193
195194
```tsx
196195
{
@@ -214,7 +213,7 @@ P.S. Любой другой компонент или пользователь
214213
},
215214
```
216215
217-
Код компонента опубликован на Github, посмотреть можно по ссылке:
218-
[https://github.com/react-declarative/rn-declarative/](https://github.com/react-declarative/rn-declarative/)
216+
The component code is published on GitHub and can be viewed at:
217+
[https://github.com/react-declarative/rn-declarative/](https://github.com/react-declarative/rn-declarative/)
219218
220-
Спасибо за внимание!
219+
Thank you for your attention!

0 commit comments

Comments
 (0)