Skip to content

Commit ad76c6a

Browse files
authored
feat: compound KeyboardToolbar (#1125)
## 📜 Description Added compound pattern to `KeyboardToolbar` component. ## 💡 Motivation and Context This component started as a very simple component with limited customization. However, over the time it got many new props, such as `onNextCallback` etc. and right now we have too many props for customization. Since I'm planning to add #881 I decided that it'll be a good time to refactor the component and apply compound pattern. So in the end I come up with next API design: ```tsx <KeyboardToolbar> <KeyboardToolbar.Background /> <KeyboardToolbar.Prev /> <KeyboardToolbar.Next /> <KeyboardToolbar.Content /> <KeyboardToolbar.Done /> </KeyboardToolbar> ``` > I intentionally changed `blur` prop to `background`, because with iOS 26 we may use liquid glass as a container Closes #1121 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - added new compound `KeyboardToolbar` API; - moved props declaration into `types.ts` file. ### Docs - added new API reference; - added migration guide. ## 🤔 How Has This Been Tested? - tested that old code works with new API and doesn't introduce visual regressions (via e2e tests) - started to use new API and assure that it doesn't break e2e tests. ## 📸 Screenshots (if appropriate): <img width="614" height="422" alt="image" src="https://github.com/user-attachments/assets/8d2cc932-7fd8-4f29-89d4-bf4961bd97dc" /> ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 5c8faca commit ad76c6a

File tree

14 files changed

+772
-306
lines changed

14 files changed

+772
-306
lines changed

FabricExample/src/screens/Examples/AwareScrollView/styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ export const styles = StyleSheet.create({
3838
borderRadius: 8,
3939
paddingHorizontal: 12,
4040
},
41+
bottomSheetContent: {
42+
flex: 1,
43+
},
4144
});

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-
);

0 commit comments

Comments
 (0)