| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import {
- useLayoutEffect
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- SystemToolbar,
- PageContainer,
- CodeViewer,
- Header,
- Text
- } from "ncore-ui-kit";
- import {
- useNavigation
- } from "@react-navigation/native";
- import type RootStackParamList from "../../../navigation/type";
- import type {
- NativeStackNavigationProp
- } from "@react-navigation/native-stack";
- import {
- SettingsIcon,
- LogOutIcon,
- UserIcon,
- MenuIcon,
- HomeIcon
- } from "lucide-react-native";
- const SystemToolbarPage = () => {
- const {
- radiuses,
- borders,
- spaces,
- colors
- } = NCoreUIKitTheme.useContext();
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- title={localize("systemToolbar-title")}
- isWrapSafeareaContext={false}
- navigation={navigation}
- isGoBackEnable={true}
- />,
- headerShown: true
- });
- }, [
- navigation,
- localize
- ]);
- return <PageContainer
- scrollViewProps={{
- contentContainerStyle: stylesheet.scrollContent
- }}
- isWorkWithHeaderSpace={false}
- scrollViewStyle={[
- stylesheet.container
- ]}
- isScrollable={true}
- >
- <View
- style={[
- stylesheet.contentContainer
- ]}
- >
- <Text
- style={stylesheet.marginContainer}
- variant="bodyMediumSize"
- color="mid"
- >
- {localize("systemToolbar-desc")}
- </Text>
- <View
- style={[
- stylesheet.previewContainer,
- {
- borderColor: colors.content.border.subtle,
- marginBottom: spaces.spacingMd,
- borderRadius: radiuses.form,
- borderWidth: borders.line,
- padding: spaces.spacingMd
- }
- ]}
- >
- <SystemToolbar
- actions={[
- {
- onPress: () => console.log("Settings pressed"),
- icon: ({
- color,
- size
- }) => <SettingsIcon
- color={colors.content.icon[color]}
- size={size}
- />,
- titleKey: "menu-settings"
- },
- {
- content: [
- {
- icon: ({
- color,
- size
- }) => <HomeIcon
- color={colors.content.icon[color]}
- size={size}
- />,
- onPress: () => console.log("Home"),
- titleKey: "menu-home"
- },
- {
- icon: ({
- color,
- size
- }) => <LogOutIcon
- color={colors.content.icon[color]}
- size={size}
- />,
- onPress: () => console.log("Logout"),
- titleKey: "close"
- }
- ],
- icon: ({
- color,
- size
- }) => <UserIcon
- color={colors.content.icon[color]}
- size={size}
- />,
- titleKey: "avatar-title"
- }
- ]}
- icon={({
- color,
- size
- }) => <MenuIcon
- color={colors.content.icon[color]}
- size={size}
- />}
- titleKey="menu-title"
- />
- </View>
- <View
- style={{
- marginBottom: spaces.spacingMd
- }}
- >
- <Text
- style={{
- marginBottom: spaces.spacingSm
- }}
- variant="headlineSmallSize"
- >
- {localize("usage")}
- </Text>
- <CodeViewer
- code={"import {\n SystemToolbar\n} from \"ncore-ui-kit\";\nimport {\n Settings,\n User,\n LogOut,\n Menu,\n Home\n} from \"lucide-react-native\";\n\n<SystemToolbar\n titleKey=\"menu\"\n icon={({ color, size }) => <Menu color={colors.content.icon[color]} size={size} />}\n actions={[\n {\n titleKey: \"menu-settings\",\n icon: ({ color, size }) => <Settings color={colors.content.icon[color]} size={size} />,\n onPress: () => console.log(\"Settings pressed\")\n }\n ]}\n/>"}
- language="tsx"
- />
- </View>
- </View>
- </PageContainer>;
- };
- export default SystemToolbarPage;
|