You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/HOWTO.md
+15-16
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,35 @@
1
1
# Адаптивная верстка на React Native
2
2
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.
4
4
5
5
## Проблема
6
6
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.
8
8
9
9

10
10
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.
13
12

14
13
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).
16
15
17
16

18
17
19
-
Если принебречь правилом привязки групп полей к верхнему краю, получится уродство
18
+
Ignoring the rule of binding field groups to the top edge results in an ugly layout.
Поля внутри группы должны быть привязаны к нижнему краю строки
22
+
Fields within a group should be bound to the bottom edge of the row.
24
23
25
24

26
25
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.
Для того, чтобы делегировать сложную задачу грамотной компоновки форм более дешевому специалисту, был разработан шаблонизатор, генерирующий верстку по указанным выше правилам из 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:
Библиотека разделена на два модуля: [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.
135
134
136
135
```tsx
137
136
import { useMediaContext } from'rn-declarative'
@@ -141,7 +140,7 @@ import { useMediaContext } from 'rn-declarative'
Настройка ширины компоновок и полей осуществляется через свойства объектов `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`.
145
144
146
145
```tsx
147
146
import { Toggle } from'@ui-kitten/components';
@@ -190,7 +189,7 @@ const defaultSlots = {
190
189
</OneSlotFactory>
191
190
```
192
191
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`.
194
193
195
194
```tsx
196
195
{
@@ -214,7 +213,7 @@ P.S. Любой другой компонент или пользователь
214
213
},
215
214
```
216
215
217
-
Код компонента опубликован на Github, посмотреть можно по ссылке:
0 commit comments