Skip to content

Commit e281db0

Browse files
committed
Improve onboarding loader docs
1 parent 0a72b75 commit e281db0

2 files changed

Lines changed: 124 additions & 5 deletions

File tree

versioned_docs/version-3.0/flutter-present-onboardings.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,38 @@ class MainActivity : FlutterFragmentActivity() {
110110

111111
## Loader during onboarding
112112

113-
By default, between the splash screen and onboarding, you will see the loading screen until the onboarding is fully loaded. However, if you want to make the transition smoother, you can override this in your Flutter app:
113+
When presenting an onboarding, you may notice a short loading screen between your splash screen and the onboarding while the underlying view is being initialized. You can handle this in different ways depending on your needs.
114114

115-
- To customize the native loader on iOS, add `AdaptyOnboardingPlaceholderView.xib` to your Xcode project.
116-
- For full control, overlay your own widget above `AdaptyUIOnboardingPlatformView` and hide it on `onDidFinishLoading`.
117-
- To customize the native loader on Android, create `adapty_onboarding_placeholder_view.xml` in `res/layout` and define a placeholder there.
115+
#### Control splash screen using onDidFinishLoading
118116

119-
This helps create seamless transitions and custom loading experiences.
117+
:::note
118+
This approach is only available when embedding the onboarding as a widget. It is not available for standalone screen presentation.
119+
:::
120+
121+
The recommended cross-platform approach is to keep your splash screen or custom overlay visible until the onboarding is fully loaded, then hide it manually.
122+
123+
When using the embedded widget, overlay your own widget above it and hide the overlay when `onDidFinishLoading` fires:
124+
125+
```dart showLineNumbers title="Flutter"
126+
AdaptyUIOnboardingPlatformView(
127+
onboarding: onboarding,
128+
onDidFinishLoading: (meta) {
129+
// Hide your custom splash screen or overlay here
130+
},
131+
// ... other callbacks
132+
)
133+
```
134+
135+
### Customize native loader
136+
137+
:::important
138+
This approach is platform-specific and requires maintaining native UI code. It's not recommended unless you already maintain separate native layers in your app.
139+
:::
140+
141+
If you need to customize the default loader itself, you can replace it with platform-specific layouts. This approach requires separate implementations for Android and iOS:
142+
143+
- **iOS**: Add `AdaptyOnboardingPlaceholderView.xib` to your Xcode project
144+
- **Android**: Create `adapty_onboarding_placeholder_view.xml` in `res/layout` and define a placeholder there
120145

121146
## Customize how links open in onboardings
122147

versioned_docs/version-3.0/react-native-present-onboardings.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,100 @@ try {
160160
}
161161
```
162162

163+
## Loader during onboarding
164+
165+
When presenting an onboarding in React Native, you may notice a short white flash or loading screen before the onboarding appears. This happens while the underlying native view is being initialized. You can handle this in different ways depending on your needs and your workflow.
166+
167+
#### Control splash screen using onFinishedLoading
168+
169+
:::note
170+
This approach is only available when using the React component. It is not available for modal presentation.
171+
:::
172+
173+
The recommended approach for React Native is to keep your splash screen or a custom overlay visible until the onboarding is fully loaded, then hide it manually.
174+
175+
When using the React component (`AdaptyOnboardingView`), wait for the `onFinishedLoading` event before hiding your splash screen or overlay:
176+
177+
<Tabs groupId="version" queryString>
178+
<TabItem value="new" label="SDK version 3.14 or later" default>
179+
180+
```typescript showLineNumbers title="React Native (TSX)"
181+
import React, { useCallback, useState } from 'react';
182+
import { AdaptyOnboardingView } from 'react-native-adapty';
183+
import type { OnboardingEventHandlers } from 'react-native-adapty';
184+
185+
function MyOnboarding({ onboarding }) {
186+
const [isLoading, setIsLoading] = useState(true);
187+
188+
const onFinishedLoading = useCallback<OnboardingEventHandlers['onFinishedLoading']>((meta) => {
189+
// Hide your splash screen or custom overlay here
190+
setIsLoading(false);
191+
}, []);
192+
193+
return (
194+
<>
195+
<AdaptyOnboardingView
196+
onboarding={onboarding}
197+
style={styles.container}
198+
onFinishedLoading={onFinishedLoading}
199+
// ... other callbacks
200+
/>
201+
{isLoading && <YourCustomLoadingOverlay />}
202+
</>
203+
);
204+
}
205+
```
206+
207+
</TabItem>
208+
209+
<TabItem value="old" label="SDK version < 3.14">
210+
211+
```typescript showLineNumbers title="React Native (TSX)"
212+
import React, { useState } from 'react';
213+
import { AdaptyOnboardingView } from 'react-native-adapty';
214+
215+
function MyOnboarding({ onboarding }) {
216+
const [isLoading, setIsLoading] = useState(true);
217+
218+
return (
219+
<>
220+
<AdaptyOnboardingView
221+
onboarding={onboarding}
222+
style={{ flex: 1 }}
223+
eventHandlers={{
224+
onFinishedLoading(meta) {
225+
// Hide your splash screen or custom overlay here
226+
setIsLoading(false);
227+
},
228+
// ... other handlers
229+
}}
230+
/>
231+
{isLoading && <YourCustomLoadingOverlay />}
232+
</>
233+
);
234+
}
235+
```
236+
237+
</TabItem>
238+
</Tabs>
239+
240+
#### Customize native loader
241+
242+
:::important
243+
Expo does not support placing custom native layouts (e.g., `res/layout` on Android). For Expo apps, controlling the splash screen or using a React Native overlay is the only viable solution.
244+
:::
245+
246+
You can replace the native loader using platform-specific layouts on Android and iOS. However, this approach is usually less convenient for React Native apps:
247+
248+
- Requires separate Android and iOS implementations
249+
- Not compatible with Expo (Expo doesn't allow adding custom native layouts)
250+
- Higher maintenance cost
251+
252+
Define a placeholder for each platform:
253+
254+
- **iOS**: Add `AdaptyOnboardingPlaceholderView.xib` to your Xcode project
255+
- **Android**: Create `adapty_onboarding_placeholder_view.xml` in `res/layout` and define a placeholder there
256+
163257
## Customize how links open in onboardings
164258

165259
:::important

0 commit comments

Comments
 (0)