Skip to content

Commit 3313cb4

Browse files
committed
refactor: revision after self review
1 parent f470b19 commit 3313cb4

6 files changed

Lines changed: 46 additions & 42 deletions

File tree

FabricExample/src/screens/Examples/Toolbar/index.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,26 @@ function Form() {
156156
/>
157157
</KeyboardAwareScrollView>
158158
<KeyboardToolbar
159-
blur={blur}
160-
content={
161-
showAutoFill ? (
162-
<AutoFillContacts onContactSelected={onContactSelected} />
163-
) : null
164-
}
165159
insets={insets}
166160
opacity={Platform.OS === "ios" ? "4F" : "DD"}
167-
onDoneCallback={haptic}
168-
onNextCallback={haptic}
169-
onPrevCallback={haptic}
170-
/>
161+
>
162+
<KeyboardToolbar.Background>
163+
<BlurView
164+
blurAmount={32}
165+
blurType={Platform.OS === "ios" ? "chromeMaterial" : "light"}
166+
reducedTransparencyFallbackColor="white"
167+
style={styles.absolute}
168+
/>
169+
</KeyboardToolbar.Background>
170+
<KeyboardToolbar.Content>
171+
{showAutoFill ? (
172+
<AutoFillContacts onContactSelected={onContactSelected} />
173+
) : null}
174+
</KeyboardToolbar.Content>
175+
<KeyboardToolbar.Prev onPress={haptic} />
176+
<KeyboardToolbar.Next onPress={haptic} />
177+
<KeyboardToolbar.Done onPress={haptic} />
178+
</KeyboardToolbar>
171179
</>
172180
);
173181
}
@@ -238,12 +246,3 @@ const styles = StyleSheet.create({
238246
marginTop: 32,
239247
},
240248
});
241-
242-
const blur = (
243-
<BlurView
244-
blurAmount={32}
245-
blurType={Platform.OS === "ios" ? "chromeMaterial" : "light"}
246-
reducedTransparencyFallbackColor="white"
247-
style={styles.absolute}
248-
/>
249-
);

docs/docs/api/components/keyboard-toolbar/index.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@ To migrate from the legacy prop-based API to the compound API:
535535
</KeyboardToolbar>
536536
```
537537

538+
:::info Struggle to migrate?
539+
540+
If you found any bugs or inconsistent behavior comparing to old implementation and can not migrate to new compound API - don't hesitate to open an [issue](https://github.com/kirillzyusko/react-native-keyboard-controller/issues/new?assignees=kirillzyusko&labels=bug&template=bug_report.md&title=). It will help the project 🙏
541+
542+
:::
543+
538544
## Limitations
539545

540546
- By default `TextInput` search happens within `UIViewController`/`FragmentActivity` (current screen if you are using `react-native-screens`)

example/src/screens/Examples/Toolbar/index.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,26 @@ function Form() {
156156
/>
157157
</KeyboardAwareScrollView>
158158
<KeyboardToolbar
159-
blur={blur}
160-
content={
161-
showAutoFill ? (
162-
<AutoFillContacts onContactSelected={onContactSelected} />
163-
) : null
164-
}
165159
insets={insets}
166160
opacity={Platform.OS === "ios" ? "4F" : "DD"}
167-
onDoneCallback={haptic}
168-
onNextCallback={haptic}
169-
onPrevCallback={haptic}
170-
/>
161+
>
162+
<KeyboardToolbar.Background>
163+
<BlurView
164+
blurAmount={32}
165+
blurType={Platform.OS === "ios" ? "chromeMaterial" : "light"}
166+
reducedTransparencyFallbackColor="white"
167+
style={styles.absolute}
168+
/>
169+
</KeyboardToolbar.Background>
170+
<KeyboardToolbar.Content>
171+
{showAutoFill ? (
172+
<AutoFillContacts onContactSelected={onContactSelected} />
173+
) : null}
174+
</KeyboardToolbar.Content>
175+
<KeyboardToolbar.Prev onPress={haptic} />
176+
<KeyboardToolbar.Next onPress={haptic} />
177+
<KeyboardToolbar.Done onPress={haptic} />
178+
</KeyboardToolbar>
171179
</>
172180
);
173181
}
@@ -238,12 +246,3 @@ const styles = StyleSheet.create({
238246
marginTop: 32,
239247
},
240248
});
241-
242-
const blur = (
243-
<BlurView
244-
blurAmount={32}
245-
blurType={Platform.OS === "ios" ? "chromeMaterial" : "light"}
246-
reducedTransparencyFallbackColor="white"
247-
style={styles.absolute}
248-
/>
249-
);

src/components/KeyboardToolbar/compound/components/Done.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { useCallback, useMemo } from "react";
33
import { StyleSheet, Text } from "react-native";
44

5+
import { useKeyboardState } from "../../../../hooks";
56
import { KeyboardController } from "../../../../module";
67
import Button from "../../Button";
78
import { TEST_ID_KEYBOARD_TOOLBAR_DONE } from "../../constants";
@@ -18,8 +19,9 @@ const Done: React.FC<Omit<ButtonSubProps, "icon"> & { text?: ReactNode }> = ({
1819
text,
1920
button: ButtonContainer = Button,
2021
}) => {
22+
const colorScheme = useKeyboardState((state) => state.appearance);
2123
const context = useToolbarContext();
22-
const { theme, colorScheme } = context;
24+
const { theme } = context;
2325

2426
const doneStyle = useMemo(
2527
() => [styles.doneButton, { color: theme[colorScheme].primary }],

src/components/KeyboardToolbar/compound/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { KeyboardToolbarTheme } from "../types";
44

55
type ToolbarContextType = {
66
theme: KeyboardToolbarTheme;
7-
colorScheme: "light" | "dark";
87
isPrevDisabled: boolean;
98
isNextDisabled: boolean;
109
};

src/components/KeyboardToolbar/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> & {
178178
const contextValue = useMemo(
179179
() => ({
180180
theme,
181-
colorScheme,
182181
isPrevDisabled,
183182
isNextDisabled,
184183
}),
185-
[theme, colorScheme, button, icon, isPrevDisabled, isNextDisabled],
184+
[theme, isPrevDisabled, isNextDisabled],
186185
);
187186

188187
return (

0 commit comments

Comments
 (0)